Search in sources :

Example 21 with ComponentAdapter

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();
            }
        }
    });
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter) ObjEntityDisplayListener(org.apache.cayenne.modeler.event.ObjEntityDisplayListener)

Example 22 with ComponentAdapter

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());
        }
    });
}
Also used : BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DataNodeDisplayListener(org.apache.cayenne.modeler.event.DataNodeDisplayListener) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) ComponentEvent(java.awt.event.ComponentEvent) ProjectController(org.apache.cayenne.modeler.ProjectController) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 23 with ComponentAdapter

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()");
}
Also used : DataNodeDisplayListener(org.apache.cayenne.modeler.event.DataNodeDisplayListener) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComponentEvent(java.awt.event.ComponentEvent) ProjectController(org.apache.cayenne.modeler.ProjectController) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 24 with ComponentAdapter

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()");
}
Also used : BindingBuilder(org.apache.cayenne.swing.BindingBuilder) DataNodeDisplayListener(org.apache.cayenne.modeler.event.DataNodeDisplayListener) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) ComponentEvent(java.awt.event.ComponentEvent) ProjectController(org.apache.cayenne.modeler.ProjectController) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 25 with ComponentAdapter

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);
            }
        }
    });
}
Also used : JButton(javax.swing.JButton) NavigateForwardAction(org.apache.cayenne.modeler.action.NavigateForwardAction) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) NavigateBackwardAction(org.apache.cayenne.modeler.action.NavigateBackwardAction) MainToolBar(org.apache.cayenne.swing.components.MainToolBar) ComponentEvent(java.awt.event.ComponentEvent) RemoveAction(org.apache.cayenne.modeler.action.RemoveAction) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

ComponentAdapter (java.awt.event.ComponentAdapter)96 ComponentEvent (java.awt.event.ComponentEvent)96 Dimension (java.awt.Dimension)17 ActionEvent (java.awt.event.ActionEvent)17 JPanel (javax.swing.JPanel)17 JButton (javax.swing.JButton)15 Component (java.awt.Component)14 MouseEvent (java.awt.event.MouseEvent)14 JLabel (javax.swing.JLabel)13 JScrollPane (javax.swing.JScrollPane)13 BorderLayout (java.awt.BorderLayout)12 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 MouseAdapter (java.awt.event.MouseAdapter)11 Point (java.awt.Point)10 ActionListener (java.awt.event.ActionListener)10 AbstractAction (javax.swing.AbstractAction)8 BoxLayout (javax.swing.BoxLayout)8 JComponent (javax.swing.JComponent)8 JTable (javax.swing.JTable)8