diff options
author | Henrik Rentz-Reichert | 2011-01-28 08:38:18 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2011-01-28 08:38:18 +0000 |
commit | 9f929db356936cd2a8894a99c8b8f8b99c5b3f6f (patch) | |
tree | 0458446abb95d79570509392d649f25c6e58b440 /plugins | |
parent | 1ff059b31fe2a07cc9c470375b31f9503d8575b9 (diff) | |
download | org.eclipse.etrice-9f929db356936cd2a8894a99c8b8f8b99c5b3f6f.tar.gz org.eclipse.etrice-9f929db356936cd2a8894a99c8b8f8b99c5b3f6f.tar.xz org.eclipse.etrice-9f929db356936cd2a8894a99c8b8f8b99c5b3f6f.zip |
core.room: more unique name providers
ui.behavior: using unique names for new objects
Diffstat (limited to 'plugins')
6 files changed, 40 insertions, 6 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java index c9033afef..9cffa890b 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java @@ -226,8 +226,8 @@ public class RoomNameProvider { public static String getUniqueChoicePointName(StateGraph sg) {
HashSet<String> names = new HashSet<String>();
- for (ChoicePoint t : sg.getChPoints()) {
- names.add(t.getName());
+ for (ChoicePoint cp : sg.getChPoints()) {
+ names.add(cp.getName());
}
for (int i = 0; i < 1000; i++) {
@@ -238,6 +238,36 @@ public class RoomNameProvider { return "not_unique";
}
+
+ public static String getUniqueTrPointName(StateGraph sg) {
+ HashSet<String> names = new HashSet<String>();
+ for (TrPoint tp : sg.getTrPoints()) {
+ names.add(tp.getName());
+ }
+
+ for (int i = 0; i < 1000; i++) {
+ String name = "tp"+i;
+ if (!names.contains(name))
+ return name;
+ }
+
+ return "not_unique";
+ }
+
+ public static String getUniqueStateName(StateGraph sg) {
+ HashSet<String> names = new HashSet<String>();
+ for (State s : sg.getStates()) {
+ names.add(s.getName());
+ }
+
+ for (int i = 0; i < 1000; i++) {
+ String name = "s"+i;
+ if (!names.contains(name))
+ return name;
+ }
+
+ return "not_unique";
+ }
public static String getTransitionLabelName(Transition t) {
String name = null;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java index c919b4115..7a0e1e808 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java +++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java @@ -78,6 +78,7 @@ public class StatePropertyDialog extends AbstractPropertyDialog { createDecorator(name, "invalid name");
name.setFocus();
+ name.selectAll();
}
else {
Text name = mform.getToolkit().createText(body, "Name:", SWT.BORDER);
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TrPointPropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TrPointPropertyDialog.java index d27446cdb..d986686cd 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TrPointPropertyDialog.java +++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TrPointPropertyDialog.java @@ -80,6 +80,7 @@ public class TrPointPropertyDialog extends AbstractPropertyDialog { createDecorator(name, "invalid name");
name.setFocus();
+ name.selectAll();
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java index fa9b75566..5c324c25e 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java +++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java @@ -227,6 +227,7 @@ public class TransitionPropertyDialog extends AbstractPropertyDialog { createDecorator(name, "invalid name");
name.setFocus();
+ name.selectAll();
}
if (trans instanceof TriggeredTransition) {
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java index 40fe3964a..693ef0a7f 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java +++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java @@ -15,6 +15,7 @@ package org.eclipse.etrice.ui.behavior.support; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.ActorRef;
@@ -143,7 +144,7 @@ public class StateSupport { // create new State
BaseState s = RoomFactory.eINSTANCE.createBaseState();
- s.setName("state");
+ s.setName(RoomNameProvider.getUniqueStateName(sg));
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
StatePropertyDialog dlg = new StatePropertyDialog(shell, s, sg);
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java index 6067801bd..bb307a002 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java +++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java @@ -14,6 +14,7 @@ package org.eclipse.etrice.ui.behavior.support; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.EntryPoint;
import org.eclipse.etrice.core.room.ExitPoint;
@@ -143,9 +144,8 @@ public class TrPointSupport { tp = RoomFactory.eINSTANCE.createTransitionPoint();
break;
}
- tp.setName("tp");
-
- StateGraph sg = (StateGraph) context.getTargetContainer().getLink().getBusinessObjects().get(0);
+ StateGraph sg = (StateGraph) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(context.getTargetContainer());
+ tp.setName(RoomNameProvider.getUniqueTrPointName(sg));
// TODOHRR-B add property dialog
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|