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.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;
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;
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;
- 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));