org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard#org.eclipse.jface.wizard.IWizard源码实例Demo

下面列出了org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard#org.eclipse.jface.wizard.IWizard 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: slr-toolkit   文件: ExportHandler.java
/**
	 * Tries to load the wizard for the LaTex export. If a project can be loaded, it will be opened.
	 */
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {	
		if(tryLoadingProjectFiles(event)) {
			Shell activeShell = HandlerUtil.getActiveShell(event);
			IWizard wizard = new LatexExportWizard();
			WizardDialog wizardDialog = new WizardDialog(activeShell, wizard);
			wizardDialog.open();
		}
		else {

//			String errorMessage = "No taxonomy is present. Please load a taxonomy to be able to use the LaTex export.";
//			if (!ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy().isPresent()) {
//				MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
//						errorMessage);
//				return null;
//			} else {
//
//			}	
		}
		return null;


	}
 
源代码2 项目: translationstudio8   文件: TSWizardDialog.java
/**
 * Closes this window.
 * 
 * @return <code>true</code> if the window is (or was already) closed, and
 *         <code>false</code> if it is still open
 */
private boolean hardClose() {
	// inform wizards
	for (int i = 0; i < createdWizards.size(); i++) {
		IWizard createdWizard = (IWizard) createdWizards.get(i);
		try {
			createdWizard.dispose();
		} catch (Exception e) {
			Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
			Policy.getLog().log(status);
		}
		// Remove this dialog as a parent from the managed wizard.
		// Note that we do this after calling dispose as the wizard or
		// its pages may need access to the container during
		// dispose code
		createdWizard.setContainer(null);
	}
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
	// disposing the wizards could cause the image currently set in
	// this dialog to be disposed.  A subsequent repaint event during
	// close would then fail.  To prevent this case, we null out the image.
	setTitleImage(null);
	return super.close();
}
 
源代码3 项目: translationstudio8   文件: TSWizardDialog.java
/**
 * Computes the correct dialog size for the given wizard and resizes its shell if necessary.
 * 
 * @param sizingWizard the wizard
 */
private void updateSizeForWizard(IWizard sizingWizard) {
	Point delta = new Point(0, 0);
	IWizardPage[] pages = sizingWizard.getPages();
	for (int i = 0; i < pages.length; i++) {
		// ensure the page container is large enough
		Point pageDelta = calculatePageSizeDelta(pages[i]);
		delta.x = Math.max(delta.x, pageDelta.x);
		delta.y = Math.max(delta.y, pageDelta.y);
	}
	if (delta.x > 0 || delta.y > 0) {
		// increase the size of the shell
		Shell shell = getShell();
		Point shellSize = shell.getSize();
		setShellSize(shellSize.x + delta.x, shellSize.y + delta.y);
	}
}
 
@Test
public void should_not_close_on_double_click_if_finish_fail() {
    IWizard wizard = mock(IWizard.class);
    when(wizard.canFinish()).thenReturn(true);
    when(wizard.performFinish()).thenReturn(false);

    IWizardPage currentPage = mock(IWizardPage.class);
    when(currentPage.getWizard()).thenReturn(wizard);

    WizardDialog wizardContainer = mock(WizardDialog.class);
    when(wizardContainer.getCurrentPage()).thenReturn(currentPage);

    WizardDoubleClickListener listener = new WizardDoubleClickListener(wizardContainer);

    DoubleClickEvent event = mock(DoubleClickEvent.class);
    listener.doubleClick(event);

    verify(wizardContainer, times(0)).close();
}
 
源代码5 项目: tmxeditor8   文件: TSWizardDialog.java
/**
 * Closes this window.
 * 
 * @return <code>true</code> if the window is (or was already) closed, and
 *         <code>false</code> if it is still open
 */
