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.amazonaws.eclipse.datatools.sqltools.tablewizard.simpledb.ui.popup.actions.DeleteDomainWizardAction.java

License:Apache License

@Override
public void run() {
    if (!this.event.getSelection().isEmpty()) {
        Iterator<?> iter = ((IStructuredSelection) this.event.getSelection()).iterator();
        Object selectedObj = iter.next();

        if (selectedObj instanceof PersistentTable) {
            boolean confirmed = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                    Messages.ConfirmDomainDeletion, MessageFormat.format(
                            Messages.ConfirmDomainDeletionDescription, ((Table) selectedObj).getName()));
            if (!confirmed) {
                return;
            }//from   w w w.j  av a 2s  . co m

            if (!closeEditors((Table) selectedObj)) {
                return;
            }

            Database db = getDatabase(((PersistentTable) selectedObj).getSchema());
            ConnectionInfo conInfo = (ConnectionInfo) DatabaseConnectionRegistry.getConnectionForDatabase(db);
            final PersistentTable table = (PersistentTable) selectedObj;
            try {
                deleteTable(conInfo, table);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}

From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.basic.EnvironmentTypeConfigEditorSection.java

License:Apache License

@Override
protected void createCombo(Composite parent, ConfigurationOptionDescription option) {
    Label label = createLabel(toolkit, parent, option);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    final Combo combo = new Combo(parent, SWT.READ_ONLY);
    combo.setItems(option.getValueOptions().toArray(new String[option.getValueOptions().size()]));
    IObservableValue modelv = model.observeEntry(option);
    ISWTObservableValue widget = SWTObservables.observeSelection(combo);
    parentEditor.getDataBindingContext().bindValue(widget, modelv,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
    final String oldEnvironmentType = (String) modelv.getValue();

    // After you do the confirmation, we will update the environment and refresh the layout.
    combo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            boolean confirmation = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                    "Change Environment Type", CHANGE_ENVIRONMENT_TYPE_WARNING);
            if (confirmation == true) {
                parentEditor.destroyOldLayouts();
                UpdateEnvironmentRequest rq = generateUpdateEnvironmentTypeRequest();
                if (rq != null) {
                    UpdateEnvironmentAndRefreshLayoutJob job = new UpdateEnvironmentAndRefreshLayoutJob(
                            environment, rq);
                    job.schedule();//from   ww  w . ja v  a  2s  . c  o  m
                }
            } else {
                combo.setText(oldEnvironmentType);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }

    });
}

From source file:com.amazonaws.eclipse.identitymanagement.group.GroupTable.java

License:Apache License

public GroupTable(AmazonIdentityManagement iam, Composite parent, FormToolkit toolkit) {
    super(iam, parent, toolkit);

    MenuManager menuManager = new MenuManager("#PopupMenu");
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (viewer.getTable().getSelectionCount() > 0) {

                manager.add(new Action() {

                    @Override/* w ww .  j  ava2  s .com*/
                    public ImageDescriptor getImageDescriptor() {
                        return AwsToolkitCore.getDefault().getImageRegistry()
                                .getDescriptor(AwsToolkitCore.IMAGE_REMOVE);
                    }

                    @Override
                    public void run() {
                        boolean confirmation = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                                "Delete Group", DELTE_GROUP_CONFIRMATION);
                        if (confirmation) {
                            groupSummary.setGroup(null);
                            usersInGroup.setGroup(null);
                            groupPermissions.setGroup(null);
                            deleteMultipleGroups(viewer.getTable().getSelectionIndices());
                        }
                    }

                    @Override
                    public String getText() {
                        if (viewer.getTable().getSelectionIndices().length > 1) {
                            return "Delete Groups";
                        }
                        return "Delete Group";
                    }

                });

                manager.add(new Action() {

                    @Override
                    public ImageDescriptor getImageDescriptor() {
                        return null;
                    }

                    @Override
                    public void run() {
                        EditGroupNameDialog editGroupNameDialog = new EditGroupNameDialog(contentProvider
                                .getItemByIndex(viewer.getTable().getSelectionIndex()).getGroupName());
                        if (editGroupNameDialog.open() == 0) {
                            editGroupName(editGroupNameDialog.getOldGroupName(),
                                    editGroupNameDialog.getNewGroupName());
                        }
                    }

                    @Override
                    public String getText() {
                        return "Edit Group Name";
                    }
                });
            }
        }
    });

    viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));

    viewer.getTable().addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            int index = viewer.getTable().getSelectionIndex();
            if (index >= 0) {
                Group group = contentProvider.getItemByIndex(index);
                groupSummary.setGroup(group);
                usersInGroup.setGroup(group);
                groupPermissions.setGroup(group);
            } else {
                groupSummary.setGroup(null);
                usersInGroup.setGroup(null);
                groupPermissions.setGroup(null);
            }
        }
    });

}

