Search in sources :

Example 6 with SketchNode

use of easik.overview.vertex.SketchNode in project fql by CategoricalData.

the class Overview method initializeOverview.

/**
 * When we initialise the overview, we flush out all the data concerning the
 * sketch itself.
 *
 * This methods serves as a "new overview" function.
 */
public void initializeOverview() {
    clearSelection();
    if (_sketchNodes != null) {
        for (SketchNode node : _sketchNodes.values()) {
            node.getFrame().dispose();
        }
    }
    if (_viewNodes != null) {
        for (ViewNode node : _viewNodes.values()) {
            node.getFrame().dispose();
        }
    }
    setFile(null);
    _sketchNodes = new HashMap<>();
    _viewNodes = new HashMap<>();
    _viewEdges = new HashMap<>();
    _docInfo = new DocumentInfo(_appFrame);
    if (_appFrame.getInfoTreeUI() != null) {
        _appFrame.setInfoTreeUI(new OverviewInfoTreeUI(_appFrame));
        _appFrame.getInfoTreeUI().refreshTree();
    }
    OverviewGraphModel model = new OverviewGraphModel(this);
    GraphLayoutCache glc = new GraphLayoutCache(model, new DefaultCellViewFactory());
    setModel(model);
    setGraphLayoutCache(glc);
}
Also used : DefaultCellViewFactory(org.jgraph.graph.DefaultCellViewFactory) GraphLayoutCache(org.jgraph.graph.GraphLayoutCache) ViewNode(easik.overview.vertex.ViewNode) OverviewGraphModel(easik.overview.util.graph.OverviewGraphModel) OverviewInfoTreeUI(easik.ui.tree.OverviewInfoTreeUI) SketchNode(easik.overview.vertex.SketchNode) DocumentInfo(easik.DocumentInfo)

Example 7 with SketchNode

use of easik.overview.vertex.SketchNode in project fql by CategoricalData.

the class Overview method refreshAll.

/**
 * Refreshes the overview GUI as well as the GUIs of all Sketches and Views.
 */
public void refreshAll() {
    for (SketchNode node : _sketchNodes.values()) {
        Sketch s = node.getFrame().getMModel();
        s.refresh();
        s.updateThumb();
    }
    for (ViewNode node : _viewNodes.values()) {
        View v = node.getMModel();
        v.refresh();
        v.updateThumb();
    }
    refresh();
}
Also used : Sketch(easik.sketch.Sketch) ViewNode(easik.overview.vertex.ViewNode) SketchNode(easik.overview.vertex.SketchNode) View(easik.view.View)

Example 8 with SketchNode

use of easik.overview.vertex.SketchNode in project fql by CategoricalData.

the class ApplicationFrame method setSketchPopItems.

/**
 */
public void setSketchPopItems() {
    // disable all elements
    for (final Component c : _sketchPopupMenu.getComponents()) {
        c.setEnabled(false);
    }
    _OpenSketchManipulatePopDefItem.setVisible(false);
    _OpenSketchManipulatePopItem.setVisible(true);
    _OpenSketchPopDefItem.setVisible(false);
    _OpenSketchPopItem.setVisible(true);
    // We always want to be able to delete
    _DeleteSketchPopItem.setEnabled(true);
    final Object[] currentSelection = _overview.getSelectionCells();
    if (currentSelection.length == 1) {
        _RenamePopItem.setEnabled(true);
        if (((SketchNode) currentSelection[0]).getFrame().getMode() == SketchFrame.Mode.EDIT) {
            _NewViewPopItem.setEnabled(true);
        }
        _ExportSketchPopItem.setEnabled(true);
        // Enable sketch export to db
        _ExportSketchDatabasePopItem.setEnabled(true);
        _ExportSketchDatabasePopItem.setEnabled(true);
        // Enable sketch export to image
        // _ExportSketchImage.setEnabled(true);
        // The the export item to work with current selection
        _sketchPopupMenu.remove(_ExportSketchDatabasePopItem);
        // _sketchPopupMenu.remove(_ExportSketchImage);
        // _ExportSketchImage = new JMenuItem(new
        // ExportImageAction<SketchFrame, SketchGraphModel, Sketch,
        // EntityNode, SketchEdge>(((SketchNode)
        // currentSelection[0]).getFrame()));
        _ExportSketchDatabasePopItem = new JMenuItem(new ExportDatabaseAction(this, ((SketchNode) currentSelection[0]).getFrame().getMModel()));
        _sketchPopupMenu.add(_ExportSketchDatabasePopItem);
        if (((SketchNode) currentSelection[0]).getFrame().getMModel().isSynced()) {
            _OpenSketchManipulatePopDefItem.setEnabled(true);
            _OpenSketchManipulatePopDefItem.setVisible(true);
            _OpenSketchManipulatePopDefItem.setArmed(true);
            _OpenSketchManipulatePopItem.setVisible(false);
            _OpenSketchPopItem.setEnabled(true);
        } else {
            _OpenSketchPopDefItem.setEnabled(true);
            _OpenSketchPopDefItem.setVisible(true);
            _OpenSketchPopDefItem.setArmed(true);
            _OpenSketchPopItem.setVisible(false);
            _OpenSketchManipulatePopItem.setEnabled(true);
        }
    }
}
Also used : Component(java.awt.Component) SketchNode(easik.overview.vertex.SketchNode) JMenuItem(javax.swing.JMenuItem) ExportDatabaseAction(easik.ui.menu.ExportDatabaseAction)

