use of java.util.Observer in project xtext-xtend by eclipse.
the class LineWrapTab method doCreatePreviewPane.
@Override
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
super.doCreatePreviewPane(composite, numColumns);
formatterPreview.moveMarginToColumn(previewLineWidth.toString());
final NumberPreference previewLineWidth = new NumberPreference(composite, numColumns / 2, fPreviewPreferences, PREF_PREVIEW_LINE_WIDTH, 0, 999, "Line width for preview");
fDefaultFocusManager.add(previewLineWidth);
previewLineWidth.addObserver(fUpdater);
previewLineWidth.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (fDialogSettings != null)
fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, fPreviewPreferences.get(PREF_PREVIEW_LINE_WIDTH));
}
});
return composite;
}
use of java.util.Observer in project tcom-poi by ai-coders.
the class ObserverTest method testObserver.
@Test
public void testObserver() {
Watched watched = new Watched();
WatcherDemo watcherDemo = new WatcherDemo();
watched.addObserver(watcherDemo);
watched.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg.toString().equals("closeWindows")) {
System.out.println("已经关闭窗口");
}
}
});
// 触发打开窗口事件,通知观察者
watched.notifyObservers("openWindows");
// 触发关闭窗口事件,通知观察者
watched.notifyObservers("closeWindows");
}
use of java.util.Observer in project osumer by mob41.
the class Queue method start.
public void start() {
runBeforeActions();
setStartTime(System.nanoTime());
downloader.download();
downloader.deleteObservers();
downloader.addObserver(new Observer() {
@Override
public void update(Observable arg0, Object arg1) {
if (downloader.getStatus() == Downloader.COMPLETED) {
runAfterActions();
}
}
});
}
use of java.util.Observer in project bugsnag-android by bugsnag.
the class NativeInterface method configureClientObservers.
/**
* Sets up observers for the NDK client
* @param client the client
*/
public static void configureClientObservers(@NonNull Client client) {
// Should only happen if the NDK library is present
try {
String className = "com.bugsnag.android.ndk.BugsnagObserver";
Class clz = Class.forName(className);
Observer observer = (Observer) clz.newInstance();
client.addObserver(observer);
} catch (ClassNotFoundException exception) {
// ignore this one, will happen if the NDK plugin is not present
Logger.info("Bugsnag NDK integration not available");
} catch (InstantiationException exception) {
Logger.warn("Failed to instantiate NDK observer", exception);
} catch (IllegalAccessException exception) {
Logger.warn("Could not access NDK observer", exception);
}
// Should make NDK components configure
client.notifyBugsnagObservers(NotifyType.ALL);
}
use of java.util.Observer in project core by jcryptool.
the class IntegratorWizardPage method makeNewKey.
protected void makeNewKey() {
Job[] preJobs = Job.getJobManager().find(KeyStoreHelper.KEYSTOREHELPER_FAMILY);
int preJobCount = preJobs.length;
KeyStoreHelper.makeSymmetricKeyByWizard(showKeyGroup).addObserver(new Observer() {
public void update(Observable o, final Object arg) {
if (arg != null) {
keyFromKeystoreGroup.getDisplay().syncExec(new Runnable() {
public void run() {
KeyStoreAlias ref = (KeyStoreAlias) arg;
setKeyForShowcase(ref);
}
});
}
}
});
Job[] jobs = Job.getJobManager().find(KeyStoreHelper.KEYSTOREHELPER_FAMILY);
if (jobs.length > preJobCount) {
createNewKeyButton.getDisplay().syncExec(new Runnable() {
public void run() {
buttonTextBeforeJobrunningMsg = createNewKeyButton.getText();
// $NON-NLS-1$
createNewKeyButton.setText(Messages.getString("IntegratorWizardPage.generatingButtonHint"));
disableControls();
}
});
Job job = jobs[jobs.length - 1];
IJobChangeListener listener = new IJobChangeListener() {
public void sleeping(IJobChangeEvent event) {
}
public void done(IJobChangeEvent event) {
createNewKeyButton.getDisplay().syncExec(new Runnable() {
public void run() {
createNewKeyButton.setText(buttonTextBeforeJobrunningMsg);
enableControls();
}
});
}
public void awake(IJobChangeEvent event) {
}
public void aboutToRun(IJobChangeEvent event) {
}
public void running(IJobChangeEvent event) {
}
public void scheduled(IJobChangeEvent event) {
}
};
if (job.getState() != Job.NONE)
job.addJobChangeListener(listener);
else {
listener.done(null);
}
}
}
Aggregations