From source file:com.amazonaws.eclipse.identitymanagement.role.RoleTable.java

License:Apache License

public RoleTable(AmazonIdentityManagement iam, Composite parent, FormToolkit toolkit) {
    super(parent, SWT.NONE);

    this.iam = iam;

    TableColumnLayout tableColumnLayout = new TableColumnLayout();
    this.setLayout(tableColumnLayout);
    this.setLayoutData(new GridData(GridData.FILL_BOTH));

    contentProvider = new RoleTableContentProvider();
    RoleTableLabelProvider labelProvider = new RoleTableLabelProvider();

    viewer = new TableViewer(this, SWT.BORDER | SWT.MULTI);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.setLabelProvider(labelProvider);
    viewer.setContentProvider(contentProvider);

    MenuManager menuManager = new MenuManager("#PopupMenu");
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (viewer.getTable().getSelectionCount() > 0) {

                manager.add(new Action() {
                    @Override/*ww  w  .  j av a2 s.  c o m*/
                    public ImageDescriptor getImageDescriptor() {
                        return AwsToolkitCore.getDefault().getImageRegistry()
                                .getDescriptor(AwsToolkitCore.IMAGE_REMOVE);
                    }

                    @Override
                    public void run() {
                        boolean confirmation = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                                "Delete Role", DELTE_ROLE_CONFIRMATION);
                        if (confirmation) {
                            roleSummary.setRole(null);
                            rolePermissions.setRole(null);
                            roleTrustRelationships.setRole(null);
                            deleteMultipleGroups(viewer.getTable().getSelectionIndices());
                        }
                    }

                    @Override
                    public String getText() {
                        if (viewer.getTable().getSelectionIndices().length > 1) {
                            return "Delete Roles";
                        }
                        return "Delete Role";
                    }

                });
            }
        }
    });

    viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));

    viewer.getTable().addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            int index = viewer.getTable().getSelectionIndex();
            if (index >= 0) {
                Role role = contentProvider.getItemByIndex(index);
                roleSummary.setRole(role);
                rolePermissions.setRole(role);
                roleTrustRelationships.setRole(role);
            } else {
                roleSummary.setRole(null);
                rolePermissions.setRole(null);
                roleTrustRelationships.setRole(null);
            }

        }
    });

    createColumns(tableColumnLayout, viewer.getTable());
    refresh();
}

From source file:com.amitinside.e4.rcp.todo.handlers.ExitHandler.java

License:Apache License

@Execute
public void execute(EPartService partService, IWorkbench workbench, Shell shell) {
    if (!partService.getDirtyParts().isEmpty()) {
        boolean confirm = MessageDialog.openConfirm(shell, "Unsaved", "Unsaved data, do you want to save?");
        if (confirm) {
            partService.saveAll(false);/*from  w ww. ja va  2  s. c o  m*/
            // Ok we close here directy to avoid 
            // second popup
            workbench.close();
        }
    }

    boolean result = MessageDialog.openConfirm(shell, "Close", "Close application?");
    if (result) {
        workbench.close();
    }

}

From source file:com.amitinside.e4.rcp.todo.handlers.TestHandler.java

License:Apache License

@Execute
public void execute(final Shell shell, MWindow window) {
    IWindowCloseHandler handler = new IWindowCloseHandler() {
        @Override//from  w  w  w  .  ja  v a2s  .  c  o m
        public boolean close(MWindow window) {
            return MessageDialog.openConfirm(shell, "Close", "You will loose data. Really close?");
        }
    };
    window.getContext().set(IWindowCloseHandler.class, handler);
}

From source file:com.amitinside.mqtt.client.kura.handlers.QuitHandler.java

License:Apache License

@Execute
public void execute(final IWorkbench workbench, final Shell shell, final MApplication application,
        final IEclipseContext context) {
    if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) {
        final KuraMQTTClient client = context.get(KuraMQTTClient.class);
        client.disconnect();/*from  ww  w  .  ja va  2s.  c  o m*/
        workbench.close();
    }
}

From source file:com.android.glesv2debugger.ShaderEditor.java

License:Apache License

