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

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

Introduction

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

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

From source file:com.hangum.tadpole.rdb.core.editors.table.TableViewerEditPart.java

License:Open Source License

/**
 * where  /*from   ww w  .ja  v  a  2 s.c  o  m*/
 * 
 * @param where
 */
private void changeWhere(String where) {

    //  ...
    if (!"".equals(getChangeQuery())) { //$NON-NLS-1$
        if (MessageDialog.openConfirm(null, Messages.TableEditPart_5, Messages.TableViewerEditPart_1)) {
            initBusiness(where);
        }
    } else {
        initBusiness(where);
    }
}

From source file:com.hangum.tadpole.rdb.core.viewers.sql.template.SQLTemplateView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));

    Composite compositeHead = new Composite(parent, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeHead.setLayout(new GridLayout(1, false));

    ToolBar toolBar = new ToolBar(compositeHead, SWT.FLAT | SWT.RIGHT);

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.addSelectionListener(new SelectionAdapter() {
        @Override//from   w w w  .j  ava2 s  . c  o m
        public void widgetSelected(SelectionEvent e) {
            initData();
        }
    });
    tltmRefresh.setImage(GlobalImageUtils.getRefresh());
    tltmRefresh.setToolTipText(Messages.get().Refresh);

    ToolItem tltmAdd = new ToolItem(toolBar, SWT.NONE);
    tltmAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addTemplate(SQL_TEMPLATE_TYPE.PRI);
        }
    });
    tltmAdd.setImage(GlobalImageUtils.getAdd());
    tltmAdd.setToolTipText(Messages.get().Add);

    tltmModify = new ToolItem(toolBar, SWT.NONE);
    tltmModify.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            StructuredSelection ss = (StructuredSelection) tvSQLTemplate.getSelection();
            if (ss.getFirstElement() instanceof SQLTemplateDAO) {
                SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement();
                SQLTemplateDialog dialog = new SQLTemplateDialog(getSite().getShell(), dao);
                if (Dialog.OK == dialog.open()) {
                    tvSQLTemplate.refresh(dialog.getOldSqlTemplateDAO());
                    textSQL.setText("");
                }
            }
        }
    });
    tltmModify.setImage(GlobalImageUtils.getModify());
    tltmModify.setToolTipText(Messages.get().Modified);
    tltmModify.setEnabled(false);

    tltmDelete = new ToolItem(toolBar, SWT.NONE);
    tltmDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!MessageDialog.openConfirm(getSite().getShell(), Messages.get().Confirm,
                    Messages.get().SQLTemplateView_del_equestion))
                return;

            StructuredSelection ss = (StructuredSelection) tvSQLTemplate.getSelection();
            if (ss.getFirstElement() instanceof SQLTemplateDAO) {
                SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement();
                try {
                    TadpoleSystem_SQLTemplate.deleteSQLTemplate(dao);
                    grpPrivateDao.getChildList().remove(dao);
                    tvSQLTemplate.remove(dao);

                    textSQL.setText("");
                } catch (Exception e1) {
                    logger.error("Delete SQL template", e1);
                }
            }
        }
    });
    tltmDelete.setImage(GlobalImageUtils.getDelete());
    tltmDelete.setToolTipText(Messages.get().Delete);
    tltmDelete.setEnabled(false);

    // admin menu
    if (SessionManager.isSystemAdmin()) {
        new ToolItem(toolBar, SWT.SEPARATOR);
        ToolItem tltmAdminAdd = new ToolItem(toolBar, SWT.NONE);
        tltmAdminAdd.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                addTemplate(SQL_TEMPLATE_TYPE.PUB);
            }
        });
        tltmAdminAdd.setText(Messages.get().SQLTemplateView_Addpublictemplate);
        tltmAdminAdd.setToolTipText(Messages.get().SQLTemplateView_Addpublictemplate);
    }

    SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Composite compositeBody = new Composite(sashForm, SWT.NONE);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_compositeBody = new GridLayout(1, false);
    gl_compositeBody.verticalSpacing = 0;
    gl_compositeBody.horizontalSpacing = 0;
    gl_compositeBody.marginHeight = 0;
    gl_compositeBody.marginWidth = 0;
    compositeBody.setLayout(gl_compositeBody);

    textSearch = new Text(compositeBody, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    textSearch.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            filterText();
        }
    });
    textSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    tvSQLTemplate = new TreeViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    tvSQLTemplate.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection ss = (StructuredSelection) event.getSelection();
            if (ss.getFirstElement() instanceof SQLTemplateDAO) {
                SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement();
                if (SQL_TEMPLATE_TYPE.PUB.name().equals(dao.getCategory())) {
                    if (SessionManager.isSystemAdmin()) {
                        enableBtn(true);
                    } else {
                        enableBtn(false);
                    }
                } else {
                    enableBtn(true);
                }

                textSQL.setText(dao.getContent());
            } else {
                enableBtn(false);
                textSQL.setText("");
            }
        }

        private void enableBtn(boolean bool) {
            tltmModify.setEnabled(bool);
            tltmDelete.setEnabled(bool);
        }
    });
    tvSQLTemplate.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection ss = (StructuredSelection) event.getSelection();
            if (ss.getFirstElement() instanceof SQLTemplateDAO) {
                SQLTemplateDAO dao = (SQLTemplateDAO) ss.getFirstElement();
                FindEditorAndWriteQueryUtil.run(dao.getContent());
            }
        }
    });
    Tree tree = tvSQLTemplate.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TreeViewerColumn treeViewerColumn = new TreeViewerColumn(tvSQLTemplate, SWT.NONE);
    TreeColumn trclmnUrl = treeViewerColumn.getColumn();
    trclmnUrl.setWidth(55);
    trclmnUrl.setText(Messages.get().GroupName);

    TreeViewerColumn tvcName = new TreeViewerColumn(tvSQLTemplate, SWT.NONE);
    TreeColumn trclmnDBName = tvcName.getColumn();
    trclmnDBName.setWidth(100);
    trclmnDBName.setText(Messages.get().Name);

    TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(tvSQLTemplate, SWT.NONE);
    TreeColumn trclmnDescription = treeViewerColumn_2.getColumn();
    trclmnDescription.setWidth(100);
    trclmnDescription.setText(Messages.get().Description);

    TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(tvSQLTemplate, SWT.NONE);
    TreeColumn trclmnName = treeViewerColumn_1.getColumn();
    trclmnName.setWidth(300);
    trclmnName.setText(Messages.get().SQL);

    Composite compositeSQL = new Composite(sashForm, SWT.NONE);
    GridLayout gl_compositeSQL = new GridLayout(1, false);
    gl_compositeSQL.verticalSpacing = 0;
    gl_compositeSQL.horizontalSpacing = 0;
    gl_compositeSQL.marginHeight = 0;
    gl_compositeSQL.marginWidth = 0;
    compositeSQL.setLayout(gl_compositeSQL);

    textSQL = new TadpoleEditorWidget(compositeSQL, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", "");
    textSQL.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sashForm.setWeights(new int[] { 7, 3 });

    tvSQLTemplate.setContentProvider(new SQLTemplateContentprovider());
    tvSQLTemplate.setLabelProvider(new SQLTemplateLabelprovider());

    //      Composite compositeTail = new Composite(parent, SWT.NONE);
    //      compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    //      compositeTail.setLayout(new GridLayout(1, false));

    initData();

    filter = new SQLTemplateFilter();
    tvSQLTemplate.addFilter(filter);

    AnalyticCaller.track(SQLTemplateView.ID);
}