private boolean hardClose() {
	// inform wizards
	for (int i = 0; i < createdWizards.size(); i++) {
		IWizard createdWizard = (IWizard) createdWizards.get(i);
		try {
			createdWizard.dispose();
		} catch (Exception e) {
			Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
			Policy.getLog().log(status);
		}
		// Remove this dialog as a parent from the managed wizard.
		// Note that we do this after calling dispose as the wizard or
		// its pages may need access to the container during
		// dispose code
		createdWizard.setContainer(null);
	}
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
	// disposing the wizards could cause the image currently set in
	// this dialog to be disposed.  A subsequent repaint event during
	// close would then fail.  To prevent this case, we null out the image.
	setTitleImage(null);
	return super.close();
}
 
源代码6 项目: tmxeditor8   文件: TSWizardDialog.java
/**
 * Computes the correct dialog size for the given wizard and resizes its shell if necessary.
 * 
 * @param sizingWizard the wizard
 */
private void updateSizeForWizard(IWizard sizingWizard) {
	Point delta = new Point(0, 0);
	IWizardPage[] pages = sizingWizard.getPages();
	for (int i = 0; i < pages.length; i++) {
		// ensure the page container is large enough
		Point pageDelta = calculatePageSizeDelta(pages[i]);
		delta.x = Math.max(delta.x, pageDelta.x);
		delta.y = Math.max(delta.y, pageDelta.y);
	}
	if (delta.x > 0 || delta.y > 0) {
		// increase the size of the shell
		Shell shell = getShell();
		Point shellSize = shell.getSize();
		setShellSize(shellSize.x + delta.x, shellSize.y + delta.y);
	}
}
 
@Test
public void should_perform_finish_on_double_click() {
    IWizard wizard = mock(IWizard.class);
    when(wizard.canFinish()).thenReturn(true);
    when(wizard.performFinish()).thenReturn(true);

    IWizardPage currentPage = mock(IWizardPage.class);
    when(currentPage.getWizard()).thenReturn(wizard);

    WizardDialog wizardContainer = mock(WizardDialog.class);
    when(wizardContainer.getCurrentPage()).thenReturn(currentPage);

    WizardDoubleClickListener listener = new WizardDoubleClickListener(wizardContainer);

    DoubleClickEvent event = mock(DoubleClickEvent.class);
    listener.doubleClick(event);

    verify(wizard).performFinish();
    verify(wizardContainer).close();

}
 
源代码8 项目: corrosion   文件: TestNewCargoProjectWizard.java
private static void confirmPageState(IWizard wizard, String expectedProjectName, String expectedVCS,
		Boolean expectedBinaryState) {
	NewCargoProjectWizardPage page = (NewCargoProjectWizardPage) wizard.getPages()[0];
	assertEquals(expectedProjectName, page.getProjectName());
	assertEquals(expectedVCS, page.getVCS());
	assertEquals(expectedBinaryState, page.isBinaryTemplate());
}
 
源代码9 项目: bonita-studio   文件: ConfigurationWizardDialog.java
public ConfigurationWizardDialog(Shell parentShell, IWizard newWizard) {
    super(parentShell, newWizard);
    IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
    dialogSettings = workbenchSettings.getSection(ConfigurationWizardDialog.class.getName());
    if (dialogSettings == null) {
        dialogSettings = workbenchSettings.addNewSection(ConfigurationWizardDialog.class.getName());
    }
    isSimpleMode = dialogSettings.getBoolean(CONFIGURATION_WIZARD_DIALOG_SIMPLE_MODE);
}
 
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	Shell activeShell = HandlerUtil.getActiveShell(event);
	IWizard wizard = new CreateWorkingSetWizard();
	
	WizardDialog dialog = new WizardDialog(activeShell, wizard);
	dialog.open();	
	return null;
}
 
@Override
public Object execute( ExecutionEvent event ) throws ExecutionException
{
	Shell activeShell = HandlerUtil.getActiveShell(event);
	IWizard wizard = new AttachSourcesWizard();
	
	WizardDialog dialog = new WizardDialog(activeShell, wizard);
	dialog.open();
	
	return null;
}
 
