List of usage examples for org.eclipse.jface.action MenuManager setParent
@Override
public void setParent(IContributionManager manager)
From source file:org.eclipse.osee.ote.ui.define.views.TestRunView.java
License:Open Source License
private void createMenus() { MenuManager menuManager = new MenuManager(); getSite().registerContextMenu(VIEW_ID, menuManager, viewer); menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menuManager.setParent(getViewSite().getActionBars().getMenuManager()); fillMenu(menuManager);/* www . java 2s. co m*/ getSite().setSelectionProvider(viewer); }
From source file:org.eclipse.sapphire.ui.swt.gef.internal.DiagramEditorContextMenuProvider.java
License:Open Source License
@Override public void buildContextMenu(final IMenuManager menuManager) { final ISapphirePart part; final DiagramPresentation presentation; final GraphicalEditPart editPart; final String context; final List<GraphicalEditPart> selection = this.editor.getSelectedEditParts(); List<ISapphirePart> emptySelection = new ArrayList<ISapphirePart>(); if (selection.size() == 1) { editPart = selection.get(0);//from w w w . j av a 2s .com if (editPart instanceof SapphireDiagramEditorPageEditPart) { context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR; presentation = this.editor.getDiagramPresentation(); } else if (editPart instanceof DiagramNodeEditPart) { DiagramNodeEditPart nodePart = (DiagramNodeEditPart) editPart; if (isMouseOnEditPart(nodePart)) { context = SapphireActionSystem.CONTEXT_DIAGRAM_NODE; presentation = ((DiagramNodeEditPart) editPart).getPresentation(); } else { this.editor.selectParts(emptySelection); context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR; presentation = this.editor.getDiagramPresentation(); } } else if (editPart instanceof ShapeEditPart) { DiagramNodeEditPart nodePart = ((ShapeEditPart) editPart).getNodeEditPart(); if (isMouseOnEditPart(nodePart)) { context = SapphireActionSystem.CONTEXT_DIAGRAM_NODE_SHAPE; presentation = ((ShapeEditPart) editPart).getShapePresentation(); } else { this.editor.selectParts(emptySelection); context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR; presentation = this.editor.getDiagramPresentation(); } } else if (editPart instanceof DiagramConnectionEditPart) { if (isMouseOnEditPart(editPart)) { context = SapphireActionSystem.CONTEXT_DIAGRAM_CONNECTION; presentation = ((DiagramConnectionEditPart) editPart).getPresentation(); } else { this.editor.selectParts(emptySelection); context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR; presentation = this.editor.getDiagramPresentation(); } } else if (editPart instanceof DiagramConnectionLabelEditPart) { return; } else { throw new IllegalStateException(); } part = presentation.part(); } else if (selection.size() > 1) { if (isMouseOnEditParts(selection)) { context = SapphireActionSystem.CONTEXT_DIAGRAM_MULTIPLE_PARTS; } else { this.editor.selectParts(emptySelection); context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR; } presentation = this.editor.getDiagramPresentation(); part = this.editor.getPart(); } else { throw new IllegalStateException(); } final Map<SapphireActionSystemPart, ActionSystemPartBridge> updatedCache = new IdentityHashMap<SapphireActionSystemPart, ActionSystemPartBridge>(); String currentGroupId = null; for (SapphireAction action : part.getActions(context).getActions()) { if (action.getId().equals(DIAGRAM_NODE_DEFAULT_ACTION)) { continue; } if (skipMultipleConnectionAction(this.editor.getSelectedParts(), context, action)) { continue; } final String groupId = action.getGroup(); if ((currentGroupId != null && groupId == null) || (currentGroupId == null && groupId != null) || (currentGroupId != null && groupId != null && !currentGroupId.equals(groupId))) { currentGroupId = groupId; menuManager.add(new Separator(currentGroupId == null ? DIAGRAM_DEFAULT_GROUP : currentGroupId)); } final List<SapphireActionHandler> handlers = action.getActiveHandlers(); final int count = handlers.size(); if (count == 1) { ActionSystemPartBridge bridge = this.cache.get(action); if (bridge == null) { bridge = new ActionBridge(presentation, action); } updatedCache.put(action, bridge); menuManager.add(bridge); } else if (count > 1) { final String childMenuText = LabelTransformer.transform(action.getLabel(), CapitalizationType.TITLE_STYLE, true); final ImageDescriptor childMenuImage = SwtUtil.toImageDescriptor(action.getImage(16)); final MenuManager childMenuManager = new MenuManager(childMenuText, childMenuImage, action.getId()); childMenuManager.setParent(menuManager); menuManager.add(childMenuManager); for (SapphireActionHandler handler : action.getActiveHandlers()) { ActionSystemPartBridge bridge = this.cache.get(handler); if (bridge == null) { bridge = new ActionHandlerBridge(presentation, handler); } updatedCache.put(handler, bridge); childMenuManager.add(bridge); } } } for (Map.Entry<SapphireActionSystemPart, ActionSystemPartBridge> entry : this.cache.entrySet()) { if (!updatedCache.containsKey(entry.getKey())) { entry.getValue().dispose(); } } this.cache = updatedCache; }
From source file:org.eclipse.sirius.tree.ui.tools.internal.editor.provider.TreePopupMenuContributionSupport.java
License:Open Source License
/** * Adds all menus and actions defined for the given {@link DTreeItem} to the * given contextual menu./*from ww w. j a va 2 s .c o m*/ * * @param menu * the contextual menu about to be shown * @param selectedItem * the selected {@link DTreeItem} from which getting the * additional menus and actions */ public void contributeToPopupMenu(final IMenuManager menu, DTreeItem selectedItem) { EList<TreePopupMenu> popupMenus = selectedItem.getActualMapping().getPopupMenus(); IInterpreter interpreter = SiriusPlugin.getDefault().getInterpreterRegistry() .getInterpreter(selectedItem.getTarget()); boolean haveCreatedAtLeastOnePopupMenu = false; if (interpreter == null || popupMenus.isEmpty()) { return; } // For each defined popupMenu for (TreePopupMenu popupMenu : popupMenus) { // If the defined popupMenu is applicable (i.e. has a "true" // precondition) final Boolean menuPrecondition; if (StringUtil.isEmpty(popupMenu.getPrecondition())) { menuPrecondition = true; } else { menuPrecondition = RuntimeLoggerManager.INSTANCE.decorate(interpreter).evaluateBoolean( selectedItem.getTarget(), popupMenu, ToolPackage.eINSTANCE.getAbstractToolDescription_Precondition()); } if (menuPrecondition) { // We create a subMenu final MenuManager subMenu = new MenuManager(new IdentifiedElementQuery(popupMenu).getLabel(), new IdentifiedElementQuery(popupMenu).getLabel().toLowerCase()); // and populate it with all menu contributions contained it this // popupMenu buildActionsFromTreePopupMenu(subMenu, selectedItem, popupMenu, interpreter); // If at least one action has been added to the subMenu, we make // it visible if (subMenu.getSize() > 0) { haveCreatedAtLeastOnePopupMenu = true; subMenu.setParent(menu); menu.add(subMenu); subMenu.setVisible(true); } } } if (haveCreatedAtLeastOnePopupMenu) { menu.add(new Separator()); } }
From source file:org.jboss.tools.vpe.editor.menu.MenuCreationHelper.java
License:Open Source License
/** * Create menu visual element for the node passed by parameter. * * @param node the Node object//from w w w . j av a 2 s .c om * @param manager MenuManager object * @param topLevelFlag in case of "true" indicates if top level flag in relevant */ public void createMenuForNode(Node node, MenuManager manager, boolean topLevelFlag) { NodeActionManager.setTextNodeSplitter(null); StructuredSelection structuredSelection = null; if (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { VpeElementMapping elementMapping = (VpeElementMapping) domMapping.getNodeMapping(node); if (elementMapping != null && elementMapping.getTemplate() != null) { manager.add(new VpeAction("<" + node.getNodeName() + "> Attributes", node) { //$NON-NLS-1$ //$NON-NLS-2$ public void run() { showProperties(actionNode); } }); if (!topLevelFlag) { manager.add(new VpeAction("Select This Tag", node) { //$NON-NLS-1$ public void run() { SelectionUtil.setSourceSelection(pageContext, actionNode); } }); } Node parent = node.getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { MenuManager menuManager = new MenuManager("Parent Tag"); //$NON-NLS-1$ menuManager.setParent(manager); manager.add(menuManager); createMenuForNode(parent, menuManager); } manager.add(new Separator()); } } if (node.getNodeType() == Node.TEXT_NODE) { Point range = sourceEditor.getTextViewer().getSelectedRange(); TextNodeSplitterImpl splitter = new TextNodeSplitterImpl(range, (Text) node); NodeActionManager.setTextNodeSplitter(splitter); } structuredSelection = new StructuredSelection(node); } else { structuredSelection = new StructuredSelection(); } NodeActionManager actionManager = new NodeActionManager(sourceEditor.getModel(), null); if (actionManager != null) { actionManager.fillContextMenuForVpe(manager, structuredSelection); } IContributionItem[] items = manager.getItems(); /* * Fix https://jira.jboss.org/jira/browse/JBIDE-3532 */ boolean insertFromPalette = false; // fixed for JBIDE-3072 // add "insert arround", for (int i = 0; i < items.length; i++) { if (items[i] instanceof MenuManager) { MenuManager mm = (MenuManager) items[i]; int type = 0; Point region = null; if (NodeActionManager.INSERT_AROUND_MENU.equals(mm.getMenuText())) { type = ITextNodeSplitter.INSERT_AROUND; // if node is text then allow to wrap only selected text if (node.getNodeType() == Node.TEXT_NODE) { region = SelectionUtil.getSourceSelectionRange(sourceEditor); } // else wrap all tag else { region = NodesManagingUtil.getNodeRange(node); } insertFromPalette = true; } else if (NodeActionManager.INSERT_BEFORE_MENU.equals(mm.getMenuText())) { type = ITextNodeSplitter.INSERT_BEFORE; region = new Point(NodesManagingUtil.getStartOffsetNode(node), 0); insertFromPalette = true; } else if (NodeActionManager.INSERT_AFTER_MENU.equals(mm.getMenuText())) { type = ITextNodeSplitter.INSERT_AFTER; region = new Point(NodesManagingUtil.getEndOffsetNode(node), 0); insertFromPalette = true; } else if (NodeActionManager.REPLACE_TAG_MENU.equals(mm.getMenuText())) { //added by Max Areshkau, fix for JBIDE-3428 type = ITextNodeSplitter.REPLACE_TAG; //post start and end offset of node region = new Point(NodesManagingUtil.getStartOffsetNode(node), NodesManagingUtil.getNodeLength(node)); insertFromPalette = true; } if (insertFromPalette) { listenContextMenu(mm, region, type); } } } manager.add(new Separator()); if (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { VpeElementMapping elementMapping = (VpeElementMapping) domMapping.getNodeMapping(node); if (elementMapping != null && elementMapping.getTemplate() != null && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) { final VpeTemplate selectedTemplate = elementMapping.getTemplate(); manager.add(new VpeAction(NLS.bind(VpeUIMessages.SETUP_TEMPLATE_FOR_MENU, node.getNodeName()), node) { public void run() { boolean isCorrectNS = pageContext.isCorrectNS(actionNode); VpeAnyData data = null; if (isCorrectNS) { data = selectedTemplate.getAnyData(); data.setUri(pageContext.getSourceTaglibUri(actionNode)); data.setName(actionNode.getNodeName()); } data = editAnyData(sourceEditor, isCorrectNS, data); if (data != null && data.isChanged()) VpeTemplateManager.getInstance().setAnyTemplate(data); } }); manager.add(new Separator()); } manager.add(new VpeTextOperationAction(CUT_ACTION, ActionFactory.CUT.getId(), node, pageContext, sourceEditor)); manager.add(new VpeTextOperationAction(COPY_ACTION, ActionFactory.COPY.getId(), node, pageContext, sourceEditor)); manager.add(new VpeTextOperationAction(PASTE_ACTION, ActionFactory.PASTE.getId(), node, pageContext, sourceEditor)); } else if (node.getNodeType() == Node.TEXT_NODE) { manager.add(new Action(CUT_ACTION) { public void run() { sourceEditor.getAction(ActionFactory.CUT.getId()).run(); } }); manager.add(new Action(COPY_ACTION) { public void run() { sourceEditor.getAction(ActionFactory.COPY.getId()).run(); } }); manager.add(new Action(PASTE_ACTION) { public void run() { sourceEditor.getAction(ActionFactory.PASTE.getId()).run(); } }); } manager.add(new Separator()); if (actionManager != null && node != null) { structuredSelection = node.getNodeType() == Node.ELEMENT_NODE ? new StructuredSelection(node) : null; actionManager.addContextMenuForVpe(manager, structuredSelection); } if (node.getNodeType() == Node.ELEMENT_NODE) { boolean stripEnable = false; NodeImpl impl = (NodeImpl) node; if (impl.isContainer()) { NodeList list = impl.getChildNodes(); if (list.getLength() > 0) { if (list.getLength() == 1) { Node child = list.item(0); if (child.getNodeType() == Node.TEXT_NODE) { if (Constants.EMPTY.equals(child.getNodeValue().trim())) stripEnable = false; else stripEnable = true; } else stripEnable = true; } else stripEnable = true; } } if (stripEnable) manager.add(new VpeAction("Strip Tag", node) { //$NON-NLS-1$ public void run() { Node parent = actionNode.getParentNode(); if (parent != null) { int index = ((NodeImpl) actionNode).getIndex(); parent.removeChild(actionNode); NodeList children = actionNode.getChildNodes(); int lengh = children.getLength(); Node child; for (int i = 0; i < lengh; i++) { child = children.item(0); actionNode.removeChild(child); insertNode(parent, child, index++); } } } private void insertNode(Node parent, Node node, int index) { Node oldNode = null; int childSize = parent.getChildNodes().getLength(); if (index <= (childSize - 1)) oldNode = parent.getChildNodes().item(index); if (oldNode != null) parent.insertBefore(node, oldNode); else parent.appendChild(node); } }); } if (node.getNodeType() == Node.TEXT_NODE) { manager.add(new Action(DELETE_ACTION) { public void run() { sourceEditor.getAction(ActionFactory.DELETE.getId()).run(); } }); } if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE) { manager.add(new Action("Dump Source") { //$NON-NLS-1$ public void run() { DOMTreeDumper dumper = new DOMTreeDumper(VpeDebug.VISUAL_DUMP_PRINT_HASH); dumper.setIgnoredAttributes(VpeDebug.VISUAL_DUMP_IGNORED_ATTRIBUTES); dumper.dumpToStream(System.out, visualEditor.getDomDocument()); } }); } if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SELECTED_ELEMENT) { manager.add(new Action("Dump Selected Element") { //$NON-NLS-1$ public void run() { VpeNodeMapping nodeMapping = SelectionUtil.getNodeMappingBySourceSelection(sourceEditor, domMapping); if (nodeMapping != null) { DOMTreeDumper dumper = new DOMTreeDumper(VpeDebug.VISUAL_DUMP_PRINT_HASH); dumper.setIgnoredAttributes(VpeDebug.VISUAL_DUMP_IGNORED_ATTRIBUTES); dumper.dumpNode(nodeMapping.getVisualNode()); } } }); } if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_CSS_STYLE) { manager.add(new Action("Dump CSS Style") { //$NON-NLS-1$ public void run() { VpeNodeMapping nodeMapping = SelectionUtil.getNodeMappingBySourceSelection(sourceEditor, domMapping); if (nodeMapping != null) { DOMTreeDumper dumper = new DOMTreeDumper(VpeDebug.VISUAL_DUMP_PRINT_HASH); dumper.setIgnoredAttributes(VpeDebug.VISUAL_DUMP_IGNORED_ATTRIBUTES); dumper.dumpStyle(nodeMapping.getVisualNode()); } } }); } if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING) { manager.add(new Action("Dump Mapping") { //$NON-NLS-1$ public void run() { printMapping(); } }); } if (VpeDebug.VISUAL_CONTEXTMENU_TEST) { manager.add(new VpeAction(TEST_ACTION, node) { public void run() { test(actionNode); } }); } } else { manager.add(new Action(PASTE_ACTION) { public void run() { sourceEditor.getAction(ActionFactory.PASTE.getId()).run(); } }); } }
From source file:org.jboss.tools.vpe.editor.menu.VpeMenuCreator.java
License:Open Source License
/** * Adds a menu item for operations on {@code parent} element. * /*from ww w . j a va 2 s .c om*/ * @param parent * the parent element */ private void addParentTagMenuItem(final Element parent) { final String itemName = MessageFormat.format(VpeUIMessages.PARENT_TAG_MENU_ITEM, parent.getNodeName()); final MenuManager parentMenuManager = new MenuManager(itemName); parentMenuManager.setParent(menuManager); parentMenuManager.setRemoveAllWhenShown(true); parentMenuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(final IMenuManager manager) { new VpeMenuCreator(parentMenuManager, parent).createMenu(false); } }); menuManager.add(parentMenuManager); }
From source file:org.neo4j.neoclipse.property.NeoPropertySheetPage.java
License:Apache License
/** * Create the context menu for this property sheet. * //w w w . j a v a 2 s . com * @param parent */ private void createMenu(final Composite parent) { MenuManager menuManager = createMainMenu(parent); menu = menuManager.createContextMenu(getControl()); MenuManager addMenuManager = createNewSubmenu(parent); addMenuManager.setParent(menuManager); menuManager.add(addMenuManager); MenuManager addArrayMenuManager = createNewArraySubmenu(parent); addArrayMenuManager.setParent(menuManager); menuManager.add(addArrayMenuManager); }
From source file:org.talend.core.ui.actions.ActionsHelper.java
License:Open Source License
public static MenuManager[] getRepositoryContextualsActionGroups() { IExtensionPointLimiter actionExtensionPoint = new ExtensionPointLimiterImpl( "org.talend.core.repositoryContextualsActions", //$NON-NLS-1$ "Group"); //$NON-NLS-1$ List<IConfigurationElement> extension = ExtensionImplementationProvider.getInstanceV2(actionExtensionPoint); Set<RepositoryContextualsActionGroup> tempSet = new HashSet<RepositoryContextualsActionGroup>(); for (IConfigurationElement current : extension) { final String id = current.getAttribute("id"); final String name = current.getAttribute("name"); final String parentId = current.getAttribute("parentId"); if (id != null && name != null) { tempSet.add(new RepositoryContextualsActionGroup(id, name, parentId)); }/*from w w w .j a v a 2 s . c o m*/ } // Set<MenuManager> groups = new HashSet<MenuManager>(); for (RepositoryContextualsActionGroup group : tempSet) { final MenuManager menuManger = group.getMenuManger(); RepositoryContextualsActionGroup parentGroup = findGroup(tempSet, group.getParentId()); if (parentGroup != null) { menuManger.setParent(parentGroup.getMenuManger()); parentGroup.getMenuManger().add(menuManger); } groups.add(menuManger); } return groups.toArray(new MenuManager[0]); }
From source file:org.talend.core.ui.actions.ActionsHelper.java
License:Open Source License
private static MenuManager findParentNameByParentId(String parentId, List<IConfigurationElement> extension, MenuManager relation) { String parentName = null;//from w w w . j a v a2 s . c o m String grandFatherId = null; MenuManager tempFather = null; for (IConfigurationElement current : extension) { String id = current.getAttribute("id"); if (id.equals(parentId)) { parentName = current.getAttribute("name"); grandFatherId = current.getAttribute("parentId"); tempFather = new MenuManager(parentName, id); relation.setParent(tempFather); if (grandFatherId != null) { findParentNameByParentId(grandFatherId, extension, (MenuManager) relation.getParent()); } break; } } return relation; }
From source file:org.thanlwinsoft.doccharconvert.eclipse.editors.MappingTableEditorPart.java
License:Open Source License
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { this.setSite(site); clipboard = new Clipboard(site.getShell().getDisplay()); menuManager = new MenuManager(parentEditor.getPartName() + ":" + mt.getId()); Action insertAction = new Action() { @Override//w w w.j a v a 2s. co m public void run() { int mapIndex = getSelectedMapIndex(); if (mapIndex < 0) mapIndex = mt.getMaps().sizeOfMArray(); int insertRowCount = Math.max(1, table.getSelectionCount()); for (int i = 0; i < insertRowCount; i++) mt.getMaps().insertNewM(mapIndex); viewer.refresh(); parentEditor.setDirty(true); } }; insertAction.setId("Insert"); insertAction.setText(MessageUtil.getString("InsertRow")); insertAction.setToolTipText(MessageUtil.getString("InsertRowToolTip")); Action deleteAction = new Action() { @Override public void run() { //int mapIndex = getSelectedMapIndex(); //if (mapIndex < 0) // return; TreeSet<Integer> mapIndices = getSelectedMapIndices(); Iterator<Integer> mapI = mapIndices.descendingIterator(); while (mapI.hasNext()) { int mapIndex = mapI.next().intValue(); mt.getMaps().removeM(mapIndex); } viewer.refresh(); parentEditor.setDirty(true); } }; deleteAction.setId("Delete"); deleteAction.setText(MessageUtil.getString("DeleteRow")); deleteAction.setToolTipText(MessageUtil.getString("DeleteRowToolTip")); Action moveUpAction = new Action() { @Override public void run() { int mapIndex = getSelectedMapIndex(); if (mapIndex < 1) return; Map toMove = (Map) mt.getMaps().getMArray(mapIndex).copy(); mt.getMaps().removeM(mapIndex); Map newMap = mt.getMaps().insertNewM(mapIndex - 1); newMap.setCArray(toMove.getCArray()); viewer.refresh(); parentEditor.setDirty(true); } }; moveUpAction.setId("MoveUp"); moveUpAction.setText(MessageUtil.getString("MoveUp")); moveUpAction.setToolTipText(MessageUtil.getString("MoveUpToolTip")); Action moveDownAction = new Action() { @Override public void run() { int mapIndex = getSelectedMapIndex(); if (mapIndex < 0 || mapIndex + 1 >= table.getItemCount()) return; Map toMove = (Map) mt.getMaps().getMArray(mapIndex).copy(); mt.getMaps().removeM(mapIndex); Map newMap = mt.getMaps().insertNewM(mapIndex + 1); newMap.setCArray(toMove.getCArray()); viewer.refresh(); parentEditor.setDirty(true); } }; moveDownAction.setId("MoveDown"); moveDownAction.setText(MessageUtil.getString("MoveDown")); moveDownAction.setToolTipText(MessageUtil.getString("MoveDownToolTip")); final IEditorPart part = this; Action deleteTableAction = new Action() { @Override public void run() { if (MessageDialog.openConfirm(part.getSite().getShell(), part.getTitle(), MessageUtil.getString("ConfirmDeleteTable")) == false) { return; } int index = parentEditor.getEditorIndex(part); parentEditor.removePage(index); SyllableConverter sc = parentEditor.getDocument().getSyllableConverter(); for (int i = 0; i < sc.sizeOfMappingTableArray(); i++) { if (sc.getMappingTableArray(i) == mt) { sc.removeMappingTable(i); break; } } parentEditor.setDirty(true); } }; deleteTableAction.setId("DeleteTable"); deleteTableAction.setText(MessageUtil.getString("DeleteTable")); deleteTableAction.setToolTipText(MessageUtil.getString("DeleteTableToolTip")); menuManager.add(deleteTableAction); menuManager.add(insertAction); menuManager.add(deleteAction); menuManager.add(moveUpAction); menuManager.add(moveDownAction); menuManager.add(new Separator()); Action optionalAction = new Action(MessageUtil.getString("OptionalTable"), IAction.AS_CHECK_BOX) { @Override public void run() { mt.setOptional(this.isChecked()); parentEditor.setDirty(true); } }; optionalAction.setText(MessageUtil.getString("OptionalTable")); optionalAction.setToolTipText(MessageUtil.getString("OptionalTableToolTip")); if (mt.isSetOptional() && mt.getOptional()) { optionalAction.setChecked(true); } else { optionalAction.setChecked(false); } menuManager.add(optionalAction); Action firstWinsAction = new Action(MessageUtil.getString("FirstWins"), IAction.AS_CHECK_BOX) { @Override public void run() { mt.setFirstEntryWins(this.isChecked()); parentEditor.setDirty(true); } }; firstWinsAction.setText(MessageUtil.getString("FirstWins")); firstWinsAction.setToolTipText(MessageUtil.getString("FirstWinsToolTip")); if (mt.isSetFirstEntryWins() && mt.getFirstEntryWins()) { firstWinsAction.setChecked(true); } else { firstWinsAction.setChecked(false); } menuManager.add(firstWinsAction); menuManager.add(new Separator()); SyllableConverter sc = parentEditor.getDocument().getSyllableConverter(); int usedIndex = 0; MenuManager addColumns = new MenuManager(MessageUtil.getString("AddColumn")); MenuManager copyColumns = new MenuManager(MessageUtil.getString("Copy")); MenuManager cutColumns = new MenuManager(MessageUtil.getString("Cut")); MenuManager pasteColumns = new MenuManager(MessageUtil.getString("Paste")); addColumns.setParent(menuManager); menuManager.add(addColumns); copyColumns.setParent(menuManager); menuManager.add(copyColumns); cutColumns.setParent(menuManager); menuManager.add(cutColumns); pasteColumns.setParent(menuManager); menuManager.add(pasteColumns); Action copyAction = new Action() { @Override public void run() { doCopy(false); } }; copyAction.setText(MessageUtil.getString("CopyRow")); menuManager.add(copyAction); Action cutAction = new Action() { @Override public void run() { doCopy(true); } }; cutAction.setText(MessageUtil.getString("CutRow")); menuManager.add(cutAction); Action pasteAction = new Action() { @Override public void run() { doPaste(); } }; pasteAction.setText(MessageUtil.getString("PasteRow")); menuManager.add(pasteAction); for (Script script : sc.getScriptArray()) { menuManager.add(new Separator()); for (Component c : script.getCluster().getComponentArray()) { if (!c.isSetId()) continue; boolean used = false; for (ComponentRef cr : mt.getColumns().getComponentArray()) { if (cr.getR().equals(c.getId())) { used = true; ++usedIndex; break; } } final String cId = c.getId(); final int insertPos = usedIndex; Action addColumn = new Action() { @Override public void run() { if (this.isChecked()) { ComponentRef ncr = mt.getColumns().insertNewComponent(insertPos); ncr.setR(cId); } else { for (int i = 0; i < mt.getColumns().sizeOfComponentArray(); i++) { if (mt.getColumns().getComponentArray(i).getR().equals(cId)) { mt.getColumns().removeComponent(i); break; } } } // viewer.refresh(); try { int index = parentEditor.getEditorIndex(part); IEditorPart replacement = new MappingTableEditorPart(parentEditor, mt); parentEditor.addPage(index + 1, replacement, parentEditor.getEditorInput()); parentEditor.setDirty(true); parentEditor.removePage(index); parentEditor.setActiveEditor(replacement); } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; addColumn.setText(c.getId()); addColumn.setChecked(used); addColumns.add(addColumn); if (!used) continue; Action copyColumn = new Action() { @Override public void run() { doCopy(cId, false); } }; copyColumn.setText(c.getId()); copyColumns.add(copyColumn); Action cutColumn = new Action() { @Override public void run() { doCopy(cId, true); } }; cutColumn.setText(c.getId()); cutColumns.add(cutColumn); Action pasteColumn = new Action() { @Override public void run() { doPaste(cId); } }; pasteColumn.setText(c.getId()); pasteColumns.add(pasteColumn); } } // SyllableConverterDocument doc = this.parentEditor.getDocument(); // TODO check table hasn't changed }