Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-08-29 09:47:19 +0000
committerEike Stepper2013-08-29 09:47:19 +0000
commitce63cf1331986cfb6c60b2b67423e62a832d4970 (patch)
tree04cb0a5aeedec2a35a1e14162222c8e3759fe290 /plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui
parent93aa53e384db6626bdb4dbadf489e45c90b27a66 (diff)
downloadcdo-ce63cf1331986cfb6c60b2b67423e62a832d4970.tar.gz
cdo-ce63cf1331986cfb6c60b2b67423e62a832d4970.tar.xz
cdo-ce63cf1331986cfb6c60b2b67423e62a832d4970.zip
[416122] [UI] Move IDE-independent actions from cdo.ui.ide to cdo.ui
https://bugs.eclipse.org/bugs/show_bug.cgi?id=416122
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceActionDelegate.java113
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceActionDelegate.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewBinaryResourceActionDelegate.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceActionDelegate.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceFolderActionDelegate.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeActionDelegate.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTextResourceActionDelegate.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveResourceActionDelegate.java133
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RenameResourceActionDelegate.java77
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundActionDelegate.java136
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties36
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOPerspective.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOExplorerPerspective.java)6
13 files changed, 878 insertions, 16 deletions
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/ExportResourceActionDelegate.java
new file mode 100644
index 0000000000..4226773ecb
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceActionDelegate.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2009, 2011, 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+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.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;
+
+import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class ExportResourceActionDelegate extends TransactionalBackgroundActionDelegate
+{
+ private URI targetURI;
+
+ public ExportResourceActionDelegate()
+ {
+ super(Messages.getString("ExportSelectedResourceAction_0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected final CDOObject preRun(CDOObject object)
+ {
+ ResourceDialog dialog = new ResourceDialog(new Shell(),
+ Messages.getString("ExportSelectedResourceAction_1"), SWT.SAVE); //$NON-NLS-1$
+ if (dialog.open() == ImportResourceDialog.OK)
+ {
+ List<URI> uris = dialog.getURIs();
+ if (uris.size() == 1)
+ {
+ targetURI = uris.get(0);
+ CDOTransaction transaction = object.cdoView().getSession().openTransaction();
+ new CDOTransactionCommentator(transaction);
+
+ CDOObject transactionalObject = transaction.getObject(object);
+ return transactionalObject;
+ }
+
+ MessageDialog.openError(new Shell(), Messages.getString("ExportResourceActionDelegate.0"), //$NON-NLS-1$
+ Messages.getString("ExportSelectedResourceAction_2")); //$NON-NLS-1$
+ cancel();
+ }
+ else
+ {
+ cancel();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) throws Exception
+ {
+ // Source Resource
+ Resource source = object instanceof CDOResource ? (CDOResource)object : object.cdoResource();
+ List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
+ exportObjects(sourceContents);
+ }
+
+ private void exportObjects(List<EObject> sourceContents)
+ {
+ // Target Resource
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
+ Resource resource = resourceSet.createResource(targetURI);
+
+ Collection<EObject> copiedRoots = EcoreUtil.copyAll(sourceContents);
+ resource.getContents().addAll(copiedRoots);
+
+ try
+ {
+ resource.save(null);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+}
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/ImportResourceActionDelegate.java
new file mode 100644
index 0000000000..cb37fc4fcc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceActionDelegate.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2009, 2011, 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+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.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;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class ImportResourceActionDelegate extends NewResourceActionDelegate
+{
+ private URI sourceURI;
+
+ public ImportResourceActionDelegate()
+ {
+ }
+
+ @Override
+ protected final CDOObject preRun(CDOObject object)
+ {
+ ImportResourceDialog dialog = new ImportResourceDialog(new Shell(),
+ Messages.getString("ImportResourceToFolderAction_0"), SWT.OPEN); //$NON-NLS-1$
+ if (dialog.open() == ImportResourceDialog.OK)
+ {
+ List<URI> uris = dialog.getURIs();
+ if (uris.size() == 1)
+ {
+ sourceURI = uris.get(0);
+ setNewResourceNode(createNewResourceNode());
+ getNewResourceNode().setName(dialog.getTargetPath());
+
+ CDOTransaction transaction = object.cdoView().getSession().openTransaction();
+ new CDOTransactionCommentator(transaction);
+
+ CDOObject transactionalObject = transaction.getObject(object);
+ return transactionalObject;
+ }
+
+ MessageDialog.openError(new Shell(), Messages.getString("ImportResourceActionDelegate.0"), //$NON-NLS-1$
+ Messages.getString("ImportResourceToFolderAction_1")); //$NON-NLS-1$
+ cancel();
+ }
+ else
+ {
+ cancel();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ CDOResource resource = (CDOResource)super.createNewResourceNode();
+
+ // Source ResourceSet
+ ResourceSet sourceSet = new ResourceSetImpl();
+ // sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry());
+
+ // Source Resource
+ Resource source = sourceSet.getResource(sourceURI, true);
+ List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
+
+ // Target Resource
+ EList<EObject> targetContents = resource.getContents();
+
+ // Move contents over
+ for (EObject root : sourceContents)
+ {
+ targetContents.add(root);
+ }
+
+ return resource;
+ }
+}
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/NewBinaryResourceActionDelegate.java
new file mode 100644
index 0000000000..1b22ec19a8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewBinaryResourceActionDelegate.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+
+/**
+ * @author Eike Stepper
+ */
+public class NewBinaryResourceActionDelegate extends NewResourceNodeActionDelegate
+{
+ public NewBinaryResourceActionDelegate()
+ {
+ super(Messages.getString("NewBinaryResourceAction_0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ return EresourceFactory.eINSTANCE.createCDOBinaryResource();
+ }
+}
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/NewResourceActionDelegate.java
new file mode 100644
index 0000000000..d6bf5a933c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceActionDelegate.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2009, 2011, 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+
+/**
+ * @author Eike Stepper
+ */
+public class NewResourceActionDelegate extends NewResourceNodeActionDelegate
+{
+ public NewResourceActionDelegate()
+ {
+ super(Messages.getString("NewResourceAction_0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ return EresourceFactory.eINSTANCE.createCDOResource();
+ }
+}
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/NewResourceFolderActionDelegate.java
new file mode 100644
index 0000000000..93566d2a1b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceFolderActionDelegate.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2009, 2011, 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+
+/**
+ * @author Eike Stepper
+ */
+public class NewResourceFolderActionDelegate extends NewResourceNodeActionDelegate
+{
+ public NewResourceFolderActionDelegate()
+ {
+ super(Messages.getString("NewResourceFolderAction_0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ return EresourceFactory.eINSTANCE.createCDOResourceFolder();
+ }
+}
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/NewResourceNodeActionDelegate.java
new file mode 100644
index 0000000000..9a5fdae99f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewResourceNodeActionDelegate.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2009-2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+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.messages.Messages;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class NewResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate
+{
+ private CDOResourceNode newResourceNode;
+
+ public NewResourceNodeActionDelegate(String text)
+ {
+ super(text);
+ }
+
+ @Override
+ protected CDOObject preRun(CDOObject object)
+ {
+ InputDialog dialog = new InputDialog(
+ getTargetPart().getSite().getShell(),
+ getText(),
+ Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$
+ if (dialog.open() == Dialog.OK)
+ {
+ setNewResourceNode(createNewResourceNode());
+ getNewResourceNode().setName(dialog.getValue());
+ return super.preRun(object);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
+ throws Exception
+ {
+ if (object instanceof CDOResourceFolder)
+ {
+ ((CDOResourceFolder)object).getNodes().add(getNewResourceNode());
+ }
+ else
+ {
+ transaction.getRootResource().getContents().add(getNewResourceNode());
+ }
+ }
+
+ protected void setNewResourceNode(CDOResourceNode newResourceNode)
+ {
+ this.newResourceNode = newResourceNode;
+ }
+
+ protected CDOResourceNode getNewResourceNode()
+ {
+ return newResourceNode;
+ }
+
+ protected abstract CDOResourceNode createNewResourceNode();
+}
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/NewTextResourceActionDelegate.java
new file mode 100644
index 0000000000..5f8a843cb7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/NewTextResourceActionDelegate.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+
+/**
+ * @author Eike Stepper
+ */
+public class NewTextResourceActionDelegate extends NewResourceNodeActionDelegate
+{
+ public NewTextResourceActionDelegate()
+ {
+ super(Messages.getString("NewTextResourceAction_0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CDOResourceNode createNewResourceNode()
+ {
+ return EresourceFactory.eINSTANCE.createCDOTextResource();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
new file mode 100644
index 0000000000..a4fb38b8df
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012 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.CDOFileResource;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
+import org.eclipse.emf.cdo.internal.ui.CDOLobEditorInput;
+import org.eclipse.emf.cdo.ui.CDOEditorUtil;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public final class OpenResourceEditorAction extends ResourceNodeAction
+{
+ private static final String TITLE = Messages.getString("OpenResourceEditorAction.0"); //$NON-NLS-1$
+
+ private static final String TOOL_TIP = Messages.getString("OpenResourceEditorAction.1"); //$NON-NLS-1$
+
+ private static final String FILE_TITLE = Messages.getString("OpenFileEditorAction.0"); //$NON-NLS-1$
+
+ private static final String FILE_TOOL_TIP = Messages.getString("OpenFileEditorAction.1"); //$NON-NLS-1$
+
+ public OpenResourceEditorAction(IWorkbenchPage page, CDOResourceLeaf resource)
+ {
+ super(page, resource instanceof CDOResource ? TITLE : FILE_TITLE, resource instanceof CDOResource ? TOOL_TIP
+ : FILE_TOOL_TIP, null, resource);
+ }
+
+ @Override
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
+ {
+ final CDOResourceLeaf resource = (CDOResourceLeaf)getResourceNode();
+ final IWorkbenchPage page = getPage();
+
+ if (resource instanceof CDOResource)
+ {
+ CDOView view = resource.cdoView();
+ String resourcePath = resource.getPath();
+ CDOEditorUtil.openEditor(page, view, resourcePath);
+ }
+ else if (resource instanceof CDOFileResource)
+ {
+ Display display = page.getWorkbenchWindow().getShell().getDisplay();
+ display.asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ IEditorInput input = new CDOLobEditorInput(resource);
+ page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ });
+ }
+ }
+}
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/RemoveResourceActionDelegate.java
new file mode 100644
index 0000000000..1ba9baafed
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveResourceActionDelegate.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2009, 2011, 2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+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.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionCommentator;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+import org.eclipse.emf.cdo.internal.ui.messages.Messages;
+
+import org.eclipse.net4j.util.ui.UIUtil;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class RemoveResourceActionDelegate implements IObjectActionDelegate
+{
+ // private Image deleteIcon;
+
+ private List<CDOResourceNode> nodes;
+
+ private Shell shell;
+
+ public RemoveResourceActionDelegate()
+ {
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ shell = targetPart.getSite().getShell();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ nodes = UIUtil.getElements(selection, CDOResourceNode.class);
+ }
+
+ public void run(IAction action)
+ {
+ if (MessageDialog.openConfirm(shell, Messages.getString("RemoveResourceAction_1"), MessageFormat.format( //$NON-NLS-1$
+ Messages.getString("RemoveResourceAction_2"), nodes.size()))) //$NON-NLS-1$
+ {
+ Job job = new Job(Messages.getString("RemoveResourceAction_3")) //$NON-NLS-1$
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ Map<Integer, CDOTransaction> repositoryToTransaction = new HashMap<Integer, CDOTransaction>();
+ for (CDOResourceNode node : nodes)
+ {
+ int sessionID = node.cdoView().getSession().getSessionID();
+ CDOTransaction transaction = repositoryToTransaction.get(sessionID);
+ if (transaction == null)
+ {
+ transaction = node.cdoView().getSession().openTransaction();
+ new CDOTransactionCommentator(transaction);
+ repositoryToTransaction.put(sessionID, transaction);
+ }
+
+ CDOObject writableNode = transaction.getObject(node.cdoID());
+ EObject container = writableNode.eContainer();
+ if (container == null)
+ {
+ container = (CDOResource)writableNode.eResource();
+ }
+
+ if (container instanceof CDOResource)
+ {
+ ((CDOResource)container).getContents().remove(writableNode);
+ }
+ else if (container instanceof CDOResourceFolder)
+ {
+ ((CDOResourceFolder)container).getNodes().remove(writableNode);
+ }
+ }
+
+ for (CDOTransaction transaction : repositoryToTransaction.values())
+ {
+ try
+ {
+ transaction.commit();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(MessageFormat.format(
+ Messages.getString("RemoveResourceAction_4"), this.getClass().getName().toString()), ex); //$NON-NLS-1$
+ }
+ finally
+ {
+ transaction.close();
+ }
+ }
+
+ // UIUtil.setStatusBarMessage(
+ // MessageFormat.format(Messages.getString("RemoveResourceAction_5"), nodes.size()), getDeleteIcon()); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.schedule();
+ }
+ }
+}
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/RenameResourceActionDelegate.java
new file mode 100644
index 0000000000..1e44507720
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RenameResourceActionDelegate.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2010-2012 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+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;
+import org.eclipse.jface.dialogs.InputDialog;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class RenameResourceActionDelegate extends TransactionalBackgroundActionDelegate
+{
+ private String newResourceName;
+
+ public RenameResourceActionDelegate()
+ {
+ super(Messages.getString("RenameResourceActionDelegate.0")); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CDOObject preRun(CDOObject object)
+ {
+ InputDialog dialog = new InputDialog(
+ getTargetPart().getSite().getShell(),
+ getText(),
+ Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$
+ if (dialog.open() == Dialog.OK)
+ {
+ setNewResourceName(dialog.getValue());
+ return super.preRun(object);
+ }
+
+ cancel();
+
+ return null;
+ }
+
+ private void setNewResourceName(String newName)
+ {
+ newResourceName = newName;
+ }
+
+ private String getNewResourceName()
+ {
+ return newResourceName;
+ }
+
+ @Override
+ protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
+ throws Exception
+ {
+ if (object instanceof CDOResourceNode)
+ {
+ ((CDOResourceNode)object).setName(getNewResourceName());
+ }
+ else
+ {
+ throw new IllegalArgumentException("object is not a CDOResourceNode"); //$NON-NLS-1$
+ }
+ }
+
+}
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/TransactionalBackgroundActionDelegate.java
new file mode 100644
index 0000000000..a2d5fddd07
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/TransactionalBackgroundActionDelegate.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2009, 2011-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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOObject;
+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.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.AdapterUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public abstract class TransactionalBackgroundActionDelegate extends LongRunningActionDelegate implements
+ IObjectActionDelegate
+{
+ private IWorkbenchPart targetPart;
+
+ private String text;
+
+ private CDOObject transactionalObject;
+
+ public TransactionalBackgroundActionDelegate(String text)
+ {
+ this.text = text;
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ this.targetPart = targetPart;
+ selectionChanged(action, getSelection());
+ }
+
+ public IWorkbenchPart getTargetPart()
+ {
+ return targetPart;
+ }
+
+ @Override
+ protected String getText()
+ {
+ return text;
+ }
+
+ protected int getCommitWorkPercent()
+ {
+ return 90;
+ }
+
+ @Override
+ protected final void preRun() throws Exception
+ {
+ Object element = UIUtil.getElement(getSelection());
+ CDOObject object = AdapterUtil.adapt(element, CDOObject.class);
+ if (object != null)
+ {
+ transactionalObject = preRun(object);
+ if (transactionalObject != null)
+ {
+ CDOView view = transactionalObject.cdoView();
+ if (view.isReadOnly())
+ {
+ throw new IllegalStateException(MessageFormat.format(
+ Messages.getString("TransactionalBackgroundAction_0"), transactionalObject)); //$NON-NLS-1$
+ }
+
+ // Bypass cancel()
+ return;
+ }
+ }
+
+ cancel();
+ }
+
+ /**
+ * Usually opens a new transaction based on the passed object and its view/session and returns a "contextualized" copy
+ * of this object. Clients may override to access the UI thread before the background job is started or change the
+ * contextualization procedure.
+ *
+ * @param object
+ * Usually an object in a read-only view that needs to be modified in a separate transaction.
+ * @return A transactional copy of the passed object, or <code>null</code> to indicate cancelation of this action.
+ */
+ protected CDOObject preRun(CDOObject object)
+ {
+ CDOTransaction transaction = object.cdoView().getSession().openTransaction();
+ new CDOTransactionCommentator(transaction);
+
+ CDOObject transactionalObject = transaction.getObject(object);
+ return transactionalObject;
+ }
+
+ @Override
+ protected final void doRun(IProgressMonitor progressMonitor) throws Exception
+ {
+ CDOTransaction transaction = (CDOTransaction)transactionalObject.cdoView();
+ int commitWorkPercent = getCommitWorkPercent();
+ progressMonitor.beginTask(Messages.getString("TransactionalBackgroundAction_1"), 100); //$NON-NLS-1$
+
+ try
+ {
+ doRun(transaction, transactionalObject, new SubProgressMonitor(progressMonitor, 100 - commitWorkPercent));
+ transaction.commit(new SubProgressMonitor(progressMonitor, commitWorkPercent));
+ }
+ finally
+ {
+ progressMonitor.done();
+ transaction.close();
+ transactionalObject = null;
+ }
+ }
+
+ protected abstract void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
+ throws Exception;
+}
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 a0f77707a3..f33f853ec5 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
@@ -17,15 +17,9 @@
AbstractLockObjectsAction.0=Error
AbstractLockObjectsAction.1=Cannot obtain locks
AsyncContentProvider_0=Pending...
-BranchSelectionDialog_0=Switch Target
-BranchSelectionDialog_1=Please choose the target branch
-BranchSelectionDialog_2=The selected branch point is current
-BranchSelectionDialog.0=Branch Point
BranchSelectionDialog.1=Head
BranchSelectionDialog.2=Base
BranchSelectionDialog.3=Time
-BranchSelectionDialog.4=Commit Point
-BranchSelectionDialog.5=Cannot select base point for the main branch
BulkAddDialog.0=Bulk Add
BulkAddDialog.1=Select a child type and number of child instances
BulkAddDialog.2=Type:
@@ -47,9 +41,6 @@ CDOInteractiveExceptionHandler.2=attempts
CDOInteractiveExceptionHandler.3=A protocol problem occurred in {0} after {1} {2}.\n\nRetry or abort the operation?
CDOInteractiveExceptionHandler.4=Retry
CDOInteractiveExceptionHandler.5=Abort
-CDOItemProvider.0=Session {0} [{1}]
-CDOItemProvider.3=Transaction
-CDOItemProvider.7=View
CDOItemProvider.8=Register Generated Package
CDOPreferencePage.0=Session Defaults
CDOPreferencePage.1=Repository name:
@@ -105,9 +96,6 @@ CloseViewAction.1=Close the CDO view
CloseViewAction.2=You have uncommitted changes. Do you want to discard them?
CommitTransactionAction.0=Commit
CommitTransactionAction.1=Commit this transaction
-CreateResourceAction.2=Enter resource name:
-CreateResourceAction.4=Resource already exists
-CreateResourceAction.5=There already exists a resource with path "{0}". Do you want to edit the resource?
Title.Folder=New Folder
Tooltip.Folder=Create a new resource folder
@@ -201,5 +189,27 @@ SessionComposite.0=Server Description:
SessionComposite.1=for example 'tcp://dev.eclipse.org:2036'
SessionComposite.2=Repository Name:
SessionComposite.3=Automatic Package Registry
-SessionComposite.4=Legacy Mode Default
WriteLockObjectsAction.1=Write Lock
+ExportSelectedResourceAction_0=Export Resource
+ImportResourceActionDelegate.0=Couldn't Import CDOResource
+ImportResourceToFolderAction_0=Import Resource
+ImportResourceToFolderAction_1=No URI has been introduced
+NewResourceAction_0=Creating CDO resource
+NewResourceFolderAction_0=Creating CDO folder
+NewTextResourceAction_0=Creating CDO text resource
+NewBinaryResourceAction_0=Creating CDO binary resource
+NewResourceNodeAction_0=Enter the name
+RemoveResourceAction_1=Delete Resource
+RemoveResourceAction_2=Are you sure you want to delete the selected {0} item(s)?
+RemoveResourceAction_3=Deleting CDOResource(s)
+RemoveResourceAction_4={0}: Cannot perform commit
+RenameResourceActionDelegate.0=Rename
+TransactionalBackgroundAction_0=Object is not transactional: {0}
+TransactionalBackgroundAction_1=Commit Transaction
+ExportResourceActionDelegate.0=Couldn't Export CDOResource
+ExportSelectedResourceAction_1=Export CDOResource
+ExportSelectedResourceAction_2=No URI has been introduced
+OpenFileEditorAction.0=Open File Editor
+OpenFileEditorAction.1=Open a file editor for this resource
+OpenResourceEditorAction.0=Open Editor
+OpenResourceEditorAction.1=Open a model editor for this resource
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOExplorerPerspective.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOPerspective.java
index 0e2013a2ad..de3b5a2e9b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOExplorerPerspective.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/perspectives/CDOPerspective.java
@@ -23,13 +23,13 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Victor Roldan Betancort
*/
-public class CDOExplorerPerspective implements IPerspectiveFactory
+public class CDOPerspective implements IPerspectiveFactory
{
public static final String ID = "org.eclipse.emf.cdo.ui.CDOExplorerPerspective"; //$NON-NLS-1$
private IPageLayout pageLayout;
- public CDOExplorerPerspective()
+ public CDOPerspective()
{
}
@@ -85,6 +85,6 @@ public class CDOExplorerPerspective implements IPerspectiveFactory
static public boolean isCurrent()
{
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective().getId()
- .equals(CDOExplorerPerspective.ID);
+ .equals(CDOPerspective.ID);
}
}

Back to the top