Example usage for org.eclipse.jface.dialogs DialogMessageArea DialogMessageArea

List of usage examples for org.eclipse.jface.dialogs DialogMessageArea DialogMessageArea

Introduction

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

Prototype

public DialogMessageArea() 

Source Link

Document

Create a new instance of the receiver.

Usage

From source file:au.gov.ga.earthsci.bookmark.part.editor.BookmarkEditorDialog.java

License:Apache License

/**
 * Create the property edit area (right side) used to contain the {@link IBookmarkProperty} editors.
 * <p/>/*from w  ww  . ja  v  a2  s .  c  o  m*/
 * Expects the {@code parent} to have a {@link GridLayout}.
 */
protected Control createPropertyEditArea(Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    container.setLayout(layout);

    final Label leftSeparator = new Label(container, SWT.VERTICAL | SWT.SEPARATOR);
    leftSeparator.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL));

    editorScroller = new ScrolledComposite(container, SWT.V_SCROLL | SWT.H_SCROLL);
    editorScroller.setShowFocusedControl(true);
    editorScroller.setExpandHorizontal(true);
    editorScroller.setExpandVertical(true);
    editorScroller.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    editorScroller.setMinSize(DEFAULT_MIN_PAGE_SIZE);

    final Composite inner = new Composite(editorScroller, SWT.NONE);
    inner.setLayoutData(new GridData(GridData.FILL_BOTH));
    inner.setLayout(new GridLayout());

    editorScroller.setContent(inner);
    editorScroller.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            updateScrollerMinSize();
        }
    });

    messageArea = new DialogMessageArea();
    messageArea.createContents(inner);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    messageArea.setTitleLayoutData(gd);
    messageArea.setMessageLayoutData(gd);

    Label separator = new Label(inner, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    editorInclusionArea = new Composite(inner, SWT.NONE);
    editorInclusionArea.setLayout(new GridLayout());
    editorInclusionArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    editorInclusionCheck = new Button(editorInclusionArea, SWT.CHECK);
    editorInclusionCheck.setText(Messages.BookmarkEditorDialog_IncludeInBookmarkLabel);
    editorInclusionCheck.setSelection(true);
    editorInclusionCheck.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateEditorIncluded(editorInclusionCheck.getSelection());
        }
    });

    editorContainer = new Composite(inner, SWT.NONE);
    editorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    editorContainer.setLayout(new GridLayout());

    editorButtonBar = new Composite(inner, SWT.RIGHT_TO_LEFT);
    editorButtonBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    editorButtonBar.setLayout(new RowLayout());

    resetButton = new Button(editorButtonBar, SWT.NONE);
    resetButton.setText(Messages.BookmarkEditorDialog_ResetValuesLabel);
    resetButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (currentEditor == null) {
                return;
            }
            currentEditor.restoreOriginalValues();
        }
    });

    fillFromCurrentButton = new Button(editorButtonBar, SWT.NONE);
    fillFromCurrentButton.setText(Messages.BookmarkEditorDialog_FillFromCurrentLabel);
    fillFromCurrentButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (currentEditor == null || !(currentEditor instanceof IBookmarkPropertyEditor)) {
                return;
            }
            ((IBookmarkPropertyEditor) currentEditor).fillFromCurrent();
        }
    });

    return container;
}

