summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-05 04:03:28 (EDT)
committerEike Stepper2007-07-05 04:03:28 (EDT)
commited0ac635b7b3f949905b438475604502e278fe4d (patch)
tree4c747a96048ec36334605fcf31daaa9c383d0c94
parentc22d46fa7e70659b20b236ef1db60c30bf446a88 (diff)
downloadcdo-ed0ac635b7b3f949905b438475604502e278fe4d.zip
cdo-ed0ac635b7b3f949905b438475604502e278fe4d.tar.gz
cdo-ed0ac635b7b3f949905b438475604502e278fe4d.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ResourceHistory.java56
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistoryEvent.java27
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java23
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java1
6 files changed, 95 insertions, 73 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ResourceHistory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ResourceHistory.java
deleted file mode 100644
index 150774c..0000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ResourceHistory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/***************************************************************************
- * 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.CDOView;
-
-/**
- * @author Eike Stepper
- */
-public final class ResourceHistory
-{
- public static final ResourceHistory INSTANCE = new ResourceHistory();
-
- private static final Entry[] NO_ENTRIES = {};
-
- private ResourceHistory()
- {
- }
-
- public Entry[] getEntries(CDOView view)
- {
- return NO_ENTRIES;
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Entry
- {
- private String resourcePath;
-
- private Entry(String resourcePath)
- {
- this.resourcePath = resourcePath;
- }
-
- public String getResourcePath()
- {
- return resourcePath;
- }
-
- @Override
- public String toString()
- {
- return resourcePath;
- }
- }
-}
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 278da1e..8fd7a3f 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
@@ -13,7 +13,6 @@ 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;
@@ -50,13 +49,21 @@ public class CDOItemProvider extends ContainerItemProvider
{
public void notifyEvent(IEvent event)
{
- CDOViewHistory history = (CDOViewHistory)event.getSource();
- CDOView view = history.getView();
- refreshElement(view, false);
+ if (event instanceof CDOViewHistoryEvent)
+ {
+ CDOViewHistoryEvent e = (CDOViewHistoryEvent)event;
+ CDOViewHistory history = e.getViewHistory();
+ CDOView view = history.getView();
+ refreshElement(view, false);
+ if (e.getAddedEntry() != null)
+ {
+ revealElement(e.getAddedEntry());
+ }
+ }
}
};
- private static int lastNumber = -1;
+ private static int lastResourceNumber = 0;
public CDOItemProvider(IWorkbenchPage page, IElementFilter rootElementFilter)
{
@@ -201,7 +208,7 @@ public class CDOItemProvider extends ContainerItemProvider
@Override
protected void preRun(IWorkbenchPage page) throws Exception
{
- String uri = lastNumber == -1 ? "" : "/res" + lastNumber;
+ String uri = lastResourceNumber == 0 ? "" : "/res" + lastResourceNumber;
InputDialog dialog = new InputDialog(page.getWorkbenchWindow().getShell(), "Load Resource",
"Enter resource path:", uri, null);
if (dialog.open() == InputDialog.OK)
@@ -230,11 +237,11 @@ public class CDOItemProvider extends ContainerItemProvider
@Override
protected void preRun(IWorkbenchPage page) throws Exception
{
- lastNumber = (int)(Math.random() * 10000000.0);
InputDialog dialog = new InputDialog(page.getWorkbenchWindow().getShell(), "Create Resource",
- "Enter resource path:", "/res" + lastNumber, null);
+ "Enter resource path:", "/res" + (lastResourceNumber + 1), null);
if (dialog.open() == InputDialog.OK)
{
+ ++lastResourceNumber;
resourcePath = dialog.getValue();
}
else
@@ -314,11 +321,6 @@ public class CDOItemProvider extends ContainerItemProvider
}
}
- protected Object[] getResources(CDOView view)
- {
- return ResourceHistory.INSTANCE.getEntries(view);
- }
-
public static ImageDescriptor getOpenEditorImageDescriptor()
{
return SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR);
@@ -349,7 +351,7 @@ public class CDOItemProvider extends ContainerItemProvider
// final CDOView view =
createView();
// final IWorkbenchPart part = page.getActivePart();
- // getDisplay().asyncExec(new Runnable()
+ // getDisplay().syncExec(new Runnable()
// {
// public void run()
// {
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
index fec0b3d..d6d6af6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewResourcesEvent;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.net4j.internal.util.event.Event;
import org.eclipse.net4j.internal.util.event.Notifier;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
@@ -101,7 +100,7 @@ public final class CDOViewHistory extends Notifier
if (changed)
{
- fireEvent(new Event(this));
+ fireEvent(new Event(null));
}
}
@@ -116,7 +115,33 @@ public final class CDOViewHistory extends Notifier
if (changed)
{
- fireEvent(new Event(this));
+ fireEvent(new Event(entry));
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class Event extends org.eclipse.net4j.internal.util.event.Event implements CDOViewHistoryEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ Entry addedEntry;
+
+ public Event(Entry addedEntry)
+ {
+ super(CDOViewHistory.this);
+ this.addedEntry = addedEntry;
+ }
+
+ public CDOViewHistory getViewHistory()
+ {
+ return CDOViewHistory.this;
+ }
+
+ public Entry getAddedEntry()
+ {
+ return addedEntry;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistoryEvent.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistoryEvent.java
new file mode 100644
index 0000000..b2a35f4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistoryEvent.java
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * 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.views;
+
+import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface CDOViewHistoryEvent extends IEvent
+{
+
+ public CDOViewHistory getViewHistory();
+
+ public Entry getAddedEntry();
+
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java
index 2d79b11..c1945b0 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/StructuredContentProvider.java
@@ -119,6 +119,29 @@ public abstract class StructuredContentProvider<INPUT> implements IStructuredCon
}
}
+ protected void revealElement(final Object element)
+ {
+ try
+ {
+ getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ viewer.reveal(element);
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
protected Display getDisplay()
{
Display display = viewer.getControl().getDisplay();
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java
index 39de5b6..66c314b 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ContainerItemProvider.java
@@ -258,6 +258,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer> extends ItemPro
if (node != null)
{
refreshElement(container, false);
+ revealElement(element);
elementAdded(element, container);
}
}