Example usage for org.eclipse.jface.wizard WizardDialog setPageSize

List of usage examples for org.eclipse.jface.wizard WizardDialog setPageSize

Introduction

In this page you can find the example usage for org.eclipse.jface.wizard WizardDialog setPageSize.

Prototype

public void setPageSize(Point size) 

Source Link

Document

Sets the size of all pages.

Usage

From source file:com.htmlhifive.tools.wizard.ui.property.LibraryImportPropertyPage.java

License:Apache License

/**
 * {@inheritDoc}/*from   ww  w.ja  v  a 2s .  c o  m*/
 * 
 * @see org.eclipse.jface.preference.PreferencePage#performOk()
 */
@Override
public boolean performOk() {

    logger.log(Messages.TR0021, getClass().getName(), "performOk");

    if (!getApplyButton().isEnabled()) { // ?.
        return true;
    }

    // ????????.
    boolean needConfirmDialog = false;
    for (LibraryNode libraryNode : H5WizardPlugin.getInstance().getSelectedLibrarySet()) {
        if (libraryNode.isNeedConfirmDialog()) {
            needConfirmDialog = true;
        }
    }

    // ?.
    if (needConfirmDialog) {
        WizardDialog confirmLicenseWizardDialog = new WizardDialog(getShell(), new ConfirmLicenseWizard());
        confirmLicenseWizardDialog.setPageSize(getShell().getSize()); // ????.
        int ret = confirmLicenseWizardDialog.open();
        if (ret == SWT.ERROR) {
            // .
            return false;
        }
    }

    // ?.
    final ResultStatus logger = new ResultStatus();

    try {
        // .
        final IRunnableWithProgress downloadRunnable = getDownloadRunnnable(logger);

        ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        dialog.run(false, false, downloadRunnable);

    } catch (InvocationTargetException e) {
        final Throwable ex = e.getTargetException();

        H5LogUtils.putLog(ex, Messages.SE0025);

    } catch (InterruptedException e) {
        logger.setInterrupted(true);
        // We were cancelled...
        //removeProject(logger);

        return false;
    } finally {
        // ?.
        logger.showDialog(Messages.PI0138);

        // ??(??).
        container.refreshTreeLibrary(false, true);
        // SE0103=INFO,?????
        logger.log(Messages.SE0103);
    }

    return logger.isSuccess();
}

From source file:org.dawb.workbench.ui.data.PlotDataComponent.java

License:Open Source License

/**
 * Puts actions on right click menu and in action bar.
 * @param bars/*from   w  w w  .jav  a 2  s.  c  o  m*/
 */
