X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FdiagramEditor%2Fe4%2FPopulateElementDropParticipant.java;h=ac9413064a7b8b222e401a820e0e552a582dc198;hp=51f5d82698201b412e8dde2437e8cc13ff2287ac;hb=47269fe0acb894f346810417d950a1ab59cdc0ea;hpb=11309f6516278203264b680235cbbe1dc2bde98e diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java index 51f5d8269..ac9413064 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java @@ -30,6 +30,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osgi.util.NLS; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; @@ -210,32 +211,33 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i return processor.syncRequest(new UniqueRead() { @Override public String perform(ReadGraph graph) throws DatabaseException { -// System.out.println("dragged resource: " + draggedResource); -// System.out.println("drop target resource: " + dropTarget); + // System.out.println("dragged resource: " + draggedResource); + // System.out.println("drop target resource: " + dropTarget); Resource sourceModel = graph.syncRequest(new PossibleIndexRoot(draggedResource)); Resource targetModel = graph.syncRequest(new PossibleIndexRoot(dropTarget)); -// System.out.println("source model: " + sourceModel); -// System.out.println("target model: " + targetModel); + // System.out.println("source model: " + sourceModel); + // System.out.println("target model: " + targetModel); // Prevent dragging data from one source model to another. // If source is not part of any model, everything is okay. if (sourceModel != null && !graph.syncRequest(new IsLinkedTo(targetModel, sourceModel))) { // Prevent a symbol instantiating within its own configuration. // NOTE: this doesn't handle transitive cycles. - return "Cannot instantiate " + NameUtils.getSafeName(graph, draggedResource) + " into model " - + NameUtils.getURIOrSafeNameInternal(graph, targetModel) + ". The source namespace (" - + NameUtils.getURIOrSafeNameInternal(graph, sourceModel) + ") is not linked to the target model."; + return NLS.bind(Messages.PopulateElementDropParticipant_CannotInstantiate, + new Object[] { NameUtils.getSafeName(graph, draggedResource), + NameUtils.getURIOrSafeNameInternal(graph, targetModel), + NameUtils.getURIOrSafeNameInternal(graph, sourceModel) }); } - + // Prevent dragging to published components ModelingResources MOD = ModelingResources.getInstance(graph); StructuralResource2 STR = StructuralResource2.getInstance(graph); Resource configuration = graph.getPossibleObject(dropTarget, MOD.DiagramToComposite); if (configuration != null) { Resource componentTypeFromDiagram = graph.getPossibleObject(configuration, STR.Defines); - if(componentTypeFromDiagram != null) { - if(Layer0Utils.isPublished(graph, componentTypeFromDiagram)) - return "Cannot create elements into a diagram that belongs to a published user component."; + if (componentTypeFromDiagram != null) { + if (Layer0Utils.isPublished(graph, componentTypeFromDiagram)) + return Messages.PopulateElementDropParticipant_CannotCreateElementIntoDiagram; } } @@ -244,8 +246,9 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i if (componentTypeFromSymbol != null) { if (configuration != null) { Resource componentTypeFromDiagram = graph.getPossibleObject(configuration, STR.Defines); - if (componentTypeFromDiagram != null && componentTypeFromSymbol.equals(componentTypeFromDiagram)) { - return "Cannot instantiate user component within its own configuration."; + if (componentTypeFromDiagram != null + && componentTypeFromSymbol.equals(componentTypeFromDiagram)) { + return Messages.PopulateElementDropParticipant_CannotInstantiateUserComponent; } } } @@ -284,7 +287,7 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i @Override public void drop(DropTargetDropEvent dtde, final IDnDContext dp) { - TimeLogger.resetTimeAndLog(getClass(), "drop"); + TimeLogger.resetTimeAndLog(getClass(), "drop"); //$NON-NLS-1$ final IDiagram d = getHint(DiagramHints.KEY_DIAGRAM); if (d == null) @@ -381,7 +384,7 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i } } } catch (DatabaseException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Diagram content change tracking failed.", e)); + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.PopulateElementDropParticipant_ActivatorDiagramContentTrackingFailed, e)); } }