Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-07-26 06:54:58 -0400
committerEike Stepper2015-07-26 06:54:58 -0400
commit8743379312de89965370af9e8ef9457581dc8845 (patch)
tree990c79bca75a97709bbe7717b762794d32e73b46
parente983f203a6542e5e35c2e9e3271d33dbd6a6eb7b (diff)
downloadcdo-8743379312de89965370af9e8ef9457581dc8845.tar.gz
cdo-8743379312de89965370af9e8ef9457581dc8845.tar.xz
cdo-8743379312de89965370af9e8ef9457581dc8845.zip
[458349] Consolidate UI - Add SelectClassDialog and make item providers more robust
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/.settings/.api_filters8
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java119
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutState.java56
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/.settings/.api_filters14
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/CDOClient1.launch27
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectClassDialog.java455
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java314
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOTimeMachineView.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java5
-rw-r--r--plugins/org.eclipse.net4j.util.ui/.settings/.api_filters25
-rw-r--r--plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF34
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java101
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/FirstChildLayout.java61
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/SearchField.java231
20 files changed, 1522 insertions, 113 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.explorer.ui/.settings/.api_filters
index 99d40c0b79..3ac1b82df2 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/.settings/.api_filters
@@ -16,14 +16,6 @@
</message_arguments>
</filter>
</resource>
- <resource path="src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java" type="org.eclipse.emf.cdo.explorer.ui.checkouts.actions.NewActionProvider">
- <filter id="574664731">
- <message_arguments>
- <message_argument value="org.eclipse.emf.cdo.explorer.ui.checkouts.actions.NewActionProvider.init(ICommonActionExtensionSite)"/>
- <message_argument value="IWizardRegistry"/>
- </message_arguments>
- </filter>
- </resource>
<resource path="src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java" type="org.eclipse.emf.cdo.explorer.ui.checkouts.actions.NewActionProvider$WizardDescriptorWrapper">
<filter id="574619656">
<message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
index f94946d2fb..5820bc1bf5 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutContentProvider.java
@@ -413,18 +413,18 @@ public class CDOCheckoutContentProvider implements ICommonContentProvider, IProp
InternalCDORevision revision = cdoObject.cdoRevision(false);
if (revision != null)
{
- ITreeItemContentProvider provider = (ITreeItemContentProvider)stateManager.adapt(object,
- ITreeItemContentProvider.class);
- if (provider instanceof ItemProviderAdapter)
+ try
{
- try
+ ITreeItemContentProvider provider = (ITreeItemContentProvider)stateManager.adapt(object,
+ ITreeItemContentProvider.class);
+ if (provider instanceof ItemProviderAdapter)
{
return hasChildren(cdoObject, revision, (ItemProviderAdapter)provider);
}
- catch (Exception ex)
- {
- //$FALL-THROUGH$
- }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
}
}
}
@@ -710,29 +710,29 @@ public class CDOCheckoutContentProvider implements ICommonContentProvider, IProp
InternalCDORevision revision = cdoObject.cdoRevision(false);
if (revision != null)
{
- ITreeItemContentProvider provider = (ITreeItemContentProvider)stateManager.adapt(object,
- ITreeItemContentProvider.class);
- if (provider instanceof ItemProviderAdapter)
+ try
{
- try
+ ITreeItemContentProvider provider = (ITreeItemContentProvider)stateManager.adapt(object,
+ ITreeItemContentProvider.class);
+ if (provider instanceof ItemProviderAdapter)
{
determineChildRevisions(cdoObject, revision, (ItemProviderAdapter)provider, loadedRevisions, missingIDs);
- }
- catch (Exception ex)
- {
- //$FALL-THROUGH$
- }
- if (missingIDs.isEmpty())
- {
- // All revisions are cached. Just return the objects without server round-trips.
- ITreeContentProvider contentProvider = stateManager.getContentProvider(object);
- if (contentProvider != null)
+ if (missingIDs.isEmpty())
{
- return contentProvider.getChildren(object);
+ // All revisions are cached. Just return the objects without server round-trips.
+ ITreeContentProvider contentProvider = stateManager.getContentProvider(object);
+ if (contentProvider != null)
+ {
+ return contentProvider.getChildren(object);
+ }
}
}
}
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java
index df80fc6b4e..419cc58fb1 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutLabelProvider.java
@@ -14,8 +14,12 @@ import org.eclipse.emf.cdo.explorer.CDOExplorerElement;
import org.eclipse.emf.cdo.explorer.ui.ViewerUtil;
import org.eclipse.emf.cdo.transfer.CDOTransferElement;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProvider;
@@ -27,6 +31,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.ICommonLabelProvider;
@@ -37,6 +42,9 @@ import org.eclipse.ui.navigator.ICommonLabelProvider;
public class CDOCheckoutLabelProvider extends LabelProvider
implements ICommonLabelProvider, IColorProvider, IStyledLabelProvider
{
+ private static final Image ERROR_IMAGE = PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+
private static final IEditorRegistry EDITOR_REGISTRY = PlatformUI.getWorkbench().getEditorRegistry();
private final EditorRegistryListener editorRegistryListener = new EditorRegistryListener();
@@ -84,10 +92,17 @@ public class CDOCheckoutLabelProvider extends LabelProvider
public Color getForeground(Object object)
{
- IColorProvider provider = getStateManager().getLabelProvider(object);
- if (provider != null)
+ try
+ {
+ IColorProvider provider = getStateManager().getLabelProvider(object);
+ if (provider != null)
+ {
+ return provider.getForeground(object);
+ }
+ }
+ catch (Exception ex)
{
- return provider.getForeground(object);
+ //$FALL-THROUGH$
}
return null;
@@ -95,10 +110,17 @@ public class CDOCheckoutLabelProvider extends LabelProvider
public Color getBackground(Object object)
{
- IColorProvider provider = getStateManager().getLabelProvider(object);
- if (provider != null)
+ try
+ {
+ IColorProvider provider = getStateManager().getLabelProvider(object);
+ if (provider != null)
+ {
+ return provider.getBackground(object);
+ }
+ }
+ catch (Exception ex)
{
- return provider.getBackground(object);
+ //$FALL-THROUGH$
}
return null;
@@ -117,10 +139,17 @@ public class CDOCheckoutLabelProvider extends LabelProvider
public StyledString getStyledText(Object object)
{
- IStyledLabelProvider provider = getStateManager().getLabelProvider(object);
- if (provider != null)
+ try
{
- return provider.getStyledText(object);
+ IStyledLabelProvider provider = getStateManager().getLabelProvider(object);
+ if (provider != null)
+ {
+ return provider.getStyledText(object);
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
}
String text = getText(object);
@@ -136,13 +165,55 @@ public class CDOCheckoutLabelProvider extends LabelProvider
return pending.getText();
}
- ILabelProvider provider = getStateManager().getLabelProvider(object);
- if (provider != null)
+ try
+ {
+ ILabelProvider provider = getStateManager().getLabelProvider(object);
+ if (provider != null)
+ {
+ String text = provider.getText(object);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ try
+ {
+ String text = super.getText(object);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ try
+ {
+ if (object instanceof EObject)
+ {
+ EObject eObject = (EObject)object;
+ EClass eClass = eObject.eClass();
+ String text = getText(eClass);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ignore)
{
- return provider.getText(object);
+ //$FALL-THROUGH$
}
- return super.getText(object);
+ return object.getClass().getSimpleName();
}
@Override
@@ -153,13 +224,27 @@ public class CDOCheckoutLabelProvider extends LabelProvider
return ContainerItemProvider.PENDING_IMAGE;
}
- ILabelProvider provider = getStateManager().getLabelProvider(object);
- if (provider != null)
+ try
+ {
+ ILabelProvider provider = getStateManager().getLabelProvider(object);
+ if (provider != null)
+ {
+ return provider.getImage(object);
+ }
+ }
+ catch (Exception ex)
{
- return provider.getImage(object);
+ //$FALL-THROUGH$
}
- return super.getImage(object);
+ try
+ {
+ return super.getImage(object);
+ }
+ catch (Exception ex)
+ {
+ return ERROR_IMAGE;
+ }
}
public CDOCheckoutStateManager getStateManager()
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutState.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutState.java
index 5e42c2fbc3..f8ee800fc8 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutState.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutState.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.ui.CDOLabelDecorator;
import org.eclipse.emf.cdo.ui.CDOTreeExpansionAgent;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
@@ -32,6 +33,7 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -326,13 +328,21 @@ public final class CDOCheckoutState
if (element instanceof CDOCheckout)
{
CDOCheckout checkout = (CDOCheckout)element;
- return checkout.getLabel();
+ String text = checkout.getLabel();
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
}
if (element instanceof CDOElement)
{
CDOElement checkoutElement = (CDOElement)element;
- return checkoutElement.toString();
+ String text = checkoutElement.toString();
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
}
if (element instanceof EObject)
@@ -340,7 +350,11 @@ public final class CDOCheckoutState
CDOElement checkoutElement = (CDOElement)EcoreUtil.getExistingAdapter((Notifier)element, CDOElement.class);
if (checkoutElement != null)
{
- return checkoutElement.toString(element);
+ String text = checkoutElement.toString(element);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
}
if (element instanceof CDOResourceNode)
@@ -364,12 +378,36 @@ public final class CDOCheckoutState
return pending.getText();
}
- return super.getText(element);
+ String text = super.getText(element);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
}
catch (Exception ex)
{
- return ex.getMessage();
+ //$FALL-THROUGH$
}
+
+ try
+ {
+ if (element instanceof EObject)
+ {
+ EObject eObject = (EObject)element;
+ EClass eClass = eObject.eClass();
+ String text = getText(eClass);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return element.getClass().getSimpleName();
}
@Override
@@ -400,7 +438,13 @@ public final class CDOCheckoutState
return CDOLabelDecorator.decorate(image, element);
}
- return doGetImage(element);
+ Image image = doGetImage(element);
+ if (image == null)
+ {
+ return ERROR_IMAGE;
+ }
+
+ return image;
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
index 18a02b9e20..084093776a 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/NewActionProvider.java
@@ -19,16 +19,20 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.ui.checkouts.CDOCheckoutContentProvider;
import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.NewWizard;
import org.eclipse.emf.cdo.internal.ui.actions.TransactionalBackgroundAction;
+import org.eclipse.emf.cdo.internal.ui.dialogs.SelectClassDialog;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor.NewRootMenuPopulator;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.ui.shared.SharedIcons;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.CommandParameter;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -204,6 +208,10 @@ public class NewActionProvider extends CommonActionProvider implements ISelectio
if (!resource.isRoot())
{
fillNewRootActions(submenu, checkout, resource);
+
+ submenu.add(new Separator());
+ submenu.add(new NewRootOtherAction(resource, checkout));
+ submenu.add(new Separator());
}
}
else if (selectedObject instanceof CDOResourceNode)
@@ -217,10 +225,6 @@ public class NewActionProvider extends CommonActionProvider implements ISelectio
submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
- // Add other...
- submenu.add(new Separator());
- submenu.add(showDlgAction);
-
// Append the submenu after the GROUP_NEW group.
menu.insertAfter(ICommonMenuConstants.GROUP_NEW, submenu);
}
@@ -494,6 +498,44 @@ public class NewActionProvider extends CommonActionProvider implements ISelectio
/**
* @author Eike Stepper
*/
+ private class NewRootOtherAction extends AbstractNewAction
+ {
+ private EObject object;
+
+ public NewRootOtherAction(CDOResource resource, CDOCheckout checkout)
+ {
+ super("Other...", null, SharedIcons.getDescriptor(SharedIcons.OBJ_ECLASS), checkout, resource);
+ }
+
+ @Override
+ protected void preRun() throws Exception
+ {
+ SelectClassDialog dialog = new SelectClassDialog(page, "New Root Object",
+ "Select a package and a class for new root object.");
+
+ if (dialog.open() == SelectClassDialog.OK)
+ {
+ EClass eClass = dialog.getSelectedClass();
+ object = EcoreUtil.create(eClass);
+ }
+ else
+ {
+ cancel();
+ }
+ }
+
+ @Override
+ protected EObject doRun(CDOTransaction transaction, CDOObject resource, ISelection selection)
+ {
+ EList<EObject> contents = ((CDOResource)resource).getContents();
+ contents.add(object);
+ return object;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
private class NewChildAction extends AbstractNewAction
{
private final Object childDescriptor;
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
index fa6635c529..90d59b16c2 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
@@ -622,14 +622,14 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
}
CDOSession session = view.getSession();
- CDOBranch branch = view.getBranch();
- CDOBranchPoint head = branch.getHead();
if (readOnly)
{
- return session.openView(head, resourceSet);
+ return session.openView(view, resourceSet);
}
+ CDOBranch branch = view.getBranch();
+ CDOBranchPoint head = branch.getHead();
return session.openTransaction(head, resourceSet);
}
@@ -638,7 +638,9 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
CDOUtil.configureView(view);
((InternalCDOView)view).setRepositoryName(repository.getLabel());
+ view.properties().put(CDOView.PROP_TIME_MACHINE_DISABLED, !isReadOnly());
view.properties().put(CHECKOUT_KEY, this);
+
view.addListener(new IListener()
{
public void notifyEvent(IEvent event)
diff --git a/plugins/org.eclipse.emf.cdo.ui/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.ui/.settings/.api_filters
index b3e13c7604..0f01c031c4 100644
--- a/plugins/org.eclipse.emf.cdo.ui/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.ui/.settings/.api_filters
@@ -1525,11 +1525,25 @@
<resource path="src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java" type="org.eclipse.emf.cdo.internal.ui.editor.CDOEditor">
<filter id="571519004">
<message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.internal.ui.editor.CDOEditor"/>
+ <message_argument value="TreeViewer"/>
+ </message_arguments>
+ </filter>
+ <filter id="571519004">
+ <message_arguments>
<message_argument value="org.eclipse.emf.cdo.internal.ui.editor.CDOEditor.createPages()"/>
<message_argument value="TreeViewer"/>
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java" type="org.eclipse.emf.cdo.internal.ui.editor.CDOEditor$SafeTreeViewer">
+ <filter id="571473929">
+ <message_arguments>
+ <message_argument value="TreeViewer"/>
+ <message_argument value="SafeTreeViewer"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java" type="org.eclipse.emf.cdo.ui.widgets.TimeSlider">
<filter id="571473929">
<message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.ui/CDOClient1.launch b/plugins/org.eclipse.emf.cdo.ui/CDOClient1.launch
index 0c756d6677..8a7c9d8351 100644
--- a/plugins/org.eclipse.emf.cdo.ui/CDOClient1.launch
+++ b/plugins/org.eclipse.emf.cdo.ui/CDOClient1.launch
@@ -2,8 +2,35 @@
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
<setAttribute key="additional_plugins">
<setEntry value="javax.servlet:3.1.0.v201410161800:default:false"/>
+<setEntry value="org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.edit:2.0.300.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.edit:1.0.300.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf.edit:1.0.300.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.dawn.examples.acore.edit:1.0.400.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.edit:4.4.0.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.examples.company.edit:4.0.400.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.expressions.edit:4.3.100.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.cdo.security.edit:4.3.100.qualifier:default:true"/>
+<setEntry value="org.eclipse.emf.compare.edit:4.1.0.201507190444:default:true"/>
+<setEntry value="org.eclipse.emf.databinding.edit:1.3.0.v20150601-0402:default:true"/>
<setEntry value="org.eclipse.emf.ecore.edit:2.9.0.v20150601-0402:default:true"/>
<setEntry value="org.eclipse.emf.ecore.editor:2.11.0.v20150601-0402:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.categorization.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.compoundcontrol.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.custom.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.group.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.horizontal.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.label.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.rule.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.stack.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.table.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.template.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.treemasterdetail.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.ecp.view.vertical.model.edit:1.5.0.20141210-1818:default:true"/>
+<setEntry value="org.eclipse.emf.edit:2.11.0.v20150601-0402:default:true"/>
+<setEntry value="org.eclipse.gmf.codegen.edit:2.9.0.201406111907:default:true"/>
+<setEntry value="org.eclipse.gmf.runtime.notation.edit:1.7.0.201505312221:default:true"/>
</setAttribute>
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="true"/>
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java
index 5d1d419c6f..c225a77c91 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java
@@ -114,9 +114,18 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory
try
{
adapterFactory = CDOEditor.createAdapterFactory(false);
+ IItemPropertySource propertySource = null;
+
+ try
+ {
+ propertySource = (IItemPropertySource)adapterFactory.adapt(cdoObject.cdoInternalInstance(),
+ IItemPropertySource.class);
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
- IItemPropertySource propertySource = (IItemPropertySource)adapterFactory
- .adapt(cdoObject.cdoInternalInstance(), IItemPropertySource.class);
if (propertySource != null)
{
List<IItemPropertyDescriptor> propertyDescriptors = propertySource.getPropertyDescriptors(cdoObject);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectClassDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectClassDialog.java
new file mode 100644
index 0000000000..db5e2bff60
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectClassDialog.java
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2007, 2009-2012, 2015 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.dialogs;
+
+import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.emf.cdo.ui.shared.SharedIcons;
+
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.net4j.util.ui.widgets.SearchField;
+import org.eclipse.net4j.util.ui.widgets.SearchField.FilterHandler;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class SelectClassDialog extends TitleAreaDialog
+{
+ private final IWorkbenchPage page;
+
+ private final String title;
+
+ private final String message;
+
+ private EPackage.Registry registry = EPackage.Registry.INSTANCE;
+
+ private SearchField packageSearch;
+
+ private TableViewer packageViewer;
+
+ private SearchField classSearch;
+
+ private EClass selectedClass;
+
+ private TableViewer classViewer;
+
+ public SelectClassDialog(IWorkbenchPage page, String title, String message)
+ {
+ super(new Shell(page.getWorkbenchWindow().getShell()));
+ this.page = page;
+ this.title = title;
+ this.message = message;
+ setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE);
+ }
+
+ public IWorkbenchPage getPage()
+ {
+ return page;
+ }
+
+ public EPackage.Registry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(EPackage.Registry registry)
+ {
+ this.registry = registry;
+ }
+
+ public EClass getSelectedClass()
+ {
+ return selectedClass;
+ }
+
+ @Override
+ protected Point getInitialSize()
+ {
+ return new Point(750, 600);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ getShell().setText(title);
+ setTitle(title);
+ setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER));
+ setMessage(message);
+
+ Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE);
+ composite.setLayoutData(UIUtil.createGridData());
+ composite.setLayout(new FillLayout(SWT.HORIZONTAL));
+
+ SashForm sashForm = new SashForm(composite, SWT.SMOOTH);
+
+ GridLayout packageLayout = new GridLayout(1, false);
+ packageLayout.marginWidth = 0;
+ packageLayout.marginHeight = 0;
+
+ Composite packageComposite = new Composite(sashForm, SWT.NONE);
+ packageComposite.setLayout(packageLayout);
+
+ PackageContentProvider packageContentProvider = new PackageContentProvider();
+ packageSearch = new SearchField(packageComposite, packageContentProvider);
+ packageSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ packageViewer = new TableViewer(packageComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
+ packageViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ // Does NOT work with update(element): packageViewer.setUseHashlookup(true);
+ packageViewer.setContentProvider(packageContentProvider);
+ packageViewer.setLabelProvider(new PackageLabelProvider(packageViewer));
+ packageViewer.setInput(registry);
+ packageViewer.addSelectionChangedListener(new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ IStructuredSelection selection = (IStructuredSelection)event.getSelection();
+ String nsURI = (String)selection.getFirstElement();
+ EPackage ePackage = ((EPackage.Registry)packageViewer.getInput()).getEPackage(nsURI);
+ classViewer.setInput(ePackage);
+
+ try
+ {
+ packageViewer.update(nsURI, null); // Doe NOT work with hash lookup!!!
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+ }
+ });
+
+ GridLayout classLayout = new GridLayout(1, false);
+ classLayout.marginWidth = 0;
+ classLayout.marginHeight = 0;
+
+ Composite classComposite = new Composite(sashForm, SWT.NONE);
+ classComposite.setLayout(classLayout);
+
+ ClassContentProvider classContentProvider = new ClassContentProvider();
+ classSearch = new SearchField(classComposite, classContentProvider);
+ classSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ classViewer = new TableViewer(classComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
+ classViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ classViewer.setUseHashlookup(true);
+ classViewer.setContentProvider(classContentProvider);
+ classViewer.setLabelProvider(new ClassLabelProvider());
+ classViewer.addSelectionChangedListener(new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ IStructuredSelection selection = (IStructuredSelection)event.getSelection();
+ selectedClass = (EClass)selection.getFirstElement();
+
+ updateOkButton();
+ }
+ });
+
+ classViewer.addDoubleClickListener(new IDoubleClickListener()
+ {
+ public void doubleClick(DoubleClickEvent event)
+ {
+ okPressed();
+ }
+ });
+
+ sashForm.setWeights(new int[] { 2, 1 });
+ return composite;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ super.createButtonsForButtonBar(parent);
+ updateOkButton();
+ }
+
+ private void updateOkButton()
+ {
+ Button button = getButton(IDialogConstants.OK_ID);
+ if (button != null)
+ {
+ button.setEnabled(selectedClass != null);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class PackageContentProvider implements IStructuredContentProvider, FilterHandler
+ {
+ private Viewer viewer;
+
+ private Object input;
+
+ private String filter;
+
+ private String[] elements;
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ this.viewer = viewer;
+ input = newInput;
+ computeElements();
+ }
+
+ public void handleFilter(String filter)
+ {
+ this.filter = filter == null ? null : filter.toLowerCase();
+ computeElements();
+ viewer.refresh();
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return elements;
+ }
+
+ public void dispose()
+ {
+ elements = null;
+ }
+
+ private void computeElements()
+ {
+ if (input instanceof EPackage.Registry)
+ {
+ final EPackage.Registry registry = (EPackage.Registry)input;
+
+ List<String> nsURIs = new ArrayList<String>();
+ for (String nsURI : registry.keySet())
+ {
+ if (filter == null || nsURI.toLowerCase().contains(filter))
+ {
+ nsURIs.add(nsURI);
+ }
+ }
+
+ elements = nsURIs.toArray(new String[nsURIs.size()]);
+ Arrays.sort(elements);
+ }
+ else
+ {
+ elements = null;
+ }
+
+ if (elements == null)
+ {
+ elements = new String[0];
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class PackageLabelProvider extends LabelProvider
+ {
+ private static final Image PACKAGE_IMAGE = SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE);
+
+ private static final Image UNKNOWN_IMAGE = SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_UNKNOWN);
+
+ private final Viewer viewer;
+
+ public PackageLabelProvider(Viewer viewer)
+ {
+ this.viewer = viewer;
+ }
+
+ @Override
+ public Image getImage(Object element)
+ {
+ String nsURI = (String)element;
+ EPackage.Registry registry = (Registry)viewer.getInput();
+ Object value = registry.get(nsURI);
+ if (value instanceof EPackage)
+ {
+ return PACKAGE_IMAGE;
+ }
+
+ return UNKNOWN_IMAGE;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class ClassContentProvider implements IStructuredContentProvider, FilterHandler
+ {
+ private Viewer viewer;
+
+ private Object input;
+
+ private String filter;
+
+ private EClass[] elements;
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ this.viewer = viewer;
+ input = newInput;
+ computeElements();
+ }
+
+ public void handleFilter(String filter)
+ {
+ this.filter = filter == null ? null : filter.toLowerCase();
+ computeElements();
+ viewer.refresh();
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return elements;
+ }
+
+ public void dispose()
+ {
+ elements = null;
+ }
+
+ private void computeElements()
+ {
+ if (input instanceof EPackage)
+ {
+ EPackage ePackage = (EPackage)input;
+
+ List<EClass> eClasses = new ArrayList<EClass>();
+ for (EClassifier eClassifier : ePackage.getEClassifiers())
+ {
+ if (eClassifier instanceof EClass)
+ {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract() && !eClass.isInterface())
+ {
+ if (filter == null || eClass.getName().toLowerCase().contains(filter))
+ {
+ eClasses.add(eClass);
+ }
+ }
+ }
+ }
+
+ elements = eClasses.toArray(new EClass[eClasses.size()]);
+ Arrays.sort(elements, new Comparator<EClass>()
+ {
+ public int compare(EClass c1, EClass c2)
+ {
+ return StringUtil.safe(c1.getName()).compareTo(StringUtil.safe(c2.getName()));
+ }
+ });
+ }
+ else
+ {
+ elements = null;
+ }
+
+ if (elements == null)
+ {
+ elements = new EClass[0];
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class ClassLabelProvider extends LabelProvider
+ {
+ private static final Image CLASS_IMAGE = SharedIcons.getImage(SharedIcons.OBJ_ECLASS);
+
+ private final ComposedAdapterFactory adapterFactory;
+
+ private final ILabelProvider labelProvider;
+
+ public ClassLabelProvider()
+ {
+ adapterFactory = CDOEditor.createAdapterFactory(true);
+ labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
+ }
+
+ @Override
+ public void dispose()
+ {
+ labelProvider.dispose();
+ adapterFactory.dispose();
+ super.dispose();
+ }
+
+ @Override
+ public Image getImage(Object element)
+ {
+ try
+ {
+ EClass eClass = (EClass)element;
+ EObject eObject = EcoreUtil.create(eClass);
+ Image image = labelProvider.getImage(eObject);
+ if (image != null)
+ {
+ return image;
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return CLASS_IMAGE;
+ }
+
+ @Override
+ public String getText(Object element)
+ {
+ return ((EClass)element).getName();
+ }
+ }
+}
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 9228fff853..bcd4e5a921 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
@@ -40,6 +40,8 @@ import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
import org.eclipse.net4j.util.AdapterUtil;
import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
import org.eclipse.net4j.util.ui.actions.SafeAction;
@@ -111,6 +113,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -125,17 +128,21 @@ import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
@@ -199,7 +206,14 @@ public class CDOEditor extends MultiPageEditorPart
return Collections.unmodifiableList(result);
}
- private static final Field VIEWER_FIELD = getViewerField();
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOEditor.class);
+
+ private static final Image ERROR_IMAGE = PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+
+ private static final Field PROPERTY_SHEET_PAGE_VIEWER_FIELD = getPropertySheetPageViewerField();
+
+ private static final Field CONTENT_OUTLINE_PAGE_VIEWER_FIELD = getContentOutlinePageViewerField();
/**
* @ADDED
@@ -1187,13 +1201,38 @@ public class CDOEditor extends MultiPageEditorPart
createModel();
Tree tree = new Tree(getContainer(), SWT.MULTI);
- selectionViewer = new TreeViewer(tree);
+ selectionViewer = new SafeTreeViewer(tree);
setCurrentViewer(selectionViewer);
selectionViewer.setContentProvider(createContentProvider());
selectionViewer.setLabelProvider(createLabelProvider());
selectionViewer.setInput(viewerInput);
+ getSite().getShell().getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ IContentProvider contentProvider = selectionViewer.getContentProvider();
+ if (contentProvider instanceof IStructuredContentProvider)
+ {
+ IStructuredContentProvider structuredContentProvider = (IStructuredContentProvider)contentProvider;
+
+ Object[] elements = structuredContentProvider.getElements(viewerInput);
+ if (elements != null && elements.length != 0)
+ {
+ setSelectionToViewer(Collections.singleton(elements[0]));
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+ }
+ });
+
new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
createContextMenuFor(selectionViewer);
@@ -1246,7 +1285,7 @@ public class CDOEditor extends MultiPageEditorPart
}
catch (NoSuchMethodError ex)
{
- if (VIEWER_FIELD == null)
+ if (PROPERTY_SHEET_PAGE_VIEWER_FIELD == null)
{
throw ex;
}
@@ -1256,7 +1295,7 @@ public class CDOEditor extends MultiPageEditorPart
if (objects == null)
{
- Object value = ReflectUtil.getValue(VIEWER_FIELD, propertySheetPage);
+ Object value = ReflectUtil.getValue(PROPERTY_SHEET_PAGE_VIEWER_FIELD, propertySheetPage);
if (value instanceof IInputProvider)
{
IInputProvider inputProvider = (IInputProvider)value;
@@ -1353,7 +1392,26 @@ public class CDOEditor extends MultiPageEditorPart
*/
protected IContentProvider createContentProvider()
{
- return new AdapterFactoryContentProvider(adapterFactory);
+ return new AdapterFactoryContentProvider(adapterFactory)
+ {
+ @Override
+ public boolean hasChildren(Object object)
+ {
+ try
+ {
+ return super.hasChildren(object);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+
+ return false;
+ }
+ }
+ };
}
/**
@@ -1362,7 +1420,70 @@ public class CDOEditor extends MultiPageEditorPart
protected ILabelProvider createLabelProvider()
{
return new DecoratingLabelProvider(new CDOLabelProvider(adapterFactory, view, selectionViewer),
- createLabelDecorator());
+ createLabelDecorator())
+ {
+ @Override
+ public Image getImage(Object element)
+ {
+ try
+ {
+ Image image = super.getImage(element);
+ if (image != null)
+ {
+ return image;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
+
+ return ERROR_IMAGE;
+ }
+
+ @Override
+ public String getText(Object element)
+ {
+ try
+ {
+ String text = super.getText(element);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
+
+ try
+ {
+ if (element instanceof EObject)
+ {
+ EObject eObject = (EObject)element;
+ EClass eClass = eObject.eClass();
+ String text = getText(eClass);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return element.getClass().getSimpleName();
+ }
+ };
}
/**
@@ -1468,15 +1589,34 @@ public class CDOEditor extends MultiPageEditorPart
@Override
public void createControl(Composite parent)
{
- super.createControl(parent);
+ if (CONTENT_OUTLINE_PAGE_VIEWER_FIELD == null)
+ {
+ super.createControl(parent);
+ }
+ else
+ {
+ TreeViewer treeViewer = new SafeTreeViewer(parent, getTreeStyle());
+ treeViewer.addSelectionChangedListener(this);
+ ReflectUtil.setValue(CONTENT_OUTLINE_PAGE_VIEWER_FIELD, this, treeViewer);
+ }
+
+ // super.createControl(parent);
contentOutlineViewer = getTreeViewer();
contentOutlineViewer.addSelectionChangedListener(this);
// Set up the tree viewer.
//
- contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
- contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
- contentOutlineViewer.setInput(viewerInput);
+ contentOutlineViewer.setContentProvider(createContentProvider());
+ contentOutlineViewer.setLabelProvider(createLabelProvider());
+
+ try
+ {
+ contentOutlineViewer.setInput(viewerInput);
+ }
+ catch (Exception ex)
+ {
+ contentOutlineViewer.setInput(null);
+ }
// Make sure our popups work.
//
@@ -1587,6 +1727,24 @@ public class CDOEditor extends MultiPageEditorPart
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection)
+ {
+ try
+ {
+ super.selectionChanged(part, selection);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+
+ super.selectionChanged(part, StructuredSelection.EMPTY);
+ }
+ }
};
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
@@ -1969,7 +2127,7 @@ public class CDOEditor extends MultiPageEditorPart
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
* Calling this result will notify the listeners.
* <!-- begin-user-doc --> <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
public void setSelection(ISelection selection)
{
@@ -1977,14 +2135,25 @@ public class CDOEditor extends MultiPageEditorPart
for (ISelectionChangedListener listener : selectionChangedListeners)
{
- listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ try
+ {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
}
+
setStatusLineManager(selection);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
public void setStatusLineManager(ISelection selection)
{
@@ -2005,7 +2174,43 @@ public class CDOEditor extends MultiPageEditorPart
}
case 1:
{
- String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
+ Object element = collection.iterator().next();
+ AdapterFactoryItemDelegator adapterFactoryItemDelegator = new AdapterFactoryItemDelegator(adapterFactory);
+ String text = null;
+
+ try
+ {
+ text = adapterFactoryItemDelegator.getText(element);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+
+ text = null;
+ }
+
+ try
+ {
+ if (StringUtil.isEmpty(text) && element instanceof EObject)
+ {
+ EObject eObject = (EObject)element;
+ EClass eClass = eObject.eClass();
+ text = adapterFactoryItemDelegator.getText(eClass);
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ if (StringUtil.isEmpty(text))
+ {
+ text = element.getClass().getSimpleName();
+ }
+
statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
break;
}
@@ -2039,6 +2244,7 @@ public class CDOEditor extends MultiPageEditorPart
public void menuAboutToShow(IMenuManager menuManager)
{
menuAboutToShowGen(menuManager);
+
MenuManager submenuManager = new MenuManager(Messages.getString("CDOEditor.23")); //$NON-NLS-1$
NewRootMenuPopulator populator = new NewRootMenuPopulator(view.getSession().getPackageRegistry())
@@ -2450,7 +2656,7 @@ public class CDOEditor extends MultiPageEditorPart
return PluginDelegator.INSTANCE.getString(key, new Object[] { s1 });
}
- private static Field getViewerField()
+ private static Field getPropertySheetPageViewerField()
{
try
{
@@ -2462,6 +2668,84 @@ public class CDOEditor extends MultiPageEditorPart
}
}
+ private static Field getContentOutlinePageViewerField()
+ {
+ try
+ {
+ return ReflectUtil.getField(ContentOutlinePage.class, "treeViewer");
+ }
+ catch (Throwable ex)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class SafeTreeViewer extends TreeViewer
+ {
+ public SafeTreeViewer(Tree tree)
+ {
+ super(tree);
+ }
+
+ public SafeTreeViewer(Composite parent, int style)
+ {
+ super(parent, style);
+ }
+
+ @Override
+ protected void doUpdateItem(Widget widget, Object element, boolean fullMap)
+ {
+ try
+ {
+ super.doUpdateItem(widget, element, fullMap);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
+ }
+
+ @Override
+ protected void doUpdateItem(final Item item, Object element)
+ {
+ try
+ {
+ super.doUpdateItem(item, element);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+ }
+ }
+
+ @Override
+ public boolean isExpandable(Object element)
+ {
+ try
+ {
+ return super.isExpandable(element);
+ }
+ catch (Exception ex)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(ex);
+ }
+
+ return false;
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOTimeMachineView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOTimeMachineView.java
index 7f7ec15569..b744226e02 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOTimeMachineView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOTimeMachineView.java
@@ -71,6 +71,11 @@ public class CDOTimeMachineView extends ViewPart implements ISelectionListener
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
CDOView view = getView(selection);
+ if (view != null && view.properties().getOrDefault(CDOView.PROP_TIME_MACHINE_DISABLED, false) == Boolean.TRUE)
+ {
+ view = null;
+ }
+
timeSlider.connect(view, null);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java
index 2c7cb25f7b..0147182aeb 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java
@@ -14,10 +14,13 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
@@ -28,6 +31,9 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
/**
* A {@link org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider AdapterFactoryLabelProvider} specialization
@@ -48,6 +54,9 @@ public class CDOLabelProvider extends AdapterFactoryLabelProvider implements ICo
private static final Color RED = UIUtil.getDisplay().getSystemColor(SWT.COLOR_RED);
+ private static final Image ERROR_IMAGE = PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+
private Font bold;
private CDOView view;
@@ -112,6 +121,56 @@ public class CDOLabelProvider extends AdapterFactoryLabelProvider implements ICo
}
@Override
+ public Image getImage(Object object)
+ {
+ try
+ {
+ return super.getImage(object);
+ }
+ catch (Exception ex)
+ {
+ return ERROR_IMAGE;
+ }
+ }
+
+ @Override
+ public String getText(Object object)
+ {
+ try
+ {
+ String text = super.getText(object);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ catch (Exception ex)
+ {
+ //$FALL-THROUGH$
+ }
+
+ try
+ {
+ if (object instanceof EObject)
+ {
+ EObject eObject = (EObject)object;
+ EClass eClass = eObject.eClass();
+ String text = getText(eClass);
+ if (!StringUtil.isEmpty(text))
+ {
+ return text;
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ //$FALL-THROUGH$
+ }
+
+ return object.getClass().getSimpleName();
+ }
+
+ @Override
public Color getBackground(Object object)
{
// Use default
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java
index 99b78024fc..1bdc503727 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/TimeSlider.java
@@ -229,6 +229,10 @@ public class TimeSlider extends Scale implements IListener, ITreeViewerListener
setEnabled(false);
}
}
+ else if (this.view == null)
+ {
+ setEnabled(false);
+ }
}
public void disconnect()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
index 61c0501eff..99ba3f7b4e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
@@ -96,6 +96,11 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, CDOCommitHistory.P
IContainer<CDOResourceNode>
{
/**
+ * @since 4.5
+ */
+ public static String PROP_TIME_MACHINE_DISABLED = "timeMachineDisabled";
+
+ /**
* Returns the {@link CDOSession session} this view was opened by.
*
* @return The session this view was opened by, or <code>null</code> if this view is closed.
diff --git a/plugins/org.eclipse.net4j.util.ui/.settings/.api_filters b/plugins/org.eclipse.net4j.util.ui/.settings/.api_filters
index ed9bda4e47..9779b6967d 100644
--- a/plugins/org.eclipse.net4j.util.ui/.settings/.api_filters
+++ b/plugins/org.eclipse.net4j.util.ui/.settings/.api_filters
@@ -100,6 +100,31 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/net4j/util/ui/UIUtil.java" type="org.eclipse.net4j.util.ui.UIUtil">
+ <filter id="1141899266">
+ <message_arguments>
+ <message_argument value="3.5"/>
+ <message_argument value="3.6"/>
+ <message_argument value="syncExec(Display, Runnable)"/>
+ </message_arguments>
+ </filter>
+ <filter id="1141899266">
+ <message_arguments>
+ <message_argument value="3.5"/>
+ <message_argument value="3.6"/>
+ <message_argument value="syncExec(Runnable)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/net4j/util/ui/widgets/FirstChildLayout.java" type="org.eclipse.net4j.util.ui.widgets.FirstChildLayout">
+ <filter id="1108344834">
+ <message_arguments>
+ <message_argument value="3.5"/>
+ <message_argument value="3.6"/>
+ <message_argument value="org.eclipse.net4j.util.ui.widgets.FirstChildLayout"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/net4j/util/ui/widgets/ImageButton.java" type="org.eclipse.net4j.util.ui.widgets.ImageButton">
<filter id="571473929">
<message_arguments>
diff --git a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
index 30089a9ef3..2ea832f899 100644
--- a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j.util.ui;singleton:=true
-Bundle-Version: 3.5.100.qualifier
+Bundle-Version: 3.6.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
@@ -15,19 +15,19 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.ui.shared;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.net4j.util.internal.ui;version="3.5.100";x-internal:=true,
- org.eclipse.net4j.util.internal.ui.actions;version="3.5.100";x-internal:=true,
- org.eclipse.net4j.util.internal.ui.bundle;version="3.5.100";x-internal:=true,
- org.eclipse.net4j.util.internal.ui.messages;version="3.5.100";x-internal:=true,
- org.eclipse.net4j.util.internal.ui.views;version="3.5.100";x-internal:=true,
- org.eclipse.net4j.util.ui;version="3.5.100",
- org.eclipse.net4j.util.ui.actions;version="3.5.100",
- org.eclipse.net4j.util.ui.confirmation;version="3.5.100",
- org.eclipse.net4j.util.ui.container;version="3.5.100",
- org.eclipse.net4j.util.ui.dnd;version="3.5.100",
- org.eclipse.net4j.util.ui.handlers;version="3.5.100",
- org.eclipse.net4j.util.ui.prefs;version="3.5.100",
- org.eclipse.net4j.util.ui.proposals;version="3.5.100",
- org.eclipse.net4j.util.ui.security;version="3.5.100",
- org.eclipse.net4j.util.ui.views;version="3.5.100",
- org.eclipse.net4j.util.ui.widgets;version="3.5.100"
+Export-Package: org.eclipse.net4j.util.internal.ui;version="3.6.0";x-internal:=true,
+ org.eclipse.net4j.util.internal.ui.actions;version="3.6.0";x-internal:=true,
+ org.eclipse.net4j.util.internal.ui.bundle;version="3.6.0";x-internal:=true,
+ org.eclipse.net4j.util.internal.ui.messages;version="3.6.0";x-internal:=true,
+ org.eclipse.net4j.util.internal.ui.views;version="3.6.0";x-internal:=true,
+ org.eclipse.net4j.util.ui;version="3.6.0",
+ org.eclipse.net4j.util.ui.actions;version="3.6.0",
+ org.eclipse.net4j.util.ui.confirmation;version="3.6.0",
+ org.eclipse.net4j.util.ui.container;version="3.6.0",
+ org.eclipse.net4j.util.ui.dnd;version="3.6.0",
+ org.eclipse.net4j.util.ui.handlers;version="3.6.0",
+ org.eclipse.net4j.util.ui.prefs;version="3.6.0",
+ org.eclipse.net4j.util.ui.proposals;version="3.6.0",
+ org.eclipse.net4j.util.ui.security;version="3.6.0",
+ org.eclipse.net4j.util.ui.views;version="3.6.0",
+ org.eclipse.net4j.util.ui.widgets;version="3.6.0"
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
index e041c7ea28..b63c84f4c6 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
@@ -30,6 +30,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceAdapter;
@@ -539,6 +540,70 @@ public final class UIUtil
}
/**
+ * @since 3.5
+ */
+ public static void syncExec(final Runnable runnable)
+ {
+ final Display display = getDisplay();
+ if (Display.getCurrent() == display || display == null)
+ {
+ runnable.run();
+ }
+ else
+ {
+ syncExec(display, runnable);
+ }
+ }
+
+ /**
+ * @since 3.5
+ */
+ public static void syncExec(final Display display, final Runnable runnable)
+ {
+ try
+ {
+ if (display.isDisposed())
+ {
+ return;
+ }
+
+ display.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ if (display.isDisposed())
+ {
+ return;
+ }
+
+ try
+ {
+ runnable.run();
+ }
+ catch (SWTException ex)
+ {
+ if (ex.code != SWT.ERROR_WIDGET_DISPOSED)
+ {
+ throw ex;
+ }
+
+ //$FALL-THROUGH$
+ }
+ }
+ });
+ }
+ catch (SWTException ex)
+ {
+ if (ex.code != SWT.ERROR_WIDGET_DISPOSED)
+ {
+ throw ex;
+ }
+
+ //$FALL-THROUGH$
+ }
+ }
+
+ /**
* @since 3.3
*/
public static void runWithProgress(final IRunnableWithProgress runnable)
@@ -736,25 +801,25 @@ public final class UIUtil
{
viewer.addDragSupport(DND.DROP_LINK | DND.DROP_MOVE | DND.DROP_COPY,
new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DragSourceAdapter()
- {
- private long lastDragTime;
+ {
+ private long lastDragTime;
- @Override
- public void dragStart(DragSourceEvent event)
- {
- lastDragTime = System.currentTimeMillis();
- LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection());
- LocalSelectionTransfer.getTransfer().setSelectionSetTime(lastDragTime);
- }
+ @Override
+ public void dragStart(DragSourceEvent event)
+ {
+ lastDragTime = System.currentTimeMillis();
+ LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection());
+ LocalSelectionTransfer.getTransfer().setSelectionSetTime(lastDragTime);
+ }
- @Override
- public void dragFinished(DragSourceEvent event)
- {
- if (LocalSelectionTransfer.getTransfer().getSelectionSetTime() == lastDragTime)
- {
- LocalSelectionTransfer.getTransfer().setSelection(null);
- }
- }
- });
+ @Override
+ public void dragFinished(DragSourceEvent event)
+ {
+ if (LocalSelectionTransfer.getTransfer().getSelectionSetTime() == lastDragTime)
+ {
+ LocalSelectionTransfer.getTransfer().setSelection(null);
+ }
+ }
+ });
}
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/FirstChildLayout.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/FirstChildLayout.java
new file mode 100644
index 0000000000..cec6a33c70
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/FirstChildLayout.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 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
+ */
+package org.eclipse.net4j.util.ui.widgets;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+/**
+ * @author Eike Stepper
+ * @since 3.5
+ */
+public class FirstChildLayout extends Layout
+{
+ @Override
+ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
+ {
+ Control children[] = composite.getChildren();
+ if (children.length != 0)
+ {
+ return children[0].computeSize(wHint, hHint, flushCache);
+ }
+
+ return new Point(0, 0);
+ }
+
+ @Override
+ protected boolean flushCache(Control control)
+ {
+ return true;
+ }
+
+ @Override
+ protected void layout(Composite composite, boolean flushCache)
+ {
+ Rectangle rect = composite.getClientArea();
+
+ Control children[] = composite.getChildren();
+ for (int i = 0; i < children.length; i++)
+ {
+ children[i].setBounds(rect);
+ children[i].setVisible(i == 0);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/SearchField.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/SearchField.java
new file mode 100644
index 0000000000..e996d06434
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/SearchField.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2015 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
+ */
+package org.eclipse.net4j.util.ui.widgets;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
+
+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.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+import java.lang.reflect.Field;
+
+/**
+ * @author Eike Stepper
+ * @since 3.6
+ */
+public class SearchField extends Composite
+{
+ private static final Field patternFilterField = ReflectUtil.getField(FilteredTree.class, "patternFilter");
+
+ private static final Field refreshJobField = ReflectUtil.getField(FilteredTree.class, "refreshJob");
+
+ private final InternalTree filteredTree;
+
+ public SearchField(Composite parent, final FilterHandler filterHandler)
+ {
+ super(parent, SWT.NONE);
+ setLayout(new FirstChildLayout());
+
+ final PatternFilter patternFilter = new PatternFilter()
+ {
+ @Override
+ public Object[] filter(Viewer viewer, Object parent, Object[] elements)
+ {
+ if (filteredTree != null)
+ {
+ Text filterControl = filteredTree.getFilterControl();
+ String filter = filterControl.getText();
+ if (ObjectUtil.equals(filter, filteredTree.getInitialText()))
+ {
+ filter = null;
+ }
+
+ filterHandler.handleFilter(filter);
+ }
+
+ return new Object[0];
+ }
+ };
+
+ filteredTree = new InternalTree(this, SWT.NONE, patternFilter, true, patternFilter);
+
+ final Text filterControl = filteredTree.getFilterControl();
+ filterControl.addTraverseListener(new TraverseListener()
+ {
+ public void keyTraversed(TraverseEvent e)
+ {
+ if (e.keyCode == SWT.ESC)
+ {
+ if (!"".equals(filterControl.getText()))
+ {
+ filterControl.setText("");
+ e.doit = false;
+ }
+ }
+ }
+ });
+
+ filterControl.addKeyListener(new KeyAdapter()
+ {
+ @Override
+ public void keyPressed(KeyEvent e)
+ {
+ if (e.keyCode == SWT.CR || e.keyCode == SWT.ARROW_DOWN)
+ {
+ finishFilter();
+ e.doit = false;
+ }
+ }
+ });
+ }
+
+ public final PatternFilter getPatternFilter()
+ {
+ return filteredTree.getPatternFilter();
+ }
+
+ public final Text getFilterControl()
+ {
+ return filteredTree.getFilterControl();
+ }
+
+ public final void setInitialText(String text)
+ {
+ filteredTree.setInitialText(text);
+ }
+
+ @Override
+ public final boolean getEnabled()
+ {
+ return filteredTree.getEnabled();
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ filteredTree.setEnabled(enabled);
+ }
+
+ @Override
+ public boolean setFocus()
+ {
+ return getFilterControl().setFocus();
+ }
+
+ @Override
+ protected void checkSubclass()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Subclasses may override.
+ * @param e
+ */
+ protected void finishFilter()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class InternalTree extends FilteredTree
+ {
+ private final PatternFilter patternFilter;
+
+ private InternalTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook,
+ PatternFilter patternFilter)
+ {
+ super(parent, treeStyle, filter, useNewLook);
+ this.patternFilter = patternFilter;
+ }
+
+ @Override
+ @SuppressWarnings("restriction")
+ protected void init(int treeStyle, PatternFilter filter)
+ {
+ ReflectUtil.setValue(patternFilterField, this, filter);
+
+ showFilterControls = PlatformUI.getPreferenceStore()
+ .getBoolean(IWorkbenchPreferenceConstants.SHOW_FILTERED_TEXTS);
+ createControl(SearchField.this, treeStyle);
+
+ Job refreshJob = new Job("Refresh Filter")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ UIUtil.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ patternFilter.filter(treeViewer, (Object)null, null);
+ }
+ });
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ refreshJob.setSystem(true);
+ ReflectUtil.setValue(refreshJobField, this, refreshJob);
+
+ setInitialText(org.eclipse.ui.internal.WorkbenchMessages.FilteredTree_FilterMessage);
+ setFont(SearchField.this.getFont());
+ }
+
+ @Override
+ protected void createControl(Composite xxx, int treeStyle)
+ {
+ super.createControl(SearchField.this, treeStyle);
+
+ Tree tree = treeViewer.getTree();
+ tree.setParent(SearchField.this);
+ tree.setLayoutData(new GridData(0, 0));
+
+ treeComposite.dispose();
+ treeComposite = null;
+ }
+
+ @Override
+ public String getInitialText()
+ {
+ return super.getInitialText();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface FilterHandler
+ {
+ public void handleFilter(String filter);
+ }
+}

Back to the top