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

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

Introduction

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

Prototype

int BUTTON_BAR_HEIGHT

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

Click Source Link

Document

Height of button bar in dialog units (value 25).

Usage

From source file:org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard.EntitiesList.java

License:Open Source License

public void createControl(Composite parent) {
    initializeDialogUnits(parent);/*from   ww  w .  j a va 2  s.co m*/
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 1;
    //Label label = new Label(container, SWT.NULL);
    //label.setText(JdtUiMessages.AllEntitiesProcessor_message);

    listViewer = new TableViewer(container, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    //listViewer.setComparator(getViewerComparator());
    Control control = listViewer.getControl();
    GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    gridData.heightHint = convertHeightInCharsToPixels(10);
    control.setLayoutData(gridData);
    String[] columnProperties = new String[] { Columns.CLASS.toString(), Columns.PROJECT.toString(), };
    listViewer.setColumnProperties(columnProperties);
    listViewer.setContentProvider(createContentProvider(data));
    listViewer.setLabelProvider(new TableLableProvider(listViewer));
    createTableColumns(listViewer.getTable());
    listViewer.setInput(data.getEntities());
    listViewer.getTable().setHeaderVisible(true);
    listViewer.getTable().setLinesVisible(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
            .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
                    convertHorizontalDLUsToPixels(2 * IDialogConstants.BUTTON_BAR_HEIGHT))
            .applyTo(listViewer.getControl());
    //Button generateChoice = new Button(container, SWT.CHECK);
    //generateChoice.setText("fdwsdfv");
    Composite combolabel = new Composite(container, SWT.NULL);
    layout = new GridLayout();
    combolabel.setLayout(layout);
    layout.numColumns = 2;
    Label labelChoice = new Label(combolabel, SWT.NULL);
    labelChoice.setText(JdtUiMessages.AllEntitiesProcessor_preferred_location_annotations);
    Combo generateChoice = new Combo(combolabel, SWT.READ_ONLY);
    generateChoice.add(JdtUiMessages.AllEntitiesProcessor_fields);
    generateChoice.add(JdtUiMessages.AllEntitiesProcessor_getters);
    generateChoice.add(JdtUiMessages.AllEntitiesProcessor_auto_select_from_class_preference);
    int idx = 0;
    if (params.getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
        idx = 0;
    } else if (params.getAnnotationStyle().equals(AnnotStyle.GETTERS)) {
        idx = 1;
    } else if (params.getAnnotationStyle().equals(AnnotStyle.AUTO)) {
        idx = 2;
    }
    generateChoice.select(idx);
    final ModifyListener mlGenerateChoice = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            int idx = ((Combo) e.getSource()).getSelectionIndex();
            if (idx == 0 && !params.getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
                params.setAnnotationStyle(AnnotStyle.FIELDS);
                params.reCollectModification(data.getEntities());
            } else if (idx == 1 && !params.getAnnotationStyle().equals(AnnotStyle.GETTERS)) {
                params.setAnnotationStyle(AnnotStyle.GETTERS);
                params.reCollectModification(data.getEntities());
            } else if (idx == 2 && !params.getAnnotationStyle().equals(AnnotStyle.AUTO)) {
                params.setAnnotationStyle(params.getAnnotationStylePreference());
                params.reCollectModification(data.getEntities());
                params.setAnnotationStyle(AnnotStyle.AUTO);
            }
        }

    };
    generateChoice.addModifyListener(mlGenerateChoice);

    Label labelDefaultStrLength = new Label(combolabel, SWT.NULL);
    labelDefaultStrLength.setText(JdtUiMessages.AllEntitiesProcessor_default_string_length);
    Text textDefaultStrLength = new Text(combolabel, SWT.SINGLE | SWT.BORDER | SWT.TRAIL);
    textDefaultStrLength.setText(String.valueOf(params.getDefaultStrLength()));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(textDefaultStrLength);
    textDefaultStrLength.addListener(SWT.Verify, new Listener() {
        public void handleEvent(Event e) {
            for (int i = 0; i < e.text.length(); i++) {
                char val = e.text.charAt(i);
                if (!('0' <= val && val <= '9')) {
                    e.doit = false;
                    return;
                }
            }
        }
    });
    final ModifyListener mlDefaultStrLength = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (e == null || !(e.getSource() instanceof Text)) {
                return;
            }
            String str = ((Text) e.getSource()).getText();
            Integer val = IHibernateJPAWizardParams.columnLength;
            if (str != null && str.length() > 0) {
                val = Integer.valueOf(str);
            }
            params.setDefaultStrLength(val);
            params.reCollectModification(data.getEntities());
        }

    };
    textDefaultStrLength.addModifyListener(mlDefaultStrLength);

    // enable optimistic locking functionality
    Label labelOptLock = new Label(combolabel, SWT.NULL);
    labelOptLock.setText(JdtUiMessages.AllEntitiesProcessor_enable_optimistic_locking);
    Button checkboxOptLock = new Button(combolabel, SWT.CHECK);
    checkboxOptLock.setSelection(params.getEnableOptLock());
    final Listener mlOptLock = new Listener() {

        public void handleEvent(Event e) {
            params.setEnableOptLock(((Button) e.widget).getSelection());
            params.reCollectModification(data.getEntities());
        }

    };
    checkboxOptLock.addListener(SWT.Selection, mlOptLock);

    setControl(container);
}