void uploadShader() {
    current.source = styledText.getText();

    // optional syntax check by glsl_compiler, built from external/mesa3d
    if (new File("./glsl_compiler").exists())
        try {/*ww  w.  j  a  va  2 s.c om*/
            File file = File.createTempFile("shader",
                    current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag");
            FileWriter fileWriter = new FileWriter(file, false);
            fileWriter.write(current.source);
            fileWriter.close();

            ProcessBuilder processBuilder = new ProcessBuilder("./glsl_compiler", "--glsl-es",
                    file.getAbsolutePath());
            final Process process = processBuilder.start();
            InputStream is = process.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line;
            String infolog = "";

            styledText.setLineBackground(0, styledText.getLineCount(), null);

            while ((line = br.readLine()) != null) {
                infolog += line;
                if (!line.startsWith("0:"))
                    continue;
                String[] details = line.split(":|\\(|\\)");
                final int ln = Integer.parseInt(details[1]);
                if (ln > 0) // usually line 0 means errors other than syntax
                    styledText.setLineBackground(ln - 1, 1, new Color(Display.getCurrent(), 255, 230, 230));
            }
            file.delete();
            if (infolog.length() > 0) {
                if (!MessageDialog.openConfirm(getShell(), "Shader Syntax Error, Continue?", infolog))
                    return;
            }
        } catch (IOException e) {
            sampleView.showError(e);
        }

    // add the initial command, which when read by server will set
    // expectResponse for the message loop and go into message exchange
    synchronized (shadersToUpload) {
        for (GLShader shader : shadersToUpload) {
            if (shader.context.context.contextId != current.context.context.contextId)
                continue;
            MessageDialog.openWarning(this.getShell(),
                    "Context 0x" + Integer.toHexString(current.context.context.contextId),
                    "Previous shader upload not complete, try again");
            return;
        }
        shadersToUpload.add(current);
        final int contextId = current.context.context.contextId;
        Message.Builder builder = getBuilder(contextId);
        MessageParserEx.instance.parse(builder,
                String.format("glShaderSource(%d,1,\"%s\",0)", current.name, current.source));
        sampleView.messageQueue.addCommand(builder.build());
    }
}

From source file:com.android.ide.eclipse.gldebugger.ShaderEditor.java

License:Apache License

void uploadShader() {
    current.source = styledText.getText();

    // optional syntax check by glsl_compiler, built from external/mesa3d
    if (new File("./glsl_compiler").exists())
        try {//from w  ww. j  a  va  2  s.  c  o  m
            File file = File.createTempFile("shader",
                    current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag");
            FileWriter fileWriter = new FileWriter(file, false);
            fileWriter.write(current.source);
            fileWriter.close();

            ProcessBuilder processBuilder = new ProcessBuilder("./glsl_compiler", "--glsl-es",
                    file.getAbsolutePath());
            final Process process = processBuilder.start();
            InputStream is = process.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line;
            String infolog = "";

            styledText.setLineBackground(0, styledText.getLineCount(), null);

            while ((line = br.readLine()) != null) {
                infolog += line;
                if (!line.startsWith("0:"))
                    continue;
                String[] details = line.split(":|\\(|\\)");
                final int ln = Integer.parseInt(details[1]);
                if (ln > 0) // usually line 0 means errors other than syntax
                    styledText.setLineBackground(ln - 1, 1, new Color(Display.getCurrent(), 255, 230, 230));
            }
            file.delete();
            if (infolog.length() > 0) {
                if (!MessageDialog.openConfirm(getShell(), "Shader Syntax Error, Continue?", infolog))
                    return;
            }
        } catch (IOException e) {
            mGLFramesView.showError(e);
        }

    // add the initial command, which when read by server will set
    // expectResponse for the message loop and go into message exchange
    synchronized (shadersToUpload) {
        for (GLShader shader : shadersToUpload) {
            if (shader.context.context.contextId != current.context.context.contextId)
                continue;
            MessageDialog.openWarning(this.getShell(),
                    "Context 0x" + Integer.toHexString(current.context.context.contextId),
                    "Previous shader upload not complete, try again");
            return;
        }
        shadersToUpload.add(current);
        final int contextId = current.context.context.contextId;
        Message.Builder builder = getBuilder(contextId);
        MessageParserEx.instance.parse(builder,
                String.format("glShaderSource(%d,1,\"%s\",0)", current.name, current.source));
        mGLFramesView.messageQueue.addCommand(builder.build());
    }
}

From source file:com.apicloud.authentication.splashHandlers.APICloudSplashHandler.java

License:Open Source License

private void handleButtonCancelWidgetSelected() {
    if (!(MessageDialog.openConfirm(getSplash(), Messages.ApicloudSplashHandler_EXIT,
            Messages.ApicloudSplashHandler_EXIT_MESSAGE)))
        return;/*from w w  w. ja va2  s  .c  o  m*/
    System.exit(0);
}