Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraradermache2011-07-04 15:10:07 +0000
committeraradermache2011-07-04 15:10:07 +0000
commit63914816639c51903329f1e56dac2fa122bbde33 (patch)
treea2ca109cdc10a9edcb972a15b33afcf48308d3c7
parentec73de6fb1d2b6c1fac49e8680a610dd8bb19699 (diff)
downloadorg.eclipse.papyrus-63914816639c51903329f1e56dac2fa122bbde33.tar.gz
org.eclipse.papyrus-63914816639c51903329f1e56dac2fa122bbde33.tar.xz
org.eclipse.papyrus-63914816639c51903329f1e56dac2fa122bbde33.zip
Fix for bug 351093: Propagation button in Show/Hide compartment dialog
Implied modification: made properties fContentProvider and fInput of CustomCheckedTreeSelectionDialog protected instead of private, since button listener needs access to these two. (good for customization, which is the objective behind the class CustomCheckedTreeSelectionDialog)
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/dialogs/CustomCheckedTreeSelectionDialog.java4
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java102
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/Messages.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/messages.properties5
4 files changed, 108 insertions, 6 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/dialogs/CustomCheckedTreeSelectionDialog.java b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/dialogs/CustomCheckedTreeSelectionDialog.java
index fbb7a53cdcd..89f20d49e4b 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/dialogs/CustomCheckedTreeSelectionDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/dialogs/CustomCheckedTreeSelectionDialog.java
@@ -65,7 +65,7 @@ public class CustomCheckedTreeSelectionDialog extends SelectionStatusDialog {
private ILabelProvider fLabelProvider;
- private ITreeContentProvider fContentProvider;
+ protected ITreeContentProvider fContentProvider;
private ISelectionStatusValidator fValidator = null;
@@ -77,7 +77,7 @@ public class CustomCheckedTreeSelectionDialog extends SelectionStatusDialog {
private List fFilters;
- private Object fInput;
+ protected Object fInput;
private boolean fIsEmpty;
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
index c0a9df2c4b9..3dab56a9a91 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
@@ -9,33 +9,45 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Added propagation button
*
*****************************************************************************/
package org.eclipse.papyrus.diagram.menu.dialogs;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPartService;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.CheckboxCellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.papyrus.diagram.common.Activator;
import org.eclipse.papyrus.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog;
import org.eclipse.papyrus.diagram.common.providers.EditorLabelProvider;
import org.eclipse.papyrus.diagram.common.util.CompartmentTitleRepresentation;
import org.eclipse.papyrus.diagram.common.util.CompartmentUtils;
+import org.eclipse.papyrus.diagram.menu.messages.Messages;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
/**
@@ -108,6 +120,26 @@ public class ShowHideCompartmentSelectionDialog extends AbstractCheckedTreeColum
}
/**
+ * Adds the propagation button (in addition to the buttons added by the super class) to the dialog.
+ * @see org.eclipse.papyrus.diagram.common.dialogs.CustomCheckedTreeSelectionDialog.createSelectionButtons
+ * @param composite
+ * the parent composite
+ * @return Composite the composite the buttons were created in.
+ */
+ @Override
+ protected Composite createSelectionButtons(Composite composite) {
+ Composite buttonComposite = super.createSelectionButtons(composite);
+
+ Button propagateToSameType = createButton(buttonComposite,
+ IDialogConstants.SELECT_TYPES_ID, Messages.ShowHideCompartmentAction_PropagateToSameType,
+ false);
+ SelectionListener listener = new PropagateSelectionAdapter();
+ propagateToSameType.addSelectionListener(listener);
+
+ return buttonComposite;
+ }
+
+ /**
*
* @see org.eclipse.ui.dialogs.SelectionDialog#setInitialElementSelections(java.util.List)
*
@@ -242,8 +274,6 @@ public class ShowHideCompartmentSelectionDialog extends AbstractCheckedTreeColum
/**
* This provider is used by the 2nd column
*
- *
- *
*/
class CompartmentNameProvider extends CellLabelProvider implements ILabelProvider {
@@ -342,4 +372,72 @@ public class ShowHideCompartmentSelectionDialog extends AbstractCheckedTreeColum
return null;
}
}
+
+ /**
+ * Listener for propagation button
+ */
+ public class PropagateSelectionAdapter extends SelectionAdapter {
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = getTreeViewer().getSelection();
+ if (sel instanceof ITreeSelection) {
+ TreePath paths[] = ((ITreeSelection) sel).getPaths();
+ EditPart selectedEP;
+ // Obtain EditPart at top of selection
+ if (paths.length != 1) {
+ return;
+ }
+ Object objSelectedEP = paths[0].getFirstSegment();
+ if (objSelectedEP instanceof EditPart) {
+ selectedEP = (EditPart) objSelectedEP;
+ }
+ else {
+ return;
+ }
+ Class<? extends EditPart> clazz = ((EditPart) selectedEP).getClass();
+
+ List<View> sourceViews = CompartmentUtils.getAllCompartments(selectedEP, false);
+
+ boolean changedTitle = false;
+ Object[] viewerElements = fContentProvider.getElements(fInput);
+ for (Object viewerElement : viewerElements) {
+ // Identity guarantees that viewerElement is an instance of EditPart
+ if((viewerElement.getClass() == clazz) && (viewerElement != selectedEP)) {
+ // copy selection
+ Iterator<View> targetViews = CompartmentUtils.getAllCompartments((EditPart) viewerElement, false).iterator();
+ for (View sourceView : sourceViews) {
+ if (targetViews.hasNext()) {
+ View targetView = targetViews.next();
+ boolean isChecked = getTreeViewer().getChecked(sourceView);
+ getTreeViewer().setChecked(targetView, isChecked);
+
+ // propagate title representation
+ CompartmentTitleRepresentation sourceRepresentation = CompartmentUtils.getCompartmentTitleRepresentation(titleRepresentations, sourceView);
+ CompartmentTitleRepresentation targetRepresentation = CompartmentUtils.getCompartmentTitleRepresentation(titleRepresentations, targetView);
+ if((sourceRepresentation != null) && (targetRepresentation != null)) {
+ if(selectedTitles.contains(sourceRepresentation)) {
+ if (!selectedTitles.contains(targetRepresentation)) {
+ selectedTitles.add(targetRepresentation);
+ changedTitle = true;
+ }
+ }
+ else {
+ if (selectedTitles.contains(targetRepresentation)) {
+ selectedTitles.remove(targetRepresentation);
+ changedTitle = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ updateOKStatus();
+ if (changedTitle) {
+ getTreeViewer().refresh();
+ }
+ }
+ }
+ }
}
+
+
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/Messages.java b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/Messages.java
index 5166d9afb00..53f776e5fe7 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/Messages.java
+++ b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/Messages.java
@@ -26,6 +26,8 @@ public class Messages extends NLS
public static String ShowHideCompartmentAction_Title;
+ public static String ShowHideCompartmentAction_PropagateToSameType;
+
public static String ShowHideConnectionLabelsAction_LabelsManager;
public static String ShowHideConnectionLabelsAction_SelectTheLabelToDisplay;
@@ -36,6 +38,7 @@ public class Messages extends NLS
public static String SelectTypeAction_SelectionActionTooltype;
+
static
{
// initialize resource bundle
diff --git a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/messages.properties b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/messages.properties
index d00ba8ad606..b9030530b5e 100644
--- a/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/messages.properties
+++ b/plugins/uml/org.eclipse.papyrus.diagram.menu/src/org/eclipse/papyrus/diagram/menu/messages/messages.properties
@@ -1,9 +1,10 @@
ShowHideCompartmentAction_Messages=Choose the compartments to show.
ShowHideCompartmentAction_No_Name=No name
ShowHideCompartmentAction_Title=Show/Hide compartments
-ShowHideConnectionLabelsAction_LabelsManager=Labels Manager
+ShowHideCompartmentAction_PropagateToSameType=&Propagate selection to elements of same type
+ShowHideConnectionLabelsAction_LabelsManager=Label Manager
ShowHideConnectionLabelsAction_SelectTheLabelToDisplay=Select the labels to display.
ZoomToolbar_Zoom=Zoom
SelectTypeAction_SelectActionName=Select elements with same type
-SelectTypeAction_SelectionActionTooltype=select elements with the same type of selected element in the diagram
+SelectTypeAction_SelectionActionTooltype=Select elements with the same type of selected element in the diagram
\ No newline at end of file

Back to the top