Search in sources :

Example 1 with ExecPreparedInsertAction

use of easik.ui.datamanip.jdbc.ExecPreparedInsertAction in project fql by CategoricalData.

the class SketchFrame method buildPopupMenu.

/**
 * Creates the popup menu
 */
private void buildPopupMenu() {
    _editSketchPopMenu.add(_AddEntityPopItem = new JMenuItem(new NewEntityAction<>(_popupPosition, this)));
    _editEntityPopMenu.add(_AddEdgePopItem = new JMenuItem(new NewSketchEdgeAction(this, Edge.NORMAL)));
    _editEntityPopMenu.add(_AddInjEdgePopItem = new JMenuItem(new NewSketchEdgeAction(this, Edge.INJECTIVE)));
    _editEntityPopMenu.add(_AddParEdgePopItem = new JMenuItem(new NewSketchEdgeAction(this, Edge.PARTIAL)));
    _editEntityPopMenu.add(_AddSelfParEdgePopItem = new JMenuItem(new NewSketchEdgeAction(this, Edge.SELF)));
    _editEntityPopMenu.add(_AddAttributePopItem = new JMenuItem(new AddAttributeAction<>(this)));
    _editEntityPopMenu.add(_AddUniqueKeyPopItem = new JMenuItem(new AddUniqueKeyAction<>(this)));
    _editEntityPopMenu.add(_RenameEntityPopItem = new JMenuItem(new RenameInSketchAction(this)));
    _editEntityPopMenu.add(_DeleteEntityPopItem = new JMenuItem(new DeleteFromSketchAction(this)));
    _editEdgePopMenu.add(_EditEdgePopItem = new JMenuItem(new EditSketchEdgeAction(this)));
    _editEdgePopMenu.add(_DeleteEdgePopItem = new JMenuItem(new DeleteFromSketchAction(this)));
    _editConstraintPopMenu.add(_AddPathPopItem = new JMenuItem(new AddPathAction<>(this)));
    _editConstraintPopMenu.add(_DeleteConstraintPopItem = new JMenuItem(new DeleteFromSketchAction(this)));
    _editMixedPopMenu.add(_DeleteAllPopItem = new JMenuItem(new DeleteFromSketchAction(this)));
    _addConstraintPopMenu.add(_NextPopItem = new JMenuItem("Next"));
    _addConstraintPopMenu.add(_FinishPopItem = new JMenuItem("Finish"));
    _addConstraintPopMenu.add(_CancelPopItem = new JMenuItem("Cancel"));
    _manipulateEntityPopMenu.add(_AddRowPopItem = new JMenuItem(new AddRowAction(_ourSketch)));
    _manipulateEntityPopMenu.add(_AddByQueryPopItem = new JMenuItem(new ExecPreparedInsertAction(_ourSketch)));
    _manipulateEntityPopMenu.add(new JSeparator());
    _manipulateEntityPopMenu.add(_UpdateRowPopItem = new JMenuItem(new UpdateRowAction(_ourSketch)));
    _manipulateEntityPopMenu.add(new JSeparator());
    _manipulateEntityPopMenu.add(_DeleteRowsPopItem = new JMenuItem(new DeleteRowAction(_ourSketch)));
    _manipulateEntityPopMenu.add(_DeleteByQueryPopItem = new JMenuItem(new ExecPreparedDeleteAction(_ourSketch)));
    _manipulateEntityPopMenu.add(new JSeparator());
    _manipulateEntityPopMenu.add(_ViewDataPopItem = new JMenuItem(new ViewDataAction(_ourSketch)));
    _NextPopItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            _ourSketch.getStateManager().nextClicked();
        }
    });
    _FinishPopItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            _ourSketch.getStateManager().finishClicked();
        }
    });
    _CancelPopItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e1) {
            _ourSketch.getStateManager().cancelClicked();
        }
    });
    _ourSketch.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 = _ourSketch.getFirstCellForLocation(evt.getX(), evt.getY());
                // the current selection
                if (rightClickedOn != null) {
                    final Object[] selection = _ourSketch.getSelectionCells();
                    if (!Arrays.asList(selection).contains(rightClickedOn)) {
                        _ourSketch.setSelectionCell(_ourSketch.getFirstCellForLocation(evt.getX(), evt.getY()));
                    }
                } else {
                    _ourSketch.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 : MouseEvent(java.awt.event.MouseEvent) UpdateRowAction(easik.ui.menu.popup.UpdateRowAction) ActionEvent(java.awt.event.ActionEvent) AddRowAction(easik.ui.menu.popup.AddRowAction) ExecPreparedDeleteAction(easik.ui.datamanip.jdbc.ExecPreparedDeleteAction) MouseAdapter(java.awt.event.MouseAdapter) EditSketchEdgeAction(easik.ui.menu.popup.EditSketchEdgeAction) RenameInSketchAction(easik.ui.menu.popup.RenameInSketchAction) ViewDataAction(easik.ui.menu.popup.ViewDataAction) NewSketchEdgeAction(easik.ui.menu.popup.NewSketchEdgeAction) DeleteRowAction(easik.ui.menu.popup.DeleteRowAction) JSeparator(javax.swing.JSeparator) JPopupMenu(javax.swing.JPopupMenu) DeleteFromSketchAction(easik.ui.menu.popup.DeleteFromSketchAction) ActionListener(java.awt.event.ActionListener) ExecPreparedInsertAction(easik.ui.datamanip.jdbc.ExecPreparedInsertAction) JMenuItem(javax.swing.JMenuItem)

Example 2 with ExecPreparedInsertAction

use of easik.ui.datamanip.jdbc.ExecPreparedInsertAction 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)

Aggregations

ExecPreparedDeleteAction (easik.ui.datamanip.jdbc.ExecPreparedDeleteAction)2 ExecPreparedInsertAction (easik.ui.datamanip.jdbc.ExecPreparedInsertAction)2 AddRowAction (easik.ui.menu.popup.AddRowAction)2 DeleteFromSketchAction (easik.ui.menu.popup.DeleteFromSketchAction)2 DeleteRowAction (easik.ui.menu.popup.DeleteRowAction)2 EditSketchEdgeAction (easik.ui.menu.popup.EditSketchEdgeAction)2 NewSketchEdgeAction (easik.ui.menu.popup.NewSketchEdgeAction)2 RenameInSketchAction (easik.ui.menu.popup.RenameInSketchAction)2 UpdateRowAction (easik.ui.menu.popup.UpdateRowAction)2 ViewDataAction (easik.ui.menu.popup.ViewDataAction)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JMenuItem (javax.swing.JMenuItem)2 JSeparator (javax.swing.JSeparator)2 SketchEdge (easik.sketch.edge.SketchEdge)1 SketchGraphModel (easik.sketch.util.graph.SketchGraphModel)1 EntityNode (easik.sketch.vertex.EntityNode)1 AboutAction (easik.ui.menu.AboutAction)1 AddEqualizerConstraintAction (easik.ui.menu.AddEqualizerConstraintAction)1 DocumentInfoAction (easik.ui.menu.DocumentInfoAction)1