From source file:com.ge.research.sadl.ui.preferences.ReasonerConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override//  ww w .  j a v  a2 s.c  om
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config != null) {
                for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                    String key = entry.getKey();
                    ConfigurationOption option = entry.getValue();
                    if (key.equalsIgnoreCase("builtin")) {
                        continue;
                    }
                    String optionDescription = option.getDescription();
                    Object currentValue = currentConfig.get(key);
                    Object optionValue = option.getValue();
                    if (currentValue != null) {
                        optionValue = currentValue;
                    }
                    logger.debug(key + " class = " + optionValue.getClass().getName());
                    Object[] optionPossibleValues = option.getPossibleValues();
                    if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                        // Option has a list of values so create a dropdown box
                        String[][] nv = new String[optionPossibleValues.length][2];
                        for (int i = 0; i < optionPossibleValues.length; i++) {
                            nv[i][0] = optionPossibleValues[i].toString();
                            nv[i][1] = optionPossibleValues[i].toString();
                        }
                        editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                        editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                        editor = new BooleanFieldEditor(key, optionDescription,
                                BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                        editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.setPage(page);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                        editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    }
                }
            } else {
                logger.info("No configuration options available");
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(reasonerCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.preferences.TranslatorConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*from www  . j  ava2 s .  c o  m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config == null) {
                messageArea.updateText("No options available", IMessageProvider.NONE);
                return;
            }
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(
                        key + " class = " + (optionValue != null ? optionValue.getClass().getName() : "null"));
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue == null) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(translatorCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.properties.ReasonerConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/* w ww . j a v a 2 s. c o  m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(key + " class = " + optionValue.getClass().getName());
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(reasonerCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.properties.TranslatorConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override//from   w w w  .  j a  v a  2 s  . c om
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config == null) {
                messageArea.updateText("No options available", IMessageProvider.NONE);
                return;
            }
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(key + " class = " + optionValue.getClass().getName());
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(translatorCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.mindquarry.desktop.preferences.dialog.FilteredPreferenceDialog.java

License:Open Source License

/**
 * Creates the wizard's title area.// w  w  w.j  a  v a  2 s. c  o m
 * 
 * @param parent the SWT parent for the title area composite.
 * @return the created title area composite.
 */
protected Composite createTitleArea(Composite parent) {
    // Create the title area which will contain
    // a title, message, and image.
    int margins = 2;
    titleArea = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = margins;
    titleArea.setLayout(layout);

    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = SWT.TOP;
    titleArea.setLayoutData(layoutData);

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(titleArea);

    titleArea.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            updateMessage();
        }
    });

    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
                updateMessage();
            }
            if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) {
                updateMessage();
                Font dialogFont = JFaceResources.getDialogFont();
                updateTreeFont(dialogFont);
                Control[] children = ((Composite) buttonBar).getChildren();
                for (int i = 0; i < children.length; i++) {
                    children[i].setFont(dialogFont);
                }
            }
        }
    };

    titleArea.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontListener);
    messageArea.setTitleLayoutData(createMessageAreaData());
    messageArea.setMessageLayoutData(createMessageAreaData());
    return titleArea;
}

From source file:net.refractions.udig.style.sld.editor.internal.EditorDialog.java

License:Open Source License

/**
 * Creates the wizard's title area.//  w w w. j a va  2 s.c  om
 * 
 * @param parent
 *            the SWT parent for the title area composite.
 * @return the created title area composite.
 */
protected Composite createTitleArea(Composite parent) {
    // Create the title area which will contain
    // a title, message, and image.
    int margins = 2;
    titleArea = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = margins;
    titleArea.setLayout(layout);

    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = SWT.TOP;
    titleArea.setLayoutData(layoutData);

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(titleArea);

    titleArea.addControlListener(new ControlAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
         */
        @Override
        public void controlResized(ControlEvent e) {
            updateMessage();
        }
    });

    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (JFaceResources.BANNER_FONT.equals(event.getProperty()))
                updateMessage();
            if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) {
                updateMessage();
                Font dialogFont = JFaceResources.getDialogFont();
                updateTreeFont(dialogFont);
                Control[] children = ((Composite) buttonBar).getChildren();
                for (int i = 0; i < children.length; i++)
                    children[i].setFont(dialogFont);
            }
        }
    };

    titleArea.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontListener);
    messageArea.setTitleLayoutData(createMessageAreaData());
    messageArea.setMessageLayoutData(createMessageAreaData());
    return titleArea;
}

From source file:net.sf.jmoney.importer.matcher.PatternMatchingDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(composite);

    // Ensure the message area is shown and fills the space
    messageArea.setTitleLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    messageArea.setMessageLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    messageArea.showTitle("Options for Statement Import", null);
    /*/*  w  w  w .  ja va  2 s  .c  o m*/
     * It should not be possible for there to be errors when the dialog box is first
     * opened, because we don't allow the user to save the data when there are errors.
     * However, just in case, we ensure that any errors are shown. 
     */
    updateErrorMessage();

    createSampleEntryArea(composite).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label label = new Label(composite, SWT.WRAP);
    label.setText("JMoney allows you to import bank account statements from the bank's servers. "
            + "Before these records can be imported into JMoney, you must specify categories that are to be assigned to each entry "
            + "because a requirement of JMoney is that all entries have an account or category assigned. "
            + "Categories can be assigned based on regex pattern matching.");

    GridData messageData = new GridData();
    Rectangle rect = getShell().getMonitor().getClientArea();
    messageData.widthHint = rect.width / 2;
    label.setLayoutData(messageData);

    reconcilableButton = new Button(composite, SWT.CHECK);
    reconcilableButton.setText("Statements can be imported?");

    final Composite stackContainer = new Composite(composite, 0);

    final StackLayout stackLayout = new StackLayout();
    stackContainer.setLayout(stackLayout);

    GridData containerData = new GridData(SWT.FILL, SWT.FILL, true, true);
    containerData.grabExcessHorizontalSpace = true;
    containerData.grabExcessVerticalSpace = true;
    stackContainer.setLayoutData(containerData);

    // Create the control containing the controls to be shown when 'is reconcilable'
    final Control whenIsReconcilableControl = createCategoryControls(stackContainer);

    reconcilableButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean isReconcilable = reconcilableButton.getSelection();
            account.setReconcilable(isReconcilable);

            if (reconcilableButton.getSelection()) {
                stackLayout.topControl = whenIsReconcilableControl;
            } else {
                stackLayout.topControl = null;
            }
            stackContainer.layout(false);

            updateErrorMessage();
        }
    });

    reconcilableButton.setSelection(account.isReconcilable());
    if (account.isReconcilable()) {
        stackLayout.topControl = whenIsReconcilableControl;
        defaultAccountControl.setAccount(account.getDefaultCategory());
    }

    defaultAccountControl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IncomeExpenseAccount defaultCategory = defaultAccountControl.getAccount();
            account.setDefaultCategory(defaultCategory);
            updateErrorMessage();
        }
    });
    applyDialogFont(composite);
    return composite;
}

