From 7d222bdee320baf528a788dcdba9562dbdd360f5 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 30 Jul 2010 11:50:59 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16882 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../editor/participant/PointerInteractor.java | 10 ++++--- .../sysdyn/ui/elements2/ModuleFactory.java | 5 ++-- .../ui/handlers/NewModuleNodeHandler.java | 1 + .../sysdyn/ui/properties/ModuleTypeTab.java | 29 +++++++++++++++++++ .../ResourceSelectionProcessor.java | 7 +++++ sysdyn_ontologies/sysdyn.graph | 4 +-- 6 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/PointerInteractor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/PointerInteractor.java index 4bbf2ebc..f7994265 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/PointerInteractor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/PointerInteractor.java @@ -27,6 +27,7 @@ import org.simantics.g2d.diagram.participant.TerminalPainter; import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil; import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo; import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.IElementClassProvider; import org.simantics.g2d.event.MouseEvent; import org.simantics.g2d.event.EventHandlerReflection.EventHandler; @@ -79,17 +80,18 @@ public class PointerInteractor extends org.simantics.g2d.diagram.participant.poi // Pick Terminal TerminalInfo ti = pickTerminal(me.controlPosition); - if(elementClassProvider != null) { + if(ti != null && elementClassProvider != null) { - ElementClass connectionClass = null; + IElement terminalElement = ti.e; + ElementClass connectionClass = null; if( me.button == MouseEvent.LEFT_BUTTON && (me.stateMask & MouseEvent.ALT_MASK) != 0) { - if(ti.e.getElementClass().getId().equals(CloudFactory.class.getSimpleName())) return false; + if(terminalElement.getElementClass().getId().equals(CloudFactory.class.getSimpleName())) return false; diagram.setHint(DiagramHints.ROUTE_ALGORITHM, RouterFactory.create(false, false)); connectionClass = elementClassProvider.get(ConnectionClasses.DEPENDENCY); } else if (me.button == MouseEvent.RIGHT_BUTTON && (me.stateMask & MouseEvent.ALT_MASK) != 0) { - if(ti.e.getElementClass().getId().equals(AuxiliaryFactory.class.getSimpleName())) return false; + if(terminalElement.getElementClass().getId().equals(AuxiliaryFactory.class.getSimpleName())) return false; diagram.setHint(DiagramHints.ROUTE_ALGORITHM, RouterFactory.create(true, true)); connectionClass = elementClassProvider.get(ConnectionClasses.FLOW); } else { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java index b73b3f15..c542c1a2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java @@ -12,6 +12,7 @@ package org.simantics.sysdyn.ui.elements2; import java.awt.BasicStroke; +import java.awt.Font; import java.awt.geom.Rectangle2D; import java.util.Collection; @@ -44,12 +45,12 @@ public class ModuleFactory extends SysdynElementFactory { OutlinePick.INSTANCE, TextImpl.INSTANCE, TextColorImpl.BLACK, - TextFontImpl.DEFAULT, + new TextFontImpl(new Font("arial", Font.PLAIN, 25)), DefaultTransform.INSTANCE, new StaticObjectAdapter(elementType), new StaticSymbolImpl(DEFAULT_IMAGE), StaticSymbolImageInitializer.INSTANCE, - new HoverTextElementHandler(0, 0, Alignment.LEADING, 0.2f), + new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f , 7, 7, false), BoundsOutline.INSTANCE, new WholeElementTerminals(terminals) ).setId(ModuleFactory.class.getSimpleName()); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java index 5d6d72b7..1e9fdc0f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java @@ -40,6 +40,7 @@ public class NewModuleNodeHandler extends AbstractHandler { ModelingUtils mu = new ModelingUtils(g); Resource moduleType = g.newResource(); + g.claimValue(moduleType, mu.b.HasName, "New Module Type"); g.claimValue(moduleType, mu.b.HasLabel, "New Module Type"); g.claim(moduleType, mu.b.Inherits, sr.Module); g.claim(moduleType, mu.b.PartOf, model); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java new file mode 100644 index 00000000..ef019921 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java @@ -0,0 +1,29 @@ +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.widgets.Composite; +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.StringPropertyModifier; +import org.simantics.browsing.ui.swt.widgets.TrackedText; +import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.db.Builtins; +import org.simantics.db.management.ISessionContext; + +public class ModuleTypeTab extends PropertyTabContributorImpl { + + @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).numColumns(6).applyTo(composite); + TrackedText nameText = new TrackedText(composite, support, SWT.BORDER); + nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName)); + nameText.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName)); + GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget()); + } + +} 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 1ecd329c..cf6fd216 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 @@ -128,6 +128,13 @@ public class ResourceSelectionProcessor implements SelectionProcessor