Search in sources :

Example 1 with ExportDatabaseAction

use of easik.ui.menu.ExportDatabaseAction 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 2 with ExportDatabaseAction

use of easik.ui.menu.ExportDatabaseAction in project fql by CategoricalData.

the class SketchFrame method buildMenu.

/**
 * Builds the menu
 */
private void buildMenu() {
    final JMenuBar mainMenu;
    final JMenu menuFile;
    final JMenu menuHelp;
    mainMenu = new JMenuBar();
    // Make the File Menu
    menuFile = new JMenu("File");
    mainMenu.add(menuFile);
    menuFile.setMnemonic(KeyEvent.VK_F);
    final JMenu exportMenu = new JMenu("Export to");
    menuFile.add(exportMenu);
    // Export to server:
    addMenuItem(exportMenu, new JMenuItem(new ExportDatabaseAction(this, _ourSketch)), KeyEvent.VK_D);
    // Export to SQL text dump:
    addMenuItem(exportMenu, new JMenuItem(new ExportFileAction(this, _ourSketch)), KeyEvent.VK_F);
    addMenuItem(exportMenu, new JMenuItem(new ExportImageAction<>(this)), null);
    addMenuItem(exportMenu, new JMenuItem(new SketchExportAction(this)), null);
    menuFile.addSeparator();
    addMenuItem(menuFile, new JMenuItem(new DocumentInfoAction(this)), KeyEvent.VK_I);
    menuFile.addSeparator();
    addMenuItem(menuFile, new JMenuItem(new FileQuitAction(this)), KeyEvent.VK_W);
    // Make the Edit menu for "edit mode"
    menuEditEdit = new JMenu("Edit");
    mainMenu.add(menuEditEdit);
    addMenuItem(menuEditEdit, _UndoItem = new JMenuItem(new UndoAction(_ourSketch)), KeyEvent.VK_Z);
    addMenuItem(menuEditEdit, _RedoItem = new JMenuItem(new RedoAction(_ourSketch)), KeyEvent.VK_Y);
    menuEditEdit.addSeparator();
    menuEditEdit.add(menuEditAdd = new JMenu("Add"));
    addMenuItem(menuEditAdd, _AddEntityItem = new JMenuItem(new NewEntityAction<>(null, this)), null);
    menuEditAdd.add(menuEditAddEdge = new JMenu("Add edge"));
    addMenuItem(menuEditAddEdge, addEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.NORMAL)), null);
    addMenuItem(menuEditAddEdge, addInjEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.INJECTIVE)), null);
    addMenuItem(menuEditAddEdge, addParEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.PARTIAL)), null);
    addMenuItem(menuEditAddEdge, addSelfParEdge = new JMenuItem(new NewSketchEdgeAction(this, Edge.SELF)), null);
    addMenuItem(menuEditAdd, addAtt = new JMenuItem(new AddAttributeAction<>(this)), null);
    addMenuItem(menuEditAdd, addUK = new JMenuItem(new AddUniqueKeyAction<>(this)), null);
    addMenuItem(menuEditEdit, del = new JMenuItem(new DeleteFromSketchAction(this)), null);
    addMenuItem(menuEditEdit, rename = new JMenuItem(new RenameInSketchAction(this)), KeyEvent.VK_R);
    menuEditEdit.add(new JSeparator());
    addMenuItem(menuEditEdit, editEdge = new JMenuItem(new EditSketchEdgeAction(this)), KeyEvent.VK_E);
    menuEditEdit.add(new JSeparator());
    // If
    addMenuItem(menuEditEdit, _ProgramSettingsItem = new JMenuItem("Preferences"), KeyEvent.VK_P);
    // you
    // change
    // this
    // title,
    // update
    // OSX.java
    _ProgramSettingsItem.setToolTipText("Set global EASIK preferences");
    _ProgramSettingsItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            final ProgramSettingsUI myUI = new ProgramSettingsUI(SketchFrame.this);
            myUI.showDialog();
        }
    });
    // add listener to enable appropriate menu items
    menuEditEdit.addMenuListener(new MenuListener() {

        @Override
        public void menuCanceled(final MenuEvent e) {
        }

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

        @Override
        public void menuSelected(final MenuEvent e) {
            final Object[] selection = _ourSketch.getSelectionCells();
            final SketchGraphModel model = _ourSketch.getGraphModel();
            final boolean undoable = model.canUndo() && !_ourSketch.getDatabase().hasConnection() && !_ourSketch.isSynced();
            final boolean redoable = model.canRedo() && !_ourSketch.getDatabase().hasConnection() && !_ourSketch.isSynced();
            _UndoItem.setEnabled(undoable);
            _RedoItem.setEnabled(redoable);
            menuEditAdd.setEnabled(true);
            menuEditAddEdge.setEnabled(true);
            _AddEntityItem.setEnabled(false);
            addEdge.setEnabled(false);
            addInjEdge.setEnabled(false);
            addParEdge.setEnabled(false);
            addSelfParEdge.setEnabled(false);
            addAtt.setEnabled(false);
            addUK.setEnabled(false);
            rename.setEnabled(false);
            del.setEnabled(false);
            editEdge.setEnabled(false);
            if (selection.length == 0) {
                _AddEntityItem.setEnabled(true);
                menuEditAddEdge.setEnabled(false);
            }
            if (selection.length >= 1) {
                del.setEnabled(true);
                if (selection.length == 1) {
                    if (selection[0] instanceof EntityNode) {
                        rename.setEnabled(true);
                    }
                    if (selection[0] instanceof EntityNode) {
                        addSelfParEdge.setEnabled(true);
                        addAtt.setEnabled(true);
                        addUK.setEnabled(true);
                    } else if (selection[0] instanceof SketchEdge) {
                        editEdge.setEnabled(true);
                    }
                }
                // if selection contains an edge, dissable edit|add...
                for (int i = 0; i < selection.length; i++) {
                    if (selection[i] instanceof SketchEdge) {
                        menuEditAdd.setEnabled(false);
                    }
                }
                if (selection.length >= 3) {
                    menuEditAdd.setEnabled(false);
                }
            }
            if ((selection.length == 2) && (selection[0] instanceof EntityNode) && (selection[1] instanceof EntityNode)) {
                addEdge.setEnabled(true);
                addInjEdge.setEnabled(true);
                addParEdge.setEnabled(true);
            }
        }
    });
    // Make the Edit menu for "manipulate mode"
    @SuppressWarnings("unused") final JMenuItem updateRowMenuItem;
    @SuppressWarnings("unused") final JMenuItem viewDataMenuItem;
    menuEditManip = new JMenu("Edit");
    mainMenu.add(menuEditManip);
    menuEditManip.add(addRowMenuItem = new JMenuItem(new AddRowAction(_ourSketch)));
    menuEditManip.add(insertQueryMenuItem = new JMenuItem(new ExecPreparedInsertAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(updateRowMenuItem = new JMenuItem(new UpdateRowAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(deleteRowMenuItem = new JMenuItem(new DeleteRowAction(_ourSketch)));
    menuEditManip.add(deleteQueryMenuItem = new JMenuItem(new ExecPreparedDeleteAction(_ourSketch)));
    menuEditManip.addSeparator();
    menuEditManip.add(viewDataMenuItem = new JMenuItem(new ViewDataAction(_ourSketch)));
    menuEditManip.addMenuListener(new MenuListener() {

        @Override
        public void menuCanceled(final MenuEvent e) {
        }

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

        @Override
        public void menuSelected(final MenuEvent e) {
            final Object[] selection = _ourSketch.getSelectionCells();
            final boolean enable = (selection.length == 1) && (selection[0] instanceof EntityNode);
            for (final Component c : menuEditManip.getMenuComponents()) {
                c.setEnabled(enable);
            }
            if (!enable) {
                return;
            }
            if (!_ourSketch.editable((EntityNode) selection[0])) {
                addRowMenuItem.setEnabled(false);
                insertQueryMenuItem.setEnabled(false);
                deleteRowMenuItem.setEnabled(false);
                deleteQueryMenuItem.setEnabled(false);
            }
        }
    });
    menuView = new JMenu("View");
    mainMenu.add(menuView);
    menuView.add(_ShowAttributesToggle = new JCheckBoxMenuItem("Attributes/keys visible"));
    _ShowAttributesToggle.setToolTipText("Toggle display of attributes and unique keys");
    _ShowAttributesToggle.setState("show".equals(Easik.getInstance().getSettings().getProperty("attrib_display", "show")));
    _ShowAttributesToggle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            _ourSketch.refresh();
        }
    });
    menuView.add(_ShowConstraintToggle = new JCheckBoxMenuItem("Constraints visible"));
    _ShowConstraintToggle.setToolTipText("Toggle display of constraints");
    _ShowConstraintToggle.setState(true);
    _ShowConstraintToggle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            ModelConstraint.setAllConstraintsVisible(_ourSketch.getConstraints(), _ShowConstraintToggle.getState());
        }
    });
    // Create constraints menu
    menuConstraint = new JMenu("Constraints");
    menuConstraint.setMnemonic(KeyEvent.VK_C);
    mainMenu.add(menuConstraint);
    addMenuItem(menuConstraint, _AddCommutativeDiagramMenuItem = new JMenuItem(new AddCommutativeDiagramAction<>(this)), null);
    addMenuItem(menuConstraint, _AddSumMenuItem = new JMenuItem(new AddSumConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddProductMenuItem = new JMenuItem(new AddProductConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddPullbackMenuItem = new JMenuItem(new AddPullbackConstraintAction<>(this)), null);
    addMenuItem(menuConstraint, _AddEqualizerMenuItem = new JMenuItem(new AddEqualizerConstraintAction(this)), null);
    // addMenuItem(menuConstraint, _AddLimMenuItem = new JMenuItem(new
    // AddLimitConstraintAction<SketchFrame,
    // SketchGraphModel,Sketch,EntityNode, SketchEdge>(this)), null);
    // Make SQL connection menu
    menuSQL = new JMenu("SQL Connection");
    menuSQL.setMnemonic(KeyEvent.VK_S);
    mainMenu.add(menuSQL);
    addMenuItem(menuSQL, new JMenuItem(new DisconnectAction(_ourSketch)), null);
    // DTRIG
    addMenuItem(menuSQL, new JMenuItem(new OverrideConstraintAction(_ourSketch)), null);
    // CF2012
    // 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 : HelpAction(easik.ui.menu.HelpAction) ActionEvent(java.awt.event.ActionEvent) MenuListener(javax.swing.event.MenuListener) ExecPreparedDeleteAction(easik.ui.datamanip.jdbc.ExecPreparedDeleteAction) ExportFileAction(easik.ui.menu.ExportFileAction) ViewDataAction(easik.ui.menu.popup.ViewDataAction) NewSketchEdgeAction(easik.ui.menu.popup.NewSketchEdgeAction) DeleteRowAction(easik.ui.menu.popup.DeleteRowAction) JSeparator(javax.swing.JSeparator) EntityNode(easik.sketch.vertex.EntityNode) DeleteFromSketchAction(easik.ui.menu.popup.DeleteFromSketchAction) ExecPreparedInsertAction(easik.ui.datamanip.jdbc.ExecPreparedInsertAction) RedoAction(easik.ui.menu.RedoAction) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) MenuEvent(javax.swing.event.MenuEvent) SketchExportAction(easik.ui.menu.SketchExportAction) UpdateRowAction(easik.ui.menu.popup.UpdateRowAction) AddRowAction(easik.ui.menu.popup.AddRowAction) AboutAction(easik.ui.menu.AboutAction) EditSketchEdgeAction(easik.ui.menu.popup.EditSketchEdgeAction) RenameInSketchAction(easik.ui.menu.popup.RenameInSketchAction) ExportImageAction(easik.ui.menu.ExportImageAction) ExportDatabaseAction(easik.ui.menu.ExportDatabaseAction) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) SketchGraphModel(easik.sketch.util.graph.SketchGraphModel) DisconnectAction(easik.ui.menu.popup.DisconnectAction) FileQuitAction(easik.ui.menu.FileQuitAction) ActionListener(java.awt.event.ActionListener) SketchEdge(easik.sketch.edge.SketchEdge) OverrideConstraintAction(easik.ui.menu.popup.OverrideConstraintAction) DocumentInfoAction(easik.ui.menu.DocumentInfoAction) AddEqualizerConstraintAction(easik.ui.menu.AddEqualizerConstraintAction) UndoAction(easik.ui.menu.UndoAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 3 with ExportDatabaseAction

use of easik.ui.menu.ExportDatabaseAction in project fql by CategoricalData.

the class ApplicationFrame method buildPopupMenu.

/**
 * Creates the popup menu
 */
private void buildPopupMenu() {
    _canvasPopupMenu.add(_AddSketchPopItem = new JMenuItem(new NewSketchAction(_popupPosition, _overview)));
    _canvasPopupMenu.add(_ImportSketchPopItem = new JMenuItem(new ImportSketchAction(_popupPosition, _overview)));
    _sketchPopupMenu.add(_OpenSketchPopDefItem = new JMenuItem(new OpenSketchAction(_overview, true)));
    _sketchPopupMenu.add(_OpenSketchManipulatePopDefItem = new JMenuItem(new OpenSketchDataAction(_overview, true)));
    _sketchPopupMenu.add(_OpenSketchPopItem = new JMenuItem(new OpenSketchAction(_overview)));
    _sketchPopupMenu.add(_OpenSketchManipulatePopItem = new JMenuItem(new OpenSketchDataAction(_overview)));
    _sketchPopupMenu.addSeparator();
    _sketchPopupMenu.add(_NewViewPopItem = new JMenuItem(new NewViewAction(_overview)));
    _sketchPopupMenu.addSeparator();
    _sketchPopupMenu.add(_RenamePopItem = new JMenuItem(new RenameInOverviewAction(_overview)));
    _sketchPopupMenu.add(_DeleteSketchPopItem = new JMenuItem(new DeleteFromOverviewAction(_overview)));
    _sketchPopupMenu.addSeparator();
    _sketchPopupMenu.add(_ExportSketchPopItem = new JMenuItem(new SketchExportAction(this)));
    _sketchPopupMenu.add(_ExportSketchDatabasePopItem = new JMenuItem(new ExportDatabaseAction(this, null)));
    // _sketchPopupMenu.add(_ExportSketchImage = new JMenuItem(new
    // ExportImageAction<SketchFrame, SketchGraphModel, Sketch, EntityNode,
    // SketchEdge>(null)));
    _viewPopupMenu.add(_OpenViewPopItem = new JMenuItem(new OpenViewAction(_overview)));
    _viewPopupMenu.add(_RenameViewPopItem = new JMenuItem(new RenameInOverviewAction(_overview)));
    _viewPopupMenu.add(_DeleteViewPopItem = new JMenuItem(new DeleteFromOverviewAction(_overview)));
    _viewPopupMenu.addSeparator();
    // _viewPopupMenu.add(_ExportViewImage = new JMenuItem(new
    // ExportImageAction<ViewFrame, ViewGraphModel, View, QueryNode,
    // View_Edge>(null)));
    _mixedPopupMenu.add(_DeleteMixedPopItem = new JMenuItem(new DeleteFromOverviewAction(_overview)));
    _overview.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent evt) {
            mouseReleased(evt);
        }

        @Override
        public void mouseReleased(final MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                final Object rightClickedOn = _overview.getFirstCellForLocation(evt.getX(), evt.getY());
                // the current selection
                if (rightClickedOn != null) {
                    final Object[] selection = _overview.getSelectionCells();
                    if (!Arrays.asList(selection).contains(rightClickedOn)) {
                        _overview.setSelectionCell(_overview.getFirstCellForLocation(evt.getX(), evt.getY()));
                    }
                } else {
                    _overview.setSelectionCells(new Object[0]);
                }
                _popupPosition.setLocation(evt.getX(), evt.getY());
                final JPopupMenu menu = setPopMenu();
                if (menu != null) {
                    menu.show(evt.getComponent(), evt.getX(), evt.getY());
                }
            }
        }
    });
}
Also used : SketchExportAction(easik.ui.menu.SketchExportAction) MouseEvent(java.awt.event.MouseEvent) NewViewAction(easik.ui.menu.popup.NewViewAction) DeleteFromOverviewAction(easik.ui.menu.popup.DeleteFromOverviewAction) OpenSketchAction(easik.ui.menu.popup.OpenSketchAction) OpenViewAction(easik.ui.menu.popup.OpenViewAction) MouseAdapter(java.awt.event.MouseAdapter) ExportDatabaseAction(easik.ui.menu.ExportDatabaseAction) JPopupMenu(javax.swing.JPopupMenu) ImportSketchAction(easik.ui.menu.popup.ImportSketchAction) OpenSketchDataAction(easik.ui.menu.popup.OpenSketchDataAction) RenameInOverviewAction(easik.ui.menu.popup.RenameInOverviewAction) JMenuItem(javax.swing.JMenuItem) NewSketchAction(easik.ui.menu.popup.NewSketchAction)

