use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method fixEndOwners.
private static void fixEndOwners(Sector sector, DataPlugin dataPlugin) {
Function function2 = sector.getStart().getFunction();
if (function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
fillFromOwners(function2, dataPlugin);
Crosspoint crosspoint = sector.getEnd().getCrosspoint();
if (crosspoint != null) {
for (Sector sector2 : crosspoint.getOppozite(sector)) fixEndOwners(sector2, dataPlugin);
}
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method getOppozite.
/**
* Медод повертає набір секторів, протилежних до точки перетену.
*
* @param sector Сектор відображення, для якого необхідно знайти протилежні.
* @param point Точка - перхрестя.
* @return Масив секторів, які є пролежними до переданого.
*/
public PaintSector[] getOppozite(final PaintSector sector, final Crosspoint point) {
final Sector[] sectors = point.getOppozite(sector.getSector());
final Vector<PaintSector> r = new Vector<PaintSector>();
for (int i = 0; i < getSectorsCount(); i++) {
final PaintSector s = getSector(i);
final Sector sec = s.getSector();
for (final Sector element : sectors) if (sec.equals(element))
r.add(s);
}
final PaintSector[] rs = new PaintSector[r.size()];
for (int i = 0; i < rs.length; i++) rs[i] = r.get(i);
return rs;
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class StreamAttributePlugin method getAttributeEditor.
@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
if (old != null)
old.close();
return new AbstractAttributeEditor() {
private SectorRowsEditor sectorRowsEditor;
private SectorNameEditor sectorNameEditor;
private PaintSector.Pin pin;
private DataPlugin dataPlugin;
private PaintSector sector;
private JTabbedPane component;
{
dataPlugin = NDataPluginFactory.getDataPlugin(null, engine, rules);
Sector sector = dataPlugin.findSectorByGlobalId(GlobalId.create(element.getId()));
if (sector != null) {
dataPlugin = NDataPluginFactory.getDataPlugin(engine.getQualifier(sector.getFunction().getElement().getQualifierId()), engine, rules);
component = new JTabbedPane();
sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, rules);
sectorNameEditor = new SectorNameEditor(dataPlugin, framework, rules) {
@Override
public Stream getStream() {
return sectorRowsEditor.getStream();
}
};
sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
component.addTab(ResourceLoader.getString("stream"), null, sectorRowsEditor, null);
component.addTab(ResourceLoader.getString("name"), null, sectorNameEditor, null);
ResourceLoader.setJComponentsText(sectorRowsEditor);
ResourceLoader.setJComponentsText(sectorNameEditor);
}
}
@Override
public Object setValue(Object value) {
this.pin = (PaintSector.Pin) value;
sector = pin.getSector();
sectorNameEditor.setSector(sector.getSector());
sectorRowsEditor.setSector(sector.getSector());
return value;
}
@Override
public Object getValue() {
return pin;
}
@Override
public JComponent getComponent() {
if (component == null)
return new JPanel();
return component;
}
@Override
public JComponent getLastComponent() {
return component;
}
@Override
public void apply(Engine engine, Element element, Attribute attribute, Object value) {
sector.setShowText(sectorNameEditor.getBox().isSelected());
sector.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);
final Row[] added = stream.getAdded();
stream.setRows(sectorRowsEditor.getRows());
sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
stream = sector.getStream();
stream.setRows(added);
// sector.setStreamAddedByRefactor(false);
final Row[] rs = sectorRowsEditor.getRows();
sector.setRows(rs);
sector.createTexts();
PaintSector.save(sector, new DataLoader.MemoryData(), engine);
sector.getMovingArea().getRefactor().setUndoPoint();
sectorNameEditor.setChanged(false);
}
@Override
public boolean canApply() {
final boolean b = isSave();
if (b) {
if (!isOkStreamName()) {
if (JOptionPane.showConfirmDialog(component, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return false;
}
} else {
JOptionPane.showMessageDialog(component, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
return false;
}
return b;
}
private boolean isSave() {
final Row[] rs = sectorRowsEditor.getRows();
final boolean b = rs.length > 0 || !sectorNameEditor.getArrowName().equals("");
return b;
}
private boolean isOkStreamName() {
final Stream stream = sectorNameEditor.findStreamByName();
if (stream != null)
return stream.equals(sectorNameEditor.getNullStream());
return true;
}
@Override
public boolean isSaveAnyway() {
return sectorRowsEditor.isChanged() || sectorNameEditor.isChanged();
}
@Override
public void close() {
super.close();
sectorRowsEditor.dispose();
}
};
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class AbstractCrosspoint method remove1.
public void remove1(final Sector sector) {
// synchronized (dataPlugin) {
final boolean b = isDLevel();
removeData(sector);
final Sector[] ins = getIns();
final Sector[] outs = getOuts();
if (b) {
if (ins.length == 0 && outs.length == 1) {
if (outs[0].getEnd().getCrosspoint() == null)
if (outs[0].getStart().getBorderType() >= 0)
outs[0].remove();
else {
/*Function function = outs[0].getStart().getFunction();
if (function != null
&& function.getType() == Function.TYPE_DFDS_ROLE) {
((NFunction) function).remove();
outs[0].remove();
}*/
}
} else if (ins.length == 1 && outs.length == 0) {
if (ins[0].getStart().getCrosspoint() == null)
if (ins[0].getEnd().getBorderType() >= 0)
ins[0].remove();
else {
Function function = ins[0].getEnd().getFunction();
if (function != null && function.getType() == Function.TYPE_DFDS_ROLE) {
((NFunction) function).remove();
ins[0].remove();
}
}
}
}
if (getIns().length == 0 && getOuts().length == 0) {
dataPlugin.removeCrosspoint(this);
}
// }
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class AbstractCrosspoint method getSectors.
public void getSectors(final Vector<Sector> v) {
final Sector[] ins = getIns();
final Sector[] outs = getOuts();
for (final Sector element : ins) {
if (v.indexOf(element) < 0)
v.add(element);
}
for (final Sector element : outs) {
if (v.indexOf(element) < 0)
v.add(element);
}
}
Aggregations