use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class InstallerEngine method getDescriptor.
public Properties getDescriptor(String key, boolean propagate) {
int i = 0;
Properties descriptor = null;
IInstaller inst = null;
while (descriptor == null && i < this.m_installers.size()) {
inst = (IInstaller) this.m_installers.get(i);
descriptor = inst.getDescriptor(key);
i++;
}
if (descriptor == null && propagate) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, NAMESPACE, "invaliddescriptor", new Exception("No descriptor found for namespace: " + key)));
}
return descriptor;
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class ExportAction method run.
public void run() {
try {
FileDialog dialog = new FileDialog(new Shell(DisplayManager.getDefaultDisplay()), SWT.SAVE);
dialog.setText(this.getI18nManager().getString(this.getNamespace(), "title", "label", this.getLanguage()));
List ids = ImExportFactory.getInstance().getAllExporterIds(IImExporter.CALL_MODE);
String[] filternames = new String[ids.size()];
String[] extensions = new String[ids.size()];
IImExporter ie = null;
for (int i = 0; i < ids.size(); i++) {
ie = ImExportFactory.getInstance().getExporter((String) ids.get(i));
filternames[i] = ie.getFilterName();
extensions[i] = ie.getExtension();
}
dialog.setFilterNames(filternames);
dialog.setFilterExtensions(extensions);
String filter = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(getNamespace(), "lastopeneddir");
if (filter == null || filter.length() == 0 || !new File(filter).exists())
filter = PathResolver.getInstance(getRuntime()).getUserDataDirectory();
dialog.setFilterPath(filter);
final String filename = dialog.open();
if (filename == null)
return;
filter = new File(filename).getParentFile().getAbsolutePath();
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(getNamespace(), "lastopeneddir", filter);
String ext = "";
for (int i = 0; i < ids.size(); i++) {
final IImExporter exp = ImExportFactory.getInstance().getExporter((String) ids.get(i));
ext = exp.getExtension().substring(1);
if (filename.endsWith(ext) && exp.getMode() == IImExporter.CALL_MODE) {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "exportprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
((ICallExporter) exp).setCallList(((JournalController) m_app.getController()).getCallList());
exp.setFilename(filename);
if (((ICallExporter) exp).doExport()) {
progressMonitor.done();
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "success", "description", getLanguage()))), "Tray");
} else {
progressMonitor.done();
new SWTExecuter() {
protected void execute() {
MessageDialog.openError(DisplayManager.getDefaultDisplay().getActiveShell(), getI18nManager().getString(getNamespace(), "error", "label", getLanguage()), getI18nManager().getString(getNamespace(), "error", "description", getLanguage()));
m_logger.warning("Export of journal failed.");
}
}.start();
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
throw e;
} catch (InvocationTargetException e) {
throw e;
}
m_app.updateViews(false);
}
}
} catch (Exception ex) {
this.m_logger.log(Level.SEVERE, ex.getMessage(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "error", ex));
}
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class ImportAction method run.
public void run(String[] filenames) {
try {
String filename = filenames[0];
TableViewer viewer = (TableViewer) this.m_app.getApplication().getViewer();
Cursor c = new Cursor(viewer.getTable().getDisplay(), SWT.CURSOR_WAIT);
if (!filename.endsWith(this.m_app.getApplication().getConfiguration().getProperty(CFG_OLD_JOURNAL, "ajournal.dat"))) {
File f = new File(filename);
String ext = f.getName();
IImExporter ie = ImExportFactory.getInstance().getImporterByExtension(ext);
if (ie == null && ext.lastIndexOf(".") >= 0) {
ext = "*" + ext.substring(ext.lastIndexOf("."));
ie = ImExportFactory.getInstance().getImporterByExtension(ext);
if (ie == null) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "error", "description", getLanguage()))), "Tray");
new SWTExecuter() {
protected void execute() {
MessageDialog.openError(DisplayManager.getDefaultDisplay().getActiveShell(), getI18nManager().getString(getNamespace(), "error", "label", getLanguage()), getI18nManager().getString(getNamespace(), "error", "description", getLanguage()));
m_logger.warning("Import of data failed.");
}
}.start();
}
}
if (ie != null && ie.getMode() != IImExporter.CALL_MODE)
return;
final IImExporter imp = ie;
imp.setFilename(filename);
viewer.getTable().getShell().setCursor(c);
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "importprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
final ICallList importedCalls = getRuntime().getCallFactory().createCallList();
if (imp.getMode() == IImExporter.CALL_MODE) {
importedCalls.add(((ICallImporter) imp).doImport());
m_app.getController().addElements(importedCalls);
}
if (importedCalls.size() > 0) {
final String msg = StringUtils.replaceString(getI18nManager().getString(getNamespace(), "success", "description", getLanguage()), "{%1}", Integer.toString(importedCalls.size()));
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
new SWTExecuter() {
protected void execute() {
m_app.updateViews(true);
}
}.start();
} else {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "error", "description", getLanguage()))), "Tray");
new SWTExecuter() {
protected void execute() {
MessageDialog.openError(DisplayManager.getDefaultDisplay().getActiveShell(), getI18nManager().getString(getNamespace(), "error", "label", getLanguage()), getI18nManager().getString(getNamespace(), "error", "description", getLanguage()));
m_logger.warning("Import of data failed.");
// m_app.getController().addElements(importedCalls);
m_app.updateViews(true);
}
}.start();
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true,
// pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
throw e;
} catch (InvocationTargetException e) {
throw e;
}
viewer.getTable().getShell().setCursor(null);
c.dispose();
} else {
// do ajournal.dat migration
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(this.getI18nManager().getString(this.getNamespace(), "migrationconfirm", "label", this.getLanguage()));
if (messageBox.open() == SWT.YES) {
viewer.getTable().getShell().setCursor(c);
IImExporter imp = ImExportFactory.getInstance().getImporter("OldDatFileCallImporter");
if (imp != null && (imp instanceof OldDatFileCallImporter)) {
((OldDatFileCallImporter) imp).setDatePattern(this.m_app.getApplication().getConfiguration().getProperty(CFG_OLD_DATE, "dd.MM.yyyy HH:mm:ss"));
((OldDatFileCallImporter) imp).setFilename(filename);
ICallList importedCalls = ((OldDatFileCallImporter) imp).doImport();
if (importedCalls != null) {
this.m_app.getController().addElements(importedCalls);
String msg = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(importedCalls.size()));
if (!suppressDialogs)
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "success", "label", getLanguage()), msg);
m_app.updateViews(true);
}
}
viewer.getTable().getShell().setCursor(null);
c.dispose();
} else {
return;
}
}
} catch (Exception ex) {
this.m_logger.log(Level.SEVERE, ex.getMessage(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "error", ex));
}
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class UpdatesCommand method asyncExecute.
public void asyncExecute() {
try {
WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
UpdateWizard updates = new UpdateWizard(this.m_preload);
Shell s = new Shell(DisplayManager.getDefaultDisplay());
WizardDialog dlg = new WizardDialog(s, updates);
DisplayManager.forceForeground(s);
dlg.open();
this.m_preload = false;
if (dlg.getReturnCode() == WizardDialog.OK) {
}
} catch (Throwable t) {
this.m_logger.log(Level.SEVERE, t.getMessage(), t);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, this.getNamespace(), t.toString().toLowerCase(), t));
} finally {
this.isExecuting = false;
}
}
Aggregations