Search in sources :

Example 6 with SelectionListener

use of com.ramussoft.gui.qualifier.table.event.SelectionListener in project ramus by Vitaliy-Yakovchuk.

the class ChartsView method createComponent.

@Override
public JComponent createComponent() {
    Engine engine = framework.getEngine();
    AccessRules accessRules = framework.getAccessRules();
    component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
    component.getTable().addSelectionListener(new SelectionListener() {

        @Override
        public void changeSelection(SelectionEvent event) {
            TreeTableNode selectedNode = component.getTable().getSelectedNode();
            if (selectedNode == null)
                chartPrefernecesAction.setEnabled(false);
            else {
                Row row = selectedNode.getRow();
                chartPrefernecesAction.setEnabled(row != null);
            }
            openChartAction.setEnabled(chartPrefernecesAction.isEnabled());
            deleteChartAction.setEnabled(chartPrefernecesAction.isEnabled());
        }
    });
    table = component.getTable();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    openDiagram();
                } else {
                    if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
                        if (!table.isEditing()) {
                            editTableField();
                        }
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        lastSelectedRows = table.getSelectedRows();
                    }
                }
            }
        }
    });
    table.setEditIfNullEvent(false);
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
    table.getActionMap().put("EditCell", new AbstractAction() {

        /**
         */
        private static final long serialVersionUID = 3229634866196074563L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
                editTableField();
        }
    });
    table.setExportRows(true);
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) AccessRules(com.ramussoft.common.AccessRules) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) Row(com.ramussoft.database.common.Row) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 7 with SelectionListener

use of com.ramussoft.gui.qualifier.table.event.SelectionListener in project ramus by Vitaliy-Yakovchuk.

the class ChartSetsView method createComponent.

@Override
public JComponent createComponent() {
    Engine engine = framework.getEngine();
    AccessRules accessRules = framework.getAccessRules();
    component = new RowTreeTableComponent(engine, ChartPlugin.getChartSets(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
    table = component.getTable();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    openChartSet();
                } else {
                    if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
                        if (!table.isEditing()) {
                            editTableField();
                        }
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        lastSelectedRows = table.getSelectedRows();
                    }
                }
            }
        }
    });
    table.addSelectionListener(new SelectionListener() {

        @Override
        public void changeSelection(SelectionEvent event) {
            TreeTableNode selectedNode = component.getTable().getSelectedNode();
            if (selectedNode == null)
                openChartSetAction.setEnabled(false);
            else {
                Row row = selectedNode.getRow();
                openChartSetAction.setEnabled(row != null);
            }
            deleteChartSetAction.setEnabled(openChartSetAction.isEnabled());
        }
    });
    table.setEditIfNullEvent(false);
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
    table.getActionMap().put("EditCell", new AbstractAction() {

        /**
         */
        private static final long serialVersionUID = 3229634866196074563L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
                editTableField();
        }
    });
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) AccessRules(com.ramussoft.common.AccessRules) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) Row(com.ramussoft.database.common.Row) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 8 with SelectionListener

use of com.ramussoft.gui.qualifier.table.event.SelectionListener in project ramus by Vitaliy-Yakovchuk.

the class RowTreeTable method changeSelection.

@Override
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
    super.changeSelection(rowIndex, columnIndex, toggle, extend);
    SelectionEvent event = new SelectionEvent(null, false);
    for (SelectionListener listener : getSelectionListeners()) {
        listener.changeSelection(event);
    }
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 9 with SelectionListener

use of com.ramussoft.gui.qualifier.table.event.SelectionListener in project ramus by Vitaliy-Yakovchuk.

the class RowTreeTableModel method clearSelection.

public void clearSelection() {
    Set<Row> rows = selectedRows.keySet();
    SelectionEvent event = new SelectionEvent(rows.toArray(new Row[rows.size()]), false);
    selectedRows.clear();
    for (SelectionListener l : getSelectionListeners()) l.changeSelection(event);
}
Also used : SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) Row(com.ramussoft.database.common.Row) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 10 with SelectionListener

use of com.ramussoft.gui.qualifier.table.event.SelectionListener in project ramus by Vitaliy-Yakovchuk.

the class RowTreeTableModel method checkAll.

public void checkAll() {
    selectedRows.clear();
    for (Row row : getRowSet().getAllRows()) selectedRows.put(row, Boolean.TRUE);
    Set<Row> rows = selectedRows.keySet();
    SelectionEvent event = new SelectionEvent(rows.toArray(new Row[rows.size()]), true);
    for (SelectionListener l : getSelectionListeners()) {
        l.changeSelection(event);
    }
}
Also used : SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) Row(com.ramussoft.database.common.Row) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Aggregations

SelectionEvent (com.ramussoft.gui.qualifier.table.event.SelectionEvent)10 SelectionListener (com.ramussoft.gui.qualifier.table.event.SelectionListener)10 Row (com.ramussoft.database.common.Row)5 AbstractAction (javax.swing.AbstractAction)5 Attribute (com.ramussoft.common.Attribute)3 ActionEvent (java.awt.event.ActionEvent)3 AccessRules (com.ramussoft.common.AccessRules)2 Engine (com.ramussoft.common.Engine)2 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)2 QualifierView (com.ramussoft.gui.qualifier.QualifierView)2 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)2 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)2 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 JPanel (javax.swing.JPanel)2 RowTreeTable (com.ramussoft.gui.qualifier.table.RowTreeTable)1 SelectRowPanel (com.ramussoft.pb.frames.SelectRowPanel)1 Action (javax.swing.Action)1 ImageIcon (javax.swing.ImageIcon)1