use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method fillFromOwners.
private static void fillFromOwners(Function function, DataPlugin dataPlugin) {
Function par = (Function) function.getParent();
if (par == null)
return;
Vector<Sector> ends = new Vector<Sector>();
Vector<Sector> starts = new Vector<Sector>();
for (Sector sector : par.getSectors()) {
NSectorBorder start = sector.getStart();
if (function.equals(start.getFunction()) && start.getCrosspoint() != null) {
if (start.getCrosspoint().isDLevel()) {
for (Sector sector2 : start.getCrosspoint().getOppozite(sector)) starts.add(sector2);
}
}
NSectorBorder end = sector.getEnd();
if (function.equals(end.getFunction()) && end.getCrosspoint() != null) {
if (end.getCrosspoint().isDLevel()) {
for (Sector sector2 : end.getCrosspoint().getOppozite(sector)) ends.add(sector2);
}
}
}
if (ends.size() == 0 && starts.size() == 0)
return;
HashSet<Row> owners = new HashSet<Row>();
boolean[] hasFunctionOwners = new boolean[] { false };
for (Sector sector : starts) fillStartFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
for (Sector sector : ends) fillEndFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
if (!hasFunctionOwners[0] && owners.size() == 0)
return;
Stream stream = (Stream) dataPlugin.findRowByGlobalId(function.getLink());
if (stream == null) {
if (owners.size() > 0) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
function.setLink(stream.getElement().getId());
stream.setRows(owners.toArray(new Row[owners.size()]));
}
} else {
stream.setRows(owners.toArray(new Row[owners.size()]));
}
}
use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ChackedPanel method setFunctionParents.
/**
* Метод, який виводить в талицю набір тільки тих функцій, що мають дитячі
* елементи (включно з базовою фунцією "Роботи", якщо вона має дочірні
* елементи).
*/
public void setFunctionParents(DataPlugin dataPlugin) {
final Function base = dataPlugin.getBaseFunction();
final Vector<Function> res = new Vector<Function>();
if (base.isHaveChilds())
res.add(base);
final Vector<Row> v = dataPlugin.getRecChilds(base, true);
for (int i = 0; i < v.size(); i++) if (((Function) v.get(i)).isHaveRealChilds())
res.add((Function) v.get(i));
setFunctions(convert(res));
}
use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ChackedPanel method setFunctionAll.
/**
* Метод, який виводить в таблицю набір усіх функцій (включно з базовою
* фунцією "Роботи").
*/
public void setFunctionAll(DataPlugin dataPlugin) {
final Function base = dataPlugin.getBaseFunction();
final Vector<Row> v = dataPlugin.getRecChilds(base, true);
final Function[] functions = new Function[v.size() + 1];
functions[0] = base;
for (int i = 0; i < v.size(); i++) functions[i + 1] = (Function) v.get(i);
setFunctions(functions);
}
use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.
the class ArrowOptionstDialog method showModal.
public void showModal(final PaintSector sector, MovingArea movingArea) {
isOk = false;
Options.loadOptions("select_row", this);
Options.saveOptions("select_row", this);
sectorRowsEditor.setSector(sector.getSector());
sectorNameEditor.setSector(sector.getSector());
sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
getColorChooser16().setColor(sector.getColor());
getJFontChooser().setSelFont(sector.getFont());
final Stream s = sector.getStream();
loadFrom(s);
lineStyleChooser.setStroke(sector.getStroke());
sectorNameEditor.beforeShow();
Options.loadOptions("select_row", this);
setVisible(true);
if (isOk) {
((NSector) sector.getSector()).getDataPlugin().startUserTransaction();
sector.setFont(getJFontChooser().getSelFont());
sector.setColor(getColorChooser16().getColor());
sector.setStroke(lineStyleChooser.getStroke());
if (lineStyleChooser.isDefaultArrowStyle()) {
Options.setStroke("DEFAULT_ARROW_STROKE", lineStyleChooser.getStroke());
}
sector.copyVisual(Sector.VISUAL_COPY_ADDED);
sector.setShowText(sectorNameEditor.getBox().isSelected());
sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
sector.getSector().setTextAligment(sectorNameEditor.getTextAligment());
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);
}
final Row[] added = stream.getAdded();
stream.setRows(sectorRowsEditor.getRows());
sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
stream = sector.getStream();
stream.setRows(added);
saveTo(stream);
// sector.setStreamAddedByRefactor(false);
final Row[] rs = sectorRowsEditor.getRows();
sector.setRows(rs);
sector.createTexts();
HashSet<PaintSector> hashSet = new HashSet();
sector.getConnectedSector(hashSet);
for (PaintSector sp : hashSet) PaintSector.save(sp, new DataLoader.MemoryData(), dataPlugin.getEngine());
movingArea.getRefactor().setUndoPoint();
}
saveOption();
}
use of com.ramussoft.pb.Row in project ramus by Vitaliy-Yakovchuk.
the class SectorNameEditor method findStreamByName.
public Stream findStreamByName(final String name) {
if ("".equals(name))
return null;
final Vector<Row> streams = dataPlugin.getRecChilds(dataPlugin.getBaseStream(), true);
final int l = streams.size();
for (int i = 0; i < l; i++) {
final Stream s = (Stream) streams.get(i);
if (name.equals(s.getName()) && !s.isEmptyName())
return s;
}
return null;
}
Aggregations