use of de.janrufmonitor.repository.imexport.ITracker in project janrufmonitor by tbrandt77.
the class AbstractTreeTableApplication method updateViews.
public synchronized void updateViews(Object[] controllerdata, boolean reload) {
// refresh controll data
refreshController(reload);
if (controllerdata != null)
this.m_controller.generateElementArray(controllerdata);
final IFilterManager fm = this.getFilterManager();
if (fm != null) {
IFilter[] f = fm.getFiltersFromString(this.getConfiguration().getProperty(CFG_FILTER, ""));
String activeFilter = this.getFilterManager().getFiltersToLabelText(f, 45);
// get all defined Filters from configuration
List l = new ArrayList();
l.add(new IFilter[0]);
final IFilterManager jfm = getFilterManager();
Properties c = this.getConfiguration();
Iterator iter = c.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
if (key.startsWith("filter_")) {
String filter = c.getProperty(key);
l.add(jfm.getFiltersFromString(filter));
}
}
// 2009/01/10: added sorting of filters
Collections.sort(l, new Comparator() {
public int compare(Object o1, Object o2) {
if (o1 instanceof IFilter[] && o2 instanceof IFilter[]) {
return jfm.getFiltersToLabelText((IFilter[]) o1, 45).compareToIgnoreCase(jfm.getFiltersToLabelText((IFilter[]) o2, 45));
}
return 0;
}
});
String[] filters = new String[l.size()];
int select = -1;
String filterAlias = null;
for (int i = 0; i < l.size(); i++) {
filterAlias = jfm.getFiltersToLabelText((IFilter[]) l.get(i), 45);
if (filterAlias.equalsIgnoreCase(activeFilter)) {
select = i;
}
filters[i] = filterAlias;
this.currentView.setData(filterAlias, (IFilter[]) l.get(i));
}
this.currentView.setItems(filters);
if (select == -1) {
getApplication().getConfiguration().setProperty(CFG_FILTER, jfm.getFiltersToString((IFilter[]) l.get(0)));
getApplication().storeConfiguration();
select = 0;
}
this.currentView.select(select);
this.currentView.setVisibleItemCount((this.currentView.getItemCount() > 16 ? 16 : this.currentView.getItemCount()));
this.currentView.pack();
this.currentView.getParent().pack();
}
// update menu bar
Menu m = this.getMenuBarManager().getMenu();
this.setMenuItemStatus(m);
new SWTExecuter(false, getID() + "-BuildTableThread") {
protected void execute() {
final ThreadStatus ts = new ThreadStatus();
class WorkerSWTExecuter extends SWTExecuter {
public WorkerSWTExecuter(boolean sync, String name) {
super(sync, name);
}
public void execute() {
try {
Cursor c = new Cursor(((TreeViewer) viewer).getTree().getDisplay(), SWT.CURSOR_WAIT);
Tree tree = ((TreeViewer) viewer).getTree();
AbstractMenuBuilder mb = getMenuBuilder();
if (mb != null)
tree.setMenu(mb.createPopupMenu(tree));
tree.getShell().setCursor(c);
long start = System.currentTimeMillis();
viewer.setInput(null);
viewer.setInput(m_controller);
// added: 2007/03/17: avoid dead lock in journal...
ts.setFinished(true);
tree.setFocus();
tree.setLinesVisible(getConfiguration().getProperty(CFG_SHOW_GRID, "true").equalsIgnoreCase("true"));
TreeColumn[] columns = tree.getColumns();
for (int i = 0; i < columns.length; i++) {
columns[i].setImage(null);
}
int sortcolumn = getOrderColumn(Integer.parseInt(getConfiguration().getProperty(CFG_ORDER, "0")));
if (sortcolumn > -1 && sortcolumn < columns.length) {
tree.setSortColumn(columns[sortcolumn]);
if (getConfiguration().getProperty(CFG_DIRECTION, "false").equalsIgnoreCase("false")) {
tree.setSortDirection(SWT.DOWN);
} else {
tree.setSortDirection(SWT.UP);
}
}
IAction action = getColoringAction();
if (action != null)
action.run();
action = getHightlightAction();
if (action != null)
action.run();
// set new title text...
String title_ext = getTitleExtension();
if (title_ext == null || title_ext.length() == 0)
tree.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()));
else
tree.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()) + " - " + title_ext);
tree.getShell().setCursor(null);
c.dispose();
ts.setFinished(true);
if (lastMarkedTreeItem > -1 && tree.getItemCount() > 0) {
TreeItem item = tree.getItem(Math.min(lastMarkedTreeItem, tree.getItemCount() - 1));
if (item != null) {
tree.setSelection(item);
tree.showSelection();
}
}
checkAmountOfEntries(start, System.currentTimeMillis());
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
if (ts != null)
ts.setFinished(true);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "refresherror", e));
}
}
}
;
final WorkerSWTExecuter workerThread = new WorkerSWTExecuter(false, getID() + "-SetDataToTableThread");
if (getConfiguration().getProperty(AbstractTableApplication.CFG_SHOW_REFRESH_POPUP, "true").equalsIgnoreCase("true")) {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "refreshprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
Thread t = new Thread() {
public void run() {
// preload data
try {
m_controller.getElementArray();
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
};
t.setName("JAM-" + getID() + "#Preloader-Thread-(non-deamon)");
t.start();
Object repository = m_controller.getRepository();
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
if (repository instanceof ITracker) {
String msg = getI18nManager().getString(getNamespace(), "tracking", "label", getLanguage());
int leftover = Math.max(0, (((ITracker) repository).getTotal() - ((ITracker) repository).getCurrent()));
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(leftover));
progressMonitor.subTask(msg);
}
} while (t.isAlive());
workerThread.start();
while (!ts.isFinished()) {
try {
progressMonitor.worked(1);
Thread.sleep(100);
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
workerThread.execute();
}
// refresh status line
String message = m_controller.countElements() + getI18nManager().getString(getNamespace(), "items", "label", getLanguage());
if (fm != null) {
IFilter[] f = fm.getFiltersFromString(getConfiguration().getProperty(CFG_FILTER, ""));
if (f != null && f.length > 0) {
message += getI18nManager().getString(getNamespace(), "items_filtered", "label", getLanguage());
}
getStatusLineManager().setMessage(message);
}
}
}.start();
}
use of de.janrufmonitor.repository.imexport.ITracker in project janrufmonitor by tbrandt77.
the class AbstractTableApplication method updateViews.
public synchronized void updateViews(Object[] controllerdata, boolean reload) {
// refresh controll data
refreshController(reload);
if (controllerdata != null)
this.m_controller.generateElementArray(controllerdata);
final IFilterManager fm = this.getFilterManager();
if (fm != null && this.getConfiguration().getProperty(CFG_ENABLE_FILTER_VIEW, "true").equalsIgnoreCase("true")) {
IFilter[] f = fm.getFiltersFromString(this.getConfiguration().getProperty(CFG_FILTER, ""));
String activeFilter = this.getFilterLabel(fm, f);
// get all defined Filters from configuration
List l = new ArrayList();
l.add(new IFilter[0]);
IFilterManager jfm = getFilterManager();
Properties c = this.getConfiguration();
Iterator iter = c.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
if (key.startsWith("filter_")) {
String filter = c.getProperty(key);
l.add(jfm.getFiltersFromString(filter));
}
}
// added 2015/04/03: added runtime filters
if (jfm.hasRuntimeFilters()) {
IFilter[][] rf = jfm.getRuntimeFilters();
if (rf != null && rf.length > 0) {
for (int i = 0; i < rf.length; i++) l.add(rf[i]);
}
}
// added 2015/04/01: sort filter list
Collections.sort(l, new Comparator() {
public int compare(Object f1, Object f2) {
if (f1 != null && f2 != null && f1 instanceof IFilter[] && f2 instanceof IFilter[]) {
return getFilterLabel(getFilterManager(), ((IFilter[]) f1)).toLowerCase().compareTo(getFilterLabel(getFilterManager(), ((IFilter[]) f2)).toLowerCase());
// if (((IFilter[])f1).length==((IFilter[])f2).length) {
// return (((IFilter[])f2)[0].toString().compareTo(((IFilter[])f1)[0].toString()));
// }
// if (((IFilter[])f1).length<((IFilter[])f2).length) return -1;
// return 1;
}
return 0;
}
});
String[] filters = new String[l.size()];
int select = -1;
String filterAlias = null;
for (int i = 0; i < l.size(); i++) {
// this.getFilterManager().getFiltersToLabelText((IFilter[]) l.get(i),45);
filterAlias = this.getFilterLabel(fm, (IFilter[]) l.get(i));
if (filterAlias.equalsIgnoreCase(activeFilter)) {
select = i;
}
filters[i] = filterAlias;
this.currentView.setData(filterAlias, (IFilter[]) l.get(i));
}
this.currentView.setItems(filters);
if (select == -1) {
getApplication().getConfiguration().setProperty(CFG_FILTER, fm.getFiltersToString((IFilter[]) l.get(0)));
getApplication().storeConfiguration();
select = 0;
}
this.currentView.select(select);
this.currentView.setVisibleItemCount((this.currentView.getItemCount() > 16 ? 16 : this.currentView.getItemCount()));
this.currentView.pack();
this.currentView.getParent().pack();
}
// update menu bar
if (this.getMenuBarManager() != null) {
Menu m = this.getMenuBarManager().getMenu();
this.setMenuItemStatus(m);
}
new SWTExecuter(false, getID() + "-BuildTableThread") {
protected void execute() {
final ThreadStatus ts = new ThreadStatus();
class WorkerSWTExecuter extends SWTExecuter {
public WorkerSWTExecuter(boolean sync, String name) {
super(sync, name);
}
public void execute() {
try {
Cursor c = new Cursor(((TableViewer) viewer).getTable().getDisplay(), SWT.CURSOR_WAIT);
Table table = ((TableViewer) viewer).getTable();
AbstractMenuBuilder mb = getMenuBuilder();
if (mb != null)
table.setMenu(mb.createPopupMenu(table));
table.getShell().setCursor(c);
long start = System.currentTimeMillis();
viewer.setInput(null);
viewer.setInput(m_controller);
// added: 2007/03/17: avoid dead lock in journal...
ts.setFinished(true);
table.setFocus();
table.setLinesVisible(getConfiguration().getProperty(CFG_SHOW_GRID, "true").equalsIgnoreCase("true"));
TableColumn[] columns = table.getColumns();
for (int i = 0; i < columns.length; i++) {
columns[i].setImage(null);
}
int sortcolumn = getOrderColumn(Integer.parseInt(getConfiguration().getProperty(CFG_ORDER, "0")));
if (sortcolumn > -1 && sortcolumn < columns.length) {
table.setSortColumn(columns[sortcolumn]);
if (getConfiguration().getProperty(CFG_DIRECTION, "false").equalsIgnoreCase("false")) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
}
// IAction action = getColoringAction();
// if (action!=null)
// action.run();
IAction action = getHightlightAction();
if (action != null)
action.run();
// set new title text...
String title_ext = getTitleExtension();
if (title_ext == null || title_ext.length() == 0)
table.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()));
else
table.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()) + " - " + title_ext);
table.getShell().setCursor(null);
c.dispose();
ts.setFinished(true);
if (lastMarkedRow > -1) {
table.setSelection(Math.min(lastMarkedRow, table.getItemCount()));
}
checkAmountOfEntries(start, System.currentTimeMillis());
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
if (ts != null)
ts.setFinished(true);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "refresherror", e));
}
}
}
;
final WorkerSWTExecuter workerThread = new WorkerSWTExecuter(false, getID() + "-SetDataToTableThread");
if (getConfiguration().getProperty(AbstractTableApplication.CFG_SHOW_REFRESH_POPUP, "true").equalsIgnoreCase("true")) {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "refreshprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
Thread t = new Thread() {
public void run() {
// preload data
try {
m_controller.getElementArray();
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
};
t.setName("JAM-" + getID() + "#Preloader-Thread-(non-deamon)");
t.start();
Object repository = m_controller.getRepository();
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
if (repository instanceof ITracker) {
String msg = getI18nManager().getString(getNamespace(), "tracking", "label", getLanguage());
int leftover = Math.max(0, (((ITracker) repository).getTotal() - ((ITracker) repository).getCurrent()));
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(leftover));
progressMonitor.subTask(msg);
}
} while (t.isAlive());
workerThread.start();
while (!ts.isFinished()) {
try {
progressMonitor.worked(1);
Thread.sleep(100);
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
workerThread.execute();
}
// refresh status line
String message = m_controller.countElements() + getI18nManager().getString(getNamespace(), "items", "label", getLanguage());
if (fm != null) {
IFilter[] f = fm.getFiltersFromString(getConfiguration().getProperty(CFG_FILTER, ""));
if (f != null && f.length > 0 && getConfiguration().getProperty(CFG_ENABLE_FILTER_VIEW, "true").equalsIgnoreCase("true")) {
message += getI18nManager().getString(getNamespace(), "items_filtered", "label", getLanguage());
}
getStatusLineManager().setMessage(message);
}
}
}.start();
}
use of de.janrufmonitor.repository.imexport.ITracker in project janrufmonitor by tbrandt77.
the class AbstractPhonesPage method createControl.
public void createControl(Composite parent) {
setTitle(this.m_i18n.getString(getNamespace(), "title", "label", this.m_language));
setDescription(this.m_i18n.getString(getNamespace(), "description", "label", this.m_language));
Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(1, false));
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
all = new Button(c, SWT.CHECK);
all.setText(this.m_i18n.getString(this.getNamespace(), "*", "label", this.m_language));
all.setSelection((this.getCallers().size() == 0 ? true : false));
Label ln = new Label(c, SWT.LEFT);
Composite select = new Composite(c, SWT.NONE);
select.setLayout(new GridLayout(3, false));
select.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ln = new Label(select, SWT.LEFT);
ln.setText(this.m_i18n.getString(this.getNamespace(), "allphones", "label", this.m_language));
ln = new Label(select, SWT.LEFT);
ln = new Label(select, SWT.LEFT);
ln.setText(this.m_i18n.getString(this.getNamespace(), "selectedphones", "label", this.m_language));
final CheckboxTableViewer call = CheckboxTableViewer.newCheckList(select, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL);
call.setLabelProvider(new CallerLabelProvider());
call.setContentProvider(new CallerContentProvider());
call.setInput(null);
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "refreshprogress", "label", m_language), IProgressMonitor.UNKNOWN);
final List callers = new ArrayList();
Thread t = new Thread() {
public void run() {
// preload data
try {
callers.addAll(getAllCallers());
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
};
t.setName("JAM-ContactsRead-Thread-(non-deamon)");
t.start();
int lastamount = -1;
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
m_currentCallerManager = CallerReaderFactory.getInstance().getCurrent();
if (m_currentCallerManager != null && m_currentCallerManager instanceof ITracker) {
int leftover = Math.max(0, (((ITracker) m_currentCallerManager).getTotal() - ((ITracker) m_currentCallerManager).getCurrent()));
if (lastamount == leftover) {
String msg = m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "working", "label", m_language);
progressMonitor.subTask(msg);
} else {
String msg = m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "tracking", "label", m_language);
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(leftover));
if (m_currentCallerManager instanceof IConfigurable) {
msg = StringUtils.replaceString(msg, "{%2}", m_i18n.getString(((IConfigurable) m_currentCallerManager).getNamespace(), "title", "label", m_language));
} else {
msg = StringUtils.replaceString(msg, "{%2}", m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "nocallermanager", "label", m_language));
}
progressMonitor.subTask(msg);
}
lastamount = leftover;
} else {
String msg = m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "notracking", "label", m_language);
if (m_currentCallerManager instanceof IConfigurable) {
msg = StringUtils.replaceString(msg, "{%1}", m_i18n.getString(((IConfigurable) m_currentCallerManager).getNamespace(), "title", "label", m_language));
} else {
msg = StringUtils.replaceString(msg, "{%1}", m_i18n.getString("ui.jface.wizards.pages.AbstractPhonesPage", "nocallermanager", "label", m_language));
}
progressMonitor.subTask(msg);
}
} while (t.isAlive());
SWTExecuter tt = new SWTExecuter("ContactsRefresh") {
protected void execute() {
call.setInput(callers);
}
};
tt.start();
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
GridData gd = new GridData(200, 200);
call.getTable().setLayoutData(gd);
Composite btns = new Composite(select, SWT.NONE);
btns.setLayout(new GridLayout(1, false));
btns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Button add = new Button(btns, SWT.PUSH);
add.setText(this.m_i18n.getString(this.getNamespace(), "add", "label", this.m_language));
final Button remove = new Button(btns, SWT.PUSH);
remove.setText(this.m_i18n.getString(this.getNamespace(), "remove", "label", this.m_language));
final CheckboxTableViewer cselect = CheckboxTableViewer.newCheckList(select, SWT.CHECK | SWT.BORDER);
cselect.setLabelProvider(new CallerLabelProvider());
cselect.setContentProvider(new CallerContentProvider());
List selected = this.getCallers();
cselect.setInput(selected);
gd = new GridData(200, 200);
cselect.getTable().setLayoutData(gd);
all.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
add.setEnabled(!all.getSelection());
remove.setEnabled(!all.getSelection());
call.setAllGrayed(all.getSelection());
cselect.setAllGrayed(all.getSelection());
}
});
add.setEnabled(!all.getSelection());
remove.setEnabled(!all.getSelection());
call.setAllGrayed(all.getSelection());
cselect.setAllGrayed(all.getSelection());
add.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Object[] checked = call.getCheckedElements();
if (checked != null && checked.length > 0) {
for (int i = 0; i < checked.length; i++) {
if (!m_selectedCallers.contains(checked[i]))
m_selectedCallers.add(checked[i]);
}
cselect.setInput(m_selectedCallers);
}
}
});
remove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Object[] checked = cselect.getCheckedElements();
if (checked != null && checked.length > 0) {
for (int i = 0; i < checked.length; i++) {
if (m_selectedCallers.contains(checked[i]))
m_selectedCallers.remove(checked[i]);
}
cselect.setInput(m_selectedCallers);
}
}
});
setPageComplete(true);
setControl(c);
}
use of de.janrufmonitor.repository.imexport.ITracker in project janrufmonitor by tbrandt77.
the class ImportAction method run.
public void run(String[] filenames) {
List ids = ImExportFactory.getInstance().getAllImporterIds(IImExporter.CALLER_MODE);
String filename = null;
for (int h = 0; h < filenames.length; h++) {
filename = filenames[h];
if (!filename.endsWith(this.m_app.getApplication().getConfiguration().getProperty(CFG_OLD_EDITOR, "cpnumber.dat"))) {
String ext = "";
for (int i = 0; i < ids.size(); i++) {
final IImExporter imp = ImExportFactory.getInstance().getImporter((String) ids.get(i));
ext = imp.getExtension();
if (ext.startsWith("*"))
ext = ext.substring(1);
if (filename.toLowerCase().endsWith(ext) && imp.getMode() == IImExporter.CALLER_MODE) {
imp.setFilename(filename);
// chedk for categorie filters
String filter = this.m_app.getApplication().getConfiguration().getProperty("filter", "");
EditorFilterManager efm = new EditorFilterManager();
final IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, "");
if (filter.length() > 0) {
String cat = null;
IFilter[] filters = efm.getFiltersFromString(filter);
for (int z = 0; z < filters.length; z++) {
if (filters[z].getType().equals(FilterType.ATTRIBUTE)) {
AttributeFilter cf = ((AttributeFilter) filters[z]);
IAttributeMap m = cf.getAttributeMap();
if (m != null && m.size() > 0) {
Iterator it = m.iterator();
IAttribute a = null;
while (it.hasNext()) {
a = (IAttribute) it.next();
if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
cat = a.getValue();
}
}
}
}
}
if (cat != null) {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
String text = this.getI18nManager().getString(this.getNamespace(), "assigncategoryconfirm", "label", this.getLanguage());
text = StringUtils.replaceString(text, "{%1}", cat);
messageBox.setMessage(text);
if (messageBox.open() == SWT.YES) {
category.setValue(cat);
}
}
}
final String f = filename;
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "importprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
ICallerList importedCallers = (ICallerList) getRuntime().getCallerFactory().createCallerList();
if (imp.getMode() == IImExporter.CALLER_MODE) {
ImportThread ti = new ImportThread((ICallerImporter) imp, (category.getValue().length() == 0 ? null : category));
Thread t = new Thread(ti);
t.start();
while (t.isAlive()) {
if (imp instanceof ITracker) {
String text = getI18nManager().getString(getNamespace(), "importprogress2", "label", getLanguage());
text = StringUtils.replaceString(text, "{%1}", Integer.toString(((ITracker) imp).getCurrent()));
text = StringUtils.replaceString(text, "{%2}", Integer.toString(((ITracker) imp).getTotal()));
progressMonitor.beginTask(text, IProgressMonitor.UNKNOWN);
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
if (ti != null) {
importedCallers = ti.getResult();
m_app.getController().addElements(importedCallers);
}
}
if (importedCallers.size() > 0) {
progressMonitor.done();
String msg = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(importedCallers.size()));
msg = StringUtils.replaceString(msg, "{%2}", f);
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Editor.NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
new SWTExecuter() {
protected void execute() {
m_app.updateViews(true);
}
}.start();
} else {
progressMonitor.done();
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getI18nManager().getString(Editor.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();
}
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
} catch (InterruptedException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
} else {
// do cpnumber.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) {
IImExporter imp = ImExportFactory.getInstance().getImporter("OldDatFileCallerImporter");
if (imp != null && (imp instanceof OldDatFileCallerImporter)) {
((OldDatFileCallerImporter) imp).setFilename(filename);
ICallerList importedCallers = ((OldDatFileCallerImporter) imp).doImport();
if (importedCallers != null) {
final String f = filename;
this.m_app.getController().addElements(importedCallers);
String msg = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(importedCallers.size()));
msg = StringUtils.replaceString(msg, "{%2}", f);
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Editor.NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
m_app.updateViews(true);
}
}
} else {
return;
}
}
}
}
Aggregations