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