static final Font FONT = new Font(null, "Courier New", 12, SWT.NORMAL);\r
\r
SysdynDiagramEditor editor;\r
+ Text name;\r
Text startTime;\r
Text stopTime;\r
+ String originalName;\r
String originalStart;\r
String originalStop;\r
boolean disposed = false;\r
public void createPartControl(Composite parent) {\r
GridDataFactory.fillDefaults().applyTo(parent);\r
GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).spacing(3, 3).applyTo(parent);\r
-\r
+ \r
Label label = new Label(parent, SWT.NONE);\r
- label.setText("Start time");\r
+ label.setText("Name");\r
\r
- startTime = new Text(parent, SWT.BORDER | SWT.RIGHT);\r
- int columns = 10;\r
- GC gc = new GC (startTime);\r
+ name = new Text(parent, SWT.BORDER);\r
+ int columns = 35;\r
+ GC gc = new GC (name);\r
FontMetrics fm = gc.getFontMetrics ();\r
int width = columns * fm.getAverageCharWidth ();\r
int height = fm.getHeight ();\r
gc.dispose (); \r
- Point size = startTime.computeSize(width, height);\r
+ Point size = name.computeSize(width, height);\r
+ name.setFont(FONT);\r
+ GridDataFactory.fillDefaults().hint(size).applyTo(name);\r
+ name.addKeyListener(new EscListener());\r
+ name.addVerifyListener(new VerifyListener() {\r
+ \r
+ @Override\r
+ public void verifyText(VerifyEvent e) {\r
+ e.doit = false;\r
+ String s = e.text; \r
+ if(!s.contains(" ")) {\r
+ e.doit = true;\r
+ }\r
+ }\r
+ });\r
+ \r
+ label = new Label(parent, SWT.NONE);\r
+ label.setText("Start time");\r
+\r
+ startTime = new Text(parent, SWT.BORDER | SWT.RIGHT);\r
startTime.setFont(FONT);\r
GridDataFactory.fillDefaults().hint(size).applyTo(startTime);\r
startTime.addKeyListener(new EscListener());\r
Configuration conf = model.getConfiguration();\r
\r
final IMapping mapping = model.getMapping();\r
+ if(!conf.name.equals(name.getText())){\r
+ conf.name = name.getText();\r
+ modified = true;\r
+ }\r
if(conf.startTime != Double.parseDouble(startTime.getText())){\r
conf.startTime = Double.parseDouble(startTime.getText());\r
modified = true;\r
SysdynModel model = sdm.getModel(rei.getResource());\r
Configuration conf = model.getConfiguration();\r
\r
+ originalName = conf.name;\r
+ name.setText(originalName);\r
originalStart = conf.startTime.toString();\r
startTime.setText(originalStart);\r
originalStop = conf.stopTime.toString();\r
public void keyPressed(KeyEvent e) {\r
Text text = (Text)e.widget;\r
String originalText = null;\r
- if(text == startTime)\r
+ if(text == name)\r
+ originalText = originalName;\r
+ else if(text == startTime)\r
originalText = originalStart;\r
- if(text == stopTime)\r
+ else if(text == stopTime)\r
originalText = originalStop;\r
if(e.keyCode == SWT.ESC && originalText != null) {\r
text.setText(originalText);\r
import org.simantics.sysdyn.ui.actions.OpenContextMenu;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.workbench.ResourceEditorPart;\r
+import org.simantics.ui.workbench.TitleRequest;\r
+import org.simantics.ui.workbench.TitleUpdater;\r
+import org.simantics.utils.datastructures.Callable;\r
+import org.simantics.utils.datastructures.Callback;\r
import org.simantics.utils.ui.jface.ActiveSelectionProvider;\r
\r
public class SysdynDiagramEditor extends ResourceEditorPart {\r
IDiagram diagram;\r
IMapping mapping;\r
Frame frame;\r
- \r
+ boolean disposed = false; \r
+ \r
IElementListener elementUpdateListener = new IElementListener() {\r
\r
@Override\r
}\r
\r
});\r
+ \r
+ SimanticsUI.getSession().asyncRequest(\r
+ new TitleRequest(site.getId(), getResourceInput()),\r
+ new TitleUpdater(site.getShell().getDisplay(), new Callback<String>() {\r
+ @Override\r
+ public void run(String partName) {\r
+ setPartName(partName);\r
+ }\r
+ }, new Callable<Boolean>() {\r
+ @Override\r
+ public Boolean call() {\r
+ return disposed;\r
+ }\r
+ }));\r
} catch (DatabaseException e) {\r
// TODO Auto-generated catch block\r
e.printStackTrace();\r
public void dispose() {\r
mapping.dispose();\r
frame.dispose();\r
- \r
+ disposed = true;\r
}\r
\r
- @Override\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
public Object getAdapter(Class adapter) {\r
if (adapter == INode.class) {\r
return canvas.getEditor().getSceneGraph();\r