Example usage for org.eclipse.jface.dialogs MessageDialog openInformation

List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openInformation.

Prototype

public static void openInformation(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.byterefinery.rmbench.actions.ForeignKeyAction.java

License:Open Source License

public void run() {
    List<Table> matchingTables = model.findMatchingTables(selectedColumnGroup);

    if (matchingTables.isEmpty()) {
        MessageDialog.openInformation(getWorkbenchPart().getSite().getShell(), null,
                Messages.No_PrimaryKey_matches);
    } else {//from   w w w . ja  v a2 s .c  om
        TargetTableChooser chooser = new TargetTableChooser(getWorkbenchPart().getSite().getShell(),
                matchingTables, diagram);

        if (chooser.open() == Window.OK) {
            //first create FK operation first, in case state gets recalculated
            AddForeignKeyOperation addFKOp = new AddForeignKeyOperation(groupTable);
            addFKOp.setTargetTable(chooser.getResultTable());
            addFKOp.setColumns(selectedColumnGroup);

            if (chooser.getDoImport()) {
                //execute the table import first
                TableEditPart tablePart = (TableEditPart) viewer.getEditPartRegistry().get(groupTable);
                DiagramEditPart diagramPart = (DiagramEditPart) tablePart.getParent();

                Point newLocation = tablePart.getLocation();
                newLocation.translate(tablePart.getFigure().getSize().scale(1.5));

                AddToDiagramOperation addTableOp = new AddToDiagramOperation(diagramPart,
                        new Object[] { chooser.getResultTable() }, newLocation);
                CompoundOperation compound = new CompoundOperation(addFKOp);
                compound.addFirst(addTableOp);
                compound.execute(this);
            } else {
                //now execute the foreign key
                addFKOp.execute(this);
            }
        }
    }
}

From source file:com.byterefinery.rmbench.dialogs.DDLExportWizardPage1.java

License:Open Source License

public void createControl(Composite parent) {

    final DDLExportWizard ddlWizard = (DDLExportWizard) getWizard();

    GridLayout layout;/*from  w ww  .  j a va  2  s .c  o  m*/
    GridData gd;

    final Composite composite = new Composite(parent, SWT.NONE);
    layout = new GridLayout();
    layout.verticalSpacing = 10;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Composite connectionGroup = new Composite(composite, SWT.NONE);
    connectionGroup.setLayout(new GridLayout());
    connectionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Button diffCheck = new Button(connectionGroup, SWT.CHECK);
    diffCheck.setText(Messages.DDLExportWizard1_generateDiff_label);
    diffCheck.setSelection(generateDiff);
    diffCheck.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (!generateDiff) {
                if (dbmodels.length == 0) {
                    MessageDialog.openInformation(getShell(), RMBenchMessages.ModelView_ExportDialog_Title,
                            Messages.DDLExportWizard1_NoConnection);
                    diffCheck.setSelection(false);
                    return;
                }
            }
            generateDiff = diffCheck.getSelection();
            connectionsViewer.getControl().setEnabled(generateDiff);
            checkCompleteState();
        }
    });

    connectionsViewer = new ListViewer(connectionGroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.minimumHeight = convertHeightInCharsToPixels(4);
    connectionsViewer.getList().setLayoutData(gd);
    connectionsViewer.setContentProvider(new ArrayContentProvider());
    connectionsViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            return ((DBModel) element).getName();
        }
    });
    connectionsViewer.setInput(dbmodels);
    if (dbmodel != null)
        connectionsViewer.setSelection(new StructuredSelection(dbmodel));
    connectionsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection selection = (StructuredSelection) event.getSelection();
            dbmodel = (DBModel) selection.getFirstElement();
            checkCompleteState();
        }
    });
    connectionsViewer.getControl().setEnabled(generateDiff);

    final Button generateDropCheck = new Button(composite, SWT.CHECK);
    generateDropCheck.setText(Messages.DDLExportWizard1_generateDrop_text);
    generateDropCheck.setSelection(generateDrop);
    generateDropCheck.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            generateDrop = generateDropCheck.getSelection();
        }
    });

    final Composite generatorGroup = new Composite(composite, SWT.NONE);
    generatorGroup.setLayout(new GridLayout());
    generatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    final Label generatorLabel = new Label(generatorGroup, SWT.NONE);
    generatorLabel.setText(Messages.DDLExportWizard1_generator_label);
    generatorLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    final ComboViewer generatorsViewer = new ComboViewer(generatorGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    generatorsViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    generatorsViewer.setContentProvider(new ArrayContentProvider());
    generatorsViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            return ((DDLGeneratorExtension) element).getName();
        }
    });
    generatorsViewer.setInput(generators);
    generatorsViewer.setSelection(new StructuredSelection(generatorExtension));
    generatorsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection selection = (StructuredSelection) event.getSelection();

            DDLGeneratorExtension genExt = (DDLGeneratorExtension) selection.getFirstElement();
            setGenerator(genExt);

            ddlWizard.setDDLGeneratorWizardPage(genExt.createGeneratorWizardPage(generator));
            checkCompleteState();
        }
    });

    setControl(composite);
    checkCompleteState();
}

