Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-10-10 13:57:31 +0000
committerEike Stepper2016-10-10 13:57:31 +0000
commitef07d64d87b6151eca6f2fcad357b5d38050a043 (patch)
tree5dab92949f8ef94efe60180ff16482df2e1ba1fb /plugins/org.eclipse.emf.cdo.explorer.ui
parentc15fd3efd477d5336cde2ef3eee6cd40c58f59c2 (diff)
downloadcdo-ef07d64d87b6151eca6f2fcad357b5d38050a043.tar.gz
cdo-ef07d64d87b6151eca6f2fcad357b5d38050a043.tar.xz
cdo-ef07d64d87b6151eca6f2fcad357b5d38050a043.zip
[505656] [UI] Better wizard ordering in the New... context menu
https://bugs.eclipse.org/bugs/show_bug.cgi?id=505656
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.explorer.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewBinaryResourceWizard.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewFolderWizard.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewResourceWizard.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewTextResourceWizard.java2
5 files changed, 103 insertions, 21 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
index 8ee236a5bf..f6a191fe8a 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
@@ -17,6 +17,10 @@ import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.explorer.CDOExplorerUtil;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutContentProvider;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewBinaryResourceWizard;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewFolderWizard;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewResourceWizard;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewTextResourceWizard;
import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewWizard;
import org.eclipse.emf.cdo.internal.ui.actions.TransactionalBackgroundAction;
import org.eclipse.emf.cdo.internal.ui.dialogs.SelectClassDialog;
@@ -55,6 +59,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
@@ -181,27 +186,7 @@ public class NewActionProvider extends CommonActionProvider implements ISelectio
IMenuManager submenu = new MenuManager("&New", NEW_MENU_NAME);
- // Fill the menu from the commonWizard contributions.
- newWizardActionGroup.setContext(getContext());
- newWizardActionGroup.fillContextMenu(submenu);
-
- // Filter out the dubious "Ecore Diagram" action that appears everywhere.
- for (IContributionItem item : submenu.getItems())
- {
- if (item instanceof ActionContributionItem)
- {
- ActionContributionItem actionItem = (ActionContributionItem)item;
- IAction action = actionItem.getAction();
- if (action != null)
- {
- if ("Ecore Diagram".equals(action.getText()))
- {
- submenu.remove(item);
- break;
- }
- }
- }
- }
+ fillNewWizardActions(submenu);
if (selectedObject instanceof CDOResource)
{
@@ -230,6 +215,95 @@ public class NewActionProvider extends CommonActionProvider implements ISelectio
menu.insertAfter(ICommonMenuConstants.GROUP_NEW, submenu);
}
+ private void fillNewWizardActions(IMenuManager menu)
+ {
+ // Fill the menu from the commonWizard contributions.
+ newWizardActionGroup.setContext(getContext());
+ newWizardActionGroup.fillContextMenu(menu);
+
+ IContributionItem newResourceFolderItem = null;
+ IContributionItem newModelResourceItem = null;
+ IContributionItem newBinaryFileItem = null;
+ IContributionItem newTextFileItem = null;
+
+ String firstID = null;
+ IContributionItem[] newWizardItems = menu.getItems();
+ for (IContributionItem newWizardItem : newWizardItems)
+ {
+ if (newWizardItem instanceof ActionContributionItem)
+ {
+ IAction action = ((ActionContributionItem)newWizardItem).getAction();
+ if (action instanceof IPluginContribution)
+ {
+ IPluginContribution pluginContribution = (IPluginContribution)action;
+ String id = pluginContribution.getLocalId();
+ if (NewFolderWizard.ID.equals(id))
+ {
+ newResourceFolderItem = menu.remove(newWizardItem);
+ continue;
+ }
+
+ if (NewResourceWizard.ID.equals(id))
+ {
+ newModelResourceItem = menu.remove(newWizardItem);
+ continue;
+ }
+
+ if (NewBinaryResourceWizard.ID.equals(id))
+ {
+ newBinaryFileItem = menu.remove(newWizardItem);
+ continue;
+ }
+
+ if (NewTextResourceWizard.ID.equals(id))
+ {
+ newTextFileItem = menu.remove(newWizardItem);
+ continue;
+ }
+ }
+
+ // Filter out the dubious "Ecore Diagram" action that appears everywhere.
+ if ("Ecore Diagram".equals(action.getText()))
+ {
+ menu.remove(newWizardItem);
+ continue;
+ }
+ }
+
+ if (firstID == null)
+ {
+ firstID = newWizardItem.getId();
+ }
+ }
+
+ if (firstID == null)
+ {
+ Separator group = new Separator("cdo-new-wizards");
+ menu.add(group);
+ firstID = group.getId();
+ }
+
+ if (newResourceFolderItem != null)
+ {
+ menu.insertBefore(firstID, newResourceFolderItem);
+ }
+
+ if (newModelResourceItem != null)
+ {
+ menu.insertBefore(firstID, newModelResourceItem);
+ }
+
+ if (newBinaryFileItem != null)
+ {
+ menu.insertBefore(firstID, newBinaryFileItem);
+ }
+
+ if (newTextFileItem != null)
+ {
+ menu.insertBefore(firstID, newTextFileItem);
+ }
+ }
+
private void fillNewRootActions(IMenuManager menu, final CDOCheckout checkout, final CDOResource resource)
{
CDOPackageRegistry packageRegistry = resource.cdoView().getSession().getPackageRegistry();
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewBinaryResourceWizard.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewBinaryResourceWizard.java
index 053a51792d..c15c72470d 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewBinaryResourceWizard.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewBinaryResourceWizard.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.eresource.EresourceFactory;
*/
public class NewBinaryResourceWizard extends NewWizard
{
+ public static final String ID = "org.eclipse.emf.cdo.explorer.ui.new.resource.binary";
+
public NewBinaryResourceWizard()
{
super("binary", "New Binary File");
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewFolderWizard.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewFolderWizard.java
index 9094fe15d5..1129aa0c12 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewFolderWizard.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewFolderWizard.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.eresource.EresourceFactory;
*/
public class NewFolderWizard extends NewWizard
{
+ public static final String ID = "org.eclipse.emf.cdo.explorer.ui.new.folder";
+
public NewFolderWizard()
{
super("folder", "New Folder");
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewResourceWizard.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewResourceWizard.java
index 544cff2898..1258d2accb 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewResourceWizard.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewResourceWizard.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.eresource.EresourceFactory;
*/
public class NewResourceWizard extends NewWizard
{
+ public static final String ID = "org.eclipse.emf.cdo.explorer.ui.new.resource";
+
public NewResourceWizard()
{
super("model", "New Model Resource");
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewTextResourceWizard.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewTextResourceWizard.java
index f560845b41..a32d693054 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewTextResourceWizard.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/NewTextResourceWizard.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.eresource.EresourceFactory;
*/
public class NewTextResourceWizard extends NewWizard
{
+ public static final String ID = "org.eclipse.emf.cdo.explorer.ui.new.resource.text";
+
public NewTextResourceWizard()
{
super("text", "New Text File");

Back to the top