use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class Client method run.
public void run(final String[] args) {
final SplashScreen screen = new SplashScreen() {
/**
*/
private static final long serialVersionUID = -4641958771849938048L;
@Override
protected String getImageName() {
for (String s : args) if (s.equals("-season"))
return "/com/ramussoft/season/about.png";
return "/com/ramussoft/gui/about.png";
}
};
if (Metadata.CLIENT) {
Metadata.REGISTERED_FOR = ClientConnection.getName();
Metadata.DEMO_REGISTERED = ClientConnection.getName() != null;
}
screen.setLocationRelativeTo(null);
boolean hide = false;
for (String s : args) if ("--hide-splash".equals(s))
hide = true;
if (!hide)
screen.setVisible(true);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
List<PluginProvider> suits = new ArrayList<PluginProvider>();
suits.add(new SimpleAttributePluginSuit());
initAdditionalPluginSuits(suits);
PluginFactory factory = createPluginFactory(suits);
PersistentFactory persistentFactory = new PersistentFactory(null, factory.getAttributePlugins(), null);
persistentFactory.reinit();
Engine engine = getEngine(factory, persistentFactory);
AccessRules rules = getAccessRules();
e = engine;
e.setPluginProperty("Core", "PluginList", factory.getPlugins());
e.setPluginProperty("Core", "PluginFactory", factory);
LightClient.staticEngine = e;
LightClient.staticAccessRules = rules;
List<GUIPlugin> list = new ArrayList<GUIPlugin>();
QualifierPluginSuit.addPlugins(list, e, rules);
initAdditionalGuiPlugins(list);
User me = getMe();
List<Group> groups = me.getGroups();
String[] grps = new String[groups.size()];
for (int i = 0; i < grps.length; i++) grps[i] = groups.get(i).getName();
AbstractGUIPluginFactory factory1;
String ws = Options.getString("WindowsControl", "simple");
if (ws.equals("simple"))
factory1 = new SimleGUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
else
factory1 = new GUIPluginFactory(list, e, rules, getType(), grps, loadPlugins);
framework = factory1.getFramework();
framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void afterClosed() {
Client.this.close();
}
});
final JFrame frame = factory1.getMainFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String title = getTitle();
frame.setTitle(title);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frame.setVisible(true);
screen.setVisible(false);
}
});
}
});
t.start();
Thread thread = new Thread("Icons-buffer-cleaner") {
@Override
public void run() {
while (true) {
try {
Thread.sleep(20000);
IconFactory.clearIconsBuffer(LightClient.staticEngine);
IconFactory.clearQualifierIconsBuffer(LightClient.staticEngine);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class AbstractChartSetupEditor method createComponent.
@Override
public JComponent createComponent(GUIFramework framework, Element element) {
this.framework = framework;
ChartSource chartSource = new ChartSource(framework.getEngine());
if (element != null) {
Engine engine = framework.getEngine();
chartSource.load(engine.getInputStream(getPreferencesPath(element, StandardAttributesPlugin.getAttributeNameAttribute(engine))));
}
component = new ChartSourceSelectPanel(framework, chartSource);
return component;
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class SectorColorAttributePlugin 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 PaintSector.Pin pin;
private JColorChooser component;
private Color color;
{
component = new JColorChooser();
}
@Override
public Object setValue(Object value) {
this.pin = (PaintSector.Pin) value;
color = pin.getSector().getColor();
component.setColor(color);
return value;
}
@Override
public Object getValue() {
return pin;
}
@Override
public void apply(Engine engine, Element element, Attribute attribute, Object value) {
SectorColorAttributePlugin.this.apply(component.getColor(), pin);
}
@Override
public JComponent getComponent() {
return component;
}
@Override
public boolean isSaveAnyway() {
return !color.equals(component.getColor());
}
};
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class HTTPParser method printFile.
private void printFile() throws IOException {
long elementId = Long.parseLong(params.get("id"));
long attributeId = Long.parseLong(params.get("attr"));
Engine engine = dataPlugin.getEngine();
FilePlugin plugin = (FilePlugin) engine.getPluginProperty("Core", FilePlugin.PLUGIN_NAME);
String string = plugin.getFilePath(elementId, attributeId);
List<Persistent>[] lists = engine.getBinaryAttribute(elementId, attributeId);
if (lists[0].size() > 0) {
FilePersistent fp = (FilePersistent) lists[0].get(0);
String userAgent = request.getUserAgent();
String encodedFileName = null;
if ((userAgent != null) && (userAgent.contains("MSIE") || userAgent.contains("Opera"))) {
encodedFileName = URLEncoder.encode(fp.getName(), "UTF-8");
} else {
byte[] bytes = fp.getName().getBytes("UTF-8");
try {
encodedFileName = "=?UTF-8?B?" + new String(Base64.encode(bytes), "UTF-8") + "?=";
} catch (Exception e) {
e.printStackTrace();
}
}
if (params.get("prev") == null) {
response.setContentDisposition("attachment; filename=" + encodedFileName);
response.setRamusContentDisposition(toUtf8(fp.getName()));
}
}
byte[] bytes = engine.getStream(string);
response.writeHead();
if (bytes != null)
stream.write(bytes);
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class OtherElementAttributeViewer method printAttribute.
@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
Engine engine = dataPlugin.getEngine();
Long id = (Long) engine.getAttribute(element, attribute);
if (id != null) {
Element element2 = engine.getElement(id);
if (element2 != null) {
OtherElementPropertyPersistent pp = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
Attribute other = engine.getAttribute(pp.getQualifierAttribute());
if (other != null) {
callback.beforePrint(printStream);
printLinkToElement(element2, engine.getAttribute(element2, other), parser, printStream);
callback.afterPrint(printStream);
}
}
}
}
Aggregations