oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject svn commit: r1145872 [1/4] - in /oodt/trunk/app/weditor: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/oodt/ src/main/java/org/apache/oodt/cas/ src/main/java/org/apache/oodt/cas/workflow/ src/mai...
Date Wed, 13 Jul 2011 06:09:04 GMT
Author: mattmann
Date: Wed Jul 13 06:09:02 2011
New Revision: 1145872

URL: http://svn.apache.org/viewvc?rev=1145872&view=rev
Log:
- progress towards OODT-296 Workflow Editor GUI

Added:
    oodt/trunk/app/weditor/
    oodt/trunk/app/weditor/src/
    oodt/trunk/app/weditor/src/main/
    oodt/trunk/app/weditor/src/main/java/
    oodt/trunk/app/weditor/src/main/java/org/
    oodt/trunk/app/weditor/src/main/java/org/apache/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/EditMenu.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/FileMenu.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewState.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/DefaultPropView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/DefaultTreeView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/GlobalConfigView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/GraphView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/IdentifiableEdge.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/JungJGraphModelAdapter.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/impl/TreeProjectView.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/toolbox/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/toolbox/Tool.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/toolbox/ToolBox.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/GuiUtils.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/IconLoader.java
    oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/util/Line.java
    oodt/trunk/app/weditor/src/main/resources/
    oodt/trunk/app/weditor/src/main/resources/examples/
    oodt/trunk/app/weditor/src/main/resources/examples/GranuleMaps.xml
    oodt/trunk/app/weditor/src/main/resources/examples/mspi-workflow.xml
    oodt/trunk/app/weditor/src/main/resources/examples/shared-properties.xml
    oodt/trunk/app/weditor/src/main/resources/examples/test.xml
    oodt/trunk/app/weditor/src/main/resources/icons/
    oodt/trunk/app/weditor/src/main/resources/icons/create-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/create.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/cursor-zoom.png   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/delete-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/delete.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/edit-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/edit.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/move-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/move.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/zoom-in-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/zoom-in.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/zoom-out-sel.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/icons/zoom-out.jpg   (with props)
    oodt/trunk/app/weditor/src/main/resources/logging.properties

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/WorkflowGUI.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui;
+
+//JDK imports
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JMenuBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.gui.menu.EditMenu;
+import org.apache.oodt.cas.workflow.gui.menu.FileMenu;
+import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
+import org.apache.oodt.cas.workflow.gui.model.repo.XmlWorkflowModelRepository;
+import org.apache.oodt.cas.workflow.gui.model.repo.XmlWorkflowModelRepositoryFactory;
+import org.apache.oodt.cas.workflow.gui.perspective.MultiStatePerspective;
+import org.apache.oodt.cas.workflow.gui.perspective.build.BuildPerspective;
+import org.apache.oodt.cas.workflow.gui.perspective.view.View;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
+import org.apache.oodt.cas.workflow.gui.toolbox.Tool;
+import org.apache.oodt.cas.workflow.gui.toolbox.ToolBox;
+import org.apache.oodt.cas.workflow.gui.util.IconLoader;
+
+//Commons import
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * 
+ * 
+ * Main driver shell and JFrame for the Workflow Editor GUI.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class WorkflowGUI extends JFrame {
+
+  private static final long serialVersionUID = -8217540440195126377L;
+
+  private ToolBox toolbox;
+
+  private MultiStatePerspective perspective;
+
+  private static AtomicInteger untitledIter = new AtomicInteger(0);
+
+  private JMenuBar menu;
+
+  private File workspace;
+
+  public WorkflowGUI() throws Exception {
+
+    this.addWindowFocusListener(new WindowFocusListener() {
+
+      public void windowGainedFocus(WindowEvent e) {
+        if (menu != null)
+          menu.revalidate();
+        if (toolbox != null)
+          toolbox.revalidate();
+        if (perspective != null)
+          perspective.refresh();
+      }
+
+      public void windowLostFocus(WindowEvent e) {
+      }
+
+    });
+
+    this.setLayout(new BorderLayout());
+    this.setPreferredSize(new Dimension(1000, 800));
+
+    Vector<Tool> tools = new Vector<Tool>();
+    Tool editTool = new Tool(IconLoader.getIcon(IconLoader.EDIT),
+        IconLoader.getIcon(IconLoader.EDIT_SELECTED)) {
+      private static final long serialVersionUID = 1682845263796161282L;
+
+      @Override
+      public void onClick() {
+        WorkflowGUI.this.perspective.setMode(View.Mode.EDIT);
+      }
+    };
+    tools.add(editTool);
+    Tool deleteTool = new Tool(IconLoader.getIcon(IconLoader.DELETE),
+        IconLoader.getIcon(IconLoader.DELETE_SELECTED)) {
+      private static final long serialVersionUID = 5050127713254634783L;
+
+      @Override
+      public void onClick() {
+        WorkflowGUI.this.perspective.setMode(View.Mode.DELETE);
+      }
+    };
+    tools.add(deleteTool);
+    Tool moveTool = new Tool(IconLoader.getIcon(IconLoader.MOVE),
+        IconLoader.getIcon(IconLoader.MOVE_SELECTED)) {
+      private static final long serialVersionUID = 1682845263796161282L;
+
+      @Override
+      public void onClick() {
+        WorkflowGUI.this.perspective.setMode(View.Mode.MOVE);
+      }
+    };
+    tools.add(moveTool);
+    Tool zoomInTool = new Tool(IconLoader.getIcon(IconLoader.ZOOM_IN),
+        IconLoader.getIcon(IconLoader.ZOOM_IN_SELECTED)) {
+      private static final long serialVersionUID = 1682845263796161282L;
+
+      @Override
+      public void onClick() {
+        WorkflowGUI.this.perspective.setMode(View.Mode.ZOOM_IN);
+      }
+    };
+    tools.add(zoomInTool);
+    Tool zoomOutTool = new Tool(IconLoader.getIcon(IconLoader.ZOOM_OUT),
+        IconLoader.getIcon(IconLoader.ZOOM_OUT_SELECTED)) {
+      private static final long serialVersionUID = 1682845263796161282L;
+
+      @Override
+      public void onClick() {
+        WorkflowGUI.this.perspective.setMode(View.Mode.ZOOM_OUT);
+      }
+    };
+    tools.add(zoomOutTool);
+    toolbox = new ToolBox(tools);
+    toolbox.setSelected(editTool);
+    this.add(toolbox, BorderLayout.NORTH);
+
+    this.setJMenuBar(menu = this.generateMenuBar());
+    perspective = new BuildPerspective();
+    perspective.refresh();
+    this.add(perspective, BorderLayout.CENTER);
+  }
+
+  private void updateWorkspaceText() {
+    if (this.workspace == null)
+      this.setTitle(null);
+    else
+      this.setTitle(StringUtils.leftPad("Workspace: " + this.workspace, 100));
+  }
+
+  private void loadProjects() {
+    try {
+      XmlWorkflowModelRepositoryFactory factory = new XmlWorkflowModelRepositoryFactory();
+      factory.setWorkspace(this.workspace.getAbsolutePath());
+      XmlWorkflowModelRepository repo = factory.createModelRepository();
+      repo.loadGraphs(new HashSet<String>(Arrays.asList("sequential",
+          "parallel", "task", "condition")));
+      for (File file : repo.getFiles()) {
+        List<ModelGraph> graphs = new Vector<ModelGraph>();
+        for (ModelGraph graph : repo.getGraphs())
+          if (graph.getModel().getFile().equals(file))
+            graphs.add(graph);
+        System.out.println(graphs);
+        perspective.addState(new ViewState(file, null, graphs, repo
+            .getGlobalConfigGroups()));
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  public JMenuBar generateMenuBar() {
+    JMenuBar bar = new JMenuBar();
+    FileMenu fileMenu = new FileMenu();
+    bar.add(fileMenu);
+    fileMenu.getOpenWorkspace().addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event) {
+        try {
+          JFileChooser chooser = new JFileChooser(new File(".")) {
+            boolean acceptFile(File f) {
+              return f.isDirectory();
+            }
+          };
+          chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+          int value = chooser.showOpenDialog(WorkflowGUI.this);
+          if (value == JFileChooser.APPROVE_OPTION) {
+            workspace = chooser.getSelectedFile();
+            updateWorkspaceText();
+            perspective.reset();
+            loadProjects();
+          }
+        } catch (Exception e1) {
+          e1.printStackTrace();
+        }
+      }
+    });
+    fileMenu.getImport().addActionListener(new ActionListener() {
+
+      public void actionPerformed(ActionEvent event) {
+        try {
+          if (workspace == null)
+            return;
+          JFileChooser chooser = new JFileChooser(new File("."));
+          int value = chooser.showOpenDialog(WorkflowGUI.this);
+          if (value == JFileChooser.APPROVE_OPTION) {
+            File file = chooser.getSelectedFile();
+            XmlWorkflowModelRepositoryFactory factory = new XmlWorkflowModelRepositoryFactory();
+            factory.setWorkspace(workspace.getAbsolutePath());
+            View activeView = perspective.getActiveView();
+
+            if (activeView != null) {
+              // TODO: add code for import
+            }
+          }
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+
+    });
+    fileMenu.getNewWorkspace().addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event) {
+        JFileChooser chooser = new JFileChooser(new File(".")) {
+          boolean acceptFile(File f) {
+            return f.isDirectory();
+          }
+        };
+        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+        int value = chooser.showOpenDialog(WorkflowGUI.this);
+        if (value == JFileChooser.APPROVE_OPTION) {
+          workspace = chooser.getSelectedFile();
+          updateWorkspaceText();
+          perspective.reset();
+          loadProjects();
+          perspective.refresh();
+        }
+      }
+    });
+
+    fileMenu.getNewProject().addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event) {
+        // TODO: add new project code
+      }
+    });
+    fileMenu.getSave().addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event) {
+        // TODO: add file save code
+      }
+    });
+    EditMenu editMenu = new EditMenu();
+    bar.add(editMenu);
+    editMenu.getUndo().addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent event) {
+        try {
+          perspective.undo();
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+    });
+    bar.revalidate();
+    return bar;
+  }
+
+  public static void main(String[] args) {
+    UIManager.put("TabbedPane.selected", new Color(238, 238, 238));
+    SwingUtilities.invokeLater(new Runnable() {
+      public void run() {
+        WorkflowGUI gui;
+        try {
+          gui = new WorkflowGUI();
+          gui.pack();
+          gui.setVisible(true);
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+    });
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/EditMenu.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/EditMenu.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/EditMenu.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/EditMenu.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.menu;
+
+//JDK imports
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+/**
+ * 
+ * 
+ * Edit menu driver for the Workflow Editor GUI.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class EditMenu extends JMenu {
+
+  private static final long serialVersionUID = -8368744697132421274L;
+
+  private JMenuItem undoItem;
+
+  public EditMenu() {
+    super("Edit");
+    this.add(this.undoItem = new JMenuItem("Undo"));
+  }
+
+  public JMenuItem getUndo() {
+    return this.undoItem;
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/FileMenu.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/FileMenu.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/FileMenu.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/menu/FileMenu.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.menu;
+
+//JDK imports
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+/**
+ * 
+ * 
+ * File menu driver for the Workflow Editor GUI.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class FileMenu extends JMenu {
+
+  private static final long serialVersionUID = -5702987396916441718L;
+
+  private JMenuItem newWorkspace;
+  private JMenuItem newProject;
+  private JMenuItem openWorkspace;
+  private JMenuItem importItem;
+  private JMenuItem saveItem;
+  private JMenu newMenu, openMenu, importMenu;
+
+  public FileMenu() {
+    super("File");
+    this.add(newMenu = new JMenu("New"));
+    newMenu.add(this.newWorkspace = new JMenuItem("Workspace"));
+    newMenu.add(this.newProject = new JMenuItem("Project"));
+    this.add(openMenu = new JMenu("Open"));
+    openMenu.add(this.openWorkspace = new JMenuItem("Workspace"));
+    this.add(importMenu = new JMenu("Import"));
+    importMenu.add(this.importItem = new JMenuItem("Project"));
+    this.add(this.saveItem = new JMenuItem("Save Project"));
+  }
+
+  public JMenuItem getOpenWorkspace() {
+    return this.openWorkspace;
+  }
+
+  public JMenuItem getImport() {
+    return this.importItem;
+  }
+
+  public JMenuItem getNewWorkspace() {
+    return this.newWorkspace;
+  }
+
+  public JMenuItem getNewProject() {
+    return this.newProject;
+  }
+
+  public JMenuItem getSave() {
+    return this.saveItem;
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelGraph.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,281 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.model;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
+import org.apache.oodt.cas.workflow.gui.util.GuiUtils;
+
+//JDK imports
+import java.util.List;
+import java.util.Stack;
+import java.util.Vector;
+
+/**
+ * 
+ * 
+ * The graph to display per workflow in the Workflow Editor GUI.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class ModelGraph {
+
+  private ModelGraph parent;
+  private ModelNode model;
+  private ModelGraph preConditions;
+  private Vector<ModelGraph> children;
+  private ModelGraph postConditions;
+  private boolean isPreCondition;
+  private boolean isPostCondition;
+
+  public ModelGraph(ModelNode model) {
+    this.isPreCondition = isPostCondition = false;
+    this.model = model;
+    this.children = new Vector<ModelGraph>();
+    if (this.model.isParentType())
+      this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
+  }
+
+  public void setIsRef(boolean isRef) {
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(this);
+    while (!stack.empty()) {
+      ModelGraph curGraph = stack.pop();
+      curGraph.getModel().setIsRef(isRef);
+      stack.addAll(curGraph.getChildren());
+      if (curGraph.getPreConditions() != null)
+        stack.add(curGraph.getPreConditions());
+      if (curGraph.getPostConditions() != null)
+        stack.add(curGraph.getPostConditions());
+    }
+  }
+
+  public boolean isCondition() {
+    return this.isPreCondition || this.isPostCondition;
+  }
+
+  public boolean isExcused() {
+    return this.parent != null
+        && this.parent.getModel().getExcusedSubProcessorIds()
+            .contains(this.getModel().getModelId());
+  }
+
+  public String getId() {
+    return model.getId();
+  }
+
+  public void setParent(ModelGraph parent) {
+    if (this.parent != null) {
+      if (this.isCondition() && !this.parent.isCondition()) {
+        if (this.isPreCondition)
+          this.parent.preConditions = null;
+        else
+          this.parent.postConditions = null;
+      } else {
+        this.parent.removeChild(this);
+      }
+    }
+    this.parent = parent;
+    if (!this.getModel().isRef() && parent != null && parent.getModel().isRef())
+      this.getModel().setIsRef(true);
+  }
+
+  public ModelGraph getParent() {
+    return this.parent;
+  }
+
+  public ModelGraph getRootParent() {
+    if (this.parent == null)
+      return this;
+    else
+      return this.parent.getRootParent();
+  }
+
+  public List<ModelGraph> getPathFromRootParent() {
+    Vector<ModelGraph> path = new Vector<ModelGraph>();
+    ModelGraph curGraph = this;
+    while (curGraph != null) {
+      path.add(0, curGraph);
+      curGraph = this.parent;
+    }
+    return path;
+  }
+
+  public void addChild(ModelGraph graph) {
+    if (this.children.size() == 1
+        && GuiUtils.isDummyNode(this.children.get(0).getModel()))
+      this.children.clear();
+    this.children.add(graph);
+    graph.setParent(this);
+  }
+
+  public void removeChild(ModelGraph graph) {
+    this.children.remove(graph);
+    this.getModel().getExcusedSubProcessorIds()
+        .remove(graph.getModel().getModelId());
+    graph.parent = null;
+    if (this.children.size() == 0)
+      this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
+  }
+
+  public List<ModelGraph> getChildren() {
+    if (this.getModel().isParentType() && children.size() == 0)
+      this.addChild(new ModelGraph(GuiUtils.createDummyNode()));
+    return children;
+  }
+
+  public boolean hasChildren() {
+    if (this.children.size() == 1
+        && GuiUtils.isDummyNode(this.children.get(0).getModel()))
+      return false;
+    else
+      return this.children.size() > 0;
+  }
+
+  public ModelNode getModel() {
+    return model;
+  }
+
+  public void setModel(ModelNode model) {
+    this.model = model;
+  }
+
+  public Metadata getInheritedStaticMetadata(ViewState state) {
+    Metadata m = new Metadata();
+    if (this.parent != null) {
+      m.replaceMetadata(this.parent.getInheritedStaticMetadata(state));
+      if (this.parent.getModel().getStaticMetadata() != null)
+        m.replaceMetadata(this.parent.getModel().getStaticMetadata());
+      if (this.parent.getModel().getExtendsConfig() != null)
+        for (String configGroup : this.parent.getModel().getExtendsConfig())
+          m.replaceMetadata(state.getGlobalConfigGroups().get(configGroup)
+              .getMetadata());
+    }
+    return m;
+  }
+
+  public ModelGraph getPreConditions() {
+    return preConditions;
+  }
+
+  public void setPreConditions(ModelGraph preConditions) {
+    if (this.preConditions != null)
+      this.preConditions.setParent(null);
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(preConditions);
+    while (!stack.empty()) {
+      ModelGraph graph = stack.pop();
+      graph.isPreCondition = true;
+      stack.addAll(graph.getChildren());
+    }
+    (this.preConditions = preConditions).setParent(this);
+  }
+
+  public ModelGraph getPostConditions() {
+    return postConditions;
+  }
+
+  public void setPostConditions(ModelGraph postConditions) {
+    if (this.postConditions != null)
+      this.postConditions.setParent(null);
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(postConditions);
+    while (!stack.empty()) {
+      ModelGraph graph = stack.pop();
+      graph.isPostCondition = true;
+      stack.addAll(graph.getChildren());
+    }
+    (this.postConditions = postConditions).setParent(this);
+  }
+
+  public ModelGraph recursiveFind(String id) {
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(this);
+    while (!stack.empty()) {
+      ModelGraph curGraph = stack.pop();
+      if (curGraph.getId().equals(id))
+        return curGraph;
+      stack.addAll(curGraph.getChildren());
+      if (curGraph.getPreConditions() != null)
+        stack.add(curGraph.getPreConditions());
+      if (curGraph.getPostConditions() != null)
+        stack.add(curGraph.getPostConditions());
+    }
+    return null;
+  }
+
+  public ModelGraph recursiveFindByModelId(String modelId) {
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(this);
+    while (!stack.empty()) {
+      ModelGraph curGraph = stack.pop();
+      if (curGraph.getModel().getModelId().equals(modelId))
+        return curGraph;
+      stack.addAll(curGraph.getChildren());
+      if (curGraph.getPreConditions() != null)
+        stack.add(curGraph.getPreConditions());
+      if (curGraph.getPostConditions() != null)
+        stack.add(curGraph.getPostConditions());
+    }
+    return null;
+  }
+
+  public List<ModelGraph> getLeafNodes() {
+    Vector<ModelGraph> leafNodes = new Vector<ModelGraph>();
+    Stack<ModelGraph> stack = new Stack<ModelGraph>();
+    stack.add(this);
+    while (!stack.empty()) {
+      ModelGraph curGraph = stack.pop();
+      if (curGraph.getChildren().size() == 0)
+        leafNodes.add(curGraph);
+      else
+        stack.addAll(curGraph.getChildren());
+    }
+    return leafNodes;
+  }
+
+  public int hashCode() {
+    return this.getId().hashCode();
+  }
+
+  public boolean equals(Object obj) {
+    if (obj instanceof ModelGraph)
+      return this.getId().equals(((ModelGraph) obj).getId());
+    else
+      return false;
+  }
+
+  public String toString() {
+    return this.getModel().getModelId();
+  }
+
+  public ModelGraph clone() {
+    ModelNode cloneNode = this.model.clone();
+    ModelGraph clone = new ModelGraph(cloneNode);
+    for (ModelGraph child : this.children)
+      clone.addChild(child.clone());
+    if (this.preConditions != null)
+      clone.setPreConditions(this.preConditions.clone());
+    if (this.postConditions != null)
+      clone.setPostConditions(this.postConditions.clone());
+    return clone;
+  }
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/ModelNode.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,326 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.model;
+
+//JDK imports
+import java.awt.Color;
+import java.io.File;
+import java.util.List;
+import java.util.UUID;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * 
+ * 
+ * Represents a node in the Workflow Model graph.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class ModelNode {
+
+  private String id;
+  private boolean isRef;
+  private File file;
+  private boolean textVisible;
+  private boolean entryPoint;
+  private List<String> configGroups;
+  private String executionType;
+  private String modelId;
+  private String modelName;
+  private String instanceClass;
+  private List<String> excusedSubProcessorIds;
+  private Metadata staticMetadata;
+
+  public ModelNode(File file) {
+    super();
+    this.file = file;
+    this.id = UUID.randomUUID().toString();
+    this.isRef = false;
+    this.executionType = "task";
+    this.textVisible = true;
+    this.entryPoint = false;
+    this.configGroups = new Vector<String>();
+    this.modelId = null;
+    this.modelName = null;
+    this.instanceClass = null;
+    this.excusedSubProcessorIds = new Vector<String>();
+    this.staticMetadata = new Metadata();
+  }
+
+  public ModelNode(File file, String modelId) {
+    this(file);
+    this.setModelId(modelId);
+    this.setModelName(modelId);
+  }
+
+  public ModelNode(File file, String modelId, boolean isRef) {
+    this(file, modelId);
+    this.isRef = isRef;
+  }
+
+  public String getId() {
+    return this.id;
+  }
+
+  public void setIsRef(boolean isRef) {
+    this.isRef = isRef;
+  }
+
+  public boolean isRef() {
+    return this.isRef;
+  }
+
+  public File getFile() {
+    return this.file;
+  }
+
+  public void setExtendsConfig(List<String> configGroups) {
+    this.configGroups.clear();
+    this.configGroups.addAll(configGroups);
+  }
+
+  public List<String> getExtendsConfig() {
+    return this.configGroups;
+  }
+
+  public void setTextVisible(boolean textVisible) {
+    this.textVisible = textVisible;
+  }
+
+  public void setEntryPoint(boolean entryPoint) {
+    this.entryPoint = entryPoint;
+  }
+
+  public boolean isEntryPoint() {
+    return this.entryPoint;
+  }
+
+  public boolean isParentType() {
+    return !(this.getExecutionType().equals("task") || this.getExecutionType()
+        .equals("condition"));
+  }
+
+  public Color getColor() {
+    if (this.isParentType()) {
+      if (this.getExecutionType().equals("sequential"))
+        return new Color(100, 149, 237);
+      else if (this.getExecutionType().equals("parallel"))
+        return new Color(143, 188, 143);
+      else
+        return Color.darkGray;
+    } else {
+      if (this.getExecutionType().equals("task"))
+        return Color.orange;
+      else
+        return Color.cyan;
+    }
+  }
+
+  public Color getGradientColor() {
+    if (this.isParentType()) {
+      if (this.getExecutionType().equals("sequential"))
+        return new Color(200, 200, 200);
+      else if (this.getExecutionType().equals("parallel"))
+        return new Color(200, 200, 200);
+      else
+        return Color.white;
+    } else {
+      return Color.darkGray;
+    }
+  }
+
+  public String getModelId() {
+    return modelId;
+  }
+
+  public String getModelName() {
+    if (modelName == null) {
+      return modelId;
+    } else {
+      return modelName;
+    }
+  }
+
+  public String getExecutionType() {
+    return executionType;
+  }
+
+  public String getInstanceClass() {
+    return instanceClass;
+  }
+
+  public List<String> getExcusedSubProcessorIds() {
+    if (this.excusedSubProcessorIds == null)
+      this.excusedSubProcessorIds = new Vector<String>();
+    return this.excusedSubProcessorIds;
+  }
+
+  public Metadata getStaticMetadata() {
+    return staticMetadata != null ? this.staticMetadata
+        : (this.staticMetadata = new Metadata());
+  }
+
+  public int hashCode() {
+    return this.getId().hashCode();
+  }
+
+  public boolean equals(Object obj) {
+    if (obj instanceof ModelNode)
+      return this.getId().equals(((ModelNode) obj).getId());
+    else
+      return false;
+  }
+
+  public String toString() {
+    if (this.textVisible) {
+      if (this.isParentType())
+        return this.getModelName() + " : " + this.getExecutionType();
+      else
+        return this.getModelName();
+    } else {
+      return null;
+    }
+  }
+
+  public ModelNode clone() {
+    ModelNode clone = new ModelNode(this.file);
+    clone.id = this.id;
+    if (this.excusedSubProcessorIds != null)
+      clone.excusedSubProcessorIds = new Vector<String>(
+          this.excusedSubProcessorIds);
+    clone.executionType = this.executionType;
+    clone.instanceClass = this.instanceClass;
+    clone.modelId = this.modelId;
+    clone.modelName = this.modelName;
+    clone.staticMetadata = null;
+    clone.textVisible = this.textVisible;
+    if (this.staticMetadata != null)
+      clone.staticMetadata = new Metadata(this.staticMetadata);
+    return clone;
+  }
+
+  /**
+   * @param modelId
+   *          the modelId to set
+   */
+  public void setModelId(String modelId) {
+    this.modelId = modelId;
+  }
+
+  /**
+   * @param modelName
+   *          the modelName to set
+   */
+  public void setModelName(String modelName) {
+    this.modelName = modelName;
+  }
+
+  /**
+   * @param instanceClass
+   *          the instanceClass to set
+   */
+  public void setInstanceClass(String instanceClass) {
+    this.instanceClass = instanceClass;
+  }
+
+  /**
+   * @param excusedSubProcessorIds
+   *          the excusedSubProcessorIds to set
+   */
+  public void setExcusedSubProcessorIds(List<String> excusedSubProcessorIds) {
+    this.excusedSubProcessorIds = excusedSubProcessorIds;
+  }
+
+
+
+  /**
+   * @return the configGroups
+   */
+  public List<String> getConfigGroups() {
+    return configGroups;
+  }
+
+
+
+  /**
+   * @param configGroups the configGroups to set
+   */
+  public void setConfigGroups(List<String> configGroups) {
+    this.configGroups = configGroups;
+  }
+
+
+
+  /**
+   * @return the textVisible
+   */
+  public boolean isTextVisible() {
+    return textVisible;
+  }
+
+
+
+  /**
+   * @param id the id to set
+   */
+  public void setId(String id) {
+    this.id = id;
+  }
+
+
+
+  /**
+   * @param isRef the isRef to set
+   */
+  public void setRef(boolean isRef) {
+    this.isRef = isRef;
+  }
+
+
+
+  /**
+   * @param file the file to set
+   */
+  public void setFile(File file) {
+    this.file = file;
+  }
+
+
+
+  /**
+   * @param executionType the executionType to set
+   */
+  public void setExecutionType(String executionType) {
+    this.executionType = executionType;
+  }
+
+
+
+  /**
+   * @param staticMetadata the staticMetadata to set
+   */
+  public void setStaticMetadata(Metadata staticMetadata) {
+    this.staticMetadata = staticMetadata;
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepository.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,413 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.model.repo;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
+import org.apache.oodt.cas.workflow.gui.model.ModelNode;
+
+//JDK imports
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Vector;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+import org.apache.commons.io.FileUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * 
+ * Model Repository which stores models in xml files
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class XmlWorkflowModelRepository {
+
+  private File workspace;
+  private List<File> files;
+  private Set<ModelGraph> graphs;
+  private Map<String, ConfigGroup> globalConfigGroups;
+
+  public XmlWorkflowModelRepository(File workspace) {
+    this.files = new Vector<File>();
+    for (File file : (this.workspace = workspace).listFiles())
+      if (!file.isDirectory())
+        this.files.add(file);
+  }
+
+  public void loadGraphs(Set<String> supportedProcessorIds) throws Exception {
+    this.graphs = new HashSet<ModelGraph>();
+    HashMap<String, ConfigGroup> globalConfGroups = new HashMap<String, ConfigGroup>();
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    factory.setNamespaceAware(true);
+    DocumentBuilder parser = factory.newDocumentBuilder();
+    List<FileBasedElement> rootElements = new Vector<FileBasedElement>();
+    for (File file : files) {
+      System.out.println("Loading: " + file);
+      rootElements.add(new FileBasedElement(file, parser.parse(file)
+          .getDocumentElement()));
+    }
+    for (FileBasedElement root : rootElements) {
+      loadConfiguration(rootElements, root, null, globalConfGroups);
+      NodeList rootChildren = root.getElement().getChildNodes();
+      for (int i = 0; i < rootChildren.getLength(); i++)
+        if (rootChildren.item(i).getNodeType() == Node.ELEMENT_NODE
+            && !rootChildren.item(i).getNodeName().equals("configuration")) {
+          ModelGraph graph = this.loadGraph(rootElements, new FileBasedElement(
+              root.getFile(), (Element) rootChildren.item(i)), new Metadata(),
+              globalConfGroups, supportedProcessorIds);
+          this.graphs.add(graph);
+        }
+    }
+    insureUniqueIds(graphs);
+    this.globalConfigGroups = globalConfGroups;
+    System.out.println(this.globalConfigGroups.keySet());
+  }
+
+  public Set<ModelGraph> getGraphs() {
+    return this.graphs;
+  }
+
+  public Map<String, ConfigGroup> getGlobalConfigGroups() {
+    return this.globalConfigGroups;
+  }
+
+  public List<File> getFiles() {
+    return this.files;
+  }
+
+  public void save(List<ModelGraph> graphs,
+      Map<String, Metadata> globalConfigGroups) throws Exception {
+    this.backupCurrentFiles();
+  }
+
+  private void backupCurrentFiles() throws Exception {
+    File backupDir = new File(this.workspace, ".backup");
+    for (File file : this.files) {
+      FileUtils.copyFile(file, new File(backupDir, file.getName()));
+      file.delete();
+    }
+    this.files.clear();
+  }
+
+  private void insureUniqueIds(Set<ModelGraph> graphs) {
+    for (ModelGraph graph : graphs) {
+      HashSet<String> names = new HashSet<String>();
+      Vector<ModelGraph> stack = new Vector<ModelGraph>();
+      stack.add(graph);
+      while (!stack.isEmpty()) {
+        ModelGraph currentGraph = stack.remove(0);
+        String currentId = currentGraph.getId();
+        for (int i = 1; names.contains(currentId); i++)
+          currentId = currentGraph.getId() + "-" + i;
+        names.add(currentId);
+        if (!currentId.equals(currentGraph.getId()))
+          currentGraph.getModel().setModelId(currentId);
+        stack.addAll(currentGraph.getChildren());
+      }
+    }
+  }
+
+  private ModelGraph loadGraph(List<FileBasedElement> rootElements,
+      FileBasedElement workflowNode, Metadata staticMetadata,
+      HashMap<String, ConfigGroup> globalConfGroups,
+      Set<String> supportedProcessorIds) throws Exception {
+    String modelIdRef = null;
+    String modelId = null;
+    String modelName = null;
+    String alias = null;
+    String executionType = null;
+    List<String> excused = new Vector<String>();
+    String clazz = null;
+    boolean entryPoint = false;
+
+    NamedNodeMap attributes = workflowNode.getElement().getAttributes();
+    for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
+      Node node = workflowNode.getElement().getAttributes().item(i);
+      if (node.getNodeName().equals("id")) {
+        modelId = node.getNodeValue();
+      } else if (node.getNodeName().equals("name")) {
+        modelName = node.getNodeValue();
+      } else if (node.getNodeName().equals("class")) {
+        clazz = node.getNodeValue();
+      } else if (node.getNodeName().equals("id-ref")) {
+        modelIdRef = node.getNodeValue();
+      } else if (node.getNodeName().equals("excused")) {
+        excused.addAll(Arrays.asList(node.getNodeValue().split(",")));
+      } else if (node.getNodeName().equals("entryPoint")) {
+        entryPoint = Boolean.parseBoolean(node.getNodeValue());
+      } else if (node.getNodeName().equals("alias")) {
+        alias = node.getNodeValue();
+      } else if (node.getNodeName().equals("execution")) {
+        executionType = node.getNodeValue();
+      } else if (node.getNodeName().startsWith("p:")) {
+        staticMetadata.replaceMetadata(node.getNodeName().substring(2),
+            node.getNodeValue());
+      }
+    }
+
+    if (modelId == null && modelIdRef == null)
+      modelId = UUID.randomUUID().toString();
+
+    ModelGraph graph = null;
+    if (modelId != null) {
+
+      if (workflowNode.getElement().getNodeName().equals("workflow")
+          || workflowNode.getElement().getNodeName().equals("conditions")) {
+        if (executionType == null)
+          throw new Exception("workflow model '"
+              + workflowNode.getElement().getNodeName()
+              + "' missing execution type");
+      } else {
+        executionType = workflowNode.getElement().getNodeName();
+      }
+
+      if (!supportedProcessorIds.contains(executionType))
+        throw new Exception("Unsupported execution type id '" + executionType
+            + "'");
+
+      ModelNode modelNode = new ModelNode(workflowNode.getFile());
+      modelNode.setModelId(modelId);
+      modelNode.setModelName(modelName);
+      modelNode.setExecutionType(executionType);
+      modelNode.setStaticMetadata(staticMetadata);
+      modelNode.setExcusedSubProcessorIds(excused);
+      modelNode.setInstanceClass(clazz);
+      modelNode.setEntryPoint(entryPoint);
+
+      loadConfiguration(rootElements, workflowNode, modelNode, globalConfGroups);
+
+      graph = new ModelGraph(modelNode);
+
+      boolean loadedPreConditions = false;
+      NodeList children = workflowNode.getElement().getChildNodes();
+      for (int i = 0; i < children.getLength(); i++) {
+        Node curChild = children.item(i);
+        if (curChild.getNodeType() == Node.ELEMENT_NODE) {
+          if (curChild.getNodeName().equals("conditions")) {
+            boolean isPreCondition = !loadedPreConditions;
+            String type = ((Element) curChild).getAttribute("type");
+            if (type.length() > 0)
+              isPreCondition = type.toLowerCase().equals("pre");
+            if (isPreCondition)
+              graph.setPreConditions(this.loadGraph(rootElements,
+                  new FileBasedElement(workflowNode.getFile(),
+                      (Element) curChild), new Metadata(staticMetadata),
+                  globalConfGroups, supportedProcessorIds));
+            else
+              graph.setPostConditions(this.loadGraph(rootElements,
+                  new FileBasedElement(workflowNode.getFile(),
+                      (Element) curChild), new Metadata(staticMetadata),
+                  globalConfGroups, supportedProcessorIds));
+            loadedPreConditions = true;
+          } else if (!curChild.getNodeName().equals("configuration")) {
+            graph.addChild(this.loadGraph(rootElements, new FileBasedElement(
+                workflowNode.getFile(), (Element) curChild), new Metadata(
+                staticMetadata), globalConfGroups, supportedProcessorIds));
+          }
+        }
+      }
+
+    } else if (modelIdRef != null) {
+      graph = this.findGraph(rootElements, modelIdRef, new Metadata(
+          staticMetadata), globalConfGroups, supportedProcessorIds);
+      if (graph == null)
+        throw new Exception("Workflow '" + modelIdRef
+            + "' has not been defined in this context");
+      graph.setIsRef(true);
+      graph.getModel().setStaticMetadata(new Metadata());
+      loadConfiguration(rootElements, workflowNode, graph.getModel(),
+          globalConfGroups);
+      if (alias != null)
+        graph.getModel().setModelId(alias);
+    }
+
+    if (entryPoint && graph.getParent() != null) {
+      this.graphs.add(graph);
+    }
+
+    return graph;
+  }
+
+  protected ModelGraph findGraph(List<FileBasedElement> rootElements,
+      String modelIdRef, Metadata staticMetadata,
+      HashMap<String, ConfigGroup> globalConfGroups,
+      Set<String> supportedProcessorIds) throws Exception {
+    XPath xpath = XPathFactory.newInstance().newXPath();
+    XPathExpression expr = xpath.compile("//*[@id = '" + modelIdRef + "']");
+    for (FileBasedElement rootElement : rootElements) {
+      Node node = (Node) expr.evaluate(rootElement.getElement(),
+          XPathConstants.NODE);
+      if (node != null) {
+        return this.loadGraph(rootElements,
+            new FileBasedElement(rootElement.getFile(), (Element) node),
+            staticMetadata, globalConfGroups, supportedProcessorIds);
+      }
+    }
+    return null;
+  }
+
+  private void loadConfiguration(List<FileBasedElement> rootElements,
+      FileBasedElement workflowNode, ModelNode modelNode,
+      HashMap<String, ConfigGroup> globalConfGroups) throws Exception {
+    NodeList children = workflowNode.getElement().getChildNodes();
+    for (int i = 0; i < children.getLength(); i++) {
+      Node curChild = children.item(i);
+      if (curChild.getNodeName().equals("configuration")) {
+        Metadata curMetadata = new Metadata();
+        if (modelNode != null
+            && !((Element) curChild).getAttribute("extends").equals(""))
+          modelNode.setExtendsConfig(Arrays.asList(((Element) curChild)
+              .getAttribute("extends").split(",")));
+        curMetadata.replaceMetadata(this.loadConfiguration(rootElements,
+            curChild, globalConfGroups));
+        if (!((Element) curChild).getAttribute("name").equals("")) {
+          ConfigGroup configGroup = new ConfigGroup(
+              ((Element) curChild).getAttribute("name"), curMetadata);
+          if (modelNode != null) {
+            List<String> extendsConfig = new Vector<String>(
+                modelNode.getExtendsConfig());
+            configGroup.addAllExtends(extendsConfig);
+            extendsConfig.add(configGroup.getName());
+            modelNode.setExtendsConfig(extendsConfig);
+          }
+          globalConfGroups.put(((Element) curChild).getAttribute("name"),
+              configGroup);
+        } else if (modelNode != null) {
+          modelNode.setStaticMetadata(curMetadata);
+        }
+      }
+    }
+  }
+
+  private Metadata loadConfiguration(List<FileBasedElement> rootElements,
+      Node configNode, HashMap<String, ConfigGroup> globalConfGroups)
+      throws Exception {
+    Metadata curMetadata = new Metadata();
+    NodeList curGrandChildren = configNode.getChildNodes();
+    for (int k = 0; k < curGrandChildren.getLength(); k++) {
+      if (curGrandChildren.item(k).getNodeName().equals("property")) {
+        Element property = (Element) curGrandChildren.item(k);
+        String delim = property.getAttribute("delim");
+        String envReplace = property.getAttribute("envReplace");
+        String name = property.getAttribute("name");
+        String value = property.getAttribute("value");
+        if (Boolean.parseBoolean(envReplace))
+          curMetadata.replaceMetadata(name + "/envReplace", "true");
+        List<String> values = new Vector<String>();
+        if (delim.length() > 0)
+          values.addAll(Arrays.asList(value.split("\\" + delim)));
+        else
+          values.add(value);
+        curMetadata.replaceMetadata(name, values);
+      }
+    }
+    return curMetadata;
+  }
+
+  private class FileBasedElement {
+
+    private File file;
+    private Element element;
+
+    public FileBasedElement(File file, Element element) {
+      this.file = file;
+      this.element = element;
+    }
+
+    public File getFile() {
+      return this.file;
+    }
+
+    public Element getElement() {
+      return this.element;
+    }
+
+  }
+
+  public class ConfigGroup {
+
+    private String name;
+    private Metadata metadata;
+    private List<String> extendsConfig;
+
+    public ConfigGroup(String name, Metadata metadata) {
+      this.name = name;
+      this.metadata = metadata;
+      this.extendsConfig = new Vector<String>();
+    }
+
+    public String getName() {
+      return this.name;
+    }
+
+    public Metadata getMetadata() {
+      return this.metadata;
+    }
+
+    public void addExtends(String child) {
+      this.extendsConfig.add(child);
+    }
+
+    public void addAllExtends(List<String> children) {
+      this.extendsConfig.addAll(children);
+    }
+
+    public void removeExtends(String child) {
+      this.extendsConfig.remove(child);
+    }
+
+    public List<String> getExtends() {
+      return this.extendsConfig;
+    }
+
+    public int hashCode() {
+      return this.name.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+      if (obj instanceof ConfigGroup) {
+        ConfigGroup comp = (ConfigGroup) obj;
+        return comp.name.equals(this.name);
+      } else
+        return false;
+    }
+
+    public String toString() {
+      return this.name;
+    }
+
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/model/repo/XmlWorkflowModelRepositoryFactory.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.model.repo;
+
+//JDK imports
+import java.io.File;
+
+/**
+ * 
+ * Factory for creating xml model repositories
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class XmlWorkflowModelRepositoryFactory {
+
+  private String workspace;
+
+  public XmlWorkflowModelRepository createModelRepository() {
+    if (workspace == null)
+      return null;
+    if (!new File(workspace).exists())
+      new File(workspace).mkdirs();
+    return new XmlWorkflowModelRepository(new File(workspace));
+  }
+
+  public void setWorkspace(String workspace) {
+    this.workspace = workspace;
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/MultiStatePerspective.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective;
+
+//JDK imports
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
+import org.apache.oodt.cas.workflow.gui.perspective.view.View.Mode;
+
+/**
+ * 
+ * A multi-state display perspective.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public abstract class MultiStatePerspective extends Perspective {
+
+  private static final long serialVersionUID = -6410768713084872977L;
+
+  private final Map<String, ViewState> states = new HashMap<String, ViewState>();
+
+  private Mode mode;
+
+  public MultiStatePerspective(String name) {
+    super(name);
+    this.mode = Mode.EDIT;
+  }
+
+  public void addState(ViewState state) {
+    this.setState(state);
+  }
+
+  public void setState(ViewState state) {
+    super.setState(state);
+    state.setMode(this.mode);
+    if (!this.states.containsKey(state.getId())) {
+      this.states.put(state.getId(), state);
+      this.handleAddState(state);
+    }
+  }
+
+  public void removeState(ViewState state) {
+    this.states.remove(state);
+    this.handleRemoveState(state);
+    super.setState(this.getActiveState());
+  }
+
+  public ViewState getState(String stateId) {
+    return this.states.get(stateId);
+  }
+
+  public List<ViewState> getStates() {
+    return new Vector<ViewState>(this.states.values());
+  }
+
+  public Set<String> getStateIds() {
+    return this.states.keySet();
+  }
+
+  public void setMode(Mode mode) {
+    this.mode = mode;
+    for (ViewState state : states.values())
+      state.setMode(mode);
+    this.refresh();
+  }
+
+  public void reset() {
+    super.reset();
+    this.mode = Mode.EDIT;
+    states.clear();
+  }
+
+  public abstract void handleAddState(ViewState state);
+
+  public abstract void handleRemoveState(ViewState state);
+
+  public abstract ViewState getActiveState();
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/Perspective.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective;
+
+//JDK imports
+import javax.swing.JPanel;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.gui.perspective.view.View;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewListener;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
+import org.apache.oodt.cas.workflow.gui.perspective.view.View.Mode;
+
+/**
+ * 
+ * 
+ * A view listener and jpanel for keeping the Workflow perspective in sync.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public abstract class Perspective extends JPanel implements ViewListener {
+
+  private static final long serialVersionUID = -3343805159396435882L;
+
+  private ViewState state;
+  private String name;
+
+  public Perspective(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  public ViewState getState() {
+    return this.state;
+  }
+
+  public void setState(ViewState state) {
+    this.state = state;
+  }
+
+  public void setMode(Mode mode) {
+    this.state.setMode(mode);
+    this.refresh();
+  }
+
+  public void save() {
+    if (this.state != null)
+      this.state.save();
+  }
+
+  public void undo() {
+    if (this.state != null) {
+      this.state.undo();
+      this.refresh();
+    }
+  }
+
+  public void reset() {
+    this.state = null;
+  }
+
+  public abstract void refresh();
+
+  public abstract View getActiveView();
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/build/BuildPerspective.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,425 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective.build;
+
+//JDK imports
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
+import org.apache.oodt.cas.workflow.gui.perspective.MultiStatePerspective;
+import org.apache.oodt.cas.workflow.gui.perspective.view.MultiStateView;
+import org.apache.oodt.cas.workflow.gui.perspective.view.View;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewChange;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewListener;
+import org.apache.oodt.cas.workflow.gui.perspective.view.ViewState;
+import org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView;
+import org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView;
+import org.apache.oodt.cas.workflow.gui.perspective.view.impl.GlobalConfigView;
+import org.apache.oodt.cas.workflow.gui.perspective.view.impl.GraphView;
+import org.apache.oodt.cas.workflow.gui.perspective.view.impl.TreeProjectView;
+import org.apache.oodt.cas.workflow.gui.util.GuiUtils;
+
+/**
+ * 
+ * The default build perspective.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public class BuildPerspective extends MultiStatePerspective {
+
+  private static final long serialVersionUID = 3387632819576057527L;
+
+  private View projectView;
+  private View globalConfigView;
+  private Class<? extends View> projectViewClass;
+  private Class<? extends View> mainViewClass;
+  private Class<? extends View> treeViewClass;
+  private Class<? extends View> propViewClass;
+  private Class<? extends View> globalViewClass;
+
+  private HashMap<ViewState, BuildPanel> stateViews;
+  private ViewState activeState;
+
+  public static final int MAIN_VIEW = 1;
+
+  private static final int WIDTH = 1000;
+  private static final int HEIGHT = 700;
+
+  private JSplitPane projectSplitPane;
+
+  private boolean findSelectedInTab = false;
+
+  public BuildPerspective() throws InstantiationException,
+      IllegalAccessException {
+    this(TreeProjectView.class, GraphView.class, DefaultTreeView.class,
+        DefaultPropView.class, GlobalConfigView.class);
+  }
+
+  public BuildPerspective(Class<? extends View> projectViewClass,
+      Class<? extends View> mainViewClass, Class<? extends View> treeViewClass,
+      Class<? extends View> propViewClass, Class<? extends View> globalViewClass)
+      throws InstantiationException, IllegalAccessException {
+    super("Build");
+    this.projectViewClass = projectViewClass;
+    this.mainViewClass = mainViewClass;
+    this.treeViewClass = treeViewClass;
+    this.propViewClass = propViewClass;
+    this.globalViewClass = globalViewClass;
+    this.stateViews = new HashMap<ViewState, BuildPanel>();
+    this.projectView = this.createProjectView();
+    this.projectView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
+    this.globalConfigView = this.createGlobalConfigView();
+    this.globalConfigView
+        .setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
+  }
+
+  public void reset() {
+    super.reset();
+    this.activeState = null;
+    this.stateViews.clear();
+    this.projectView = this.createProjectView();
+    this.globalConfigView = this.createGlobalConfigView();
+  }
+
+  public void stateChangeNotify(ViewChange<?> change) {
+    if (change instanceof ViewChange.NEW_ACTIVE_STATE) {
+      this.activeState = ((ViewChange.NEW_ACTIVE_STATE) change).getObject();
+      this.refresh();
+    } else if (change instanceof ViewChange.REFRESH_VIEW) {
+      this.refresh();
+    } else if (change instanceof ViewChange.STATE_NAME_CHANGE) {
+      ViewState state = ((ViewChange.STATE_NAME_CHANGE) change).getObject();
+      this.refresh();
+    } else if (change instanceof ViewChange.VIEW_MODEL) {
+      String modelId = ((ViewChange.VIEW_MODEL) change).getObject();
+      for (ViewState state : this.stateViews.keySet()) {
+        for (ModelGraph graph : state.getGraphs()) {
+          ModelGraph found = graph.recursiveFindByModelId(modelId);
+          if (found != null && !found.getModel().isRef()) {
+            this.activeState = state;
+            this.activeState.setSelected(found);
+            break;
+          }
+        }
+      }
+      this.findSelectedInTab = true;
+      this.refresh();
+      this.findSelectedInTab = false;
+    }
+  }
+
+  @Override
+  public ViewState getActiveState() {
+    return this.activeState;
+  }
+
+  public View getActiveView() {
+    if (this.getActiveState() != null)
+      return this.stateViews.get(this.getActiveState()).getActiveView();
+    else
+      return null;
+  }
+
+  @Override
+  public void handleAddState(final ViewState state) {
+    this.activeState = state;
+    BuildPanel buildPanel = new BuildPanel(state);
+    this.stateViews.put(state, buildPanel);
+    this.refresh();
+  }
+
+  @Override
+  public void handleRemoveState(ViewState state) {
+    this.stateViews.remove(state);
+    if (this.stateViews.size() > 0)
+      this.activeState = this.stateViews.keySet().iterator().next();
+    else
+      this.activeState = null;
+    this.refresh();
+  }
+
+  @Override
+  public void refresh() {
+    this.save();
+    this.removeAll();
+    this.setLayout(new BorderLayout());
+    JPanel panel = null;
+    if (this.activeState != null) {
+      BuildPanel buildPanel = this.stateViews.get(this.activeState);
+      buildPanel.refresh();
+      panel = buildPanel;
+    } else {
+      panel = new JPanel();
+    }
+
+    if (this.projectView instanceof MultiStateView)
+      ((MultiStateView) this.projectView).refreshView(this.activeState,
+          this.getStates());
+    else
+      this.projectView.refreshView(this.activeState);
+
+    this.globalConfigView.refreshView(this.activeState);
+
+    JPanel globalPanel = new JPanel();
+    globalPanel.setLayout(new BorderLayout());
+    globalPanel.add(this.projectView, BorderLayout.CENTER);
+    globalPanel.add(this.globalConfigView, BorderLayout.SOUTH);
+
+    int dividerLocation = -1;
+    if (projectSplitPane != null)
+      dividerLocation = projectSplitPane.getDividerLocation();
+    projectSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, globalPanel,
+        panel);
+    if (dividerLocation != -1)
+      projectSplitPane.setDividerLocation(dividerLocation);
+    this.add(projectSplitPane, BorderLayout.CENTER);
+
+    this.revalidate();
+
+  }
+
+  private View createMainView(String name) {
+    try {
+      return this.mainViewClass.getConstructor(String.class).newInstance(name);
+    } catch (Exception e) {
+      e.printStackTrace();
+      return null;
+    }
+  }
+
+  private View createTreeView() {
+    try {
+      return this.treeViewClass.getConstructor(String.class).newInstance(
+          this.treeViewClass.getSimpleName());
+    } catch (Exception e) {
+      e.printStackTrace();
+      return null;
+    }
+  }
+
+  private View createGlobalConfigView() {
+    try {
+      return this.globalViewClass.getConstructor(String.class).newInstance(
+          this.globalViewClass.getSimpleName());
+    } catch (Exception e) {
+      e.printStackTrace();
+      return null;
+    }
+  }
+
+  private View createProjectView() {
+    try {
+      View view = this.projectViewClass.getConstructor(String.class)
+          .newInstance(this.projectViewClass.getSimpleName());
+      view.registerListener(this);
+      return view;
+    } catch (Exception e) {
+      e.printStackTrace();
+      return null;
+    }
+  }
+
+  private View createPropView() {
+    try {
+      return this.propViewClass.getConstructor(String.class).newInstance(
+          this.propViewClass.getSimpleName());
+    } catch (Exception e) {
+      e.printStackTrace();
+      return null;
+    }
+  }
+
+  private class BuildPanel extends JPanel implements ViewListener {
+
+    private static final long serialVersionUID = -6120047959962567963L;
+
+    private JTabbedPane tabbedPane;
+    private Map<View, ViewState> mainViews;
+    private View propView;
+    private View treeView;
+
+    private View primaryMainView;
+
+    private JPopupMenu closeTabPopup;
+
+    private ViewState state;
+
+    public BuildPanel(ViewState state) {
+      this.state = state;
+
+      mainViews = new HashMap<View, ViewState>();
+
+      propView = createPropView();
+      propView.registerListener(this);
+
+      treeView = createTreeView();
+      treeView.registerListener(this);
+
+      tabbedPane = new JTabbedPane();
+
+      this.addMainView(createMainView(state.getFile().getName()), state);
+
+      closeTabPopup = new JPopupMenu();
+      JMenuItem closeItem = new JMenuItem("Close");
+      closeItem.addActionListener(new ActionListener() {
+
+        public void actionPerformed(ActionEvent e) {
+          View mainView = (View) BuildPanel.this.tabbedPane
+              .getSelectedComponent();
+          BuildPanel.this.removeMainView(mainView);
+        }
+
+      });
+      closeTabPopup.add(closeItem);
+
+      this.tabbedPane.addMouseListener(new MouseListener() {
+
+        public void mouseClicked(MouseEvent e) {
+          if (e.getButton() == MouseEvent.BUTTON3
+              && !BuildPanel.this.tabbedPane.getSelectedComponent().equals(
+                  BuildPanel.this.primaryMainView)) {
+            closeTabPopup.show(BuildPanel.this.tabbedPane, e.getX(), e.getY());
+          }
+        }
+
+        public void mouseEntered(MouseEvent e) {
+        }
+
+        public void mouseExited(MouseEvent e) {
+        }
+
+        public void mousePressed(MouseEvent e) {
+        }
+
+        public void mouseReleased(MouseEvent e) {
+        }
+
+      });
+
+      this.tabbedPane.addChangeListener(new ChangeListener() {
+
+        public void stateChanged(ChangeEvent e) {
+          View activeView = (View) BuildPanel.this.tabbedPane
+              .getSelectedComponent();
+          activeView.notifyListeners();
+        }
+
+      });
+
+      treeView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
+      propView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));
+      JSplitPane treePropPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+          treeView, propView);
+      treePropPane.setResizeWeight(.25);
+      tabbedPane.setPreferredSize(new Dimension(WIDTH, HEIGHT));
+      JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+          tabbedPane, treePropPane);
+      mainSplitPane.setResizeWeight(.75);
+      this.setLayout(new BorderLayout());
+      this.add(mainSplitPane, BorderLayout.CENTER);
+    }
+
+    public void addMainView(View mainView, ViewState state) {
+      if (this.mainViews.size() == 0) {
+        this.primaryMainView = mainView;
+        mainView.setPrimary(true);
+      }
+      this.mainViews.put(mainView, state);
+      this.tabbedPane.addTab(mainView.getName(), mainView);
+      this.tabbedPane.setSelectedComponent(mainView);
+      mainView.registerListener(this);
+    }
+
+    public void removeMainView(View mainView) {
+      if (!this.primaryMainView.equals(mainView)) {
+        for (int i = 0; i < this.tabbedPane.getTabCount(); i++) {
+          if (mainView.getName().equals(this.tabbedPane.getTitleAt(i))) {
+            this.tabbedPane.removeTabAt(i);
+            this.mainViews.remove(mainView);
+            return;
+          }
+        }
+      }
+    }
+
+    public View getActiveView() {
+      return (View) this.tabbedPane.getSelectedComponent();
+    }
+
+    public void refresh() {
+      if (this.getActiveView() != null) {
+        ViewState viewState = null;
+        if (this.state.getSelected() != null && findSelectedInTab) {
+          TOP: for (Entry<View, ViewState> entry : this.mainViews.entrySet()) {
+            for (ModelGraph graph : entry.getValue().getGraphs()) {
+              ModelGraph found = graph.recursiveFindByModelId(this.state
+                  .getSelected().getModel().getModelId());
+              if (found != null && !found.getModel().isRef()) {
+                viewState = entry.getValue();
+                viewState.setSelected(found);
+                this.tabbedPane.setSelectedComponent(entry.getKey());
+                break TOP;
+              }
+            }
+          }
+        } else {
+          viewState = this.mainViews.get(this.getActiveView());
+        }
+        this.getActiveView().refreshView(viewState);
+        this.propView.refreshView(viewState);
+        this.treeView.refreshView(viewState);
+      }
+      this.revalidate();
+    }
+
+    public void stateChangeNotify(ViewChange<?> change) {
+      if (change instanceof ViewChange.NEW_VIEW) {
+        this.addMainView(
+            createMainView(((ViewChange.NEW_VIEW) change).getObject()
+                .getModel().getModelId()),
+            new ViewState(this.state.getFile(), null, Collections
+                .singletonList(GuiUtils.find(this.state.getGraphs(),
+                    ((ViewChange.NEW_VIEW) change).getObject().getModel()
+                        .getId())), this.state.getGlobalConfigGroups()));
+        this.refresh();
+      }
+      BuildPerspective.this.stateChangeNotify(change);
+    }
+
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/MultiStateView.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective.view;
+
+//JDK imports
+import java.util.List;
+
+/**
+ * 
+ * A multi-state view.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public abstract class MultiStateView extends View {
+
+  public MultiStateView(String name) {
+    super(name);
+  }
+
+  private static final long serialVersionUID = -6968627851727698540L;
+
+  public void refreshView(ViewState state) {
+    throw new RuntimeException(
+        "This is a mutli-state view -- call multi-state view refreshView method!");
+  }
+
+  public abstract void refreshView(ViewState activeState, List<ViewState> states);
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/View.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective.view;
+
+//JDK imports
+import java.util.UUID;
+import java.util.Vector;
+import javax.swing.JPanel;
+
+/**
+ * 
+ * 
+ * View abstract base class.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public abstract class View extends JPanel {
+
+  private static final long serialVersionUID = -708692459667309413L;
+
+  public enum Mode {
+    DELETE, EDIT, MOVE, ZOOM_IN, ZOOM_OUT;
+  }
+
+  private Vector<ViewListener> listeners;
+  private String id;
+  private boolean isPrimary;
+
+  public static final String DISPLAY_GRAPH_IDS = "DisplayGraphIds";
+
+  public View(String name) {
+    super();
+    this.id = UUID.randomUUID().toString();
+    if (name != null)
+      this.setName(name);
+    this.listeners = new Vector<ViewListener>();
+  }
+
+  public void setPrimary(boolean isPrimary) {
+    this.isPrimary = isPrimary;
+  }
+
+  public boolean isPrimary() {
+    return this.isPrimary;
+  }
+
+  public String getId() {
+    return this.id;
+  }
+
+  public void registerListener(ViewListener listener) {
+    listeners.add(listener);
+  }
+
+  public void deregisterListener(ViewListener listener) {
+    this.listeners.remove(listener);
+  }
+
+  public void notifyListeners(ViewChange<?> change) {
+    for (ViewListener listener : listeners)
+      listener.stateChangeNotify(change);
+  }
+
+  public void notifyListeners() {
+    this.notifyListeners(new ViewChange.REFRESH_VIEW(this, this));
+  }
+
+  public int hashCode() {
+    return this.id.hashCode();
+  }
+
+  public boolean equals(Object obj) {
+    return obj instanceof View && ((View) obj).id.equals(this.id);
+  }
+
+  public abstract void refreshView(ViewState state);
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewChange.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective.view;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.gui.model.ModelGraph;
+
+/**
+ * 
+ * Represents a change in the Workflow GUI model view.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public abstract class ViewChange<T> {
+
+  private T object;
+  private View source;
+
+  protected ViewChange(T object, View source) {
+    this.object = object;
+    this.source = source;
+  }
+
+  public T getObject() {
+    return this.object;
+  }
+
+  public View getSource() {
+    return this.source;
+  }
+
+  public static final class NEW_VIEW extends ViewChange<ModelGraph> {
+    public NEW_VIEW(ModelGraph object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class DELETE_VIEW extends ViewChange<View> {
+    public DELETE_VIEW(View object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class REFRESH_VIEW extends ViewChange<View> {
+    public REFRESH_VIEW(View object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class NEW_STATE extends ViewChange<ViewState> {
+    public NEW_STATE(ViewState object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class REMOVE_STATE extends ViewChange<ViewState> {
+    public REMOVE_STATE(ViewState object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class NEW_ACTIVE_STATE extends ViewChange<ViewState> {
+    public NEW_ACTIVE_STATE(ViewState object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class STATE_NAME_CHANGE extends ViewChange<ViewState> {
+    public STATE_NAME_CHANGE(ViewState object, View source) {
+      super(object, source);
+    }
+  }
+
+  public static final class VIEW_MODEL extends ViewChange<String> {
+    public VIEW_MODEL(String modelId, View source) {
+      super(modelId, source);
+    }
+  }
+
+}

Added: oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java
URL: http://svn.apache.org/viewvc/oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java?rev=1145872&view=auto
==============================================================================
--- oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java (added)
+++ oodt/trunk/app/weditor/src/main/java/org/apache/oodt/cas/workflow/gui/perspective/view/ViewListener.java Wed Jul 13 06:09:02 2011
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.gui.perspective.view;
+
+/**
+ * 
+ * Interface for listening/notifying about Workflow View state changes.
+ * 
+ * @author bfoster
+ * @author mattmann
+ * 
+ */
+public interface ViewListener {
+
+  public void stateChangeNotify(ViewChange<?> change);
+
+}



Mime
View raw message