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

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

Introduction

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

Prototype

public Shell getShell();

Source Link

Document

Returns the shell for this wizard container.

Usage

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

License:Open Source License

/**
 * Runs the wizard in a dialog.// w  w w. ja v  a2  s .  c om
 * 
 * @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.//from   w ww  . ja  v a2s  .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.part.ComponentsDiagramEditorUtil.java

License:Open Source License

/**
 * Runs the wizard in a dialog./* ww w. j  a v a  2 s  . 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.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();/*from   www.ja  v a 2s.  c om*/
    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  w w w.ja  v  a  2s. co m
 * 
 * @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 w w  w  .j  a  v  a  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();
}

From source file:ar.com.tadp.xml.rinzo.core.actions.GenerateXMLStructureDefinitionAction.java

License:Open Source License

private void createDefinition(List<IFile> files) {
    StructuredSelection selection = new StructuredSelection(files.get(0));
    NewXMLStructureDefinitionWizard wizard = new NewXMLStructureDefinitionWizard(files);
    // Use this point to mark initial destination folder based on selected file
    wizard.init(PlatformUI.getWorkbench(), selection);
    WizardDialog dialog = new WizardDialog(/*this.viewer.getTextWidget().getShell()*/null, wizard);
    dialog.create();//from  www.j a va  2 s.  c  om
    dialog.getShell().setText("Create XML Definition");
    dialog.open();
}

From source file:ar.com.tadp.xml.rinzo.jdt.actions.GenerateJAXBParserAction.java

License:Open Source License

public void run(IAction arg0) {
    RinzoXMLEditor editor = (RinzoXMLEditor) this.getTextEditor();
    StructuredSelection selection = new StructuredSelection(editor.getEditorInputIFile());
    Collection<DocumentStructureDeclaration> definitions = editor.getModel().getSchemaDefinitions();
    Map<String, String> fileLocations = DocumentCache.getInstance().getAllLocations(definitions,
            editor.getFileName());//from w ww  .  j a v  a 2 s.c om

    NewJAXBParserWizard wizard = new NewJAXBParserWizard(fileLocations.values());
    wizard.init(PlatformUI.getWorkbench(), selection);
    WizardDialog dialog = new WizardDialog(editor.getSourceViewerEditor().getTextWidget().getShell(), wizard);
    dialog.create();
    dialog.getShell().setText("Generate Parser");
    dialog.open();
}

From source file:ch.elexis.core.ui.CoreOperationAdvisor.java

License:Open Source License

@Override
public void requestDatabaseConnectionConfiguration() {
    WizardDialog wd = new WizardDialog(UiDesk.getTopShell(), new DBConnectWizard());
    wd.create();//w  ww .j av  a 2  s  . c om
    SWTHelper.center(wd.getShell());
    wd.open();
    CoreHub.localCfg.flush();
}

From source file:ch.elexis.data.PersistentObject.java

License:Open Source License

/**
 * Connect to a database./*from   w  w  w.j  a  v a  2 s .  com*/
 * 
 * In the first place, the method checks if there is a demoDB in the Elexis base directory. If
 * found, only this database will be used. If not, connection parameters are taken from the
 * provided Settings. If there ist no database found, it will be created newly, using the
 * createDB-Script. After successful connection, the global Settings (Hub.globalCfg) are linked
 * to the database.
 * 
 * For automated testing the following rules apply:
 * 
 * The methods check whether the properties ch.elexis.* are set. If set, Elexis will open the
 * corresponding database. E.g -Dch.elexis.username=test -Dch.elexis.password=test
 * -Dch.elexis.dbUser=elexis -Dch.elexis.dbPw=elexisTest -Dch.elexis.dbFlavor=mysql
 * -Dch.elexis.dbSpec=jdbc:mysql://jenkins-service:3306/miniDB
 * 
 * If the property elexis-run-mode is set to RunFromScratch then the connected database will be
 * wiped out and initialized with default values for the mandant (007, topsecret). For mysql and
 * postgresql this will only work if the database is empty! Therefore you mus call something
 * like ""drop database miniDB; create dabase miniDB;" before starting Elexis.
 * 
 * @return true on success
 * 
 *         Verbindung mit der Datenbank herstellen. Die Verbindungsparameter werden aus den
 *         bergebenen Settings entnommen. Falls am angegebenen Ort keine Datenbank gefunden
 *         wird, wird eine neue erstellt, falls ein create-Script fr diesen Datenbanktyp unter
 *         rsc gefunden wurde. Wenn die Verbindung hergestell werden konnte, werden die global
 *         Settings mit dieser Datenbank verbunden.
 * @return true fr ok, false wenn keine Verbindung hergestellt werden konnte.
 */
