use of com.ramussoft.pb.data.negine.NDataPlugin in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method createDataPlugin.
private DataPlugin createDataPlugin() {
DataPlugin plugin = (DataPlugin) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { DataPlugin.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
String name = method.getName();
if ("getBaseFunction".equals(name)) {
if (rowBaseFunction == null) {
rowBaseFunction = getBaseFunction(dataPlugin, baseFunction);
}
return rowBaseFunction;
}
if ("getBaseFunctionQualifier".equals(name))
return baseFunction;
if ("isReadOnly".equals(name))
return !dataPlugin.getAccessRules().canUpdateQualifier(baseFunction.getId());
if ("createRow".equals(name)) {
com.ramussoft.pb.Row parent = (com.ramussoft.pb.Row) args[0];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent);
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ("createFunction".equals(name)) {
com.ramussoft.pb.Function parent = (com.ramussoft.pb.Function) args[0];
final Integer type = (Integer) args[1];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent, new ElementCreationCallback() {
@Override
public void created(Element element) {
Engine engine = dataPlugin.getEngine();
Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
engine.setAttribute(element, attribute, type);
}
});
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ((("getChilds".equals(name)) || ("getRecChilds".equals(name))) && (args[0] == null) && (((Boolean) args[1]) == false)) {
Vector v = (Vector) method.invoke(dataPlugin, args);
v.add(0, dataPlugin.getBaseStream());
v.add(0, getBaseFunction(dataPlugin, baseFunction));
return v;
}
if ("getProjectOptions".equals(name))
return getProjectOptions();
if ("setProjectOptions".equals(name))
return setProjectOptions((ProjectOptions) args[0]);
if ("refresh".equals(name)) {
fullRefrash((GUIFramework) args[0]);
return null;
}
return method.invoke(dataPlugin, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
private Row getBaseFunction(final NDataPlugin dataPlugin, final Qualifier baseFunction) {
return dataPlugin.getNBaseFunction(baseFunction.getId());
}
protected Object setProjectOptions(ProjectOptions projectOptions) {
getBaseFunction(dataPlugin, baseFunction).setAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()), projectOptions);
return null;
}
protected Object getProjectOptions() {
return getBaseFunction(dataPlugin, baseFunction).getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
}
});
plugin.getBaseFunction();
return plugin;
}
use of com.ramussoft.pb.data.negine.NDataPlugin in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method fullRefrash.
public static void fullRefrash(GUIFramework framework) {
Engine engine = framework.getEngine();
Long long1 = (Long) engine.getPluginProperty("IDEF0", "NDataPluginRefreshId");
if (long1 == null)
return;
long id = framework.getActionId(Commands.FULL_REFRESH);
if (id == long1.longValue())
return;
engine.setPluginProperty("IDEF0", "NDataPluginRefreshId", new Long(id));
List<NDataPluginFactory> list = (List<NDataPluginFactory>) engine.getPluginProperty("IDEF0", "NDataPluginFactoryList");
NDataPlugin dataPlugin = getExistingDataPlugin(engine);
dataPlugin.close();
dataPlugin = new NDataPlugin(dataPlugin.getEngine(), dataPlugin.getAccessRules());
for (NDataPluginFactory f : list) {
f.dataPlugin = dataPlugin;
f.rowBaseFunction = null;
}
engine.setPluginProperty("IDEF0", "DataPlugin", dataPlugin);
}
use of com.ramussoft.pb.data.negine.NDataPlugin in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ViewPlugin method setFramework.
@Override
public void setFramework(final GUIFramework framework) {
super.setFramework(framework);
this.engine = framework.getEngine();
this.rules = framework.getAccessRules();
this.frame.setEngine(framework);
addOpenDiagramListener();
addOpenStreamsViewListener();
framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void closed() {
Options.save();
if (navigator != null)
navigator.dispose();
if (engine.getPluginProperty("Core", "MainFrame") == framework.getMainFrame()) {
NDataPlugin dataPlugin = (NDataPlugin) engine.getPluginProperty("IDEF0", "DataPlugin");
if (dataPlugin != null) {
dataPlugin.clear();
dataPlugin.clearAll();
}
}
if (server != null) {
try {
server.getServer().close();
} catch (IOException e) {
e.printStackTrace();
}
server.interrupt();
}
}
});
framework.addActionListener("FileOpened", new ActionListener() {
@Override
public void onAction(ActionEvent event) {
if (event.getValue() == null) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
NewProjectDialog dialog = new NewProjectDialog(framework.getMainFrame());
dialog.showModal(engine, rules, framework);
}
});
}
}
});
framework.addActionListener(Commands.FULL_REFRESH, new ActionListener() {
@Override
public void onAction(ActionEvent event) {
if (NDataPluginFactory.getExistingDataPlugin(engine) != null)
NDataPluginFactory.fullRefrash(framework);
}
});
framework.setSystemAttributeName(IDEF0Plugin.getBackgroundColorAttribute(engine), ResourceLoader.getString("bk_color"));
framework.setSystemAttributeName(IDEF0Plugin.getForegroundColorAttribute(engine), ResourceLoader.getString("fg_color"));
framework.setSystemAttributeName(IDEF0Plugin.getFontAttribute(engine), ResourceLoader.getString("font"));
framework.setSystemAttributeName(IDEF0Plugin.getFunctionTypeAttribute(engine), ResourceLoader.getString("function_type"));
framework.setSystemAttributeName(IDEF0Plugin.getFunctionOunerAttribute(engine), ResourceLoader.getString("select_owner"));
StreamAttributePlugin plugin = new StreamAttributePlugin();
plugin.setFramework(framework);
framework.setSystemAttributePlugin(IDEF0Plugin.getStreamAttribute(engine), plugin);
framework.setSystemAttributeName(IDEF0Plugin.getStreamAttribute(engine), ResourceLoader.getString("stream"));
framework.setSystemAttributePlugin(IDEF0Plugin.getSectorBorderEndAttribute(engine), new SectorFontAttributePlugin());
framework.setSystemAttributeName(IDEF0Plugin.getSectorBorderEndAttribute(engine), ResourceLoader.getString("font"));
framework.setSystemAttributePlugin(IDEF0Plugin.getSectorBorderStartAttribute(engine), new SectorColorAttributePlugin());
framework.setSystemAttributeName(IDEF0Plugin.getSectorBorderStartAttribute(engine), ResourceLoader.getString("color"));
framework.setSystemAttributePlugin(IDEF0Plugin.getSectorFunctionAttribute(engine), new LineStyleAttributePlugin());
framework.setSystemAttributeName(IDEF0Plugin.getSectorFunctionAttribute(engine), ResourceLoader.getString("arrow"));
}
use of com.ramussoft.pb.data.negine.NDataPlugin in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method getDataPlugin.
public static DataPlugin getDataPlugin(Qualifier baseFunction, Engine e, AccessRules accessRules) {
NDataPlugin dataPlugin = getExistingDataPlugin(e);
if (dataPlugin == null) {
dataPlugin = new NDataPlugin(e, accessRules);
e.setPluginProperty("IDEF0", "DataPlugin", dataPlugin);
}
if (baseFunction == null)
return dataPlugin;
DataPlugin dp = (DataPlugin) e.getPluginProperty("IDEF0", "BaseFunction_" + baseFunction.getId());
if (dp == null) {
NDataPluginFactory dataPluginFactory = new NDataPluginFactory(e, baseFunction, dataPlugin);
List<NDataPluginFactory> list = (List<NDataPluginFactory>) e.getPluginProperty("IDEF0", "NDataPluginFactoryList");
if (list == null) {
list = new ArrayList<NDataPluginFactory>();
e.setPluginProperty("IDEF0", "NDataPluginFactoryList", list);
e.setPluginProperty("IDEF0", "NDataPluginRefreshId", new Long(-1l));
}
list.add(dataPluginFactory);
dp = dataPluginFactory.createDataPlugin();
e.setPluginProperty("IDEF0", "BaseFunction_" + baseFunction.getId(), dp);
}
initTemplate();
return dp;
}
use of com.ramussoft.pb.data.negine.NDataPlugin in project ramus by Vitaliy-Yakovchuk.
the class AbstractDataPlugin method createParalel.
public boolean createParalel(final Function base, final boolean copyAllRows, final boolean clearElements, final File file, final GUIFramework framework, final DataPlugin dataPlugin) throws IOException {
Thread thread = new Thread("Model-paraleler") {
public void run() {
try {
framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, false);
framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, true);
framework.showAnimation(ResourceLoader.getString("Wait.Message"));
MemoryDatabase md = new MemoryDatabase() {
protected String getJournalDirectoryName(String tmp) {
return null;
}
};
final NDataPlugin fdp = new NDataPlugin(md.getEngine("idef0"), md.getAccessRules("idef0"));
final ModelParaleler paraleler = new ModelParaleler(AbstractDataPlugin.this, fdp, framework);
paraleler.createParalel(base, copyAllRows);
FileIEngineImpl impl = (FileIEngineImpl) md.getEngine("idef0").getDeligate();
impl.saveToFile(file);
impl.close();
if (clearElements) {
((Journaled) getEngine()).startUserTransaction();
try {
paraleler.clear(base);
} finally {
((Journaled) getEngine()).commitUserTransaction();
}
}
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
} finally {
framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, false);
framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, true);
framework.propertyChanged(ModelsView.REFRESH_ALL_MODELS);
framework.hideAnimation();
}
}
};
thread.start();
return true;
}
Aggregations