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

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

Introduction

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

Prototype

int OPEN_ID

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

Click Source Link

Document

Button id for an "Open" button (value 11).

Usage

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

License:Open Source License

/**
 * ???????/*w  w  w  .  jav a  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.ApprovalFilterDialog.java

License:Open Source License

/**
 * ???????<BR>// w w  w. j a va  2 s .  com
 * ????? ?????
 *
 * @param parent ???
 *
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 * @see com.clustercontrol.approval.action.GetApprovalFilterProperty#getProperty()
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    // 
    this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("clear"), false);
    this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // 
            resetPropertySheet();
        }
    });

    super.createButtonsForButtonBar(parent);
}

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

License:Open Source License

/**
 * Customize button bar/*from  ww w  . j av  a2s  .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.monitor.dialog.EventReportDialog.java

License:Open Source License

/**
 * ???????<BR>/*from  w  w w.  ja  v a2 s  .c o m*/
 * ????? ?????
 *
 * @param parent
 *            ???
 *
 * @see org.eclipse.swt.widgets.Button#addSelectionListener(SelectionListener)
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    // Add clear button
    Button clearButton = this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("clear"),
            false);
    WidgetTestUtil.setTestId(this, "clear", clearButton);

    this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            resetPropertySheet();
        }
    });

    super.createButtonsForButtonBar(parent);
}

From source file:com.clustercontrol.repository.dialog.NodeAssignDialog.java

License:Open Source License

/**
 * ???????//from www . j av a 2 s  .c o m
 *
 * @param parent
 *            ??
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    // 
    this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("filter"), false);
    this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // ?
            NodeFilterDialog dialog = new NodeFilterDialog(getShell());
            if (dialog.open() == IDialogConstants.OK_ID) {
                nodeList.update(dialog.getInputData());
            }
        }
    });

    super.createButtonsForButtonBar(parent);
}

From source file:com.foglyn.ui.WorkingOnCaseErrorDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    if (isMissingEstimateProblem()) {
        createButton(parent, IDialogConstants.OPEN_ID, "Open Case " + taskID, false);
    }/*  w  w w  . j  a v  a2 s .  c o m*/

    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}

From source file:com.foglyn.ui.WorkingOnCaseErrorDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    switch (buttonId) {
    case IDialogConstants.OPEN_ID:
        TasksUiUtil.openTask(repositoryURL, taskID, null);
        break;//from   w w  w.  j  a v  a2 s  .  c o  m
    default:
        // OK
    }

    if (workingOnSynchronization != null) {
        com.foglyn.core.Utils.setWorkingOnSynchronization(getTaskRepository(),
                workingOnSynchronization.getSelection());
    }

    setReturnCode(IDialogConstants.OK_ID);
    close();
}

From source file:com.google.dart.tools.search2.internal.ui.SearchHistorySelectionDialog.java

License:Open Source License

protected final void validateDialogState() {
    IStructuredSelection sel = (IStructuredSelection) fViewer.getSelection();
    int elementsSelected = sel.toList().size();

    fRemoveButton.setEnabled(elementsSelected > 0);
    Button okButton = getOkButton();
    if (okButton != null) {
        okButton.setEnabled(elementsSelected == 1);
    }//w w  w.  j a  va  2  s. c  om
    Button openInNewButton = getButton(IDialogConstants.OPEN_ID);
    if (openInNewButton != null) {
        openInNewButton.setEnabled(elementsSelected == 1);
    }
}

From source file:com.nokia.carbide.search.system2.internal.ui.SearchHistorySelectionDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OPEN_LABEL, true);
    createButton(parent, IDialogConstants.OPEN_ID,
            SearchMessages.SearchHistorySelectionDialog_open_in_new_button, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.nokia.carbide.search.system2.internal.ui.SearchHistorySelectionDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    if (buttonId == REMOVE_ID) {
        IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
        Iterator searchResults = selection.iterator();
        while (searchResults.hasNext()) {
            Object curr = searchResults.next();
            fRemovedEntries.add(curr);//from   www .ja  v  a  2 s. c om
            fInput.remove(curr);
            fViewer.remove(curr);
        }
        if (fViewer.getSelection().isEmpty() && !fInput.isEmpty()) {
            fViewer.setSelection(new StructuredSelection(fInput.get(0)));
        }
        return;
    }
    if (buttonId == IDialogConstants.OPEN_ID) {
        fIsOpenInNewView = true;
        buttonId = IDialogConstants.OK_ID;
    }
    super.buttonPressed(buttonId);
}