Search in sources :

Example 6 with TableColumnPreferences

use of org.apache.cayenne.modeler.pref.TableColumnPreferences in project cayenne by apache.

the class ProcedureParameterTab method init.

protected void init() {
    setLayout(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateProcedureParameterAction.class).buildButton(1));
    removeParameterButton = actionManager.getAction(RemoveProcedureParameterAction.class).buildButton(3);
    toolBar.add(removeParameterButton);
    toolBar.addSeparator();
    Icon up = ModelerUtil.buildIcon("icon-up.png");
    Icon down = ModelerUtil.buildIcon("icon-down.png");
    moveUp = new CayenneAction.CayenneToolbarButton(null, 1);
    moveUp.setIcon(up);
    moveUp.setDisabledIcon(FilteredIconFactory.createDisabledIcon(up));
    moveUp.setToolTipText("Move Parameter Up");
    toolBar.add(moveUp);
    moveDown = new CayenneAction.CayenneToolbarButton(null, 3);
    moveDown.setIcon(down);
    moveDown.setDisabledIcon(FilteredIconFactory.createDisabledIcon(down));
    moveDown.setToolTipText("Move Parameter Down");
    toolBar.add(moveDown);
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(CutProcedureParameterAction.class).buildButton(1));
    toolBar.add(actionManager.getAction(CopyProcedureParameterAction.class).buildButton(2));
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton(3));
    add(toolBar, BorderLayout.NORTH);
    // Create table with two columns and no rows.
    table = new CayenneTable();
    tablePreferences = new TableColumnPreferences(this.getClass(), "procedure/parameterTable");
    // Create and install a popup
    JPopupMenu popup = new JPopupMenu();
    removeParameterMenu = actionManager.getAction(RemoveProcedureParameterAction.class).buildMenu();
    popup.add(removeParameterMenu);
    popup.addSeparator();
    moveUpMenu = new JMenuItem("Move Parameter Up", up);
    moveDownMenu = new JMenuItem("Move Parameter Down", down);
    popup.add(moveUpMenu);
    popup.add(moveDownMenu);
    popup.addSeparator();
    popup.add(actionManager.getAction(CutProcedureParameterAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyProcedureParameterAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());
    TablePopupHandler.install(table, popup);
    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
    actionManager.setupCutCopyPaste(table, CutProcedureParameterAction.class, CopyProcedureParameterAction.class);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) Icon(javax.swing.Icon) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) JMenuItem(javax.swing.JMenuItem) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction) JPopupMenu(javax.swing.JPopupMenu)

Example 7 with TableColumnPreferences

use of org.apache.cayenne.modeler.pref.TableColumnPreferences in project cayenne by apache.

the class ResolveDbRelationshipDialog method initView.

/**
 * Creates graphical components.
 */
private void initView() {
    // create widgets
    name = new JTextField(25);
    reverseName = new JTextField(25);
    addButton = new JButton("Add");
    addButton.setEnabled(this.editable);
    removeButton = new JButton("Remove");
    removeButton.setEnabled(this.editable);
    saveButton = new JButton("Done");
    cancelButton = new JButton("Cancel");
    cancelButton.setEnabled(this.editable);
    table = new AttributeTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tablePreferences = new TableColumnPreferences(getClass(), "dbentity/dbjoinTable");
    // assemble
    getContentPane().setLayout(new BorderLayout());
    CellConstraints cc = new CellConstraints();
    PanelBuilder builder = new PanelBuilder(new FormLayout("right:max(50dlu;pref), 3dlu, fill:min(150dlu;pref), 3dlu, fill:min(50dlu;pref)", "p, 3dlu, p, 3dlu, p, 9dlu, p, 3dlu, top:14dlu, 3dlu, top:p:grow"));
    builder.setDefaultDialogBorder();
    builder.addSeparator("DbRelationship Information", cc.xywh(1, 1, 5, 1));
    builder.addLabel("Relationship:", cc.xy(1, 3));
    builder.add(name, cc.xywh(3, 3, 1, 1));
    builder.addLabel("Reverse Relationship", cc.xy(1, 5));
    builder.add(reverseName, cc.xywh(3, 5, 1, 1));
    builder.addSeparator("Joins", cc.xywh(1, 7, 5, 1));
    builder.add(new JScrollPane(table), cc.xywh(1, 9, 3, 3, "fill, fill"));
    JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEADING));
    buttons.add(addButton);
    buttons.add(removeButton);
    builder.add(buttons, cc.xywh(5, 9, 1, 3));
    getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    getContentPane().add(PanelFactory.createButtonPanel(new JButton[] { saveButton, cancelButton }), BorderLayout.SOUTH);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) PanelBuilder(com.jgoodies.forms.builder.PanelBuilder) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Aggregations

TableColumnPreferences (org.apache.cayenne.modeler.pref.TableColumnPreferences)7 BorderLayout (java.awt.BorderLayout)6 JPopupMenu (javax.swing.JPopupMenu)6 ActionManager (org.apache.cayenne.modeler.action.ActionManager)6 CayenneTable (org.apache.cayenne.modeler.util.CayenneTable)6 Icon (javax.swing.Icon)4 CayenneAction (org.apache.cayenne.modeler.util.CayenneAction)4 JToolBar (javax.swing.JToolBar)2 BoardTableCellRenderer (org.apache.cayenne.modeler.util.BoardTableCellRenderer)2 PanelBuilder (com.jgoodies.forms.builder.PanelBuilder)1 CellConstraints (com.jgoodies.forms.layout.CellConstraints)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 ImageIcon (javax.swing.ImageIcon)1 JMenuItem (javax.swing.JMenuItem)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1