private boolean isMultilineSelection() { ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection ts= (ITextSelection) selection; return ts.getStartLine() != ts.getEndLine(); } return false; }
private boolean isMultilineSelection() { ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection ts= (ITextSelection) selection; return ts.getStartLine() != ts.getEndLine(); } return false; }
private int getElementAfterCursorPosition(CompilationUnitEditor editor, IJavaElement[] members) throws JavaModelException { if (editor == null) { return -1; } int offset= ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset(); for (int i= 0; i < members.length; i++) { IMember curr= (IMember) members[i]; ISourceRange range= curr.getSourceRange(); if (offset < range.getOffset()) { return i; } } return members.length; }
private int getElementAfterCursorPosition(CompilationUnitEditor editor, IJavaElement[] members) throws JavaModelException { if (editor == null) { return -1; } int offset= ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset(); for (int i= 0; i < members.length; i++) { IMember curr= (IMember) members[i]; ISourceRange range= curr.getSourceRange(); if (offset < range.getOffset()) { return i; } } return members.length; }
private boolean hasCursorPositionElement(CompilationUnitEditor editor, IJavaElement[] members, List insertPositions) throws JavaModelException { if (editor == null) { return false; } int offset= ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset(); for (int i= 0; i < members.length; i++) { IMember curr= (IMember) members[i]; ISourceRange range= curr.getSourceRange(); if (offset < range.getOffset()) { insertPositions.add(curr); return true; } else if (offset < range.getOffset() + range.getLength()) { return false; // in the middle of a member } } insertPositions.add(null); return true; }
@Override public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); }
public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); }
@Override public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); }
/** * The Menu to show when right click on the editor * {@inheritDoc} */ @Override public void fillContextMenu(IMenuManager menu) { ISelectionProvider selectionProvider= fEditor.getSelectionProvider(); if (selectionProvider == null) return; ISelection selection= selectionProvider.getSelection(); if (!(selection instanceof ITextSelection)) return; ITextSelection textSelection= (ITextSelection)selection; if (textSelection.getLength() == 0) return; String menuText= ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName; MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID); subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID); menu.appendToGroup(fGroup, subMenu); subMenu.add(new Action() {}); subMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { manager.removeAll(); SurroundWithTemplateMenuAction.fillMenu(manager, fEditor, fSurroundWithTryCatchAction, fSurroundWithTryMultiCatchAction); } }); }
/** * The Menu to show when right click on the editor * {@inheritDoc} */ @Override public void fillContextMenu(IMenuManager menu) { ISelectionProvider selectionProvider= fEditor.getSelectionProvider(); if (selectionProvider == null) return; ISelection selection= selectionProvider.getSelection(); if (!(selection instanceof ITextSelection)) return; ITextSelection textSelection= (ITextSelection)selection; if (textSelection.getLength() == 0) return; String menuText= ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName; MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID); subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID); menu.appendToGroup(fGroup, subMenu); subMenu.add(new Action() {}); subMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { manager.removeAll(); SurroundWithTemplateMenuAction.fillMenu(manager, fEditor, fSurroundWithTryCatchAction, fSurroundWithTryMultiCatchAction); } }); }
ISelectionProvider selectionProvider= fEditor.getSelectionProvider(); if (selectionProvider == null) return;
public static void fillMenu(IMenuManager menu, CompilationUnitEditor editor, SurroundWithTryCatchAction surroundWithTryCatchAction) { IAction[] actions= getTemplateActions(editor); surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection()); if (actions == null && !surroundWithTryCatchAction.isEnabled()) { menu.add(NONE_APPLICABLE_ACTION); } else { menu.add(surroundWithTryCatchAction); menu.add(new Separator(TEMPLATE_GROUP)); if (actions == null) { menu.add(NONE_APPLICABLE_ACTION); } else { for (int i= 0; i < actions.length; i++) { menu.add(actions[i]); } } } menu.add(new Separator(CONFIG_GROUP)); menu.add(new ConfigureTemplatesAction()); }
public static void fillMenu(IMenuManager menu, CompilationUnitEditor editor, SurroundWithTryCatchAction surroundWithTryCatchAction, SurroundWithTryMultiCatchAction surroundWithTryMultiCatchAction) { IAction[] actions= getTemplateActions(editor); surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection()); boolean addSurroundWithTryCatchAction= surroundWithTryCatchAction.isEnabled() && !isInJavadoc(editor); boolean addSurroundWithTryMultiCatchAction= surroundWithTryMultiCatchAction.isEnabled() && !isInJavadoc(editor); if ((actions == null || actions.length == 0) && (!addSurroundWithTryCatchAction && !addSurroundWithTryMultiCatchAction)) { menu.add(NONE_APPLICABLE_ACTION); } else { if (addSurroundWithTryCatchAction) menu.add(surroundWithTryCatchAction); if (addSurroundWithTryMultiCatchAction) menu.add(surroundWithTryMultiCatchAction); menu.add(new Separator(TEMPLATE_GROUP)); for (int i= 0; actions != null && i < actions.length; i++) menu.add(actions[i]); } menu.add(new Separator(CONFIG_GROUP)); menu.add(new ConfigureTemplatesAction()); }
public static void fillMenu(IMenuManager menu, CompilationUnitEditor editor, SurroundWithTryCatchAction surroundWithTryCatchAction, SurroundWithTryMultiCatchAction surroundWithTryMultiCatchAction) { IAction[] actions= getTemplateActions(editor); surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection()); boolean addSurroundWithTryCatchAction= surroundWithTryCatchAction.isEnabled() && !isInJavadoc(editor); boolean addSurroundWithTryMultiCatchAction= surroundWithTryMultiCatchAction.isEnabled() && !isInJavadoc(editor); if ((actions == null || actions.length == 0) && (!addSurroundWithTryCatchAction && !addSurroundWithTryMultiCatchAction)) { menu.add(NONE_APPLICABLE_ACTION); } else { if (addSurroundWithTryCatchAction) menu.add(surroundWithTryCatchAction); if (addSurroundWithTryMultiCatchAction) menu.add(surroundWithTryMultiCatchAction); menu.add(new Separator(TEMPLATE_GROUP)); for (int i= 0; actions != null && i < actions.length; i++) menu.add(actions[i]); } menu.add(new Separator(CONFIG_GROUP)); menu.add(new ConfigureTemplatesAction()); }
return; ISelection selection= fEditor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { final ITextSelection textSelection= (ITextSelection) selection;
return; ISelection selection= fEditor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { final ITextSelection textSelection= (ITextSelection) selection;
return; ISelection selection= fEditor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { final ITextSelection textSelection= (ITextSelection) selection;