use of de.janrufmonitor.service.IService in project janrufmonitor by tbrandt77.
the class Activator method execute.
public void execute() {
IMonitorListener ml = PIMRuntime.getInstance().getMonitorListener();
if (ml.isRunning()) {
ml.stop();
} else {
ml.start();
}
IService tray = this.getRuntime().getServiceFactory().getService("TrayIcon");
if (tray != null && tray instanceof TrayIcon) {
((TrayIcon) tray).setIconStateMonitorListener();
}
getRuntime().getEventBroker().register(this);
getRuntime().getEventBroker().send(this, getRuntime().getEventBroker().createEvent(IEventConst.EVENT_TYPE_APPLICATION_READY));
getRuntime().getEventBroker().unregister(this);
}
use of de.janrufmonitor.service.IService in project janrufmonitor by tbrandt77.
the class Dialog method createContents.
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
Group g = new Group(composite, SWT.SHADOW_ETCHED_IN);
g.setLayout(new GridLayout(2, false));
Label date = new Label(g, SWT.NONE);
date.setText(this.getI18nManager().getString(this.getNamespace(), "date_label", "label", this.getLanguage()) + this.getParsedDate());
Font initialFont = date.getFont();
FontData[] fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(this.getFontSize() - 3);
}
Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
date.setFont(newFont);
boolean hasCallerImage = this.hasCallerImage();
Label image = new Label(g, SWT.BORDER | SWT.RIGHT);
GridData gd = new GridData();
gd.verticalSpan = 6;
image.setVisible(false);
if (hasCallerImage) {
gd.widthHint = 92;
gd.heightHint = 110;
gd.horizontalIndent = 10;
image.setVisible(true);
image.setImage(this.getCallerImage());
}
image.setLayoutData(gd);
Label msn = new Label(g, SWT.NONE);
msn.setText(this.getI18nManager().getString(this.getNamespace(), "msn_label", "label", this.getLanguage()) + this.getParsedMsn());
initialFont = msn.getFont();
fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(this.getFontSize() - 3);
fontData[i].setStyle(SWT.BOLD);
}
newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
msn.setFont(newFont);
Label callerLabel = new Label(g, SWT.NONE);
callerLabel.setText(this.getI18nManager().getString(this.getNamespace(), "caller_label", "label", this.getLanguage()));
initialFont = callerLabel.getFont();
fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(this.getFontSize() - 3);
}
newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
callerLabel.setFont(newFont);
caller = new Label(g, SWT.WRAP);
caller.setText(this.getParsedCaller());
caller.setForeground(new Color(DisplayManager.getDefaultDisplay(), this.getColor()));
initialFont = caller.getFont();
fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(this.getFontSize());
fontData[i].setStyle(SWT.BOLD);
}
newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
caller.setFont(newFont);
caller.pack();
this.checkCallerLength(caller);
caller.pack();
// added 2008/04/08: add provider image if present
Composite numberbar = new Composite(g, SWT.NONE);
ITableCellRenderer tr = RendererRegistry.getInstance().getRenderer("ProviderLogo".toLowerCase());
Image img = null;
Label l = null;
if (tr != null && this.m_call != null && !isCliredCaller()) {
tr.updateData(this.m_call);
img = tr.renderAsImage();
}
numberbar.setLayout(new GridLayout((img != null ? 2 : 1), false));
if (img != null) {
l = new Label(numberbar, SWT.LEFT);
l.setImage(new Image(DisplayManager.getDefaultDisplay(), img.getImageData().scaledTo(32, 32)));
}
Label number = new Label(numberbar, SWT.NONE);
number.setText(this.getParsedNumber());
number.setForeground(new Color(DisplayManager.getDefaultDisplay(), this.getColor()));
initialFont = number.getFont();
fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(this.getFontSize() - 3);
fontData[i].setStyle(SWT.BOLD);
}
newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
number.setFont(newFont);
new Label(g, SWT.NONE).setText(this.getParsedCip());
// check for plugins
List plugins = this.getPlugins(this.getConfiguration().getProperty("pluginlist", ""));
Composite buttonbar = new Composite(composite, SWT.NONE);
buttonbar.setLayout(new GridLayout(Math.max(4, (plugins.size() + 2)), false));
// check for active reject service
IService rejectService = this.getRuntime().getServiceFactory().getService("Reject");
if (rejectService != null && rejectService.isEnabled()) {
reject = new Button(buttonbar, SWT.PUSH);
reject.setText(this.getI18nManager().getString(this.getNamespace(), "reject", "label", this.getLanguage()));
reject.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
reject.setEnabled(false);
IEventBroker eventBroker = getRuntime().getEventBroker();
if (getCall() != null)
getCall().setAttribute(getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
eventBroker.send(Dialog.this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, getCall()));
}
}
});
}
// dialog close manually
if (this.getShowTime() == -2) {
Button close = new Button(buttonbar, SWT.PUSH);
close.setText(this.getI18nManager().getString(this.getNamespace(), "close", "label", this.getLanguage()));
close.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
close();
}
}
});
}
// name assign is active
if (this.isAssignement() && !this.isCliredCaller()) {
Button assign = new Button(buttonbar, SWT.PUSH);
assign.setText(this.getI18nManager().getString(this.getNamespace(), "assign", "label", this.getLanguage()));
assign.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
Thread thread = new Thread() {
public void run() {
DisplayManager.getDefaultDisplay().asyncExec(new NameAssignDialog(getCaller()));
}
};
thread.setName(getID());
thread.start();
}
}
});
}
// add plugins
String classString = null;
for (int i = 0, j = plugins.size(); i < j; i++) {
classString = this.getConfiguration().getProperty((String) plugins.get(i));
if (classString != null && classString.trim().length() > 0) {
try {
Class classObject = Thread.currentThread().getContextClassLoader().loadClass(classString);
final IDialogPlugin plugin = (IDialogPlugin) classObject.newInstance();
plugin.setDialog(this);
plugin.setID((String) plugins.get(i));
if (plugin.isEnabled()) {
Button button = new Button(buttonbar, SWT.PUSH);
button.setText(plugin.getLabel());
button.pack();
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
plugin.run();
}
}
});
}
} catch (ClassNotFoundException e) {
this.m_logger.warning("Class not found: " + classString);
} catch (InstantiationException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (IllegalAccessException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
if (this.getShowTime() > 0) {
Timer aTimer = new Timer();
aTimer.schedule(new TimerTask() {
public void run() {
new SWTExecuter(getID()) {
protected void execute() {
close();
}
}.start();
}
}, (long) ((this.getShowDuration() + 1) * 1000));
}
gd = new GridData();
if (!hasCallerImage) {
gd.widthHint = Math.max(350, this.caller.getBounds().width + 10);
}
g.setLayoutData(gd);
parent.getShell().pack();
return composite;
}
use of de.janrufmonitor.service.IService in project janrufmonitor by tbrandt77.
the class ExtendedBalloonDialog method createDialog.
public synchronized void createDialog() {
Composite c = this.getContents();
prepareDialog(c, getShell());
final Color color = new Color(getShell().getDisplay(), 255, 255, 225);
// Buttons
Composite buttonBar = new Composite(c, SWT.NONE);
GridData gd = new GridData();
gd.horizontalSpan = this.m_columnCount;
// check for plugins
List plugins = this.getPlugins(this.getConfiguration().getProperty("pluginlist", ""));
GridLayout gl = new GridLayout(Math.max(5, (plugins.size() + 2)), false);
gl.marginRight = 20;
buttonBar.setLayout(gl);
buttonBar.setLayoutData(gd);
buttonBar.setBackground(color);
// check for active reject service
IService rejectService = this.getRuntime().getServiceFactory().getService("Reject");
if (rejectService != null && rejectService.isEnabled()) {
final HyperLink reject = new HyperLink(buttonBar, SWT.LEFT);
reject.setBackground(color);
reject.setText(this.getI18nManager().getString(this.getNamespace(), "reject", "label", this.getLanguage()));
reject.pack();
reject.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
reject.setEnabled(false);
reject.setText(getI18nManager().getString(getNamespace(), "rejected", "label", getLanguage()));
reject.setUnderline(color);
reject.setActiveUnderline(color);
reject.setHoverUnderline(color);
reject.pack(true);
IEventBroker eventBroker = getRuntime().getEventBroker();
if (m_call != null)
m_call.setAttribute(getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_REJECTED));
eventBroker.send(ExtendedBalloonDialog.this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLREJECTED, m_call));
}
}
});
}
if (this.isAssignement() && !this.isCliredCaller()) {
final IDialogPlugin assignPlugin = new AssignPlugin();
assignPlugin.setDialog(this);
HyperLink hl = new HyperLink(buttonBar, SWT.LEFT);
hl.setText(assignPlugin.getLabel());
hl.setBackground(color);
hl.pack();
hl.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
assignPlugin.run();
}
}
});
}
// add plugins
String classString = null;
for (int i = 0, j = plugins.size(); i < j; i++) {
classString = this.getConfiguration().getProperty((String) plugins.get(i));
if (classString != null && classString.trim().length() > 0) {
try {
Class classObject = Thread.currentThread().getContextClassLoader().loadClass(classString);
final IDialogPlugin plugin = (IDialogPlugin) classObject.newInstance();
plugin.setDialog(this);
plugin.setID((String) plugins.get(i));
if (plugin.isEnabled()) {
HyperLink hl = new HyperLink(buttonBar, SWT.LEFT);
hl.setText(plugin.getLabel());
hl.setBackground(color);
hl.pack();
hl.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
plugin.run();
}
}
});
}
} catch (ClassNotFoundException e) {
this.m_logger.warning("Class not found: " + classString);
} catch (InstantiationException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (IllegalAccessException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
color.dispose();
c.pack();
}
use of de.janrufmonitor.service.IService in project janrufmonitor by tbrandt77.
the class CommentDialog method getHandler.
private CommentCallerHandler getHandler() {
IService service = PIMRuntime.getInstance().getServiceFactory().getService("CommentService");
if (service != null) {
if (service instanceof CommentService) {
CommentService commentService = (CommentService) service;
CommentCallerHandler cch = commentService.getHandler();
return cch;
}
}
return null;
}
use of de.janrufmonitor.service.IService in project janrufmonitor by tbrandt77.
the class Refresh method run.
public void run() {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
IService srv = getRuntime().getServiceFactory().getService(SynchronizerService.ID);
if (srv != null && srv instanceof SynchronizerService && srv.isEnabled()) {
((SynchronizerService) srv).synchronize(progressMonitor);
}
}
};
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);
}
m_app.updateViews(true);
return;
}
Aggregations