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);
}
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);
}
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;
}
Aggregations