Search in sources :

Example 1 with GUIFramework

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

the class LogPlugin method getActions.

@Override
public Action[] getActions(final TableTabView tableView) {
    return new Action[] { new AbstractAction("EventType.qualifierLog", new ImageIcon(getClass().getResource("/com/ramussoft/client/log/log.png"))) {

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

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableView.getFramework();
            long qId = tableView.getQualifier().getId();
            List<Event> events = ((ILog) framework.getEngine()).getEventsWithParams(new String[] { EngineLogExtension.QUALIFIER_ID }, new Object[] { qId }, 150);
            ElementLogDialog dialog = new ElementLogDialog(events, framework.getEngine());
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));
            Options.loadOptions(dialog);
            dialog.setVisible(true);
            Options.saveOptions(dialog);
        }
    } };
}
Also used : ImageIcon(javax.swing.ImageIcon) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) GUIFramework(com.ramussoft.gui.common.GUIFramework) Event(com.ramussoft.common.logger.Event) ActionEvent(java.awt.event.ActionEvent) ILog(com.ramussoft.common.logger.ILog) AbstractAction(javax.swing.AbstractAction)

Example 2 with GUIFramework

use of com.ramussoft.gui.common.GUIFramework 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 3 with GUIFramework

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

the class ModelsPanel method init.

private void init() {
    tree = new RowTreeTableComponent(engine, IDEF0Plugin.getModelTree(engine), framework.getAccessRules(), new ModelRowCreator(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework) {

        @Override
        protected RowTreeTableModel createRowTreeTableModel(final Engine engine, Qualifier qualifier, AccessRules accessRules, RootCreater rootCreater, Attribute[] attributes, GUIFramework framework) {
            RowTreeTableModel rowTreeTableModel = new RowTreeTableModel(engine, qualifier, attributes, accessRules, rootCreater, framework) {

                @Override
                protected RowNode newRowNode(Row row) {
                    Long id = (Long) row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine));
                    if (id != null) {
                        Qualifier qualifier = engine.getQualifier(id);
                        if (qualifier != null) {
                            ModelsNode node = newModelsNode(row, qualifier);
                            node.getTreeTableModel().setTable(tree.getTable());
                            node.getTreeTableModel().setModelSupport(tree.getModel().getModelSupport());
                            return node;
                        }
                    }
                    return super.newRowNode(row);
                }

                @Override
                public boolean isCellEditable(Object node, int column) {
                    if (super.isCellEditable(node, column)) {
                        if (node instanceof ModelsNode)
                            return true;
                    }
                    return false;
                }
            };
            return rowTreeTableModel;
        }

        @Override
        protected RowTreeTable createTable(AccessRules accessRules, GUIFramework framework, AttributePlugin[] plugins) {
            return new RowTreeTable(accessRules, model.getRowSet(), plugins, framework, model) {

                long treeModelsId = IDEF0Plugin.getModelTree(engine).getId();

                @Override
                public Transferable createTransferable() {
                    final int[] is = getSelectedRows();
                    final ArrayList<Integer> al = new ArrayList<Integer>();
                    long id = IDEF0Plugin.getModelTree(engine).getId();
                    Rows rows = new Rows();
                    for (final int i : is) {
                        al.add(i);
                        TreeTableNode node = (TreeTableNode) getPathForRow(i).getLastPathComponent();
                        if ((node != null) && (node.getRow() != null)) {
                            Row row = node.getRow();
                            rows.add(row);
                            if (row.getElement().getQualifierId() != id)
                                return null;
                        }
                    }
                    exporting = true;
                    return new ArrayTransferable(al, rows);
                }

                @Override
                public boolean importData(Transferable t, boolean on, int aIndex) {
                    int index = aIndex;
                    long id = IDEF0Plugin.getModelTree(engine).getId();
                    if (index >= getRowCount())
                        index--;
                    if (index < 0)
                        return false;
                    TreeTableNode node = (TreeTableNode) getPathForRow(index).getLastPathComponent();
                    if (node.getRow() != null)
                        if (node.getRow().getElement().getQualifierId() != id)
                            return false;
                    return super.importData(t, on, aIndex);
                }

                @Override
                protected Icon getDefaultIcon(Row row) {
                    if (row.getElement().getQualifierId() != treeModelsId) {
                        if (row.getChildCount() == 0)
                            return note;
                        else
                            return function;
                    }
                    if (row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine)) == null)
                        return null;
                    return ModelsPanel.this.model;
                }
            };
        }
    };
    fixTable((TreeTableNode) tree.getModel().getRoot());
    tree.getTable().addMouseListener(new MouseAdapter() {

        private int[] lastSelectedRows;

        private long lastClickTime;

        @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 < QualifierView.EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, tree.getTable().getSelectedRows()))) {
                        if (!tree.getTable().isEditing()) {
                            editTableField();
                        }
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        lastSelectedRows = tree.getTable().getSelectedRows();
                    }
                }
            }
        }
    });
    tree.getTable().setEditIfNullEvent(false);
    tree.getTable().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
    tree.getTable().getActionMap().put("EditCell", new AbstractAction() {

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

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((tree.getTable().getSelectedRow() >= 0) && (tree.getTable().getSelectedColumn() >= 0))
                editTableField();
        }
    });
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane, BorderLayout.CENTER);
}
Also used : RootCreater(com.ramussoft.gui.qualifier.table.RootCreater) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) GUIFramework(com.ramussoft.gui.common.GUIFramework) RowNode(com.ramussoft.gui.qualifier.table.RowNode) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) RowTreeTable(com.ramussoft.gui.qualifier.table.RowTreeTable) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine) Rows(com.ramussoft.gui.qualifier.table.Rows) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Transferable(java.awt.datatransfer.Transferable) MouseAdapter(java.awt.event.MouseAdapter) RowTreeTableModel(com.ramussoft.gui.qualifier.table.RowTreeTableModel) AccessRules(com.ramussoft.common.AccessRules) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow) ImageIcon(javax.swing.ImageIcon) Icon(javax.swing.Icon)

