use of com.ramussoft.gui.common.event.CloseMainFrameAdapter in project ramus by Vitaliy-Yakovchuk.
the class FilePlugin method setFramework.
@SuppressWarnings("unused")
@Override
public void setFramework(final GUIFramework framework) {
super.setFramework(framework);
framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public boolean close() {
boolean close = closeFrame(framework);
return close;
}
@Override
public void closed() {
plugins.remove(FilePlugin.this);
}
});
setFile(file);
if ((!Metadata.CORPORATE) && (Options.getBoolean(CHECK_FOR_UPDATES, true)) && (isTimeToUpdate())) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(20000);
checkForUpdates();
} catch (Exception e) {
}
}
}, "Update-checker");
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
if (Metadata.DEMO) {
framework.put("FilePlugin", this);
framework.addActionListener("DisableSaveActions", new ActionListener() {
@Override
public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
saveAction.setEnabled(false);
saveFileAsAction.setEnabled(false);
}
});
framework.addActionListener("EnableSaveActions", new ActionListener() {
@Override
public void onAction(com.ramussoft.gui.common.event.ActionEvent event) {
saveAction.setEnabled(true);
saveFileAsAction.setEnabled(true);
}
});
}
}
use of com.ramussoft.gui.common.event.CloseMainFrameAdapter 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.event.CloseMainFrameAdapter 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.event.CloseMainFrameAdapter in project ramus by Vitaliy-Yakovchuk.
the class OtherElementPlugin method setFramework.
@Override
public void setFramework(GUIFramework framework) {
super.setFramework(framework);
final QualifierListener listener = new QualifierAdapter() {
@Override
public void qualifierDeleted(QualifierEvent event) {
RowSetValue value = sets.get(event.getOldQualifier());
if (value != null) {
value.rowSet.close();
sets.remove(event.getOldQualifier());
}
}
};
framework.getEngine().addQualifierListener(listener);
framework.addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void closed() {
for (RowSetValue value : sets.values()) {
try {
value.rowSet.close();
} catch (Exception e) {
e.printStackTrace();
}
}
sets.clear();
OtherElementPlugin.this.framework.getEngine().removeQualifierListener(listener);
}
});
}
use of com.ramussoft.gui.common.event.CloseMainFrameAdapter 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"));
}
Aggregations