use of org.eclipse.jface.wizard.Wizard in project core by jcryptool.
the class KeyStoreHelper method makeSymmetricKeyByWizard.
public static KeyStoreAliasNotifier makeSymmetricKeyByWizard(String keyType) {
// $NON-NLS-1$
LogUtil.logInfo("NewSymmetricKeyAction");
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Wizard wizard = new NewSymmetricKeyWizard(keyType);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.setMinimumPageSize(300, 350);
final KeyStoreAliasNotifier resultAlias = new KeyStoreAliasNotifier();
int result = dialog.open();
if (result == Window.OK) {
if (wizard instanceof INewKeyWizard) {
final INewEntryDescriptor nkd = ((INewKeyWizard) wizard).getNewEntryDescriptor();
final Integer[] argument = new Integer[1];
argument[0] = nkd.getKeyLength();
final Integer keyLen = argument[0];
// $NON-NLS-1$
LogUtil.logInfo("key strength: " + argument[0]);
Job job = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"New SecretKey Job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
// $NON-NLS-1$
monitor.beginTask("New SecretKey Task", IProgressMonitor.UNKNOWN);
try {
IMetaKeyGenerator gen = AlgorithmsXMLManager.getInstance().getSecretKeyGenerator(nkd.getAlgorithmName());
IMetaLength validKeyLengths = gen.getLengths();
// Check if entered key length is valid
boolean isValidKeyLength = true;
if (validKeyLengths != null) {
isValidKeyLength = (validKeyLengths.getDefaultLength() == keyLen) || (keyLen >= validKeyLengths.getLowerBound() && keyLen <= validKeyLengths.getUpperBound()) || (validKeyLengths.getLengths() != null && validKeyLengths.getLengths().contains(keyLen));
}
if (!isValidKeyLength) {
throw new InvalidAlgorithmParameterException("illegal key length");
}
AlgorithmParameterSpec spec = null;
if (gen.getParameterSpecClassName() != null) {
spec = Reflector.getInstance().instantiateParameterSpec(gen.getParameterSpecClassName(), argument);
}
SecretKeyGenerator generator = Registry.getSecretKeyGenerator(nkd.getAlgorithmName());
if (spec != null) {
// $NON-NLS-1$
LogUtil.logInfo("initializing generator with spec");
generator.init(spec, FlexiProviderKeystorePlugin.getSecureRandom());
} else {
generator.init(FlexiProviderKeystorePlugin.getSecureRandom());
}
SecretKey key = generator.generateKey();
INewEntryDescriptor descriptor = new NewSecretKeyDescriptor(nkd, key);
resultAlias.notifyAboutAlias(AbstractKeyStoreHandler.addSecretKeyStatic(descriptor, ((NewSecretKeyDescriptor) descriptor).getSecretKey()));
} catch (SecurityException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "SecurityException while generating a secret key", e, true);
} catch (IllegalArgumentException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "IllegalArgumentException while generating a secret key", e, true);
} catch (ClassNotFoundException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "ClassNotFoundException while generating a secret key", e, true);
} catch (NoSuchMethodException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "NoSuchMethodException while generating a secret key", e, true);
} catch (InstantiationException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "InstantiationException while generating a secret key", e, true);
} catch (IllegalAccessException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "IllegalAccessException while generating a secret key", e, true);
} catch (InvocationTargetException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "InvocationTargetException while generating a secret key", e, true);
} catch (NoSuchAlgorithmException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "NoSuchAlgorithmException while generating a secret key", e, true);
} catch (InvalidAlgorithmParameterException e) {
LogUtil.logError(FlexiProviderKeystorePlugin.PLUGIN_ID, "InvalidAlgorithmParameterException while generating a secret key", e, true);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
return family == KEYSTOREHELPER_FAMILY;
}
};
job.setPriority(Job.LONG);
job.setUser(true);
job.schedule();
}
} else {
resultAlias.notifyAboutAlias(null);
}
return resultAlias;
}
use of org.eclipse.jface.wizard.Wizard in project tmdm-studio-se by Talend.
the class MDMEditPropertyAction method doRun.
@Override
protected void doRun() {
Object obj = getSelectedObject().get(0);
if (obj instanceof IRepositoryViewObject) {
viewObject = (IRepositoryViewObject) obj;
Wizard wizard = getEditWizard(viewObject);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
if (dlg.open() == Window.OK) {
isCanceled = false;
commonViewer.refresh(obj);
} else {
isCanceled = true;
}
}
}
use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class SpoonJobDelegate method ripDBWizard.
/**
* Create a job that extracts tables & data from a database.
* <p>
* <p>
*
* 0) Select the database to rip
* <p>
* 1) Select the tables in the database to rip
* <p>
* 2) Select the database to dump to
* <p>
* 3) Select the repository directory in which it will end up
* <p>
* 4) Select a name for the new job
* <p>
* 5) Create an empty job with the selected name.
* <p>
* 6) Create 1 transformation for every selected table
* <p>
* 7) add every created transformation to the job & evaluate
* <p>
*/
public void ripDBWizard() {
final List<DatabaseMeta> databases = spoon.getActiveDatabases();
if (databases.size() == 0) {
// Nothing to do here
return;
}
final RipDatabaseWizardPage1 page1 = new RipDatabaseWizardPage1("1", databases);
final RipDatabaseWizardPage2 page2 = new RipDatabaseWizardPage2("2");
final RipDatabaseWizardPage3 page3 = new RipDatabaseWizardPage3("3", spoon.getRepository());
Wizard wizard = new Wizard() {
public boolean performFinish() {
try {
JobMeta jobMeta = ripDB(databases, page3.getJobname(), page3.getRepositoryDirectory(), page3.getDirectory(), page1.getSourceDatabase(), page1.getTargetDatabase(), page2.getSelection());
if (jobMeta == null) {
return false;
}
if (page3.getRepositoryDirectory() != null) {
spoon.saveToRepository(jobMeta, false);
} else {
spoon.saveToFile(jobMeta);
}
addJobGraph(jobMeta);
return true;
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), "Error", "An unexpected error occurred!", e);
return false;
}
}
/**
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
public boolean canFinish() {
return page3.canFinish();
}
};
wizard.addPage(page1);
wizard.addPage(page2);
wizard.addPage(page3);
WizardDialog wd = new WizardDialog(spoon.getShell(), wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 400);
wd.updateSize();
wd.open();
}
use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class Spoon method copyTableWizard.
/**
* Create a transformation that extracts tables & data from a database.
* <p>
* <p>
*
* 0) Select the database to rip
* <p>
* 1) Select the table in the database to copy
* <p>
* 2) Select the database to dump to
* <p>
* 3) Select the repository directory in which it will end up
* <p>
* 4) Select a name for the new transformation
* <p>
* 6) Create 1 transformation for the selected table
* <p>
*/
public void copyTableWizard() {
List<DatabaseMeta> databases = getActiveDatabases();
if (databases.size() == 0) {
// Nothing to do here
return;
}
final CopyTableWizardPage1 page1 = new CopyTableWizardPage1("1", databases);
final CopyTableWizardPage2 page2 = new CopyTableWizardPage2("2");
Wizard wizard = new Wizard() {
@Override
public boolean performFinish() {
return delegates.db.copyTable(page1.getSourceDatabase(), page1.getTargetDatabase(), page2.getSelection());
}
/**
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
@Override
public boolean canFinish() {
return page2.canFinish();
}
};
wizard.addPage(page1);
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 400);
wd.updateSize();
wd.open();
}
use of org.eclipse.jface.wizard.Wizard in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationMainTab method handlePropertyFileCreate.
private void handlePropertyFileCreate() {
Wizard wizard = new Wizard() {
String pageName = HibernateConsoleMessages.ConsoleConfigurationMainTab_create_property_file;
WizardNewFileCreationPage cPage = null;
@Override
public void addPages() {
StructuredSelection selection = null;
IJavaProject project = findJavaProject();
if (project != null) {
selection = new StructuredSelection(project);
} else {
selection = StructuredSelection.EMPTY;
}
cPage = new WizardNewFileCreationPage(pageName, selection);
cPage.setTitle(HibernateConsoleMessages.ConsoleConfigurationMainTab_create_hibernate_properties_file);
cPage.setDescription(HibernateConsoleMessages.ConsoleConfigurationMainTab_create_new_properties_file);
// $NON-NLS-1$
cPage.setFileName("hibernate.properties");
addPage(cPage);
}
@Override
public boolean performFinish() {
final IFile file = cPage.createNewFile();
propertyFileText.setText(file.getFullPath().toOSString());
return true;
}
};
IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
WizardDialog wdialog = new WizardDialog(win.getShell(), wizard);
wdialog.open();
}
Aggregations