From 882533713e17e5b0e68b17e6bc08988833fc99b4 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Thu, 19 Mar 2015 11:09:54 +0100 Subject: [458349] Consolidate UI Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349--- plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml | 4 +- .../checkouts/wizards/CheckoutBranchPointPage.java | 5 +- .../ui/checkouts/wizards/CheckoutLabelPage.java | 9 ++-- .../checkouts/wizards/CheckoutRepositoryPage.java | 3 +- .../checkouts/wizards/CheckoutRootObjectPage.java | 2 +- .../ui/checkouts/wizards/CheckoutTypePage.java | 63 ++++++++++++++-------- plugins/org.eclipse.emf.cdo.ui/plugin.xml | 4 +- .../cdo/internal/ui/CDOPropertyAdapterFactory.java | 8 +-- 8 files changed, 59 insertions(+), 39 deletions(-) diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml index 479e5a96a8..b1b7e91ef1 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/plugin.xml @@ -183,8 +183,8 @@ - + @@ -234,7 +234,7 @@ - + diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java index 4ad0ddc60a..36820374d5 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.util.CDOCommonUtil; import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; import org.eclipse.emf.cdo.explorer.repositories.CDORepository; +import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.ui.widgets.ComposeBranchPointComposite; @@ -199,7 +200,7 @@ public class CheckoutBranchPointPage extends CheckoutWizardPage @Override protected void fillProperties(Properties properties) { - properties.setProperty("branchID", Integer.toString(branchID)); - properties.setProperty("timeStamp", Long.toString(timeStamp)); + properties.setProperty(CDOCheckoutImpl.PROP_BRANCH_ID, Integer.toString(branchID)); + properties.setProperty(CDOCheckoutImpl.PROP_TIME_STAMP, Long.toString(timeStamp)); } } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java index bdbb98f736..5914476c37 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckoutManager; import org.eclipse.emf.cdo.explorer.repositories.CDORepository; import org.eclipse.emf.cdo.internal.explorer.AbstractElement; +import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl; import org.eclipse.net4j.util.StringUtil; @@ -225,7 +226,7 @@ public class CheckoutLabelPage extends CheckoutWizardPage @Override protected void fillProperties(Properties properties) { - properties.setProperty("label", label); + properties.setProperty(CDOCheckoutImpl.PROP_LABEL, label); } private void clearLabel() @@ -240,13 +241,13 @@ public class CheckoutLabelPage extends CheckoutWizardPage public static String getUniqueLabel(String label) { Set names = new HashSet(); - + CDOCheckoutManager checkoutManager = CDOExplorerUtil.getCheckoutManager(); for (CDOCheckout checkout : checkoutManager.getCheckouts()) { names.add(checkout.getLabel()); } - + for (int i = 1; i < Integer.MAX_VALUE; i++) { String name = i == 1 ? label : label + " (" + i + ")"; @@ -255,7 +256,7 @@ public class CheckoutLabelPage extends CheckoutWizardPage return name; } } - + throw new IllegalStateException("Too many checkouts"); } } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRepositoryPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRepositoryPage.java index 98fdb2e27a..d58ab83678 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRepositoryPage.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRepositoryPage.java @@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.explorer.CDOExplorerUtil; import org.eclipse.emf.cdo.explorer.repositories.CDORepository; import org.eclipse.emf.cdo.explorer.ui.repositories.CDORepositoriesView; import org.eclipse.emf.cdo.explorer.ui.repositories.CDORepositoryItemProvider; +import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.jface.layout.TableColumnLayout; @@ -211,6 +212,6 @@ public class CheckoutRepositoryPage extends CheckoutWizardPage @Override protected void fillProperties(Properties properties) { - properties.setProperty("repository", repository.getID()); + properties.setProperty(CDOCheckoutImpl.PROP_REPOSITORY, repository.getID()); } } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRootObjectPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRootObjectPage.java index c31fee26c4..d5ca34a1d1 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRootObjectPage.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutRootObjectPage.java @@ -324,7 +324,7 @@ public class CheckoutRootObjectPage extends CheckoutWizardPage { if (rootID != null) { - properties.setProperty("rootID", CDOCheckoutImpl.getCDOIDString(rootID)); + properties.setProperty(CDOCheckoutImpl.PROP_ROOT_ID, CDOCheckoutImpl.getCDOIDString(rootID)); } } diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutTypePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutTypePage.java index ab18d5f65b..f995a62849 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutTypePage.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutTypePage.java @@ -14,8 +14,10 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout; import org.eclipse.emf.cdo.explorer.repositories.CDORepository; import org.eclipse.emf.cdo.explorer.repositories.CDORepository.IDGeneration; import org.eclipse.emf.cdo.explorer.ui.bundle.OM; +import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl; import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.ui.UIUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; @@ -23,6 +25,7 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; 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.Label; @@ -75,15 +78,16 @@ public class CheckoutTypePage extends CheckoutWizardPage protected void createUI(Composite parent) { transactionalButton = addChoice(parent, "Online Transactional", "icons/transactional.gif", - CDOCheckout.TYPE_ONLINE_TRANSACTIONAL); + "Creates a remote connection for online editing.", CDOCheckout.TYPE_ONLINE_TRANSACTIONAL); historicalButton = addChoice(parent, "Online Historical", "icons/historical.gif", - CDOCheckout.TYPE_ONLINE_HISTORICAL); + "Creates a remote connection for online auditing.", CDOCheckout.TYPE_ONLINE_HISTORICAL); - offlineButton = addChoice(parent, "Offline", "icons/disconnect.gif", CDOCheckout.TYPE_OFFLINE); + offlineButton = addChoice(parent, "Offline", "icons/disconnect.gif", + "Creates a local checkout for offline editing.", CDOCheckout.TYPE_OFFLINE); } - private Button addChoice(Composite composite, String text, String imagePath, final String type) + private Button addChoice(Composite composite, String text, String imagePath, String description, final String type) { final SelectionListener listener = new SelectionListener() { @@ -112,25 +116,21 @@ public class CheckoutTypePage extends CheckoutWizardPage } }); - Label imageLabel = new Label(composite, SWT.NONE); - imageLabel.setImage(OM.getImage(imagePath)); + GridLayout descriptionLayout = UIUtil.createGridLayout(2); + descriptionLayout.marginLeft = 20; + descriptionLayout.horizontalSpacing = 5; - new Label(composite, SWT.NONE); - return button; - } + Composite descriptionComposite = new Composite(composite, SWT.NONE); + descriptionComposite.setLayout(descriptionLayout); - @Override - protected void repositoryChanged(CDORepository repository) - { - this.repository = repository; + Label imageLabel = new Label(descriptionComposite, SWT.NONE); + imageLabel.setImage(OM.getImage(imagePath)); - Button button = getButton(type); - if (button != null && !button.isEnabled()) - { - setType(CDOCheckout.TYPE_ONLINE_TRANSACTIONAL); - } + Label descriptionLabel = new Label(descriptionComposite, SWT.NONE); + descriptionLabel.setText(description); - super.repositoryChanged(repository); + new Label(composite, SWT.NONE); + return button; } private Button getButton(String type) @@ -153,6 +153,20 @@ public class CheckoutTypePage extends CheckoutWizardPage return null; } + @Override + protected void repositoryChanged(CDORepository repository) + { + this.repository = repository; + + Button button = getButton(type); + if (button != null && !button.isEnabled()) + { + setType(CDOCheckout.TYPE_ONLINE_TRANSACTIONAL); + } + + super.repositoryChanged(repository); + } + @Override protected void pageActivated() { @@ -185,10 +199,11 @@ public class CheckoutTypePage extends CheckoutWizardPage } } - transactionalButton.setSelection(type == CDOCheckout.TYPE_ONLINE_TRANSACTIONAL); + transactionalButton.setSelection(CDOCheckout.TYPE_ONLINE_TRANSACTIONAL.equals(type)); } - historicalButton.setSelection(type == CDOCheckout.TYPE_ONLINE_HISTORICAL); - offlineButton.setSelection(type == CDOCheckout.TYPE_OFFLINE); + + historicalButton.setSelection(CDOCheckout.TYPE_ONLINE_HISTORICAL.equals(type)); + offlineButton.setSelection(CDOCheckout.TYPE_OFFLINE.equals(type)); } @Override @@ -200,6 +215,8 @@ public class CheckoutTypePage extends CheckoutWizardPage @Override protected void fillProperties(Properties properties) { - properties.setProperty("type", type); + properties.setProperty(CDOCheckoutImpl.PROP_TYPE, type); + properties.setProperty(CDOCheckoutImpl.PROP_READ_ONLY, + Boolean.toString(CDOCheckout.TYPE_ONLINE_HISTORICAL.equals(type))); } } diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml index 306fae6a6c..dab1dd0a3e 100644 --- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml @@ -402,7 +402,7 @@ - + @@ -440,7 +440,7 @@ - + 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 0095d3a794..79389f2a12 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 @@ -11,7 +11,6 @@ package org.eclipse.emf.cdo.internal.ui; import org.eclipse.emf.cdo.CDOElement; -import org.eclipse.emf.cdo.CDOObject; import org.eclipse.emf.cdo.edit.CDOItemProviderAdapter.CDOPropertyDescriptor; import org.eclipse.emf.cdo.internal.ui.bundle.OM; import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; @@ -38,6 +37,7 @@ import org.eclipse.emf.edit.provider.IItemLabelProvider; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.emf.spi.cdo.InternalCDOObject; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.ui.IActionFilter; @@ -88,7 +88,7 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory if (object instanceof EObject) { EObject eObject = (EObject)object; - CDOObject cdoObject = CDOUtil.getCDOObject(eObject, false); + InternalCDOObject cdoObject = (InternalCDOObject)CDOUtil.getCDOObject(eObject, false); if (cdoObject != null) { final Map emfProperties = new HashMap(); @@ -115,8 +115,8 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory { adapterFactory = CDOEditor.createAdapterFactory(false); - IItemPropertySource propertySource = (IItemPropertySource)adapterFactory.adapt(cdoObject, - IItemPropertySource.class); + IItemPropertySource propertySource = (IItemPropertySource)adapterFactory.adapt( + cdoObject.cdoInternalInstance(), IItemPropertySource.class); if (propertySource != null) { List propertyDescriptors = propertySource.getPropertyDescriptors(cdoObject); -- cgit v1.2.3