/**
   * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   * @since 4.0
   */
  @Override
  public void init(final IWorkbench workbench, final IStructuredSelection selection) {

    IStructuredSelection finalSelection = selection;
    if (!ModelerUiViewUtils.workspaceHasOpenModelProjects()) {
      IProject newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

      if (newProject != null) {
        finalSelection = new StructuredSelection(newProject);
      }
    }

    if (importLicensed) {
      importTextMainPage = new ImportTextMainPage(finalSelection);
      addPage(importTextMainPage);
      //
      for (int i = 0; i < importers.length; i++) {
        addPage((IWizardPage) importers[i]);
      }
    } else {
      // Create empty page
      WizardPage page =
          new WizardPage(ImportTextWizard.class.getSimpleName(), TITLE, null) {

            @Override
            public void createControl(final Composite parent) {
              setControl(createEmptyPageControl(parent));
            }
          };
      page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
      page.setPageComplete(false);
      addPage(page);
    }
  }
Пример #2
0
  /**
   * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   * @since 4.0
   */
  @Override
  public void init(final IWorkbench workbench, final IStructuredSelection originalSelection) {

    IStructuredSelection selection = originalSelection;
    openProjectExists = ModelerUiViewUtils.workspaceHasOpenModelProjects();
    if (!openProjectExists) {
      newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

      if (newProject != null) {
        selection = new StructuredSelection(newProject);
        openProjectExists = true;
      } else {
        openProjectExists = false;
      }
    }

    if (isAllModelsSelected(selection)) {
      initialSelection = new StructuredSelection(selection.toArray());
    }
    if (selection != null && !selection.isEmpty()) {
      this.folder = ModelUtil.getContainer(selection.getFirstElement());
    }

    if (folder != null && !folderInModelProject()) {
      // Create empty page
      this.mainPage =
          new WizardPage(NewVdbWizard.class.getSimpleName(), PAGE_TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
              setControl(createEmptyPageControl(parent));
            }
          };
      this.mainPage.setMessage(NOT_MODEL_PROJECT_MSG, IMessageProvider.ERROR);
    } else {

      // Create and add page
      this.mainPage =
          new WizardPage(NewVdbWizard.class.getSimpleName(), PAGE_TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
              setControl(createPageControl(parent));
            }
          };
      this.mainPage.setMessage(INITIAL_MESSAGE);

      // If current selection not null, set folder to selection if a folder, or to containing folder
      // if not
      if (this.folder != null) {
        if (!projectValidator.validate(new Object[] {this.folder}).isOK()) {
          this.folder = null;
        }
      } else { // folder == null
        this.mainPage.setMessage(SELECT_FOLDER_MESSAGE, IMessageProvider.ERROR);
      }
    }

    this.mainPage.setPageComplete(false);
    addPage(mainPage);
  }