Class MainFrame

All Implemented Interfaces:
DropTargetListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, UndoableEditListener, RootPaneContainer, WindowConstants, IOManager.IOManagerListener, PluginManagerListener, ViewManager.ViewManagerListener, SelectionListener, SessionListener, SessionManager

public class MainFrame
extends JFrame
implements SessionManager, SessionListener, PluginManagerListener, UndoableEditListener, IOManager.IOManagerListener, ViewManager.ViewManagerListener, SelectionListener, DropTargetListener
Constructs a new graffiti frame, which contains the main gui components.
Version:
$Revision: 1.164.2.2 $
See Also:
Serialized Form
Recent revisions:
2.7.0
  • Field Details

    • PREFERRED_INTERNALFRAME_SIZE

      public static final Dimension PREFERRED_INTERNALFRAME_SIZE
      The size of an internal frame for first displaying.
    • blockUpdates

      public static boolean blockUpdates
    • fileClose

      public GraffitiAction fileClose
      The main frame's static actions
    • sidepanel

      public JComponent sidepanel
    • cancelledSaveAction

      public AtomicBoolean cancelledSaveAction
      Set, when external dialog's been cancelled, to restore flow.
    • SIZE_WIDTH

      static final int SIZE_WIDTH
      The default width of the main frame.
      See Also:
      Constant Field Values
    • SIZE_HEIGHT

      static final int SIZE_HEIGHT
      The default height of the main frame.
      See Also:
      Constant Field Values
    • VERT_SPLITTER

      static final int VERT_SPLITTER
      The number of pixels for the vertical splitter's divider location.
      See Also:
      Constant Field Values
  • Constructor Details

    • MainFrame

      public MainFrame()
    • MainFrame

      public MainFrame​(PluginManager pluginmgr, Preferences prefs)
      Constructs a new MainFrame.
      Parameters:
      pluginmgr - DOCUMENT ME!
      prefs - DOCUMENT ME!
    • MainFrame

      public MainFrame​(PluginManager pluginmgr, Preferences prefs, JPanel progressPanel, boolean showVantedHelp)
      Constructs a new MainFrame.
      Parameters:
      pluginmgr - DOCUMENT ME!
      prefs - DOCUMENT ME!
  • Method Details

    • setTitle

      public void setTitle​(String title)
      Overrides:
      setTitle in class Frame
    • getHideDeactivateSwitch

      public static MainFrame.HideOrDeactivateMenu getHideDeactivateSwitch()
    • setHideDeactivateSwitch

      public static void setHideDeactivateSwitch​(MainFrame.HideOrDeactivateMenu hideDeactivateSwitch)
    • getActiveEditorSession

      public EditorSession getActiveEditorSession()
      Returns the current active editor session.
      Returns:
      the current active editor session.
    • getActiveSession

      public Session getActiveSession()
      Returns the current active session.
      Specified by:
      getActiveSession in interface SessionManager
      Returns:
      the current active session.
    • setActiveSession

      public void setActiveSession​(Session s, View targetView)
      Sets the current active session.
      Parameters:
      s - The session to be activated.
    • getDefaultView

      public String getDefaultView()
      Returns the defaultView.
      Returns:
      String
    • getAttributeComponentManager

      public AttributeComponentManager getAttributeComponentManager()
      Returns:
      the global Attribute Component Manager
      Since:
      2.7.0
    • getEditComponentManager

      public EditComponentManager getEditComponentManager()
      DOCUMENT ME!
      Returns:
      the global Edit Component Manager
    • getIoManager

      public IOManager getIoManager()
      DOCUMENT ME!
      Returns:
      the global IO Manager
    • getPluginManager

      public PluginManager getPluginManager()
      DOCUMENT ME!
      Returns:
      the global Plugin Manager
    • isSessionActive

      public boolean isSessionActive()
      Returns true, if a session is active.
      Specified by:
      isSessionActive in interface SessionManager
      Returns:
      DOCUMENT ME!
    • getSessionManager

      public SessionManager getSessionManager()
      DOCUMENT ME!
      Returns:
      the global Session Manager
    • getSessions

      public static Set<Session> getSessions()
    • getEditorSessions

      public static Set<EditorSession> getEditorSessions()
    • getSessionsIterator

      public Iterator<Session> getSessionsIterator()
      Returns an iterator over all sessions.
      Specified by:
      getSessionsIterator in interface SessionManager
      Returns:
      an iterator over all sessions.
      See Also:
      Session
    • getUndoSupport

      public UndoableEditSupport getUndoSupport()
      Returns the class for undoSupport.
      Returns:
      the class for undoSupport.
    • getViewManager

      public ViewManager getViewManager()
      Returns the viewManager.
      Returns:
      ViewManager
    • addSelectionListener

      public void addSelectionListener​(SelectionListener sl)
      Adds a SelectionListener.
      Parameters:
      sl - DOCUMENT ME!
    • removeSession

      public void removeSession​(Session s)
      Removes the session from the list of sessions.
      Parameters:
      s - the session to remove.
      Since:
      2.7.0
    • addSession

      public void addSession​(Session s)
      Adds the given session to the list of sessions.
      Specified by:
      addSession in interface SessionManager
      Parameters:
      s - the new session to add.
    • addSessionListener

      public void addSessionListener​(SessionListener sl)
      Adds a SessionListener.
      Specified by:
      addSessionListener in interface SessionManager
      Parameters:
      sl - DOCUMENT ME!
    • addViewListener

      public void addViewListener​(ViewListener vl)
    • createInternalFrame

      public JScrollPane createInternalFrame​(String viewName, String newFrameTitle, boolean returnScrollpane, boolean otherViewWillBeClosed)
      Creates and adds a new internal frame to the desktop within an existing session.
      Parameters:
      viewName - a name of the new view
      newFrameTitle - the title for the frame, if null or the empty String no title will be set.
      returnScrollpane - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • createInternalFrame

      public JScrollPane createInternalFrame​(String viewName, String newFrameTitle, EditorSession session, boolean returnScrollpane, boolean otherViewWillBeClosed, ConfigureViewAction c)
    • createInternalFrame

      public Object createInternalFrame​(String viewName, String newFrameTitle, EditorSession session, boolean returnScrollPane, boolean returnGraffitiFrame, boolean otherViewWillBeClosed)
    • createInternalFrame

      public Object createInternalFrame​(String viewName, String newFrameTitle, EditorSession session, boolean returnScrollPane, boolean returnGraffitiFrame, boolean otherViewWillBeClosed, ConfigureViewAction configNewView, boolean addViewToEditorSession)
      Creates and adds a new internal frame to the desktop within a new session.
      Parameters:
      viewName - a name of the new view
      newFrameTitle - the title for the frame, if null or the empty String no title will be set.
      session - a new session.
      returnScrollPane - A scrollpane or a graffitiinternalframe
      Returns:
      DOCUMENT ME!
      Throws:
      RuntimeException - DOCUMENT ME!
    • createNewSession

      public EditorSession createNewSession()
      Creates and returns a new editor session.
      Returns:
      New session
    • createNewSession

      public EditorSession createNewSession​(Graph g)
    • fireSessionChanged

      public void fireSessionChanged​(Session session)
      Informs all SessionListeners that the active session has changed.
      Parameters:
      session - DOCUMENT ME!
    • fireSelectionChanged

      public void fireSelectionChanged​(EditorSession session)
    • fireSessionDataChanged

      public void fireSessionDataChanged​(Session session)
      Called, if the session or data (except graph data) in the session have been changed.
      Specified by:
      fireSessionDataChanged in interface SessionManager
      Parameters:
      session - DOCUMENT ME!
    • inputSerializerAdded

      public void inputSerializerAdded​(InputSerializer is)
      Description copied from interface: IOManager.IOManagerListener
      Called, if an input serializer is added to the io manager.
      Specified by:
      inputSerializerAdded in interface IOManager.IOManagerListener
      Parameters:
      is - the input serializer, which was added to the manager.
    • loadGraph

      public Graph loadGraph​(String fileName, URL url)
      Loads a graph from a file;
      Parameters:
      file - File containing the graph;
    • getGraph

      public Graph getGraph​(String fileName, URL url)
    • loadGraphInBackground

      public void loadGraphInBackground​(File file, ActionEvent ae, boolean autoSwitch) throws IllegalAccessException, InstantiationException
      Loads a graph in the background (using a background thread). During loading a progress bar is shown. Do not use this command if you want to work with a given graph after loading a file. The graph will not be completely loaded or shown after this method returns. Instead the graph will be shown as soon as the file loading is finished.
      Parameters:
      file - or url
      Throws:
      IllegalAccessException
      InstantiationException
    • loadGraphInBackground

      public void loadGraphInBackground​(File[] proposedFiles, ActionEvent ae, boolean autoSwitch) throws IllegalAccessException, InstantiationException
      Throws:
      IllegalAccessException
      InstantiationException
    • addNewRecentFileMenuItem

      public void addNewRecentFileMenuItem​(File file)
    • loadGraph

      public void loadGraph​(File file)
      Loads a graph from a file;
      Parameters:
      file - File containing the graph;
    • getGraph

      public Graph getGraph​(File file) throws Exception
      Throws:
      Exception
    • getGraph

      public Graph getGraph​(IOurl url) throws Exception
      Throws:
      Exception
    • getGraph

      public Graph getGraph​(IOurl url, String fileName) throws Exception
      Will not be able to read cluster information (in separate file) for ".net" files and .gz-files
      Parameters:
      inps -
      fileName -
      Returns:
      Throws:
      Exception
    • isInputSerializerKnown

      public boolean isInputSerializerKnown​(File file)
    • saveGraphAs

      public void saveGraphAs​(Graph graph, String fileName, String fileTypeDescription) throws Exception
      Throws:
      Exception
    • showGraph

      public void showGraph​(Graph g, ActionEvent e)
    • showGraph

      public void showGraph​(Graph g, ActionEvent e, LoadSetting interaction)
    • outputSerializerAdded

      public void outputSerializerAdded​(OutputSerializer os)
      Description copied from interface: IOManager.IOManagerListener
      Called, if an output serializer ist added to the io manager.
      Specified by:
      outputSerializerAdded in interface IOManager.IOManagerListener
      Parameters:
      os - the output serializer, which was added to the manager.
    • pluginAdded

      public void pluginAdded​(GenericPlugin plugin, PluginDescription desc)
      Called by the plugin manager, iff a plugin has been added.
      Specified by:
      pluginAdded in interface PluginManagerListener
      Parameters:
      plugin - the added plugin.
      desc - the description of the new plugin.
    • getInspectorPlugin

      public InspectorPlugin getInspectorPlugin()
    • addMenuItemForAlgorithmOrExtension

      public JMenu addMenuItemForAlgorithmOrExtension​(JMenuItem item, String cat)
      Adds a menu item to the menu given a category The menuitem's action should be a GraffitiAction with the implemented Action that is called, when the user clicks on that menu item The category string defines the place, where this item is places The category string is a '.'-separated string, where each token represents a parental level of the items path e.g. cat="New.Random" would put the menuitem 'item' in the submenu Random under New
      Parameters:
      action -
      cat -
    • getJMenuBar

      public JMenuBar getJMenuBar()
      Overrides:
      getJMenuBar in class JFrame
    • removeSelectionListener

      public void removeSelectionListener​(SelectionListener sl)
      Removes a SelectionListener.
      Parameters:
      sl - DOCUMENT ME!
    • saveActiveFileAs

      public void saveActiveFileAs()
    • saveActiveFile

      public void saveActiveFile()
    • promptClosing

      public boolean promptClosing​(Session session)
      This delegates the session closing down below the method chain, given the user has not chosen 'Cancel'. In this case it simply returns. Used for processing the closing of the external GraffitiFrame, encapsulating the above mentioned goals.

      Code originates from the closeSession() method. Now there is placed only a method call instead.

      Parameters:
      session - current active Session
      Returns:
      true if the frame should be closed.
    • closeSession

      public boolean closeSession​(Session session)
      Closes all views of the given session and removes the session from the list of sessions.
      Specified by:
      closeSession in interface SessionManager
      Parameters:
      session - the session to be removed.
      Returns:
      true if the session has been closed
    • removeSessionListener

      public void removeSessionListener​(SessionListener sl)
      Removes a SessionListener.
      Specified by:
      removeSessionListener in interface SessionManager
      Parameters:
      sl - DOCUMENT ME!
    • sessionChanged

      public void sessionChanged​(Session s)
      Invoked when the session changed.
      Specified by:
      sessionChanged in interface SessionListener
      Parameters:
      s - the new session.
    • sessionDataChanged

      public void sessionDataChanged​(Session s)
      Invoked when the session data changed.
      Specified by:
      sessionDataChanged in interface SessionListener
      Parameters:
      s - DOCUMENT ME!
    • showMessage

      public static void showMessage​(String message, MessageType type)
      Method showMesssage displays a message on GUI components according to the specified type. The message will be displayed for some defined number of seconds. This method can be called from a background thread.
      Parameters:
      message - a message string to be displayed
      type - a type of the message (e.g. MessageType.INFO)
    • showMessage

      public static void showMessage​(String message, MessageType type, int timeMillis)
      Method showMesssage displays a message on GUI components according to the specified type for the given interval. This method is thread safe.
      Parameters:
      message - a message string to be displayed
      type - a type of the message (e.g. ERROR)
      timeMillis - number of milliseconds the message should be displayed
    • showViewChooserDialog

      public JScrollPane showViewChooserDialog​(boolean returnScrollpane, boolean useDefaultViewForSmallGraphs, ActionEvent ae)
      Method showViewChooserDialog invokes a view chooser dialog for choosing view types. The parameter withNewSession specifies whether the new view starts within an existing session or within a new session.
      Parameters:
      returnScrollpane - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • showViewChooserDialog

      public JScrollPane showViewChooserDialog​(EditorSession session, boolean returnScrollPane, ActionEvent e)
    • showViewChooserDialog

      public JScrollPane showViewChooserDialog​(EditorSession session, boolean returnScrollPane, ActionEvent e, LoadSetting interaction)
    • showViewChooserDialog

      public JScrollPane showViewChooserDialog​(EditorSession session, boolean returnScrollPane, ActionEvent e, LoadSetting interaction, ConfigureViewAction configNewView)
      Method showViewChooserDialog invokes a view chooser dialog for choosing view types. The parameter withNewSession specifies whether the new view starts within an existing session or within a new session.
      Parameters:
      session - the session in which to open the new view.
      returnScrollPane - DOCUMENT ME!
      e -
      interaction -
      Returns:
      DOCUMENT ME!
    • undoableEditHappened

      public void undoableEditHappened​(UndoableEditEvent e)
      This method is called when an undoableEdit happened.
      Specified by:
      undoableEditHappened in interface UndoableEditListener
      See Also:
      UndoableEditListener
    • updateActions

      public void updateActions()
      Updates the state of the actions.
    • viewTypeAdded

      public void viewTypeAdded​(String viewType)
      Description copied from interface: ViewManager.ViewManagerListener
      Called, if a new view type is added to view manager.
      Specified by:
      viewTypeAdded in interface ViewManager.ViewManagerListener
      Parameters:
      viewType - the type of the new view.
    • showMessageDialog

      public void showMessageDialog​(String msg)
      Shows an arbitrary message dialog.
      Parameters:
      msg - the message to be shown.
    • setGUIcomponent

      public void setGUIcomponent​(String id, JComponent o)
    • showMessageDialog

      public static void showMessageDialog​(String msg, String title)
      Shows an arbitrary message dialog.
      Parameters:
      msg - the message to be shown.
    • showMessageDialogWithScrollBars

      public static void showMessageDialogWithScrollBars​(String msg, String title)
    • showMessageDialogWithScrollBars2

      public static void showMessageDialogWithScrollBars2​(String msg, String title)
    • getInstance

      public static MainFrame getInstance()
    • installDragNDropForGraphFiles

      public void installDragNDropForGraphFiles​(JButton target)
    • closeGravisto

      public void closeGravisto()
    • addStatusPanel

      public void addStatusPanel​(JPanel panel)
      Parameters:
      panel - A status panel that will be shown in the progress area. A timer calls isVisible to this panel. If it is not visible any more, it will be removed from the status area.
    • selectionChanged

      public void selectionChanged​(SelectionEvent e)
      Description copied from interface: SelectionListener
      Is called, if something in the selection model changed.
      Specified by:
      selectionChanged in interface SelectionListener
    • selectionListChanged

      public void selectionListChanged​(SelectionEvent e)
      Description copied from interface: SelectionListener
      Is called, if a named selection is added or removed.
      Specified by:
      selectionListChanged in interface SelectionListener
    • getDetachedFrames

      public GraffitiFrame[] getDetachedFrames()
    • addDetachedFrame

      public void addDetachedFrame​(GraffitiFrame frame)
    • removeDetachedFrame

      public void removeDetachedFrame​(GraffitiFrame frame)
    • getActiveDetachedFrame

      public GraffitiFrame getActiveDetachedFrame()
    • getRelativeCenterPosition

      public static Rectangle getRelativeCenterPosition​(JDialog md)
    • dragEnter

      public void dragEnter​(DropTargetDragEvent dtde)
      Specified by:
      dragEnter in interface DropTargetListener
    • dragOver

      public void dragOver​(DropTargetDragEvent dtde)
      Specified by:
      dragOver in interface DropTargetListener
    • dropActionChanged

      public void dropActionChanged​(DropTargetDragEvent dtde)
      Specified by:
      dropActionChanged in interface DropTargetListener
    • dragExit

      public void dragExit​(DropTargetEvent dte)
      Specified by:
      dragExit in interface DropTargetListener
    • drop

      public void drop​(DropTargetDropEvent e)
      Specified by:
      drop in interface DropTargetListener
    • showMessageDialog

      public static void showMessageDialog​(String title, JComponent comp)
    • showMessageDialogPlain

      public static void showMessageDialogPlain​(String title, JComponent comp)
    • showMessageWindowUpdate

      public static void showMessageWindowUpdate​(JFrame jf, String title, JComponent jc)
    • showMessageWindow

      public static JFrame showMessageWindow​(String title, JComponent jc)
    • showMessageWindow

      public static JFrame showMessageWindow​(String title, JComponent jc, boolean show)
    • isTaskPanelVisible

      public boolean isTaskPanelVisible​(String string)
    • lookUpAndSwitchToNamedSession

      public boolean lookUpAndSwitchToNamedSession​(String fileName)
    • lookUpSession

      public EditorSession lookUpSession​(Graph g, boolean createIfNotFound)
    • lookUpNamedSession

      public EditorSession lookUpNamedSession​(String fileName)
    • getActionManager

      public URLattributeActionManager getActionManager()
    • frameClosing

      public void frameClosing​(EditorSession session, View view)
    • setVisible

      public void setVisible​(boolean b)
      Overrides:
      setVisible in class Window
    • createExternalFrame

      public View createExternalFrame​(String viewClassName, EditorSession session, boolean otherViewWillBeClosed, boolean fullscreen, int x, int y, int w, int h)
    • createExternalFrame

      public View createExternalFrame​(String viewClassName, String framename, EditorSession session, boolean otherViewWillBeClosed, boolean fullscreen, int x, int y, int w, int h)
    • createInternalFrame

      public View createInternalFrame​(String viewClassName, EditorSession session, boolean otherViewWillBeClosed)
    • createInternalFrame

      public View createInternalFrame​(String viewClassName, String newFrameTitle, EditorSession session, boolean otherViewWillBeClosed)
    • showAndHighlightSidePanelSubTab

      public void showAndHighlightSidePanelSubTab​(String tabtitle, String subtabtitle)
    • showAndHighlightSidePanelTab

      public void showAndHighlightSidePanelTab​(String title, boolean cycle)
    • setSidePanel

      public void setSidePanel​(JToolBar component, int width)
    • setSidePanel

      public void setSidePanel​(int width)
    • warnUserAboutFileSaveProblem

      public void warnUserAboutFileSaveProblem​(Exception ioe)
    • getDesktop

      public JDesktopPane getDesktop()
    • isViewProvidingToolbar

      public static boolean isViewProvidingToolbar​(View view)
    • getEditorSessionForGraph

      public Session getEditorSessionForGraph​(Graph graph)
      Parameters:
      graph -
      Returns:
    • getNumberOfOpenSessions

      public int getNumberOfOpenSessions()
    • isGraphLoadingInProgress

      public boolean isGraphLoadingInProgress()
    • showWarningPopup

      public static void showWarningPopup​(String text, int time)
    • showWarningPopup

      public static void showWarningPopup​(String text, int time, Collection<WarningButton> bts)