Search in sources :

Example 11 with AttributePlugin

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

the class AttributePullView method createComponent.

@Override
public JComponent createComponent() {
    component = new RowTreeTableComponent(engine, attributeQualifier, rules, new RowRootCreater(), new Attribute[] { attributeName, attributeTypeName }, framework);
    table = component.getTable();
    component.getModel().setEditable(1, false);
    ((AbstractTableModel) table.getModel()).fireTableStructureChanged();
    Attribute type = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_TYPE_NAME);
    final Hashtable<String, String> names = new Hashtable<String, String>();
    for (AttributeType type2 : engine.getAttributeTypes()) {
        AttributePlugin plugin = framework.findAttributePlugin(type2);
        try {
            String key = "AttributeType." + type2.toString();
            names.put(key, plugin.getString(key));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    String key = "AttributeType.Core.ElementList";
    names.put(key, GlobalResourcesManager.getString(key));
    component.getModel().setAttributeLocalizer(new RowTreeTableModel.Localizer() {

        @Override
        public Object getValue(Object key) {
            if (key == null)
                return "Anknown attribute type";
            return names.get("AttributeType." + key.toString());
        }
    }, type);
    table.getTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            refreshActions();
        }
    });
    rowSet = component.getRowSet();
    table.setEditIfNullEvent(false);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    setupAttribute();
                }
            }
        }
    });
    refreshActions();
    table.setComponentPopupMenu(createJPopupMenu());
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) Hashtable(java.util.Hashtable) MouseAdapter(java.awt.event.MouseAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) RowTreeTableModel(com.ramussoft.gui.qualifier.table.RowTreeTableModel) AttributeType(com.ramussoft.common.AttributeType) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) AbstractTableModel(javax.swing.table.AbstractTableModel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 12 with AttributePlugin

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

the class ElementAttributesEditor method reload.

protected void reload() {
    CloseEvent event = new CloseEvent(this);
    CloseListener[] listeners = getCloseListeners();
    for (CloseListener listener : listeners) {
        listener.closed(event);
        removeCloseListener(listener);
    }
    loadCurrentQualifierAttributes();
    Engine engine = framework.getEngine();
    AccessRules rules = framework.getAccessRules();
    getters = new ValueGetter[attributes.size()];
    renderers = new TableCellRenderer[attributes.size()];
    values = new Object[attributes.size()];
    saveValues = new boolean[attributes.size()];
    Arrays.fill(saveValues, true);
    Arrays.fill(getters, new ValueGetter() {

        @Override
        public Object getValue(TableNode node, int index) {
            return node.getValueAt(index);
        }
    });
    for (int i = 0; i < attributes.size(); i++) {
        Attribute attr = attributes.get(i).attribute;
        AttributePlugin plugin = framework.findAttributePlugin(attr);
        if (plugin instanceof TabledAttributePlugin) {
            ValueGetter getter = ((TabledAttributePlugin) plugin).getValueGetter(attr, engine, framework, this);
            if (getter != null)
                getters[i] = getter;
        }
        renderers[i] = plugin.getTableCellRenderer(engine, rules, attr);
    }
    loadElement();
}
Also used : CloseEvent(com.ramussoft.gui.qualifier.table.event.CloseEvent) TabledAttributePlugin(com.ramussoft.gui.qualifier.table.TabledAttributePlugin) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) TabledAttributePlugin(com.ramussoft.gui.qualifier.table.TabledAttributePlugin) ValueGetter(com.ramussoft.gui.qualifier.table.ValueGetter) CloseListener(com.ramussoft.gui.qualifier.table.event.CloseListener) TableNode(com.ramussoft.gui.qualifier.table.TableNode) AccessRules(com.ramussoft.common.AccessRules) Engine(com.ramussoft.common.Engine)

Example 13 with AttributePlugin

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

the class MovingArea method editActive.

/**
 * Якщо виділений якийсь об’єкт, тоді з’являється діалогове вікно для роботи
 * з його властивостями.
 */
@SuppressWarnings("unused")
public void editActive() {
    if ((Metadata.EDUCATIONAL) && (Math.random() < 0.2d)) {
        AttributePlugin plugin = panel.getFramework().findAttributePlugin(new AttributeType("Core", "Table", false));
        if (!(plugin instanceof EmptyPlugin)) {
            System.exit(233);
        }
    }
    if ((activeObject instanceof MovingFunction) || (activeObject instanceof DFDFunction)) {
        final IDEF0Object movingFunction = (IDEF0Object) activeObject;
        // String text = movingFunction.getFunction().getName();
        panel.getFunctionOptions().showModal(movingFunction);
    /*
			 * if(!text.equals(movingFunction.getFunction().getName()))
			 * movingFunction.resetBounds();
			 */
    } else if (activeObject instanceof DFDSRole) {
        panel.getDFDSRoleOptionsDialog().showModal((DFDSRole) activeObject);
    } else if (activeObject instanceof DFDObject) {
        panel.getDFDObjectOptionsDialog().showModal((DFDObject) activeObject);
    } else if (activeObject instanceof MovingText)
        panel.getTextOptionsDialog().showModal((MovingText) activeObject);
    else if (activeObject instanceof PaintSector.Pin) {
        panel.getArrowOptionsDialog().showModal(((PaintSector.Pin) activeObject).getSector(), this);
    // setPanels();
    }
    repaintAsync();
}
Also used : EmptyPlugin(com.ramussoft.gui.common.EmptyPlugin) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) AttributeType(com.ramussoft.common.AttributeType) DFDObject(com.ramussoft.pb.dfd.visual.DFDObject)

Example 14 with AttributePlugin

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

the class GroupRootCreater method init.

@Override
public void init(Engine engine, GUIFramework framework, Closeable model) {
    for (Attribute a : attrs) {
        AttributePlugin plugin = framework.findAttributePlugin(a);
        ValueGetter getter = null;
        if (plugin instanceof TabledAttributePlugin) {
            getter = ((TabledAttributePlugin) plugin).getValueGetter(a, engine, framework, model);
        }
        if (getter == null)
            getter = new RowTreeTableModel.DefaultValueGetter();
        hash.put(a, getter);
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute)

Example 15 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin 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)

Aggregations

AttributePlugin (com.ramussoft.gui.common.AttributePlugin)15 Attribute (com.ramussoft.common.Attribute)10 Engine (com.ramussoft.common.Engine)5 AttributeType (com.ramussoft.common.AttributeType)4 Qualifier (com.ramussoft.common.Qualifier)4 BorderLayout (java.awt.BorderLayout)4 JPanel (javax.swing.JPanel)4 AccessRules (com.ramussoft.common.AccessRules)3 Element (com.ramussoft.common.Element)3 JLabel (javax.swing.JLabel)3 AttributeEditor (com.ramussoft.gui.common.AttributeEditor)2 GUIFramework (com.ramussoft.gui.common.GUIFramework)2 DialogedTableCellEditor (com.ramussoft.gui.qualifier.table.DialogedTableCellEditor)2 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)2 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)2 RowTreeTableModel (com.ramussoft.gui.qualifier.table.RowTreeTableModel)2 TabledAttributePlugin (com.ramussoft.gui.qualifier.table.TabledAttributePlugin)2 IDEF0Object (com.ramussoft.pb.idef.visual.IDEF0Object)2 TableLayout (info.clearthought.layout.TableLayout)2 KeyEvent (java.awt.event.KeyEvent)2