Revision 6ca6495d
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/fragment.e4xmi | ||
---|---|---|
83 | 83 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_1JIbQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.copy" label="%command.label.12" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/> |
84 | 84 |
<children xsi:type="menu:MenuSeparator" xmi:id="_z0Q6EJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.4"/> |
85 | 85 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_0FX4MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.refresh" label="%command.label.11" command="_ukhM0JIyEeeJAdt8ZUxyaw"/> |
86 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_7MpwILVfEeeZf_R8QJbACw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.syncwithtaxon" label="Sync with taxon" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/synced.gif" command="_6iiY8LVbEeeZf_R8QJbACw"/> |
|
86 | 87 |
</menus> |
87 | 88 |
</elements> |
88 | 89 |
<elements xsi:type="basic:PartDescriptor" xmi:id="_AcycAKOkEee6lJH578buGg" elementId="eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4" label="%view.name" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/system-search.png" allowMultiple="true" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4"> |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java | ||
---|---|---|
25 | 25 |
import javax.annotation.PreDestroy; |
26 | 26 |
import javax.inject.Inject; |
27 | 27 |
|
28 |
import org.eclipse.core.commands.Command; |
|
29 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
30 | 28 |
import org.eclipse.core.commands.operations.UndoContext; |
31 | 29 |
import org.eclipse.core.runtime.IAdaptable; |
32 | 30 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
35 | 33 |
import org.eclipse.e4.ui.di.Focus; |
36 | 34 |
import org.eclipse.e4.ui.di.UIEventTopic; |
37 | 35 |
import org.eclipse.e4.ui.di.UISynchronize; |
38 |
import org.eclipse.e4.ui.model.application.commands.MCommand; |
|
39 |
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory; |
|
40 | 36 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
41 |
import org.eclipse.e4.ui.model.application.ui.menu.ItemType; |
|
42 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem; |
|
43 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory; |
|
44 |
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; |
|
45 | 37 |
import org.eclipse.e4.ui.services.EMenuService; |
46 | 38 |
import org.eclipse.e4.ui.workbench.modeling.ESelectionService; |
47 | 39 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
... | ... | |
176 | 168 |
viewer.addDropSupport(dndOperations, transfers, new TreeNodeDropAdapterE4(this)); |
177 | 169 |
|
178 | 170 |
//add toolbar |
179 |
MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar(); |
|
180 |
MHandledToolItem linkWithEditor = MMenuFactory.INSTANCE.createHandledToolItem(); |
|
181 |
linkWithEditor.setIconURI("platform:/plugin/eu.etaxonomy.taxeditor.store/icons/synced.gif"); |
|
182 |
Command command = commandService.getCommand("eu.etaxonomy.taxeditor.navigation.command.linkWithTaxon"); |
|
183 |
MCommand mCommand = MCommandsFactory.INSTANCE.createCommand(); |
|
184 |
mCommand.setElementId(command.getId()); |
|
185 |
try { |
|
186 |
mCommand.setCommandName(command.getName()); |
|
187 |
} catch (NotDefinedException e) { |
|
188 |
e.printStackTrace(); |
|
189 |
} |
|
190 |
linkWithEditor.setCommand(mCommand); |
|
191 |
linkWithEditor.setType(ItemType.CHECK); |
|
192 |
toolBar.getChildren().add(linkWithEditor); |
|
193 |
thisPart.setToolbar(toolBar); |
|
171 |
// MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
|
|
172 |
// MHandledToolItem linkWithEditor = MMenuFactory.INSTANCE.createHandledToolItem();
|
|
173 |
// linkWithEditor.setIconURI("platform:/plugin/eu.etaxonomy.taxeditor.store/icons/synced.gif");
|
|
174 |
// Command command = commandService.getCommand("eu.etaxonomy.taxeditor.navigation.command.linkWithTaxon");
|
|
175 |
// MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
|
|
176 |
// mCommand.setElementId(command.getId());
|
|
177 |
// try {
|
|
178 |
// mCommand.setCommandName(command.getName());
|
|
179 |
// } catch (NotDefinedException e) {
|
|
180 |
// e.printStackTrace();
|
|
181 |
// }
|
|
182 |
// linkWithEditor.setCommand(mCommand);
|
|
183 |
// linkWithEditor.setType(ItemType.CHECK);
|
|
184 |
// toolBar.getChildren().add(linkWithEditor);
|
|
185 |
// thisPart.setToolbar(toolBar);
|
|
194 | 186 |
|
195 | 187 |
init(); |
196 | 188 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/LinkWithTaxonHandlerE4.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 14 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
15 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 16 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 17 |
|
17 | 18 |
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4; |
... | ... | |
25 | 26 |
public class LinkWithTaxonHandlerE4 { |
26 | 27 |
|
27 | 28 |
@Execute |
28 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
|
29 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, MHandledMenuItem menuItem) {
|
|
29 | 30 |
TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject(); |
30 | 31 |
taxonNavigator.setLinkWithTaxon(!taxonNavigator.isLinkWithTaxon()); |
32 |
if(taxonNavigator.isLinkWithTaxon()){ |
|
33 |
menuItem.setLabel("Do not sync with taxon"); |
|
34 |
} |
|
35 |
else { |
|
36 |
menuItem.setLabel("Sync with taxon"); |
|
37 |
} |
|
31 | 38 |
} |
32 | 39 |
} |
Also available in: Unified diff
ref #6909 Add "Link with editor" item to context menu