Search in sources :

Example 11 with AttributeType

use of com.ramussoft.common.AttributeType 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 AttributeType

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

the class AttributeStorageCommand method loadAttribute.

protected void loadAttribute(BinaryDataInput input, Attribute attribute) throws IOException {
    attribute.setAttributeType(new AttributeType());
    attribute.setId(input.readLong());
    attribute.setName(input.readSwimedString());
    attribute.getAttributeType().setPluginName(input.readSwimedString());
    attribute.getAttributeType().setTypeName(input.readSwimedString());
    attribute.getAttributeType().setComparable(input.readBoolean());
}
Also used : AttributeType(com.ramussoft.common.AttributeType)

Example 13 with AttributeType

use of com.ramussoft.common.AttributeType 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 AttributeType

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

the class NewProjectDialog method showModal.

public void showModal(final Engine engine, final AccessRules accessRules, final GUIFramework framework) {
    ((Journaled) engine).setNoUndoPoint();
    final Properties name_author = new DefaultProperties(new Property[] { new DefaultProperty(AUTOR, Property.TEXT_FIELD), new DefaultProperty(PROJECT_NAME, Property.TEXT_FIELD), new DefaultProperty(MODEL_NAME, Property.TEXT_FIELD) }, Factory.getString("name_author.Describe"));
    final Properties used_at = new DefaultProperties(new Property[] { new DefaultProperty(USED_AT, Property.TEXT_FIELD) }, Factory.getString("used_at.Describe"));
    final Properties def = new DefaultProperties(new Property[] { new DefaultProperty(DEFINITION, Property.TEXT) }, Factory.getString("describe.Describe"));
    final Properties clasificators = new DefaultProperties(new Property[] { new DefaultProperty(CLASIFICATOR1, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR2, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR3, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR4, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR5, Property.TEXT_FIELD) }, Factory.getString("Clasificators.Describe"));
    masterModel = new DefaultMasterModel(new Properties[] { name_author, used_at, def, clasificators });
    mainPanel = new MainPanel(new PanelCreator(masterModel)) {

        @Override
        public boolean cancel() {
            if (super.cancel()) {
                NewProjectDialog.this.setVisible(false);
                finish();
                return true;
            }
            return false;
        }

        @Override
        protected void finish() {
            super.finish();
            ((Journaled) engine).startUserTransaction();
            final Qualifier baseFunction = engine.createQualifier();
            String modelName = getValue(MODEL_NAME);
            if ((modelName == null) || (modelName.length() == 0))
                baseFunction.setName(ResourceLoader.getString("base_function"));
            else
                baseFunction.setName(modelName);
            Attribute name = engine.createAttribute(new AttributeType("Core", "Text", true));
            name.setName(ResourceLoader.getString("name"));
            engine.updateAttribute(name);
            java.util.Properties ps = engine.getProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES);
            ps.setProperty(AutochangePlugin.AUTO_ADD_ATTRIBUTE_IDS, Long.toString(name.getId()));
            ps.setProperty(AutochangePlugin.ATTRIBUTE_FOR_NAME, Long.toString(name.getId()));
            engine.setProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES, ps);
            baseFunction.getAttributes().add(name);
            baseFunction.setAttributeForName(name.getId());
            IDEF0Plugin.installFunctionAttributes(baseFunction, engine);
            Element element = engine.createElement(IDEF0Plugin.getModelTree(engine).getId());
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(engine), baseFunction.getId());
            HierarchicalPersistent hp = new HierarchicalPersistent();
            hp.setParentElementId(-1l);
            hp.setPreviousElementId(-1l);
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(engine), baseFunction.getName());
            engine.setAttribute(element, StandardAttributesPlugin.getHierarchicalAttribute(engine), hp);
            DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(baseFunction, engine, accessRules);
            if (dfd.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFD);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            ProjectOptions projectOptions = new ProjectOptions();
            projectOptions.setProjectAutor(getValue(AUTOR));
            projectOptions.setProjectName(getValue(PROJECT_NAME));
            projectOptions.setDefinition(getValue(DEFINITION));
            projectOptions.setUsedAt(getValue(USED_AT));
            NewProjectDialog.this.setVisible(false);
            final String[] cls = getClasifiactors();
            final StringBuffer ounersIds = new StringBuffer();
            for (final String c : cls) {
                Row row = dataPlugin.createRow(null, false);
                Qualifier qualifier = engine.getQualifier(StandardAttributesPlugin.getQualifierId(engine, row.getElement().getId()));
                qualifier.setName(c);
                engine.updateQualifier(qualifier);
                if (ouners.indexOf(c) >= 0) {
                    ounersIds.append(qualifier.getId());
                    ounersIds.append(' ');
                }
            }
            dataPlugin.setProperty(DataPlugin.PROPERTY_OUNERS, ounersIds.toString());
            dataPlugin.getBaseFunction().setProjectOptions(projectOptions);
            ((Journaled) engine).commitUserTransaction();
            ((Journaled) engine).setNoUndoPoint();
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    framework.propertyChanged("ShowWorkspace", "Workspace.IDEF0");
                    OpenDiagram open = new OpenDiagram(baseFunction, -1l);
                    framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
                }
            });
        }
    };
    setContentPane(mainPanel);
    pack();
    Dimension size = this.getSize();
    setMinimumSize(new Dimension(size.width, size.height + 30));
    setLocationRelativeTo(null);
    setVisible(true);
    frame.repaint();
}
Also used : DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Dimension(java.awt.Dimension) DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Properties(com.ramussoft.pb.master.model.Properties) DefaultProperty(com.ramussoft.pb.master.model.DefaultProperty) Journaled(com.ramussoft.common.journal.Journaled) MainPanel(com.ramussoft.pb.master.gui.MainPanel) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) AttributeType(com.ramussoft.common.AttributeType) DefaultPanelCreator(com.ramussoft.pb.master.gui.DefaultPanelCreator) OpenDiagram(com.ramussoft.idef0.OpenDiagram) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) DefaultMasterModel(com.ramussoft.pb.master.model.DefaultMasterModel) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 15 with AttributeType

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