Example 9 with SketchNode

use of easik.overview.vertex.SketchNode in project fql by CategoricalData.

the class ApplicationFrame method buildMenu.

/**
 * Builds the menu
 */
private void buildMenu() {
    final JMenuBar mainMenu;
    final JMenu menuFile;
    final JMenu menuEdit;
    @SuppressWarnings("unused") JMenu menuAction;
    final JMenu menuHelp;
    mainMenu = new JMenuBar();
    // Make the File Menu
    menuFile = new JMenu("File");
    addMenuItem(menuFile, new FileNewOverviewAction(this), KeyEvent.VK_N);
    addMenuItem(menuFile, new FileOpenAction(this), KeyEvent.VK_O);
    menuFile.addSeparator();
    addMenuItem(menuFile, new FileSaveAction(this), KeyEvent.VK_S);
    addMenuItem(menuFile, new FileSaveAsAction(this), KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK);
    menuFile.addSeparator();
    _recentFilesMenu = new JMenu("Open recent...");
    menuFile.add(_recentFilesMenu);
    updateRecentFilesMenu();
    menuFile.addSeparator();
    addMenuItem(menuFile, new OverviewDocumentInfoAction(this), KeyEvent.VK_I);
    menuFile.addSeparator();
    addMenuItem(menuFile, new FileQuitAction(this), KeyEvent.VK_Q);
    mainMenu.add(menuFile);
    menuFile.setMnemonic(KeyEvent.VK_F);
    menuEdit = new JMenu("Edit");
    menuEdit.add(new JMenuItem(new NewSketchAction(null, _overview)));
    menuEdit.add(new JMenuItem(new ImportSketchAction(null, _overview)));
    menuEdit.addSeparator();
    menuEdit.add(_NewViewMenuItem = new JMenuItem(new NewViewAction(_overview)));
    mainMenu.add(menuEdit);
    menuEdit.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e1) {
            final Object[] selection = _overview.getSelectionCells();
            _NewViewMenuItem.setEnabled((selection.length == 1) && (selection[0] instanceof SketchNode));
        }

        @Override
        public void menuDeselected(final MenuEvent e1) {
        }

        @Override
        public void menuCanceled(final MenuEvent e1) {
        }
    });
    menuEdit.addSeparator();
    // If
    addMenuItem(menuEdit, _ProgramSettingsItem = new JMenuItem("Preferences"), KeyEvent.VK_E);
    // you
    // change
    // this
    // title,
    // update
    // OSX.java
    _ProgramSettingsItem.setToolTipText("Set Global Easik Properties");
    _ProgramSettingsItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            final ProgramSettingsUI myUI = new ProgramSettingsUI(ApplicationFrame.this);
            myUI.showDialog();
        }
    });
    menuEdit.setMnemonic(KeyEvent.VK_E);
    // Create help menu
    menuHelp = new JMenu("Help");
    mainMenu.add(menuHelp);
    menuHelp.setMnemonic(KeyEvent.VK_H);
    menuHelp.add(new HelpAction());
    menuHelp.add(new AboutAction());
    setJMenuBar(mainMenu);
}
Also used : FileNewOverviewAction(easik.ui.menu.FileNewOverviewAction) HelpAction(easik.ui.menu.HelpAction) OverviewDocumentInfoAction(easik.ui.menu.OverviewDocumentInfoAction) NewViewAction(easik.ui.menu.popup.NewViewAction) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) AboutAction(easik.ui.menu.AboutAction) FileSaveAsAction(easik.ui.menu.FileSaveAsAction) SketchNode(easik.overview.vertex.SketchNode) FileSaveAction(easik.ui.menu.FileSaveAction) FileQuitAction(easik.ui.menu.FileQuitAction) ActionListener(java.awt.event.ActionListener) ImportSketchAction(easik.ui.menu.popup.ImportSketchAction) JMenuItem(javax.swing.JMenuItem) NewSketchAction(easik.ui.menu.popup.NewSketchAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) FileOpenAction(easik.ui.menu.FileOpenAction) MenuEvent(javax.swing.event.MenuEvent)

