Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2012-02-23 12:06:20 -0500
committerrschnekenbu2012-02-23 12:06:20 -0500
commit807feb6a6b06b26b7066f7c961559e68b4fc22c7 (patch)
treeaebfe009235235933a830e075311dbf9ea81c3c5 /plugins
parent8f4f042aa82aa93b09cb76464378ce1400fa8113 (diff)
downloadorg.eclipse.papyrus-807feb6a6b06b26b7066f7c961559e68b4fc22c7.tar.gz
org.eclipse.papyrus-807feb6a6b06b26b7066f7c961559e68b4fc22c7.tar.xz
org.eclipse.papyrus-807feb6a6b06b26b7066f7c961559e68b4fc22c7.zip
ASSIGNED - Bug 351093: [All digrams] ShowHide dialog should allow to propagate values
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351093 => porting bugfix from branch 0.8.X, r7268
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideCompartmentAction.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java120
3 files changed, 63 insertions, 61 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
index a05a7a9850c..ab6e986727b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
@@ -387,7 +387,7 @@ public abstract class AbstractShowHideAction implements IActionDelegate, IWorkbe
* This class provides some facilities to build the action.
*
*/
- protected class EditPartRepresentation {
+ public class EditPartRepresentation {
/** the editpart represented by this class */
private IGraphicalEditPart representedEditPart;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideCompartmentAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideCompartmentAction.java
index f25cb9bb202..4f7ff0c809e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideCompartmentAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideCompartmentAction.java
@@ -78,7 +78,7 @@ public class ShowHideCompartmentAction extends AbstractShowHideAction {
/**
* Edit part representation used as a main element in the tree
*/
- protected class RootEditPartRepresentation extends EditPartRepresentation {
+ public class RootEditPartRepresentation extends EditPartRepresentation {
/**
* Constructor.
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
index 0cadd914f9c..4c51bb68896 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/dialogs/ShowHideCompartmentSelectionDialog.java
@@ -16,8 +16,10 @@ package org.eclipse.papyrus.uml.diagram.menu.dialogs;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CellLabelProvider;
@@ -26,11 +28,16 @@ import org.eclipse.jface.viewers.ColumnLabelProvider;
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.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.actions.AbstractShowHideAction.EditPartRepresentation;
import org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog;
import org.eclipse.papyrus.uml.diagram.menu.actions.ShowHideCompartmentAction.CompartmentEditPartRepresentation;
+import org.eclipse.papyrus.uml.diagram.menu.actions.ShowHideCompartmentAction.RootEditPartRepresentation;
import org.eclipse.papyrus.uml.diagram.menu.messages.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -318,67 +325,62 @@ public class ShowHideCompartmentSelectionDialog extends AbstractCheckedTreeColum
* Listener for propagation button
*/
public class PropagateSelectionAdapter extends SelectionAdapter {
+
+ /**
+ * {@inheritDoc}
+ */
@Override
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();
- // }
- // }
+ ISelection sel = getTreeViewer().getSelection();
+ if(sel instanceof ITreeSelection) {
+ TreePath paths[] = ((ITreeSelection)sel).getPaths();
+ RootEditPartRepresentation selectedRootEPRep;
+ if(paths.length != 1) {
+ return;
+ }
+ Object objSelectedEP = paths[0].getFirstSegment();
+ if(objSelectedEP instanceof RootEditPartRepresentation) {
+ selectedRootEPRep = (RootEditPartRepresentation)objSelectedEP;
+ } else {
+ return;
+ }
+ EClass eClass = selectedRootEPRep.getSemanticElement().eClass();
+
+ boolean changedTitle = false;
+ Object[] viewerElements = fContentProvider.getElements(fInput);
+ for(Object viewerElement : viewerElements) {
+ // not the element of that is currently selected
+ if(viewerElement != selectedRootEPRep) {
+ if(viewerElement instanceof RootEditPartRepresentation) {
+ RootEditPartRepresentation otherRootEPRep = (RootEditPartRepresentation)viewerElement;
+ // verify identical eClass of underlying elements before copying selection
+ if(otherRootEPRep.getSemanticElement().eClass() == eClass) {
+ Iterator<EditPartRepresentation> selectedCompartmentIter = selectedRootEPRep.getPossibleElement().iterator();
+ for(EditPartRepresentation subElement : otherRootEPRep.getPossibleElement()) {
+ if(subElement instanceof CompartmentEditPartRepresentation) {
+ Object selectedCompartment = selectedCompartmentIter.next();
+ if(selectedCompartment instanceof CompartmentEditPartRepresentation) {
+ CompartmentEditPartRepresentation selectedCEPR = (CompartmentEditPartRepresentation)selectedCompartment;
+ CompartmentEditPartRepresentation otherCEPR = (CompartmentEditPartRepresentation)subElement;
+ if(otherCEPR.isTitleVisible() != selectedCEPR.isTitleVisible()) {
+ otherCEPR.setTitleVisible(selectedCEPR.isTitleVisible());
+ changedTitle = true;
+ }
+ boolean isChecked = getTreeViewer().getChecked(selectedCEPR);
+ getTreeViewer().setChecked(otherCEPR, isChecked);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ updateOKStatus();
+ if(changedTitle) {
+ getTreeViewer().refresh();
+ }
+ }
}
}
}
-

Back to the top