Example usage for org.eclipse.jface.wizard IWizardContainer getShell

List of usage examples for org.eclipse.jface.wizard IWizardContainer getShell

Introduction

In this page you can find the example usage for org.eclipse.jface.wizard IWizardContainer getShell.

Prototype

public Shell getShell();

Source Link

Document

Returns the shell for this wizard container.

Usage

From source file:com.microsoft.tfs.client.common.ui.framework.command.WizardContainerCommandExecutor.java

License:Open Source License

/**
 * Creates a new {@link WizardContainerCommandExecutor} that uses the
 * specified {@link IWizardContainer}./*from   w  w w.ja  va 2 s.com*/
 *
 * @param wizardContainer
 *        an {@link IWizardContainer} to use (must not be <code>null</code>)
 */
public WizardContainerCommandExecutor(final IWizardContainer wizardContainer) {
    super(wizardContainer.getShell(), wizardContainer);
}

From source file:com.motorola.studio.android.model.ProjectCreationSupport.java

License:Apache License

/**
 * Run the operation in async thread.//from  w  w  w. j  av  a  2  s. c o m
 * @param op
 * @param container
 * 
 * @return true if no errors occur during the operation or false otherwise
 */
private static boolean runAsyncOperation(WorkspaceModifyOperation op, IWizardContainer container) {
    boolean created = false;

    try {
        container.run(true, true, op);
        created = true;
    } catch (InvocationTargetException ite) {
        Throwable t = ite.getTargetException();
        if (t instanceof CoreException) {
            CoreException core = (CoreException) t;
            if (core.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
                MessageDialog.openError(container.getShell(), AndroidNLS.UI_GenericErrorDialogTitle,
                        AndroidNLS.ERR_ProjectCreationSupport_CaseVariantExistsError);
            } else {
                ErrorDialog.openError(container.getShell(), AndroidNLS.UI_GenericErrorDialogTitle, null,
                        core.getStatus());
            }
        } else {
            MessageDialog.openError(container.getShell(), AndroidNLS.UI_GenericErrorDialogTitle,
                    t.getMessage());
        }
    } catch (InterruptedException e) {
        StudioLogger.error(ProjectCreationSupport.class, "Error creating project.", e); //$NON-NLS-1$
    }

    return created;
}

From source file:com.motorola.studio.android.wizards.buildingblocks.NewActivityMainPage.java

License:Apache License

/**
 * add samples control.//from w  w  w.j a v  a  2  s . c  o m
 * 
 * @param composite
 *            The wizard page composite
 */
@Override
protected void createSampleControls(Composite composite, int nColumns) {
    GridData data = null;

    Composite linkCompositecomposite = new Composite(composite, SWT.FILL);
    linkCompositecomposite.setFont(composite.getFont());
    GridLayout layout = new GridLayout(nColumns, false);
    linkCompositecomposite.setLayout(layout);
    data = new GridData(SWT.FILL, SWT.FILL, true, true, nColumns, 2);
    linkCompositecomposite.setLayoutData(data);

    Image image = null;
    try {
        ImageDescriptor imageDesc = ImageDescriptor.createFromURL(CodeUtilsActivator.getDefault().getBundle()
                .getEntry("icons/obj16/new_activity_template_wiz.png")); //$NON-NLS-1$
        image = imageDesc.createImage();
    } catch (Exception ex) {
        // do nothing;
    }

    CLabel imgLabelLeft = new CLabel(linkCompositecomposite, SWT.CENTER);
    data = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    imgLabelLeft.setLayoutData(data);
    imgLabelLeft.setImage(image);

    final Link templateLink = new Link(linkCompositecomposite, SWT.NONE);
    data = new GridData(SWT.LEFT, SWT.CENTER, true, true);
    templateLink.setLayoutData(data);
    templateLink.setText("<a>" + CodeUtilsNLS.UI_CreateNewActivityBasedOnTemplateLink //$NON-NLS-1$
            + "</a>"); //$NON-NLS-1$

    templateLink.addSelectionListener(new SelectionAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent event) {

            NewActivityWizard newActivityWizard = (NewActivityWizard) getWizard();
            IWizardContainer container = newActivityWizard.getContainer();

            container.getShell().setVisible(false);

            if (container instanceof WizardDialog) {

                IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry()
                        .findWizard("com.motorola.studio.android.wizards.newActivityBasedOnTemplateWizard");
                if (descriptor != null) {
                    NewActivityBasedOnTemplateWizard wizard = null;
                    try {
                        wizard = (NewActivityBasedOnTemplateWizard) descriptor.createWizard();
                        NewActivityWizard activityWizard = (NewActivityWizard) getWizard();

                        wizard.init(PlatformUI.getWorkbench(), activityWizard.getSelection());
                        WizardDialog nextWd = new WizardDialog(getShell(), wizard);
                        nextWd.setTitle(wizard.getWindowTitle());
                        nextWd.open();
                    } catch (CoreException e) {
                        StudioLogger.error(NewActivityMainPage.class,
                                "could not open new activity based on template wizard from inside new activity wizard");
                    }
                }

                WizardDialog nextWd = (WizardDialog) container;
                nextWd.close();
            }

        }

    });

    templateLink.setEnabled(true);

}

