org.eclipse.jface.wizard.IWizardContainer Java Examples

The following examples show how to use org.eclipse.jface.wizard.IWizardContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractImportPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    final Composite importerComposite = new Composite(parent, SWT.NONE);
    importerComposite.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 0, 10, 0).create());
    importerComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    importerWidget = new TextWidget.Builder()
            .withLabel(Messages.importLabel)
            .labelAbove()
            .fill()
            .widthHint(500)
            .grabHorizontalSpace()
            .readOnly()
            .withButton(Messages.browse)
            .onClickButton(e -> openFileDialog(parent.getShell()).ifPresent(importerWidget::setText))
            .bindTo(filePathObservable)
            .withTargetToModelStrategy(fileUpdateStrategy())
            .inContext(ctx)
            .createIn(importerComposite);

    return importerComposite;
}
 
Example #2
Source File: ImportWorkspaceControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see org.bonitasoft.studio.ui.wizard.ControlSupplier#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.core.databinding.DataBindingContext)
 */
@Override
public Control createControl(Composite parent, IWizardContainer container, DataBindingContext ctx) {
    this.wizardContainer = container;
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(
            GridLayoutFactory.fillDefaults().margins(10, 10).spacing(LayoutConstants.getSpacing().x, 25).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    doCreateWorkspaceTips(mainComposite);
    doCreateFileBrowser(mainComposite, ctx);
    statusSection = createStatusSection(mainComposite);

    statusSection.setVisible(false);
    textWidget.addTextListener(SWT.Modify, e -> {
        statusSection.setVisible(textWidget.getText() != null && !textWidget.getText().isEmpty());
    });
    return mainComposite;
}
 
Example #3
Source File: DeployArtifactsHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected IStatus deployArtifacts(RepositoryAccessor repositoryAccessor,
        Collection<Artifact> artifactsToDeploy,
        Map<String, Object> deployOptions,
        IWizardContainer container) {
    MultiStatus status = new MultiStatus(ApplicationPlugin.PLUGIN_ID, 0, null, null);
    if (!checkDirtyState(container)) {
        return null;
    }
    try {
        container.run(true, true,
                performFinish(repositoryAccessor, artifactsToDeploy, deployOptions, status));
    } catch (InvocationTargetException | InterruptedException e) {
        BonitaStudioLog.error(e);
        return new Status(IStatus.ERROR, ApplicationPlugin.PLUGIN_ID, "Deploy failed",
                e.getCause() != null ? e.getCause() : e);
    }
    if (status.getSeverity() == IStatus.CANCEL) {
        openAbortDialog(Display.getDefault().getActiveShell());
    }
    return status.getSeverity() == IStatus.CANCEL ? null : status;
}
 
Example #4
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer container, DataBindingContext ctx) {
    this.wizardContainer = container;
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(
            GridLayoutFactory.fillDefaults().margins(10, 10).spacing(LayoutConstants.getSpacing().x, 25).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    final LocalResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(),
            mainComposite);
    this.errorColor = resourceManager.createColor(ColorConstants.ERROR_RGB);
    this.successColor = resourceManager.createColor(ColorConstants.SUCCESS_RGB);
    doFileLocationBrowser(mainComposite, ctx);
    doCreateAdditionalControl(mainComposite, ctx);
    doCreateFileTree(mainComposite, ctx);

    treeSection.setVisible(filePath != null);
    textWidget.addTextListener(SWT.Modify, e -> {
        treeSection.setVisible(textWidget.getText() != null && !textWidget.getText().isEmpty());
        treeSection.layout();
    });

    return mainComposite;
}
 
Example #5
Source File: ContractInputGenerationWizardTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_canFinish_return_false_when_no_data_is_defined() {
    final Pool process = aPool().havingContract(aContract()).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, contractConstraintBuilder, 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());

    assertThat(wizard.canFinish()).isFalse();
}
 
Example #6
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is the wizard on the page you want?
 *
 * @param wizard
 *            wizard
 * @param page
 *            the desired page
 * @return ICondition for verification
 */
