Search in sources :

Example 1 with CayenneTable

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

the class EmbeddableAttributeTab method init.

private void init() {
    this.setLayout(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(RemoveAttributeAction.class).buildButton());
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(CutAttributeAction.class).buildButton(1));
    toolBar.add(actionManager.getAction(CopyAttributeAction.class).buildButton(2));
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton(3));
    add(toolBar, BorderLayout.NORTH);
    table = new CayenneTable();
    tablePreferences = new TableColumnPreferences(this.getClass(), "embeddable/attributeTable");
    // Create and install a popup
    JPopupMenu popup = new JPopupMenu();
    popup.add(actionManager.getAction(RemoveAttributeAction.class).buildMenu());
    popup.addSeparator();
    popup.add(actionManager.getAction(CutAttributeAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyAttributeAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());
    TablePopupHandler.install(table, popup);
    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) JPopupMenu(javax.swing.JPopupMenu)

Example 2 with CayenneTable

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

the class AbstractCallbackMethodsTab method rebuildTables.

/**
 * rebuilds table content
 */
protected void rebuildTables() {
    CallbackMap callbackMap = getCallbackMap();
    for (int i = 0; i < callbackTypes.length; i++) {
        CallbackType callbackType = callbackTypes[i];
        List<String> methods = new ArrayList<>();
        CallbackDescriptor descriptor = null;
        if (callbackMap != null && callbackType != null) {
            descriptor = callbackMap.getCallbackDescriptor(callbackType.getType());
            methods.addAll(descriptor.getCallbackMethods());
        }
        CallbackDescriptorTableModel model = new CallbackDescriptorTableModel(mediator, this, methods, descriptor, callbackType);
        tables[i].setModel(model);
    }
    for (CayenneTable table : tables) {
        tablePreferences.bind(table, MIN_SIZES, null, null);
    }
}
Also used : CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) CallbackDescriptor(org.apache.cayenne.map.CallbackDescriptor) ArrayList(java.util.ArrayList) CallbackMap(org.apache.cayenne.map.CallbackMap)

Example 3 with CayenneTable

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

the class ObjEntityRelationshipPanel method init.

private void init() {
    this.setLayout(new BorderLayout());
    ActionManager actionManager = Application.getInstance().getActionManager();
    table = new CayenneTable();
    table.setDefaultRenderer(String.class, new StringRenderer());
    table.setDefaultRenderer(ObjEntity.class, new EntityRenderer());
    tablePreferences = new TableColumnPreferences(ObjRelationshipTableModel.class, "objEntity/relationshipTable");
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            int row = table.rowAtPoint(e.getPoint());
            int col = table.columnAtPoint(e.getPoint());
            ObjRelationshipTableModel tableModel = ((ObjRelationshipTableModel) table.getModel());
            ObjRelationship relationship = tableModel.getRelationship(row);
            int columnFromModel = table.getColumnModel().getColumn(col).getModelIndex();
            if (row >= 0 && columnFromModel == ObjRelationshipTableModel.REL_NAME) {
                if (relationship.getSourceEntity() != tableModel.getEntity()) {
                    TableCellRenderer renderer = table.getCellRenderer(row, col);
                    Rectangle rectangle = table.getCellRect(row, col, false);
                    ((StringRenderer) renderer).mouseClicked(e, rectangle.x);
                }
            }
        }
    });
    // Create and install a popup
    Icon ico = ModelerUtil.buildIcon("icon-edit.png");
    resolveMenu = new CayenneAction.CayenneMenuItem("Database Mapping", 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) ObjRelationship(org.apache.cayenne.map.ObjRelationship) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Rectangle(java.awt.Rectangle) 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 4 with CayenneTable

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

the class DbEntityRelationshipPanel method init.

protected void init() {
    this.setLayout(new BorderLayout());
    ActionManager actionManager = Application.getInstance().getActionManager();
    table = new CayenneTable();
    table.setDefaultRenderer(DbEntity.class, CellRenderers.entityTableRendererWithIcons(mediator));
    table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
    tablePreferences = new TableColumnPreferences(DbRelationshipTableModel.class, "relationshipTable");
    // Create and install a popup
    Icon ico = ModelerUtil.buildIcon("icon-edit.png");
    resolveMenu = new CayenneAction.CayenneMenuItem("Database Mapping", 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 : ActionManager(org.apache.cayenne.modeler.action.ActionManager) BoardTableCellRenderer(org.apache.cayenne.modeler.util.BoardTableCellRenderer) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) Icon(javax.swing.Icon) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction) JPopupMenu(javax.swing.JPopupMenu)

Example 5 with CayenneTable

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

the class DbEntityAttributePanel method initView.

private void initView() {
    this.setLayout(new BorderLayout());
    ActionManager actionManager = Application.getInstance().getActionManager();
    // Create table with two columns and no rows.
    table = new CayenneTable();
    tablePreferences = new TableColumnPreferences(DbAttributeTableModel.class, "attributeTable");
    table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
    // Create and install a popup
    JPopupMenu popup = new JPopupMenu();
    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 : ActionManager(org.apache.cayenne.modeler.action.ActionManager) BoardTableCellRenderer(org.apache.cayenne.modeler.util.BoardTableCellRenderer) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) JPopupMenu(javax.swing.JPopupMenu)

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