private void createActions(final IActionBars bars) {

    final MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    dataViewer.getControl().setMenu(menuManager.createContextMenu(dataViewer.getControl()));

    final List<Object> rightClickActions = new ArrayList<Object>(11);
    createDimensionalActions(rightClickActions, false);

    PlotDataComponent.this.dataReduction = new Action("Data reduction...",
            Activator.getImageDescriptor("icons/data-reduction.png")) {
        @Override
        public void run() {
            DataReductionWizard wiz = null;
            try {
                wiz = (DataReductionWizard) EclipseUtils.openWizard(DataReductionWizard.ID, false);
            } catch (Exception e) {
                logger.error("Cannot open wizard " + DataReductionWizard.ID, e);
            }
            wiz.setData(getFile(), getSelectionNames().get(0),
                    (IDataReductionToolPage) getAbstractPlottingSystem().getActiveTool(), getSliceSet());
            wiz.setSlice(getSliceSet(), getSliceData());

            // TODO Should be non modal, it takes a while.
            WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wiz);
            wd.setTitle(wiz.getWindowTitle());
            wd.create();
            wd.getShell().setSize(650, 800);
            DialogUtils.centerDialog(Display.getDefault().getActiveShell(), wd.getShell());
            wd.open();
        }
    };

    final Action showSignal = new Action("Show only data with a 'signal' attribute", IAction.AS_CHECK_BOX) {
        public void run() {
            Activator.getDefault().getPreferenceStore().setValue(EditorConstants.SHOW_SIGNAL_ONLY, isChecked());
            refresh();
        }
    };
    showSignal.setImageDescriptor(Activator.getImageDescriptor("icons/signal.png"));
    bars.getToolBarManager().add(showSignal);
    bars.getToolBarManager().add(new Separator("signal.group"));
    showSignal.setChecked(
            Activator.getDefault().getPreferenceStore().getBoolean(EditorConstants.SHOW_SIGNAL_ONLY));

    final Action copy = new Action("Copy selected data (it can then be pasted to another data list.)",
            Activator.getImageDescriptor("icons/copy.gif")) {
        public void run() {
            final ITransferableDataObject sel = (ITransferableDataObject) ((IStructuredSelection) dataViewer
                    .getSelection()).getFirstElement();
            if (sel == null)
                return;
            transferableService.setBuffer(sel);
        }
    };
    bars.getToolBarManager().add(copy);
    copy.setEnabled(false);

    final Action paste = new Action("Paste", Activator.getImageDescriptor("icons/paste.gif")) {
        public void run() {
            ITransferableDataObject checkedObject = getCheckedObject(transferableService.getBuffer());
            if (checkedObject == null)
                return;
            data.add(checkedObject);
            checkedObject.setChecked(!checkedObject.isChecked());
            selectionChanged(checkedObject, true);
            dataViewer.refresh();

            final ISliceSystem system = (ISliceSystem) editor.getAdapter(ISliceSystem.class);
            if (system != null)
                system.refresh();
        }
    };
    bars.getToolBarManager().add(paste);
    paste.setEnabled(false);

    final Action delete = new Action("Delete", Activator.getImageDescriptor("icons/delete.gif")) {
        public void run() {
            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            if (ob != null) {
                boolean ok = data.remove(ob);
                if (ok)
                    ob.dispose();
            }
            dataViewer.refresh();
        }
    };
    bars.getToolBarManager().add(delete);
    delete.setEnabled(false);

    // Fix to http://jira.diamond.ac.uk/browse/SCI-1558
    // remove feature.
    final Action createFilter = null;
    final Action clearFilter = null;

    // Used to have ability to choose a python script to filter datasets:
    //      bars.getToolBarManager().add(new Separator());
    //      final Action createFilter = new Action("Create Filter", Activator.getImageDescriptor("icons/filter.png")) {
    //         public void run() {
    //            final Object sel           = ((StructuredSelection)dataViewer.getSelection()).getFirstElement();
    //            final ITransferableDataObject ob  = (ITransferableDataObject)sel;
    //            if (ob==null) return;
    //            chooseFilterFile(ob);
    //         }
    //      };
    //      bars.getToolBarManager().add(createFilter);
    //      createFilter.setEnabled(false);
    //      
    //      final Action clearFilter = new Action("Clear filter", Activator.getImageDescriptor("icons/delete_filter.png")) {
    //         public void run() {
    //            final Object sel           = ((StructuredSelection)dataViewer.getSelection()).getFirstElement();
    //            final ITransferableDataObject ob  = (ITransferableDataObject)sel;
    //            if (ob==null) return;
    //            clearFilterFile(ob);
    //         }
    //      };
    //      bars.getToolBarManager().add(clearFilter);
    //      clearFilter.setEnabled(false);

    final Action export = new Action("Export...", Activator.getImageDescriptor("icons/export_wiz.gif")) {
        public void run() {

            final ConvertWizard cwizard = new ConvertWizard();
            final IStructuredSelection sel = (IStructuredSelection) dataViewer.getSelection();
            cwizard.setSelectionOverride(sel.toList());
            WizardDialog dialog = new WizardDialog(container.getShell(), cwizard);
            dialog.setPageSize(new Point(400, 450));
            dialog.create();
            dialog.open();

        }
    };
    export.setEnabled(false);
    bars.getToolBarManager().add(new Separator());
    bars.getToolBarManager().add(export);
    bars.getToolBarManager().add(new Separator());

    dataViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            updateActions(copy, paste, delete, createFilter, clearFilter, export, ob, bars);
        }
    });

    final InjectPyDevConsoleAction inject = new InjectPyDevConsoleAction("Open Scripting");
    inject.setParameter(InjectPyDevConsole.CREATE_NEW_CONSOLE_PARAM, Boolean.TRUE.toString());
    inject.setParameter(InjectPyDevConsole.SETUP_SCISOFTPY_PARAM,
            InjectPyDevConsole.SetupScisoftpy.ALWAYS.toString());
    inject.setParameter(InjectPyDevConsole.VIEW_NAME_PARAM, editor.getTitle());

    menuManager.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {

            if (staggerSupported) {
                updatePlotDimenionsSelected((IAction) rightClickActions.get(1),
                        (IAction) rightClickActions.get(2), (IAction) rightClickActions.get(3),
                        getPlottingSystem().getPlotType());
            }

            for (Object action : rightClickActions) {
                if (action instanceof IAction) {
                    menuManager.add((IAction) action);
                } else if (action instanceof IContributionItem) {
                    menuManager.add((IContributionItem) action);
                }
            }

            menuManager.add(new Separator(getClass().getName() + "sep1"));
            menuManager.add(new Action("Clear") {
                @Override
                public void run() {
                    for (ITransferableDataObject co : data) {
                        co.setChecked(false);
                    }
                    selections.clear();
                    dataViewer.refresh();
                    fireSelectionListeners(Collections.<ITransferableDataObject>emptyList());
                }
            });

            menuManager.add(new Separator(getClass().getName() + ".copyPaste"));

            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            menuManager.add(copy);
            menuManager.add(paste);
            menuManager.add(delete);
            menuManager.add(new Separator(getClass().getName() + ".filter"));
            if (createFilter != null)
                menuManager.add(createFilter);
            if (clearFilter != null)
                menuManager.add(clearFilter);

            updateActions(copy, paste, delete, createFilter, clearFilter, export, ob, null);

            menuManager.add(new Separator(getClass().getName() + ".export"));
            menuManager.add(export);

            if (H5Loader.isH5(getFileName())) {
                menuManager.add(new Separator(getClass().getName() + "sep2"));

                dataReduction.setEnabled(false);
                menuManager.add(dataReduction);
            }

            menuManager.add(new Separator(getClass().getName() + ".error"));

            /**
             * What follows is adding some actions for setting errors on other plotted data sets.
             * The logic is a bit convoluted at the moment.
             */
            final ILazyDataset currentSelectedData = ob != null ? getLazyValue(ob.getVariable(), null) : null;

            if (currentSelectedData != null) {
                if (selections != null && selections.size() > 0) {
                    menuManager.add(new Action("Set '" + ob.getName() + "' as error on other plotted data...") {
                        @Override
                        public void run() {
                            final PlotDataChooseDialog dialog = new PlotDataChooseDialog(
                                    Display.getDefault().getActiveShell());
                            dialog.init(selections, ob);
                            final ITransferableDataObject plotD = dialog.choose();
                            if (plotD != null) {
                                ILazyDataset set = (ILazyDataset) getLazyValue(plotD.getVariable(), null);

                                if (set instanceof IErrorDataset) { // Data was all read in already.
                                    IErrorDataset errSet = (IErrorDataset) set;
                                    // Read plotted data into memory, so can read error data too.
                                    errSet.setError(getVariableValue(ob.getVariable(), null));

                                } else { // Set errors lazily
                                    set.setError(currentSelectedData);
                                }
                                fireSelectionListeners(selections);

                            }
                        }
                    });
                }

                final boolean isDatasetError = currentSelectedData instanceof IErrorDataset
                        && ((IErrorDataset) currentSelectedData).hasErrors();
                final boolean isLazyError = currentSelectedData.getError() != null;
                if (isDatasetError || isLazyError) {
                    menuManager.add(new Action("Clear error on '" + currentSelectedData.getName() + "'") {
                        @Override
                        public void run() {
                            currentSelectedData.setError(null);
                            fireSelectionListeners(selections);
                        }
                    });
                }
            }

            // TODO Send the dataset via the flattening service.
            if (currentSelectedData != null && currentSelectedData instanceof IDataset) {

                inject.setData(ob.getVariable(), (IDataset) currentSelectedData);
                inject.setText("Open '" + currentSelectedData.getName() + "' in scripting console");

                menuManager.add(inject);
            }

            menuManager.add(new Separator(getClass().getName() + "sep3"));
            menuManager.add(new Action("Preferences...") {
                @Override
                public void run() {
                    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            "org.edna.workbench.editors.preferencePage", null, null);
                    if (pref != null)
                        pref.open();
                }
            });

            menuManager.addMenuListener(new IMenuListener() {
                @Override
                public void menuAboutToShow(IMenuManager manager) {
                    if (dataReduction != null)
                        dataReduction.setEnabled(isDataReductionToolActive());
                }
            });
        }
    });

}

