Search in sources :

Example 1 with RowChildAdapter

use of com.ramussoft.database.common.RowChildAdapter in project ramus by Vitaliy-Yakovchuk.

the class ReportsView method createComponent.

@Override
public JComponent createComponent() {
    JComponent createComponent = super.createComponent();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    openReport();
                } else {
                    if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < QualifierView.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();
        }
    });
    component.getRowSet().addRowChildListener(new RowChildAdapter() {

        @Override
        public void addedByThisRowSet(final Row row) {
            row.setAttribute(ReportPlugin.getReportTypeAttribute(engine), createType);
            row.setAttribute(ReportPlugin.getReportNameAttribute(engine), name);
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    openReport(row);
                }
            });
        }
    });
    return createComponent;
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) RowChildAdapter(com.ramussoft.database.common.RowChildAdapter) JComponent(javax.swing.JComponent) MouseAdapter(java.awt.event.MouseAdapter) Row(com.ramussoft.database.common.Row) AbstractAction(javax.swing.AbstractAction)

Example 2 with RowChildAdapter

use of com.ramussoft.database.common.RowChildAdapter in project ramus by Vitaliy-Yakovchuk.

the class QualifierView method createInnerComponent.

@Override
protected void createInnerComponent() {
    super.createInnerComponent();
    ((AbstractTableModel) component.getTable().getModel()).fireTableStructureChanged();
    component.getTable().setLeafIcon(new ImageIcon(getClass().getResource("/com/ramussoft/gui/table/qualifier.png")));
    getComponent().getRowSet().addRowChildListener(new RowChildAdapter() {

        @Override
        public void added(Row parent, Row row, int index) {
            if (parent.getParent() == null)
                return;
            framework.propertyChanged("CloseQualifier", StandardAttributesPlugin.getQualifierId(engine, parent.getElementId()));
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) RowChildAdapter(com.ramussoft.database.common.RowChildAdapter) AbstractTableModel(javax.swing.table.AbstractTableModel) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Aggregations

Row (com.ramussoft.database.common.Row)2 RowChildAdapter (com.ramussoft.database.common.RowChildAdapter)2 RootRow (com.ramussoft.database.common.RowSet.RootRow)1 ActionEvent (java.awt.event.ActionEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 AbstractAction (javax.swing.AbstractAction)1 ImageIcon (javax.swing.ImageIcon)1 JComponent (javax.swing.JComponent)1 AbstractTableModel (javax.swing.table.AbstractTableModel)1