use of java.awt.event.ComponentAdapter in project cayenne by apache.
the class ObjEntityCallbackMethodsTab method initController.
/**
* listeners initialization
*/
protected void initController() {
super.initController();
addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
rebuildTables();
}
});
mediator.addObjEntityDisplayListener(new ObjEntityDisplayListener() {
public void currentObjEntityChanged(EntityDisplayEvent e) {
if (ObjEntityCallbackMethodsTab.this.isVisible()) {
rebuildTables();
}
}
});
}
use of java.awt.event.ComponentAdapter in project cayenne by apache.
the class AdapterEditor method initController.
protected void initController() {
// init bindings
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
adapterNameBinding = builder.bindToTextField(view.getCustomAdapter(), "adapterName");
((ProjectController) getParent()).addDataNodeDisplayListener(new DataNodeDisplayListener() {
public void currentDataNodeChanged(DataNodeDisplayEvent e) {
refreshView(e.getDataNode());
}
});
getView().addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
refreshView(node != null ? node : ((ProjectController) getParent()).getCurrentDataNode());
}
});
}
use of java.awt.event.ComponentAdapter in project cayenne by apache.
the class MainDataNodeEditor method initController.
protected void initController() {
view.getDataSourceDetail().add(defaultSubeditor.getView(), "default");
view.getFactories().setEditable(true);
// init combo box choices
view.getFactories().setModel(new DefaultComboBoxModel(standardDataSourceFactories));
view.getSchemaUpdateStrategy().setEditable(true);
view.getSchemaUpdateStrategy().setModel(new DefaultComboBoxModel(standardSchemaUpdateStrategy));
// init listeners
((ProjectController) getParent()).addDataNodeDisplayListener(new DataNodeDisplayListener() {
public void currentDataNodeChanged(DataNodeDisplayEvent e) {
refreshView(e.getDataNode());
}
});
getView().addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
refreshView(node != null ? node : ((ProjectController) getParent()).getCurrentDataNode());
}
});
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
localDataSourceBinding = builder.bindToComboSelection(view.getLocalDataSources(), "parent.dataNodePreferences.localDataSource", NO_LOCAL_DATA_SOURCE);
// use delegate for the rest of them
builder.setDelegate(nodeChangeProcessor);
bindings = new ObjectBinding[3];
bindings[0] = builder.bindToTextField(view.getDataNodeName(), "nodeName");
bindings[1] = builder.bindToComboSelection(view.getFactories(), "factoryName");
bindings[2] = builder.bindToComboSelection(view.getSchemaUpdateStrategy(), "schemaUpdateStrategy");
// one way bindings
builder.bindToAction(view.getConfigLocalDataSources(), "dataSourceConfigAction()");
}
use of java.awt.event.ComponentAdapter in project cayenne by apache.
the class PasswordEncoderEditor method initController.
protected void initController() {
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.setDelegate(nodeChangeProcessor);
bindings = new ObjectBinding[4];
bindings[0] = builder.bindToComboSelection(view.getPasswordEncoder(), "node.dataSourceDescriptor.passwordEncoderClass");
bindings[1] = builder.bindToTextField(view.getPasswordKey(), "node.dataSourceDescriptor.passwordEncoderKey");
bindings[2] = builder.bindToComboSelection(view.getPasswordLocation(), "node.dataSourceDescriptor.passwordLocation");
bindings[3] = builder.bindToTextField(view.getPasswordSource(), "node.dataSourceDescriptor.passwordSource");
((ProjectController) getParent()).addDataNodeDisplayListener(new DataNodeDisplayListener() {
public void currentDataNodeChanged(DataNodeDisplayEvent e) {
refreshView(e.getDataNode());
}
});
getView().addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
refreshView(node != null ? node : ((ProjectController) getParent()).getCurrentDataNode());
}
});
builder.bindToAction(view.getPasswordEncoder(), "validatePasswordEncoderAction()");
builder.bindToAction(view.getPasswordLocation(), "passwordLocationChangedAction()");
}
use of java.awt.event.ComponentAdapter in project cayenne by apache.
the class CayenneModelerFrame method initToolbar.
/**
* Initializes main toolbar.
*/
protected void initToolbar() {
final JToolBar toolBar = new MainToolBar();
Dimension smallBtnDim = new Dimension(30, 30);
JButton backButton = getAction(NavigateBackwardAction.class).buildButton(1);
backButton.setMinimumSize(smallBtnDim);
backButton.setPreferredSize(smallBtnDim);
toolBar.add(backButton);
JButton forwardButton = getAction(NavigateForwardAction.class).buildButton(3);
forwardButton.setMinimumSize(smallBtnDim);
forwardButton.setPreferredSize(smallBtnDim);
toolBar.add(forwardButton);
toolBar.addSeparator(new Dimension(30, 0));
toolBar.add(getAction(NewProjectAction.class).buildButton(1));
toolBar.add(getAction(OpenProjectAction.class).buildButton(2));
toolBar.add(getAction(SaveAction.class).buildButton(3));
toolBar.addSeparator();
JButton removeButton = getAction(RemoveAction.class).buildButton();
toolBar.add(removeButton);
toolBar.addSeparator();
toolBar.add(getAction(CutAction.class).buildButton(1));
toolBar.add(getAction(CopyAction.class).buildButton(2));
toolBar.add(getAction(PasteAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(UndoAction.class).buildButton(1));
toolBar.add(getAction(RedoAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateNodeAction.class).buildButton(1));
toolBar.add(getAction(CreateDataMapAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateDbEntityAction.class).buildButton(1));
toolBar.add(getAction(CreateProcedureAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateObjEntityAction.class).buildButton(1));
toolBar.add(getAction(CreateEmbeddableAction.class).buildButton(2));
toolBar.add(getAction(CreateQueryAction.class).buildButton(3));
// is used to place search feature components the most right on a toolbar
toolBar.add(new SearchPanel());
getContentPane().add(toolBar, BorderLayout.NORTH);
// Hide some buttons when frame is too small
final int defaultBtnWidth = removeButton.getUI().getPreferredSize(backButton).width;
addComponentListener(new ComponentAdapter() {
private final int[] empty = {};
private final int[] all = { 6, 7, 8, 9, 10, 11, 12, 13, 14 };
private final int[] remove = { 6, 7 };
private final int[] removeAndCopy = { 6, 7, 8, 9, 10, 11 };
private final int[] undo = { 12, 13, 14 };
private final int[] undoAndCopy = { 8, 9, 10, 11, 12, 13, 14 };
@Override
public void componentResized(ComponentEvent e) {
int[] hidden, shown;
if (getSize().width < (13 * defaultBtnWidth + 300)) {
hidden = all;
shown = empty;
} else if (getSize().width < (16 * defaultBtnWidth + 300)) {
hidden = removeAndCopy;
shown = undo;
} else if (getSize().width < (18 * defaultBtnWidth + 300)) {
hidden = remove;
shown = undoAndCopy;
} else {
hidden = empty;
shown = all;
}
for (int i : hidden) {
toolBar.getComponentAtIndex(i).setVisible(false);
}
for (int i : shown) {
toolBar.getComponentAtIndex(i).setVisible(true);
}
}
});
}
Aggregations