]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java
Externalize strings
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagramEditor / e4 / PopulateElementDropParticipant.java
index 51f5d82698201b412e8dde2437e8cc13ff2287ac..ac9413064a7b8b222e401a820e0e552a582dc198 100644 (file)
@@ -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.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;
 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<String>() {
             @Override
             public String perform(ReadGraph graph) throws DatabaseException {
         return processor.syncRequest(new UniqueRead<String>() {
             @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));
                 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.
 
                 // 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);
                 // 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 (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) {
 
     @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)
 
         final IDiagram d = getHint(DiagramHints.KEY_DIAGRAM);
         if (d == null)
@@ -381,7 +384,7 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i
                 }
             }
         } catch (DatabaseException e) {
                 }
             }
         } 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));
         }
     }
 
         }
     }