summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-03 01:16:28 (EDT)
committerEike Stepper2007-07-03 01:16:28 (EDT)
commit5d09e30fe32ae05c51681ffb3b22f138eb6912c3 (patch)
treef7f97ace6c98da396cc9da64ae475cc9611925a8
parent94ec396dc322b98a584c89ecef2267c1a73f8b25 (diff)
downloadcdo-5d09e30fe32ae05c51681ffb3b22f138eb6912c3.zip
cdo-5d09e30fe32ae05c51681ffb3b22f138eb6912c3.tar.gz
cdo-5d09e30fe32ae05c51681ffb3b22f138eb6912c3.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java77
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java52
4 files changed, 162 insertions, 80 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java
new file mode 100644
index 0000000..32e5306
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+
+import org.eclipse.net4j.IConnector;
+
+import org.eclipse.swt.graphics.Image;
+
+import java.util.Date;
+
+/**
+ * @author Eike Stepper
+ */
+public final class LabelUtil
+{
+ private LabelUtil()
+ {
+ }
+
+ public static String getText(Object obj)
+ {
+ if (obj instanceof CDOSession)
+ {
+ CDOSession session = (CDOSession)obj;
+ IConnector connector = session.getChannel().getConnector();
+ String repositoryName = session.getRepositoryName();
+ return connector.getURL() + "/" + repositoryName;
+ }
+
+ if (obj instanceof CDOView)
+ {
+ CDOView view = (CDOView)obj;
+ return view.isHistorical() ? new Date(view.getTimeStamp()).toString() : view.isReadOnly() ? "View"
+ : "Transaction";
+ }
+
+ return null;
+ }
+
+ public static Image getImage(Object obj)
+ {
+ if (obj instanceof CDOSession)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
+ }
+
+ if (obj instanceof CDOView)
+ {
+ CDOView view = (CDOView)obj;
+ if (view.isHistorical())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
+ }
+
+ if (view.isReadOnly())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
+ }
+
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
+ }
+
+ return null;
+ }
+}
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 07551c4..b8dc9e5 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
@@ -7,7 +7,6 @@
package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.ui.bundle.CDOUI;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -143,7 +142,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
- private CDOResource resource;
+ private Object viewerInput;
/**
* This keeps track of the editing domain that is used to track all changes to
@@ -236,7 +235,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected ISelection editorSelection = StructuredSelection.EMPTY;
/**
- * The MarkerHelper is responsible for creating workspace resource markers
+ * The MarkerHelper is responsible for creating workspace viewerInput markers
* presented in Eclipse's Problems View. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
@@ -323,8 +322,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
protected Collection<Resource> savedResources = new ArrayList<Resource>();
/**
- * Map to store the diagnostic associated with a resource. <!-- begin-user-doc
- * --> <!-- end-user-doc -->
+ * Map to store the diagnostic associated with a viewerInput. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@@ -898,8 +897,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
- * This is the method called to load a resource into the editing domain's
- * resource set based on the editor's input. <!-- begin-user-doc --> <!--
+ * This is the method called to load a viewerInput into the editing domain's
+ * viewerInput set based on the editor's input. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated NOT
@@ -908,9 +907,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
try
{
- CDOEditorInput input = (CDOEditorInput)getEditorInput();
- view = input.getView();
- URI resourceURI = CDOUtil.createURI(input.getResourcePath());
+ CDOEditorInput editorInput = (CDOEditorInput)getEditorInput();
+ view = editorInput.getView();
BasicCommandStack commandStack = new BasicCommandStack();
commandStack.addCommandStackListener(new CommandStackListener()
@@ -941,7 +939,17 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet);
editingDomain.setResourceToReadOnlyMap(new HashMap<Resource, Boolean>());
- resource = (CDOResource)resourceSet.getResource(resourceURI, true);
+ String resourcePath = editorInput.getResourcePath();
+ if (resourcePath == null)
+ {
+ viewerInput = resourceSet;
+ }
+ else
+ {
+ URI resourceURI = CDOUtil.createURI(resourcePath);
+ viewerInput = resourceSet.getResource(resourceURI, true);
+ }
+
resourceSet.eAdapters().add(problemIndicationAdapter);
}
catch (RuntimeException ex)
@@ -953,8 +961,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* Returns a dignostic describing the errors and warnings listed in the
- * resource and the specified exception (if any). <!-- begin-user-doc --> <!--
- * end-user-doc -->
+ * viewerInput and the specified exception (if any). <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
*
* @generated
*/
@@ -1006,8 +1014,8 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
- selectionViewer.setInput(resource);
- selectionViewer.setSelection(new StructuredSelection(resource), true);
+ selectionViewer.setInput(viewerInput);
+ // selectionViewer.setSelection(new StructuredSelection(viewerInput), true);
new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
@@ -1340,9 +1348,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This returns wether something has been persisted to the URI of the
- * specified resource. The implementation uses the URI converter from the
- * editor's resource set to try to open an input stream. <!-- begin-user-doc
- * --> <!-- end-user-doc -->
+ * specified viewerInput. The implementation uses the URI converter from the
+ * editor's viewerInput set to try to open an input stream. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@@ -1680,31 +1688,31 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
*/
public static void open(final IWorkbenchPage page, final CDOView view, final String resourcePath)
{
- IEditorReference reference = find(page, view, resourcePath);
- if (reference != null)
- {
- IEditorPart editor = reference.getEditor(true);
- page.activate(editor);
- }
- else
+ Display display = page.getWorkbenchWindow().getShell().getDisplay();
+ display.asyncExec(new Runnable()
{
- Display display = page.getWorkbenchWindow().getShell().getDisplay();
- display.asyncExec(new Runnable()
+ public void run()
{
- public void run()
+ try
{
- try
+ IEditorReference reference = find(page, view, resourcePath);
+ if (reference != null)
{
- IEditorInput input = new CDOEditorInput(view, resourcePath);
- page.openEditor(input, EDITOR_ID);
+ IEditorPart editor = reference.getEditor(true);
+ page.activate(editor);
}
- catch (Exception ex)
+ else
{
- CDOUI.LOG.error(ex);
+ IEditorInput input = new CDOEditorInput(view, resourcePath);
+ page.openEditor(input, EDITOR_ID);
}
}
- });
- }
+ catch (Exception ex)
+ {
+ CDOUI.LOG.error(ex);
+ }
+ }
+ });
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
index 1ad75e5..0d35594 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
@@ -11,18 +11,20 @@
package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.LabelUtil;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
-import java.text.MessageFormat;
+import java.util.Date;
/**
* @author Eike Stepper
*/
-public class CDOEditorInput implements IEditorInput
+public class CDOEditorInput extends PlatformObject implements IEditorInput
{
private CDOView view;
@@ -66,7 +68,14 @@ public class CDOEditorInput implements IEditorInput
public String getName()
{
- return resourcePath;
+ StringBuilder builder = new StringBuilder();
+ builder.append(view.getSession().getRepositoryName());
+ if (resourcePath != null)
+ {
+ builder.append(resourcePath);
+ }
+
+ return builder.toString();
}
public IPersistableElement getPersistable()
@@ -76,21 +85,25 @@ public class CDOEditorInput implements IEditorInput
public String getToolTipText()
{
+ StringBuilder builder = new StringBuilder();
+ builder.append(LabelUtil.getText(view.getSession()));
+ if (resourcePath != null)
+ {
+ builder.append(resourcePath);
+ }
+
if (view.isHistorical())
{
- return MessageFormat.format("{0} ({1,D})", resourcePath, view.getTimeStamp());
+ builder.append(" (");
+ builder.append(new Date(view.getTimeStamp()));
+ builder.append(")");
}
if (view.isReadOnly())
{
- return MessageFormat.format("{0} (read only)", resourcePath);
+ builder.append(" (readonly)");
}
- return resourcePath;
- }
-
- public Object getAdapter(Class adapter)
- {
- return null;
+ return builder.toString();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index a8d9ea2..8e20e62 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -12,12 +12,12 @@ package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.LabelUtil;
import org.eclipse.emf.cdo.internal.ui.ResourceHistory;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
-import org.eclipse.net4j.IConnector;
import org.eclipse.net4j.ui.actions.LongRunningAction;
import org.eclipse.net4j.ui.views.ContainerItemProvider;
import org.eclipse.net4j.ui.views.IElementFilter;
@@ -34,7 +34,6 @@ import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbenchPage;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -118,49 +117,25 @@ public class CDOItemProvider extends ContainerItemProvider
@Override
public String getText(Object obj)
{
- if (obj instanceof CDOSession)
+ String text = LabelUtil.getText(obj);
+ if (text == null)
{
- CDOSession session = (CDOSession)obj;
- IConnector connector = session.getChannel().getConnector();
- String repositoryName = session.getRepositoryName();
- return connector.getURL() + "/" + repositoryName;
+ text = super.getText(obj);
}
- if (obj instanceof CDOView)
- {
- CDOView view = (CDOView)obj;
- return view.isHistorical() ? new Date(view.getTimeStamp()).toString() : view.isReadOnly() ? "View"
- : "Transaction";
- }
-
- return super.getText(obj);
+ return text;
}
@Override
public Image getImage(Object obj)
{
- if (obj instanceof CDOSession)
+ Image image = LabelUtil.getImage(obj);
+ if (image == null)
{
- return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
- }
-
- if (obj instanceof CDOView)
- {
- CDOView view = (CDOView)obj;
- if (view.isHistorical())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
- }
-
- if (view.isReadOnly())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
- }
-
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
+ image = super.getImage(obj);
}
- return super.getImage(obj);
+ return image;
}
@Override
@@ -247,6 +222,15 @@ public class CDOItemProvider extends ContainerItemProvider
}
});
}
+
+ manager.add(new LongRunningAction(page, "Open", "Open a CDO editor", null)
+ {
+ @Override
+ protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
+ {
+ CDOEditor.open(page, view, null);
+ }
+ });
}
protected void fillHistoryEntry(IMenuManager manager, Entry entry)