Example 4 with GUIFramework

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

the class IDEF0Object method createEditFrame.

@Override
protected void createEditFrame() {
    final GUIFramework framework = movingArea.getPanel().getFramework();
    final Engine engine = framework.getEngine();
    long id = getFunction().getLink();
    Element element2 = null;
    if (id >= 0)
        element2 = engine.getElement(id);
    if (element2 == null)
        element2 = getFunction().getElement();
    final Element element = element2;
    Qualifier qualifier = engine.getQualifier(element.getQualifierId());
    Attribute name = null;
    if (qualifier.getAttributeForName() >= 0)
        name = engine.getAttribute(qualifier.getAttributeForName());
    if (name == null) {
        JOptionPane.showMessageDialog(framework.getMainFrame(), ResourceLoader.getString("NameAttributeNotSet"));
        return;
    }
    final Attribute nameAttribute = name;
    AttributePlugin plugin = framework.findAttributePlugin(name);
    final AttributeEditor editor = plugin.getAttributeEditor(engine, framework.getAccessRules(), element, name, "activity_name", null);
    setTextComponent(new JScrollPane(editor.getLastComponent()));
    final Object value = engine.getAttribute(element, name);
    editor.setValue(value);
    final Rectangle r = movingArea.getIBounds(getBounds());
    final JTextArea textArea = (JTextArea) editor.getLastComponent();
    processTextArea(textArea);
    // textArea.setBackground(getFunction().getBackground());
    // textArea.setForeground(getFunction().getForeground());
    // textArea.setFont(movingArea.getFont(getFont()));
    // textArea.setCaretColor(getFunction().getForeground());
    final JPopupMenu menu = textArea.getComponentPopupMenu();
    textArea.setComponentPopupMenu(null);
    movingArea.getPanel().setActionDisable(true);
    textArea.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER && e.isControlDown()) {
                stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                cancelEdit(editor, textArea, menu);
        }
    });
    textArea.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });
    movingArea.add(getTextComponent());
    movingArea.setbImage(null);
    getTextComponent().setBounds(r);
    movingArea.revalidate();
    movingArea.repaint();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            textArea.requestFocus();
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) GUIFramework(com.ramussoft.gui.common.GUIFramework) Element(com.ramussoft.common.Element) KeyAdapter(java.awt.event.KeyAdapter) Rectangle(java.awt.Rectangle) FRectangle(com.dsoft.pb.types.FRectangle) FocusEvent(java.awt.event.FocusEvent) JPopupMenu(javax.swing.JPopupMenu) KeyEvent(java.awt.event.KeyEvent) AttributeEditor(com.ramussoft.gui.common.AttributeEditor) Qualifier(com.ramussoft.common.Qualifier) FocusListener(java.awt.event.FocusListener) Engine(com.ramussoft.common.Engine)

