Search in sources :

Example 21 with Observer

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;
}
Also used : Observer(java.util.Observer) Observable(java.util.Observable)

Example 22 with Observer

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");
}
Also used : Observer(java.util.Observer) Observable(java.util.Observable) Test(org.junit.Test)

Example 23 with Observer

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();
            }
        }
    });
}
Also used : Observer(java.util.Observer) Observable(java.util.Observable)

Example 24 with Observer

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);
}
Also used : Observer(java.util.Observer)

Example 25 with Observer

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);
        }
    }
}
Also used : KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) Observer(java.util.Observer) IJobChangeListener(org.eclipse.core.runtime.jobs.IJobChangeListener) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) Observable(java.util.Observable)

Aggregations

Observer (java.util.Observer)36 Observable (java.util.Observable)29 Test (org.junit.Test)12 ContentQueryMap (android.content.ContentQueryMap)6 ContentResolver (android.content.ContentResolver)6 ContentValues (android.content.ContentValues)6 Cursor (android.database.Cursor)6 Handler (android.os.Handler)6 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 Map (java.util.Map)2 Properties (java.util.Properties)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)2 Job (org.eclipse.core.runtime.jobs.Job)2 ITestActor (org.getopentest.contracts.ITestActor)2 IDataObject (org.jcryptool.core.operations.dataobject.IDataObject)2 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)2 ParameterizedConstructorInstantiator (org.mockito.internal.util.reflection.FieldInitializer.ParameterizedConstructorInstantiator)2 CvsBundle (com.intellij.CvsBundle)1