the class ReportPlugin method init.

@Override
public void init(Engine engine, AccessRules rules) {
    super.init(engine, rules);
    engine.setPluginProperty(getName(), PLUGIN, this);
    reports = engine.getSystemQualifier(REPORTS_QUALIFIER);
    if (reports == null) {
        reports = engine.createSystemQualifier();
        reportName = createAttribute(REPORT_NAME, new AttributeType("Core", "Text", true));
        reportQualifier = createAttribute(REPORT_QUALIFIER, new AttributeType("Core", "Long", true));
        reports.setName(REPORTS_QUALIFIER);
        reports.getAttributes().add(reportName);
        reports.getSystemAttributes().add(reportQualifier);
        reports.setAttributeForName(reportName.getId());
        Attribute hierarchical = (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE);
        reports.getSystemAttributes().add(hierarchical);
        engine.updateQualifier(reports);
    } else {
        reportName = engine.getSystemAttribute(REPORT_NAME);
        reportQualifier = engine.getSystemAttribute(REPORT_QUALIFIER);
    }
    reportType = engine.getSystemAttribute(REPORT_TYPE);
    if (reportType == null) {
        reportType = createAttribute(REPORT_TYPE, new AttributeType("Core", "Text", true));
        reports.getSystemAttributes().add(reportType);
        engine.updateQualifier(reports);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) AttributeType(com.ramussoft.common.AttributeType)

Aggregations

AttributeType (com.ramussoft.common.AttributeType)20 Attribute (com.ramussoft.common.Attribute)15 Qualifier (com.ramussoft.common.Qualifier)8 Element (com.ramussoft.common.Element)5 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)4 AttributeEvent (com.ramussoft.common.event.AttributeEvent)3 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)3 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)3 QualifierEvent (com.ramussoft.common.event.QualifierEvent)3 Journaled (com.ramussoft.common.journal.Journaled)3 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)3 ArrayList (java.util.ArrayList)3 Hashtable (java.util.Hashtable)3 Engine (com.ramussoft.common.Engine)2 IEngine (com.ramussoft.common.IEngine)2 ElementAdapter (com.ramussoft.common.event.ElementAdapter)2 ElementEvent (com.ramussoft.common.event.ElementEvent)2 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)2 JDBCTemplate (com.ramussoft.jdbc.JDBCTemplate)2 RowMapper (com.ramussoft.jdbc.RowMapper)2