Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-02-08 20:28:55 +0000
committerEike Stepper2015-02-18 14:40:42 +0000
commit8f64246fab05a52e74011c1d4d1aa6cc58189ee2 (patch)
treeb4b139aa8b8b4557ae433b006e6d9394714c4f7d /plugins/org.eclipse.emf.cdo.ui
parent716e64491628f9309b6d165acc09d4e005d73e4c (diff)
downloadcdo-8f64246fab05a52e74011c1d4d1aa6cc58189ee2.tar.gz
cdo-8f64246fab05a52e74011c1d4d1aa6cc58189ee2.tar.xz
cdo-8f64246fab05a52e74011c1d4d1aa6cc58189ee2.zip
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeAction.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTopLevelResourceNodeAction.java186
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundAction.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ExportResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceActionDelegate.java)5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ImportResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceActionDelegate.java)5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewBinaryResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewBinaryResourceActionDelegate.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceActionDelegate.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceFolderActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceFolderActionDelegate.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceNodeActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeActionDelegate.java)6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewTextResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTextResourceActionDelegate.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RemoveResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveResourceActionDelegate.java)4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RenameResourceActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RenameResourceActionDelegate.java)4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/TransactionalBackgroundActionDelegate.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundActionDelegate.java)4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java373
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java50
19 files changed, 655 insertions, 331 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index 0dc08c68a3..e0be83294a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.ui;singleton:=true
-Bundle-Version: 4.3.100.qualifier
+Bundle-Version: 4.4.0.qualifier
Bundle-Activator: org.eclipse.emf.cdo.internal.ui.bundle.OM$Activator
Bundle-Vendor: %providerName
Bundle-ClassPath: .
@@ -23,8 +23,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";reso
org.eclipse.emf.cdo.transfer.ui;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.transfer.repository;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.ui.shared;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.ui.messages;version="4.3.100";
+Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -34,7 +33,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.actions;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -44,7 +43,9 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.actions;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.actions.delegates;version="4.4.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.ui.bundle;version="4.4.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.ui.dialogs;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -54,7 +55,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.dialogs;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.dnd;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -64,7 +65,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.dnd;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.editor;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -74,7 +75,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.editor;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.filters;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -84,7 +85,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.filters;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.history;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -94,7 +95,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.history;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.messages;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -104,7 +105,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.perspectives;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.perspectives;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -114,7 +115,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.preferences;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.preferences;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -124,7 +125,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.transfer;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.transfer;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -134,7 +135,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.internal.ui.views;version="4.3.100";
+ org.eclipse.emf.cdo.internal.ui.views;version="4.4.0";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.ui.location,
@@ -144,5 +145,5 @@ Export-Package: org.eclipse.emf.cdo.internal.ui.bundle;version="4.3.100";x-inter
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.ui.team,
org.eclipse.emf.cdo.ui.compare",
- org.eclipse.emf.cdo.ui;version="4.3.100",
- org.eclipse.emf.cdo.ui.widgets;version="4.3.100"
+ org.eclipse.emf.cdo.ui;version="4.4.0",
+ org.eclipse.emf.cdo.ui.widgets;version="4.4.0"
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index 9fc7b0fc11..b17d933aae 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -197,7 +197,7 @@
</provider>
</extension>
- <extension
+ <!--extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
@@ -288,6 +288,6 @@
<test property="org.eclipse.emf.cdo.object.readable" value="true"/>
</enablement>
</objectContribution>
- </extension>
+ </extension-->
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeAction.java
index 12ba0dbe33..378b0c3edd 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeAction.java
@@ -1,65 +1,68 @@
/*
- * Copyright (c) 2012, 2013 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
*/
package org.eclipse.emf.cdo.internal.ui.actions;
-import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.actions.NewTopLevelResourceNodeAction.Type;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.ui.CDOItemProvider;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPage;
/**
* @author Eike Stepper
*/
-public class NewResourceNodeAction extends AbstractViewAction
+public abstract class NewResourceNodeAction extends TransactionalBackgroundAction
{
- private CDOItemProvider itemProvider;
+ private final Type type;
- private CDOResourceNode selectedNode;
+ private String name;
- private Type type;
+ public NewResourceNodeAction(IWorkbenchPage page, Type type, CDOObject object)
+ {
+ super(page, type.getTitle(), type.getTooltip(), type.getImageDescriptor(), object);
+ this.type = type;
+ }
- private String resourceNodeName;
+ public final Type getType()
+ {
+ return type;
+ }
- public NewResourceNodeAction(CDOItemProvider itemProvider, IWorkbenchPage page, CDOView view, CDOResourceNode node,
- Type type)
+ public final String getName()
{
- super(page, type.getTitle() + INTERACTIVE, type.getTooltip(), type.getImageDescriptor(), view);
- selectedNode = node;
- this.itemProvider = itemProvider;
- this.type = type;
+ return name;
}
@Override
- protected void preRun() throws Exception
+ protected void preRun()
{
- InputDialog dialog = new InputDialog(getShell(), type.getTitle(), Messages.getString("NewResourceNodeAction.8"),
- (type == Type.FOLDER ? "folder" : "resource") + (AbstractViewAction.lastResourceNumber + 1),
- new ResourceNodeNameInputValidator(selectedNode));
+ CDOResourceNode object = (CDOResourceNode)getObject();
- if (dialog.open() == InputDialog.OK)
+ String initialValue = (type == Type.FOLDER ? "folder" : "resource") + (AbstractViewAction.lastResourceNumber + 1);
+ InputDialog dialog = new InputDialog(getShell(), getText(), Messages.getString("NewResourceNodeAction.8"),
+ initialValue, new ResourceNodeNameInputValidator(object));
+ if (dialog.open() == Dialog.OK)
{
++AbstractViewAction.lastResourceNumber;
- resourceNodeName = dialog.getValue();
+ name = dialog.getValue();
}
else
{
@@ -68,119 +71,96 @@ public class NewResourceNodeAction extends AbstractViewAction
}
@Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
+ protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
+ throws Exception
{
- CDOTransaction transaction = getTransaction();
- CDOResourceNode node = null;
+ CDOResourceNode newResourceNode = createNewResourceNode();
+ newResourceNode.setName(name);
- switch (type)
+ if (object instanceof CDOResourceFolder)
+ {
+ ((CDOResourceFolder)object).getNodes().add(newResourceNode);
+ }
+ else
{
- case FOLDER:
- node = EresourceFactory.eINSTANCE.createCDOResourceFolder();
- node.setName(resourceNodeName);
- if (selectedNode instanceof CDOResourceFolder)
- {
- ((CDOResourceFolder)selectedNode).getNodes().add(node);
- }
- else
- {
- ((CDOResource)selectedNode).getContents().add(node); // selectedNode is root resource
- }
-
- break;
-
- case MODEL:
- if (selectedNode instanceof CDOResourceFolder)
- {
- node = transaction.createResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
- }
- else
- {
- node = transaction.createResource(resourceNodeName);
- }
-
- break;
-
- case TEXT:
- if (selectedNode instanceof CDOResourceFolder)
- {
- node = transaction.createTextResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
- }
- else
- {
- node = transaction.createTextResource(resourceNodeName);
- }
-
- break;
-
- case BINARY:
- if (selectedNode instanceof CDOResourceFolder)
- {
- node = transaction.createBinaryResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
- }
- else
- {
- node = transaction.createBinaryResource(resourceNodeName);
- }
-
- break;
+ transaction.getRootResource().getContents().add(newResourceNode);
}
+ }
- transaction.commit();
+ protected abstract CDOResourceNode createNewResourceNode();
- itemProvider.refreshViewer(true);
- itemProvider.selectElement(node, true);
+ /**
+ * @author Eike Stepper
+ */
+ public static class Folder extends NewResourceNodeAction
+ {
+ public Folder(IWorkbenchPage page, CDOObject object)
+ {
+ super(page, Type.FOLDER, object);
+ }
- if (type == Type.MODEL)
+ @Override
+ protected CDOResourceNode createNewResourceNode()
{
- String resourcePath = node.getPath();
- CDOEditorUtil.openEditor(getPage(), transaction, resourcePath);
+ return EresourceFactory.eINSTANCE.createCDOResourceFolder();
}
}
/**
* @author Eike Stepper
*/
- public static enum Type
+ public static class Model extends NewResourceNodeAction
{
- FOLDER(Messages.getString("Title.Folder"), Messages.getString("Tooltip.Folder"), SharedIcons
- .getDescriptor(SharedIcons.ETOOL_NEW_RESOURCE_FOLDER)),
-
- MODEL(Messages.getString("Title.Model"), Messages.getString("Tooltip.Model"), SharedIcons
- .getDescriptor(SharedIcons.ETOOL_NEW_RESOURCE)),
-
- TEXT(Messages.getString("Title.Text"), Messages.getString("Tooltip.Text"), SharedIcons
- .getDescriptor(SharedIcons.ETOOL_NEW_TEXT_RESOURCE)),
-
- BINARY(Messages.getString("Title.Binary"), Messages.getString("Tooltip.Binary"), SharedIcons
- .getDescriptor(SharedIcons.ETOOL_NEW_BINARY_RESOURCE));
-
- private String title;
+ public Model(IWorkbenchPage page, CDOObject object)
+ {
+ super(page, Type.MODEL, object);
+ }
- private String tooltip;
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ return EresourceFactory.eINSTANCE.createCDOResource();
+ }
- private ImageDescriptor imageDescriptor;
+ @Override
+ protected void postRun(CDOView view, CDOObject object)
+ {
+ String resourcePath = ((CDOResourceNode)object).getPath() + "/" + getName();
+ CDOEditorUtil.openEditor(getPage(), view, resourcePath);
+ }
+ }
- private Type(String title, String tooltip, ImageDescriptor imageDescriptor)
+ /**
+ * @author Eike Stepper
+ */
+ public static class Binary extends NewResourceNodeAction
+ {
+ public Binary(IWorkbenchPage page, CDOObject object)
{
- this.title = title;
- this.tooltip = tooltip;
- this.imageDescriptor = imageDescriptor;
+ super(page, Type.BINARY, object);
}
- public String getTitle()
+ @Override
+ protected CDOResourceNode createNewResourceNode()
{
- return title;
+ return EresourceFactory.eINSTANCE.createCDOBinaryResource();
}
+ }
- public String getTooltip()
+ /**
+ * @author Eike Stepper
+ */
+ public static class Text extends NewResourceNodeAction
+ {
+ public Text(IWorkbenchPage page, CDOObject object)
{
- return tooltip;
+ super(page, Type.TEXT, object);
}
- public ImageDescriptor getImageDescriptor()
+ @Override
+ protected CDOResourceNode createNewResourceNode()
{
- return imageDescriptor;
+ return EresourceFactory.eINSTANCE.createCDOTextResource();
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTopLevelResourceNodeAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTopLevelResourceNodeAction.java
new file mode 100644
index 0000000000..beef49f580
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTopLevelResourceNodeAction.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2012, 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Victor Roldan Betancort - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.ui.CDOEditorUtil;
+import org.eclipse.emf.cdo.ui.CDOItemProvider;
+import org.eclipse.emf.cdo.ui.shared.SharedIcons;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public class NewTopLevelResourceNodeAction extends AbstractViewAction
+{
+ private CDOItemProvider itemProvider;
+
+ private CDOResourceNode selectedNode;
+
+ private Type type;
+
+ private String resourceNodeName;
+
+ public NewTopLevelResourceNodeAction(CDOItemProvider itemProvider, IWorkbenchPage page, CDOView view,
+ CDOResourceNode node, Type type)
+ {
+ super(page, type.getTitle() + INTERACTIVE, type.getTooltip(), type.getImageDescriptor(), view);
+ selectedNode = node;
+ this.itemProvider = itemProvider;
+ this.type = type;
+ }
+
+ @Override
+ protected void preRun() throws Exception
+ {
+ String initialValue = (type == Type.FOLDER ? "folder" : "resource") + (AbstractViewAction.lastResourceNumber + 1);
+ InputDialog dialog = new InputDialog(getShell(), getText(), Messages.getString("NewResourceNodeAction.8"),
+ initialValue, new ResourceNodeNameInputValidator(selectedNode));
+
+ if (dialog.open() == InputDialog.OK)
+ {
+ ++AbstractViewAction.lastResourceNumber;
+ resourceNodeName = dialog.getValue();
+ }
+ else
+ {
+ cancel();
+ }
+ }
+
+ @Override
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
+ {
+ CDOTransaction transaction = getTransaction();
+ CDOResourceNode node = null;
+
+ switch (type)
+ {
+ case FOLDER:
+ node = EresourceFactory.eINSTANCE.createCDOResourceFolder();
+ node.setName(resourceNodeName);
+ if (selectedNode instanceof CDOResourceFolder)
+ {
+ ((CDOResourceFolder)selectedNode).getNodes().add(node);
+ }
+ else
+ {
+ ((CDOResource)selectedNode).getContents().add(node); // selectedNode is root resource
+ }
+
+ break;
+
+ case MODEL:
+ if (selectedNode instanceof CDOResourceFolder)
+ {
+ node = transaction.createResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
+ }
+ else
+ {
+ node = transaction.createResource(resourceNodeName);
+ }
+
+ break;
+
+ case TEXT:
+ if (selectedNode instanceof CDOResourceFolder)
+ {
+ node = transaction.createTextResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
+ }
+ else
+ {
+ node = transaction.createTextResource(resourceNodeName);
+ }
+
+ break;
+
+ case BINARY:
+ if (selectedNode instanceof CDOResourceFolder)
+ {
+ node = transaction.createBinaryResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
+ }
+ else
+ {
+ node = transaction.createBinaryResource(resourceNodeName);
+ }
+
+ break;
+ }
+
+ transaction.commit();
+
+ itemProvider.refreshViewer(true);
+ itemProvider.selectElement(node, true);
+
+ if (type == Type.MODEL)
+ {
+ String resourcePath = node.getPath();
+ CDOEditorUtil.openEditor(getPage(), transaction, resourcePath);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static enum Type
+ {
+ FOLDER(Messages.getString("Title.Folder"), Messages.getString("Tooltip.Folder"), SharedIcons
+ .getDescriptor(SharedIcons.ETOOL_NEW_RESOURCE_FOLDER)),
+
+ MODEL(Messages.getString("Title.Model"), Messages.getString("Tooltip.Model"), SharedIcons
+ .getDescriptor(SharedIcons.ETOOL_NEW_RESOURCE)),
+
+ TEXT(Messages.getString("Title.Text"), Messages.getString("Tooltip.Text"), SharedIcons
+ .getDescriptor(SharedIcons.ETOOL_NEW_TEXT_RESOURCE)),
+
+ BINARY(Messages.getString("Title.Binary"), Messages.getString("Tooltip.Binary"), SharedIcons
+ .getDescriptor(SharedIcons.ETOOL_NEW_BINARY_RESOURCE));
+
+ private String title;
+
+ private String tooltip;
+
+ private ImageDescriptor imageDescriptor;
+
+ private Type(String title, String tooltip, ImageDescriptor imageDescriptor)
+ {
+ this.title = title;
+ this.tooltip = tooltip;
+ this.imageDescriptor = imageDescriptor;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public String getTooltip()
+ {
+ return tooltip;
+ }
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return imageDescriptor;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java
index bcdfa83458..c06c4c004e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java
@@ -49,10 +49,16 @@ public class ResourceNodeNameInputValidator implements IInputValidator
return Messages.getString("NewResourceNodeAction.2"); //$NON-NLS-1$
}
- for (EObject nodeObject : node.eContents())
+ for (EObject childObject : node.eContents())
{
- CDOResourceNode node = (CDOResourceNode)nodeObject;
- if (node.getName().equals(newText))
+ CDOResourceNode child = (CDOResourceNode)childObject;
+
+ if (node.isRoot() && child.getFolder() != null)
+ {
+ continue;
+ }
+
+ if (child.getName().equals(newText))
{
return isFolder ? Messages.getString("NewResourceNodeAction.5") + " " + newText : Messages.getString("NewResourceNodeAction.6") //$NON-NLS-1$ //$NON-NLS-2$
+ " " + newText;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundAction.java
new file mode 100644
index 0000000000..4f2ea8ea92
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundAction.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.ui.actions.LongRunningAction;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class TransactionalBackgroundAction extends LongRunningAction
+{
+ private final CDOObject object;
+
+ public TransactionalBackgroundAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
+ CDOObject object)
+ {
+ super(page, text, toolTipText, image);
+ this.object = object;
+ }
+
+ public final CDOObject getObject()
+ {
+ return object;
+ }
+
+ @Override
+ protected final void doRun(IProgressMonitor progressMonitor) throws Exception
+ {
+ progressMonitor.beginTask(Messages.getString("TransactionalBackgroundAction_1"), 100); //$NON-NLS-1$
+
+ CDOView view = object.cdoView();
+ CDOSession session = view.getSession();
+ CDOTransaction transaction = session.openTransaction(view.getBranch());
+ OpenTransactionAction.configureTransaction(transaction);
+
+ CDOObject transactionalObject = transaction.getObject(object);
+ progressMonitor.worked(5);
+
+ CDOCommitInfo commitInfo = null;
+
+ try
+ {
+ doRun(transaction, transactionalObject, new SubProgressMonitor(progressMonitor, 5));
+ commitInfo = transaction.commit(new SubProgressMonitor(progressMonitor, 90));
+ }
+ finally
+ {
+ progressMonitor.done();
+ transaction.close();
+ transactionalObject = null;
+ }
+
+ if (commitInfo != null)
+ {
+ view.waitForUpdate(commitInfo.getTimeStamp(), 5000);
+ postRun(view, object);
+ }
+ }
+
+ protected abstract void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
+ throws Exception;
+
+ protected void postRun(CDOView view, CDOObject object)
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ExportResourceActionDelegate.java
index 5db65fc693..d4eb247b60 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ExportResourceActionDelegate.java
@@ -9,14 +9,14 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionCommentator;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.net4j.util.io.IORuntimeException;
@@ -42,6 +42,7 @@ import java.util.List;
/**
* @author Victor Roldan Betancort
*/
+@Deprecated
public class ExportResourceActionDelegate extends TransactionalBackgroundActionDelegate
{
private URI targetURI;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ImportResourceActionDelegate.java
index 427403224c..36740755fd 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/ImportResourceActionDelegate.java
@@ -9,15 +9,15 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionCommentator;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -36,6 +36,7 @@ import java.util.List;
/**
* @author Victor Roldan Betancort
*/
+@Deprecated
public class ImportResourceActionDelegate extends NewResourceActionDelegate
{
private URI sourceURI;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewBinaryResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewBinaryResourceActionDelegate.java
index c87425c8cf..bdb5ca813a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewBinaryResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewBinaryResourceActionDelegate.java
@@ -9,7 +9,7 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.ui.messages.Messages;
/**
* @author Eike Stepper
*/
+@Deprecated
public class NewBinaryResourceActionDelegate extends NewResourceNodeActionDelegate
{
public NewBinaryResourceActionDelegate()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceActionDelegate.java
index 9f3fa6307d..5f22eae223 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceActionDelegate.java
@@ -9,7 +9,7 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.ui.messages.Messages;
/**
* @author Eike Stepper
*/
+@Deprecated
public class NewResourceActionDelegate extends NewResourceNodeActionDelegate
{
public NewResourceActionDelegate()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceFolderActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceFolderActionDelegate.java
index 081055bcb3..917ec00be6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceFolderActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceFolderActionDelegate.java
@@ -9,7 +9,7 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.ui.messages.Messages;
/**
* @author Eike Stepper
*/
+@Deprecated
public class NewResourceFolderActionDelegate extends NewResourceNodeActionDelegate
{
public NewResourceFolderActionDelegate()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceNodeActionDelegate.java
index aa0aa2986a..3daa305827 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewResourceNodeActionDelegate.java
@@ -9,13 +9,14 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
@@ -24,6 +25,7 @@ import org.eclipse.jface.dialogs.InputDialog;
/**
* @author Eike Stepper
*/
+@Deprecated
public abstract class NewResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate
{
private CDOResourceNode newResourceNode;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTextResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewTextResourceActionDelegate.java
index 40fd74fd58..55ab7545e0 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTextResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/NewTextResourceActionDelegate.java
@@ -9,7 +9,7 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.ui.messages.Messages;
/**
* @author Eike Stepper
*/
+@Deprecated
public class NewTextResourceActionDelegate extends NewResourceNodeActionDelegate
{
public NewTextResourceActionDelegate()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RemoveResourceActionDelegate.java
index 3450b46141..9823785330 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RemoveResourceActionDelegate.java
@@ -9,12 +9,13 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -43,6 +44,7 @@ import java.util.Map;
/**
* @author Victor Roldan Betancort
*/
+@Deprecated
public class RemoveResourceActionDelegate implements IObjectActionDelegate
{
// private Image deleteIcon;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RenameResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RenameResourceActionDelegate.java
index 3b251a9960..f80b461883 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RenameResourceActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/RenameResourceActionDelegate.java
@@ -9,10 +9,11 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -23,6 +24,7 @@ import org.eclipse.jface.dialogs.InputDialog;
/**
* @author Victor Roldan Betancort
*/
+@Deprecated
public class RenameResourceActionDelegate extends TransactionalBackgroundActionDelegate
{
private String newResourceName;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/TransactionalBackgroundActionDelegate.java
index 1ad94e9afe..771710b132 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/TransactionalBackgroundActionDelegate.java
@@ -9,9 +9,10 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.cdo.internal.ui.actions;
+package org.eclipse.emf.cdo.internal.ui.actions.delegates;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -32,6 +33,7 @@ import java.text.MessageFormat;
/**
* @author Victor Roldan Betancort
*/
+@Deprecated
public abstract class TransactionalBackgroundActionDelegate extends LongRunningActionDelegate implements
IObjectActionDelegate
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index ac9ad827e8..c0dd97af26 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -2205,26 +2205,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This looks up a string in the plugin's plugin.properties file.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- * @generated
- */
- private static String getString(String key)
- {
- return PluginDelegator.INSTANCE.getString(key);
- }
-
- /**
- * This looks up a string in plugin.properties, making a substitution.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- * @generated
- */
- private static String getString(String key, Object s1)
- {
- return PluginDelegator.INSTANCE.getString(key, new Object[] { s1 });
- }
-
- /**
* This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
@@ -2241,7 +2221,17 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
menuAboutToShowGen(menuManager);
MenuManager submenuManager = new MenuManager(Messages.getString("CDOEditor.23")); //$NON-NLS-1$
- if (populateNewRoot(submenuManager))
+
+ NewRootMenuPopulator populator = new NewRootMenuPopulator(view.getSession().getPackageRegistry())
+ {
+ @Override
+ protected IAction createAction(EObject object)
+ {
+ return new CreateRootAction(object);
+ }
+ };
+
+ if (populator.populateMenu(submenuManager))
{
menuManager.insertBefore("edit", submenuManager); //$NON-NLS-1$
}
@@ -2308,157 +2298,6 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * @ADDED
- */
- protected boolean populateNewRoot(MenuManager menuManager)
- {
- boolean populated = false;
- CDOPackageRegistry packageRegistry = view.getSession().getPackageRegistry();
- for (Map.Entry<String, Object> entry : EMFUtil.getSortedRegistryEntries(packageRegistry))
- {
- IContributionItem item = populateSubMenu(entry.getKey(), entry.getValue(), packageRegistry);
- if (item != null)
- {
- menuManager.add(item);
- populated = true;
- }
- }
-
- return populated;
- }
-
- /**
- * @ADDED
- */
- protected IContributionItem populateSubMenu(String nsURI, Object value, final CDOPackageRegistry packageRegistry)
- {
- if (value instanceof EPackage)
- {
- EPackage ePackage = (EPackage)value;
- CDOPackageInfo packageInfo = packageRegistry.getPackageInfo(ePackage);
- CDOPackageUnit packageUnit = packageInfo.getPackageUnit();
- if (packageUnit.isResource())
- {
- return null;
- }
-
- ImageDescriptor imageDescriptor = SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE);
- MenuManager submenuManager = new MenuManager(nsURI, imageDescriptor, nsURI);
- populateSubMenu(ePackage, submenuManager);
- return submenuManager;
- }
-
- ImageDescriptor imageDescriptor = SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_UNKNOWN);
- final MenuManager submenuManager = new MenuManager(nsURI, imageDescriptor, nsURI);
- submenuManager.setRemoveAllWhenShown(true);
- submenuManager.add(new Action(Messages.getString("CDOEditor.27")) //$NON-NLS-1$
- {
- });
-
- submenuManager.addMenuListener(new IMenuListener()
- {
- public void menuAboutToShow(IMenuManager manager)
- {
- String nsURI = submenuManager.getMenuText();
- EPackage ePackage = packageRegistry.getEPackage(nsURI);
-
- if (ePackage != null)
- {
- populateSubMenu(ePackage, submenuManager);
- }
- else
- {
- OM.LOG.warn(MessageFormat.format(Messages.getString("CDOEditor.28"), nsURI)); //$NON-NLS-1$
- }
- }
- });
-
- return submenuManager;
- }
-
- /**
- * @ADDED
- */
- protected void populateSubMenu(EPackage ePackage, final MenuManager submenuManager)
- {
- List<EObject> objects = new ArrayList<EObject>();
- for (EClassifier eClassifier : ePackage.getEClassifiers())
- {
- if (eClassifier instanceof EClass)
- {
- EClass eClass = (EClass)eClassifier;
- if (!eClass.isAbstract() && !eClass.isInterface())
- {
- objects.add(EcoreUtil.create(eClass));
- }
- }
- }
-
- if (!objects.isEmpty())
- {
- Collections.sort(objects, new Comparator<EObject>()
- {
- public int compare(EObject o1, EObject o2)
- {
- return o1.eClass().getName().compareTo(o2.eClass().getName());
- }
- });
-
- for (EObject object : objects)
- {
- CreateRootAction action = new CreateRootAction(object);
- submenuManager.add(action);
- }
- }
- }
-
- /**
- * @ADDED
- */
- protected String getLabelText(Object object)
- {
- try
- {
- IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class);
- if (labelProvider != null)
- {
- String text = labelProvider.getText(object);
- if (text != null)
- {
- return text;
- }
- }
- }
- catch (Exception ignore)
- {
- ignore.printStackTrace();
- }
-
- return ""; //$NON-NLS-1$
- }
-
- /**
- * @ADDED
- */
- protected Object getLabelImage(Object object)
- {
- try
- {
- IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class);
- if (labelProvider != null)
- {
- return labelProvider.getImage(object);
- }
- }
- catch (Exception ignore)
- {
- ignore.printStackTrace();
- }
-
- return null;
- }
-
- /**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@@ -2676,6 +2515,83 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
}
+ /**
+ * @ADDED
+ */
+ public static String getLabelText(AdapterFactory adapterFactory, Object object)
+ {
+ try
+ {
+ IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class);
+ if (labelProvider != null)
+ {
+ String text = labelProvider.getText(object);
+ if (text != null)
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ if (object != null)
+ {
+ String text = object.getClass().getSimpleName();
+ if (text.endsWith("Impl"))
+ {
+ text = text.substring(0, text.length() - "Impl".length());
+ }
+
+ return text;
+ }
+
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * @ADDED
+ */
+ public static Object getLabelImage(AdapterFactory adapterFactory, Object object)
+ {
+ try
+ {
+ IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class);
+ if (labelProvider != null)
+ {
+ return labelProvider.getImage(object);
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return null;
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key)
+ {
+ return PluginDelegator.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1)
+ {
+ return PluginDelegator.INSTANCE.getString(key, new Object[] { s1 });
+ }
+
private static Field getViewerField()
{
try
@@ -2690,6 +2606,116 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @author Eike Stepper
+ */
+ public static abstract class NewRootMenuPopulator
+ {
+ private final CDOPackageRegistry packageRegistry;
+
+ public NewRootMenuPopulator(CDOPackageRegistry packageRegistry)
+ {
+ this.packageRegistry = packageRegistry;
+ }
+
+ public boolean populateMenu(IMenuManager menuManager)
+ {
+ boolean populated = false;
+ for (Map.Entry<String, Object> entry : EMFUtil.getSortedRegistryEntries(packageRegistry))
+ {
+ IContributionItem item = populateSubMenu(entry.getKey(), entry.getValue(), packageRegistry);
+ if (item != null)
+ {
+ menuManager.add(item);
+ populated = true;
+ }
+ }
+
+ return populated;
+ }
+
+ protected IContributionItem populateSubMenu(String nsURI, Object value, final CDOPackageRegistry packageRegistry)
+ {
+ if (value instanceof EPackage)
+ {
+ EPackage ePackage = (EPackage)value;
+ CDOPackageInfo packageInfo = packageRegistry.getPackageInfo(ePackage);
+ CDOPackageUnit packageUnit = packageInfo.getPackageUnit();
+ if (packageUnit.isResource())
+ {
+ return null;
+ }
+
+ ImageDescriptor imageDescriptor = SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE);
+ MenuManager submenuManager = new MenuManager(nsURI, imageDescriptor, nsURI);
+ populateSubMenu(ePackage, submenuManager);
+ return submenuManager;
+ }
+
+ ImageDescriptor imageDescriptor = SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_UNKNOWN);
+ final MenuManager submenuManager = new MenuManager(nsURI, imageDescriptor, nsURI);
+ submenuManager.setRemoveAllWhenShown(true);
+ submenuManager.add(new Action(Messages.getString("CDOEditor.27")) //$NON-NLS-1$
+ {
+ });
+
+ submenuManager.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ String nsURI = submenuManager.getMenuText();
+ EPackage ePackage = packageRegistry.getEPackage(nsURI);
+
+ if (ePackage != null)
+ {
+ populateSubMenu(ePackage, submenuManager);
+ }
+ else
+ {
+ OM.LOG.warn(MessageFormat.format(Messages.getString("CDOEditor.28"), nsURI)); //$NON-NLS-1$
+ }
+ }
+ });
+
+ return submenuManager;
+ }
+
+ protected void populateSubMenu(EPackage ePackage, final IMenuManager submenuManager)
+ {
+ List<EObject> objects = new ArrayList<EObject>();
+ for (EClassifier eClassifier : ePackage.getEClassifiers())
+ {
+ if (eClassifier instanceof EClass)
+ {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract() && !eClass.isInterface())
+ {
+ objects.add(EcoreUtil.create(eClass));
+ }
+ }
+ }
+
+ if (!objects.isEmpty())
+ {
+ Collections.sort(objects, new Comparator<EObject>()
+ {
+ public int compare(EObject o1, EObject o2)
+ {
+ return o1.eClass().getName().compareTo(o2.eClass().getName());
+ }
+ });
+
+ for (EObject object : objects)
+ {
+ IAction action = createAction(object);
+ submenuManager.add(action);
+ }
+ }
+ }
+
+ protected abstract IAction createAction(EObject object);
+ }
+
+ /**
+ * @author Eike Stepper
* @ADDED
*/
protected class CreateRootAction extends LongRunningAction
@@ -2699,7 +2725,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected CreateRootAction(EObject object)
{
super(getEditorSite().getPage(), object.eClass().getName(), ExtendedImageRegistry.getInstance()
- .getImageDescriptor(getLabelImage(object)));
+ .getImageDescriptor(getLabelImage(adapterFactory, object)));
this.object = object;
}
@@ -2735,6 +2761,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
object = ((InternalCDOObject)object).cdoInternalInstance();
}
+ // TODO Use a command!
resource.getContents().add(object);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
index 9371174925..563d9ca3a7 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
@@ -211,10 +211,10 @@ SwitchTargetAction.0=Switch Target
SwitchTargetAction.1=Switch the target branch point
MergeBranchPointAction.0=Merge
MergeBranchPointAction.1=Merge changes from a different branch point
-Title.Binary=New Binary Resource
+Title.Binary=New Binary File
Title.Folder=New Folder
Title.Model=New Model Resource
-Title.Text=New Text Resource
+Title.Text=New Text File
Tooltip.Binary=Create a new binary resource
Tooltip.Folder=Create a new resource folder
Tooltip.Model=Create a new model resource
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
index d93a6d7412..7b592ccb34 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
@@ -40,8 +40,10 @@ import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.MergeBranchPointAction;
import org.eclipse.emf.cdo.internal.ui.actions.MergeConflictsAction;
import org.eclipse.emf.cdo.internal.ui.actions.NewResourceNodeAction;
+import org.eclipse.emf.cdo.internal.ui.actions.NewTopLevelResourceNodeAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenAuditAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenDurableViewAction;
+import org.eclipse.emf.cdo.internal.ui.actions.OpenResourceEditorAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterSinglePackageAction;
@@ -490,13 +492,9 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
{
fillBranch(manager, (CDOBranch)object);
}
- else if (object instanceof CDOResourceFolder)
+ else if (object instanceof CDOResourceNode)
{
- fillResourceFolder(manager, (CDOResourceFolder)object);
- }
- else if (object instanceof CDOResourceLeaf)
- {
- fillResourceLeaf(manager, object);
+ fillResourceNode(manager, (CDOResourceNode)object);
}
}
@@ -589,10 +587,14 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
CDOResource rootResource = view.getRootResource();
if (rootResource.cdoPermission() == CDOPermission.WRITE)
{
- manager.add(new NewResourceNodeAction(this, page, view, rootResource, NewResourceNodeAction.Type.FOLDER));
- manager.add(new NewResourceNodeAction(this, page, view, rootResource, NewResourceNodeAction.Type.MODEL));
- manager.add(new NewResourceNodeAction(this, page, view, rootResource, NewResourceNodeAction.Type.TEXT));
- manager.add(new NewResourceNodeAction(this, page, view, rootResource, NewResourceNodeAction.Type.BINARY));
+ manager.add(new NewTopLevelResourceNodeAction(this, page, view, rootResource,
+ NewTopLevelResourceNodeAction.Type.FOLDER));
+ manager.add(new NewTopLevelResourceNodeAction(this, page, view, rootResource,
+ NewTopLevelResourceNodeAction.Type.MODEL));
+ manager.add(new NewTopLevelResourceNodeAction(this, page, view, rootResource,
+ NewTopLevelResourceNodeAction.Type.TEXT));
+ manager.add(new NewTopLevelResourceNodeAction(this, page, view, rootResource,
+ NewTopLevelResourceNodeAction.Type.BINARY));
}
}
@@ -641,10 +643,32 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
}
/**
+ * @since 4.4
+ */
+ public void fillResourceNode(IMenuManager manager, CDOResourceNode node)
+ {
+ if (node instanceof CDOResourceFolder)
+ {
+ fillResourceFolder(manager, (CDOResourceFolder)node);
+ }
+ else if (node instanceof CDOResourceLeaf)
+ {
+ fillResourceLeaf(manager, node);
+ }
+ }
+
+ /**
* @since 4.2
*/
public void fillResourceFolder(IMenuManager manager, CDOResourceFolder folder)
{
+ if (!folder.cdoView().isReadOnly() && folder.cdoPermission() == CDOPermission.WRITE)
+ {
+ manager.add(new NewResourceNodeAction.Folder(page, folder));
+ manager.add(new NewResourceNodeAction.Model(page, folder));
+ manager.add(new NewResourceNodeAction.Binary(page, folder));
+ manager.add(new NewResourceNodeAction.Text(page, folder));
+ }
}
/**
@@ -673,7 +697,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
*/
public void fillResource(IMenuManager manager, CDOResource resource)
{
- // manager.add(new OpenResourceEditorAction(page, resource));
+ manager.add(new OpenResourceEditorAction(page, resource));
}
/**
@@ -681,7 +705,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
*/
public void fillTextResource(IMenuManager manager, CDOTextResource resource)
{
- // manager.add(new OpenResourceEditorAction(page, resource));
+ manager.add(new OpenResourceEditorAction(page, resource));
}
/**
@@ -689,7 +713,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
*/
public void fillBinaryResource(IMenuManager manager, CDOBinaryResource resource)
{
- // manager.add(new OpenResourceEditorAction(page, resource));
+ manager.add(new OpenResourceEditorAction(page, resource));
}
@Override

Back to the top