From source file:com.byterefinery.rmbench.export.ExecuteScriptAction.java

License:Open Source License

public void run() {
    final IDDLScriptContext.Statement[] statements = ddlContext.getAllStatements();
    if (statements.length == 0) {
        MessageDialog.openInformation(ddlContext.getShell(), Messages.ExportEditor_infoTitle,
                Messages.ExportEditor_noStmts);
        return;//  ww w  . j  a va  2s .  c o  m
    }
    IDBAccess.Executor executor = null;
    try {
        executor = ddlContext.getSelectedDBModel().getExecutor(ddlContext.getShell());
    } catch (SystemException e) {
        ExceptionDialog.openError(ddlContext.getShell(), Messages.ExportEditor_connectError,
                e.getStatus(Messages.ExportEditor_connectError));
        RMBenchPlugin.logError(e.getCause());
    }
    if (executor != null) {
        ExecRunnable execRunnable = new ExecRunnable(executor, statements);
        IProgressService progressService = RMBenchPlugin.getDefault().getWorkbench().getProgressService();

        try {
            progressService.busyCursorWhile(execRunnable);
        } catch (Exception e) {
            RMBenchPlugin.logError(e);
        }
        if (execRunnable.errCount > 0) {
            MessageDialog.openError(ddlContext.getShell(), Messages.ExportEditor_infoTitle,
                    Messages.ExportEditor_executeError2);
        }
    }
}

From source file:com.byterefinery.rmbench.export.ExecuteStatementAction.java

License:Open Source License

public void run() {
    IDDLScriptContext.Statement statement = ddlContext.getSelectedStatement();
    if (statement == null) {
        MessageDialog.openInformation(ddlContext.getShell(), Messages.ExportEditor_infoTitle,
                Messages.ExportEditor_noStmt);
        return;/*from   w ww  .  j a va 2s  . c  o m*/
    }
    IDBAccess.Executor executor = null;
    try {
        executor = ddlContext.getSelectedDBModel().getExecutor(ddlContext.getShell());
    } catch (SystemException e) {
        ExceptionDialog.openError(ddlContext.getShell(), Messages.ExportEditor_connectError,
                e.getStatus(Messages.ExportEditor_connectError));
        RMBenchPlugin.logError(e.getCause());
    }
    if (executor != null) {
        ExecRunnable execRunnable = new ExecRunnable(executor, statement);
        BusyIndicator.showWhile(Display.getCurrent(), execRunnable);
        if (execRunnable.error != null) {
            ExceptionDialog.openError(ddlContext.getShell(), Messages.ExportEditor_executeError,
                    execRunnable.error.getStatus(Messages.ExportEditor_executeError));
        }
    }
}

From source file:com.byterefinery.rmbench.export.ModelCompareEditor.java

License:Open Source License