From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java

License:Open Source License

private void carefullyDisplayErrorDialog(String message) {
    if (message == null) {
        message = "Unknown error.";
    }//from  w ww  .ja va 2s  .c  om
    int errorCode = MessageDialog.ERROR;
    IWizardContainer container = getContainer();
    Shell shell = null;
    if (container != null) {
        shell = container.getShell();
    }

    // get a shell if the current one is null, we need to show the error.
    if (shell == null) {
        shell = WidgetUtils.getShell();
    }

    MessageDialog.open(errorCode, shell, getErrorDialogTitle(), "Error encountered while "
            + getExportingActionVerb() + " " + getOutputProductNameSingular() + ": " + message, SWT.SHEET);
}

From source file:net.sf.eclipsensis.installoptions.wizard.InstallOptionsWizard.java

License:Open Source License

/** (non-Javadoc)
 * Method declared on Wizard./*from  ww w  .  j a  va 2 s.c om*/
 */
@Override
public void addPages() {
    if (EclipseNSISPlugin.getDefault().isConfigured()) {
        addPage(new InstallOptionsWizardPage());
    } else {
        String error = EclipseNSISPlugin.getFormattedString("wizard.unconfigured.error", //$NON-NLS-1$
                new Object[] { getWindowTitle() });
        Common.openError(getShell(), error, InstallOptionsPlugin.getShellImage());
        EclipseNSISPlugin.getDefault().getJobScheduler().scheduleUIJob("", new IJobStatusRunnable() { //$NON-NLS-1$
            public IStatus run(IProgressMonitor monitor) {
                IWizardContainer container = getContainer();
                if (container != null) {
                    container.getShell().close();
                }
                return Status.OK_STATUS;
            }
        });
    }
}

From source file:net.sf.eclipsensis.wizard.NSISWizard.java

License:Open Source License

/**
 * Adding the page to the wizard./*from ww w. j  av a2 s. c o m*/
 */
@Override
public final void addPages() {
    if (EclipseNSISPlugin.getDefault().isConfigured()) {
        initSettings();

        addStartPage();
        addPage(new NSISWizardGeneralPage());
        addPage(new NSISWizardAttributesPage());
        addPage(new NSISWizardPresentationPage());
        addPage(new NSISWizardContentsPage());
        addPage(new NSISWizardCompletionPage());
    } else {
        String error = EclipseNSISPlugin.getFormattedString("wizard.unconfigured.error", //$NON-NLS-1$
                new Object[] { getWindowTitle() });
        Common.openError(getShell(), error, EclipseNSISPlugin.getShellImage());
        mForcedCancel = true;
        EclipseNSISPlugin.getDefault().getJobScheduler().scheduleUIJob("", new IJobStatusRunnable() { //$NON-NLS-1$
            public IStatus run(IProgressMonitor monitor) {
                IWizardContainer container = getContainer();
                if (container != null) {
                    container.getShell().close();
                }
                return Status.OK_STATUS;
            }
        });
    }
}

From source file:org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationWizardTest.java

License:Open Source License

