Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-11-17 13:03:43 +0000
committerGerrit Code Review @ Eclipse.org2016-11-30 13:47:52 +0000
commita3ea7ef9891a5d83d0de788df4bafcfcfb50b453 (patch)
treeba6c0877b799748a0f3120e096273571462b4370 /plugins
parente96ff0214a5cdea079ffb209880589c35e9077cf (diff)
downloadorg.eclipse.papyrus-a3ea7ef9891a5d83d0de788df4bafcfcfb50b453.tar.gz
org.eclipse.papyrus-a3ea7ef9891a5d83d0de788df4bafcfcfb50b453.tar.xz
org.eclipse.papyrus-a3ea7ef9891a5d83d0de788df4bafcfcfb50b453.zip
Bug 507654 - [Palette Customization] Exported Element type model are
wrong - Fix issue Plus: - correct selection dialog of palette configuration layers - for some use of tree selector dialog - Add constraint to flat tabulation: - Don't display tab in selector dialog when the contentProvider is flat https://bugs.eclipse.org/bugs/show_bug.cgi?id=507654 Change-Id: If547f0f8101d56dacc1b2dc488f71a2d8550e792 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AbstractPaletteConfigurationWizard.java16
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExportPaletteConfigurationWizard.java19
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/providers/ViewContentProvider.java15
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/FeatureNameValueEditor.java19
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/ViewToDisplayValueEditor.java7
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ElementsExplorerDialog.java436
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java54
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FilteredContentProvider.java5
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FlatFilteredContentProvider.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.types.ui.properties/src/org/eclipse/papyrus/uml/types/ui/properties/widgets/FeatureToSetNameValueEditor.java18
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeExplorerDialog.java85
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml1
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabConstaint.java102
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabUMLLabelProvider.java5
14 files changed, 266 insertions, 518 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AbstractPaletteConfigurationWizard.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AbstractPaletteConfigurationWizard.java
index c6b92702601..5d302806620 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AbstractPaletteConfigurationWizard.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AbstractPaletteConfigurationWizard.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 507654 Change load order and add EcoreUtil.resolveAll(resource) to avoid absolute references
*****************************************************************************/
package org.eclipse.papyrus.customization.palette.dialog;
@@ -23,6 +24,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
@@ -313,28 +315,29 @@ public abstract class AbstractPaletteConfigurationWizard extends Wizard {
}
// Create resource
- elementTypeUIResource = editingDomain.getResourceSet().createResource(elementTypeUIURI);
elementTypeSemResource = editingDomain.getResourceSet().createResource(elementTypeSemURI);
+ elementTypeUIResource = editingDomain.getResourceSet().createResource(elementTypeUIURI);
if (!PaletteUtils.notErrorOnFile(elementTypeUIFile) && !PaletteUtils.notErrorOnFile(elementTypeSemFile)) {
- ElementTypeSetConfiguration emptyElementTypeModelUI = getEmptyElementTypeModel(elementTypeUIResource.getURI().lastSegment().replace(STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION, ""));//$NON-NLS-1$
ElementTypeSetConfiguration emptyElementTypeModelSem = getEmptyElementTypeModel(elementTypeSemResource.getURI().lastSegment().replace(STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION, ""));//$NON-NLS-1$
+ ElementTypeSetConfiguration emptyElementTypeModelUI = getEmptyElementTypeModel(elementTypeUIResource.getURI().lastSegment().replace(STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION, ""));//$NON-NLS-1$
// Add it to the resource
CompoundCommand compoundCommand = new CompoundCommand();
- compoundCommand.append(new AddCommand(editingDomain, elementTypeUIResource.getContents(), emptyElementTypeModelUI));
compoundCommand.append(new AddCommand(editingDomain, elementTypeSemResource.getContents(), emptyElementTypeModelSem));
+ compoundCommand.append(new AddCommand(editingDomain, elementTypeUIResource.getContents(), emptyElementTypeModelUI));
editingDomain.getCommandStack().execute(compoundCommand);
}
if (null != elementTypeUIResource || null != elementTypeSemResource) {
try {
- elementTypeUIResource.load(Collections.emptyMap());
elementTypeSemResource.load(Collections.emptyMap());
-
- elementTypeUIResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_UI_RESSOURCE_IDENTIFIER, elementTypeUIResource);
+ EcoreUtil.resolveAll(elementTypeSemResource);
+ elementTypeUIResource.load(Collections.emptyMap());
+ EcoreUtil.resolveAll(elementTypeUIResource);
elementTypeSemResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_SEMENTIC_RESSOURCE_IDENTIFIER, elementTypeSemResource);
+ elementTypeUIResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_UI_RESSOURCE_IDENTIFIER, elementTypeUIResource);
} catch (IOException e) {
Activator.log.error(e);
}
@@ -421,6 +424,7 @@ public abstract class AbstractPaletteConfigurationWizard extends Wizard {
try {
paletteResource.load(Collections.emptyMap());
paletteResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.PALETTE_RESSOURCE_IDENTIFIER, paletteResource);
+ EcoreUtil.resolveAll(paletteResource);
} catch (IOException e) {
Activator.log.error(e);
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExportPaletteConfigurationWizard.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExportPaletteConfigurationWizard.java
index 85dce028af4..6e89b2fe30d 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExportPaletteConfigurationWizard.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExportPaletteConfigurationWizard.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
- *
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 507654 Change the save order
*****************************************************************************/
package org.eclipse.papyrus.customization.palette.dialog;
@@ -77,34 +77,33 @@ public class ExportPaletteConfigurationWizard extends AbstractPaletteConfigurati
clearStringBuilder();
stringBuilder.append(selectedPath);
+ stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX);
stringBuilder.append(STR_DOT);
- stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION);
- // Set new path
- paletteResource.setURI(URI.createFileURI(stringBuilder.toString()));
+ stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION);
+ elementTypeSemResource.setURI(URI.createFileURI(stringBuilder.toString()));
clearStringBuilder();
stringBuilder.append(selectedPath);
stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX);
stringBuilder.append(STR_DOT);
stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION);
-
elementTypeUIResource.setURI(URI.createFileURI(stringBuilder.toString()));
clearStringBuilder();
stringBuilder.append(selectedPath);
- stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX);
stringBuilder.append(STR_DOT);
- stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION);
- elementTypeSemResource.setURI(URI.createFileURI(stringBuilder.toString()));
+ stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION);
+ // Set new path
+ paletteResource.setURI(URI.createFileURI(stringBuilder.toString()));
// Save
try {
- paletteResource.save(PaletteUtils.saveOptions);
// Checks if model are not void and are useful
if (!((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0)).getElementTypeConfigurations().isEmpty()) {
- elementTypeUIResource.save(PaletteUtils.saveOptions);
elementTypeSemResource.save(PaletteUtils.saveOptions);
+ elementTypeUIResource.save(PaletteUtils.saveOptions);
}
+ paletteResource.save(PaletteUtils.saveOptions);
} catch (IOException e) {
Activator.log.error(e);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/providers/ViewContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/providers/ViewContentProvider.java
index e8edbae6b29..37dee81d76f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/providers/ViewContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/providers/ViewContentProvider.java
@@ -19,12 +19,12 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.contexts.View;
import org.eclipse.papyrus.infra.properties.ui.runtime.PropertiesRuntime;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.FilteredContentProvider;
/**
* A {@link ITreeContentProvider} for {@link View}.
*/
-public class ViewContentProvider implements ITreeContentProvider, IStaticContentProvider {
+public class ViewContentProvider extends FilteredContentProvider {
/**
* {@inheritDoc}
@@ -80,4 +80,15 @@ public class ViewContentProvider implements ITreeContentProvider, IStaticContent
return features.toArray();
}
+ /**
+ * @see org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider#isValidValue(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public boolean isValidValue(final Object element) {
+ return element instanceof View;
+ }
+
} \ No newline at end of file
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/FeatureNameValueEditor.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/FeatureNameValueEditor.java
index 30583fec8f5..67a490345c6 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/FeatureNameValueEditor.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/FeatureNameValueEditor.java
@@ -22,14 +22,14 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.emf.types.ui.properties.messages.Messages;
import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.infra.widgets.editors.ElementsExplorerDialog;
import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.infra.widgets.providers.FilteredContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -45,7 +45,7 @@ public class FeatureNameValueEditor extends StringEditor {
/**
* Content provider for the feature viewer.
*/
- protected class FeatureContentProvider implements IStructuredContentProvider {
+ protected class FeatureContentProvider extends FilteredContentProvider {
/** current edited Eclass */
protected EClass currentEClass;
@@ -75,6 +75,17 @@ public class FeatureNameValueEditor extends StringEditor {
return features.toArray();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider#isFlat()
+ */
+ @Override
+ public boolean isFlat() {
+ return true;
+ }
+
+
}
/**
@@ -178,7 +189,7 @@ public class FeatureNameValueEditor extends StringEditor {
* Handles action when user press the Manage bundle button in the combo area
*/
protected void handleManageBrowseButtonPressed() {
- ElementsExplorerDialog dialog = new ElementsExplorerDialog(getParent().getShell());
+ TreeSelectorDialog dialog = new TreeSelectorDialog(getParent().getShell());
dialog.setContentProvider(new FeatureContentProvider());
dialog.setLabelProvider(new FeatureStyledLabelProvider());
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/ViewToDisplayValueEditor.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/ViewToDisplayValueEditor.java
index bd617aa201e..7a1d6227638 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/ViewToDisplayValueEditor.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui.properties/src/org/eclipse/papyrus/infra/emf/types/ui/properties/widgets/ViewToDisplayValueEditor.java
@@ -18,8 +18,8 @@ import org.eclipse.papyrus.infra.emf.types.ui.properties.providers.ViewContentPr
import org.eclipse.papyrus.infra.emf.types.ui.properties.providers.ViewLabelProvider;
import org.eclipse.papyrus.infra.properties.contexts.View;
import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.infra.widgets.editors.ElementsExplorerDialog;
import org.eclipse.papyrus.infra.widgets.editors.ReferenceDialog;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -120,12 +120,11 @@ public class ViewToDisplayValueEditor extends ReferenceDialog {
* Handles action when user press the Manage bundle button in the combo area
*/
protected void handleManageBrowseButtonPressed() {
- ElementsExplorerDialog dialog = new ElementsExplorerDialog(getParent().getShell());
+ TreeSelectorDialog dialog = new TreeSelectorDialog(getParent().getShell());
dialog.setContentProvider(new ViewContentProvider());
dialog.setLabelProvider(new ViewLabelProvider());
- // Set the return type.
- dialog.setReturnTypeClass(View.class);
+
dialog.setTitle(Messages.ViewToDisplayValueEditor_dialogTitle);
dialog.setMessage(Messages.ViewToDisplayValueEditor_dialogMessage);
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ElementsExplorerDialog.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ElementsExplorerDialog.java
deleted file mode 100644
index 92d56d82e9d..00000000000
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ElementsExplorerDialog.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST.
- *
- * 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:
- * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.widgets.editors;
-
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-
-/**
- * Selection dialog for icons in bundles.
- */
-// TODO implement multiselection with multi return
-public class ElementsExplorerDialog extends SelectionStatusDialog {
-
-
- /** indicates if several icons can be selected at the same time */
- protected final boolean allowMultiple;
-
- /** initial value */
- protected String initialValue;
-
- /** The resource set. */
- protected ResourceSet resourceSet = new ResourceSetImpl();
-
- /** The tree viewer. */
- protected TreeViewer elementsTreeViewer;
-
- /** The tree viewer filter. */
- protected PatternViewerFilterEx viewerFilter = new PatternViewerFilterEx();
-
- /** The information text. */
- private StyledText informationText;
-
- /** The default profile icon path. */
- private static final String ICONS_EXPAND_ALL = "/icons/expandAll.png";//$NON-NLS-1$
-
- /** The default profile icon path. */
- private static final String ICONS_COLLAPSE_ALL = "/icons/collapseAll.png";//$NON-NLS-1$
-
- /** the content provider. */
- private IStructuredContentProvider contentProvider;
-
- /** The label provider. */
- private IBaseLabelProvider labelProvider;
-
- /** The input. */
- private Object input;
-
- /** the return class type. */
- private Class<?> returnClass;
-
- public ElementsExplorerDialog(final Shell parentShell, final boolean allowMultiple, final String initialQualifyName) {
- super(parentShell);
- this.allowMultiple = allowMultiple;
- this.initialValue = initialQualifyName;
- }
-
- public ElementsExplorerDialog(final Shell parentShell, final String initialValue) {
- this(parentShell, false, initialValue);
- }
-
- public ElementsExplorerDialog(final Shell parentShell) {
- this(parentShell, false, "");//$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- * Unloads resources.
- *
- * @see org.eclipse.jface.dialogs.Dialog#close()
- */
- @Override
- public boolean close() {
- for (Resource resource : resourceSet.getResources()) {
- if (resource.isLoaded()) {
- resource.unload();
- }
- }
- return super.close();
- }
-
- /**
- * Return the selected {@link Stereotype}.
- * {@inheritDoc}
- */
- @Override
- protected void computeResult() {
- Object selectedElements = getSelectedElements();
- if (null != selectedElements) {
- setResult(Arrays.asList(selectedElements));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Control createDialogArea(final Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- initializeDialogUnits(composite);
-
- // creates the message area, as defined in the super class
- createMessageArea(composite);
- createFilterText(composite);
- createExpandCollapseButtons(composite);
- createFilteredList(composite);
- createInformationText(composite);
-
- selectInitialValue();
- refreshOkButton();
- return composite;
- }
-
- /**
- * Create buttons to collapse and expand treeViewer.
- */
- protected void createExpandCollapseButtons(final Composite composite) {
- if (contentProvider instanceof ITreeContentProvider) {
- Composite container = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout(2, true);
- layout.horizontalSpacing = 2;
- layout.marginBottom = -5;
- layout.marginBottom = -5;
- container.setLayout(layout);
-
- Label buttonExpand = new Label(container, SWT.NONE);
- Image imageExpand = Activator.getDefault().getImage(ICONS_EXPAND_ALL);
- buttonExpand.setImage(imageExpand);
- buttonExpand.addMouseListener(new MouseAdapter() {
- /**
- * {@iniriteDoc]
- *
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- @Override
- public void mouseUp(MouseEvent event) {
- elementsTreeViewer.expandAll();
- }
- });
-
- Label buttonCollapse = new Label(container, SWT.NONE);
- Image imageCollapse = Activator.getDefault().getImage(ICONS_COLLAPSE_ALL);
- buttonCollapse.setImage(imageCollapse);
- buttonCollapse.addMouseListener(new MouseAdapter() {
- /**
- * {@iniriteDoc]
- *
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- @Override
- public void mouseUp(MouseEvent event) {
- elementsTreeViewer.collapseAll();
- }
- });
- }
- }
-
- /**
- * Selected the initial value in treeViewer.
- */
- protected void selectInitialValue() {
- // //Select initialValue Stereotype
- if (!initialValue.isEmpty()) {
- ITreeContentProvider contentProvider = (ITreeContentProvider) elementsTreeViewer.getContentProvider();
- Object[] roots = contentProvider.getElements(null);
- // TODO select initial value
- // for (Object root : roots) {
- // Object[] profiles = contentProvider.getChildren(root);
- // for (Object profile : profiles) {
- // Object[] stereotypes = contentProvider.getChildren(profile);
- // for (Object stereotype : stereotypes) {
- // // if (stereotype instanceof Stereotype && initialValue.equals(((Stereotype) stereotype).getQualifiedName())) {
- // // elementsTreeViewer.expandToLevel(profile, 1);
- // // elementsTreeViewer.setSelection(new StructuredSelection(stereotype), true);
- // // break;
- // // }
- //
- // }
- // }
- // }
- }
- }
-
- /**
- * Create information text field.
- */
- protected void createInformationText(final Composite composite) {
- informationText = new StyledText(composite, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL);
- informationText.setLayoutData(new GridData(SWT.FILL, SWT.WRAP, true, false));
- informationText.setAlwaysShowScrollBars(false);
- }
-
- /**
- * Creates a filtered list.
- *
- * @param parent
- * the parent composite.
- * @return returns the filtered list widget.
- */
- protected TreeViewer createFilteredList(final Composite parent) {
-
- Tree tree = new Tree(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- final GridLayout filterLayout = new GridLayout();
- filterLayout.marginHeight = 0;
- filterLayout.marginWidth = 0;
- tree.setLayout(filterLayout);
- {
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- tree.setLayoutData(gridData);
- }
-
- TreeViewer treeViewer = new TreeViewer(tree);
- treeViewer.setContentProvider(new EncapsulatedContentProvider(contentProvider));
- treeViewer.setLabelProvider(labelProvider);
-
- treeViewer.setFilters(viewerFilter);
-
- treeViewer.setInput(null != input ? input : new Object());
-
- // Selection change listener to refresh button and information
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(final SelectionChangedEvent event) {
- refreshOkButton();
- refreshInformationText();
- }
- });
-
- // Double click listener to validate with double click
- treeViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- @Override
- public void doubleClick(final DoubleClickEvent event) {
- if (getOkButton().isEnabled()) {
- okPressed();
- }
- }
-
- });
-
- treeViewer.refresh();
- elementsTreeViewer = treeViewer;
-
- return treeViewer;
- }
-
- /**
- * Pattern viewer filter extension used to filter elements from stereotype tree viewer with the text field.
- * Extended to filter only applicable {@link Stereotype} from source {@link Element}.
- */
- private class PatternViewerFilterEx extends PatternViewerFilter {
- /**
- * Only set it visible if we can load the profile.
- *
- * @see org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter#isVisible(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public boolean isVisible(final Viewer viewer, final Object parentElement, final Object element) {
-
- boolean visible = super.isVisible(viewer, parentElement, element);
- visible &= ElementsExplorerDialog.this.isVisible(element);
- return visible;
- }
-
- /**
- * Override to pass method from protected to public.
- *
- * @see org.eclipse.papyrus.infra.widgets.providers.AbstractTreeFilter#clearCache()
- */
- public void clearCache() {
- super.clearCache();
- }
- }
-
- /**
- * Creates an area where a filter can be entered.
- *
- * @param parent
- * the parent composite where to create the filter text
- * @return the created text area
- */
- protected void createFilterText(final Composite parent) {
- // Create the filter composite
- final StringWithClearEditor filterText = new StringWithClearEditor(parent, SWT.BORDER);
-
- filterText.setValue("");//$NON-NLS-1$
-
- filterText.getText().addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(final ModifyEvent e) {
- String value = filterText.getValue();
- viewerFilter.setPattern(value);
- elementsTreeViewer.refresh();
- elementsTreeViewer.collapseAll();
- // If some text in filter expands to the stereotype level else to the profile level
- elementsTreeViewer.expandToLevel(value.isEmpty() ? 2 : 3);
- }
- });
-
- // Key listener to focus in the treviewer when presser arrow down key
- filterText.getText().addKeyListener(new KeyAdapter() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void keyPressed(final KeyEvent e) {
- if (e.keyCode == SWT.ARROW_DOWN) {
- elementsTreeViewer.getControl().setFocus();
- }
- }
- });
- }
-
- /**
- * Returns the currently selected element.
- * To be called within or after open().
- *
- * @return returns the currently selected element.
- */
- protected Object getSelectedElements() {
- Assert.isNotNull(elementsTreeViewer);
- return elementsTreeViewer.getStructuredSelection().getFirstElement();
- }
-
- /**
- * Refresh the Ok button according to the selection.
- */
- protected void refreshOkButton() {
- Object selectedElements = getSelectedElements();
-
- if (null != selectedElements && (null == returnClass || returnClass.isInstance(selectedElements))) {
- updateStatus(new Status(IStatus.OK, Activator.PLUGIN_ID, ""));//$NON-NLS-1$
- } else {
- updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ""));//$NON-NLS-1$
- }
- }
-
- /**
- * Refresh the Information text according to the selection. To be implemented by client.
- */
- protected void refreshInformationText() {
- // To be implemented by client.
- }
-
-
- /**
- * Return true if element have to be visible. It can be used to force element to be visible even if the filter dosen't not match with them.
- */
- protected boolean isVisible(final Object element) {
- return true;
- }
-
- /**
- * Set the content provider of the treeviewer.
- */
- public void setContentProvider(final IStructuredContentProvider contentProvider) {
- this.contentProvider = contentProvider;
- if (null != elementsTreeViewer) {
- elementsTreeViewer.setContentProvider(new EncapsulatedContentProvider(contentProvider));
- }
- }
-
- /**
- * Set the label provider of the treeviewer.
- */
- public void setLabelProvider(final IBaseLabelProvider labelProvider) {
- this.labelProvider = labelProvider;
- if (null != elementsTreeViewer) {
- elementsTreeViewer.setLabelProvider(labelProvider);
- }
- }
-
- /**
- * Set the input.
- */
- public void setInput(final Object input) {
- this.input = input;
- if (null != elementsTreeViewer) {
- elementsTreeViewer.setInput(input);
- }
- }
-
- /**
- * Sets the return type Class that will be return.
- */
- public void setReturnTypeClass(final Class<?> returnClass) {
- this.returnClass = returnClass;
- }
-
-}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
index e6bdf573aa8..2fc31bfe4d7 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
@@ -219,10 +219,6 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
*/
public TreeSelectorDialog(final Shell parentShell) {
super(parentShell);
- tabIds.add(defaultTabId);
- tabNames.put(defaultTabId, Messages.TreeSelectorDialog_defaultTabLabel);
- Image treeIcon = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, ICONS_TREE_VIEW);
- tabIcons.put(defaultTabId, treeIcon);
}
/**
@@ -231,26 +227,33 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
protected void initializeTabulationInfo() {
SelectorDialogTabReader instance = SelectorDialogTabReader.getInstance();
+ // Add default tab
+ tabIds.add(defaultTabId);
+ tabNames.put(defaultTabId, Messages.TreeSelectorDialog_defaultTabLabel);
+ Image treeIcon = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, ICONS_TREE_VIEW);
+ tabIcons.put(defaultTabId, treeIcon);
+
List<String> ids = instance.getIds();
for (String id : ids) {
+
+ ILabelProvider tabLabelProvider = instance.getLabelProviders().get(id);
+ labelProviders.put(id, tabLabelProvider);
+ if (tabLabelProvider instanceof IDependableLabelProvider) {
+ ((IDependableLabelProvider) tabLabelProvider).setLabelProvider(labelProviders.get(defaultTabId));
+ }
+
+ ITreeContentProvider tabContentProvider = instance.getContentProviders().get(id);
+ contentProviders.put(id, tabContentProvider);
+ if (tabContentProvider instanceof IDependableContentProvider) {
+ ((IDependableContentProvider) tabContentProvider).setContentProvider(contentProviders.get(defaultTabId));
+ }
+
Constraint constraint = instance.getConstraints().get(id);
if (!tabIds.contains(id) && (null == constraint || constraint.match(Collections.singleton(id)))) {
tabIds.addAll(ids);
tabNames.put(id, instance.getTabNames().get(id));
tabIcons.put(id, instance.getTabIcons().get(id));
descriptions.put(id, instance.getDescriptions().get(id));
-
- ILabelProvider tabLabelProvider = instance.getLabelProviders().get(id);
- labelProviders.put(id, tabLabelProvider);
- if (tabLabelProvider instanceof IDependableLabelProvider) {
- ((IDependableLabelProvider) tabLabelProvider).setLabelProvider(labelProviders.get(defaultTabId));
- }
-
- ITreeContentProvider tabContentProvider = instance.getContentProviders().get(id);
- contentProviders.put(id, tabContentProvider);
- if (tabContentProvider instanceof IDependableContentProvider) {
- ((IDependableContentProvider) tabContentProvider).setContentProvider(contentProviders.get(defaultTabId));
- }
}
}
@@ -457,13 +460,20 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
GridLayoutFactory.swtDefaults().applyTo(tabComposite);
}
+ // Message label(common for all tabs)
+ if (null != getMessage() && !getMessage().isEmpty()) {
+ Label messageLabel = new Label(tabComposite, SWT.WRAP);
+ messageLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ messageLabel.setText(getMessage());
+ }
// Description Label
- if (null != descriptions.get(tabId)) {
+ if (null != descriptions.get(tabId) && !descriptions.get(tabId).isEmpty()) {
Label descriptionLabel = new Label(tabComposite, SWT.WRAP);
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
descriptionLabel.setText(tabDescription);
}
+
// create tree viewer
ExtendedTreeViewer tabTreeViewer = new ExtendedTreeViewer(tabComposite, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).hint(300, 300).applyTo(tabTreeViewer.getTree());
@@ -656,10 +666,12 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
* The input.
*/
private void doSetInput(final String TabId) {
- if (null == input) {
- treeViewers.get(TabId).setInput("");//$NON-NLS-1$
- } else {
- treeViewers.get(TabId).setInput(input);
+ if (null != treeViewers.get(TabId)) {
+ if (null == input) {
+ treeViewers.get(TabId).setInput("");//$NON-NLS-1$
+ } else {
+ treeViewers.get(TabId).setInput(input);
+ }
}
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FilteredContentProvider.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FilteredContentProvider.java
index d86d51e8254..b67a5bb31f0 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FilteredContentProvider.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FilteredContentProvider.java
@@ -130,7 +130,9 @@ public class FilteredContentProvider extends EncapsulatedContentProvider {
@Override
public void createViewerToolbar(final Composite parent) {
// Create case sensitive checkbox
- createExpandCollapseButtons(parent);
+ if (!isFlat()) {
+ createExpandCollapseButtons(parent);
+ }
}
/**
@@ -138,7 +140,6 @@ public class FilteredContentProvider extends EncapsulatedContentProvider {
*/
protected void createExpandCollapseButtons(final Composite parent) {
-
ToolBar Toolbar = new ToolBar(parent, SWT.NONE);
buttonExpand = new ToolItem(Toolbar, SWT.NONE);
buttonExpand.setImage(Activator.getDefault().getImage(ICONS_EXPAND_ALL));
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FlatFilteredContentProvider.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FlatFilteredContentProvider.java
index 0b943186ac6..c41dbda329e 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FlatFilteredContentProvider.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/FlatFilteredContentProvider.java
@@ -182,7 +182,7 @@ public class FlatFilteredContentProvider
protected Object[] getAllChildren(final Object parentElement, final Set<Object> visitedElements) {
Set<Object> list = new HashSet<Object>();
Object[] children = provider.getChildren(parentElement);
- if (0 < children.length) {
+ if (null != children && 0 < children.length) {
for (int i = 0; i < children.length; i++) {
boolean visited = false;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.types.ui.properties/src/org/eclipse/papyrus/uml/types/ui/properties/widgets/FeatureToSetNameValueEditor.java b/plugins/uml/org.eclipse.papyrus.uml.types.ui.properties/src/org/eclipse/papyrus/uml/types/ui/properties/widgets/FeatureToSetNameValueEditor.java
index 3ec94bff7b8..b241e3993b5 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.types.ui.properties/src/org/eclipse/papyrus/uml/types/ui/properties/widgets/FeatureToSetNameValueEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.types.ui.properties/src/org/eclipse/papyrus/uml/types/ui/properties/widgets/FeatureToSetNameValueEditor.java
@@ -24,13 +24,13 @@ import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.infra.widgets.editors.ElementsExplorerDialog;
import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.infra.widgets.providers.FilteredContentProvider;
import org.eclipse.papyrus.uml.diagram.common.parser.PropertyLabelParser;
import org.eclipse.papyrus.uml.types.ui.properties.messages.Messages;
import org.eclipse.swt.SWT;
@@ -50,7 +50,7 @@ public class FeatureToSetNameValueEditor extends StringEditor {
/**
* Content provider for the feature viewer.
*/
- protected class StereotypeAttributesContentProvider implements IStructuredContentProvider {
+ protected class StereotypeAttributesContentProvider extends FilteredContentProvider {
/** current edited EClass */
protected EClass currentEClass;
@@ -72,6 +72,16 @@ public class FeatureToSetNameValueEditor extends StringEditor {
return attributes.toArray();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider#isFlat()
+ */
+ @Override
+ public boolean isFlat() {
+ return true;
+ }
+
}
public class StereotypeAttributesStyledLabelProvider extends DelegatingStyledCellLabelProvider implements ILabelProvider {
@@ -181,7 +191,7 @@ public class FeatureToSetNameValueEditor extends StringEditor {
* Handles action when user press the Manage bundle button in the combo area
*/
protected void handleManageBrowseButtonPressed() {
- ElementsExplorerDialog dialog = new ElementsExplorerDialog(getParent().getShell());
+ TreeSelectorDialog dialog = new TreeSelectorDialog(getParent().getShell());
dialog.setContentProvider(new StereotypeAttributesContentProvider());
dialog.setLabelProvider(new StereotypeAttributesStyledLabelProvider());
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeExplorerDialog.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeExplorerDialog.java
index ed47d6d07a8..4236da8c368 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeExplorerDialog.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeExplorerDialog.java
@@ -29,10 +29,15 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -41,7 +46,6 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.papyrus.infra.widgets.editors.StringWithClearEditor;
import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
@@ -58,8 +62,6 @@ import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@@ -70,6 +72,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
import org.eclipse.uml2.uml.Comment;
@@ -352,8 +356,21 @@ public class StereotypeExplorerDialog extends SelectionStatusDialog {
// creates the message area, as defined in the super class
createMessageArea(composite);
- createFilterText(composite);
- createExpandCollapseButtons(composite);
+
+ // Top composite containing filter and collapse/expand buttons
+ Composite topComposite = new Composite(composite, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(topComposite);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(topComposite);
+
+ // Create filter
+ createFilterText(topComposite);
+
+ // create separator
+ Label separator = new Label(topComposite, SWT.VERTICAL | SWT.SEPARATOR);
+ GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 10).grab(false, false).applyTo(separator);
+
+ // Create Expand button
+ createExpandCollapseButtons(topComposite);
createStereotypeFilteredList(composite);
createInformationText(composite);
createFilterOnSourceElementButton(composite);
@@ -367,40 +384,54 @@ public class StereotypeExplorerDialog extends SelectionStatusDialog {
* Create buttons to collapse and expand treeViewer.
*/
protected void createExpandCollapseButtons(final Composite composite) {
- Composite container = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout(2, true);
- layout.horizontalSpacing = 2;
- layout.marginBottom = -5;
- layout.marginBottom = -5;
- container.setLayout(layout);
-
- Label buttonExpand = new Label(container, SWT.NONE);
+
+ ToolBar container = new ToolBar(composite, SWT.NONE);
+
+ ToolItem buttonExpand = new ToolItem(container, SWT.NONE);
Image imageExpand = Activator.getPluginIconImage(org.eclipse.papyrus.infra.widgets.Activator.PLUGIN_ID, ICONS_EXPAND_ALL);
buttonExpand.setImage(imageExpand);
- buttonExpand.addMouseListener(new MouseAdapter() {
+ buttonExpand.addSelectionListener(new SelectionAdapter() {
/**
- * {@iniriteDoc]
- *
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+ * {@inheritDoc}
*/
@Override
- public void mouseUp(MouseEvent event) {
- stereotypeTreeViewer.expandAll();
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = stereotypeTreeViewer.getSelection();
+ // If there are selected element
+ if (selection instanceof StructuredSelection && !selection.isEmpty()) {
+ // For each element
+ for (Object object : ((StructuredSelection) selection).toArray()) {
+ ((AbstractTreeViewer) stereotypeTreeViewer).expandToLevel(object, org.eclipse.papyrus.infra.widgets.Activator.getMaxLevelToExpandValue());
+ }
+ } else {
+ // or expand all
+ ((AbstractTreeViewer) stereotypeTreeViewer).expandToLevel(org.eclipse.papyrus.infra.widgets.Activator.getMaxLevelToExpandValue());
+ }
+ stereotypeTreeViewer.refresh();
}
});
- Label buttonCollapse = new Label(container, SWT.NONE);
+ ToolItem buttonCollapse = new ToolItem(container, SWT.NONE);
Image imageCollapse = Activator.getPluginIconImage(org.eclipse.papyrus.infra.widgets.Activator.PLUGIN_ID, ICONS_COLLAPSE_ALL);
buttonCollapse.setImage(imageCollapse);
- buttonCollapse.addMouseListener(new MouseAdapter() {
+ buttonCollapse.addSelectionListener(new SelectionAdapter() {
/**
- * {@iniriteDoc]
- *
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+ * {@inheritDoc}
*/
@Override
- public void mouseUp(MouseEvent event) {
- stereotypeTreeViewer.collapseAll();
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = ((AbstractTreeViewer) stereotypeTreeViewer).getSelection();
+ // If there are selected element
+ if (selection instanceof StructuredSelection && !selection.isEmpty()) {
+ // expand each selected element
+ for (Object object : ((StructuredSelection) selection).toArray()) {
+ ((AbstractTreeViewer) stereotypeTreeViewer).collapseToLevel(object, AbstractTreeViewer.ALL_LEVELS);
+ }
+
+ } else {
+ // or collapse all
+ ((AbstractTreeViewer) stereotypeTreeViewer).collapseAll();
+ }
}
});
}
@@ -553,7 +584,7 @@ public class StereotypeExplorerDialog extends SelectionStatusDialog {
protected void createFilterText(final Composite parent) {
// Create the filter composite
final StringWithClearEditor filterText = new StringWithClearEditor(parent, SWT.BORDER);
-
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(filterText);
filterText.setValue("");//$NON-NLS-1$
filterText.getText().addModifyListener(new ModifyListener() {
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
index 02791e1f1ba..827731a7a6a 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
@@ -118,6 +118,7 @@
contentProvider="org.eclipse.papyrus.infra.widgets.providers.FlatFilteredContentProvider"
id="org.eclipse.papyrus.uml.tools.tabflat"
labelProvider="org.eclipse.papyrus.uml.tools.providers.FlatTabUMLLabelProvider"
+ tabConstraint="org.eclipse.papyrus.uml.tools.providers.FlatTabConstaint"
tabIcon="icons/flatView.gif"
tabLabel="Flat">
</tabDeclaration>
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabConstaint.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabConstaint.java
new file mode 100644
index 00000000000..9d6befa11d8
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabConstaint.java
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST, ALL4TEC 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.providers;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
+import org.eclipse.papyrus.infra.constraints.DisplayUnit;
+import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
+import org.eclipse.papyrus.infra.widgets.SelectorDialogTabReader;
+import org.eclipse.papyrus.infra.widgets.providers.IDependableContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IFlattenableContentProvider;
+
+/**
+ * Contraint for flat tabulation of selector tab. Match if the dependable content provider of {@link FlatTabUMLLabelProvider} is not flat.
+ *
+ * @since 3.0
+ */
+public class FlatTabConstaint implements Constraint {
+
+ /**
+ * Constructor.
+ */
+ public FlatTabConstaint() {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.Constraint#setConstraintDescriptor(org.eclipse.papyrus.infra.constraints.ConstraintDescriptor)
+ */
+ @Override
+ public void setConstraintDescriptor(final ConstraintDescriptor descriptor) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.Constraint#match(java.util.Collection)
+ */
+ @Override
+ public boolean match(Collection<?> selection) {
+ boolean match = false;
+ if (!selection.isEmpty() && selection instanceof Set) {
+ // Get the id of the tab
+ Object id = ((Set) selection).toArray()[0];
+ if (id instanceof String) {
+ ITreeContentProvider iContentProvider = SelectorDialogTabReader.getInstance().getContentProviders().get(id);
+ if (iContentProvider instanceof IDependableContentProvider) {
+ ITreeContentProvider contentProvider = ((IDependableContentProvider) iContentProvider).getContentProvider();
+ if (contentProvider instanceof IFlattenableContentProvider) {
+ IFlattenableContentProvider flattenableContentProvider = (IFlattenableContentProvider) contentProvider;
+ match = !flattenableContentProvider.isFlat();
+ }
+ }
+ }
+ }
+ return match;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.Constraint#getDisplayUnit()
+ */
+ @Override
+ public DisplayUnit getDisplayUnit() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.Constraint#overrides(org.eclipse.papyrus.infra.constraints.constraints.Constraint)
+ */
+ @Override
+ public boolean overrides(final Constraint constraint) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.Constraint#getDescriptor()
+ */
+ @Override
+ public ConstraintDescriptor getDescriptor() {
+ return null;
+ }
+
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabUMLLabelProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabUMLLabelProvider.java
index dfa5ef5160a..e9f51a8c6db 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabUMLLabelProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/FlatTabUMLLabelProvider.java
@@ -166,7 +166,10 @@ public class FlatTabUMLLabelProvider implements IGraphicalLabelProvider, IStyled
*/
protected void setDisplayQualifiedNameButton(final boolean visible) {
if (null != Toolbar && !Toolbar.isDisposed() && visible != Toolbar.getVisible()) {
- Toolbar.setVisible(visible);
+ Composite parent = Toolbar.getParent();
+ Toolbar.dispose();
+ parent.pack();
+
}
}

Back to the top