From source file:com.hangum.tadpole.rdb.erd.core.actions.ERDRefreshAction.java

License:Open Source License

@Override
public void run() {
    if (!MessageDialog.openConfirm(getWorkbenchPart().getSite().getShell(), Messages.get().Confirm,
            Messages.get().ERDRefreshAction_4))
        return;/*from  w  w w.ja v a  2s. c o  m*/

    DB dbModel = rdbEditor.getDb();

    //   table ?  .
    Map<String, Rectangle> mapOldTables = new HashMap<String, Rectangle>();
    for (Table table : dbModel.getTables()) {
        mapOldTables.put(table.getName(), table.getConstraints());
    }

    // remove tables
    int intTableCnt = dbModel.getTables().size();
    for (int i = 0; i < intTableCnt; i++) {
        Table table = dbModel.getTables().get(0);
        table.setDb(null);
    }

    List<String> strTableNames = new ArrayList<String>(mapOldTables.keySet());

    // refresh ui
    try {
        final RdbFactory factory = RdbFactory.eINSTANCE;
        final UserDBDAO userDB = rdbEditor.getUserDB();
        //   ? ?.
        Map<String, Table> mapDBTables = new HashMap<String, Table>();

        List<TableDAO> listTAbles = TadpoleModelUtils.INSTANCE.getTable(userDB, strTableNames);

        for (TableDAO table : listTAbles) {
            Table tableModel = factory.createTable();
            tableModel.setDb(dbModel);
            tableModel.setName(table.getName());

            if (userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) {
                tableModel.setComment(""); //$NON-NLS-1$
            } else {
                String tableComment = table.getComment();
                tableComment = StringUtils.substring("" + tableComment, 0, 10); //$NON-NLS-1$
                tableModel.setComment(tableComment);
            }

            mapDBTables.put(tableModel.getName(), tableModel);
            tableModel.setConstraints(mapOldTables.get(table.getName()));
            // column add
            List<TableColumnDAO> columnList = TDBDataHandler.getColumns(userDB, table);
            for (TableColumnDAO columnDAO : columnList) {

                Column column = factory.createColumn();
                column.setDefault(columnDAO.getDefault());
                column.setExtra(columnDAO.getExtra());
                column.setField(columnDAO.getField());
                column.setNull(columnDAO.getNull());
                column.setKey(columnDAO.getKey());
                column.setType(columnDAO.getType());

                String strComment = columnDAO.getComment();
                if (strComment == null)
                    strComment = ""; //$NON-NLS-1$
                strComment = StringUtils.substring("" + strComment, 0, 10); //$NON-NLS-1$
                column.setComment(strComment);

                column.setTable(tableModel);
                tableModel.getColumns().add(column);
            }

        } // end table list

        //  .
        RelationUtil.calRelation(userDB, mapDBTables, dbModel);

    } catch (Exception e) {
        logger.error("Get all table list", e); //$NON-NLS-1$
    }
}

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