/**
 * ask the user for the workspace path of a file resource and save the document there.
 * <p><em>/*from w ww. jav a  2  s  .  c om*/
 * copied from {@link org.eclipse.ui.editors.text.TextEditor}. Sorry for that</em>
 * 
 * @param progressMonitor the progress monitor to be used
 */
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();

    SaveAsDialog dialog = new SaveAsDialog(shell);

    IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
    if (original != null)
        dialog.setOriginalFile(original);

    dialog.create();

    if (documentProvider == null) {
        // editor has programmatically been  closed while the dialog was open
        return;
    }

    if (documentProvider.isDeleted(input) && original != null) {
        String message = MessageFormat.format(Messages.MCEditor_warning_save_delete,
                new Object[] { original.getName() });
        dialog.setErrorMessage(null);
        dialog.setMessage(message, IMessageProvider.WARNING);
    }

    if (dialog.open() == Window.CANCEL) {
        if (progressMonitor != null)
            progressMonitor.setCanceled(true);
        return;
    }

    IPath filePath = dialog.getResult();
    if (filePath == null) {
        if (progressMonitor != null)
            progressMonitor.setCanceled(true);
        return;
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFile file = workspace.getRoot().getFile(filePath);
    final IEditorInput newInput = new NonPersistableFileEditorInput(file);

    boolean success = false;
    try {

        documentProvider.aboutToChange(newInput);
        documentProvider.saveDocument(progressMonitor, newInput, documentProvider.getDocument(input), true);
        success = true;

    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            String title = Messages.MCEditor_error_save_title;
            String msg = MessageFormat.format(Messages.MCEditor_error_save_message,
                    new Object[] { x.getMessage() });

            if (status != null) {
                switch (status.getSeverity()) {
                case IStatus.INFO:
                    MessageDialog.openInformation(shell, title, msg);
                    break;
                case IStatus.WARNING:
                    MessageDialog.openWarning(shell, title, msg);
                    break;
                default:
                    MessageDialog.openError(shell, title, msg);
                }
            } else {
                MessageDialog.openError(shell, title, msg);
            }
        }
    } finally {
        documentProvider.changed(newInput);
        if (success)
            setInput(newInput);
    }

    if (progressMonitor != null)
        progressMonitor.setCanceled(!success);
}

From source file:com.byterefinery.rmbench.export.ModelCompareEditorInput.java

License:Open Source License

/**
 * Perform the model comparison, displaying error dialogs if the comparison fails or 
 * no differences are found. //www .  j  a v a  2s  .  co m
 * 
 * @return true if successful
 */
public boolean compareResultOK() {
    try {
        PlatformUI.getWorkbench().getProgressService().run(true, false, this);

        String message = getMessage();
        if (message != null) {
            MessageDialog.openError(shell, Messages.CompareInput_compareFailed, message);
            return false;
        }

        if (dbmodel.isLoaded() && getCompareResult() == null) {
            MessageDialog.openInformation(shell, Messages.CompareInput_DialogTitle,
                    Messages.CompareInput_noDifferences);
            return false;
        }

        return true;

    } catch (InterruptedException x) {
        // cancelled by user        
    } catch (InvocationTargetException x) {
        RMBenchPlugin.logError(x.getTargetException());
        String msg = x.getTargetException().getMessage();
        if (msg == null)
            msg = x.getTargetException().getClass().getName();
        ExceptionDialog.openError(shell, Messages.CompareInput_compareFailed,
                SystemException.getStatus(x.getTargetException(), msg));
    }
    return false;
}

From source file:com.byterefinery.rmbench.operations.DeleteColumnOperation.java

License:Open Source License

