Search in sources :

Example 6 with Wizard

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;
}
Also used : NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) IMetaKeyGenerator(org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaKeyGenerator) Shell(org.eclipse.swt.widgets.Shell) INewKeyWizard(org.jcryptool.crypto.keystore.descriptors.interfaces.INewKeyWizard) Job(org.eclipse.core.runtime.jobs.Job) NewSecretKeyDescriptor(org.jcryptool.crypto.keystore.descriptors.NewSecretKeyDescriptor) InvalidAlgorithmParameterException(de.flexiprovider.api.exceptions.InvalidAlgorithmParameterException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IMetaLength(org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaLength) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SecretKey(de.flexiprovider.api.keys.SecretKey) NewSymmetricKeyWizard(org.jcryptool.crypto.flexiprovider.keystore.wizards.NewSymmetricKeyWizard) SecretKeyGenerator(de.flexiprovider.api.keys.SecretKeyGenerator) NewSymmetricKeyWizard(org.jcryptool.crypto.flexiprovider.keystore.wizards.NewSymmetricKeyWizard) Wizard(org.eclipse.jface.wizard.Wizard) INewKeyWizard(org.jcryptool.crypto.keystore.descriptors.interfaces.INewKeyWizard) NewKeyPairWizard(org.jcryptool.crypto.flexiprovider.keystore.wizards.NewKeyPairWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AlgorithmParameterSpec(de.flexiprovider.api.parameters.AlgorithmParameterSpec) INewEntryDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.INewEntryDescriptor)

Example 7 with Wizard

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;
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MdmPropertiesWizard(org.talend.mdm.repository.ui.wizards.MdmPropertiesWizard) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 8 with Wizard

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();
}
Also used : RipDatabaseWizardPage3(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage3) JobMeta(org.pentaho.di.job.JobMeta) RipDatabaseWizardPage2(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage2) RipDatabaseWizardPage1(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage1) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 9 with Wizard

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();
}
Also used : CopyTableWizardPage2(org.pentaho.di.ui.spoon.wizards.CopyTableWizardPage2) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) CopyTableWizardPage1(org.pentaho.di.ui.spoon.wizards.CopyTableWizardPage1) CreateDatabaseWizard(org.pentaho.di.ui.core.database.wizard.CreateDatabaseWizard) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 10 with Wizard

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();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) WizardNewFileCreationPage(org.eclipse.ui.dialogs.WizardNewFileCreationPage) Wizard(org.eclipse.jface.wizard.Wizard) NewConfigurationWizard(org.hibernate.eclipse.console.wizards.NewConfigurationWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

Wizard (org.eclipse.jface.wizard.Wizard)40 WizardDialog (org.eclipse.jface.wizard.WizardDialog)34 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 CoreException (org.eclipse.core.runtime.CoreException)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 Path (org.eclipse.core.runtime.Path)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Shell (org.eclipse.swt.widgets.Shell)5 InvalidAlgorithmParameterException (de.flexiprovider.api.exceptions.InvalidAlgorithmParameterException)4 NoSuchAlgorithmException (de.flexiprovider.api.exceptions.NoSuchAlgorithmException)4 AlgorithmParameterSpec (de.flexiprovider.api.parameters.AlgorithmParameterSpec)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IContainer (org.eclipse.core.resources.IContainer)4 IResource (org.eclipse.core.resources.IResource)4 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)4 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 INewWizard (org.eclipse.ui.INewWizard)4