use of com.ramussoft.gui.common.AbstractGUIPluginFactory in project ramus by Vitaliy-Yakovchuk.
the class Runner method openInNewWindows.
@SuppressWarnings("unchecked")
public void openInNewWindows(final Engine engine, AccessRules rules) {
List<GUIPlugin> list = new ArrayList<GUIPlugin>();
initAdditionalGUIPlugins(list, engine, rules);
list.add(new UndoRedoPlugin(engine));
final AbstractGUIPluginFactory factory = createGUIPluginFactory(engine, rules, list);
final JFrame frame = factory.getMainFrame();
List<JFrame> frames = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
if (frames == null) {
frames = new ArrayList<JFrame>();
engine.setPluginProperty(CORE, "AdditionalWindows", frames);
}
frames.add(frame);
final JFrame mainFrame = (JFrame) engine.getPluginProperty(CORE, "MainFrame");
frame.setTitle("[" + mainFrame.getTitle() + "]");
final PropertyChangeListener titleListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
frame.setTitle("[" + (String) evt.getNewValue() + "]");
}
};
factory.getFramework().addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void afterClosed() {
mainFrame.removePropertyChangeListener("title", titleListener);
List<JFrame> list = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
list.remove(frame);
}
});
mainFrame.addPropertyChangeListener("title", titleListener);
beforeMainFrameShow(frame);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
postShowVisibaleMainFrame(engine, factory.getFramework());
}
});
}
use of com.ramussoft.gui.common.AbstractGUIPluginFactory 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.gui.common.AbstractGUIPluginFactory in project ramus by Vitaliy-Yakovchuk.
the class Runner method createGUIPluginFactory.
private AbstractGUIPluginFactory createGUIPluginFactory(final Engine engine, final AccessRules rules, List<GUIPlugin> list) {
AbstractGUIPluginFactory factory;
String ws = Options.getString("WindowsControl", "classic");
if (ws.equals("simple"))
factory = new SimleGUIPluginFactory(list, engine, rules, null, null);
else
factory = new GUIPluginFactory(list, engine, rules, null, null);
return factory;
}
use of com.ramussoft.gui.common.AbstractGUIPluginFactory in project ramus by Vitaliy-Yakovchuk.
the class Runner method openInNewWindows.
@SuppressWarnings("unchecked")
public JFrame openInNewWindows(final Engine engine, final AccessRules rules, final File file, final boolean recovered) {
List<GUIPlugin> list = new ArrayList<GUIPlugin>();
FilePlugin filePlugin = new FilePlugin((FileIEngineImpl) engine.getDeligate(), engine, rules, file, this);
list.add(filePlugin);
list.add(new UndoRedoPlugin(engine));
initAdditionalGUIPlugins(list, engine, rules);
final AbstractGUIPluginFactory factory = createGUIPluginFactory(engine, rules, list);
final JFrame frame = factory.getMainFrame();
engine.setPluginProperty(CORE, "MainFrame", frame);
String title = getApplicationTitle();
if (file != null)
title += " - " + file.getName();
frame.setTitle(title);
factory.getFramework().addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void afterClosed() {
List<JFrame> list = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
if (list != null) {
JFrame[] frames = list.toArray(new JFrame[list.size()]);
for (JFrame frame : frames) {
frame.setVisible(false);
frame.dispose();
}
}
FileIEngineImpl impl = (FileIEngineImpl) engine.getDeligate();
try {
impl.getTemplate().getConnection().close();
if (engine instanceof Journaled)
((Journaled) engine).close();
impl.close();
impl.clear();
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
Object changed = engine.getPluginProperty(CORE, "Changed");
if (changed != null)
filePlugin.changed();
InputStream is = engine.getInputStream("/user/gui/session.binary");
if (is != null) {
try {
ObjectInputStream ois = new ObjectInputStream(is);
try {
final List<ActionEvent> session = (List<ActionEvent>) ois.readObject();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (ActionEvent e : session) if (e != null)
factory.getFramework().propertyChanged(e);
}
});
} catch (Exception e) {
e.printStackTrace();
} finally {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
beforeMainFrameShow(frame);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
if (recovered) {
factory.getFramework().propertyChanged("FileRecovered");
} else
factory.getFramework().propertyChanged("FileOpened", file);
postShowVisibaleMainFrame(engine, factory.getFramework());
}
});
return frame;
}
Aggregations