License:Apache License

@Override
public boolean okToLeave() {

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

    // ????.//from  w w w . j  a  v a 2 s .  co  m
    if (getJavaScriptProject() == null || !getApplyButton().isEnabled()
            || H5WizardPlugin.getInstance().getSelectedLibrarySet().isEmpty()) { // ?.
        return super.okToLeave();
    }

    // ?
    if (!MessageDialog.openConfirm(null, Messages.SE0111.format(), Messages.SE0112.format())) {
        return false;
    }

    // ?
    getDefaultsButton().setEnabled(false);
    getApplyButton().setEnabled(false);

    return true;
}

From source file:com.hudson.hibernatesynchronizer.editors.synchronizer.actions.RemoveRelatedFiles.java

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)/*from  ww w. j a v  a 2  s  .  co m*/
 */
public void run(IAction action) {
    final Shell shell = new Shell();
    if (MessageDialog.openConfirm(shell, "File Removal Confirmation",
            "Are you sure you want to delete all related classes and resources to the selected mapping files?")) {
        ISelectionProvider provider = part.getSite().getSelectionProvider();
        if (null != provider) {
            if (provider.getSelection() instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) provider.getSelection();
                Object[] obj = selection.toArray();
                final IFile[] files = new IFile[obj.length];
                IProject singleProject = null;
                boolean isSingleProject = true;
                for (int i = 0; i < obj.length; i++) {
                    if (obj[i] instanceof IFile) {
                        IFile file = (IFile) obj[i];
                        files[i] = file;
                        if (null == singleProject)
                            singleProject = file.getProject();
                        if (!singleProject.getName().equals(file.getProject().getName())) {
                            isSingleProject = false;
                        }
                    }
                }
                if (isSingleProject) {
                    final IProject project = singleProject;
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(part.getSite().getShell());
                    try {
                        dialog.open();

                        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
                            public void run(IProgressMonitor monitor) throws CoreException {
                                try {
                                    removeRelatedFiles(project, files, shell, monitor);
                                } catch (Exception e) {
                                    throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID,
                                            IStatus.OK, e.getMessage(), e));
                                } finally {
                                    monitor.done();
                                }
                            }
                        }, dialog.getProgressMonitor());
                    } catch (Exception e) {
                        UIUtil.pluginError(e, shell);
                    } finally {
                        dialog.close();
                    }
                } else {
                    UIUtil.pluginError("SingleProjectSelectedFiles", shell);
                }
            }
        }
    }
}

From source file:com.hudson.hibernatesynchronizer.popup.actions.RemoveRelatedFiles.java

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)//w w  w  .  j  ava  2  s  . c o  m
 */
