summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-03 14:05:18 (EDT)
committerEike Stepper2007-07-03 14:05:18 (EDT)
commit1fef71e6c7b59e389e46447ce8d6468be95aadd7 (patch)
tree6e2b5d9ef3c0dc6169b7fc5c8bc072a863c20709
parent656525bc332dbe7e51a47c6a80a0b14f28d1c9e5 (diff)
downloadcdo-1fef71e6c7b59e389e46447ce8d6468be95aadd7.zip
cdo-1fef71e6c7b59e389e46447ce8d6468be95aadd7.tar.gz
cdo-1fef71e6c7b59e389e46447ce8d6468be95aadd7.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java15
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java1
3 files changed, 61 insertions, 14 deletions
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 ec17291..afe4f0c 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
@@ -28,6 +28,7 @@ import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
@@ -50,6 +51,7 @@ import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+import org.eclipse.emf.internal.cdo.util.EMFUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -136,7 +138,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
- public static final String EDITOR_ID = "org.eclipse.emf.cdo.ui.CDOEditor";
+ public static final String EDITOR_ID = CDOUI.BUNDLE_ID + ".CDOEditor";
/**
* @ADDED
@@ -1637,13 +1639,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
MenuManager submenuManager = new MenuManager(cdoPackage.getPackageURI());
for (CDOClass cdoClass : cdoClasses)
{
- submenuManager.add(new LongRunningAction(getEditorSite().getPage(), cdoClass.getName())
- {
- @Override
- protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
- {
- }
- });
+ submenuManager.add(new CreateRootAction(cdoClass));
}
menuManager.add(submenuManager);
@@ -1789,4 +1785,51 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
return null;
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class CreateRootAction extends LongRunningAction
+ {
+ private CDOClass cdoClass;
+
+ private CreateRootAction(CDOClass cdoClass)
+ {
+ super(getEditorSite().getPage(), cdoClass.getName());
+ this.cdoClass = cdoClass;
+ }
+
+ @Override
+ protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
+ {
+ Resource resource = null;
+ IStructuredSelection ssel = (IStructuredSelection)editorSelection;
+ if (ssel.isEmpty())
+ {
+ if (viewerInput instanceof Resource)
+ {
+ resource = (Resource)viewerInput;
+ }
+ }
+ else if (ssel.size() == 1)
+ {
+ Object element = ssel.getFirstElement();
+ if (element instanceof Resource)
+ {
+ resource = (Resource)element;
+ }
+ else if (element instanceof EObject)
+ {
+ resource = ((EObject)element).eResource();
+ }
+ }
+
+ if (resource != null)
+ {
+ EClass eClass = EMFUtil.getEClass(cdoClass);
+ EObject object = EcoreUtil.create(eClass);
+ resource.getContents().add(object);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index a582cd2..322b86f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -212,15 +212,18 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements CDOObject
revision.setContainerID(eContainer == null ? CDOID.NULL : ((CDOObjectImpl)eContainer).cdoID());
revision.setContainingFeature(eContainerFeatureID);
- for (int i = 0; i < eClass().getFeatureCount(); i++)
+ if (eSettings != null)
{
- Object setting = eSettings[i];
- if (setting != null)
+ for (int i = 0; i < eClass().getFeatureCount(); i++)
{
- EStructuralFeature eFeature = eDynamicFeature(i);
- if (!eFeature.isTransient())
+ Object setting = eSettings[i];
+ if (setting != null)
{
- finalizeRevisionFeature(adapter, revision, i, setting, eFeature);
+ EStructuralFeature eFeature = eDynamicFeature(i);
+ if (!eFeature.isTransient())
+ {
+ finalizeRevisionFeature(adapter, revision, i, setting, eFeature);
+ }
}
}
}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java
index 1f0c9c9..d57cbd3 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/actions/LongRunningAction.java
@@ -125,6 +125,7 @@ public abstract class LongRunningAction extends SafeAction
protected IStatus handleException(Exception ex)
{
+ ex.printStackTrace();
return new Status(IStatus.ERROR, OM.BUNDLE_ID, "An error has occured.", ex);
}