public static ICondition isWizardOnPage(final Wizard wizard, final IWizardPage page) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            if (wizard == null || page == null) {
                return false;
            }
            final IWizardContainer container = wizard.getContainer();
            if (container == null) {
                return false;
            }
            IWizardPage currentPage = container.getCurrentPage();
            return page.equals(currentPage);
        }
    };
}
 
Example #7
Source File: FileCreator.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
public IFile createModelFile(IWizardContainer context, IPackageFragmentRoot packageFragmentRoot,
		IPackageFragment packageFragment, String typeName, boolean isXtxtUml) {
	try {
		String filename;
		StringBuilder contentBuilder = new StringBuilder();
		if (isXtxtUml) {
			filename = buildXtxtUmlModelFileContent(packageFragment, typeName, contentBuilder);
		} else {
			filename = buildJavaModelFileContent(packageFragment, typeName, contentBuilder);
		}

		if (createFile(context, packageFragmentRoot, packageFragment, contentBuilder.toString(), filename)) {
			return (IFile) resource;
		}
	} catch (Throwable e) {
		Logger.sys.error("Error while creating package/model-info file", e);
	}
	return null;
}
 
Example #8
Source File: SelectionRenamePage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    super.createControl(mainComposite, wizardContainer, ctx);
    currentShell = wizardContainer.getShell();

    ButtonWidget renameButton = new ButtonWidget.Builder()
            .alignLeft()
            .withLabel(org.bonitasoft.studio.ui.i18n.Messages.rename)
            .onClick(this::rename)
            .createIn(mainComposite);
    renameButton.disable();

    tableViewer.addSelectionChangedListener(e -> {
        if (getSelection().count() == 1
                && !Objects.equals(getSelection().findFirst().get().getName(), unRenamableFile.orElse(""))) {
            renameButton.enable();
        } else {
            renameButton.disable();
        }
    });

    return mainComposite;
}
 
Example #9
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    super.createControl(composite, wizardContainer, ctx);
    Composite importComposite = createImportComposite(composite);
    filePathObservable.addValueChangeListener(e -> parseInput());
    ctx.bindValue(WidgetProperties.visible().observe(importComposite), new ComputedValue<Boolean>() {

        @Override
        protected Boolean calculate() {
            return filePathObservable.getValue() != null;
        }
    });

    ctx.bindValue(new WritableValue(), importBdmModelObservable, // Purpose: disable on finish button when input isn't correct
            UpdateStrategyFactory.neverUpdateValueStrategy().create(),
            UpdateStrategyFactory.updateValueStrategy()
                    .withValidator(new SmartImportBdmModelValidator())
                    .create());

    return composite;
}
 
Example #10
Source File: FileCreator.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public IFile createXtxtUmlFile(IWizardContainer context, IPackageFragmentRoot packageFragmentRoot,
		IPackageFragment packageFragment, String filename) {
	try {
		StringBuilder contentBuilder = new StringBuilder();
		buildXtxtUmlFileContent(packageFragment, contentBuilder);

		if (createFile(context, packageFragmentRoot, packageFragment, contentBuilder.toString(), filename)) {
			return (IFile) resource;
		}
	} catch (Throwable e) {
		Logger.sys.error("Error while creating XtxtUML file", e);
	}

	return null;
}
 
Example #11
Source File: RealmWithDisplay.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public IWizard wizardWithContainer() {
    final IWizard wizard = mock(IWizard.class);
    final IWizardContainer wizardContainer = mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(getShell());
    when(wizard.getContainer()).thenReturn(wizardContainer);
    return wizard;
}
 
Example #12
Source File: DeployOrganizationControlSupplier.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.swtDefaults().spacing(LayoutConstants.getSpacing().x, 10).create());

    if (!orgaToDeploy.isPresent()) {
        createOrganizationViewer(mainComposite, fileStoreObservable, ctx);
    }
    createDefaultUserTextWidget(ctx, mainComposite, fileStoreObservable);
    initializeOrganizationFileStore();

    return mainComposite;
}
 
