Search in sources :

Example 51 with Observable

use of java.util.Observable 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)

Example 52 with Observable

use of java.util.Observable in project core by jcryptool.

the class AbstractAlgorithmHandler method performOpenEditor.

/**
 * Tries to open the given IEditorInput in the Editor associated with the given ID. This method must be executed in
 * an async way since a Job may be used to execute the cryptographic operation.
 *
 * @param input The IEditorInput that shall be displayed
 * @param editorId The ID of the Editor that is supposed to open
 */
protected void performOpenEditor(final IEditorInput input, final String editorId) {
    Observer dummyObserver = new Observer() {

        @Override
        public void update(Observable o, Object arg) {
        }
    };
    performOpenEditor(input, editorId, dummyObserver);
}
Also used : Observer(java.util.Observer) ClassicDataObject(org.jcryptool.core.operations.dataobject.classic.ClassicDataObject) IDataObject(org.jcryptool.core.operations.dataobject.IDataObject) IClassicDataObject(org.jcryptool.core.operations.dataobject.classic.IClassicDataObject) ModernDataObject(org.jcryptool.core.operations.dataobject.modern.ModernDataObject) IModernDataObject(org.jcryptool.core.operations.dataobject.modern.IModernDataObject) Observable(java.util.Observable)

Aggregations

Observable (java.util.Observable)52 Observer (java.util.Observer)30 Test (org.junit.Test)8 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 LinkedList (java.util.LinkedList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MessagePanel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)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 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)2 WithDumpException (com.github.mob41.osumer.debug.WithDumpException)1 OsuDownloader (com.github.mob41.osumer.io.OsuDownloader)1