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.buildml.eclipse.actions.dialogs.SlotSelectionDialog.java

License:Open Source License

@Override
protected void okPressed() {

    /* //ww w  .  jav a2  s .  co  m
     * Determine which slot was highlighted - check the input list first, then the
     * output list. At least one of the lists must have a selected item, otherwise
     * "OK" would have been greyed out.
     */
    int selectedIndex = -1;

    /* an input slot was selected? */
    if (showInputSlots) {
        selectedIndex = inputSlotListBox.getSelectionIndex();
        if (selectedIndex != -1) {
            this.slotId = inputSlots[selectedIndex].slotId;
            this.slotName = inputSlots[selectedIndex].slotName;
        }
    }

    if (showOutputSlots && (selectedIndex == -1)) {
        /* an output slot was selected? */
        selectedIndex = outputSlotListBox.getSelectionIndex();
        this.slotId = outputSlots[selectedIndex].slotId;
        this.slotName = outputSlots[selectedIndex].slotName;
    }

    if (selectedIndex == -1) {
        /* oops - button shouldn't have been enabled */
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }

    super.okPressed();
}

From source file:com.buildml.eclipse.actions.dialogs.SlotSelectionDialog.java

License:Open Source License

/**
 * Given an action type and a slot "position" add all the slot names to the tab, allowing
 * the slot names to be selected.//from  w w w. j  a va 2s .  c  o m
 * 
 * @param tabFolder      The SWT TabFolder to add the tab to.
 * @param tabTitle      The text string to display at the top of the tab.
 * @param slots         The list of slots to be displayed.
 * @return The newly added List widget (containing the slot names), or null on error.
 */
private List addSlotsToListBox(TabFolder tabFolder, String tabTitle, SlotDetails slots[]) {

    /* create a new tab within the existing TabFolder */
    TabItem slotTab = new TabItem(tabFolder, SWT.NONE);
    slotTab.setText(tabTitle);

    /* Add the list of slot names to the list box */
    List listBox = new List(tabFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    listBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    slotTab.setControl(listBox);
    for (int i = 0; i != slots.length; i++) {
        listBox.add(slots[i].slotName);
    }

    /* 
     * Make sure that selecting an item in this list will deselect all items in
     * the other list. The only makes sense if both lists are shown.
     */
    listBox.addSelectionListener(new SelectionListener() {

        /* a slot was single-clicked */
        @Override
        public void widgetSelected(SelectionEvent e) {
            /* deselect the other list box */
            if (showInputSlots && showOutputSlots) {
                if (e.getSource() == inputSlotListBox) {
                    outputSlotListBox.deselectAll();
                } else {
                    inputSlotListBox.deselectAll();
                }
            }

            /* it's now OK to press "OK" */
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }

        /* a slot was double-clicked */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            okPressed();
        }
    });
    return listBox;
}

From source file:com.buildml.eclipse.utils.NameFilterDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, "Select", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    /* disable the OK button by default, until some text is entered */
    getButton(OK).setEnabled(false);/*  ww w  .j  av a  2s  . co  m*/
}

From source file:com.byterefinery.rmbench.database.mysql.EnumAndSetDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite mainComposite = (Composite) super.createDialogArea(parent);

    mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    mainComposite.setLayout(new GridLayout(2, false));

    inputText = new Text(mainComposite, SWT.BORDER);
    inputText.setLayoutData(new GridData(SWT.FILL, SWT.NULL, true, false));
    inputText.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent e) {
            if (e.character == ',')
                e.doit = false;//from   w  w  w.ja v a  2  s.c  om
        }

    });
    inputText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            updateAddButton();
        }
    });

    addButton = new Button(mainComposite, SWT.PUSH);
    addButton.setImage(RMBenchPlugin.getImage(ImageConstants.ADD));
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String input = inputText.getText().trim();
            inputText.setText("");
            inputText.setFocus();

            types.add(input);
            typesViewer.refresh();
            updateAddButton();
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });

    createListViewer(mainComposite);

    Composite buttonComp = new Composite(mainComposite, SWT.NONE);
    GridData gd = new GridData(SWT.NONE, SWT.FILL, false, true);
    gd.verticalAlignment = SWT.CENTER;
    buttonComp.setLayoutData(gd);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    buttonComp.setLayout(layout);

    deleteButton = new Button(buttonComp, SWT.PUSH);
    deleteButton.setImage(sharedImages.getImage(ISharedImages.IMG_TOOL_DELETE));
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) typesViewer.getSelection();
            int index = types.indexOf(sel.getFirstElement());
            types.remove(index);
            typesViewer.refresh();
            if (index > 0)
                typesViewer.setSelection(new StructuredSelection(types.get(index - 1)));
            else if (types.size() > 0)
                typesViewer.setSelection(new StructuredSelection(types.get(0)));

            inputText.setText("");
            if (types.size() == 0)
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            else
                getButton(IDialogConstants.OK_ID).setEnabled(true);

        }
    });
    upButton = new Button(buttonComp, SWT.PUSH);
    upButton.setImage(RMBenchPlugin.getImage(ImageConstants.UP));
    upButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) typesViewer.getSelection();
            int index = types.indexOf(sel.getFirstElement());
            moveElement(index, index - 1);
            typesViewer.refresh();
        }
    });
    downButton = new Button(buttonComp, SWT.PUSH);
    downButton.setImage(RMBenchPlugin.getImage(ImageConstants.DOWN));
    downButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) typesViewer.getSelection();
            int index = types.indexOf(sel.getFirstElement());
            moveElement(index, index + 1);
            typesViewer.refresh();
        }
    });

    String typesArray[] = dataType.getElements();
    for (int i = 0; i < typesArray.length; i++) {
        types.add(typesArray[i]);
    }

    typesViewer.setInput("");

    return mainComposite;
}