源代码12 项目: xds-ide   文件: WizardUtils.java
public static void openWizard(String wizardId, Shell parentShell, ISelection selection) {
    // First see if this is a "new wizard".
    IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(wizardId);
    // If not check if it is an "import wizard".
    if  (descriptor == null) {
      descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(wizardId);
    }
    // Or maybe an export wizard
    if  (descriptor == null) {
      descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(wizardId);
    }
    try  {
      // Then if we have a wizard, open it.
      if  (descriptor != null) {
        IWizard wizard = descriptor.createWizard();
        if (wizard instanceof IWorkbenchWizard) {
            IStructuredSelection structuredSelection = selection instanceof IStructuredSelection?  (IStructuredSelection)selection : new StructuredSelection();
            ((IWorkbenchWizard)wizard).init(PlatformUI.getWorkbench(), structuredSelection);
            WizardDialog wd = new WizardDialog(parentShell, wizard);
            wd.setTitle(wizard.getWindowTitle());
            wd.open();
        }
        else {
            Assert.isTrue(false, "Attempt to call not IWorkbenchWizard"); //$NON-NLS-1$
        }
      }
    } catch  (CoreException e) {
      e.printStackTrace();
    }
}
 
源代码13 项目: depan   文件: NodeFilterViewPart.java
private void runCreateWizard() {
  SteppingFilter filter = filterControl.buildFilter();
  IWizard wizard = prepareWizard(resultNodes, filter.getName());
  Shell shell = getSite().getWorkbenchWindow().getShell();
  WizardDialog dialog = new WizardDialog(shell, wizard);
  dialog.open();
}
 
@Override
protected IWizard createWizard() {
	try {
		IJavaProject project= fJavaProject;
		IClasspathEntry[] entries= project.getRawClasspath();
		return new ClasspathContainerWizard(fEntry, project, entries);
	} catch (JavaModelException e) {
		String title= ActionMessages.ConfigureContainerAction_error_title;
		String message= ActionMessages.ConfigureContainerAction_error_creationfailed_message;
		ExceptionHandler.handle(e, getShell(), title, message);
	}

	return null;
}
 
/**
 * Creates a new refactoring location control.
 *
 * @param wizard
 *            the wizard
 * @param parent
 *            the parent control
 * @param key
 *            the dialog settings key
 */
public RefactoringLocationControl(final IWizard wizard, final Composite parent, final String key) {
	super(parent, SWT.NONE);
	final GridLayout gridLayout= new GridLayout(1, true);
	gridLayout.horizontalSpacing= 0;
	gridLayout.marginWidth= 0;
	setLayout(gridLayout);
	fCombo= new Combo(this, SWT.SINGLE | SWT.BORDER);
	fCombo.setLayoutData(createGridData(GridData.FILL_BOTH, 1, 0));
	Assert.isNotNull(wizard);
	Assert.isTrue(key != null && !"".equals(key)); //$NON-NLS-1$
	fWizard= wizard;
	fKey= key;
}
 
源代码16 项目: bonita-studio   文件: SelectDataWizardPageTest.java
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;
}
 
源代码17 项目: translationstudio8   文件: TSWizardDialog.java
/**
 * Creates a new wizard dialog for the given wizard.
 * 
 * @param parentShell
 *            the parent shell
 * @param newWizard
 *            the wizard this dialog is working on
 */
public TSWizardDialog(Shell parentShell, IWizard newWizard) {
	super(parentShell);
	setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
			| SWT.APPLICATION_MODAL | SWT.RESIZE | getDefaultOrientation());
	setWizard(newWizard);
	// since VAJava can't initialize an instance var with an anonymous
	// class outside a constructor we do it here:
	cancelListener = new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			cancelPressed();
		}
	};
}
 
