Search in sources :

Example 1 with AttributeEditor

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

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

the class FunctionOptionsDialog method load.

private void load() {
    Engine e = dataPlugin.getEngine();
    Qualifier qualifier = function.getQualifier();
    attributes = new ArrayList<Attribute>(qualifier.getAttributes());
    for (int i = attributes.size() - 1; i >= 0; i--) {
        Attribute attribute = attributes.get(i);
        AttributePlugin plugin = framework.findAttributePlugin(attribute.getAttributeType());
        Element element = ((NFunction) function).getElement();
        AttributeEditor editor = plugin.getAttributeEditor(e, dataPlugin.getAccessRules(), element, attribute, "function", null);
        if (editor == null)
            continue;
        attributeEditors.add(0, editor);
        JComponent component = editor.getComponent();
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(component, BorderLayout.CENTER);
        Action[] actions = editor.getActions();
        if (actions.length > 0) {
            JToolBar bar = new JToolBar();
            for (Action a : actions) {
                JButton b = bar.add(a);
                b.setFocusable(false);
                bar.add(b);
            }
            panel.add(bar, BorderLayout.NORTH);
        }
        getJTabbedPane().insertTab(attribute.getName(), null, panel, null, 0);
        Object value = e.getAttribute(element, attribute);
        editor.setValue(value);
        values.add(0, value);
    }
    getJColorChooser().setColor(function.getBackground());
    getJColorChooser1().setColor(function.getForeground());
    getJFontChooser().setSelFont(function.getFont());
    functionType.setFunction(function);
    selectOwner.setFunction(function);
}
Also used : JPanel(javax.swing.JPanel) Action(javax.swing.Action) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) BorderLayout(java.awt.BorderLayout) AttributeEditor(com.ramussoft.gui.common.AttributeEditor) Qualifier(com.ramussoft.common.Qualifier) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Engine(com.ramussoft.common.Engine)

Example 3 with AttributeEditor

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

the class FunctionOptionsDialog method showModal.

public void showModal(final Row row) {
    function = (Function) row;
    load();
    Options.loadOptions("function_options_dialog", this);
    int index = Options.getInteger("DEFAULT_FUNCTION_DIALOG_TAB", 0);
    if (index < getJTabbedPane().getTabCount()) {
        getJTabbedPane().setSelectedIndex(index);
        Component component = getJTabbedPane().getSelectedComponent();
        requestFocusForTextComponent(component);
    }
    setVisible(true);
    Options.saveOptions("function_options_dialog", this);
    Options.setInteger("DEFAULT_FUNCTION_DIALOG_TAB", getJTabbedPane().getSelectedIndex());
    while (getJTabbedPane().getTabCount() > staticTabCount) {
        getJTabbedPane().removeTabAt(0);
    }
    for (AttributeEditor editor : attributeEditors) editor.close();
    attributeEditors.clear();
    attributes.clear();
    values.clear();
}
Also used : AttributeEditor(com.ramussoft.gui.common.AttributeEditor) JComponent(javax.swing.JComponent) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Aggregations

AttributeEditor (com.ramussoft.gui.common.AttributeEditor)3 Attribute (com.ramussoft.common.Attribute)2 Element (com.ramussoft.common.Element)2 Engine (com.ramussoft.common.Engine)2 Qualifier (com.ramussoft.common.Qualifier)2 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)2 JComponent (javax.swing.JComponent)2 FRectangle (com.dsoft.pb.types.FRectangle)1 GUIFramework (com.ramussoft.gui.common.GUIFramework)1 NFunction (com.ramussoft.pb.data.negine.NFunction)1 IDEF0Object (com.ramussoft.pb.idef.visual.IDEF0Object)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Rectangle (java.awt.Rectangle)1 FocusEvent (java.awt.event.FocusEvent)1 FocusListener (java.awt.event.FocusListener)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 Action (javax.swing.Action)1 JButton (javax.swing.JButton)1