Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java')
-rw-r--r--tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java343
1 files changed, 164 insertions, 179 deletions
diff --git a/tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java b/tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java
index 41afb9a8d..2e8871e0b 100644
--- a/tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java
+++ b/tutorial/org.eclipse.emf.examples.library.editor/src/org/eclipse/emf/examples/extlibrary/presentation/EXTLibraryActionBarContributor.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.examples.extlibrary.presentation;
-
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
@@ -25,7 +24,6 @@ import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.action.LoadResourceAction;
import org.eclipse.emf.edit.ui.action.ValidateAction;
-
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
@@ -48,151 +46,141 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
-
/**
- * This is the action bar contributor for the EXTLibrary model editor.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * This is the action bar contributor for the EXTLibrary model editor. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
-public class EXTLibraryActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener
-{
- /**
- * This keeps track of the active editor.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+public class EXTLibraryActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener {
+ /**
+ * This keeps track of the active editor. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected IEditorPart activeEditorPart;
+ protected IEditorPart activeEditorPart;
- /**
- * This keeps track of the current selection provider.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This keeps track of the current selection provider. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected ISelectionProvider selectionProvider;
+ protected ISelectionProvider selectionProvider;
- /**
- * This action opens the Properties view.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This action opens the Properties view. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected IAction showPropertiesViewAction =
- new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
- {
- @Override
- public void run() {
- try {
- getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
- }
- catch (PartInitException exception) {
- EXTLibraryEditorPlugin.INSTANCE.log(exception);
- }
+ protected IAction showPropertiesViewAction = new Action(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
+ } catch (PartInitException exception) {
+ EXTLibraryEditorPlugin.INSTANCE.log(exception);
}
- };
+ }
+ };
- /**
- * This action refreshes the viewer of the current editor if the editor
- * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This action refreshes the viewer of the current editor if the editor implements
+ * {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected IAction refreshViewerAction =
- new Action(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
- {
- @Override
- public boolean isEnabled() {
- return activeEditorPart instanceof IViewerProvider;
- }
+ protected IAction refreshViewerAction = new Action(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) //$NON-NLS-1$
+ {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
- @Override
- public void run() {
- if (activeEditorPart instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
- if (viewer != null) {
- viewer.refresh();
- }
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.refresh();
}
}
- };
+ }
+ };
- /**
- * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
- * generated for the current selection by the item provider.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each
+ * descriptor generated for the current selection by the item provider. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- protected Collection<IAction> createChildActions;
+ protected Collection<IAction> createChildActions;
- /**
+ /**
* This is the menu manager into which menu contribution items should be added for CreateChild actions.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected IMenuManager createChildMenuManager;
+ protected IMenuManager createChildMenuManager;
- /**
- * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
- * generated for the current selection by the item provider.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each
+ * descriptor generated for the current selection by the item provider. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- protected Collection<IAction> createSiblingActions;
+ protected Collection<IAction> createSiblingActions;
- /**
+ /**
* This is the menu manager into which menu contribution items should be added for CreateSibling actions.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected IMenuManager createSiblingMenuManager;
+ protected IMenuManager createSiblingMenuManager;
- /**
- * This creates an instance of the contributor.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This creates an instance of the contributor. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- public EXTLibraryActionBarContributor()
- {
+ public EXTLibraryActionBarContributor() {
super(ADDITIONS_LAST_STYLE);
loadResourceAction = new LoadResourceAction();
validateAction = new ValidateAction();
controlAction = new ControlAction();
}
- /**
- * This adds Separators for editor additions to the tool bar.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This adds Separators for editor additions to the tool bar. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
* @generated
*/
- @Override
- public void contributeToToolBar(IToolBarManager toolBarManager)
- {
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
toolBarManager.add(new Separator("extlibrary-settings")); //$NON-NLS-1$
toolBarManager.add(new Separator("extlibrary-additions")); //$NON-NLS-1$
}
- /**
- * This adds to the menu bar a menu and some separators for editor additions,
- * as well as the sub-menus for object creation items.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions, as well as the sub-menus for
+ * object creation items. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- @Override
- public void contributeToMenu(IMenuManager menuManager)
- {
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
super.contributeToMenu(menuManager);
- IMenuManager submenuManager = new MenuManager(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_EXTLibraryEditor_menu"), "org.eclipse.emf.examples.extlibraryMenuID"); //$NON-NLS-1$ //$NON-NLS-2$
+ IMenuManager submenuManager = new MenuManager(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_EXTLibraryEditor_menu"), //$NON-NLS-1$
+ "org.eclipse.emf.examples.extlibraryMenuID"); //$NON-NLS-1$
menuManager.insertAfter("additions", submenuManager); //$NON-NLS-1$
submenuManager.add(new Separator("settings")); //$NON-NLS-1$
submenuManager.add(new Separator("actions")); //$NON-NLS-1$
@@ -201,35 +189,35 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
// Prepare for CreateChild item addition or removal.
//
- createChildMenuManager = new MenuManager(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ createChildMenuManager = new MenuManager(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
submenuManager.insertBefore("additions", createChildMenuManager); //$NON-NLS-1$
// Prepare for CreateSibling item addition or removal.
//
- createSiblingMenuManager = new MenuManager(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ createSiblingMenuManager = new MenuManager(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
submenuManager.insertBefore("additions", createSiblingMenuManager); //$NON-NLS-1$
// Force an update because Eclipse hides empty menus now.
//
- submenuManager.addMenuListener
- (new IMenuListener() {
- public void menuAboutToShow(IMenuManager menuManager) {
- menuManager.updateAll(true);
- }
- });
+ submenuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
addGlobalActions(submenuManager);
}
- /**
- * When the active editor changes, this remembers the change and registers with it as a selection provider.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection
+ * provider. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- @Override
- public void setActiveEditor(IEditorPart part)
- {
+ @Override
+ public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
activeEditorPart = part;
@@ -240,29 +228,28 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
}
if (part == null) {
selectionProvider = null;
- }
- else {
+ } else {
selectionProvider = part.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(this);
// Fake a selection changed event to update the menus.
//
if (selectionProvider.getSelection() != null) {
- selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
+ selectionChanged(
+ new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
}
}
}
- /**
- * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
- * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
- * that can be added to the selected object and updating the menus accordingly.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling
+ * {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings that
+ * can be added to the selected object and updating the menus accordingly. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- public void selectionChanged(SelectionChangedEvent event)
- {
+ public void selectionChanged(SelectionChangedEvent event) {
// Remove any menu items for old selection.
//
if (createChildMenuManager != null) {
@@ -302,15 +289,15 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
}
}
- /**
- * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
- * and returns the collection of these actions.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in
+ * <code>descriptors</code>, and returns the collection of these actions. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection)
- {
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors,
+ ISelection selection) {
Collection<IAction> actions = new ArrayList<IAction>();
if (descriptors != null) {
for (Object descriptor : descriptors) {
@@ -320,15 +307,15 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
return actions;
}
- /**
- * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
- * and returns the collection of these actions.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in
+ * <code>descriptors</code>, and returns the collection of these actions. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection)
- {
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors,
+ ISelection selection) {
Collection<IAction> actions = new ArrayList<IAction>();
if (descriptors != null) {
for (Object descriptor : descriptors) {
@@ -338,38 +325,38 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
return actions;
}
- /**
- * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
- * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
- * by inserting them before the specified contribution item <code>contributionID</code>.
- * If <code>contributionID</code> is <code>null</code>, they are simply added.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This populates the specified <code>manager</code> with
+ * {@link org.eclipse.jface.action.ActionContributionItem}s based on the
+ * {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, by
+ * inserting them before the specified contribution item <code>contributionID</code>. If
+ * <code>contributionID</code> is <code>null</code>, they are simply added. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID)
- {
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
+ String contributionID) {
if (actions != null) {
for (IAction action : actions) {
if (contributionID != null) {
manager.insertBefore(contributionID, action);
- }
- else {
+ } else {
manager.add(action);
}
}
}
}
-
- /**
- * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
- * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+
+ /**
+ * This removes from the specified <code>manager</code> all
+ * {@link org.eclipse.jface.action.ActionContributionItem}s based on the
+ * {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions)
- {
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
if (actions != null) {
IContributionItem[] items = manager.getItems();
for (int i = 0; i < items.length; i++) {
@@ -392,54 +379,52 @@ public class EXTLibraryActionBarContributor extends EditingDomainActionBarContri
}
}
- /**
- * This populates the pop-up menu before it appears.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This populates the pop-up menu before it appears. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @generated
*/
- @Override
- public void menuAboutToShow(IMenuManager menuManager)
- {
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
super.menuAboutToShow(menuManager);
MenuManager submenuManager = null;
- submenuManager = new MenuManager(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
+ submenuManager = new MenuManager(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); //$NON-NLS-1$
populateManager(submenuManager, createChildActions, null);
menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
- submenuManager = new MenuManager(EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
+ submenuManager = new MenuManager(
+ EXTLibraryEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); //$NON-NLS-1$
populateManager(submenuManager, createSiblingActions, null);
menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
}
- /**
- * This inserts global actions before the "additions-end" separator.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This inserts global actions before the "additions-end" separator. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
* @generated
*/
- @Override
- protected void addGlobalActions(IMenuManager menuManager)
- {
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
menuManager.insertAfter("additions-end", new Separator("ui-actions")); //$NON-NLS-1$ //$NON-NLS-2$
menuManager.insertAfter("ui-actions", showPropertiesViewAction); //$NON-NLS-1$
- refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
menuManager.insertAfter("ui-actions", refreshViewerAction); //$NON-NLS-1$
super.addGlobalActions(menuManager);
}
- /**
- * This ensures that a delete action will clean up all references to deleted objects.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
* @generated
*/
- @Override
- protected boolean removeAllReferencesOnDelete()
- {
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
return true;
}

Back to the top