Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-12-06 15:24:06 +0000
committerCamille Letavernier2013-12-06 15:24:06 +0000
commit3715eae962095b9ae3e78c955332c8ea4d110b75 (patch)
tree044f51bf80f65da2262005cfed2ba8d277a54037 /plugins/uml
parentd5352aa532ec0bd91f317ba615d5882aeb5c522e (diff)
downloadorg.eclipse.papyrus-3715eae962095b9ae3e78c955332c8ea4d110b75.tar.gz
org.eclipse.papyrus-3715eae962095b9ae3e78c955332c8ea4d110b75.tar.xz
org.eclipse.papyrus-3715eae962095b9ae3e78c955332c8ea4d110b75.zip
423432: [Performances - Properties view] Improve properties view loading
on startup https://bugs.eclipse.org/bugs/show_bug.cgi?id=423432 Fix compilation issues from previous commit
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java10
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/SwitchProfileDialog.java57
2 files changed, 60 insertions, 7 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
index c4dd85525a2..fd22f58d5dd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
@@ -17,6 +17,9 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent;
import org.eclipse.papyrus.commands.Activator;
import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.uml2.uml.ProfileApplication;
/**
@@ -41,7 +44,14 @@ public class PaletteProfileApplicationListener implements IPapyrusListener {
if(notification.getNotifier() instanceof ProfileApplication) {
if(Notification.SET == notification.getEventType()) {
try {
+ ProfileApplication profileApplication = (ProfileApplication)notification.getNotifier();
+ IEditorPart editor = ServiceUtilsForEObject.getInstance().getNestedActiveIEditorPart(profileApplication);
+ if(editor == null) {
+ return;
+ }
PapyrusPaletteService.getInstance().providerChanged(new ProviderChangeEvent(PapyrusPaletteService.getInstance()));
+ } catch (ServiceException ex) {
+ //Nothing to do. The ServiceRegistry is not available or there is no active editor. Don't update the palette
} catch (Exception ex) {
//Bug 407849: If a listener throws an exception, the operation is rolled back. In this case, we simply want to update the palettes and exceptions should only be logged
Activator.log.error(ex);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/SwitchProfileDialog.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/SwitchProfileDialog.java
index f890f74f24a..a172fb66fa7 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/SwitchProfileDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/SwitchProfileDialog.java
@@ -23,11 +23,12 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl.PlatformSchemeAware;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -46,8 +47,10 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.readonly.ReadOnlyManager;
import org.eclipse.papyrus.infra.emf.resource.DependencyManagementHelper;
import org.eclipse.papyrus.infra.emf.resource.Replacement;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
@@ -223,7 +226,11 @@ public class SwitchProfileDialog extends SelectionDialog {
}
protected void updateControls() {
-
+ String newTitle = "Switch profile location";
+ if(!profilesToEdit.isEmpty()) {
+ newTitle += " *";
+ }
+ getShell().setText(newTitle);
getButton(APPLY_ID).setEnabled(!profilesToEdit.isEmpty());
boolean enableBrowse = !viewer.getSelection().isEmpty();
@@ -272,6 +279,45 @@ public class SwitchProfileDialog extends SelectionDialog {
}
});
+ Map<String, Object> saveOptions = new HashMap<String, Object>();
+ final Map<Object, Object> targetMap = new HashMap<Object, Object>();
+ for(Map.Entry<Resource, Resource> resourceMap : profilesToEdit.entrySet()) {
+ targetMap.put(resourceMap.getKey().getURI(), resourceMap.getValue().getURI());
+ }
+
+ saveOptions.put(XMLResource.OPTION_URI_HANDLER, new PlatformSchemeAware() {
+
+ @Override
+ public URI deresolve(URI uri) {
+ URI resourceURI = uri.trimFragment();
+
+ if(targetMap.containsKey(resourceURI)) {
+ Object target = targetMap.get(resourceURI);
+ if(target instanceof URI) {
+ URI targetURI = (URI)target;
+ if(uri.fragment() != null) {
+ targetURI = targetURI.appendFragment(uri.fragment());
+ }
+ return targetURI;
+ }
+ }
+
+ return super.deresolve(uri);
+ }
+ });
+
+ IReadOnlyHandler handler = ReadOnlyManager.getReadOnlyHandler(editingDomain);
+ for(Resource resource : modelSet.getResources()) {
+ if(handler.anyReadOnly(new URI[]{ resource.getURI() }).get()) {
+ continue;
+ }
+ try {
+ resource.save(saveOptions);
+ } catch (IOException ex) {
+ Activator.log.error(ex);
+ }
+ }
+
profilesToEdit.clear();
updateControls();
viewer.refresh();
@@ -323,11 +369,7 @@ public class SwitchProfileDialog extends SelectionDialog {
protected void okPressed() {
applyPressed();
- try {
- modelSet.save(new NullProgressMonitor());
- } catch (IOException ex) {
- Activator.log.error(ex);
- }
+
super.okPressed();
}
@@ -488,6 +530,7 @@ public class SwitchProfileDialog extends SelectionDialog {
if(getSelectedResource() != targetResource) {
profilesToEdit.put(getSelectedResource(), targetResource);
updateControls();
+ applyPressed(); //Immediatly apply to avoid confusion
} else {
MessageDialog.openWarning(getShell(), "Nothing changed", "Nothing to change");
}

Back to the top