Search in sources :

Example 6 with Observer

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

the class AbstractAlgorithmHandler method finalizeRun.

/**
 * This method completes the algorithm action In this connection the polymorphism is taken advantage of by using an
 * abstract algorithm object which is passed as the parameter.
 *
 * Subclasses should use this method to finalize the to be implemented <i>run()</i> method.
 *
 * @param algorithm the abstract algorithm
 */
protected void finalizeRun(AbstractAlgorithm algorithm) {
    Observer dummyObserver = new Observer() {

        @Override
        public void update(Observable o, Object arg) {
        }
    };
    finalizeRun(algorithm, 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)

Example 7 with Observer

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

the class CommandsUiStartup method earlyStartup.

public void earlyStartup() {
    final IOConsole ioConsole = new IOConsole(Messages.CommandsUiStartup_consolename, null);
    ioConsole.setConsoleWidth(0);
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { ioConsole });
    CommandsUIPlugin.getDefault().setIoConsole(ioConsole);
    final CommandEvaluator evaluator = new CommandEvaluator();
    final IOConsolePromptShell monitor = new IOConsolePromptShell(ioConsole) {

        @Override
        protected void sendPrompt(final IOConsoleOutputStream o) throws IOException {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    Color prevColor = o.getColor();
                    int prevStyle = o.getFontStyle();
                    o.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
                    try {
                        o.write(PROMPT);
                    } catch (IOException e) {
                        LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
                    }
                    o.setColor(prevColor);
                    o.setFontStyle(prevStyle);
                }
            });
        }

        @Override
        protected void initializeConsole(IOConsoleOutputStream o) {
            super.initializeConsole(o);
            try {
                o.write(Messages.CommandsUiStartup_welcome + Messages.CommandsUiStartup_welcome_tip);
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
        }
    };
    Observer monitorObserver = new Observer() {

        public void update(Observable o, Object arg) {
            String line = monitor.getLine();
            String result = Messages.CommandsUiStartup_eval_error;
            try {
                result = evaluator.evaluate(line).getResult();
            } catch (ParseException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
            IOConsoleOutputStream outStream = ioConsole.newOutputStream();
            try {
                // $NON-NLS-1$
                outStream.write(result + "\n\n");
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
            try {
                outStream.close();
            } catch (IOException e) {
                LogUtil.logError(CommandsUIPlugin.PLUGIN_ID, e);
            }
        }
    };
    monitor.addObserver(monitorObserver);
    monitor.startMonitoring();
}
Also used : CommandEvaluator(org.jcryptool.commands.core.evaluator.CommandEvaluator) IOConsoleOutputStream(org.eclipse.ui.console.IOConsoleOutputStream) IOConsolePromptShell(org.jcryptool.commands.ui.eclipseconsole.console.IOConsolePromptShell) Color(org.eclipse.swt.graphics.Color) Observer(java.util.Observer) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException) IOConsole(org.eclipse.ui.console.IOConsole) Observable(java.util.Observable)

Example 8 with Observer

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

the class IntegratorWizardPage method setKeyForShowcase.

private void setKeyForShowcase(KeyStoreAlias publicKeyAlias) {
    // String oldMode = keyFromKeystoreMode;
    this.createdKeyPairAlias = publicKeyAlias;
    if (publicKeyAlias != null) {
        if (createdKeyViewer != null) {
            if (!createdKeyViewer.isDisposed()) {
                createdKeyViewer.dispose();
            }
        }
        if (isAlgorithmTypeAsymmetric()) {
            keyFromKeystoreMode = KEY_FROM_KEYSTORE_MODE_CREATED_PAIR;
            createdKeyViewer = new NewKeyPairComposite(showcaseKeyFromKeystoreComposite, publicKeyAlias);
        } else /* if(isAlgorithmTypeSymmetric()) */
        {
            keyFromKeystoreMode = KEY_FROM_KEYSTORE_MODE_CREATED_KEY;
            createdKeyViewer = new NewKeyComposite(showcaseKeyFromKeystoreComposite, publicKeyAlias);
        }
        createdKeyViewer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
        createdKeyViewer.getRemoveObserver().addObserver(new Observer() {

            public void update(Observable o, Object arg) {
                keyFromKeystoreGroup.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        setKeyForShowcase(null);
                    }
                });
            }
        });
        // if(oldMode.equals(KEY_FROM_KEYSTORE_MODE_SELECT)) {
        hideObject(normalKeyFromKeystoreComposite, true);
        hideObject(showcaseKeyFromKeystoreComposite, false);
    // }
    } else {
        keyFromKeystoreMode = KEY_FROM_KEYSTORE_MODE_SELECT;
        if (createdKeyViewer != null) {
            if (!createdKeyViewer.isDisposed()) {
                createdKeyViewer.dispose();
            }
        }
        createdKeyViewer = null;
        // if(! oldMode.equals(KEY_FROM_KEYSTORE_MODE_SELECT)) {
        hideObject(normalKeyFromKeystoreComposite, false);
        hideObject(showcaseKeyFromKeystoreComposite, true);
    // }
    }
    setAliasFromKeyPairAndCombo();
    calcAndSetPageCompletion();
}
Also used : Observer(java.util.Observer) GridData(org.eclipse.swt.layout.GridData) Observable(java.util.Observable)

Example 9 with Observer

use of java.util.Observer in project jbosstools-hibernate by jbosstools.

the class QueryParametersTest method testQueryParameter.

@Test
public void testQueryParameter() {
    QueryInputModel model = new QueryInputModel(service);
    ConsoleQueryParameter[] cqps = model.getQueryParameters();
    Assert.assertNotNull(cqps);
    QueryInputModel qpmodel = model;
    Assert.assertNotNull(qpmodel);
    class TestObserver implements Observer {

        int cnt = 0;

        public void update(Observable o, Object arg) {
            cnt++;
        }
    }
    ;
    TestObserver testObserver = new TestObserver();
    qpmodel.addObserver(testObserver);
    ConsoleQueryParameter consoleQueryParameter = new ConsoleQueryParameter(service);
    qpmodel.addParameter(consoleQueryParameter);
    Assert.assertEquals(1, testObserver.cnt);
    qpmodel.removeParameter(consoleQueryParameter);
    Assert.assertEquals(2, testObserver.cnt);
}
Also used : ConsoleQueryParameter(org.hibernate.console.ConsoleQueryParameter) Observer(java.util.Observer) Observable(java.util.Observable) QueryInputModel(org.hibernate.console.QueryInputModel) Test(org.junit.Test)

Example 10 with Observer

use of java.util.Observer in project opentest by mcdcorp.

the class AppiumTestAction method initialize.

@Override
public void initialize() {
    super.initialize();
    // test action is not yet populated.
    if (!AppiumTestAction.initialized) {
        AppiumTestAction.initialized = true;
        this.getActor().addObserver(new Observer() {

            @Override
            public void update(Observable eventSource, Object eventData) {
                if (eventSource instanceof ITestActor) {
                    if (eventData == TestActorEvents.TEST_COMPLETED) {
                        if (!AppiumHelper.getConfig().getBoolean("appium.reuseDriver", false)) {
                            AppiumHelper.discardDriver();
                        }
                    }
                }
            }
        });
    }
}
Also used : Observer(java.util.Observer) ITestActor(org.getopentest.contracts.ITestActor) 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