From source file:org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite.java

License:Open Source License

/**
 * Create font tool bar group/*from   w  ww .  jav a2  s. c om*/
 * 
 * @param parent - parent composite
 * @return - font tool bar
 */
protected Composite createFontsGroup(Composite parent) {
    Composite familySize = getWidgetFactory().createComposite(parent);
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    familySize.setLayout(layout);

    fontFamilyCombo = getWidgetFactory().createCCombo(familySize, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    fontFamilyCombo.setItems(FontHelper.getFontNames());
    fontFamilyCombo.setText((String) note.getPropertyValue(EParameterName.NOTE_FONT.getName()));
    fontFamilyCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            updateFontFamily();
        }
    });

    fontSizeCombo = getWidgetFactory().createCCombo(familySize, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    fontSizeCombo.setItems(FontHelper.getFontSizes());
    fontSizeCombo.setText((String) note.getPropertyValue(EParameterName.FONT_SIZE.getName()));
    fontSizeCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            updateFontSize();
        }
    });

    Composite toolBar = new Composite(parent, SWT.SHADOW_NONE);
    toolBar.setLayout(new GridLayout(7, false));
    toolBar.setBackground(parent.getBackground());

    fontBoldButton = new Button(toolBar, SWT.TOGGLE);
    fontBoldButton.setImage(ImageProvider.getImage(EImage.BOLD_ICON));
    fontBoldButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Bold";
        }
    });

    fontItalicButton = new Button(toolBar, SWT.TOGGLE);
    fontItalicButton.setImage(ImageProvider.getImage(EImage.ITALIC_ICON));
    fontItalicButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Italic";
        }
    });

    fontBoldButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            updateFontBold();
        }
    });

    fontItalicButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            updateFontItalic();
        }
    });

    new Label(toolBar, SWT.LEFT);

    fontColorButton = new Button(toolBar, SWT.PUSH);
    Image overlyedImage = new ColorOverlayImageDescriptor(
            ImageProvider.getImageDesc(EImage.FONT_COLOR_ICON).getImageData(),
            ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName())))
                    .createImage();
    fontColorButton.setImage(overlyedImage);
    fontColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Font Color";
        }
    });
    fontColorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            ColorPalettePopup popup = new ColorPalettePopup(fontColorButton.getParent().getShell(),
                    IDialogConstants.BUTTON_BAR_HEIGHT);
            Rectangle r = fontColorButton.getBounds();
            Point location = fontColorButton.getParent().toDisplay(r.x, r.y);
            popup.open(new Point(location.x, location.y + r.height));

            if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
                return;
            }
            // selectedColor should be null if we are to use the default color
            RGB selectedColor = popup.getSelectedColor();
            if (popup.useDefaultColor()) {
                selectedColor = new RGB(0, 0, 0);
            }
            if (selectedColor != null) {
                String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue; //$NON-NLS-1$ //$NON-NLS-2$
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTETXT_COLOR.getName(), value);
                getCommandStack().execute(cmd);
                note.refresh();
                Image overlyedImage = new ColorOverlayImageDescriptor(
                        ImageProvider.getImageDesc(EImage.FONT_COLOR_ICON).getImageData(), selectedColor)
                                .createImage();
                fontColorButton.setImage(overlyedImage);
                text.setForeground(new Color(null, ColorUtils
                        .stringToRGB((String) note.getPropertyValue(EParameterName.NOTETXT_COLOR.getName()))));
            }
        }
    });
    new Label(toolBar, SWT.LEFT);

    lineColorButton = new Button(toolBar, SWT.PUSH);
    overlyedImage = new ColorOverlayImageDescriptor(
            ImageProvider.getImageDesc(EImage.LINE_COLOR_ICON).getImageData(),
            ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTE_LINECOLOR.getName())))
                    .createImage();
    lineColorButton.setImage(overlyedImage);
    lineColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Line Color";
        }
    });
    lineColorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            ColorPalettePopup popup = new ColorPalettePopup(lineColorButton.getParent().getShell(),
                    IDialogConstants.BUTTON_BAR_HEIGHT);
            Rectangle r = lineColorButton.getBounds();
            Point location = lineColorButton.getParent().toDisplay(r.x, r.y);
            popup.open(new Point(location.x, location.y + r.height));

            if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
                return;
            }
            // selectedColor should be null if we are to use the default color
            RGB selectedColor = popup.getSelectedColor();
            if (popup.useDefaultColor()) {
                selectedColor = new RGB(237, 201, 122);
            }
            if (selectedColor != null) {
                String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue; //$NON-NLS-1$ //$NON-NLS-2$
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTE_LINECOLOR.getName(), value);
                getCommandStack().execute(cmd);
                note.refresh();
                Image overlyedImage = new ColorOverlayImageDescriptor(
                        ImageProvider.getImageDesc(EImage.LINE_COLOR_ICON).getImageData(), selectedColor)
                                .createImage();
                lineColorButton.setImage(overlyedImage);
            }
        }
    });

    fillColorButton = new Button(toolBar, SWT.PUSH);
    overlyedImage = new ColorOverlayImageDescriptor(
            ImageProvider.getImageDesc(EImage.FILL_COLOR_ICON).getImageData(),
            ColorUtils.stringToRGB((String) note.getPropertyValue(EParameterName.NOTE_COLOR.getName())))
                    .createImage();
    fillColorButton.setImage(overlyedImage);
    fillColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Fill Color";
        }
    });
    fillColorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            ColorPalettePopup popup = new ColorPalettePopup(fillColorButton.getParent().getShell(),
                    IDialogConstants.BUTTON_BAR_HEIGHT);
            Rectangle r = fillColorButton.getBounds();
            Point location = fillColorButton.getParent().toDisplay(r.x, r.y);
            popup.open(new Point(location.x, location.y + r.height));

            if (popup.getSelectedColor() == null && !popup.useDefaultColor()) {
                return;
            }
            // selectedColor should be null if we are to use the default color
            RGB selectedColor = popup.getSelectedColor();
            if (popup.useDefaultColor()) {
                selectedColor = new RGB(255, 255, 203);
            }
            if (selectedColor != null) {
                String value = selectedColor.red + ";" + selectedColor.green + ";" + selectedColor.blue; //$NON-NLS-1$ //$NON-NLS-2$
                Command cmd = new PropertyChangeCommand(note, EParameterName.NOTE_COLOR.getName(), value);
                getCommandStack().execute(cmd);
                note.refresh();
                Image overlyedImage = new ColorOverlayImageDescriptor(
                        ImageProvider.getImageDesc(EImage.FILL_COLOR_ICON).getImageData(), selectedColor)
                                .createImage();
                fillColorButton.setImage(overlyedImage);
            }
        }
    });

    return toolBar;
}