Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/.classpath16
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/META-INF/MANIFEST.MF2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java70
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java60
5 files changed, 108 insertions, 46 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/.classpath b/plugins/views/properties/org.eclipse.papyrus.views.properties/.classpath
index e12efdd53ae..50aae142c50 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/.classpath
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/.classpath
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src-gen"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/.settings/org.eclipse.jdt.core.prefs b/plugins/views/properties/org.eclipse.papyrus.views.properties/.settings/org.eclipse.jdt.core.prefs
index 4759947300a..62a08f4494d 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/META-INF/MANIFEST.MF b/plugins/views/properties/org.eclipse.papyrus.views.properties/META-INF/MANIFEST.MF
index f324b7513b0..3f18db67532 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/META-INF/MANIFEST.MF
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/META-INF/MANIFEST.MF
@@ -20,7 +20,7 @@ Bundle-ClassPath: .,
bin
Bundle-Name: %pluginName
Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.emf;bundle-version="2.6.0",
org.eclipse.emf.ecore;bundle-version="2.6.0";visibility:=reexport,
org.eclipse.emf.ecore.xmi;bundle-version="2.5.0",
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
index 990a7a1cffb..df45283b98f 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2015 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 482930
*****************************************************************************/
package org.eclipse.papyrus.views.properties.preferences;
@@ -16,6 +17,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -44,8 +48,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
*/
public class Preferences extends PreferencePage implements IWorkbenchPreferencePage {
- private boolean changeOccured = false;
-
+ @Override
public void init(IWorkbench workbench) {
// Nothing
}
@@ -61,8 +64,6 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
final ConfigurationManager configurationManager = ConfigurationManager.getInstance();
- contextState.init();
-
// Only customizable Property view contexts should appear here
List<Context> contexts = new java.util.ArrayList<Context>(configurationManager.getCustomizableContexts());
contexts.addAll(configurationManager.getMissingContexts());
@@ -77,10 +78,12 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
checkbox.addSelectionListener(new SelectionListener() {
+ @Override
public void widgetSelected(SelectionEvent e) {
contextState.setContextState(theContext, ((Button) e.widget).getSelection());
}
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing
}
@@ -90,7 +93,7 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
checkboxes.put(context, checkbox);
}
- changeOccured = false;
+ contextState.snapshot();
return null;
}
@@ -111,9 +114,8 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
Button checkbox = checkboxes.get(context);
if (checkbox != null) {
checkbox.setSelection(applied);
+ contextState.setContextState(context, applied);
}
-
- contextState.setContextState(context, applied);
}
}
@@ -137,16 +139,20 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
private class ContextState {
- public ContextState() {
+ private Map<Context, Boolean> contexts = new HashMap<>();
+
+ private Map<Context, Boolean> snapshot;
+
+ ContextState() {
+ super();
}
- public void init() {
- contexts.clear();
+ void snapshot() {
+ snapshot = new HashMap<>(contexts);
}
public void setContextState(Context context, boolean applied) {
contexts.put(context, applied);
- changeOccured = true;
}
public boolean saveContext() {
@@ -160,27 +166,39 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
ConfigurationManager.getInstance().update();
- Collection<ConfigurationConflict> conflicts = ConfigurationManager.getInstance().checkConflicts();
-
- if (changeOccured && !conflicts.isEmpty()) {
- String errorMessage = Messages.Preferences_ConflictWarning1;
- for (ConfigurationConflict conflict : conflicts) {
- errorMessage += conflict.toString() + "\n"; //$NON-NLS-1$
+ Set<Context> delta = getChangedContexts();
+ if (!delta.isEmpty()) {
+ Collection<ConfigurationConflict> conflicts = ConfigurationManager.getInstance().checkConflicts(delta);
+
+ if (!conflicts.isEmpty()) {
+ String errorMessage = Messages.Preferences_ConflictWarning1;
+ for (ConfigurationConflict conflict : conflicts) {
+ errorMessage += conflict.toString() + "\n"; //$NON-NLS-1$
+ }
+ errorMessage += Messages.Preferences_ConflictWarning2;
+
+ MessageDialog dialog = new MessageDialog(getShell(), Messages.Preferences_ConflictWarningTitle, null, errorMessage, MessageDialog.WARNING,
+ new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
+ 1);
+ int result = dialog.open();
+ if (result != 0) {
+ return false;
+ }
}
- errorMessage += Messages.Preferences_ConflictWarning2;
- MessageDialog dialog = new MessageDialog(getShell(), Messages.Preferences_ConflictWarningTitle, null, errorMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 1);
- int result = dialog.open();
- if (result != 0) {
- return false;
- }
+ snapshot();
}
- changeOccured = false;
return true;
}
- private Map<Context, Boolean> contexts = new HashMap<Context, Boolean>();
+ Set<Context> getChangedContexts() {
+ return (snapshot == null)
+ ? contexts.keySet()
+ : snapshot.keySet().stream()
+ .filter(c -> !Objects.equals(snapshot.get(c), contexts.get(c)))
+ .collect(Collectors.toSet());
+ }
}
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
index 29283c9ba88..6f3da4ec9ea 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2013 CEA LIST.
+ * Copyright (c) 2010, 2015 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +10,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - Factor out workspace storage for pluggable storage providers (CDO)
* Christian W. Damus (CEA) - Support implicit enablement of prototypes of unavailable contexts (CDO)
+ * Christian W. Damus - bug 482930
*****************************************************************************/
package org.eclipse.papyrus.views.properties.runtime;
@@ -211,6 +212,7 @@ public class ConfigurationManager {
if (contextStorageProviderListener == null) {
contextStorageProviderListener = new IContextStorageProviderListener() {
+ @Override
public void contextsAdded(Collection<? extends Context> contexts) {
List<Context> appliedContexts = new java.util.ArrayList<Context>(contexts.size());
@@ -229,6 +231,7 @@ public class ConfigurationManager {
}
}
+ @Override
public void contextsChanged(Collection<? extends Context> contexts) {
List<Context> appliedContexts = new java.util.ArrayList<Context>(contexts.size());
@@ -247,6 +250,7 @@ public class ConfigurationManager {
}
}
+ @Override
public void contextsRemoved(Collection<? extends Context> contexts) {
List<Context> appliedContexts = new java.util.ArrayList<Context>(contexts.size());
@@ -304,6 +308,7 @@ public class ConfigurationManager {
Display.getDefault().asyncExec(new Runnable() {
+ @Override
public void run() {
NotificationBuilder.createAsyncPopup(message).setType(org.eclipse.papyrus.infra.widgets.toolbox.notification.Type.INFO).setDelay(5000L).run();
}
@@ -694,6 +699,19 @@ public class ConfigurationManager {
}
/**
+ * Queries whether a given context is {@linkplain #getEnabledContexts() enabled}.
+ *
+ * @param context
+ * a context
+ * @return whether it is currently enabled
+ *
+ * @see #getEnabledContexts()
+ */
+ public boolean isEnabled(Context context) {
+ return enabledContexts.contains(context);
+ }
+
+ /**
* Tests if a Context is a plugin context. plugin contexts
* are registered through {@link ContextExtensionPoint} and are
* read-only.
@@ -1073,7 +1091,7 @@ public class ConfigurationManager {
}
/**
- * Checks the conflicts between all applied configurations
+ * Checks the conflicts between all applied {@linkplain #getEnabledContexts() enabled}) configurations
* A Conflict may occur when two sections have the same ID : they can't
* be displayed at the same time
*
@@ -1081,6 +1099,24 @@ public class ConfigurationManager {
* The list of conflicts
*/
public Collection<ConfigurationConflict> checkConflicts() {
+ return checkConflicts(getEnabledContexts());
+ }
+
+ /**
+ * Checks the conflicts between those of the specified configurations that are enabled.
+ * A Conflict may occur when two sections have the same ID : they can't
+ * be displayed at the same time.
+ *
+ * @param contexts
+ * a set of configurations to check for conflicts (amongst the subset of these
+ * that are actually {@linkplain #isEnabled(Context) enabled}
+ *
+ * @return
+ * The list of conflicts
+ *
+ * @see #isEnabled(Context)
+ */
+ public Collection<ConfigurationConflict> checkConflicts(Collection<? extends Context> contexts) {
Map<String, List<Context>> sections = new HashMap<String, List<Context>>();
Map<String, ConfigurationConflict> conflicts = new HashMap<String, ConfigurationConflict>();
@@ -1088,27 +1124,35 @@ public class ConfigurationManager {
for (Tab tab : context.getTabs()) {
for (Section section : tab.getSections()) {
String sectionID = section.getName();
- List<Context> contexts = sections.get(sectionID);
- if (contexts == null) {
- contexts = new LinkedList<Context>();
- sections.put(sectionID, contexts);
+ List<Context> sectionContexts = sections.get(sectionID);
+ if (sectionContexts == null) {
+ sectionContexts = new LinkedList<Context>();
+ sections.put(sectionID, sectionContexts);
} else {
ConfigurationConflict conflict = conflicts.get(sectionID);
if (conflict == null) {
conflict = new ConfigurationConflict(sectionID);
conflicts.put(sectionID, conflict);
- conflict.addContext(contexts.get(0));
+ conflict.addContext(sectionContexts.get(0));
}
conflict.addContext(context);
}
- contexts.add(context);
+ sectionContexts.add(context);
}
}
}
+ // Report only conflicts involving the originally requested contexts
+ for (Iterator<ConfigurationConflict> iter = conflicts.values().iterator(); iter.hasNext();) {
+ ConfigurationConflict next = iter.next();
+ if (next.conflictingContexts.stream().noneMatch(ctx -> contexts.contains(ctx))) {
+ iter.remove();
+ }
+ }
+
return conflicts.values();
}

Back to the top