From source file:com.byterefinery.rmbench.dialogs.AbstractDependencyDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
    detailsButton = createButton(parent, IDialogConstants.DETAILS_ID, IDialogConstants.SHOW_DETAILS_LABEL,
            false);/*from  w ww . j  a v a  2s.  c  o  m*/

}

From source file:com.byterefinery.rmbench.dialogs.ForeignKeyConfigurator.java

License:Open Source License

protected Control createDialogArea(Composite container) {

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

    Composite mainGroup = new Composite(parent, SWT.NONE);
    mainGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    mainGroup.setLayout(new GridLayout(3, false));

    viewerHandler = new CheckboxTableHandler(mainGroup);

    Label columnsLabel = new Label(mainGroup, SWT.NONE);
    columnsLabel.setText(Messages.ForeignKeyConfigurator_Columns);
    Label tablesLabel = new Label(mainGroup, SWT.NONE);
    tablesLabel.setText(Messages.ForeignKeyConfigurator_TargetTable);

    columnsViewer = CheckboxTableViewer.newCheckList(mainGroup, SWT.SINGLE | SWT.BORDER);
    columnsViewer.getTable().setLayoutData(createTableGridData());
    columnsViewer.setLabelProvider(new LabelProvider() {
        public Image getImage(Object element) {
            if (((Column) element).belongsToPrimaryKey())
                return RMBenchPlugin.getImage(ImageConstants.KEY);
            return null;
        }//from w w w.j  av a2s.  com

        public String getText(Object element) {
            return ((Column) element).getName();
        }
    });
    viewerHandler.setViewer(columnsViewer, sourceTable.getColumns());
    viewerHandler.addListener(new CheckboxTableHandler.Listener() {
        public void checkMoved(Column column, int oldIndex, int newIndex) {
            computeTargetTables();
        }

        public void checkCountChanged() {
            computeTargetTables();
        }
    });

    org.eclipse.swt.widgets.Table viewerTable = new org.eclipse.swt.widgets.Table(mainGroup,
            SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER);

    TableLayout tableLayout = new TableLayout();
    TableColumn column;

    column = new TableColumn(viewerTable, SWT.NONE);
    column.setText(Messages.ForeignKeyConfigurator_Table_Schema);
    tableLayout.addColumnData(new ColumnWeightData(10));
    column = new TableColumn(viewerTable, SWT.NONE);
    column.setText(Messages.ForeignKeyConfigurator_Table_Name);
    tableLayout.addColumnData(new ColumnWeightData(20));

    viewerTable.setLayout(tableLayout);
    viewerTable.setLayoutData(createTableGridData());

    tablesViewer = new TableViewer(viewerTable);
    tablesViewer.setContentProvider(new ArrayContentProvider());
    tablesViewer.setLabelProvider(new TablesViewerLabelProvider());
    tablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection().isEmpty()) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            } else {
                IStructuredSelection selection = (IStructuredSelection) tablesViewer.getSelection();
                targetTable = (Table) selection.getFirstElement();
                getButton(IDialogConstants.OK_ID).setEnabled(true);
            }
        }
    });

    return parent;
}

From source file:com.byterefinery.rmbench.dialogs.KeyEditorDialog.java

License:Open Source License

protected void updateButtonState() {

    String newName = nameText.getText();
    if (newName.length() == 0 || !viewerHandler.hasChecked() || nameError) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;/*ww  w.j a v  a 2  s.  com*/
    }
    boolean columnsEqual = true;
    Iterator<Column> it = viewerHandler.checkedColumns();
    int i = 0;
    while (it.hasNext() && i < key.size()) {
        Column col = it.next();
        if (col != key.getColumn(i)) {
            columnsEqual = false;
            break;
        }
        i++;
    }
    columnsChanged = !columnsEqual || i != key.size() || it.hasNext();
    nameChanged = !newName.equals(key.getName());
    getButton(IDialogConstants.OK_ID).setEnabled(columnsChanged || nameChanged);
}

From source file:com.byterefinery.rmbench.dialogs.ModelPropertiesDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setEnabled(true);
}

From source file:com.byterefinery.rmbench.dialogs.ModelPropertiesDialog.java

License:Open Source License

protected void updateOKButton() {
    boolean enabled = modelName != null && (!modelName.equals(model.getName())
            || databaseExtension.getDatabaseInfo() != model.getDatabaseInfo()
            || generatorExtension.getNameGenerator() != model.getNameGenerator());

    getButton(IDialogConstants.OK_ID).setEnabled(enabled);
}

From source file:com.byterefinery.rmbench.dialogs.NewDiagramDialog.java

License:Open Source License

protected void updateOKButton() {
    getButton(IDialogConstants.OK_ID).setEnabled(diagramName != null);
}