@Test
public void should_add_a_contract_input_with_selected_mappings_on_finish() throws Exception {
    final BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee")
            .build();/*  ww w  .j a v a 2s  . c  o  m*/
    final Pool process = aPool().havingContract(aContract()).build();
    process.getData().add(data);

    final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
    when(store.getBusinessObjectByQualifiedName("org.company.Employee"))
            .thenReturn(BusinessObjectBuilder.aBO("org.company.Employee")
                    .withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
    when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
    when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG))
            .thenReturn("always");
    when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class)))
            .thenReturn(groovyViewer);
    when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
    when(groovyViewer.getDocument()).thenReturn(document);

    final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(),
            repositoryAccessor, operationBuilder, expressionBuilder, preferenceStore, sharedImages,
            dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
    wizard.addPages();
    final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
    wizard.setContainer(wizardContainer);
    wizard.createPageControls(realmWithDisplay.createComposite());
    wizard.performFinish();

    assertThat(process.getContract().getInputs()).extracting("name").contains("employeeInput");
    assertThat(process.getContract().getInputs().get(0).getInputs()).extracting("name").contains("firstName");
}

From source file:org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationWizardTest.java

License:Open Source License

@Test
public void should_not_add_script_on_finish() throws Exception {
    final BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee")
            .build();//from  w ww.ja v  a 2 s  .  com
    final Pool process = aPool().havingContract(aContract()).build();
    process.getData().add(data);

    final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
    when(store.getBusinessObjectByQualifiedName("org.company.Employee"))
            .thenReturn(BusinessObjectBuilder.aBO("org.company.Employee")
                    .withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
    when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
    when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG))
            .thenReturn("always");
    when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class)))
            .thenReturn(groovyViewer);
    when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
    when(groovyViewer.getDocument()).thenReturn(document);

    final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(),
            repositoryAccessor, operationBuilder, expressionBuilder, preferenceStore, sharedImages,
            dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
    wizard.addPages();

    final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
    wizard.setContainer(wizardContainer);
    wizard.createPageControls(realmWithDisplay.createComposite());
    wizard.getContractInputFromBusinessObjectWizardPage().disableAutoGeneration();
    wizard.performFinish();

    assertThat(process.getData().get(0).getDefaultValue()).isNull();
}

From source file:org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationWizardTest.java

License:Open Source License

@Test
public void should_add_script_on_finish() throws Exception {
    final BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee")
            .build();//from   w  ww. ja  va2s.c  om
    final Pool process = aPool().havingContract(aContract()).build();
    process.getData().add(data);

    final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
    when(store.getBusinessObjectByQualifiedName("org.company.Employee"))
            .thenReturn(BusinessObjectBuilder.aBO("org.company.Employee")
                    .withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
    when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
    when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG))
            .thenReturn("always");
    when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class),
            anyBoolean())).thenReturn(aGroovyScriptExpression().build());
    when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class)))
            .thenReturn(groovyViewer);
    when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
    when(groovyViewer.getDocument()).thenReturn(document);

    final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(),
            repositoryAccessor, operationBuilder, expressionBuilder, preferenceStore, sharedImages,
            dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
    wizard.addPages();

    final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
    wizard.setContainer(wizardContainer);
    wizard.createPageControls(realmWithDisplay.createComposite());
    wizard.performFinish();

    assertThat(process.getData().get(0).getDefaultValue()).isNotNull();
}

From source file:org.bonitasoft.studio.contract.ui.wizard.ContractInputGenerationWizardTest.java

License:Open Source License

@Test
public void should_not_add_operations_on_finish() throws Exception {
    final BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee")
            .build();//from w  w  w. j a  v a 2  s .  com
    final Task task = aTask().havingContract(aContract()).build();
    final Pool process = aPool().havingContract(aContract()).build();
    process.getElements().add(task);
    process.getData().add(data);

    final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
    when(store.getBusinessObjectByQualifiedName("org.company.Employee"))
            .thenReturn(BusinessObjectBuilder.aBO("org.company.Employee")
                    .withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
    when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
    when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG))
            .thenReturn("always");

    final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(),
            repositoryAccessor, operationBuilder, expressionBuilder, preferenceStore, sharedImages,
            dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
    wizard.addPages();

    final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
    wizard.setContainer(wizardContainer);
    wizard.createPageControls(realmWithDisplay.createComposite());
    wizard.getContractInputFromBusinessObjectWizardPage().disableAutoGeneration();
    wizard.performFinish();

    assertThat(task.getOperations().isEmpty()).isTrue();
}