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

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

Introduction

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

Prototype

int OK_ID

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

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.amalto.workbench.dialogs.IdentityConstraintInputDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    // super.createButtonsForButtonBar(parent);
    // getButton(IDialogConstants.OK_ID).addSelectionListener(this.caller);
    // /*/*www  .  j  av a2 s .com*/
    // createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
    // true);
    // createButton(parent, IDialogConstants.CANCEL_ID,
    // IDialogConstants.CANCEL_LABEL, false);
    // */

    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

}

From source file:com.amalto.workbench.dialogs.IdentityConstraintInputDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!validInput())
            return;
    }//from w w w.j  a  va  2  s.  c  om
    super.buttonPressed(buttonId);
}

From source file:com.amalto.workbench.dialogs.ImportExchangeOptionsDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(Messages.ImportExchangeOptionsDialog_DialogTitle);

    Composite composite = (Composite) super.createDialogArea(parent);

    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 5;// w ww .  j av a  2  s.c  om

    exportsBtn = new Button(composite, SWT.RADIO);
    exportsBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    exportsBtn.setText(Messages.ImportExchangeOptionsDialog_Exports);
    exportsBtn.setEnabled((export | radioEnable) ? true : false);
    exportsBtn.setSelection(false);

    dataModelBtn = new Button(composite, SWT.RADIO);
    dataModelBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    dataModelBtn.setText(Messages.ImportExchangeOptionsDialog_Datamodels);
    dataModelBtn.setEnabled((!export) | radioEnable ? true : false);
    dataModelBtn.setSelection(false);

    Label label = new Label(composite, SWT.BORDER);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    label.setText(Messages.ImportExchangeOptionsDialog_RevisionXX);

    revisionCombo = new CCombo(composite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.FLAT | SWT.BORDER);
    GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    revisionCombo.setLayoutData(gd);
    gd.widthHint = 100;
    Set<String> revisions = new HashSet<String>();
    Map<String, String> rMap = getRevisionMap();
    revisions.addAll(rMap.values());
    revisionCombo.setItems(revisions.toArray(new String[0]));

    // get current plugin revision
    String bundleVersion = MDMWorbenchPlugin.getDefault().getVersion();
    String version = bundleVersion.split("_")[0];//$NON-NLS-1$
    revision = rMap.get(version);
    if (revision == null) {
        revision = "1"; //$NON-NLS-1$
    }
    revisionCombo.setText(revision);

    revisionCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            revision = revisionCombo.getText();
            fillInTable();
        }
    });
    executeBtn = new Button(composite, SWT.PUSH);
    executeBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1));
    executeBtn.addSelectionListener(this);
    executeBtn.setImage(ImageCache.getCreatedImage(EImage.REFRESH.getPath()));

    if (exportsBtn.getSelection()) {
        exchangeDwnTable = new Table(composite,
                SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    } else {
        exchangeDwnTable = new Table(composite,
                SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    }

    exchangeDwnTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
    ((GridData) exchangeDwnTable.getLayoutData()).heightHint = 300;
    exchangeDwnTable.setHeaderVisible(true);
    exchangeDwnTable.setLinesVisible(true);

    final TableColumn column1 = new TableColumn(exchangeDwnTable, SWT.NONE);
    column1.setText(Messages.ImportExchangeOptionsDialog_Name);
    final TableColumn column2 = new TableColumn(exchangeDwnTable, SWT.NONE);
    column2.setText(Messages.ImportExchangeOptionsDialog_Revision);
    final TableColumn column3 = new TableColumn(exchangeDwnTable, SWT.NONE);
    column3.setText(Messages.ImportExchangeOptionsDialog_Url);
    column1.setWidth(100);
    column2.setWidth(100);
    column3.setWidth(400);

    exchangeDwnTable.addListener(SWT.SetData, new Listener() {

        public void handleEvent(Event e) {
            TableItem item = (TableItem) e.item;
            int index = exchangeDwnTable.indexOf(item);
            try {
                JSONObject datum = dataContent[index];
                item.setText(new String[] { datum.get(COLUMN_EXTENSION_NAME).toString(),
                        datum.get(COLUMN_REVISION_NAME).toString(), datum.get(COLUMN_URL_NAME).toString() });
            } catch (JSONException je) {
                log.error(je.getMessage(), je);
            }
        }
    });

    exchangeDwnTable.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            getButton(IDialogConstants.OK_ID)
                    .setEnabled(exchangeDwnTable.getSelection().length >= 1 ? true : false);
        }

    });

    // Add sort indicator and sort data when column selected
    Listener sortListener = new Listener() {

        @SuppressWarnings("unchecked")
        public void handleEvent(Event e) {
            // determine new sort column and direction
            TableColumn sortColumn = exchangeDwnTable.getSortColumn();
            final TableColumn currentColumn = (TableColumn) e.widget;
            int dir = exchangeDwnTable.getSortDirection();
            if (sortColumn == currentColumn) {
                dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {
                exchangeDwnTable.setSortColumn(currentColumn);
                dir = SWT.UP;
            }
            // sort the data based on column and direction
            final int direction = dir;
            Arrays.sort(dataContent, new Comparator() {

                public int compare(Object arg0, Object arg1) {
                    JSONObject jsonA = (JSONObject) arg0;
                    JSONObject jsonB = (JSONObject) arg1;
                    String valueA = null, valueB = null;

                    try {
                        if (currentColumn == column1) {
                            valueA = jsonA.get(COLUMN_EXTENSION_NAME).toString();
                            valueB = jsonB.get(COLUMN_EXTENSION_NAME).toString();
                        } else if (currentColumn == column2) {
                            valueA = jsonA.get(COLUMN_REVISION_NAME).toString();
                            valueB = jsonB.get(COLUMN_REVISION_NAME).toString();
                        } else {
                            valueA = jsonA.get(COLUMN_URL_NAME).toString();
                            valueB = jsonB.get(COLUMN_URL_NAME).toString();
                        }

                        if (valueA.equals(valueB)) {
                            return 0;
                        }
                        if (direction == SWT.UP) {
                            return valueA.compareTo(valueB) < 0 ? -1 : 1;
                        }
                        return valueA.compareTo(valueB) < 0 ? 1 : -1;
                    } catch (JSONException je) {
                        log.error(je.getMessage(), je);
                        return -1;
                    }
                }
            });
            // update data displayed in table
            exchangeDwnTable.setSortDirection(dir);
            exchangeDwnTable.clearAll();
        }
    };

    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);

    exchangeDwnTable.setSortColumn(column1);
    exchangeDwnTable.setSortDirection(SWT.UP);

    return composite;
}