From source file:org.dawnsci.conversion.ui.ConvertWizardHandler.java

License:Open Source License

private void openWizard(final Shell shell) {
    ConvertWizard wizard = new ConvertWizard();
    wizard.init(PlatformUI.getWorkbench(), null);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.setPageSize(new Point(400, 450));
    dialog.create();/*from  ww  w. ja  va2s  .com*/
    dialog.open();
}

From source file:org.dawnsci.spectrum.ui.views.ProcessMenuManager.java

License:Open Source License

private void addWizardActions(MenuAction menuManager) {

    boolean enabled = ((IStructuredSelection) viewer.getSelection()).size() == 1
            && manager.getCachedFile() != null;
    MenuAction menu = new MenuAction("Wizards");

    IAction subtractionWizard = new Action("Subtraction wizard...") {
        public void run() {
            ISelection selection = viewer.getSelection();
            SpectrumWizard sw = new SpectrumWizard();
            List<IContain1DData> list = SpectrumUtils.get1DDataList((IStructuredSelection) selection);
            sw.addPage(new SpectrumSubtractionWizardPage(manager.getCachedFile(), list));
            sw.setData(list);//from   w w  w  .j ava 2 s.c  o  m
            WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), sw);
            wd.setPageSize(new Point(800, 400));
            if (wd.open() == WizardDialog.OK) {
                List<IContain1DData> out = sw.getOutputData();

                for (IContain1DData data : out) {
                    SpectrumInMemory mem = new SpectrumInMemory(data.getLongName(), data.getName(),
                            data.getxDataset(), data.getyDatasets(), system);
                    ProcessMenuManager.this.manager.addFile(mem);
                }
            }
        }
    };

    IAction rollingBaseline = new Action("Rolling Ball Baseline Correction...") {
        public void run() {
            ISelection selection = viewer.getSelection();
            final List<IContain1DData> list = SpectrumUtils.get1DDataList((IStructuredSelection) selection);

            int size = list.get(0).getyDatasets().get(0).getSize();

            IntegerInputDialog id = new IntegerInputDialog(Display.getDefault().getActiveShell(), 0, size,
                    size / 20, "Select ball radius (data points):");

            if (id.open() == Dialog.OK) {
                int width = id.getValue();

                final RollingBallBaselineProcess process = new RollingBallBaselineProcess();
                process.setWidth(width);

                Job processJob = new Job("process") {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        List<IContain1DData> out = process.process(list);

                        if (out == null) {
                            showMessage("Could not process dataset, operation not supported for this data!");
                            return Status.CANCEL_STATUS;
                        }

                        for (IContain1DData data : out) {
                            SpectrumInMemory mem = new SpectrumInMemory(data.getLongName(), data.getName(),
                                    data.getxDataset(), data.getyDatasets(), system);
                            ProcessMenuManager.this.manager.addFile(mem);
                        }
                        return Status.OK_STATUS;
                    }
                };

                processJob.schedule();

            }
        }
    };

    IAction cropWizard = new Action("Crop wizard...") {
        public void run() {
            ISelection selection = viewer.getSelection();
            SpectrumWizard sw = new SpectrumWizard();
            List<IContain1DData> list = SpectrumUtils.get1DDataList((IStructuredSelection) selection);
            sw.addPage(new CropWizardPage(list));
            sw.setData(list);
            WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), sw);
            wd.setPageSize(new Point(600, 400));
            if (wd.open() == WizardDialog.OK) {
                List<IContain1DData> out = sw.getOutputData();

                for (IContain1DData data : out) {
                    SpectrumInMemory mem = new SpectrumInMemory(data.getLongName(), data.getName(),
                            data.getxDataset(), data.getyDatasets(), system);
                    ProcessMenuManager.this.manager.addFile(mem);
                }
            }
        }
    };

    subtractionWizard.setEnabled(enabled);
    rollingBaseline.setEnabled(((IStructuredSelection) viewer.getSelection()).size() >= 1);

    menu.add(subtractionWizard);
    menu.add(rollingBaseline);
    menu.add(cropWizard);
    menuManager.add(menu);
}

