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();
}
}
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 не поддерживается.");
}
}
}
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();
}
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);
}
};
}
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();
}
Aggregations