public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

    if (column.belongsToForeignKey()) {
        MessageDialog.openInformation(RMBenchPlugin.getModelView().getViewSite().getShell(),
                Messages.Operation_DeleteColumn_messageTitle,
                Messages.Operation_DeleteColumn_foreignKey_Message);
        return Status.CANCEL_STATUS;
    }/*from w  w  w. j a v a  2s.  com*/

    ColumnDependencyDialog dialog = new ColumnDependencyDialog(column);

    if (dialog.calculateDependencies()) {
        if (dialog.open() != MessageDialog.OK) {
            return Status.CANCEL_STATUS;
        }
    }
    deletableForeignKeys = dialog.getDeletableForeignKeys();
    undeletableForeignKeys = dialog.getUnDeletableForeignKeys();
    deleteConstraints = dialog.getDeleteConstraints();

    if (column.belongsToPrimaryKey()) {
        index = column.getTable().getPrimaryKey().getIndex(column);
    }

    indexList = dialog.getIndexList();
    deleteIndices = dialog.getDeleteIndices();

    return redo(monitor, info);
}

From source file:com.ca.casd.lisa.plugins.odataassistant.views.OdataAssistant.java

License:Open Source License

private void showMessage(String message) {
    MessageDialog.openInformation(composite.getShell(), viewTitle, message);
}

From source file:com.casmall.common.dialog.Login.java

License:Open Source License

private void btnLoginMouseDown(MouseEvent evt) {
    if ("".equals(txtID.getText().trim())) {
        MessageDialog.openInformation(dialogShell, "Validation", "? ID .");
        txtID.setFocus();// w ww  . j  av  a  2  s. c  o m
        return;
    }
    if ("".equals(txtPassword.getText().trim())) {
        MessageDialog.openInformation(dialogShell, "Validation", "Password .");
        txtPassword.setFocus();
        return;
    }
    CmUsrInfMgr mgr = new CmUsrInfMgr();
    if (!mgr.checkLogin(txtID.getText().trim(), txtPassword.getText().trim())) {
        MessageDialog.openInformation(dialogShell, "Login check",
                "ID   ?.");
        txtPassword.setText("");
        txtID.setText("");
        txtID.setFocus();
        return;
    }

    // TODO NONE ??  ?  ??  : ?  <== !!
    dialogShell.setData(true);
    dialogShell.close();
}

From source file:com.casmall.common.dialog.MessageConfig.java

License:Open Source License

/**
 * Check input validate//from   w w w. j a v a2s. c  om
 * @return
 */
private boolean validate() {
    if (rdoLineFeedFlagChar.getSelection()) {
        if ("".equals(txtLineFeedChar.getText())) {
            MessageDialog.openInformation(dialogShell, "Validation", "Line Feed is not exists");
            txtLineFeedChar.setFocus();
            return false;
        }
        if ("#NA".equals(txtLineFeedChar.getText())) {
            MessageDialog.openInformation(dialogShell, "Validation", "Line Feed is invalid");
            txtLineFeedChar.setFocus();
            return false;
        }
    }
    if ("".equals(txtLineLength.getText()) || "-".equals(txtLineLength.getText())) {
        MessageDialog.openInformation(dialogShell, "Validation", "Line Length is not exists");
        txtLineLength.setFocus();
        return false;
    }
    if ("".equals(txtWeightLength.getText()) || Integer.parseInt(txtWeightLength.getText()) <= 0) {
        MessageDialog.openInformation(dialogShell, "Validation", "Data parts length is invalid.");
        txtWeightSttPos.setFocus();
        return false;
    }
    if ("".equals(txtMcnoLength.getText()) || Integer.parseInt(txtMcnoLength.getText()) <= 0) {
        MessageDialog.openInformation(dialogShell, "Validation", "Mc No length is invalid.");
        txtMcnoSttPos.setFocus();
        return false;
    }
    if (Integer.parseInt(this.txtLineLength.getText()) <= Integer.parseInt(this.txtWeightEndPos.getText())) {
        MessageDialog.openInformation(dialogShell, "Validation",
                "Data parts end position must be greater than Line Length.");
        txtWeightEndPos.setFocus();
        return false;
    }
    if (Integer.parseInt(this.txtLineLength.getText()) <= Integer.parseInt(this.txtMcnoEndPos.getText())) {
        MessageDialog.openInformation(dialogShell, "Validation",
                "Mc No end position must be greater than Line Length.");
        txtMcnoEndPos.setFocus();
        return false;
    }
    return true;
}