Example 5 with GUIFramework

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

the class LogPlugin method modify.

@Override
public Action[] modify(Action[] actions, final TableEditor tableEditor) {
    actions = Arrays.copyOf(actions, actions.length + 1);
    actions[actions.length - 1] = new AbstractAction("Log", new ImageIcon(getClass().getResource("/com/ramussoft/client/log/log.png"))) {

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

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableEditor.getFramework();
            Engine engine = framework.getEngine();
            long qId = StandardAttributesPlugin.getTableQualifierForAttribute(engine, tableEditor.getAttribute()).getId();
            List<Event> events = ((ILog) engine).getEventsWithParams(new String[] { EngineLogExtension.QUALIFIER_ID }, new Object[] { qId }, 750);
            List<Event> events2 = new ArrayList<Event>();
            Attribute attribute = StandardAttributesPlugin.getTableElementIdAttribute(engine);
            Element el = tableEditor.getElement();
            for (Event event : events) {
                Long elementId = (Long) event.getAttribute("element_id");
                if (elementId != null) {
                    Element element = engine.getElement(elementId);
                    if (element != null) {
                        Long l = (Long) engine.getAttribute(element, attribute);
                        if (l != null && l.equals(el.getId()))
                            events2.add(event);
                    }
                }
            }
            ElementLogDialog dialog = new ElementLogDialog(events2, engine);
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));
            Options.loadOptions(dialog);
            dialog.setVisible(true);
            Options.saveOptions(dialog);
        }
    };
    return actions;
}
Also used : ImageIcon(javax.swing.ImageIcon) Attribute(com.ramussoft.common.Attribute) ActionEvent(java.awt.event.ActionEvent) GUIFramework(com.ramussoft.gui.common.GUIFramework) Element(com.ramussoft.common.Element) Event(com.ramussoft.common.logger.Event) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) List(java.util.List) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine)

Aggregations

GUIFramework (com.ramussoft.gui.common.GUIFramework)5 Attribute (com.ramussoft.common.Attribute)4 Element (com.ramussoft.common.Element)3 Engine (com.ramussoft.common.Engine)3 ActionEvent (java.awt.event.ActionEvent)3 AbstractAction (javax.swing.AbstractAction)3 ImageIcon (javax.swing.ImageIcon)3 Qualifier (com.ramussoft.common.Qualifier)2 Event (com.ramussoft.common.logger.Event)2 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)2 ArrayList (java.util.ArrayList)2 JScrollPane (javax.swing.JScrollPane)2 FRectangle (com.dsoft.pb.types.FRectangle)1 AccessRules (com.ramussoft.common.AccessRules)1 ILog (com.ramussoft.common.logger.ILog)1 Row (com.ramussoft.database.common.Row)1 RootRow (com.ramussoft.database.common.RowSet.RootRow)1 AttributeEditor (com.ramussoft.gui.common.AttributeEditor)1 RootCreater (com.ramussoft.gui.qualifier.table.RootCreater)1 RowNode (com.ramussoft.gui.qualifier.table.RowNode)1