Search in sources :

Example 36 with Row

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

the class ElistPanel method getElementInfo.

public ElementInfo getElementInfo(long elementId) {
    int c = table.getRowCount();
    for (int row = 0; row < c; row++) {
        TreeTableNode node = (TreeTableNode) table.getPathForRow(row).getLastPathComponent();
        Row r = node.getRow();
        if ((r != null) && (r.getElementId() == elementId)) {
            return new ElementInfo(getRowY(row), false);
        }
        if (table.isCollapsed(row)) {
            if (isPresent(node, elementId)) {
                return new ElementInfo(getRowY(row), true);
            }
        }
    }
    return null;
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row)

Example 37 with Row

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

the class ElementListAttributeEditor method getValue.

@Override
public Object getValue() {
    List<ElementListPersistent> list = new ArrayList<ElementListPersistent>();
    List<Row> rows = component.getModel().getSelectedRows();
    for (Row row : rows) {
        ElementListPersistent p;
        if (left) {
            p = new ElementListPersistent(row.getElementId(), element.getId());
        } else {
            p = new ElementListPersistent(element.getId(), row.getElementId());
        }
        list.add(p);
    }
    Collections.sort(list);
    return list;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

Example 38 with Row

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

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

the class ChartSetView method createComponent.

@Override
public JComponent createComponent() {
    final JLabel label = new JLabel(ChartResourceManager.getString("Message.MoveChartToChartSet"));
    desktop = new JDesktopPane();
    desktop.setTransferHandler(new TransferHandler("") {

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

        @Override
        public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
            for (DataFlavor flavor : transferFlavors) {
                if (flavor.equals(RowTreeTable.rowsListFlavor)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public boolean importData(JComponent comp, Transferable t) {
            try {
                Rows rows = (Rows) t.getTransferData(RowTreeTable.rowsListFlavor);
                if (rows.size() > 0) {
                    ((Journaled) engine).startUserTransaction();
                    for (Row row : rows) {
                        Point position = comp.getMousePosition();
                        if (position == null)
                            position = new Point(10, 10);
                        ChartPlugin.addChartLink(engine, element, row.getElement(), position.getX(), position.getY(), 340, 300);
                    }
                }
                ((Journaled) engine).commitUserTransaction();
                return rows.size() > 0;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return false;
        }
    });
    label.setBackground(desktop.getBackground());
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    List<ChartBounds> bounds = ChartPlugin.getChartBounds(engine, element);
    for (ChartBounds cb : bounds) {
        final JInternalFrame frame = new JInternalFrame(cb.getChart().getName(), true, true, true, true);
        final ChartView chartView = new ChartView(framework, cb.getChart()) {

            protected void titleChanged(String newTitle) {
                frame.setTitle(newTitle);
                reload();
            }
        };
        final ChartBounds b = cb;
        frame.setSize((int) cb.getWidth(), (int) cb.getHeight());
        frame.setLocation((int) cb.getX(), (int) cb.getY());
        frame.setContentPane(chartView.createComponent());
        desktop.add(frame);
        frame.setVisible(true);
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                ChartHolder holder = new ChartHolder(chartView, frame, b.getLink());
                holders.add(holder);
            }
        });
    }
    return desktop;
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) Point(java.awt.Point) PrinterException(java.awt.print.PrinterException) DataFlavor(java.awt.datatransfer.DataFlavor) TransferHandler(javax.swing.TransferHandler) ChartBounds(com.ramussoft.chart.core.ChartBounds) Row(com.ramussoft.database.common.Row) JInternalFrame(javax.swing.JInternalFrame) Rows(com.ramussoft.gui.qualifier.table.Rows)

Example 40 with Row

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

the class ChartsView method createComponent.

@Override
public JComponent createComponent() {
    Engine engine = framework.getEngine();
    AccessRules accessRules = framework.getAccessRules();
    component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
    component.getTable().addSelectionListener(new SelectionListener() {

        @Override
        public void changeSelection(SelectionEvent event) {
            TreeTableNode selectedNode = component.getTable().getSelectedNode();
            if (selectedNode == null)
                chartPrefernecesAction.setEnabled(false);
            else {
                Row row = selectedNode.getRow();
                chartPrefernecesAction.setEnabled(row != null);
            }
            openChartAction.setEnabled(chartPrefernecesAction.isEnabled());
            deleteChartAction.setEnabled(chartPrefernecesAction.isEnabled());
        }
    });
    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)) {
                    openDiagram();
                } 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.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();
        }
    });
    table.setExportRows(true);
    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)

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