Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-09-18 08:53:13 +0000
committercletavernie2012-09-18 08:53:13 +0000
commitb6f4896a0ed6cd4c7f57185eba38a053fdd943ae (patch)
tree12000c360827d38b606e4ee4262a912218eb377e
parente51185f5aa16f9cb623654ed00f95efdaee9607d (diff)
downloadorg.eclipse.papyrus-b6f4896a0ed6cd4c7f57185eba38a053fdd943ae.tar.gz
org.eclipse.papyrus-b6f4896a0ed6cd4c7f57185eba38a053fdd943ae.tar.xz
org.eclipse.papyrus-b6f4896a0ed6cd4c7f57185eba38a053fdd943ae.zip
388741: [Profile - Properties] It should be easier to reapply a profile
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388741 Backport from 0.9.X
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/icons/refresh.gifbin0 -> 330 bytes
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java55
2 files changed, 54 insertions, 1 deletions
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/icons/refresh.gif b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/icons/refresh.gif
new file mode 100644
index 00000000000..e3831471a65
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/icons/refresh.gif
Binary files differ
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
index a4d81f0bc7f..13aaaf2bb55 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
@@ -12,6 +12,7 @@
package org.eclipse.papyrus.uml.properties.widgets;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -20,7 +21,11 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog;
import org.eclipse.papyrus.uml.properties.Activator;
@@ -28,6 +33,7 @@ import org.eclipse.papyrus.uml.properties.messages.Messages;
import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.FileSelectionFilter;
import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.Message;
import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.RegisteredProfileSelectionDialog;
+import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -50,6 +56,11 @@ public class ProfileApplicationEditor extends MultipleReferenceEditor {
protected Button addRegisteredProfile;
/**
+ * The button to reapply a profile
+ */
+ protected Button reapplyProfile;
+
+ /**
* The umlPackage being edited
*/
protected Package umlPackage;
@@ -75,6 +86,14 @@ public class ProfileApplicationEditor extends MultipleReferenceEditor {
add.setToolTipText(Messages.ProfileApplicationEditor_ApplyProfile);
addRegisteredProfile = createButton(Activator.getDefault().getImage("/icons/AddReg.gif"), Messages.ProfileApplicationEditor_ApplyRegisteredProfile); //$NON-NLS-1$
+
+ reapplyProfile = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/refresh.gif"), "Reapply profile");
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateControls();
+ }
+ });
}
/**
@@ -133,7 +152,7 @@ public class ProfileApplicationEditor extends MultipleReferenceEditor {
}
if(importedModels.size() > 0) {
- ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), importedModels,true);
+ ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), importedModels, true);
profileDialog.open();
ArrayList<Profile> profilesToApply = profileDialog.getResult();
@@ -161,12 +180,30 @@ public class ProfileApplicationEditor extends MultipleReferenceEditor {
commit();
}
+ protected void reapplyProfileAction() {
+ ISelection selectedElements = treeViewer.getSelection();
+ if(!selectedElements.isEmpty() && selectedElements instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection)selectedElements;
+ Iterator<?> iterator = selection.iterator();
+ while(iterator.hasNext()) {
+ Object element = iterator.next();
+ if(element instanceof Profile) {
+ modelProperty.add(element);
+ }
+ }
+ }
+ commit();
+ }
+
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
if(e.widget == addRegisteredProfile) {
addRegisteredAction();
}
+ if(e.widget == reapplyProfile) {
+ reapplyProfileAction();
+ }
}
/**
@@ -185,5 +222,21 @@ public class ProfileApplicationEditor extends MultipleReferenceEditor {
add.setEnabled(enabled);
addRegisteredProfile.setEnabled(enabled);
remove.setEnabled(enabled);
+
+ // check whether the selection can be reapplied
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ enabled = false;
+ Iterator<?> iterator = selection.iterator();
+ while(iterator.hasNext()) {
+ Object element = iterator.next();
+ if(element instanceof Profile) {
+ if(ProfileUtil.isDirty(umlPackage, (Profile)element)) {
+ enabled = true; //At least one dirty profile is selected
+ break;
+ }
+ }
+ }
+
+ reapplyProfile.setEnabled(enabled);
}
}

Back to the top