Aggregations

ExportDatabaseAction (easik.ui.menu.ExportDatabaseAction)3 JMenuItem (javax.swing.JMenuItem)3 SketchExportAction (easik.ui.menu.SketchExportAction)2 Component (java.awt.Component)2 SketchNode (easik.overview.vertex.SketchNode)1 SketchEdge (easik.sketch.edge.SketchEdge)1 SketchGraphModel (easik.sketch.util.graph.SketchGraphModel)1 EntityNode (easik.sketch.vertex.EntityNode)1 ExecPreparedDeleteAction (easik.ui.datamanip.jdbc.ExecPreparedDeleteAction)1 ExecPreparedInsertAction (easik.ui.datamanip.jdbc.ExecPreparedInsertAction)1 AboutAction (easik.ui.menu.AboutAction)1 AddEqualizerConstraintAction (easik.ui.menu.AddEqualizerConstraintAction)1 DocumentInfoAction (easik.ui.menu.DocumentInfoAction)1 ExportFileAction (easik.ui.menu.ExportFileAction)1 ExportImageAction (easik.ui.menu.ExportImageAction)1 FileQuitAction (easik.ui.menu.FileQuitAction)1 HelpAction (easik.ui.menu.HelpAction)1 RedoAction (easik.ui.menu.RedoAction)1 UndoAction (easik.ui.menu.UndoAction)1 AddRowAction (easik.ui.menu.popup.AddRowAction)1