From source file:net.sf.jmoney.reconciliation.reconcilePage.ImportOptionsDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(composite);

    // Ensure the message area is shown and fills the space
    messageArea.setTitleLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    messageArea.setMessageLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    messageArea.showTitle("Options for Statement Import", null);
    /*//from  w w w  .j a v a  2 s  .co m
     * It should not be possible for there to be errors when the dialog box is first
     * opened, because we don't allow the user to save the data when there are errors.
     * However, just in case, we ensure that any errors are shown. 
     */
    updateErrorMessage();

    Label label = new Label(composite, SWT.WRAP);
    label.setText("JMoney allows you to import bank account statements from the bank's servers. "
            + "Before these records can be imported into JMoney, you must specify categories that are to be assigned to each entry "
            + "because a requirement of JMoney is that all entries have an account or category assigned. "
            + "Categories can be assigned based on regex pattern matching.");

    GridData messageData = new GridData();
    Rectangle rect = getShell().getMonitor().getClientArea();
    messageData.widthHint = rect.width / 2;
    label.setLayoutData(messageData);

    reconcilableButton = new Button(composite, SWT.CHECK);
    reconcilableButton.setText("Statements can be imported?");

    final Composite stackContainer = new Composite(composite, 0);

    final StackLayout stackLayout = new StackLayout();
    stackContainer.setLayout(stackLayout);

    GridData containerData = new GridData(SWT.FILL, SWT.FILL, true, true);
    containerData.grabExcessHorizontalSpace = true;
    containerData.grabExcessVerticalSpace = true;
    stackContainer.setLayoutData(containerData);

    // Create the control containing the controls to be shown when 'is reconcilable'
    final Control whenIsReconcilableControl = createCategoryControls(stackContainer);

    reconcilableButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean isReconcilable = reconcilableButton.getSelection();
            account.setReconcilable(isReconcilable);

            if (reconcilableButton.getSelection()) {
                stackLayout.topControl = whenIsReconcilableControl;
            } else {
                stackLayout.topControl = null;
            }
            stackContainer.layout(false);

            updateErrorMessage();
        }
    });

    reconcilableButton.setSelection(account.isReconcilable());
    if (account.isReconcilable()) {
        stackLayout.topControl = whenIsReconcilableControl;
        defaultAccountControl.setAccount(account.getDefaultCategory());
    }

    defaultAccountControl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IncomeExpenseAccount defaultCategory = defaultAccountControl.getAccount();
            account.setDefaultCategory(defaultCategory);
            updateErrorMessage();
        }
    });
    applyDialogFont(composite);
    return composite;
}

From source file:net.sf.jmoney.stocks.model.RatesDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(composite);

    // What are these for?
    //      messageArea.setTitleLayoutData(createMessageAreaData());
    //      messageArea.setMessageLayoutData(createMessageAreaData());

    Label label = new Label(composite, SWT.WRAP);
    label.setText(//from w w  w.j  av a  2 s  . c  o m
            "Setup the rates.  This allows JMoney to calculate the various commissions and taxes for you. "
                    + "A commission or tax may include a fixed amount and percentages.  The percentages may vary based on the amount of the purchase or sale.");

    GridData messageData = new GridData();
    Rectangle rect = getShell().getMonitor().getClientArea();
    messageData.widthHint = rect.width / 2;
    label.setLayoutData(messageData);

    control = new RatesEditorControl(composite);
    control.setRatesTable(rates, currencyForFormatting);

    applyDialogFont(composite);
    return composite;
}