Search in sources :

Example 1 with IWizard

use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.

the class TSWizardDialog method hardClose.

/**
	 * 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();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWizard(org.eclipse.jface.wizard.IWizard) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with IWizard

use of org.eclipse.jface.wizard.IWizard in project meclipse by flaper87.

the class MeclipsePlugin method openWizard.

/**
	 * Stolen from
	 * http://torkildr.blogspot.com/2010/07/invoking-eclipse-wizard.html
	 * 
	 * @param id
	 */
public void openWizard(String id) {
    // First see if this is a "new wizard".
    IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(id);
    // If not check if it is an "import wizard".
    if (descriptor == null) {
        descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(id);
    }
    // Or maybe an export wizard
    if (descriptor == null) {
        descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(id);
    }
    try {
        // Then if we have a wizard, open it.
        if (descriptor != null) {
            IWizard wizard = descriptor.createWizard();
            WizardDialog wd = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
            wd.setTitle(wizard.getWindowTitle());
            wd.open();
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
Also used : IWizardDescriptor(org.eclipse.ui.wizards.IWizardDescriptor) CoreException(org.eclipse.core.runtime.CoreException) IWizard(org.eclipse.jface.wizard.IWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 3 with IWizard

use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.

the class ConversionHandler method execute.

/**
	 * the command has been executed, so extract extract the needed information from the application context.
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    String commandId = event.getCommand().getId();
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    if (currentSelection.isEmpty()) {
        return null;
    }
    if (currentSelection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
        Object object = structuredSelection.getFirstElement();
        // 通过 adapter manager 获得 conversion item
        Object adapter = Platform.getAdapterManager().getAdapter(object, IConversionItem.class);
        if (adapter instanceof IConversionItem) {
            // open the config conversion dialog
            ConverterViewModel converterViewModel = null;
            IConversionItem sourceItem = (IConversionItem) adapter;
            if (commandId.equals("net.heartsome.cat.convert.ui.commands.convertCommand")) {
                converterViewModel = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_POSITIVE);
                // 记住所选择的文件
                converterViewModel.setConversionItem(sourceItem);
                IWizard wizard = new ConversionWizard(Arrays.asList(converterViewModel), null);
                TSWizardDialog dialog = new ConversionWizardDialog(window.getShell(), wizard);
                int result = dialog.open();
                if (result == IDialogConstants.OK_ID) {
                    converterViewModel.convert();
                }
            } else {
                converterViewModel = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_REVERSE);
                converterViewModel.setConversionItem(sourceItem);
                IWizard wizard = new ReverseConversionWizard(Arrays.asList(converterViewModel), null);
                TSWizardDialog dialog = new ConversionWizardDialog(window.getShell(), wizard);
                int result = dialog.open();
                if (result == IDialogConstants.OK_ID) {
                    converterViewModel.convert();
                }
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ReverseConversionWizard(net.heartsome.cat.convert.ui.wizard.ReverseConversionWizard) ConversionWizard(net.heartsome.cat.convert.ui.wizard.ConversionWizard) IWizard(org.eclipse.jface.wizard.IWizard) ConversionWizardDialog(net.heartsome.cat.convert.ui.wizard.ConversionWizardDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ReverseConversionWizard(net.heartsome.cat.convert.ui.wizard.ReverseConversionWizard) ISelection(org.eclipse.jface.viewers.ISelection) ConverterViewModel(net.heartsome.cat.convert.ui.model.ConverterViewModel) IConversionItem(net.heartsome.cat.convert.ui.model.IConversionItem) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog)

Example 4 with IWizard

use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.

the class TSWizardDialog method finishPressed.

/**
	 * The Finish button has been pressed.
	 */
protected void finishPressed() {
    // list (to save state).
    if (wizard.performFinish()) {
        // (to allow them to save state for example)
        for (int i = 0; i < nestedWizards.size() - 1; i++) {
            ((IWizard) nestedWizards.get(i)).performFinish();
        }
        // Hard close the dialog.
        setReturnCode(OK);
        hardClose();
    }
}
Also used : IWizard(org.eclipse.jface.wizard.IWizard) Point(org.eclipse.swt.graphics.Point)

Example 5 with IWizard

use of org.eclipse.jface.wizard.IWizard in project tdi-studio-se by Talend.

the class CreateGenericConnectionAction method doRun.

@Override
protected void doRun() {
    IWizard wizard = new GenericConnWizard(PlatformUI.getWorkbench(), creation, repositoryNode, getExistingNames());
    WizardDialog wizardDialog = new GenericWizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard, new GenericWizardInternalService().getComponentService());
    if (Platform.getOS().equals(Platform.OS_LINUX)) {
        wizardDialog.setPageSize(getWizardWidth(), getWizardHeight() + 80);
    }
    wizardDialog.create();
    wizardDialog.open();
}
Also used : IWizard(org.eclipse.jface.wizard.IWizard) GenericWizardDialog(org.talend.repository.generic.ui.common.GenericWizardDialog) GenericWizardInternalService(org.talend.repository.generic.internal.service.GenericWizardInternalService) GenericWizardDialog(org.talend.repository.generic.ui.common.GenericWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) GenericConnWizard(org.talend.repository.generic.ui.GenericConnWizard)

Aggregations

IWizard (org.eclipse.jface.wizard.IWizard)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 Point (org.eclipse.swt.graphics.Point)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 TSWizardDialog (net.heartsome.cat.common.ui.wizard.TSWizardDialog)1 ConverterViewModel (net.heartsome.cat.convert.ui.model.ConverterViewModel)1 IConversionItem (net.heartsome.cat.convert.ui.model.IConversionItem)1 ConversionWizard (net.heartsome.cat.convert.ui.wizard.ConversionWizard)1 ConversionWizardDialog (net.heartsome.cat.convert.ui.wizard.ConversionWizardDialog)1 ReverseConversionWizard (net.heartsome.cat.convert.ui.wizard.ReverseConversionWizard)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 IWizardDescriptor (org.eclipse.ui.wizards.IWizardDescriptor)1 GenericWizardInternalService (org.talend.repository.generic.internal.service.GenericWizardInternalService)1 GenericConnWizard (org.talend.repository.generic.ui.GenericConnWizard)1 GenericWizardDialog (org.talend.repository.generic.ui.common.GenericWizardDialog)1