summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-26 03:02:12 (EDT)
committerEike Stepper2007-07-26 03:02:12 (EDT)
commit732cd170cdd7956ad8f4ed70d20c38c57976cc6f (patch)
tree99bbed35b408f9cd66585e76af6f1c12e7381d5e
parentb298c14cdbc55a38c9a59276db9f3314af77c71f (diff)
downloadcdo-732cd170cdd7956ad8f4ed70d20c38c57976cc6f.zip
cdo-732cd170cdd7956ad8f4ed70d20c38c57976cc6f.tar.gz
cdo-732cd170cdd7956ad8f4ed70d20c38c57976cc6f.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java72
3 files changed, 136 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java
index cc22a6b..40e235a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java
@@ -53,7 +53,7 @@ public abstract class EditingDomainAction extends LongRunningAction
public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
{
- setPage(workbenchPart.getSite().getPage());
+ setPage(workbenchPart == null ? null : workbenchPart.getSite().getPage());
setEditingDomain(workbenchPart instanceof IEditingDomainProvider ? ((IEditingDomainProvider)workbenchPart)
.getEditingDomain() : null);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
index 3c64ab7..9449026 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
@@ -1,12 +1,21 @@
package org.eclipse.emf.cdo.internal.ui.actions;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.util.CDOPackageRegistry;
+
import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
+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.impl.ResourceSetImpl;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -17,13 +26,31 @@ public class ImportResourceAction extends EditingDomainAction
{
private static final String TITLE = "Import Resource";
- private List<URI> uris;
+ private CDOResource targetResource;
+
+ private transient List<URI> uris;
public ImportResourceAction()
{
super("Import Resource...");
}
+ public CDOResource getTargetResource()
+ {
+ return targetResource;
+ }
+
+ public void setTargetResource(CDOResource targetResource)
+ {
+ this.targetResource = targetResource;
+ }
+
+ @Override
+ public boolean isEnabled()
+ {
+ return targetResource != null && super.isEnabled();
+ }
+
@Override
protected void preRun() throws Exception
{
@@ -49,6 +76,39 @@ public class ImportResourceAction extends EditingDomainAction
@Override
protected void doRun(IProgressMonitor monitor) throws Exception
{
- MessageDialog.openInformation(getShell(), TITLE, uris.toString());
+ EList<EObject> targetContents = targetResource.getContents();
+ List<Resource> resources = getSourceResources();
+ for (Resource resource : resources)
+ {
+ List<EObject> contents = new ArrayList(resource.getContents());
+ for (EObject root : contents)
+ {
+ targetContents.add(root);
+ }
+ }
+ }
+
+ protected List<Resource> getSourceResources()
+ {
+ ResourceSetImpl resourceSet = createSourceResourceSet();
+ List<Resource> resources = new ArrayList(uris.size());
+ for (URI uri : uris)
+ {
+ Resource resource = resourceSet.getResource(uri, true);
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ protected ResourceSetImpl createSourceResourceSet()
+ {
+ CDOView view = targetResource.cdoView();
+ CDOSession session = view.getSession();
+ CDOPackageRegistry packageRegistry = session.getPackageRegistry();
+
+ ResourceSetImpl resourceSet = new ResourceSetImpl();
+ resourceSet.setPackageRegistry(packageRegistry);
+ return resourceSet;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
index b25b4da..5cb3a6c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
@@ -6,6 +6,7 @@
*/
package org.eclipse.emf.cdo.internal.ui.editor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.ui.actions.ExportResourceAction;
import org.eclipse.emf.cdo.internal.ui.actions.ImportResourceAction;
@@ -297,6 +298,55 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
*
* @generated
*/
+ public void selectionChangedGen(SelectionChangedEvent event)
+ {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null)
+ {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null)
+ {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1)
+ {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null)
+ {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null)
+ {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * @ADDED
+ */
public void selectionChanged(SelectionChangedEvent event)
{
// Remove any menu items for old selection.
@@ -324,6 +374,18 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+
+ if (importResourceAction != null)
+ {
+ if (object instanceof CDOResource)
+ {
+ importResourceAction.setTargetResource((CDOResource)object);
+ }
+ else
+ {
+ importResourceAction.setTargetResource(null);
+ }
+ }
}
// Generate actions for selection; populate and redraw the menus.
@@ -552,6 +614,15 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
if (importResourceAction != null)
{
importResourceAction.setActiveWorkbenchPart(activeEditor);
+ Object input = ((CDOEditor)getActiveEditor()).getViewer().getInput();
+ if (input instanceof CDOResource)
+ {
+ importResourceAction.setTargetResource((CDOResource)input);
+ }
+ else
+ {
+ importResourceAction.setTargetResource(null);
+ }
}
if (exportResourceAction != null)
@@ -571,6 +642,7 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
if (importResourceAction != null)
{
importResourceAction.setActiveWorkbenchPart(null);
+ importResourceAction.setTargetResource(null);
}
if (exportResourceAction != null)