use of com.ramussoft.common.journal.Journaled 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();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class ChartSetsView 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) engine.deleteElement(row.getElementId());
((Journaled) engine).commitUserTransaction();
}
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class ChartSetsView method deleteChartSet.
public void deleteChartSet() {
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.deleteChartSet(engine, row.getElement());
((Journaled) engine).commitUserTransaction();
}
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class ChartPreferencesDialog method onOk.
@Override
protected void onOk() {
Engine engine = framework.getEngine();
try {
((Journaled) engine).startUserTransaction();
chart.setName(name.getText());
Element element = chart.getElement();
editor.save(element);
((Journaled) engine).commitUserTransaction();
} catch (Exception e) {
((Journaled) engine).rollbackUserTransaction();
e.printStackTrace();
JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
}
super.onOk();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class HTMLEditPanel method createHtmlEditor.
private void createHtmlEditor() {
if (page == null) {
String text = jTextPane.getText();
try {
page = new HTMLPage(text.getBytes("UTF8"), (page != null) ? page.getPath() : null);
((Journaled) engine).startUserTransaction();
engine.setAttribute(element, attribute, page);
((Journaled) engine).commitUserTransaction();
HTMLPage page = (HTMLPage) engine.getAttribute(element, attribute);
page.setEmpty(true);
setValue(page);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
if (openEditor()) {
updateEditing();
}
}
Aggregations