Search in sources :

Example 51 with Row

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

the class StreamsTabView method createComponent.

@Override
public JComponent createComponent() {
    for (Row row : streams.getAllRows()) if (filterAdd(row))
        data.add(row);
    Collections.sort(data, new Comparator<Row>() {

        @Override
        public int compare(Row o1, Row o2) {
            return StringCollator.compare(o1.getName(), o2.getName());
        }
    });
    table = new JXTable(model = new AbstractTableModel() {

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            return data.get(rowIndex).getName();
        }

        @Override
        public int getRowCount() {
            return data.size();
        }

        @Override
        public int getColumnCount() {
            return 1;
        }

        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            data.get(rowIndex).setName(String.valueOf(aValue));
        }
    });
    table.setTableHeader(null);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            deleteElementAction.setEnabled(table.getSelectedRow() >= 0);
        }
    });
    table.setComponentPopupMenu(createPopupMenu());
    JScrollPane jScrollPane = new JScrollPane(table);
    return jScrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JXTable(org.jdesktop.swingx.JXTable) ListSelectionEvent(javax.swing.event.ListSelectionEvent) AbstractTableModel(javax.swing.table.AbstractTableModel) Row(com.ramussoft.database.common.Row) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 52 with Row

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

the class AttributePullView method setupAttribute.

private void setupAttribute() {
    AttributePreferenciesDialog dialog = new AttributePreferenciesDialogWithQualifierSet(framework);
    TreeTableNode node = table.getSelectedNode();
    if (node == null)
        return;
    Row row = node.getRow();
    Attribute attribute = engine.getAttribute((Long) row.getAttribute(attributeId));
    dialog.setAttribute(attribute);
    dialog.getOKButton().setEnabled(rules.canUpdateAttribute(attribute.getId()));
    dialog.setVisible(true);
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Attribute(com.ramussoft.common.Attribute) Row(com.ramussoft.database.common.Row)

Example 53 with Row

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

the class AttributePullView method refreshActions.

private void refreshActions() {
    createAttributeAction.setEnabled(rules.canCreateAttribute());
    if (table.getTreeSelectionModel().getSelectionPath() == null) {
        deleteAttributeAction.setEnabled(false);
        attributePreferencesAction.setEnabled(false);
    } else {
        boolean e = true;
        boolean e1 = true;
        TreePath[] paths = table.getTreeSelectionModel().getSelectionPaths();
        for (TreePath path : paths) {
            Row row = ((TreeTableNode) path.getLastPathComponent()).getRow();
            if (row == null) {
                e = false;
                e1 = false;
                break;
            }
            if (row.getChildCount() > 0) {
                e = false;
                break;
            }
            Long long1 = (Long) row.getAttribute(attributeId);
            if (long1 == null)
                break;
            long attrId = long1;
            if (!rules.canDeleteAttribute(attrId)) {
                e = false;
                break;
            }
            if (!rules.canUpdateAttribute(attrId)) {
                e1 = false;
                break;
            }
        }
        deleteAttributeAction.setEnabled(e);
        attributePreferencesAction.setEnabled(e1);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row)

Example 54 with Row

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

the class ElementListAttributeEditor method setValue.

@SuppressWarnings("unchecked")
@Override
public Object setValue(Object value) {
    component.getModel().clearSelection();
    List<ElementListPersistent> list = (List<ElementListPersistent>) value;
    RowSet rowSet = component.getRowSet();
    Row row = null;
    for (ElementListPersistent p : list) {
        long id = (left) ? p.getElement1Id() : p.getElement2Id();
        row = rowSet.findRow(id);
        if (row != null)
            component.getModel().setSelectedRow(row, true);
    }
    if (row != null)
        component.getTable().scrollRowToVisible(component.getTable().indexOfRow(row));
    Collections.sort(list);
    return value;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) RowSet(com.ramussoft.database.common.RowSet) ArrayList(java.util.ArrayList) List(java.util.List) Row(com.ramussoft.database.common.Row)

Example 55 with Row

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

the class ReportsView method openReport.

protected void openReport() {
    table.setEditable(false);
    TreeTableNode node = table.getSelectedNode();
    if (node != null) {
        Row row = node.getRow();
        if (row != null) {
            openReport(row);
        }
    }
    table.setEditable(true);
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row)

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