Search in sources :

Example 11 with Attribute

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

the class AttributeOrderEditPanel method up.

protected void up() {
    int[] is = list.getSelectedRows();
    final ArrayList<Integer> nSel = new ArrayList<Integer>();
    for (int i = 0; i < is.length; i++) {
        final int index = is[i];
        if (index > 0) {
            final Attribute obj = attributes.get(index);
            attributes.remove(index);
            final int j = index - 1;
            attributes.add(j, obj);
            nSel.add(j);
        } else
            is[i] = -1;
    }
    is = new int[nSel.size()];
    for (int i = 0; i < is.length; i++) is[i] = nSel.get(i);
    list.getSelectionModel().clearSelection();
    for (int i : is) list.getSelectionModel().addSelectionInterval(i, i);
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList)

Example 12 with Attribute

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

the class QualifierHistoryPlugin method showHistory.

@SuppressWarnings("unchecked")
protected void showHistory(TableTabView tableView, Element element, Attribute attribute) {
    GUIFramework framework = tableView.getFramework();
    Hashtable<Element, Hashtable<Attribute, HistoryDialog>> h = (Hashtable<Element, Hashtable<Attribute, HistoryDialog>>) framework.get("HistoryDialogs");
    if (h == null) {
        h = new Hashtable<Element, Hashtable<Attribute, HistoryDialog>>();
        framework.put("HistoryDialogs", h);
    }
    Hashtable<Attribute, HistoryDialog> h1 = h.get(element);
    if (h1 == null) {
        h1 = new Hashtable<Attribute, HistoryDialog>();
        h.put(element, h1);
    }
    HistoryDialog hd = h1.get(attribute);
    if (hd == null) {
        hd = new HistoryDialog(framework, this, element, attribute);
        h1.put(attribute, hd);
    }
    hd.setVisible(true);
}
Also used : Attribute(com.ramussoft.common.Attribute) GUIFramework(com.ramussoft.gui.common.GUIFramework) Hashtable(java.util.Hashtable) Element(com.ramussoft.common.Element)

Example 13 with Attribute

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

the class QualifierHistoryPlugin method getHistoryAction.

private Action getHistoryAction(final TableTabView tableView) {
    Action res = (Action) tableView.getTag().get("HistoryAction");
    if (res == null) {
        final Action action = new AbstractAction() {

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

            {
                putValue(ACTION_COMMAND_KEY, "Action.ShowHistory");
                putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/gui/table/history.png")));
                setEnabled(false);
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                RowTreeTable table = tableView.getComponent().getTable();
                Row row;
                if ((table.getSelectedColumn() >= 0) && (table.getSelectedNode() != null) && ((row = table.getSelectedNode().getRow()) != null)) {
                    int c = table.convertColumnIndexToModel(table.getSelectedColumn());
                    Attribute attribute = table.getRowSet().getAttributes()[c];
                    showHistory(tableView, row.getElement(), attribute);
                }
            }
        };
        res = action;
        tableView.getTag().put("HistoryAction", res);
        tableView.getComponent().getTable().addSelectionListener(new SelectionListener() {

            @Override
            public void changeSelection(SelectionEvent event) {
                RowTreeTable table = tableView.getComponent().getTable();
                Row row;
                if ((table.getSelectedColumn() >= 0) && (table.getSelectedNode() != null) && ((row = table.getSelectedNode().getRow()) != null)) {
                    int c = table.convertColumnIndexToModel(table.getSelectedColumn());
                    Attribute attribute = table.getRowSet().getAttributes()[c];
                    action.setEnabled(StandardAttributesPlugin.hasHistory(tableView.getFramework().getEngine(), row.getElement(), attribute));
                } else {
                    action.setEnabled(false);
                }
            }
        });
    }
    return res;
}
Also used : ImageIcon(javax.swing.ImageIcon) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) Attribute(com.ramussoft.common.Attribute) ActionEvent(java.awt.event.ActionEvent) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) Row(com.ramussoft.database.common.Row) RowTreeTable(com.ramussoft.gui.qualifier.table.RowTreeTable) AbstractAction(javax.swing.AbstractAction) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 14 with Attribute

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

the class AttributeHierarchyEditorPanel method moveLeft.

private void moveLeft(final int index) {
    final Object o = rightModel.get(index);
    rightModel.removeElementAt(index);
    int j = -1;
    for (final Attribute element : allAttributes) {
        if (o == element)
            break;
        if (leftModel.size() <= j + 1)
            break;
        if (leftModel.get(j + 1) == element) {
            j++;
        }
    }
    j++;
    leftModel.add(j, o);
}
Also used : Attribute(com.ramussoft.common.Attribute)

Example 15 with Attribute

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

the class RowTreeTableModel method getValueAt.

@Override
public Object getValueAt(Object node, int index) {
    TreeTableNode tableRow = (TreeTableNode) node;
    if (tableRow instanceof GroupNode) {
        if (index == 0) {
            GroupNode groupNode = (GroupNode) tableRow;
            if (table != null) {
                Attribute attribute = groupNode.getAttribute();
                if (attribute != null) {
                    AttributePlugin plugin = framework.findAttributePlugin(attribute);
                    TableCellRenderer renderer = plugin.getTableCellRenderer(rowSet.getEngine(), framework.getAccessRules(), attribute);
                    if (renderer != null) {
                        try {
                            Component c = renderer.getTableCellRendererComponent(table, groupNode.getValue(), false, false, -1, -1);
                            if (c instanceof JLabel)
                                return ((JLabel) c).getText();
                        } catch (Exception e) {
                        // e.printStackTrace();
                        }
                    }
                }
            }
            return groupNode.getValue();
        }
        return null;
    }
    return localizers[index].getValue(valueGetters[index].getValue(tableRow, index));
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) JLabel(javax.swing.JLabel) Component(java.awt.Component)

Aggregations

Attribute (com.ramussoft.common.Attribute)203 Qualifier (com.ramussoft.common.Qualifier)72 Element (com.ramussoft.common.Element)70 ArrayList (java.util.ArrayList)53 Engine (com.ramussoft.common.Engine)32 List (java.util.List)20 Row (com.ramussoft.database.common.Row)19 Hashtable (java.util.Hashtable)19 SQLException (java.sql.SQLException)16 AttributeType (com.ramussoft.common.AttributeType)15 FindObject (com.ramussoft.common.attribute.FindObject)11 AttributeEvent (com.ramussoft.common.event.AttributeEvent)11 ResultSet (java.sql.ResultSet)11 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)10 AccessRules (com.ramussoft.common.AccessRules)9 Transaction (com.ramussoft.common.persistent.Transaction)9 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)9 RowMapper (com.ramussoft.jdbc.RowMapper)9 Row (com.ramussoft.pb.Row)9 ImageIcon (javax.swing.ImageIcon)9