use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class ProjectOptionsPanel method update.
private void update(Function function, boolean updateFonts, boolean updateZoom, double percent, GUIFramework framework) {
if (!updateFonts && !updateZoom)
return;
long id = -1l;
if (!dataPlugin.getBaseFunction().equals(function)) {
id = function.getElement().getId();
}
framework.propertyChanged(IDEF0TabView.CLOSE, id);
SectorRefactor sectorRefactor = new SectorRefactor(new MovingArea(dataPlugin, function));
sectorRefactor.updatePageSize(updateFonts, updateZoom, percent, function);
Vector<Row> v = dataPlugin.getChilds(function, true);
for (Row row : v) {
Function function2 = (Function) row;
update(function2, updateFonts, updateZoom, percent, framework);
}
}
use of com.ramussoft.pb.Function 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.Function in project ramus by Vitaliy-Yakovchuk.
the class ExportToImagesDialog method onOk.
@Override
protected void onOk() {
final File dir = new File(directory.getText());
if (dir.exists()) {
if (!dir.isDirectory()) {
JOptionPane.showMessageDialog(this, MessageFormat.format(ResourceLoader.getString("FileIsNotADirectory"), directory.getText()));
} else {
for (File file : dir.listFiles()) {
if (file.isFile()) {
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("DirectoryIsNotEmpty"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
break;
}
}
}
} else {
if (!dir.mkdirs()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("CanNotCreateADirectory"));
}
}
final BusyDialog dialog = new BusyDialog(this, ResourceLoader.getString("ExportingBusy"));
Thread export = new Thread("Export-to-images") {
@Override
public void run() {
int i = 0;
int[] js = chackedPanel.getSelected();
for (Function f : chackedPanel.getSelectedFunctions()) {
try {
String prefix = Integer.toString(js[i] + 1);
while (prefix.length() < 2) prefix = "0" + prefix;
exportToFile(dir, f, prefix + "_");
i++;
} catch (IOException e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dialog.setVisible(false);
}
});
JOptionPane.showMessageDialog(ExportToImagesDialog.this, e.getLocalizedMessage());
if (Metadata.DEBUG)
e.printStackTrace();
return;
}
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dialog.setVisible(false);
}
});
Options.setString(LAST_IMG_EXPORT_DIRECTORY, directory.getText());
ExportToImagesDialog.super.onOk();
}
};
export.start();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (ExportToImagesDialog.this.isVisible())
dialog.setVisible(true);
}
});
}
use of com.ramussoft.pb.Function 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.Function 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);
}
Aggregations