public void run(IAction action) {
    final Shell shell = new Shell();
    if (MessageDialog.openConfirm(shell, "File Removal Confirmation",
            "Are you sure you want to delete all related class and resources to the selected mapping files?")) {
        ISelectionProvider provider = part.getSite().getSelectionProvider();
        if (null != provider) {
            if (provider.getSelection() instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) provider.getSelection();
                Object[] obj = selection.toArray();
                final IFile[] files = new IFile[obj.length];
                IProject singleProject = null;
                boolean isSingleProject = true;
                for (int i = 0; i < obj.length; i++) {
                    if (obj[i] instanceof IFile) {
                        IFile file = (IFile) obj[i];
                        files[i] = file;
                        if (null == singleProject)
                            singleProject = file.getProject();
                        if (!singleProject.getName().equals(file.getProject().getName())) {
                            isSingleProject = false;
                        }
                    }
                }
                if (isSingleProject) {
                    final IProject project = singleProject;
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(part.getSite().getShell());
                    try {
                        dialog.run(false, true, new IRunnableWithProgress() {
                            public void run(IProgressMonitor monitor)
                                    throws InvocationTargetException, InterruptedException {
                                try {
                                    RemoveRelatedFilesRunnable runnable = new RemoveRelatedFilesRunnable(
                                            project, files, monitor, shell);
                                    ResourcesPlugin.getWorkspace().run(runnable, monitor);
                                } catch (Exception e) {
                                    throw new InvocationTargetException(e);
                                } finally {
                                    monitor.done();
                                }
                            }
                        });
                    } catch (Exception e) {
                    }
                } else {
                    HSUtil.showError("The selected files must belong to a single project", shell);
                }
            }
        }
    }
}

From source file:com.hudson.hibernatesynchronizer.popup.actions.SynchronizeOverwriteFiles.java

License:GNU General Public License

public void run(IAction action) {
    Shell shell = new Shell();
    boolean rtn = MessageDialog.openConfirm(shell, "File Overwrite Confirmation",
            "Are you sure you want to overwrite all files with the template generation?");
    if (rtn) {//from   ww  w  . jav  a 2 s .c om
        super.run(action);
    }
}

From source file:com.hydra.project.handlers.QuitHandler.java

License:Open Source License

@Execute
public void execute(IWorkbench workbench, Shell shell) {
    if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) {
        LogfileView.setShutdown(true); //send a message that no log is available
        TreeTools.alleDateienSchliessen();
        workbench.close();//from w  ww  .  jav a  2  s. c  o  m
    }
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java

License:Open Source License

private void handleSetDefaultButton() {
    try {/*from  www  . j  av a2  s .co m*/
        CustomizeData custData = getCustTableSelection();
        if (custData.getName().equals(CustomizeManager.TABLE_DEFAULT_LABEL)
                || custData.getName().equals(CustomizeManager.CURRENT_LABEL)) {
            XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.set_default")); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        if (xViewerToCustomize.getCustomizeMgr().isCustomizationUserDefault(custData)) {
            if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                    XViewerText.get("button.remove_default"), //$NON-NLS-1$
                    MessageFormat.format(XViewerText.get("XViewerCustomizeDialog.prompt.remove_default"), //$NON-NLS-1$
                            custData.getName()))) {
                xViewerToCustomize.getCustomizeMgr().setUserDefaultCustData(custData, false);
            }
        } else if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                XViewerText.get("button.set_default"), //$NON-NLS-1$
                MessageFormat.format(XViewerText.get("XViewerCustomizeDialog.prompt.set_default"), //$NON-NLS-1$
                        custData.getName()))) {
            xViewerToCustomize.getCustomizeMgr().setUserDefaultCustData(custData, true);
        }
        loadCustomizeTable();
    } catch (Exception ex) {
        XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
    }
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java

License:Open Source License

private void handleDeleteButton() {
    try {/*from  ww  w  .  j  a  va  2  s.co  m*/
        CustomizeData custSel = getCustTableSelection();
        if (custSel.getName().equals(CustomizeManager.TABLE_DEFAULT_LABEL)
                || custSel.getName().equals(CustomizeManager.CURRENT_LABEL)) {
            XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.delete_default")); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        if (!custSel.isPersonal() && !xViewerToCustomize.getXViewerFactory().isAdmin()) {
            XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.delete_global")); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        String dialogTitle = XViewerText.get("XViewerCustomizeDialog.prompt.delete.title"); //$NON-NLS-1$
        String dialogMessage = XViewerText.get("XViewerCustomizeDialog.prompt.delete"); //$NON-NLS-1$
        if (!custSel.isPersonal()) {
            dialogTitle = XViewerText.get("XViewerCustomizeDialog.prompt.delete.shared.title"); //$NON-NLS-1$
            dialogMessage = XViewerText.get("XViewerCustomizeDialog.prompt.delete.shared"); //$NON-NLS-1$
        }
        if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), dialogTitle,
                MessageFormat.format(dialogMessage, custSel.getName()))) {
            xViewerToCustomize.getCustomizeMgr().deleteCustomization(custSel);
            loadCustomizeTable();
            updateButtonEnablements();
        }
    } catch (Exception ex) {
        XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
    }
}