Example usage for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.

Prototype

int CANCEL_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.

Click Source Link

Document

Button id for a "Cancel" button (value 1).

Usage

From source file:com.cloudbees.eclipse.dev.ui.views.build.DeployWarAppDialog.java

License:Open Source License

/**
 * Create contents of the button bar./*from  w w  w  .j  a va  2 s  . com*/
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(final Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.clustercontrol.accesscontrol.dialog.LoginDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // Customize createButtonsForButtonBar(parent) here
    Button button;/*  w  w  w.  j a  va  2s.  c  o m*/

    button = createButton(parent, IDialogConstants.RETRY_ID, Messages.getString("button.addlogin"), false);
    WidgetTestUtil.setTestId(this, "addlogin", button);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (inputList.size() >= maxConnectManager) {
                // ????
                String msg = Messages.getString("message.accesscontrol.66",
                        new String[] { String.valueOf(maxConnectManager) });
                m_log.warn(msg);
                MessageDialog.openError(null, Messages.getString("message"), msg);
                return;
            }

            // Save inputting account info
            for (LoginInput input : inputList) {
                input.saveInfo();
            }

            // Update counter before add a new one and copy last manager input
            reInitializeCounter();

            LoginAccount lastInputAccount = inputList.get(inputList.size() - 1).getAccount();
            inputList.add(new LoginInput(lastInputAccount.getUserId(), "", lastInputAccount.getUrl(), null));

            int buttonId = ((Integer) e.widget.getData()).intValue();
            setReturnCode(buttonId);
            close();
        }
    });

    // ?
    button = createButton(parent, IDialogConstants.OK_ID, Messages.getString("login"), true);
    WidgetTestUtil.setTestId(this, "ok", button);
    if (disableLoginButton) {
        button.setEnabled(false);
    }

    // ?. Don't need to addSelectionListener() because CANCEL button will be set by default.
    button = createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("cancel"), false);
    WidgetTestUtil.setTestId(this, "cancel", button);
}

From source file:com.clustercontrol.accesscontrol.dialog.ObjectPrivilegeListDialog.java

License:Open Source License

/**
 * ???????/*  w w  w . ja  va  2  s .c  o  m*/
 *
 * @param parent
 *            ??
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    // 
    this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("edit"), false);
    this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            List<ObjectBean> objectBeans = new ArrayList<ObjectBean>();
            objectBeans.add(new ObjectBean(m_managerName, m_objectType, m_objectId));
            ObjectPrivilegeEditDialog dialog = new ObjectPrivilegeEditDialog(getParentShell(), objectBeans,
                    m_ownerRoleId, m_objPrivMap);
            dialog.open();

            // ???
            update();
        }
    });

    // ?
    // TODO Remove the following hard-code. IDialogConstants.*_LABEL will causes IncompatibleClassChangeError on RAP
    this.createButton(parent, IDialogConstants.CANCEL_ID, "Close", false);
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

private void createButtonsForApprovalButtonBar(Composite parent) {
    //?/*  w  w  w .  ja  v  a  2  s  .  c om*/
    createButton(parent, IDialogConstants.YES_ID, Messages.getString("approval.approve"), false);
    //??
    createButton(parent, IDialogConstants.NO_ID, Messages.getString("approval.deny"), false);
    //
    createButton(parent, IDialogConstants.OK_ID, Messages.getString("approval.comment.registration"), false);
    //
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("cancel"), false);
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

private void createButtonsForStopButtonBar(Composite parent) {
    //??/*www .  j a  v a  2s.c o  m*/
    createButton(parent, IDialogConstants.STOP_ID, Messages.getString("approval.stop"), false);
    //
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("cancel"), false);
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

private void createButtonsForCancelButtonBar(Composite parent) {
    ///*  ww  w.j ava2s .c  om*/
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("cancel"), false);
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (IDialogConstants.YES_ID == buttonId) {
        OperationApprove(true);//from   w  w  w  .j a  va2s . c  om
    } else if (IDialogConstants.NO_ID == buttonId) {
        OperationApprove(false);
    } else if (IDialogConstants.OK_ID == buttonId) {
        okPressed();
    } else if (IDialogConstants.CANCEL_ID == buttonId) {
        cancelPressed();
    } else if (IDialogConstants.STOP_ID == buttonId) {
        OperationStop(approvalInfo);
    }
}

From source file:com.clustercontrol.collect.dialog.ExportDialog.java

License:Open Source License

