Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoromlois2012-10-25 14:09:45 +0000
committeromlois2012-10-25 14:09:45 +0000
commit6b4ff21deeb133ee958e246d36bc88e1763201ee (patch)
tree5cf73d2dd556ac7b859c9de19184279eeb58dac0
parentd7c17447ec3dc8f50d1a407433c712db103b2a43 (diff)
downloadorg.eclipse.papyrus-6b4ff21deeb133ee958e246d36bc88e1763201ee.tar.gz
org.eclipse.papyrus-6b4ff21deeb133ee958e246d36bc88e1763201ee.tar.xz
org.eclipse.papyrus-6b4ff21deeb133ee958e246d36bc88e1763201ee.zip
[Resource Loading][391785] Manual selection of submodels to be preloaded + fixing default values
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/META-INF/MANIFEST.MF6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/messages.properties6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/plugin.xml22
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceGroup.java39
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceManager.java216
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadinStrategyGroup.java70
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadingStrategyPreferencePage.java55
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/Messages.java40
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/PreferenceLoadingStrategyExtension.java33
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/ResourcePreferencePathEditor.java60
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/plugin.xml1
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/schema/loadedAuthorizedResource.exsd99
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java26
13 files changed, 629 insertions, 44 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/META-INF/MANIFEST.MF
index 89d2c77f1cf..52de8310ac5 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/META-INF/MANIFEST.MF
@@ -4,6 +4,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.10.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.emf;bundle-version="2.6.0",
+ org.eclipse.emf.common.ui;bundle-version="2.7.0",
+ org.eclipse.emf.common;bundle-version="2.8.0",
+ org.eclipse.core.resources;bundle-version="3.8.1",
+ org.eclipse.gef;bundle-version="3.8.1",
+ org.eclipse.emf.ecore,
org.eclipse.papyrus.infra.services.resourceloading;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.infra.services.resourceloading.pre
ferences
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/messages.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/messages.properties
new file mode 100644
index 00000000000..b60b2df9f17
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/messages.properties
@@ -0,0 +1,6 @@
+LoadedAssociatedResourceGroup_0=Automatically load the following associated resources
+LoadedAuthorizedResourceGroup_0=Automatically authorize the following resources
+LoadedAuthorizedResourceGroup_1=Select authorized elements
+LoadedAuthorizedResourceGroup_2=Select authorized elements
+LoadinStrategyGroup_0=Loading strategy :
+LoadinStrategyGroup_1=Select the loading strategy when model is opened
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/plugin.xml
index 9e4754caa1e..3e2d162b24a 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/plugin.xml
@@ -17,10 +17,30 @@
</page>
</extension>
<extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ category="org.eclipse.papyrus.infra.gmfdiag.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.infra.services.resourceloading.preferences.LoadingStrategyPreferencePage"
+ id="org.eclipse.papyrus.infra.services.resourceloading.properties.ModelLoadingPreferencePage2"
+ name="Model loading">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+ <extension
point="org.eclipse.papyrus.infra.services.resourceloading.currentStrategyChooser">
<CurrentStrategyChooser
chooser="org.eclipse.papyrus.infra.services.resourceloading.preferences.StrategyChooser">
</CurrentStrategyChooser>
</extension>
-
+ <extension
+ point="org.eclipse.papyrus.infra.services.resourceloading.loadingStrategyExtender">
+ <strategyExtender
+ description="org.eclipse.papyrus.core.resourceloading.preferences.strategyExtender1"
+ strategyExtension="org.eclipse.papyrus.infra.services.resourceloading.preferences.PreferenceLoadingStrategyExtension">
+ </strategyExtender>
+ </extension>
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceGroup.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceGroup.java
new file mode 100644
index 00000000000..67238a44e19
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceGroup.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.AbstractGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class LoadedAuthorizedResourceGroup extends AbstractGroup {
+
+ public LoadedAuthorizedResourceGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ public void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.SCROLL_PAGE);
+ group.setLayout(new GridLayout());
+ group.setText(Messages.LoadedAuthorizedResourceGroup_0);
+
+ ResourcePreferencePathEditor pathEditor = new ResourcePreferencePathEditor(LoadedAuthorizedResourceManager.URI_PREF_PREFIX, Messages.LoadedAuthorizedResourceGroup_1, Messages.LoadedAuthorizedResourceGroup_2, group);
+
+ addFieldEditor(pathEditor);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceManager.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceManager.java
new file mode 100644
index 00000000000..6bd7bdc12eb
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadedAuthorizedResourceManager.java
@@ -0,0 +1,216 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.services.resourceloading.Activator;
+import org.eclipse.papyrus.infra.services.resourceloading.util.LoadingUtils;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class LoadedAuthorizedResourceManager implements IPropertyChangeListener {
+
+ public static class LoadedAuthorizedResource {
+
+ private URI uri;
+
+ public LoadedAuthorizedResource(URI uri) {
+ this.uri = uri;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(obj instanceof LoadedAuthorizedResource && uri != null) {
+ return uri.equals(((LoadedAuthorizedResource)obj).uri);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ if(uri != null) {
+ return uri.hashCode();
+ }
+ return 0;
+ }
+ }
+
+ private static final String LOADED_AUTHORIZED_RESOURCE_ELEMENT_ID = "loadedAuthorizedResource"; //$NON-NLS-1$
+
+ private static final String URI_ID = "uri"; //$NON-NLS-1$
+
+ private static final String PREFERENCE_PREFIX = LOADED_AUTHORIZED_RESOURCE_ELEMENT_ID + "."; //$NON-NLS-1$
+
+ public static final String URI_PREF_PREFIX = PREFERENCE_PREFIX + URI_ID + "."; //$NON-NLS-1$
+
+ private static final String pluginId = CorePlugin.PLUGIN_ID;
+
+ private static class Holder {
+
+ static final LoadedAuthorizedResourceManager instance = new LoadedAuthorizedResourceManager();
+ }
+
+ public static LoadedAuthorizedResourceManager getInstance() {
+ return Holder.instance;
+ }
+
+ private IPreferenceStore prefStore;
+
+ private IPreferenceStore projectPrefStore;
+
+ private Map<String, LoadedAuthorizedResource> loadedAuthorizedResources = null;
+
+ private Set<URI> loadedAuthorizedResourcesSet = null;
+
+ public LoadedAuthorizedResourceManager() {
+ prefStore = CorePlugin.getDefault().getPreferenceStore();
+ prefStore.addPropertyChangeListener(this);
+ }
+
+ public synchronized Map<String, LoadedAuthorizedResource> getLoadedAuthorizedResources() {
+ readAuthorizedResources();
+ return loadedAuthorizedResources;
+ }
+
+ public synchronized Set<URI> getLoadedAuthorizedResourcesSet(ModelSet modelSet) {
+ readAuthorizedResources(modelSet);
+ return loadedAuthorizedResourcesSet;
+ }
+
+ public synchronized void propertyChange(PropertyChangeEvent event) {
+ Object newValue = event.getNewValue();
+ // Insertion of the new value in the PreferenceStore
+ if(event.getProperty().startsWith(URI_PREF_PREFIX) && newValue instanceof String) {
+ String[] newURIs = parseString((String)newValue);
+ if(newURIs.length > 0) {
+ for(int i = 0; i < newURIs.length; i++) {
+ String newURI = newURIs[i];
+ if(!getLoadedAuthorizedResources().containsKey(newURI)) {
+ getLoadedAuthorizedResources().put(newURI, new LoadedAuthorizedResource(URI.createURI(newURI)));
+ }
+ }
+ }
+ }
+ }
+
+ private void readAuthorizedResources(ModelSet modelSet) {
+ IModel mainDiModel = modelSet.getModel(DiModel.MODEL_ID);
+ URI mainUri = null;
+ if(mainDiModel instanceof AbstractBaseModel) {
+ AbstractBaseModel resourceMainModel = (AbstractBaseModel)mainDiModel;
+ mainUri = resourceMainModel.getResourceURI();
+
+ }
+ if(loadedAuthorizedResourcesSet == null) {
+ loadedAuthorizedResourcesSet = new HashSet<URI>();
+ }
+
+ if(loadedAuthorizedResources == null) {
+ loadedAuthorizedResources = new HashMap<String, LoadedAuthorizedResourceManager.LoadedAuthorizedResource>();
+ }
+
+ loadedAuthorizedResources.clear();
+ loadedAuthorizedResourcesSet.clear();
+
+ IFile currentFile = LoadingUtils.getFile(mainUri);
+ if(currentFile != null) {
+ IProject project = currentFile.getProject();
+ IEclipsePreferences root = Platform.getPreferencesService().getRootNode();
+ if(project != null && root != null) {
+ try {
+ // For the project preferences :
+ if(root.node(ProjectScope.SCOPE).node(project.getName()).nodeExists(pluginId)) {
+ projectPrefStore = new ScopedPreferenceStore(new ProjectScope(project), pluginId);
+ String s = projectPrefStore.getString(URI_PREF_PREFIX);
+ String[] array = parseString(s);
+ for(int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ loadedAuthorizedResourcesSet.add(uri);
+ }
+ }
+ } catch (BackingStoreException e) {
+ Activator.logError(e);
+ }
+ }
+ }
+ // For the workspace preferences :
+ String s = prefStore.getString(URI_PREF_PREFIX);
+ String[] array = parseString(s);
+ for(int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ loadedAuthorizedResourcesSet.add(uri);
+ }
+ }
+
+ private void readAuthorizedResources() {
+ if(loadedAuthorizedResources == null) {
+ loadedAuthorizedResources = new HashMap<String, LoadedAuthorizedResourceManager.LoadedAuthorizedResource>();
+ }
+ String s;
+ loadedAuthorizedResources.clear();
+
+ if(projectPrefStore == null) {
+ s = prefStore.getString(URI_PREF_PREFIX);
+ } else {
+ s = projectPrefStore.getString(URI_PREF_PREFIX);
+ }
+
+ String[] array = parseString(s);
+ for(int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ }
+ }
+
+ protected String[] parseString(String stringList) {
+ StringTokenizer st = new StringTokenizer(stringList, File.pathSeparator + "\n\r");//$NON-NLS-1$
+ ArrayList v = new ArrayList();
+ while(st.hasMoreElements()) {
+ v.add(st.nextElement());
+ }
+ return (String[])v.toArray(new String[v.size()]);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadinStrategyGroup.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadinStrategyGroup.java
index 051da3897c4..9a2946b9557 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadinStrategyGroup.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadinStrategyGroup.java
@@ -26,47 +26,47 @@ import org.eclipse.swt.widgets.Group;
public class LoadinStrategyGroup extends AbstractGroup {
- private static final String LABEL_LOADING_STRATEGY = "Loading strategy :";
+ private static final String LABEL_LOADING_STRATEGY = "Loading strategy :";
- private static final String SELECT_LOADING_STRATEGY = "Select the loading strategy when model is opened";
+ private static final String SELECT_LOADING_STRATEGY = "Select the loading strategy when model is opened";
- private RadioGroupFieldEditor fStrategyRadio;
+ private RadioGroupFieldEditor fStrategyRadio;
- public LoadinStrategyGroup(Composite parent, String title, DialogPage dialogPage) {
- super(parent, title, dialogPage);
- createContent(parent);
- }
+ public LoadinStrategyGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
- public void createContent(Composite parent) {
- Group group = new Group(parent, SWT.SCROLL_PAGE);
- group.setLayout(new GridLayout());
- group.setText(SELECT_LOADING_STRATEGY);
- fStrategyRadio = createStrategyRadio(group);
- addFieldEditor(fStrategyRadio);
- }
+ public void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.SCROLL_PAGE);
+ group.setLayout(new GridLayout());
+ group.setText(SELECT_LOADING_STRATEGY);
+ fStrategyRadio = createStrategyRadio(group);
+ addFieldEditor(fStrategyRadio);
+ }
- private static RadioGroupFieldEditor createStrategyRadio(Group group) {
- String[][] values = getValuesFromExtensionPoint();
- RadioGroupFieldEditor radio = new RadioGroupFieldEditor(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY, LABEL_LOADING_STRATEGY, 1, values, group);
- return radio;
- }
+ private static RadioGroupFieldEditor createStrategyRadio(Group group) {
+ String[][] values = getValuesFromExtensionPoint();
+ RadioGroupFieldEditor radio = new RadioGroupFieldEditor(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY, LABEL_LOADING_STRATEGY, 1, values, group);
+ return radio;
+ }
- /**
- * Gets the strategies value from extension point.
- *
- * @return the strategies value
- */
- private static String[][] getValuesFromExtensionPoint() {
- Map<Integer, String> allStrategies = ProxyManager.getAllStrategies();
- String[][] result = new String[allStrategies.size()][2];
- int i = 0;
- for(Integer val : allStrategies.keySet()) {
- result[i][0] = allStrategies.get(val);
- result[i][1] = String.valueOf(val);
- i++;
- }
- return result;
- }
+ /**
+ * Gets the strategies value from extension point.
+ *
+ * @return the strategies value
+ */
+ private static String[][] getValuesFromExtensionPoint() {
+ Map<Integer, String> allStrategies = ProxyManager.getAllStrategies();
+ String[][] result = new String[allStrategies.size()][2];
+ int i = 0;
+ for(Integer val : allStrategies.keySet()) {
+ result[i][0] = allStrategies.get(val);
+ result[i][1] = String.valueOf(val);
+ i++;
+ }
+ return result;
+ }
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadingStrategyPreferencePage.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadingStrategyPreferencePage.java
index c1eed07c46e..dcff54f7072 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadingStrategyPreferencePage.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/LoadingStrategyPreferencePage.java
@@ -13,14 +13,23 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusNodePreferencePage;
+import org.eclipse.papyrus.infra.services.resourceloading.Activator;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class LoadingStrategyPreferencePage extends AbstractPapyrusNodePreferencePage {
private LoadinStrategyGroup groupComposite;
+ private IProject project;
+
/**
* @generated
*/
@@ -42,6 +51,10 @@ public class LoadingStrategyPreferencePage extends AbstractPapyrusNodePreference
protected void createPageContents(Composite parent) {
groupComposite = new LoadinStrategyGroup(parent, getTitle(), this);
addAbstractGroup(groupComposite);
+ LoadedAuthorizedResourceGroup loadedAuthorizedResourceGroup = new LoadedAuthorizedResourceGroup(parent, getTitle(), this);
+ addAbstractGroup(loadedAuthorizedResourceGroup);
+ // TODO : if no value is set for the radio buttons (loading strategy) on
+ // a project, use the workspace loading strategy.
}
/**
@@ -50,8 +63,48 @@ public class LoadingStrategyPreferencePage extends AbstractPapyrusNodePreference
@Override
public boolean performOk() {
boolean result = super.performOk();
- StrategyChooser.setCurrentStrategy(getPreferenceStore().getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY));
+ StrategyChooser.setCurrentStrategy(doGetPreferenceStore().getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY));
+ IPreferenceStore modifiedPrefStore = doGetPreferenceStore();
+ try {
+ if(modifiedPrefStore instanceof ScopedPreferenceStore) {
+ ((ScopedPreferenceStore)modifiedPrefStore).save();
+ }
+ } catch (Exception e) {
+ Activator.logError(e);
+ }
+
return result;
}
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ project = (IProject)element.getAdapter(IResource.class);
+ }
+
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return doGetPreferenceStore();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ IPreferenceStore store;
+ if(project != null) {
+ store = new ScopedPreferenceStore(new ProjectScope(project), getBundleId());
+ } else {
+ store = new ScopedPreferenceStore(new InstanceScope(), getBundleId());
+ }
+ return store;
+ }
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/Messages.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/Messages.java
new file mode 100644
index 00000000000..6694b33bee8
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/Messages.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$
+
+ public static String LoadedAssociatedResourceGroup_0;
+
+ public static String LoadedAuthorizedResourceGroup_0;
+
+ public static String LoadedAuthorizedResourceGroup_1;
+
+ public static String LoadedAuthorizedResourceGroup_2;
+
+ public static String LoadinStrategyGroup_0;
+
+ public static String LoadinStrategyGroup_1;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/PreferenceLoadingStrategyExtension.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/PreferenceLoadingStrategyExtension.java
new file mode 100644
index 00000000000..3efe2aa1692
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/PreferenceLoadingStrategyExtension.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.resourceloading.ILoadingStrategyExtension;
+
+public class PreferenceLoadingStrategyExtension implements ILoadingStrategyExtension {
+
+ public boolean loadResource(ModelSet modelSet, URI uri) {
+ Set<URI> loadedAuthorizedResourcesSet = LoadedAuthorizedResourceManager.getInstance().getLoadedAuthorizedResourcesSet(modelSet);
+
+ if(loadedAuthorizedResourcesSet.contains(uri.trimFileExtension())) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/ResourcePreferencePathEditor.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/ResourcePreferencePathEditor.java
new file mode 100644
index 00000000000..858408ab54e
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.preferences/src/org/eclipse/papyrus/infra/services/resourceloading/preferences/ResourcePreferencePathEditor.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.preferences;
+
+import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.preference.PathEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class ResourcePreferencePathEditor extends PathEditor {
+
+ public ResourcePreferencePathEditor() {
+ super();
+ }
+
+ public ResourcePreferencePathEditor(String name, String labelText, String dirChooserLabelText, Composite parent) {
+ super(name, labelText, dirChooserLabelText, parent);
+ }
+
+ @Override
+ protected String getNewInputObject() {
+ String labelText = getLabelText();
+ ResourceDialog dialog = new ResourceDialog(getShell(), labelText, SWT.OPEN | SWT.SINGLE);
+ dialog.open();
+ String uriTexte = dialog.getURIText();
+ URI uri = URI.createURI(uriTexte);
+ return uri.trimFileExtension().toString();
+ }
+
+ @Override
+ protected void doLoad() {
+ if(getList() != null) {
+ getList().removeAll();
+ }
+ super.doLoad();
+ }
+
+ @Override
+ protected void doLoadDefault() {
+ if(getList() != null) {
+ getList().removeAll();
+ }
+ super.doLoadDefault();
+ }
+
+
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/plugin.xml
index 39607970bfb..88f75898483 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/plugin.xml
@@ -4,6 +4,7 @@
<extension-point id="loadingStrategy" name="loadingStrategy" schema="schema/loadingStrategy.exsd"/>
<extension-point id="loadingStrategyExtender" name="loadingStrategyExtender" schema="schema/loadingStrategyExtender.exsd"/>
<extension-point id="currentStrategyChooser" name="Current Strategy Chooser" schema="schema/currentStrategyChooser.exsd"/>
+ <extension-point id="loadedAuthorizedResource" name="loadedAuthorizedResource" schema="schema/loadedAuthorizedResource.exsd"/>
<extension
point="org.eclipse.papyrus.infra.core.service">
<serviceFactory
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/schema/loadedAuthorizedResource.exsd b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/schema/loadedAuthorizedResource.exsd
new file mode 100644
index 00000000000..893a1b9be4b
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/schema/loadedAuthorizedResource.exsd
@@ -0,0 +1,99 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.core.resourceloading" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.core.resourceloading" id="loadedAuthorizedResource" name="loadedAuthorizedResource"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="uri">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="loadedAuthorizedResource" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="loadedAuthorizedResource">
+ <complexType>
+ <attribute name="uri" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
index c4bb17a4c0e..24b401a2940 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
@@ -106,7 +106,7 @@ public class AskUserStrategy implements ILoadingStrategy {
// if no listener is registered, a listener is added on the editor to remove the notifications
// when the editor is closed the listener removes too the choices made by the user.
addClosingEditorListener(initialURI);
-
+
// all the verification are made with the uri without the file extension
// each load is performed for a set of resources
URI trimFileExtensionAndFragment = uri.trimFragment().trimFileExtension();
@@ -252,7 +252,8 @@ public class AskUserStrategy implements ILoadingStrategy {
}
/**
- * NO for all registers the NoForAll URI and do nothing
+ * NO for all registers the NoForAll URI and do nothing
+ *
* @param uri
* @param modelSet
* @param initialURI
@@ -291,6 +292,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Yes for All registers Yes For All URI and refresh the tabs to take in account the loaded elements
+ *
* @param uri
* @param modelSet
* @param initialURI
@@ -350,6 +352,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* No runnable does not accept the URI asked
+ *
* @param uri
* @param modelSet
* @param initialURI
@@ -373,6 +376,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Yes registers the URI and refresh the tab to take in account the loaded elements
+ *
* @param uri
* @param modelSet
* @param initialURI
@@ -384,6 +388,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Register the notification created to the URI open by the editor
+ *
* @param initialURI
* @param notification
*/
@@ -428,7 +433,7 @@ public class AskUserStrategy implements ILoadingStrategy {
* If the editor is not opened or activated some listeners will be triggered to launch the refresh
*
* @author tfaure
- *
+ *
*/
private class LoadAndRefreshRunnable implements NotificationRunnable {
@@ -530,6 +535,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Add a page listener
+ *
* @param listener
* @return
*/
@@ -544,6 +550,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Register a listener of the perspective to know when the editor is finally closed
+ *
* @param listener
* @return
*/
@@ -557,6 +564,7 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Unregister a perspective listener
+ *
* @param listener
* @return
*/
@@ -612,8 +620,9 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* An empty {@link IPartListener} implementation
+ *
* @author tfaure
- *
+ *
*/
private class EditorAdapter implements IPartListener {
@@ -636,8 +645,9 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Listener which is notifid when an editor is activated
+ *
* @author tfaure
- *
+ *
*/
private class EditorActivateListener extends EditorAdapter {
@@ -662,8 +672,9 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* Listener which is notifid when an editor is closed
+ *
* @author tfaure
- *
+ *
*/
private class EditorCloseListener extends EditorAdapter {
@@ -688,8 +699,9 @@ public class AskUserStrategy implements ILoadingStrategy {
/**
* A perspective listener which choices of an user
+ *
* @author tfaure
- *
+ *
*/
protected class EditorClosePerspectiveListener implements IPerspectiveListener {

Back to the top