use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class DFDSRoleOptionsDialog method onOk.
@Override
protected void onOk() {
if (!isCanOk()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
return;
}
if (!isOkStreamName()) {
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
}
DFDSRole role = (DFDSRole) object;
Journaled journaled = (Journaled) dataPlugin.getEngine();
journaled.startUserTransaction();
Function function = object.getFunction();
function.setFont(fontChooser.getSelFont());
function.setBackground(backgroundColorChooser.getColor());
function.setForeground(foregroundColorChooser.getColor());
role.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
Stream stream = sectorRowsEditor.getStream();
if (stream == null) {
stream = sectorNameEditor.findStreamByName();
if (stream == null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
final String t = sectorNameEditor.getArrowName();
if (!t.equals("")) {
if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
if (t.equals("")) {
if (!stream.isEmptyName()) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream.setEmptyName(true);
}
} else {
stream.setName(t);
}
stream.setRows(sectorRowsEditor.getRows());
role.setStream(stream, ReplaceStreamType.SIMPLE);
// sector.setStreamAddedByRefactor(false);
final Row[] rs = sectorRowsEditor.getRows();
role.setRows(rs);
if (rs != null) {
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = function.getBounds();
ops.background = function.getBackground();
ops.font = function.getFont();
ops.foreground = function.getForeground();
for (Row row : rs) if (row != null) {
IDEF0Plugin.setDefaultRectangleVisualOptions(dataPlugin.getEngine(), row.getElement(), ops);
}
}
journaled.commitUserTransaction();
setVisible(false);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class AbstractTemplate method createChilds.
private synchronized void createChilds(final Rectangle rectangle) {
// final IdGenerator g = GlobalId.getGenerator();
// GlobalId.setGenerator(generator);
dataPlugin = NDataPluginFactory.getTemplateDataPlugin();
Function f = dataPlugin.getBaseFunction();
final ProjectOptions po = f.getProjectOptions();
po.setChangeDate(po.getDateChangeDate());
po.setProjectAutor(po.getProjectAutor());
po.setProjectName(po.getProjectName());
po.setUsedAt(po.getUsedAt());
f.setProjectOptions(po);
final Attribute attribute = dataPlugin.getEngine().createAttribute(new com.ramussoft.common.AttributeType("Core", "Text", true));
Qualifier q = dataPlugin.getBaseFunctionQualifier();
q.getAttributes().add(attribute);
q.setAttributeForName(attribute.getId());
dataPlugin.getEngine().updateQualifier(q);
f = (Function) dataPlugin.createRow(f, true);
diagram = f;
f.setDecompositionType(decompositionType);
final FRectangle rect = f.getBounds();
rect.setX(rectangle.getWidth() / 2 - rect.getWidth() / 2);
rect.setY(rectangle.getHeight() / 2 - rect.getHeight() / 2);
f.setBounds(rect);
createChilds(f, dataPlugin);
base = f;
// GlobalId.setGenerator(g);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDEFPanel method loadPosiotion.
public void loadPosiotion() {
final InputStream stream = dataPlugin.getNamedData("system/idef0.pos");
closeTabs();
movingArea.clear();
if (stream == null) {
movingArea.setActiveFunction(dataPlugin.getBaseFunction());
} else {
try {
DataLoader.readInteger(stream);
final int l = DataLoader.readInteger(stream);
if (l < 0)
return;
final Tab[] tabs = new Tab[l];
for (int i = 0; i < l; i++) {
final GlobalId id = new GlobalId(stream);
tabs[i] = simpleCreateTab((Function) dataPlugin.findRowByGlobalId(id));
}
if (l > 0) {
final int s = DataLoader.readInteger(stream);
tabs[s].getPanel().add(getJScrollPane1(), BorderLayout.CENTER);
tabs[s].select();
movingArea.setActiveFunction(tabs[s].getFunction());
} else {
final GlobalId id = new GlobalId(stream);
Function active = (Function) dataPlugin.findRowByGlobalId(id);
if (active == null)
active = dataPlugin.getBaseFunction();
movingArea.setActiveFunction(active);
}
stream.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
repaint();
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDEFPanel method setFunctionMenu.
public void setFunctionMenu(final Function function) {
getJMenu1().removeAll();
final Row[] rows = function.getOwners();
class OwnerSetter implements ActionListener {
private final Function function;
private final Row owner;
public OwnerSetter(final Function function, final Row owner) {
super();
this.function = function;
this.owner = owner;
}
public void actionPerformed(final ActionEvent e) {
movingArea.startUserTransaction();
function.setOwner(owner);
movingArea.commitUserTransaction();
}
}
boolean parentOuner = false;
Row ouner = function.getOwner();
Row pOuner = null;
if (function.getParent() != null)
pOuner = ((Function) function.getParentRow()).getOwner();
parentOuner = ((ouner != null) && (ouner.equals(pOuner)));
JRadioButtonMenuItem item;
if (pOuner != null) {
item = new JRadioButtonMenuItem("<html><body><i><b>" + pOuner.getName() + "</b></i></body></html>");
} else
item = new JRadioButtonMenuItem("<html><body><i><b>" + ResourceLoader.getString("owner_not_selected") + "</b></i></body></html>");
item.addActionListener(new OwnerSetter(function, null));
if (ouner == null || parentOuner)
item.setSelected(true);
jMenu1.add(item);
if (rows.length > 0)
jMenu1.addSeparator();
for (final Row element : rows) if (!element.equals(pOuner)) {
item = new JRadioButtonMenuItem(element.getName());
item.addActionListener(new OwnerSetter(function, element));
if (ouner != null && ouner.equals(element))
item.setSelected(true);
jMenu1.add(item);
}
jMenu1.addSeparator();
final JMenuItem mi = new JMenuItem(ResourceLoader.getString("Owners.Clasificators"));
mi.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
getOwnerClasificatorsDialog().showModal();
}
});
jMenu1.add(mi);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method getIDEF0Kod.
/**
* Метод визначає код функціонального блоку у відповідності до стандарту
* IDEF0
*
* @param function Функціональний блок, для якого буде визначений його код.
* @return Код функціонального блока у відповідності до стандарту IDEF0.
*/
public static String getIDEF0Kod(Row function) {
Engine engine = function.getEngine();
Integer integer = (Integer) function.getAttribute(IDEF0Plugin.getDecompositionTypeAttribute(engine));
if (integer != null && integer.intValue() == MovingArea.DIAGRAM_TYPE_DFDS)
return function.getNativeCode();
Qualifier qualifier = engine.getQualifier(function.getElement().getQualifierId());
DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(qualifier, engine, null);
com.ramussoft.pb.Row f1 = dataPlugin.findRowByGlobalId(function.getElementId());
if (f1 != null)
function = (Row) f1;
final com.ramussoft.database.common.Row f = function.getParent();
if (function instanceof Function) {
ProjectOptions po = ((Function) function).getProjectOptions();
String letter = po.getDeligate().getModelLetter();
if (letter != null && letter.length() > 0) {
if (f == null)
return letter + "-0";
if (f.getParent() == null)
return letter + "0";
return letter + getRecIDEF0Kod(function);
}
}
if (f == null)
return "A-0";
if (f.getParent() == null)
return "A0";
return "A" + getRecIDEF0Kod(function);
}
Aggregations