public static boolean connect(final Settings cfg, final Shell loginshell) {
    dbUser = System.getProperty("ch.elexis.dbUser");
    dbPw = System.getProperty("ch.elexis.dbPw");
    String dbFlavor = System.getProperty("ch.elexis.dbFlavor");
    String dbSpec = System.getProperty("ch.elexis.dbSpec");
    if ("RunFromScratch".equals(System.getProperty("elexis-run-mode"))) {
        runningAsTest = true;
    }
    File base = new File(Hub.getBasePath());
    File demo = new File(base.getParentFile().getParent() + File.separator + "demoDB");
    log.log("Verzeichnis Demo-Datenbank via Hub.getBasePath(): " + demo.getAbsolutePath(), Log.INFOS);
    log.log("osgi.install.area: " + System.getProperty("osgi.install.area"), Log.INFOS);
    String demo2path = org.eclipse.core.runtime.Platform.getInstanceLocation().getURL().getPath() + "demoDB";
    File demo2 = new File(demo2path);
    if (demo2.exists()) {
        demo = demo2;
    }

    if (!demo.exists()) {
        URI demoName = URI.create(System.getProperty("osgi.install.area").replaceAll(" ", "%20"));
        demo = new File(demoName.getPath() + File.separator + "demoDB");
        log.log("Verzeichnis Demo-Datenbank via osgi.install.area: " + demo.getAbsolutePath(), Log.INFOS);
    }
    if (demo.exists() && demo.isDirectory()) {
        j = JdbcLink.createH2Link(demo.getAbsolutePath() + File.separator + "db");
        try {
            getConnection().connect("sa", StringTool.leer);
            return connect(getConnection());
        } catch (JdbcLinkException je) {
            ElexisStatus status = translateJdbcException(je);
            status.setMessage(status.getMessage()
                    + " Fehler mit Demo-Datenbank: Es wurde zwar ein demoDB-Verzeichnis gefunden, aber dort ist keine verwendbare Datenbank");
            throw new PersistenceException(status);
        }
    } else if (dbFlavor != null && dbFlavor.length() >= 2 && dbSpec != null && dbSpec.length() > 5
            && dbUser != null && dbPw != null) {
        log.log("Using " + dbFlavor + " " + dbSpec + " " + dbUser, Log.INFOS);
        String driver;
        if (dbFlavor.equalsIgnoreCase("mysql"))
            driver = "com.mysql.jdbc.Driver";
        else if (dbFlavor.equalsIgnoreCase("postgresql"))
            driver = "org.postgresql.Driver";
        else if (dbFlavor.equalsIgnoreCase("h2"))
            driver = "org.h2.Driver";
        else
            driver = "invalid";
        if (!driver.equalsIgnoreCase("invalid")) {
            try {
                j = new JdbcLink(driver, dbSpec, dbFlavor);
                if (getConnection().connect(dbUser, dbPw)) {
                    testJdbcLink = j;
                    return connect(getConnection());
                } else {
                    log.log("can't connect to test database" + dbSpec, Log.FATALS);
                    System.exit(-6);
                }
            } catch (Exception ex) {
                log.log(ex, "can't connect to test database" + dbSpec, Log.FATALS);
                System.exit(-7);
            }
        }
        log.log("can't connect to test database. invalid dbFlavor" + dbFlavor, Log.FATALS);
        System.exit(-7);
    } else if (runningAsTest) {
        try {
            File dbFile = File.createTempFile("elexis", "db");
            log.log("RunFromScratch test database created in " + dbFile.getAbsolutePath(), Log.INFOS);
            dbUser = "sa";
            dbPw = StringTool.leer;
            j = JdbcLink.createH2Link(dbFile.getAbsolutePath());
            if (getConnection().connect(dbUser, dbPw)) {
                testJdbcLink = j;
                return connect(getConnection());
            } else {
                log.log("can't create test database", Log.FATALS);
                System.exit(-6);
            }
        } catch (Exception ex) {
            log.log(ex, "can't create test database", Log.FATALS);
            System.exit(-7);
        }
    }

    // IPreferenceStore localstore = new SettingsPreferenceStore(cfg);
    /*
     * String driver = localstore.getString(PreferenceConstants.DB_CLASS); String connectstring
     * = localstore .getString(PreferenceConstants.DB_CONNECT);
     * 
     * String user = localstore.getString(PreferenceConstants.DB_USERNAME); String pwd =
     * localstore.getString(PreferenceConstants.DB_PWD); String typ =
     * localstore.getString(PreferenceConstants.DB_TYP);
     */
    String driver = "";
    String user = "";
    String pwd = "";
    String typ = "";
    String connectstring = "";
    Hashtable<Object, Object> hConn = null;
    String connection = Hub.getCfgVariant();
    ConfigurationScope pref = new ConfigurationScope();
    IEclipsePreferences node = pref.getNode("connection");
    String cnt = node.get(connection, null);
    if (cnt != null) {
        hConn = fold(StringTool.dePrintable(cnt));
        if (hConn != null) {
            driver = checkNull((String) hConn.get(CFG_DRIVER));
            user = checkNull((String) hConn.get(CFG_USER));
            pwd = checkNull((String) hConn.get(CFG_PWD));
            typ = checkNull((String) hConn.get(CFG_TYPE));
            connectstring = checkNull((String) hConn.get(CFG_CONNECTSTRING));
        }
    }
    log.log("Driver is " + driver, Log.INFOS);
    if (StringTool.leer.equals(driver)) {
        String provider = System.getProperty("elexis-provider");
        log.log("Provider is " + provider, Log.INFOS);
        if ((provider != null) && provider.startsWith("Medelexis")) {
            WizardDialog wd = new WizardDialog(loginshell, new DBConnectWizard());
            wd.create();
            SWTHelper.center(wd.getShell());
            wd.open();
            Hub.localCfg.flush();
            SWTHelper.showInfo("Datenbankverbindung gendert", "Bitte starten Sie Elexis erneut");
            System.exit(-1);
        } else {
            String d = PreferenceInitializer.getDefaultDBPath();
            j = JdbcLink.createH2Link(d + File.separator + "elexisdb");
            user = "sa";
            pwd = StringTool.leer;
            typ = getConnection().DBFlavor;
        }
    } else {
        j = new JdbcLink(driver, connectstring, typ);
    }
    try {
        getConnection().connect(user, pwd);
    } catch (JdbcLinkException je) {
        ElexisStatus status = translateJdbcException(je);
        status.setLogLevel(ElexisStatus.LOG_FATALS);
        throw new PersistenceException(status);
    }
    log.log("Verbunden mit " + getConnection().dbDriver() + ", " + connectstring, Log.SYNCMARK);
    return connect(getConnection());
}