Search in sources :

Example 6 with CayenneTable

use of org.apache.cayenne.modeler.util.CayenneTable in project cayenne by apache.

the class ObjEntityAttributePanel method initView.

private void initView() {
    this.setLayout(new BorderLayout());
    ActionManager actionManager = Application.getInstance().getActionManager();
    table = new CayenneTable();
    table.setDefaultRenderer(String.class, new CellRenderer());
    tablePreferences = new TableColumnPreferences(ObjAttributeTableModel.class, "objEntity/attributeTable");
    // go to SuperEntity from ObjEntity by inheritance icon
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            int row = table.rowAtPoint(e.getPoint());
            int col = table.columnAtPoint(e.getPoint());
            ObjAttribute objAttribute = ((ObjAttributeTableModel) table.getModel()).getAttribute(row).getValue();
            int columnFromModel = table.getColumnModel().getColumn(col).getModelIndex();
            if (row >= 0 && columnFromModel == ObjAttributeTableModel.OBJ_ATTRIBUTE) {
                if (objAttribute.isInherited()) {
                    TableCellRenderer renderer = table.getCellRenderer(row, col);
                    Rectangle rectangle = table.getCellRect(row, col, false);
                    ((CellRenderer) renderer).mouseClicked(e, rectangle.x);
                }
            }
        }
    });
    // Create and install a popup
    Icon ico = ModelerUtil.buildIcon("icon-edit.png");
    resolveMenu = new CayenneAction.CayenneMenuItem("Edit Attribute", ico);
    JPopupMenu popup = new JPopupMenu();
    popup.add(resolveMenu);
    popup.add(actionManager.getAction(RemoveAttributeRelationshipAction.class).buildMenu());
    popup.addSeparator();
    popup.add(actionManager.getAction(CutAttributeRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyAttributeRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());
    TablePopupHandler.install(table, popup);
    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) MouseEvent(java.awt.event.MouseEvent) ObjAttribute(org.apache.cayenne.map.ObjAttribute) MouseAdapter(java.awt.event.MouseAdapter) Rectangle(java.awt.Rectangle) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction) JPopupMenu(javax.swing.JPopupMenu) ActionManager(org.apache.cayenne.modeler.action.ActionManager) BorderLayout(java.awt.BorderLayout) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon)

Example 7 with CayenneTable

use of org.apache.cayenne.modeler.util.CayenneTable 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 8 with CayenneTable

use of org.apache.cayenne.modeler.util.CayenneTable in project cayenne by apache.

the class AbstractCallbackMethodsTab method createTable.

private CayenneTable createTable(CallbackType callbackType) {
    final CayenneTable cayenneTable = new CayenneTable();
    // drag-and-drop initialization
    cayenneTable.setDragEnabled(true);
    cayenneTable.setSortable(false);
    cayenneTable.setRowHeight(25);
    cayenneTable.setRowMargin(3);
    cayenneTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    cayenneTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    cayenneTable.setTransferHandler(new CallbackImportableHandler(cayenneTable));
    cayenneTable.getSelectionModel().addListSelectionListener(new CallbackListSelectionListener(cayenneTable));
    cayenneTable.getColumnModel().addColumnModelListener(new CallbackTableColumnModelListener(cayenneTable));
    cayenneTable.getTableHeader().addMouseListener(new CallbackMouseAdapter(cayenneTable));
    cayenneTable.getTableHeader().addMouseMotionListener(new CallbackMouseMotionListener(cayenneTable));
    TablePopupHandler.install(cayenneTable, popupMenu);
    addButtonAtHeader(cayenneTable, getCreateCallbackMethodAction().buildButton(), new ButtonListener(callbackType), ModelerUtil.buildIcon("icon-create-method.png"));
    return cayenneTable;
}
Also used : CayenneTable(org.apache.cayenne.modeler.util.CayenneTable)

Aggregations

CayenneTable (org.apache.cayenne.modeler.util.CayenneTable)8 BorderLayout (java.awt.BorderLayout)6 JPopupMenu (javax.swing.JPopupMenu)6 ActionManager (org.apache.cayenne.modeler.action.ActionManager)6 TableColumnPreferences (org.apache.cayenne.modeler.pref.TableColumnPreferences)6 Icon (javax.swing.Icon)4 CayenneAction (org.apache.cayenne.modeler.util.CayenneAction)4 Rectangle (java.awt.Rectangle)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 ImageIcon (javax.swing.ImageIcon)2 JToolBar (javax.swing.JToolBar)2 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 BoardTableCellRenderer (org.apache.cayenne.modeler.util.BoardTableCellRenderer)2 ArrayList (java.util.ArrayList)1 JMenuItem (javax.swing.JMenuItem)1 CallbackDescriptor (org.apache.cayenne.map.CallbackDescriptor)1 CallbackMap (org.apache.cayenne.map.CallbackMap)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1