From: lempinen Date: Thu, 17 Jun 2010 14:58:59 +0000 (+0000) Subject: Removed configuration view. Everything is in the properties -tabview X-Git-Tag: simantics-1.2.0~208 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=38c2fad3bda69f76cdbf23808f3c06c7586c1c65;p=simantics%2Fsysdyn.git Removed configuration view. Everything is in the properties -tabview git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16194 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 8c869e24..2b48bcc7 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -78,13 +78,6 @@ name="Sysdyn Model Browser" restorable="true"> - - 0 && - conf.startTime != Double.parseDouble(startTime.getText())){ - conf.startTime = Double.parseDouble(startTime.getText()); - modified = true; - } - if(stopTime.getText().length() > 0 && - conf.stopTime != Double.parseDouble(stopTime.getText())) { - conf.stopTime = Double.parseDouble(stopTime.getText()); - modified = true; - } - - if(modified) { - mapping.rangeModified(conf); - } - - - - } - } - - @Override - public void partHidden(IWorkbenchPartReference partRef) { - } - - @Override - public void partInputChanged(IWorkbenchPartReference partRef) { - } - - @Override - public void partOpened(IWorkbenchPartReference partRef) { - } - - @Override - public void partVisible(IWorkbenchPartReference partRef) { - } - }; - this.getViewSite().getPage().addPartListener(editorSelectionListener); - - IEditorPart iep = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - if (iep != null && iep instanceof SysdynDiagramEditor) - initializeFields((SysdynDiagramEditor)iep); - else - initializeFields(null); - } - - @Override - public void dispose() { - this.getViewSite().getPage().removePartListener(editorSelectionListener); - if(this.mapping != null) - this.mapping.removeMappingListener(mappingListener); - disposed = true; - super.dispose(); - } - - private void updateEditor(SysdynDiagramEditor editor) { - if(editor != null) { - this.editor = editor; - } else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().getActiveEditor() instanceof SysdynDiagramEditor) { - this.editor = (SysdynDiagramEditor)PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } else { - this.editor = null; - } - } - - private void initializeFields(SysdynDiagramEditor editor) { - updateEditor(editor); - updateMapping(); - if(mapping != null && editor != null) - setFields((Configuration)mapping.get(editor.getResourceInput().getResource())); - else - emptyFields(); - } - - private void emptyFields() { - name.setText(""); - name.setEnabled(false); - startTime.setText(""); - startTime.setEnabled(false); - stopTime.setText(""); - stopTime.setEnabled(false); - setPartName("Configuration View"); - } - private void setFields(Configuration conf) { - - if(editor != null && mapping != null) { - originalName = conf.name; - name.setText(originalName); - name.setEnabled(true); - originalStart = conf.startTime.toString(); - startTime.setText(originalStart); - startTime.setEnabled(true); - originalStop = conf.stopTime.toString(); - stopTime.setText(originalStop); - stopTime.setEnabled(true); - setPartName(conf.name); - } - - } - - private class EscListener implements KeyListener { - - @Override - public void keyPressed(KeyEvent e) { - if(e.keyCode == SWT.ESC) { - Text text = (Text)e.widget; - if(text == name) { - text.setText(originalName); - text.setSelection(text.getCharCount()); - } else if(text == startTime) { - text.setText(originalStart); - text.setSelection(0); - } else if(text == stopTime) { - text.setText(originalStop); - text.setSelection(0); - } - } - } - - @Override - public void keyReleased(KeyEvent e) { - } - - } - - private class DoubleVerify implements VerifyListener { - - @Override - public void verifyText(VerifyEvent e) { - e.doit = true; - for(int i = 0; i < e.text.length(); i++){ - if(!Character.isDigit(e.text.charAt(i))){ - if(e.text.charAt(i) != '.') { - e.doit = false; - break; - } else if(e.text.indexOf('.') != e.text.lastIndexOf('.')) { - e.doit = false; - break; - } else if(((Text)e.widget).getText().substring(0, e.start).contains(".") || - ((Text)e.widget).getText().substring(e.end, ((Text)e.widget).getText().length()).contains(".")) { - e.doit = false; - break; - } - } - } - } - } - - private void updateMapping() { - if(editor != null) { - IEditorInput input = editor.getEditorInput(); - ResourceEditorInput rei = (ResourceEditorInput) input; - SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession()); - SysdynModel model = sdm.getModel(rei.getResource()); - mapping = model.getMapping(); - mappingListener = new IMappingListener() { - - @Override - public void rangeModified() { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { - @Override - public void perform(WriteGraph graph) - throws DatabaseException { - mapping.updateDomain(graph); - } - }); - } catch (DatabaseException e) { - e.printStackTrace(); - } - } - - }); - } - - @Override - public void domainModified() { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - try { - SimanticsUI.getSession().syncRequest(new ReadRequest() { - @Override - public void run(ReadGraph graph) throws DatabaseException { - mapping.updateRange(graph); - if(editor != null && !disposed) { - name.getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - Configuration conf = (Configuration)mapping.get(editor.getResourceInput().getResource()); - setFields(conf); - } - }); - - } - } - }); - } catch (DatabaseException e) { - e.printStackTrace(); - } - } - - }); - } - - }; - mapping.addMappingListener(mappingListener); - } else { - mapping = null; - } - } - - @Override - public void setFocus() { - name.setFocus(); - name.setSelection(name.getCharCount()); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java index ae0d0534..15371b07 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java @@ -37,7 +37,6 @@ public class SysdynPerspectiveFactory implements IPerspectiveFactory { IFolderLayout bottom2 = layout.createFolder("bottom2", IPageLayout.LEFT, 0.4f, "bottom1"); bottom1.addView("org.simantics.browsing.ui.graph.propertyView"); bottom1.addView(IConsoleConstants.ID_CONSOLE_VIEW); - bottom1.addView("org.simantics.sysdyn.ui.configurationView"); bottom2.addView("org.simantics.sysdyn.ui.trend.view"); bottom2.addView("org.simantics.sysdyn.ui.dependencies.view"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index 57f162b2..86cfbf61 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -1,5 +1,6 @@ package org.simantics.sysdyn.ui.properties; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -20,14 +21,20 @@ public class ResourceSelectionProcessor implements SelectionProcessor tabs = new ArrayList(); - if (backend.isInstanceOf(r, sr.IndependentVariable)) - return Collections.singleton( - new ComparableTabContributor( + Collection tabs = new ArrayList(); + if (backend.isInstanceOf(r, sr.IndependentVariable)) { + tabs.add(new ComparableTabContributor( new EquationTab(), - 0, + 2, r, "Equation")); + tabs.add(new ComparableTabContributor( + new VariableInformationTab(), + 1, + r, + "Additional Information")); + return tabs; + } if (backend.isInstanceOf(r, sr.Configuration)) return Collections.singleton( new ComparableTabContributor( diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java new file mode 100644 index 00000000..8bef2975 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java @@ -0,0 +1,119 @@ +package org.simantics.sysdyn.ui.properties; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.swt.PropertyTabContributorImpl; +import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory; +import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.db.Builtins; +import org.simantics.db.management.ISessionContext; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.ui.properties.widgets.TextWidget; +import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory; + +public class VariableInformationTab extends PropertyTabContributorImpl { + + TextWidget information, rangeStart, rangeEnd, rangeStep; + + @Override + public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { + Composite composite = new Composite(body, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + Group informationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + informationGroup.setText("Information"); + GridDataFactory.fillDefaults().grab(false, true).applyTo(informationGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(informationGroup); + + information = new TextWidget(informationGroup, support, SWT.MULTI | SWT.BORDER); + information.setTextFactory(new StringPropertyFactory(context, Builtins.URIs.HasDescription)); + information.addFocusListener(new SaveListener()); + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getTextWidget()); + + + Group rangeGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); + rangeGroup.setText("Range"); + GridDataFactory.fillDefaults().applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(rangeGroup); + + Label label = new Label(rangeGroup, SWT.NONE); + label.setText("Start"); + + rangeStart = new TextWidget(rangeGroup, support, SWT.BORDER | SWT.RIGHT); + rangeStart.setTextFactory(new DoublePropertyFactory(context, SysdynResource.URIs.HasRangeStart)); + rangeStart.addFocusListener(new SaveListener()); + rangeStart.addVerifyListener(new DoubleVerify()); + + label = new Label(rangeGroup, SWT.NONE); + label.setText("End"); + + rangeEnd = new TextWidget(rangeGroup, support, SWT.BORDER | SWT.RIGHT); + rangeEnd.setTextFactory(new DoublePropertyFactory(context, SysdynResource.URIs.HasRangeEnd)); + rangeEnd.addFocusListener(new SaveListener()); + rangeEnd.addVerifyListener(new DoubleVerify()); + + label = new Label(rangeGroup, SWT.NONE); + label.setText("Step"); + + rangeStep = new TextWidget(rangeGroup, support, SWT.BORDER | SWT.RIGHT); + rangeStep.setTextFactory(new DoublePropertyFactory(context, SysdynResource.URIs.HasRangeStep)); + rangeStep.addFocusListener(new SaveListener()); + rangeStep.addVerifyListener(new DoubleVerify()); + + } + + + private class SaveListener implements FocusListener { + + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + save(); + } + + } + + private void save() { + this.information.save(); + this.rangeStart.save(); + this.rangeEnd.save(); + this.rangeStep.save(); + } + + private class DoubleVerify implements VerifyListener { + + @Override + public void verifyText(VerifyEvent e) { + e.doit = true; + for(int i = 0; i < e.text.length(); i++){ + if(!Character.isDigit(e.text.charAt(i))){ + if(e.text.charAt(i) != '.') { + e.doit = false; + break; + } else if(e.text.indexOf('.') != e.text.lastIndexOf('.')) { + e.doit = false; + break; + } else if(((Text)e.widget).getText().substring(0, e.start).contains(".") || + ((Text)e.widget).getText().substring(e.end, ((Text)e.widget).getText().length()).contains(".")) { + e.doit = false; + break; + } + } + } + } + } +}