/**
 * Customize button bar// ww  w .  j  a  va  2 s. co  m
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    // 
    Button exportButton = this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("export"),
            true);
    WidgetTestUtil.setTestId(this, "export", exportButton);

    this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() {
        private FileDialog saveDialog;

        @Override
        public void widgetSelected(SelectionEvent e) {
            // ????
            this.saveDialog = new FileDialog(getShell(), SWT.SAVE);
            boolean headerFlag = ExportDialog.this.headerCheckbox.getSelection();

            //???([summaryType]_.zip?summaryType?)
            // ??????????????

            // ?????ID()?
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
            // ???????????(??????)
            String defaultDateStr = sdf.format(new Date(System.currentTimeMillis()));
            String defaultFileName = SummaryTypeMessage.typeToStringEN(m_summaryType) + '_' + defaultDateStr;
            this.saveDialog.setFilterExtensions(new String[] { "*.zip" });
            defaultFileName += ".zip";
            // ??????+?????????????
            defaultFileName = defaultFileName.replaceAll(" ", "");
            this.saveDialog.setFileName(defaultFileName);

            String filePath = this.saveDialog.open();
            if (filePath != null) {
                m_log.debug("filePath = " + filePath + ", defaultFileName = " + defaultFileName);
                output(m_managerFacilityIdNameMap, m_summaryType, m_collectKeyInfoPkList,
                        m_targetManagerFacilityMap, headerFlag, filePath, defaultFileName, defaultDateStr);
            }
        }

        /**
         * Output
         */
        protected void output(TreeMap<String, String> managerFacilityIdNameMap, Integer summaryType,
                List<CollectKeyInfoPK> targetCollectKeyInfoList,
                TreeMap<String, List<String>> targetManagerFacilityMap, boolean headerFlag, String filePath,
                String fileName, String defaultDateStr) {

            // DataWriter??
            // ???
            writer = new RecordDataWriter(managerFacilityIdNameMap, summaryType, targetCollectKeyInfoList,
                    targetManagerFacilityMap, headerFlag, filePath, defaultDateStr);

            // Download & ???
            try {
                IRunnableWithProgress op = new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        // ?
                        ServiceContext context = ContextProvider.getContext();
                        writer.setContext(context);
                        Thread exportThread = new Thread(writer);
                        exportThread.start();
                        Thread.sleep(3000);
                        monitor.beginTask(Messages.getString("export"), 100); // "?"

                        int progress = 0;
                        int buff = 0;
                        while (progress < 100) {
                            progress = writer.getProgress();

                            if (monitor.isCanceled()) {
                                throw new InterruptedException("");
                            }
                            if (writer.isCanceled()) {
                                throw new InterruptedException(writer.getCancelMessage());
                            }
                            Thread.sleep(50);
                            monitor.worked(progress - buff);
                            buff = progress;
                        }
                        monitor.done();
                    }
                };

                // ?
                new ProgressMonitorDialog(getShell()).run(true, true, op);

                // Start download file
                if (ClusterControlPlugin.isRAP()) {
                    FileDownloader.openBrowser(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            filePath, fileName);
                } else {
                    MessageDialog.openInformation(getShell(), Messages.getString("confirmed"),
                            Messages.getString("performance.export.success"));
                }
            } catch (InterruptedException e) {
                // ?????
                MessageDialog.openInformation(getShell(), Messages.getString("confirmed"),
                        Messages.getString("performance.export.cancel") + " : " + e.getMessage());
            } catch (Exception e) {
                // 
                m_log.warn("output() : " + e.getMessage(), e);
                MessageDialog.openInformation(getShell(), Messages.getString("confirmed"),
                        Messages.getString("performance.export.cancel") + " : " + e.getMessage() + "("
                                + e.getClass().getName() + ")");
            } finally {
                writer.setCanceled(true);
                if (ClusterControlPlugin.isRAP()) {
                    FileDownloader.cleanup(filePath);
                }
            }
        }
    });
    createButton(parent, IDialogConstants.CANCEL_ID, "close", false);
}

From source file:com.clustercontrol.dialog.CommonDialog.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite composite = (Composite) super.createContents(parent);
    WidgetTestUtil.setTestId(this, null, composite);
    m_areaComposite = (Composite) this.getDialogArea();
    WidgetTestUtil.setTestId(this, "area", m_areaComposite);

    m_areaComposite.setLayout(new FillLayout(SWT.DEFAULT));
    m_scrolledComposite = new ScrolledComposite(m_areaComposite, SWT.V_SCROLL | SWT.H_SCROLL);
    WidgetTestUtil.setTestId(this, "scrolled", m_scrolledComposite);

    Composite childComposite = new Composite(m_scrolledComposite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "child", childComposite);

    m_scrolledComposite.setExpandHorizontal(true);
    m_scrolledComposite.setExpandVertical(true);
    m_scrolledComposite.setContent(childComposite);

    // ?/*  ww  w .j a  v  a2  s .c  om*/
    this.customizeDialog(childComposite);

    if (m_areaComposite.getSize().x > 0 && m_areaComposite.getSize().y > 0) {
        // ???pack?????
        m_scrolledComposite.setMinSize(m_areaComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        // ?????????????????
        // ?????????????
        m_scrolledComposite.setMinWidth(m_areaComposite.getSize().x - 20);
    } else {
        //???pack???????
        /*
          ?????????????????
            scrolledComposite.setMinSize(areaComposite.getShell().getSize().x,
        areaComposite.getShell().getSize().y);
         */
    }

    // ?
    String okText = this.getOkButtonText();
    if (okText != null) {
        Button okButton = this.getButton(IDialogConstants.OK_ID);
        if (okButton != null) {
            WidgetTestUtil.setTestId(this, "ok", okButton);
            okButton.setText(okText);
        }
    }

    // ?
    String cancelText = this.getCancelButtonText();
    if (cancelText != null) {
        Button cancelButton = this.getButton(IDialogConstants.CANCEL_ID);
        if (cancelButton != null) {
            WidgetTestUtil.setTestId(this, "cancel", cancelButton);
            cancelButton.setText(cancelText);
        }
    }

    return composite;
}

From source file:com.clustercontrol.dialog.TextAreaDialog.java

License:Open Source License

/**
 * ????//from w w  w  . j  a  v  a 2 s. co  m
 * 
 * @param parent
 *            ??
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {

    if (this.m_modify) {
        super.createButtonsForButtonBar(parent);
    } else {
        // ?
        this.createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("ok"), false);
    }
}