@Override
protected ITestConfigurationListener getTestListener(final ConnectorConfiguration configuration, final IWizard wizard) {
    Connector connector = null;
    if (wizard instanceof ConnectorWizard) {
        connector = ((ConnectorWizard) wizard).getWorkingCopyConnector();
    }
    return new TestConfigurationListener(configuration, this, connector);
}
 
源代码19 项目: tmxeditor8   文件: TSWizardDialog.java
/**
 * Creates a new wizard dialog for the given wizard.
 * 
 * @param parentShell
 *            the parent shell
 * @param newWizard
 *            the wizard this dialog is working on
 */
public TSWizardDialog(Shell parentShell, IWizard newWizard) {
	super(parentShell);
	setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
			| SWT.APPLICATION_MODAL | SWT.RESIZE | getDefaultOrientation());
	setWizard(newWizard);
	// since VAJava can't initialize an instance var with an anonymous
	// class outside a constructor we do it here:
	cancelListener = new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			cancelPressed();
		}
	};
}
 
源代码20 项目: pentaho-kettle   文件: CreateDatabaseWizardPage1.java
public IWizardPage getNextPage() {
  IWizard wiz = getWizard();

  IWizardPage nextPage;
  switch ( databaseMeta.getAccessType() ) {
    case DatabaseMeta.TYPE_ACCESS_OCI:
      nextPage = wiz.getPage( "oci" ); // OCI
      break;
    case DatabaseMeta.TYPE_ACCESS_ODBC:
      nextPage = wiz.getPage( "odbc" ); // ODBC
      break;
    case DatabaseMeta.TYPE_ACCESS_PLUGIN:
      nextPage = wiz.getPage( databaseMeta.getPluginId() ); // e.g. SAPR3
      break;
    default: // Generic or Native
      if ( databaseMeta.getDatabaseInterface() instanceof GenericDatabaseMeta ) { // Generic
        nextPage = wiz.getPage( "generic" ); // generic
      } else { // Native
        nextPage = wiz.getPage( "jdbc" );
        if ( nextPage != null ) {
          // Set the port number...
          ( (CreateDatabaseWizardPageJDBC) nextPage ).setData();
        }
      }
      break;
  }

  return nextPage;
}
 
源代码21 项目: tmxeditor8   文件: TSWizardDialog.java
/**
 * Sets the wizard this dialog is currently displaying.
 * 
 * @param newWizard
 *            the wizard
 */
protected void setWizard(IWizard newWizard) {
	wizard = newWizard;
	wizard.setContainer(this);
	if (!createdWizards.contains(wizard)) {
		createdWizards.add(wizard);
		// New wizard so just add it to the end of our nested list
		nestedWizards.add(wizard);
		if (pageContainer != null) {
			// Dialog is already open
			// Allow the wizard pages to precreate their page controls
			// This allows the wizard to open to the correct size
			createPageControls();
			// Ensure the dialog is large enough for the wizard
			updateSizeForWizard(wizard);
			pageContainer.layout(true);
		}
	} else {
		// We have already seen this wizard, if it is the previous wizard
		// on the nested list then we assume we have gone back and remove
		// the last wizard from the list
		int size = nestedWizards.size();
		if (size >= 2 && nestedWizards.get(size - 2) == wizard) {
			nestedWizards.remove(size - 1);
		} else {
			// Assume we are going forward to revisit a wizard
			nestedWizards.add(wizard);
		}
	}
}
 