From source file:com.amalto.workbench.dialogs.ImportExchangeOptionsDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setEnabled(false);
    getButton(IDialogConstants.OK_ID).addSelectionListener(this);
}

From source file:com.amalto.workbench.dialogs.InputComboDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        value = inputCombo.getText();// ww  w .j  a v  a2s  .  c o m
        type = inputCombo.getSelectionIndex();
    } else {
        type = -1;
        value = null;
    }
    super.buttonPressed(buttonId);
}

From source file:com.amalto.workbench.dialogs.InputComboDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    // do this here because setting the text will set enablement on the ok
    // button/*from   ww  w.ja  v  a2 s .com*/
    if (value != null) {
        inputCombo.setText(value);
    }
}

From source file:com.amalto.workbench.dialogs.JobProcesssOptionsDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    // create Generate and Cancel buttons by default
    Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    button.setText(Messages.JobProcesssOptionsDialog_Generate);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.amalto.workbench.dialogs.MDMXSDSchemaEntryDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(this.title);

    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 1;//from w  w w  .j av  a  2 s . c  o  m

    wcListViewer = new ListViewer(composite,
            SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    wcListViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    ((GridData) wcListViewer.getControl().getLayoutData()).minimumHeight = 200;

    wcListViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            return ((ArrayList) inputElement).toArray(new String[] {});
        }
    });

    wcListViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            importedUrls.clear();
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                String url = (String) iter.next();
                importedUrls.add(url);
            }
            getButton(IDialogConstants.OK_ID).setEnabled(!selection.isEmpty());
        }
    });
    wcListViewer.setLabelProvider(new ILabelProvider() {

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }

        public Image getImage(Object element) {
            return null;
        }

        public String getText(Object element) {
            return element.toString();
        }
    });

    wcListViewer.setSorter(new ViewerSorter());
    wcListViewer.setInput(urls);
    return composite;
}

From source file:com.amalto.workbench.dialogs.MDMXSDSchemaEntryDialog.java

License:Open Source License

@Override
protected void okPressed() {
    setReturnCode(OK);/*from  w w  w. j  av a  2s . c  o m*/
    getButton(IDialogConstants.OK_ID).setData("dialog", MDMXSDSchemaEntryDialog.this);//$NON-NLS-1$
    // no close let Action Handler handle it
    super.okPressed();
}

From source file:com.amalto.workbench.dialogs.MDMXSDSchemaEntryDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Control control = super.createButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setEnabled(false);

    return control;
}