xpdlviewcontroller.java

来自「jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用」· Java 代码 · 共 177 行

JAVA
177
字号
package org.enhydra.jawe.components.xpdlview;import java.util.List;import java.util.Observable;import java.util.Observer;import org.enhydra.jawe.JaWEComponent;import org.enhydra.jawe.JaWEComponentSettings;import org.enhydra.jawe.JaWEComponentView;import org.enhydra.jawe.JaWEManager;import org.enhydra.jawe.XPDLElementChangeInfo;import org.enhydra.shark.xpdl.XMLCollection;import org.enhydra.shark.xpdl.XMLElement;import org.enhydra.shark.xpdl.XMLElementChangeInfo;import org.enhydra.shark.xpdl.XMLUtil;import org.enhydra.shark.xpdl.elements.Package;/** *  Used to handle process graphs. * *  @author Sasa Bojanic */public class XPDLViewController implements Observer, JaWEComponent {      protected String type = JaWEComponent.MAIN_COMPONENT;   protected boolean updateInProgress=false;      protected XPDLViewControllerPanel panel;      protected XPDLViewSettings settings;   public XPDLViewController(JaWEComponentSettings settings)  throws Exception {      this.settings = (XPDLViewSettings) settings;      this.settings.init(this);      init();      JaWEManager.getInstance().getJaWEController().addObserver(this);   }         // ********************** Observer      public void update(Observable o, Object arg) {      if (!(arg instanceof XPDLElementChangeInfo)) return;      XPDLElementChangeInfo info=(XPDLElementChangeInfo)arg;      int action=info.getAction();      if (!(action == XMLElementChangeInfo.UPDATED ||            action == XMLElementChangeInfo.INSERTED ||            action == XMLElementChangeInfo.REMOVED ||            action == XMLElementChangeInfo.REPOSITIONED ||            action == XPDLElementChangeInfo.SELECTED ||            action == XPDLElementChangeInfo.UNDOABLE_ACTION_ENDED ||            action == XPDLElementChangeInfo.UNDO ||            action == XPDLElementChangeInfo.REDO))          return;                  long start=System.currentTimeMillis();      JaWEManager.getInstance().getLoggingManager().info("XPDLViewController -> update for event "+info+" started ...");      if (action==XPDLElementChangeInfo.UNDOABLE_ACTION_ENDED ||            action==XPDLElementChangeInfo.UNDO ||            action==XPDLElementChangeInfo.REDO) {         panel.setSelectedElement(null);      } else {         update(info);      }      JaWEManager.getInstance().getLoggingManager().info("XPDLViewController -> update ended");      long end=System.currentTimeMillis();      double diffs=(end-start)/1000.0;      JaWEManager.getInstance().getLoggingManager().debug("THE UPDATE OF XPDL COMPONENT LASTED FOR "+diffs+" SECONDS!");   }      // **********************         // ********************** JaWEComponent      public JaWEComponentSettings getSettings() {      return settings;   }      public JaWEComponentView getView () {      return panel;   }   public String getName () {      return "XPDLComponent";   }      public String getType() {      return type;   }      public void setType(String type) {      this.type = type;    }      public boolean adjustXPDL (Package pkg) {      return false;   }   public List checkValidity (XMLElement el,boolean fullCheck) {      return null;   }      public boolean canCreateElement(XMLCollection col) {      return true;   }   public boolean canInsertElement(XMLCollection col, XMLElement el) {      return true;   }   public boolean canModifyElement(XMLElement el) {      return true;   }   public boolean canRemoveElement(XMLCollection col, XMLElement el) {      return true;   }   public boolean canDuplicateElement(XMLCollection col, XMLElement el) {      return true;   }   public boolean canRepositionElement(XMLCollection col, XMLElement el) {      return true;   }   // **********************            protected void init () {      // creating special items and buttons      panel=createPanel();   }      protected XPDLViewControllerPanel createPanel () {      XPDLViewControllerPanel p=new XPDLViewControllerPanel (this);      p.configure();      p.init();      return p;   }      public void update (XPDLElementChangeInfo info) {      if (updateInProgress) return;      if (info.getSource()==this) return;      updateInProgress=true;      try {         int action=info.getAction();         if (action==XMLElementChangeInfo.REMOVED) {            panel.setSelectedElement(null);            return;         }         XMLElement curSelEl=panel.getSelectedElement();         XMLElement toSelect;         if (settings.showXPDLDetails())            toSelect=info.getChangedElement();         else            toSelect = XMLUtil.getPackage(info.getChangedElement());         if (!(action==XPDLElementChangeInfo.SELECTED || (curSelEl==toSelect && action==XMLElementChangeInfo.UPDATED))) {            toSelect=null;         }         if (curSelEl!=toSelect || action==XMLElementChangeInfo.UPDATED) {            panel.setSelectedElement(toSelect);         }      } finally {         updateInProgress=false;      }   }      public XPDLViewSettings getXPDLViewSettings() {      return settings;   }   public void setUpdateInProgress(boolean inProgress) {      updateInProgress=true;   }      public boolean isUpdateInProgress() {      return updateInProgress;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?