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);
}
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();
}
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();
}
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);
}
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();
}
}
}
}
});
}
}
Aggregations