use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.
the class GoogleCategoryImportAction method run.
public void run() {
GoogleContactsProxy ocp = new GoogleContactsProxy();
List subfolders = ocp.getCategories();
if (subfolders != null && subfolders.size() > 0) {
ocp.ensureEditorConfigurationCatergories(subfolders);
IAction cat = ActionRegistry.getInstance().getAction("editor_category", this.m_app);
cat.setApplication(this.m_app);
cat.run();
}
}
use of de.janrufmonitor.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.
the class AbstractMenuBuilder method addAction.
protected void addAction(List m, String id) {
if (id.equalsIgnoreCase(AbstractMenuBuilder.SEPARATOR_SIGN)) {
return;
}
IAction a = ActionRegistry.getInstance().getAction(id, this.m_app);
if (a != null) {
m.add((org.eclipse.jface.action.IAction) a);
this.m_logger.info("Added menu entry <" + id + "> to " + this.m_app.getID());
}
}
use of de.janrufmonitor.ui.jface.application.action.IAction 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.ui.jface.application.action.IAction in project janrufmonitor by tbrandt77.
the class NewEditorAction method getSubActions.
public IAction[] getSubActions() {
List localCallerManagers = getRuntime().getCallerManagerFactory().getTypedCallerManagers(ILocalRepository.class);
this.ensureWriteRepository(localCallerManagers);
IAction[] actions = new IAction[localCallerManagers.size()];
for (int i = 0; i < localCallerManagers.size(); i++) {
actions[i] = new SubAction((ILocalRepository) localCallerManagers.get(i));
}
return actions;
}
use of de.janrufmonitor.ui.jface.application.action.IAction 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();
}
Aggregations