use of com.ramussoft.gui.common.SplashScreen in project ramus by Vitaliy-Yakovchuk.
the class Runner method recoverySession.
public boolean recoverySession(final String sessionPath, final File sourceFile) {
Window rFrame = new Window(null);
String recovering = GlobalResourcesManager.getString("File.Recovering");
rFrame.add(new Label(MessageFormat.format(recovering, ((sourceFile == null) ? GlobalResourcesManager.getString("Session.NoName") : sourceFile.getName()))));
rFrame.pack();
rFrame.setLocationRelativeTo(null);
rFrame.setVisible(true);
final String s = sessionPath + File.separator + "source.rms";
MemoryDatabase database = new MemoryDatabase() {
@Override
protected Collection<? extends PluginProvider> getAdditionalSuits() {
ArrayList<PluginProvider> ps = new ArrayList<PluginProvider>(1);
initAdditionalPluginSuits(ps);
return ps;
}
@Override
protected File getFile() {
File file = new File(s);
if (file.exists())
return file;
return null;
}
protected FileIEngineImpl createFileIEngine(PluginFactory factory) throws ClassNotFoundException, ZipException, IOException {
return new FileIEngineImpl(0, template, factory, sessionPath);
}
};
final Engine engine = database.getEngine(null);
DirectoryJournalFactory factory = database.getJournalFactory();
Journal[] journals = factory.loadJournals(database.getJournaledEngine());
if (journals.length == 0)
return false;
boolean exist = false;
Journal.RedoCallback redoCallback = new Journal.RedoCallback() {
boolean hadStartUserTransaction;
@Override
public boolean execute(Command command) {
if (command instanceof StartUserTransactionCommand) {
hadStartUserTransaction = true;
}
return hadStartUserTransaction;
}
};
for (Journal journal : journals) {
try {
Command command = null;
while (journal.canRedo()) {
command = journal.redo(redoCallback);
}
if ((journal.getPointer() == 0l) || (command instanceof StopUndoPointCommand)) {
rFrame.setVisible(false);
continue;
} else
exist = true;
if (!(command instanceof EndUserTransactionCommand))
throw new Exception();
} catch (Exception e) {
e.printStackTrace();
while (journal.canUndo()) {
if (journal.undo() instanceof StartUserTransactionCommand)
break;
}
}
}
if (!exist) {
try {
((FileIEngineImpl) engine.getDeligate()).close();
for (Journal journal : journals) journal.close();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
((FileIEngineImpl) engine.getDeligate()).recoveryStreams();
engine.setPluginProperty(CORE, "Changed", Boolean.TRUE);
engine.setActiveBranch(-1l);
final AccessRules accessor = database.getAccessRules(null);
rFrame.setVisible(false);
Runnable runnable = new Runnable() {
@Override
public void run() {
SplashScreen screen = new SplashScreen() {
/**
*/
private static final long serialVersionUID = -2727237354089088151L;
@Override
protected String getImageName() {
return Runner.this.getSplashImageName();
}
};
screen.setLocationRelativeTo(null);
screen.setVisible(true);
final JFrame frame = openInNewWindows(engine, accessor, sourceFile, true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String recovered = GlobalResourcesManager.getString("File.Recovered");
frame.setTitle(frame.getTitle() + " " + recovered);
}
});
screen.setVisible(false);
}
};
recoveredCount++;
Thread thread = new Thread(runnable);
thread.start();
return true;
}
use of com.ramussoft.gui.common.SplashScreen 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.SplashScreen in project ramus by Vitaliy-Yakovchuk.
the class Runner method open.
public boolean open(File afile) {
JFrame frame = null;
if (afile != null)
for (FilePlugin plugin : FilePlugin.plugins) {
if ((plugin.getFile() != null) && (plugin.getFile().equals(afile))) {
frame = plugin.getFramework().getMainFrame();
break;
}
}
if (frame != null) {
frame.setVisible(true);
return false;
} else {
SplashScreen screen = null;
if (FilePlugin.plugins.size() < 1 && !Metadata.HIDE_SPLASH) {
screen = new SplashScreen() {
/**
*/
private static final long serialVersionUID = -8194442573188103621L;
@Override
protected String getImageName() {
return Runner.this.getSplashImageName();
}
};
screen.setLocationRelativeTo(null);
screen.setVisible(true);
}
try {
openFile(afile);
return true;
} catch (Exception e) {
e.printStackTrace();
if (screen != null)
screen.setVisible(false);
if (e instanceof FileMinimumVersionException) {
JOptionPane.showMessageDialog(null, MessageFormat.format(GlobalResourcesManager.getString("MinimumApplicationVersionToOpenFile"), ((FileMinimumVersionException) e).getMinimumVersion()));
} else
JOptionPane.showMessageDialog(null, e.getLocalizedMessage());
return false;
} finally {
if (FilePlugin.plugins.size() < 2) {
if (screen != null)
screen.setVisible(false);
}
}
}
}
Aggregations