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

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

Introduction

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

Prototype

public WizardDialog(Shell parentShell, IWizard newWizard) 

Source Link

Document

Creates a new wizard dialog for the given wizard.

Usage

From source file:Main.java

License:Open Source License

public static void main(String[] args) {
    // properties
    propertiesLoader = new PropertiesLoader();
    try {/*ww  w . j a  v  a2  s  .  c  o  m*/
        propertiesLoader.load();
    } catch (IOException e) {
        System.err.println("There was a problem with loading/creating the configuration file");
    }

    LoadingThread loadingThread = new LoadingThread(propertiesLoader);
    new Splash(loadingThread);

    // returns after loading
    view = loadingThread.getView();
    controller = loadingThread.getController();
    player = loadingThread.getPlay();

    // train som
    controller.trainSom();

    if (loadColourWizard()) {
        ColourAssociationWizard colourWizard = new ColourAssociationWizard(player, propertiesLoader);
        WizardDialog wizard = new WizardDialog(view.getShell(), colourWizard);
        wizard.setPageSize(400, 250);
        wizard.create();
        wizard.setBlockOnOpen(false);
        wizard.open();
    }

    // open window
    view.setBlockOnOpen(true);

    view.open();

    // save preferences
    try {
        propertiesLoader.save();
    } catch (IOException ioe) {
        System.err.println("There was an error saving the properties file while the program was shutting down");
    }

    player.cleanUp();
    controller.cleanUp();

    Database.cleanUp();
}

From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsDiagramEditorUtil.java

License:Open Source License

/**
 * Runs the wizard in a dialog./*  w  ww. j a  va  2s.  c o  m*/
 * 
 * @generated
 */
public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
    IDialogSettings pluginDialogSettings = ClassdiagramsDiagramEditorPlugin.getInstance().getDialogSettings();
    IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
    if (wizardDialogSettings == null) {
        wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
    }
    wizard.setDialogSettings(wizardDialogSettings);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
    dialog.open();
}

From source file:ac.soton.eventb.statemachines.diagram.part.StatemachinesDiagramEditorUtil.java

License:Open Source License

/**
 * Runs the wizard in a dialog.// ww  w .ja v a2  s. c o m
 * 
 * @generated
 */
public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
    IDialogSettings pluginDialogSettings = StatemachinesDiagramEditorPlugin.getInstance().getDialogSettings();
    IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
    if (wizardDialogSettings == null) {
        wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
    }
    wizard.setDialogSettings(wizardDialogSettings);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
    dialog.open();
}

From source file:ac.soton.fmusim.components.diagram.edit.parts.FMUComponentVariablesCompartmentEditPart.java

License:Open Source License

/**
 * @generated NOT//ww w  .  j  av  a2s  .  co m
 */
@Override
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        Object element = this.getParent();

        //Get FMUComponent's FMU File's path
        if (element instanceof FMUComponentEditPart) {
            FMUComponentEditPart editpart = (FMUComponentEditPart) element;
            FMUComponent original = (FMUComponent) editpart.resolveSemanticElement();
            ComponentsPaletteFactory cpf = new ComponentsPaletteFactory();

            EditDomain ed = editpart.getViewer().getEditDomain();

            FMUComponent comp = EcoreUtil.copy(original);

            cpf.fillPalette(ed.getPaletteViewer().getPaletteRoot(), comp);

            String path = comp.getPath();

            //Retrieve FMUComponent's ports
            List<FMUVariable> internals = new ArrayList<FMUVariable>();
            List<FMUVariable> inports = new ArrayList<FMUVariable>();
            List<FMUVariable> outports = new ArrayList<FMUVariable>();

            for (int i = 0; i < comp.getInputs().size(); i++) {
                inports.add(new FMUVariable(comp.getInputs().get(i).getName().toString()));
            }
            for (int j = 0; j < comp.getOutputs().size(); j++) {
                outports.add(new FMUVariable(comp.getOutputs().get(j).getName().toString()));
            }
            for (int k = 0; k < comp.getVariables().size(); k++) {
                internals.add(new FMUVariable(comp.getVariables().get(k).getName().toString()));
            }

            FMUVariable[] FMUInternals = internals.toArray(new FMUVariable[internals.size()]);
            FMUVariable[] FMUInports = inports.toArray(new FMUVariable[inports.size()]);
            FMUVariable[] FMUOutports = outports.toArray(new FMUVariable[outports.size()]);

            List<FMUVariable[]> checkedLists = new ArrayList<FMUVariable[]>();
            checkedLists.add(FMUInternals);
            checkedLists.add(FMUInports);
            checkedLists.add(FMUOutports);

            //Open WizardStart at page 2
            if (path != null) {
                WizardStart ws = new WizardStart();
                ws.setFilePath(path);
                WizardDialog dial = new WizardDialog(new Shell(), ws);
                dial.create();
                DisplayFMUInfo dfi = (DisplayFMUInfo) dial.getCurrentPage().getNextPage();
                dfi.setChecker(checkedLists);
                dial.showPage(dfi);
                dial.open();
            }
        }
    }
}