Example #13
Source File: OpenApplicationPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().create());

    TableViewer applicationsTableViewer = new TableViewer(mainComposite);
    applicationsTableViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create());
    applicationsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    applicationsTableViewer.setLabelProvider(new ApplicationFileStoreLabelProvider());
    applicationsTableViewer
            .setInput(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class).getChildren());

    ColumnViewerToolTipSupport.enableFor(applicationsTableViewer);

    ctx.bindList(ViewersObservables.observeMultiSelection(applicationsTableViewer), applicationFileStoreObservable);
    ctx.addValidationStatusProvider(new org.eclipse.core.databinding.validation.MultiValidator() {

        @Override
        protected IStatus validate() {
            return applicationFileStoreObservable.isEmpty() ? ValidationStatus.error("No selection")
                    : ValidationStatus.ok();
        }
    });

    return mainComposite;
}
 
Example #14
Source File: SelectDataWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private IWizard wizardWithContainer() {
    final IWizard wizard = mock(IWizard.class);
    final IWizardContainer wizardContainer = mock(IWizardContainer.class);
    when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
    when(wizard.getContainer()).thenReturn(wizardContainer);
    return wizard;
}
 
Example #15
Source File: LangNewProjectWizard.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
	public void setContainer(IWizardContainer wizardContainer) {
		super.setContainer(wizardContainer);
		
//		if(wizardContainer != null) {
//			WizardDialog wizardDialog = assertInstance(wizardContainer, WizardDialog.class);
//			wizardDialog.addPageChangingListener(this);
//		}
	}
 
Example #16
Source File: SelectionPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().create());

    tableViewer = createTableViewer(mainComposite);
    tableViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create());
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.setInput(getInput());
    tableViewer.addDoubleClickListener(new WizardDoubleClickListener((WizardDialog) wizardContainer));

    ColumnViewerToolTipSupport.enableFor(tableViewer);

    IObservableList<IRepositoryFileStore> multiSelection = ViewersObservables.observeMultiSelection(tableViewer);
    ctx.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            return multiSelection.isEmpty()
                    ? ValidationStatus.error("No selection")
                    : unselectableElements.isPresent()
                            && multiSelection.stream().anyMatch(unselectableElements.get()::contains)
                                    ? ValidationStatus.error("Unselectable element selected")
                                    : ValidationStatus.ok();
        }
    });

    return mainComposite;
}
 
Example #17
Source File: BirtWebProjectWizardConfigurationPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Called whenever the wizard page has changed and forces its container
 * to resize its content.
 * 
 * @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
 */
public void pageChanged( PageChangedEvent event )
{
	if ( this.wizardPage == event.getSelectedPage( ) )
	{
		// force size update
		IWizardContainer container = getContainer( );
		if ( container instanceof IWizardContainer2 )
		{
			( (IWizardContainer2) container ).updateSize( );
		}
	}
}
 
Example #18
Source File: SdkToolsControlAddDialog.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e) {
    if (rbTool.getSelection()) {
        dlgResult = Result.TOOL;
    } else if (rbSeparator.getSelection()) {
        dlgResult = Result.SEPARATOR;
    } else if (rbGroup.getSelection()) {
        dlgResult = Result.GROUP;
    }
    IWizardContainer cont = getContainer();
    if (cont != null && cont.getCurrentPage()!=null) {
        cont.updateButtons();
    }
}
 
Example #19
Source File: N4JSNewClassifierWizard.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the error message for the active wizard page.
 *
 * Note that this method has no effect if the current page doesn't support error messages.
 */
private void setErrorMessage(String message) {
	IWizardContainer container = getContainer();
	if (container != null) {
		IWizardPage currentPage = container.getCurrentPage();
		if (currentPage instanceof DialogPage) {
			((DialogPage) currentPage).setErrorMessage(message);
		}
	}
}
 
Example #20
Source File: AbapGitWizardPull.java    From ADT_Frontend with MIT License 5 votes vote down vote up
@Override
public void setContainer(IWizardContainer wizardContainer) {
	super.setContainer(wizardContainer);

	if (this.pageChangeListener == null && wizardContainer != null) {
		Assert.isLegal(wizardContainer instanceof WizardDialog, "Wizard container must be of type WizardDialog"); //$NON-NLS-1$

		this.pageChangeListener = new PageChangeListener();
		((WizardDialog) wizardContainer).addPageChangingListener(this.pageChangeListener);

	}
}
 
