Search in sources :

Example 11 with Journaled

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

the class ChartsView method deleteDiagram.

public void deleteDiagram() {
    List<Row> rows = new ArrayList<Row>();
    int[] sels = table.getSelectedRows();
    for (int i : sels) {
        TreePath path = table.getPathForRow(i);
        if (path != null) {
            TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
            if (node != null) {
                Row row = node.getRow();
                if (row != null)
                    rows.add(row);
            }
        }
    }
    if (rows.size() > 0) {
        if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
        Engine engine = framework.getEngine();
        ((Journaled) engine).startUserTransaction();
        for (Row row : rows) ChartPlugin.deleteChart(engine, row.getElement());
        ((Journaled) engine).commitUserTransaction();
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row) Engine(com.ramussoft.common.Engine)

Example 12 with Journaled

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

the class IDEF0ViewPlugin method importFromIdl.

protected void importFromIdl() {
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File f) {
            if (f.isFile()) {
                if (f.getName().toLowerCase().endsWith(".idl"))
                    return true;
                return false;
            }
            return true;
        }

        @Override
        public String getDescription() {
            return "*.idl";
        }
    });
    if (fc.showOpenDialog(framework.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
        try {
            ((Journaled) engine).startUserTransaction();
            Qualifier qualifier = engine.createQualifier();
            Attribute name = null;
            String aName = ResourceLoader.getString("name");
            for (Attribute a : engine.getAttributes()) {
                if (a.getAttributeType().toString().equals("Core.Text")) {
                    if (aName.equals(a.getName()))
                        name = a;
                }
            }
            if (name == null) {
                name = engine.createAttribute(new AttributeType("Core", "Text", true));
                name.setName(aName);
                engine.updateAttribute(name);
            }
            qualifier.getAttributes().add(name);
            qualifier.setAttributeForName(name.getId());
            IDEF0Plugin.installFunctionAttributes(qualifier, engine);
            DataPlugin plugin = NDataPluginFactory.getDataPlugin(qualifier, engine, rules);
            File file = fc.getSelectedFile();
            plugin.importFromIDL(plugin, "cp1251", new FileInputStream(file));
            ((Journaled) engine).commitUserTransaction();
            OpenDiagram openDiagram = new OpenDiagram(qualifier, -1l);
            framework.propertyChanged(OPEN_DIAGRAM, openDiagram);
        } catch (Exception e) {
            ((Journaled) engine).rollbackUserTransaction();
            e.printStackTrace();
            JOptionPane.showMessageDialog(framework.getMainFrame(), "Формат выбранного вами файла IDL не поддерживается.");
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) FileInputStream(java.io.FileInputStream) ParseException(java.text.ParseException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) Journaled(com.ramussoft.common.journal.Journaled) JFileChooser(javax.swing.JFileChooser) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier) FileFilter(javax.swing.filechooser.FileFilter) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) File(java.io.File)

Example 13 with Journaled

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

the class ModelPropertiesDialog method onOk.

@Override
protected void onOk() {
    if (nameAttribute.getSelectedItem() == null) {
        JOptionPane.showMessageDialog(this, GlobalResourcesManager.getString("Error.SetAttributeForName"));
        return;
    }
    updateAttributesInOrder(function.getAttributes());
    ((Journaled) engine).startUserTransaction();
    Attribute aForName = (Attribute) nameAttribute.getSelectedItem();
    if (aForName == null) {
        function.setAttributeForName(-1l);
    } else {
        function.setAttributeForName(aForName.getId());
    }
    engine.updateQualifier(function);
    Attribute aForTerm = (Attribute) termAttribute.getSelectedItem();
    if (aForTerm == null)
        optionsPanel.getProject().getDeligate().setTermAttribute(null);
    else
        optionsPanel.getProject().getDeligate().setTermAttribute(aForTerm.getId());
    optionsPanel.save(framework);
    ((Journaled) engine).commitUserTransaction();
    super.onOk();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Attribute(com.ramussoft.common.Attribute)

Example 14 with Journaled

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

the class SectorColorAttributePlugin method getTableCellEditor.

@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
    final JComboBox box = new JComboBox();
    box.setRenderer(comboBoxRenderer);
    box.addItem(Color.white);
    box.addItem(Color.green);
    box.addItem(Color.blue);
    box.addItem(Color.red);
    box.addItem(Color.yellow);
    box.addItem(Color.cyan);
    box.addItem(Color.magenta);
    box.addItem(Color.orange);
    box.addItem(Color.pink);
    box.addItem(Color.lightGray);
    box.addItem(Color.gray);
    box.addItem(Color.darkGray);
    box.addItem(Color.black);
    return new DefaultCellEditor(box) {

        private Pin pin;

        @Override
        public boolean stopCellEditing() {
            if (box.getSelectedItem() instanceof Color) {
                ((Journaled) engine).startUserTransaction();
                apply((Color) box.getSelectedItem(), pin);
                return super.stopCellEditing();
            }
            return false;
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            pin = (Pin) ((MetadataGetter) table).getMetadata();
            return super.getTableCellEditorComponent(table, value, isSelected, row, column);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) Color(java.awt.Color) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 15 with Journaled

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

the class CreateBaseFunctionDialog method onOk.

@Override
protected void onOk() {
    Journaled rs = (Journaled) engine;
    rs.startUserTransaction();
    createModel();
    super.onOk();
    rs.commitUserTransaction();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled)

Aggregations

Journaled (com.ramussoft.common.journal.Journaled)34 Engine (com.ramussoft.common.Engine)9 Attribute (com.ramussoft.common.Attribute)7 Element (com.ramussoft.common.Element)7 Qualifier (com.ramussoft.common.Qualifier)7 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 Row (com.ramussoft.database.common.Row)5 DataPlugin (com.ramussoft.pb.DataPlugin)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)4 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)4 AttributeType (com.ramussoft.common.AttributeType)3 MemoryDatabase (com.ramussoft.database.MemoryDatabase)3 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 Function (com.ramussoft.pb.Function)3 Row (com.ramussoft.pb.Row)3 TreePath (javax.swing.tree.TreePath)3 AccessRules (com.ramussoft.common.AccessRules)2 IEngine (com.ramussoft.common.IEngine)2