protected Composite doCreateControl(final Composite parent, final DataBindingContext context) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(fillDefaults().numColumns(2).equalWidth(true).create());

    diagramTree = new FilteredTree(mainComposite, SWT.MULTI | SWT.BORDER, new PatternFilter(), false);
    final TreeViewer treeViewer = diagramTree.getViewer();
    treeViewer.getTree().setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_OPEN_DIAGRAM_TREE_ID);
    diagramTree
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create());

    treeViewer.setContentProvider(
            new ObservableListTreeContentProvider(diagramListObservableFactory(), diagramTreeStructure()));
    treeViewer.setLabelProvider(new DiagramLabelProvider(new FileStoreLabelProvider()));

    final IObservableList selectionObservable = PojoObservables.observeList(this, "selectedDiagrams");
    context.bindList(ViewersObservables.observeMultiSelection(diagramTree.getViewer()),
            selectionObservable);
    context.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            return selectionObservable.isEmpty() ? ValidationStatus.error(Messages.noDiagramSelected)
                    : ValidationStatus.ok();
        }
    });
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(final DoubleClickEvent arg0) {
            final IWizard wizard = getWizard();
            if (wizard.canFinish() && wizard.performFinish() && wizard.getContainer() instanceof WizardDialog) {
                ((WizardDialog) wizard.getContainer()).close();
            }
        }
    });
    treeViewer.setInput(diagramRepositoryStore);
    treeViewer.getTree().setFocus();
    defaultSelection(selectionObservable);
    return mainComposite;
}
 
源代码23 项目: birt   文件: SaveReportAsWizardDialog.java
protected void finishPressed( )
{
	super.finishPressed( );
	IWizardPage page = getCurrentPage( );
	IWizard wizard = page.getWizard();
	this.saveAsPath = ( (SaveReportAsWizard) wizard ).getSaveAsPath();
}
 
@Override
public IWizardPage getPreviousPage() {
    if(previousPageBackup != null){
    	return previousPageBackup;
    }
	
	final IWizard wizard = getWizard();
    if(wizard != null){
        return wizard.getPreviousPage(this);
    }
    return super.getPreviousPage();
}
 
源代码25 项目: birt   文件: SaveReportAsWizardDialog.java
protected void finishPressed( )
{
	super.finishPressed( );
	IWizardPage page = getCurrentPage( );
	IWizard wizard = page.getWizard( );
	this.saveAsPath = ( (SaveReportAsWizard) wizard ).getSaveAsPath( );
}
 
public TestConnectorDefinitionWizardDialog(Shell parentShell, IWizard newWizard) {
    super(
    		parentShell, 
    		newWizard,
    		RepositoryManager.getInstance().getRepositoryStore(ConnectorConfRepositoryStore.class),
    		RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class), 
    		(IImplementationRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorImplRepositoryStore.class));
}
 
@Override
public IWizardPage getPreviousPage() {
    IWizard wizard = getWizard();
    if(wizard != null){
        return wizard.getPreviousPage(this);
    }
    return super.getPreviousPage();
}
 
public IWizardPage getNextPage() {
  IWizard wiz = getWizard();

  IWizardPage nextPage;
  if ( databaseMeta.getDatabaseInterface() instanceof OracleDatabaseMeta ) {
    nextPage = wiz.getPage( "oracle" ); // Oracle
  } else if ( databaseMeta.getDatabaseInterface() instanceof InformixDatabaseMeta ) {
    nextPage = wiz.getPage( "ifx" ); // Informix
  } else {
    nextPage = wiz.getPage( "2" ); // page 2
  }

  return nextPage;
}
 
源代码29 项目: bonita-studio   文件: ParameterWizardDialog.java
public ParameterWizardDialog(final Shell parentShell, final IWizard newWizard, final ParameterPropertySection parameterPropertySection) {
    super(parentShell, newWizard, parameterPropertySection != null);
    this.parameterPropertySection = parameterPropertySection;
    if (this.parameterPropertySection == null) {
        setTitle(Messages.editParameterWizardTitle);
    } else {
        setTitle(Messages.newParameter);
    }
}
 
源代码30 项目: CogniCrypt   文件: CogniCryptWizardDialog.java
public CogniCryptWizardDialog(final Shell parentShell, final IWizard newWizard) {
	super(parentShell, newWizard);
}