Example #21
Source File: AbapGitWizard.java    From ADT_Frontend with MIT License 5 votes vote down vote up
@Override
public void setContainer(IWizardContainer wizardContainer) {
	super.setContainer(wizardContainer);

	if (this.pageChangeListener == null && wizardContainer != null) {
		Assert.isLegal(wizardContainer instanceof WizardDialog, "Wizard container must be of type WizardDialog"); //$NON-NLS-1$

		this.pageChangeListener = new PageChangeListener();
		((WizardDialog) wizardContainer).addPageChangingListener(this.pageChangeListener);
	}
}
 
Example #22
Source File: DeployArtifactsHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private boolean checkDirtyState(IWizardContainer container) {
    if (PlatformUI.isWorkbenchRunning()
            && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
            && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
        List<IEditorPart> dirtyEditors = Arrays
                .asList(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences())
                .stream()
                .map(ref -> ref.getEditor(false))
                .filter(editorPart -> editorPart != null)
                .filter(IEditorPart::isDirty)
                .collect(Collectors.toList());
        if (!dirtyEditors.isEmpty()) {
            SaveStrategy strategy = saveDirtyEditors();
            if (Objects.equals(strategy, SaveStrategy.CANCEL)) {
                return false;
            } else if (Objects.equals(strategy, SaveStrategy.SAVE)) {
                try {
                    container.run(false, false, monitor -> {
                        monitor.beginTask(Messages.savingEditors, dirtyEditors.size());
                        dirtyEditors.forEach(editor -> {
                            editor.doSave(monitor);
                            monitor.worked(1);
                        });
                        monitor.done();
                    });
                } catch (InvocationTargetException | InterruptedException e) {
                    throw new RuntimeException("An error occured while saving editors", e);
                }
            }
        }
    }
    return true;
}
 
Example #23
Source File: SelectArtifactToDeployPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.INHERIT_FORCE);
    mainComposite.setLayout(GridLayoutFactory.swtDefaults()
            .create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    Composite viewerAndButtonsComposite = new Composite(mainComposite, SWT.INHERIT_FORCE);
    viewerAndButtonsComposite.setLayout(
            GridLayoutFactory.fillDefaults().numColumns(2).spacing(LayoutConstants.getSpacing().x, 1).create());
    viewerAndButtonsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    new Label(viewerAndButtonsComposite, SWT.NONE); // column filler
    createSearchAndCollapseComposite(ctx, viewerAndButtonsComposite);
    createSelectButtonComposite(viewerAndButtonsComposite);
    createViewer(ctx, viewerAndButtonsComposite);
    createArtifactCounter(viewerAndButtonsComposite);
    createDeployOptions(ctx, viewerAndButtonsComposite);

    checkedElementsObservable = fileStoreViewer.checkedElementsObservable();
    defaultSelection();
    searchObservableValue.addValueChangeListener(e -> applySearch(e.diff.getNewValue()));
    checkedElementsObservable.addSetChangeListener(event -> {
        if (!filtering) {
            mergeSets();
            updateCleanDeployEnablement();
            updateUserProposals();
            updateEnvironmentEnablement();
        }
    });
    mergeSets();
    updateUserProposals();
    updateCleanDeployEnablement();
    updateEnvironmentEnablement();

    return mainComposite;
}
 
Example #24
Source File: ImportBosHandler.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Optional<ImportArchiveModel> onFinishOperation(ImportBosArchiveControlSupplier bosArchiveControlSupplier,
        RepositoryAccessor repositoryAccessor, IWizardContainer container) {
    return Optional.ofNullable(bosArchiveControlSupplier.getArchiveModel());
}
 
Example #25
Source File: TextFileImportWizard.java    From hop with Apache License 2.0 4 votes vote down vote up
public void setContainer( IWizardContainer wizardContainer ) {
}
 
Example #26
Source File: TextFileImportWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public IWizardContainer getContainer() {
  return null;
}
 
Example #27
Source File: TextFileImportWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void setContainer( IWizardContainer wizardContainer ) {
}
 
Example #28
Source File: TextFileImportWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public IWizardContainer getContainer() {
  return null;
}
 
Example #29
Source File: TextFileImportWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void setContainer( IWizardContainer wizardContainer ) {
}
 
Example #30
Source File: RipDatabaseWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public IWizardContainer getContainer() {
  return null;
}