Search in sources :

Example 6 with Row

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

the class RowTreeTable method getCellRenderer.

@Override
public TableCellRenderer getCellRenderer(final int row, final int column) {
    int aColumn = convertColumnIndexToModel(column);
    final TableCellRenderer r = cellRenderers[aColumn];
    if (aColumn == 0) {
        JTree tree = (JTree) super.getCellRenderer(row, column);
        DelegatingRenderer rend = ((DelegatingRenderer) tree.getCellRenderer());
        TreePath pathForRow = tree.getPathForRow(convertRowIndexToModel(row));
        if (pathForRow == null)
            return super.getCellRenderer(row, column);
        Object object = pathForRow.getLastPathComponent();
        boolean setDefault = true;
        Row row2 = null;
        if (object instanceof TreeTableNode) {
            row2 = ((TreeTableNode) object).getRow();
        }
        if (row2 != null) {
            Hashtable<Long, ImageIcon> icons = IconFactory.getIcons(rowSet.getEngine());
            Icon icon = getDefaultIcon(row2);
            if (icon == null && row2.getHierarchicalPersistent() != null)
                icon = icons.get(row2.getHierarchicalPersistent().getIconId());
            setDefault = false;
            if (icon != null) {
                rend.setLeafIcon(icon);
                rend.setOpenIcon(icon);
                rend.setClosedIcon(icon);
            } else {
                ImageIcon l = IconFactory.getLeafIcons(rowSet.getEngine()).get(row2.getElement().getQualifierId());
                ImageIcon o = IconFactory.getOpenIcons(rowSet.getEngine()).get(row2.getElement().getQualifierId());
                ImageIcon c = IconFactory.getClosedIcons(rowSet.getEngine()).get(row2.getElement().getQualifierId());
                rend.setLeafIcon((l == null) ? getLeafIcon() : l);
                rend.setOpenIcon((o == null) ? getFolderIcon() : o);
                rend.setClosedIcon((c == null) ? getFolderSheetIcon() : c);
            }
        }
        if (setDefault) {
            rend.setLeafIcon(getLeafIcon());
            rend.setOpenIcon(getFolderIcon());
            rend.setClosedIcon(getFolderSheetIcon());
        }
    }
    if (aColumn == 0)
        return super.getCellRenderer(row, column);
    if ((r != null) && (aColumn == 0)) {
        // DefaultTreeCellRenderer
        JTree tree = (JTree) super.getCellRenderer(row, column);
        if (x == null) {
            x = new TreeCellRenderer() {

                @Override
                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int aRow, boolean hasFocus) {
                    return r.getTableCellRendererComponent(RowTreeTable.this, getValueAt(aRow, column), selected, hasFocus, aRow, 0);
                }
            };
            tree.setCellRenderer(x);
        }
        return (TableCellRenderer) tree;
    }
    return (r == null) ? super.getCellRenderer(row, column) : r;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) ImageIcon(javax.swing.ImageIcon) TreeCellRenderer(javax.swing.tree.TreeCellRenderer) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) DelegatingRenderer(org.jdesktop.swingx.JXTree.DelegatingRenderer) EventObject(java.util.EventObject) Row(com.ramussoft.database.common.Row) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon) Component(java.awt.Component)

Example 7 with Row

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

the class RowTreeTable method getRowMover.

private RowMover getRowMover(final int[] sels) {
    final Row[] group = getShownRows();
    final RowMover mover = new RowMover(rowSet.getRoot(), group, sels, accessRules, rowSet);
    return mover;
}
Also used : RowMover(com.ramussoft.database.common.RowMover) Row(com.ramussoft.database.common.Row)

Example 8 with Row

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

the class QualifierView method openQualifier.

protected void openQualifier() {
    for (int i : table.getSelectedRows()) {
        if (i >= 0) {
            TreePath path = table.getPathForRow(i);
            if (path != null) {
                TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
                if (node != null) {
                    Row row = node.getRow();
                    if (row != null) {
                        if (row.getChildCount() == 0) {
                            table.setEditable(false);
                            openQualifier(row);
                            table.setEditable(true);
                        }
                    }
                }
            }
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 9 with Row

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

the class SelectRowPanel method createRightComponent.

private void createRightComponent() {
    if (qualifierView == null)
        return;
    qualifier = qualifierView.getSelectedQualifier();
    boolean b = qualifier != null;
    if (b) {
        framework.setOpenDynamikViewEvent(new ActionEvent(QualifierPlugin.OPEN_QUALIFIER, qualifier));
        selectableTableView = new SelectableTableView(framework, dataPlugin.getEngine(), accessRules, qualifier) {
        };
        int dl = splitPane.getDividerLocation();
        splitPane.setRightComponent(createComponent());
        for (Row row : getSelectedRows(qualifier)) selectableTableView.getComponent().getModel().setSelectedRow(selectableTableView.getComponent().getRowSet().findRow(row.getElementId()), true);
        splitPane.revalidate();
        splitPane.repaint();
        splitPane.setDividerLocation(dl);
        selectableTableView.getComponent().getModel().addSelectionListener(selectionListener);
        if (!getSelectType().equals(SelectType.CHECK))
            selectableTableView.setSelectType(getSelectType());
    }
}
Also used : ActionEvent(com.ramussoft.gui.common.event.ActionEvent) Row(com.ramussoft.database.common.Row) SelectableTableView(com.ramussoft.gui.qualifier.table.SelectableTableView)

Example 10 with Row

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

the class SelectRowPanel method deleteRightPanel.

private void deleteRightPanel() {
    if (selectableTableView != null) {
        selectableTableView.getComponent().getModel().removeSelectionListener(selectionListener);
        List<Row> list = selectableTableView.getComponent().getModel().getSelectedRows();
        selectedRows.put(qualifier, list);
        selectableTableView.close();
        selectableTableView = null;
        splitPane.setRightComponent(new JPanel());
    }
}
Also used : JPanel(javax.swing.JPanel) 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