Class InterfaceProject

java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.projects.InterfaceProject
All Implemented Interfaces:
java.lang.Cloneable, AttributeListener, AttributeObject, InterfaceObject, PopupMenuObject, NamedObject, TreeObject, CleanableObject, XMLObject, IconObject

public class InterfaceProject
extends AbstractInterfaceObject
implements AttributeListener, AttributeObject, IconObject, PopupMenuObject, java.lang.Cloneable, XMLObject
Represents a modelGUI project, which specifies an organizational structure for persistent data related to a common project.

See http://mgui.wikidot.com/projects for details.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Constructor Details

    • InterfaceProject

      public InterfaceProject()
    • InterfaceProject

      public InterfaceProject​(java.lang.String name, java.io.File root, java.lang.String project_dir, java.lang.String instance_dir, boolean create_dirs) throws ProjectIOException
      Throws:
      ProjectIOException
  • Method Details

    • init

      protected void init()
    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Returns:
    • getProjectDir

      public java.lang.String getProjectDir()
    • setProjectDir

      public boolean setProjectDir​(java.lang.String dir)
    • getInstance

      public ProjectInstance getInstance​(int index)
    • getInstance

      public ProjectInstance getInstance​(java.lang.String name)
    • getInstanceDir

      public java.lang.String getInstanceDir()
    • setInstanceDir

      public boolean setInstanceDir​(java.lang.String dir)
    • getInstancePrefix

      public java.lang.String getInstancePrefix()
    • setInstancePrefix

      public void setInstancePrefix​(java.lang.String prefix)
    • getInstanceSuffix

      public java.lang.String getInstanceSuffix()
    • setInstanceSuffix

      public void setInstanceSuffix​(java.lang.String suffix)
    • setName

      public void setName​(java.lang.String name)
      Description copied from interface: NamedObject
      Sets the name for this object.
      Specified by:
      setName in interface NamedObject
      Overrides:
      setName in class AbstractInterfaceObject
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Overrides:
      getName in class AbstractInterfaceObject
      Returns:
    • hasInstances

      public boolean hasInstances()
    • hasInstances

      public void hasInstances​(boolean b)
    • getInstances

      public java.util.ArrayList<ProjectInstance> getInstances()
      Returns a (copied) array of the instances in this project
      Returns:
    • getSubdirs

      public java.util.ArrayList<ProjectDirectory> getSubdirs()
    • setRootDir

      public boolean setRootDir​(java.io.File file)
    • getRootDir

      public java.io.File getRootDir()
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Description copied from interface: AttributeListener
      Called when an Attribute's value has been updated.
      Specified by:
      attributeUpdated in interface AttributeListener
    • getTreeLabel

      public java.lang.String getTreeLabel()
      Description copied from interface: TreeObject
      Returns the label text to appear in a tree node.
      Specified by:
      getTreeLabel in interface TreeObject
      Overrides:
      getTreeLabel in class AbstractInterfaceObject
      Returns:
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode node)
      Description copied from interface: TreeObject
      Sets the children for this node's InterfaceTreeNode.
      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class AbstractInterfaceObject
    • getInstanceNames

      public java.util.ArrayList<java.lang.String> getInstanceNames()
    • applyInstances

      public boolean applyInstances​(boolean remove)
    • applySubdirs

      public boolean applySubdirs​(boolean remove)
    • getAllSubdirectories

      public java.util.ArrayList<ProjectDirectory> getAllSubdirectories()
      Returns a list of all directories and their subdirectories contained in this project.
      Returns:
      All subdirectories and their subdirectories, etc., contained in this project
    • getAllSubdirectories

      protected java.util.ArrayList<ProjectDirectory> getAllSubdirectories​(java.util.ArrayList<ProjectDirectory> dirs)
      Returns a list of all directories and their subdirectories contained in this list of directories. Can be used recursively.
      Parameters:
      dirs - The list of directories
      Returns:
      All subdirectories and their subdirectories, etc., contained in this list
    • updateFileSystem

      public boolean updateFileSystem​(boolean remove)
    • setInstancesFromNames

      public void setInstancesFromNames​(java.util.ArrayList<java.lang.String> names)
    • setInstances

      public void setInstances​(java.util.ArrayList<ProjectInstance> instances)
    • setInstances

      public void setInstances()
    • getAbsoluteInstanceDir

      protected java.io.File getAbsoluteInstanceDir()
    • setSubdirs

      public void setSubdirs()
    • setSubdirectoriesFromPaths

      public void setSubdirectoriesFromPaths​(java.util.ArrayList<java.lang.String> paths)
    • setSubdirectories

      public void setSubdirectories​(java.util.ArrayList<ProjectDirectory> paths)
      Sets the subdirectory list from a list of paths.
      Parameters:
      paths -
    • setFromProject

      public void setFromProject​(InterfaceProject project)
      Sets this project from another project. Destroys the current state of the project.
      Parameters:
      project -
    • getAttribute

      public Attribute<?> getAttribute​(java.lang.String attrName)
      Description copied from interface: AttributeObject
      Returns a specific attribute for this object.
      Specified by:
      getAttribute in interface AttributeObject
      Returns:
    • getAttributeValue

      public java.lang.Object getAttributeValue​(java.lang.String name)
      Description copied from interface: AttributeObject
      Gets the value of attribute name, or null if it does not exist.
      Specified by:
      getAttributeValue in interface AttributeObject
      Parameters:
      name - Name of the attribute
      Returns:
      the value of attribute name, or null if it does not exist
    • getAttributes

      public AttributeList getAttributes()
      Description copied from interface: AttributeObject
      Returns the list of current attributes for this object.
      Specified by:
      getAttributes in interface AttributeObject
      Returns:
    • setAttribute

      public void setAttribute​(java.lang.String attrName, java.lang.Object newValue)
      Description copied from interface: AttributeObject
      Sets a value for a specific attribute.
      Specified by:
      setAttribute in interface AttributeObject
    • setAttributes

      public void setAttributes​(AttributeList thisList)
      Description copied from interface: AttributeObject
      Sets the list of attributes for this object.
      Specified by:
      setAttributes in interface AttributeObject
    • loadDataInstance

      public java.lang.Object loadDataInstance​(java.lang.String instance, ProjectDataItem item, ProgressUpdater progress) throws java.io.IOException
      Attempts to load a data instance with the given data item specification.
      Parameters:
      instance -
      item -
      progress -
      Returns:
      Throws:
      ProjectIOException - If load operation failed
      java.io.IOException
    • loadDataInstance

      public java.lang.Object loadDataInstance​(java.lang.String instance, java.lang.Integer series, ProjectDataItem item, ProgressUpdater progress) throws java.io.IOException
      Attempts to load a data instance with the given data item specification.
      Parameters:
      instance -
      series -
      item -
      progress -
      Returns:
      Throws:
      ProjectIOException - If load operation failed
      java.io.IOException
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu​(java.util.List<java.lang.Object> selected)
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object. Allows an associated list of objects to be passed as an argument.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
    • showPopupMenu

      public void showPopupMenu​(java.awt.event.MouseEvent e)
      Description copied from interface: PopupMenuObject
      Shows a popup menu at the point of the given MouseEvent.
      Specified by:
      showPopupMenu in interface PopupMenuObject
    • clone

      public java.lang.Object clone()
      Overrides:
      clone in class java.lang.Object
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML​(int tab)
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
      Throws:
      org.xml.sax.SAXException
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
      Throws:
      org.xml.sax.SAXException
    • handleXMLString

      public void handleXMLString​(java.lang.String s) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
      Throws:
      org.xml.sax.SAXException
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns: