Search in sources :

Example 1 with ModelSelectionDialog

use of org.talend.commons.ui.swt.dialogs.ModelSelectionDialog in project tdi-studio-se by Talend.

the class SapSchemaTypeController method checkForRepositoryShema.

/**
     * If schema type is repository, display a dialog to ask the user to change to built-in mode or update the schema in
     * the repository. Return true to stop the process.
     *
     * @param button
     */
private boolean checkForRepositoryShema(Button button) {
    boolean stop = false;
    if (button.getData(NAME).equals(SCHEMA)) {
        String paramName = (String) button.getData(PARAMETER_NAME);
        String type = (String) elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName(), paramName);
        if (type != null && type.equals(EmfComponent.REPOSITORY)) {
            // use repository schema, pop up a dialog to ask the user for changing mode
            INode node;
            if (elem instanceof INode) {
                node = (INode) elem;
            } else {
                // else instanceof Connection
                node = ((IConnection) elem).getSource();
            }
            boolean isReadOnly = node.getProcess().isReadOnly();
            if (node.getJobletNode() != null) {
                isReadOnly = node.isReadOnly();
            }
            ModelSelectionDialog modelSelect = new ModelSelectionDialog(button.getShell(), ESelectionType.SCHEMA, isReadOnly);
            stop = true;
            if (modelSelect.open() == ModelSelectionDialog.OK) {
                if (modelSelect.getOptionValue() == EEditSelection.REPOSITORY) {
                    // update repository schema
                    button.setData(FORCE_READ_ONLY, false);
                    updateRepositorySchema(button);
                } else if (modelSelect.getOptionValue() == EEditSelection.BUILDIN) {
                    // change the schema type to built in, then continue the original process
                    executeCommand(new RepositoryChangeSchemaBuiltinCommand(elem, paramName));
                    button.setData(FORCE_READ_ONLY, false);
                    stop = false;
                } else if (modelSelect.getOptionValue() == EEditSelection.SHOW_SCHEMA) {
                    button.setData(FORCE_READ_ONLY, true);
                    stop = false;
                }
            }
        }
    }
    return stop;
}
Also used : INode(org.talend.core.model.process.INode) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog)

Example 2 with ModelSelectionDialog

use of org.talend.commons.ui.swt.dialogs.ModelSelectionDialog in project tdi-studio-se by Talend.

the class SqlMemoController method promptForChangingMode.

/**
     * Display a dialog to ask the user to update the query in the repository directly or change the query to built-in
     * mode.
     * 
     * @param shell
     */
private void promptForChangingMode(Shell shell) {
    ModelSelectionDialog modelSelect = new ModelSelectionDialog(shell, ESelectionType.QUERY);
    if (modelSelect.open() == ModelSelectionDialog.OK) {
        if (modelSelect.getOptionValue() == EEditSelection.BUILDIN) {
            executeCommand(changeToBuildInCommand());
        }
        if (modelSelect.getOptionValue() == EEditSelection.REPOSITORY) {
            executeCommand(refreshConnectionCommand());
        }
        if (modelSelect.getOptionValue() == EEditSelection.SHOW_QUERY) {
            if (queryText != null) {
                ShowQueryDialog showQueryDialog = new ShowQueryDialog(shell, queryText.getText());
                showQueryDialog.open();
            }
        }
    }
}
Also used : ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog)

Example 3 with ModelSelectionDialog

use of org.talend.commons.ui.swt.dialogs.ModelSelectionDialog in project tdi-studio-se by Talend.

the class AbstractSchemaController method checkForRepositoryShema.

/**
     * If schema type is repository, display a dialog to ask the user to change to built-in mode or update the schema in
     * the repository. Return true to stop the process.
     *
     * @param button
     */
public boolean checkForRepositoryShema(Button button) {
    boolean stop = false;
    if (button.getData(NAME).equals(SCHEMA)) {
        String paramName = (String) button.getData(PARAMETER_NAME);
        String type = (String) elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName(), paramName);
        if (type != null && type.equals(EmfComponent.REPOSITORY)) {
            // use repository schema, pop up a dialog to ask the user for changing mode
            INode node;
            if (elem instanceof INode) {
                node = (INode) elem;
            } else {
                // else instanceof Connection
                node = ((IConnection) elem).getSource();
            }
            boolean isReadOnly = node.getProcess().isReadOnly();
            if (node.getJobletNode() != null) {
                isReadOnly = node.isReadOnly();
            }
            ModelSelectionDialog modelSelect = new ModelSelectionDialog(button.getShell(), ESelectionType.SCHEMA, isReadOnly);
            stop = true;
            if (modelSelect.open() == ModelSelectionDialog.OK) {
                if (modelSelect.getOptionValue() == EEditSelection.REPOSITORY) {
                    // update repository schema
                    button.setData(FORCE_READ_ONLY, false);
                    updateRepositorySchema(button);
                } else if (modelSelect.getOptionValue() == EEditSelection.BUILDIN) {
                    // change the schema type to built in, then continue the original process
                    executeCommand(new RepositoryChangeSchemaBuiltinCommand(elem, paramName));
                    button.setData(FORCE_READ_ONLY, false);
                    stop = false;
                } else if (modelSelect.getOptionValue() == EEditSelection.SHOW_SCHEMA) {
                    button.setData(FORCE_READ_ONLY, true);
                    stop = false;
                }
            }
        }
    }
    return stop;
}
Also used : INode(org.talend.core.model.process.INode) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog)

Aggregations

ModelSelectionDialog (org.talend.commons.ui.swt.dialogs.ModelSelectionDialog)3 INode (org.talend.core.model.process.INode)2