From source file:ac.soton.fmusim.components.diagram.part.ComponentsDiagramEditorUtil.java

License:Open Source License

/**
 * Runs the wizard in a dialog.//from w  ww .j a va2s . c om
 * 
 * @generated
 */
public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
    IDialogSettings pluginDialogSettings = ComponentsDiagramEditorPlugin.getInstance().getDialogSettings();
    IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
    if (wizardDialogSettings == null) {
        wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
    }
    wizard.setDialogSettings(wizardDialogSettings);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
    dialog.open();
}

From source file:ac.soton.fmusim.components.diagram.part.CustomAction.java

License:Open Source License

/**
 * @generated NOT/*from   w  w  w.  j  av  a  2  s . c om*/
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    StructuredSelection stselec = (StructuredSelection) selection;
    Object element = stselec.getFirstElement();

    if (element instanceof FMUComponentEditPart) {
        FMUComponentEditPart editpart = (FMUComponentEditPart) element;
        FMUComponent comp = (FMUComponent) editpart.resolveSemanticElement();
        String path = comp.getPath();
        if (path != null) {
            WizardDialog dial = new WizardDialog(new Shell(),
                    new ac.soton.fmusim.components.ui.wizardmenu.WizardStart());
            dial.open();
        }
        TransactionalEditingDomain editingDomain = editpart.getEditingDomain();
        /*org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(
              shell, editingDomain);
        loadResourceDialog.open();*/
    }
    return null;
}

From source file:ac.soton.fmusim.components.diagram.part.LoadResourceAction2.java

License:Open Source License

/**
 * @generated NOT//from w w w . j a v a 2s.  c  o m
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    StructuredSelection stselec = (StructuredSelection) selection;
    Object element = stselec.getFirstElement();

    if (element instanceof FMUComponentEditPart) {
        FMUComponentEditPart editpart = (FMUComponentEditPart) element;
        FMUComponent comp = (FMUComponent) editpart.resolveSemanticElement();
        String path = comp.getPath();
        if (path != null) {
            WizardDialog dial = new WizardDialog(new Shell(),
                    new ac.soton.fmusim.components.ui.wizardmenu.WizardStart());
            dial.open();
        }
        TransactionalEditingDomain editingDomain = editpart.getEditingDomain();
        System.out.println(path);
        /*org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(
              shell, editingDomain);
        loadResourceDialog.open();*/
    }
    return null;
}

From source file:ac.soton.fmusim.components.ui.commands.ImportComponentCommand.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event);
    Shell shell = diagramEditor.getEditorSite().getShell();

    final ComponentImportWizard wiz = new ComponentImportWizard();
    wiz.setWindowTitle("abba");
    wiz.init(PlatformUI.getWorkbench(), null);
    WizardDialog wd = new WizardDialog(shell, wiz);
    wd.create();/* w ww .j  av a2s  . c o  m*/
    Rectangle mb = shell.getMonitor().getClientArea();
    Point dpi = shell.getDisplay().getDPI();
    if (Platform.OS_MACOSX.equals(Platform.getOS())) {
        dpi = new Point(110, 110); // OSX DPI is always 72; 110 is a common value for modern LCD screens
    }
    int width = dpi.x * WIZARD_WIDTH_INCH;
    int height = dpi.y * WIZARD_HEIGHT_INCH;
    int x = mb.x + (mb.width - width) / 2;
    if (x < mb.x) {
        x = mb.x;
    }
    int y = mb.y + (mb.height - height) / 2;
    if (y < mb.y) {
        y = mb.y;
    }
    wd.getShell().setLocation(x, y);
    wd.getShell().setSize(width, height);
    wd.open();
    return null;
}

From source file:ac.soton.multisim.diagram.part.MultisimDiagramEditorUtil.java

License:Open Source License

/**
 * Runs the wizard in a dialog./*from www  . j  ava 2  s.  com*/
 * 
 * @generated
 */
public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
    IDialogSettings pluginDialogSettings = MultisimDiagramEditorPlugin.getInstance().getDialogSettings();
    IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
    if (wizardDialogSettings == null) {
        wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
    }
    wizard.setDialogSettings(wizardDialogSettings);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.create();
    dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
    dialog.open();
}

From source file:ac.soton.multisim.ui.policies.ComponentCreateCommand.java

License:Open Source License

/**
 * Imports Event-B component from a Machine via configuration wizard.
 * /*from  www .  j  ava  2 s . c  o m*/
 * @param machine
 * @return
 */
private Component importEventBComponent(Machine machine) {
    Shell shell = Display.getCurrent().getActiveShell();
    EventBImportWizard wiz = new EventBImportWizard(machine);
    wiz.init(PlatformUI.getWorkbench(), null);
    WizardDialog wd = new WizardDialog(shell, wiz);
    wd.create();

    Rectangle bounds = DisplayUtil.inchToDisplay(shell, 5, 5);
    wd.getShell().setLocation(bounds.x, bounds.y);
    wd.getShell().setSize(bounds.width, bounds.height);

    if (wd.open() != Window.OK)
        return null;

    return wiz.getComponent();
}