From source file:org.eclipse.emf.ecp.emf2web.ui.handler.AbstractSchemaExportCommandHandler.java

License:Open Source License

/**
 * The default implementation opens the {@link ExportSchemaWizard} using the generation handlers returned by
 * {@link #getGenerationController()} and {@link #getGenerationExporter()}.
 *
 * @param views/*from  w w w . j a  v a2  s  .co  m*/
 *            The views which shall be exported.
 * @param event
 *            The {@link ExecutionEvent} which is given by the {@link #execute(ExecutionEvent)} method.
 * @param shell
 *            The shell for the wizard.
 * @return
 *       The return value of the {@link WizardDialog}.
 */
protected int openWizard(Collection<VView> views, ExecutionEvent event, Shell shell) {
    final List<GenerationInfo> generationInfos = getGenerationController().generate(views);
    final URI locationProposal = getLocationProposal(event);
    final ExportSchemasWizard wizard = new ExportSchemasWizard(generationInfos, getGenerationExporter(),
            locationProposal);
    final WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.setPageSize(new Point(600, 600));
    return dialog.open();
}

From source file:org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard.java

License:Open Source License

protected static int open(Shell shell, ResizableWizard wizard) {
    final WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.setPageSize(wizard.loadSize());
    return dialog.open();
}

From source file:org.jboss.tools.openshift.internal.ui.handler.DeleteResourcesHandler.java

License:Open Source License

private void openDialog(Connection connection, String namespace, Shell shell) {
    WizardDialog dialog = new OkCancelButtonWizardDialog("Delete", shell,
            new DeleteResourcesWizard(connection, namespace));
    dialog.setPageSize(DIALOG_SIZE);
    dialog.open();/*from ww  w. j a  v a2 s  .  c  o m*/
}

From source file:uk.ac.diamond.sda.exporter.ExportWizardHandler.java

License:Apache License

private void openWizard(final Shell shell) {
    WizardDialog dialog = new WizardDialog(shell, new ExportWizard());
    dialog.setPageSize(new Point(400, 300));
    dialog.create();//from   ww  w.  j  av  a  2 s .c o  m
    dialog.open();
}