Example 10 with SketchNode

use of easik.overview.vertex.SketchNode in project fql by CategoricalData.

the class RenameInOverviewFromTreeAction method actionPerformed.

/**
 * Called when clicked upon, will rename an article.
 *
 * @param e
 *            The action event
 */
@Override
public void actionPerformed(ActionEvent e) {
    // If there is nothing seleceted then just do nothing
    if (_theFrame.getInfoTreeUI().getInfoTree().isSelectionEmpty()) {
        System.err.println("'OK'");
        return;
    }
    // Get currently selected object
    DefaultMutableTreeNode curSelected = (DefaultMutableTreeNode) _theFrame.getInfoTreeUI().getInfoTree().getSelectionPath().getLastPathComponent();
    OverviewVertex nodeToRename;
    String originalName = "";
    // Check what is currently selected
    if (curSelected.getUserObject() instanceof SketchNode) {
        nodeToRename = (SketchNode) curSelected.getUserObject();
    } else if (curSelected.getUserObject() instanceof ViewNode) {
        nodeToRename = (ViewNode) curSelected.getUserObject();
    } else {
        return;
    }
    originalName = nodeToRename.getName();
    String s = (String) JOptionPane.showInputDialog(_theFrame, "New name:", "Rename", JOptionPane.QUESTION_MESSAGE, null, null, originalName);
    if (s != null) {
        s = s.trim();
        if (s.equals("")) {
            JOptionPane.showMessageDialog(_theFrame, "Entity name is empty", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (_theFrame.getOverview().isNameUsed(s)) {
            JOptionPane.showMessageDialog(_theFrame, "Entity name is already in use", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            nodeToRename.setName(s);
            _theFrame.getInfoTreeUI().refreshTree();
            _theFrame.getOverview().getGraphLayoutCache().reload();
            _theFrame.getOverview().repaint();
            if (nodeToRename instanceof SketchNode) {
                ((SketchNode) nodeToRename).getFrame().getMModel().setDirty();
            } else if (nodeToRename instanceof ViewNode) {
                ((ViewNode) nodeToRename).getFrame().getMModel().setDirty();
            }
        }
    }
    _theFrame.getOverview().clearSelection();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ViewNode(easik.overview.vertex.ViewNode) OverviewVertex(easik.overview.vertex.OverviewVertex) SketchNode(easik.overview.vertex.SketchNode)

Aggregations

SketchNode (easik.overview.vertex.SketchNode)18 ViewNode (easik.overview.vertex.ViewNode)11 ViewDefinitionEdge (easik.overview.edge.ViewDefinitionEdge)4 Sketch (easik.sketch.Sketch)4 SketchFrame (easik.ui.SketchFrame)4 DocumentInfo (easik.DocumentInfo)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Cascade (easik.model.edge.ModelEdge.Cascade)2 OverviewVertex (easik.overview.vertex.OverviewVertex)2 Component (java.awt.Component)2 Point (java.awt.Point)2 JMenuItem (javax.swing.JMenuItem)2 AttributeMap (org.jgraph.graph.AttributeMap)2 OverviewGraphModel (easik.overview.util.graph.OverviewGraphModel)1 SketchEdge (easik.sketch.edge.SketchEdge)1 ViewFrame (easik.ui.ViewFrame)1 AboutAction (easik.ui.menu.AboutAction)1 ExportDatabaseAction (easik.ui.menu.ExportDatabaseAction)1 FileNewOverviewAction (easik.ui.menu.FileNewOverviewAction)1 FileOpenAction (easik.ui.menu.FileOpenAction)1