use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class Application method patchData.
/*
* Create all needed system qualifiers and attributes.
*/
private void patchData(Engine engine) {
Journaled journal = (Journaled) engine;
journal.startUserTransaction();
Attribute textAttribute1 = createAttribute(TEXT_ATTRIBUTE1, new AttributeType("Core", "Text"), engine);
Attribute textAttribute2 = createAttribute(TEXT_ATTRIBUTE2, new AttributeType("Core", "Text"), engine);
Attribute doubleAttribute1 = createAttribute(DOUBLE_ATTRIBUTE1, new AttributeType("Core", "Double"), engine);
Qualifier qualifier1 = engine.getSystemQualifier(QUALIFIER1);
if (qualifier1 == null) {
qualifier1 = engine.createSystemQualifier();
qualifier1.getAttributes().add(textAttribute1);
qualifier1.getAttributes().add(textAttribute2);
qualifier1.getAttributes().add(doubleAttribute1);
qualifier1.setName(QUALIFIER1);
engine.updateQualifier(qualifier1);
}
journal.commitUserTransaction();
// User will not be able to undo these changes.
journal.setNoUndoPoint();
}
use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class TableChartAttributePlugin method getAttributeEditor.
@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor oldAttributeEditor) {
return new AbstractAttributeEditor() {
@Override
public Object setValue(Object value) {
return null;
}
@Override
public Object getValue() {
return null;
}
@Override
public JComponent getComponent() {
ChartDataFramework chartDataFramework = ChartDataFramework.getChartDataFramework(engine);
ChartSource source = new ChartSource(engine) {
@Override
public List<Element> getElements() {
List<Element> res = new ArrayList<Element>();
for (QualifierSource source : qualifierSources) {
if (QualifierSource.ELEMENTS_LOAD_TYPE_ALL.equals(source.getElementsLoadType())) {
FilterSource filterSource = source.getFilterSources().get(0);
Qualifier qualifier = source.getQualifier();
if (StandardAttributesPlugin.isTableQualifier(qualifier) && filterSource.getAttribute().equals(StandardAttributesPlugin.getTableElementIdAttribute(engine))) {
res.addAll(StandardAttributesPlugin.getOrderedTableElements(engine, StandardAttributesPlugin.getAttributeForTable(engine, qualifier), element));
} else
res.addAll(engine.findElements(qualifier.getId(), filterSource.getAttribute(), Long.parseLong(filterSource.getValue())));
} else
for (ElementSource elementSource : source.getElementSources()) res.add(elementSource.getElement());
}
return res;
}
};
TableChartPersistent tcp = (TableChartPersistent) engine.getAttribute(null, attribute);
Element chartElement = engine.getElement(tcp.getOtherElementId());
source.load(chartElement);
ChartDataPlugin chartDataPlugin = chartDataFramework.getChartDataPlugin(source.getChartType());
JFreeChart freeChart = chartDataPlugin.createChart(element, source);
return new ChartPanel(freeChart);
}
};
}
use of com.ramussoft.common.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ViewPlugin method exportToIdl.
protected void exportToIdl() {
final JList list = new JList();
final List<Qualifier> base = IDEF0Plugin.getBaseQualifiers(engine);
Collections.sort(base, new Comparator<Qualifier>() {
private Collator collator = Collator.getInstance();
@Override
public int compare(Qualifier o1, Qualifier o2) {
return collator.compare(o1.getName(), o2.getName());
}
});
list.setModel(new AbstractListModel() {
@Override
public Object getElementAt(int index) {
return base.get(index);
}
@Override
public int getSize() {
return base.size();
}
});
JScrollPane pane = new JScrollPane();
pane.setViewportView(list);
JFileChooser fc = new JFileChooser() {
@Override
public void approveSelection() {
Qualifier result = (Qualifier) list.getSelectedValue();
if (result == null) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("select_model_first"));
} else {
File file = getSelectedFile();
if (file.exists()) {
if (JOptionPane.showConfirmDialog(framework.getMainFrame(), GlobalResourcesManager.getString("File.Exists"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
}
DataPlugin plugin = NDataPluginFactory.getDataPlugin(result, engine, rules);
try {
if (!file.getName().toLowerCase().endsWith(".idl")) {
file = new File(file.getParentFile(), file.getName() + ".idl");
}
FileOutputStream fileOutputStream = new FileOutputStream(file);
plugin.exportToIDL(plugin.getBaseFunction(), fileOutputStream, "cp1251");
fileOutputStream.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
}
super.approveSelection();
}
}
};
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";
}
});
JPanel bottom = new JPanel(new TableLayout(new double[][] { { 5, TableLayout.FILL }, { TableLayout.MINIMUM, 5, TableLayout.FILL } }));
bottom.add(new JLabel(ResourceLoader.getString("Model")), "1, 0");
bottom.add(pane, "1, 2");
fc.setAccessory(bottom);
fc.showSaveDialog(framework.getMainFrame());
}
use of com.ramussoft.common.Qualifier 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.Qualifier in project ramus by Vitaliy-Yakovchuk.
the class ModelsView method createModelsPanel.
protected void createModelsPanel() {
if (this.modelsPanel != null)
this.modelsPanel.close();
Qualifier modelTree = IDEF0Plugin.getModelTree(engine);
modelTree = engine.getQualifier(modelTree.getId());
if (modelTree == null) {
final com.ramussoft.idef0.idef0.oldmodelsview.ModelsPanel modelsPanel = new com.ramussoft.idef0.idef0.oldmodelsview.ModelsPanel(engine, framework) {
@Override
public boolean isDisabeUpdate() {
return disableUpdated;
}
};
modelsPanel.getTree().getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
openDiagram.setEnabled(modelsPanel.getTree().getSelectionPath() != null);
}
});
modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
modelsPanel.getTree().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
ch1();
modelNode = getActiveNode1();
while ((modelNode != null) && (!(modelNode instanceof ModelsNode)) && (modelNode instanceof Row)) modelNode = ((Row) modelNode).getParent();
modelProperties.setEnabled((modelNode instanceof ModelsNode) && (rules.canUpdateQualifier(((ModelsNode) modelNode).getQualifier().getId())));
}
});
modelsPanel.getTreeModel().addTreeModelListener(new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
ch1();
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
ch1();
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
ch1();
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
ch1();
}
});
contentPanel.add(modelsPanel, BorderLayout.CENTER);
modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
this.modelsPanel = modelsPanel;
} else {
final ModelsPanel modelsPanel = new ModelsPanel(engine, framework) {
@Override
public boolean isDisabeUpdate() {
return disableUpdated;
}
};
modelsPanel.getTree().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
openDiagram.setEnabled(modelsPanel.canOpen());
}
});
modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
modelsPanel.getTree().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
ch();
modelNode = getActiveNode();
while ((modelNode != null) && (!(modelNode instanceof ModelsNode)) && (modelNode instanceof RowNode)) modelNode = ((RowNode) modelNode).getParent();
modelProperties.setEnabled((modelNode instanceof ModelsNode) && (rules.canUpdateQualifier(((ModelsNode) modelNode).getQualifier().getId())));
}
});
contentPanel.add(modelsPanel, BorderLayout.CENTER);
modelsPanel.getTree().getTable().setComponentPopupMenu(createPopupMenu());
this.modelsPanel = modelsPanel;
}
}
Aggregations