Search in sources :

Example 56 with Row

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

the class QueryView method getQuery.

public Query getQuery() {
    if (selectableTableView == null)
        return null;
    Query query = new Query(new HashMap<String, String>(0));
    List<Row> rows = selectableTableView.getSelectedRows();
    ArrayList<Element> elements = new ArrayList<Element>(rows.size());
    for (Row row : rows) elements.add(row.getElement());
    query.setElements(elements);
    return query;
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Query(com.ramussoft.report.Query) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

Example 57 with Row

use of com.ramussoft.database.common.Row 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 58 with Row

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

the class ChartSetsView method deleteDiagram.

public void deleteDiagram() {
    List<Row> rows = new ArrayList<Row>();
    int[] sels = table.getSelectedRows();
    for (int i : sels) {
        TreePath path = table.getPathForRow(i);
        if (path != null) {
            TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
            if (node != null) {
                Row row = node.getRow();
                if (row != null)
                    rows.add(row);
            }
        }
    }
    if (rows.size() > 0) {
        if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
        Engine engine = framework.getEngine();
        ((Journaled) engine).startUserTransaction();
        for (Row row : rows) engine.deleteElement(row.getElementId());
        ((Journaled) engine).commitUserTransaction();
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row) Engine(com.ramussoft.common.Engine)

Example 59 with Row

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

the class ChartSetsView method deleteChartSet.

public void deleteChartSet() {
    List<Row> rows = new ArrayList<Row>();
    int[] sels = table.getSelectedRows();
    for (int i : sels) {
        TreePath path = table.getPathForRow(i);
        if (path != null) {
            TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
            if (node != null) {
                Row row = node.getRow();
                if (row != null)
                    rows.add(row);
            }
        }
    }
    if (rows.size() > 0) {
        if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
        Engine engine = framework.getEngine();
        ((Journaled) engine).startUserTransaction();
        for (Row row : rows) ChartPlugin.deleteChartSet(engine, row.getElement());
        ((Journaled) engine).commitUserTransaction();
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row) Engine(com.ramussoft.common.Engine)

Example 60 with Row

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

the class OtherElementTableCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int columnIndex) {
    this.table = table;
    if (value instanceof String) {
        Row r = rowSet.findRow((String) value);
        if (r != null)
            value = r.getElementId();
        else
            value = null;
    }
    if (value instanceof Long) {
        value = new RowAttributeWrapper(rowSet.findRow((Long) value), nameAttribute);
    }
    this.value = value;
    if (value != null)
        this.value = ((RowAttributeWrapper) value).getRow().getElementId();
    Row row = (value != null) ? ((RowAttributeWrapper) value).getRow() : null;
    if (row == null) {
        codeField.setText("");
        valueField.setText("");
    } else {
        codeField.setText(row.getCode());
        valueField.setText(value.toString());
        valueField.setCaretPosition(0);
    }
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            codeField.selectAll();
            codeField.requestFocus();
        }
    });
    if (table instanceof ElementsTable) {
        element = ((ElementsTable) table).getElementForRow(rowIndex);
    }
    return component;
}
Also used : ElementsTable(com.ramussoft.gui.qualifier.table.ElementsTable) Row(com.ramussoft.database.common.Row) RowAttributeWrapper(com.ramussoft.gui.attribute.OtherElementPlugin.RowAttributeWrapper)

Aggregations

Row (com.ramussoft.database.common.Row)81 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)20 Attribute (com.ramussoft.common.Attribute)19 ArrayList (java.util.ArrayList)18 Qualifier (com.ramussoft.common.Qualifier)17 TreePath (javax.swing.tree.TreePath)15 Engine (com.ramussoft.common.Engine)13 Element (com.ramussoft.common.Element)12 RootRow (com.ramussoft.database.common.RowSet.RootRow)12 RowSet (com.ramussoft.database.common.RowSet)9 ActionEvent (java.awt.event.ActionEvent)8 AbstractAction (javax.swing.AbstractAction)8 RowTreeTable (com.ramussoft.gui.qualifier.table.RowTreeTable)6 MouseAdapter (java.awt.event.MouseAdapter)6 MouseEvent (java.awt.event.MouseEvent)6 JComponent (javax.swing.JComponent)6 JScrollPane (javax.swing.JScrollPane)6 AccessRules (com.ramussoft.common.AccessRules)5 Journaled (com.ramussoft.common.journal.Journaled)5 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)5