Example usage for org.eclipse.jface.util IPropertyChangeListener IPropertyChangeListener

List of usage examples for org.eclipse.jface.util IPropertyChangeListener IPropertyChangeListener

Introduction

In this page you can find the example usage for org.eclipse.jface.util IPropertyChangeListener IPropertyChangeListener.

Prototype

IPropertyChangeListener

Source Link

Usage

From source file:aktie.gui.CocoaUIEnhancer.java

License:Open Source License

/**
Modify the given workbench window shell bits to show the tool bar toggle
button./*from   w  w  w .jav a  2 s.com*/
        
@param window
          the window to modify
@since 3.2
*/
protected void modifyWindowShell(final IWorkbenchWindow window) {
    // only add the button when either the cool bar or perspective bar
    // is initially visible. This is so that RCP applications can choose to
    // use
    // this fragment without fear that their explicitly invisible bars
    // can't be shown.
    boolean coolBarInitiallyVsible = ((WorkbenchWindow) window).getCoolBarVisible();
    boolean perspectiveBarInitiallyVsible = ((WorkbenchWindow) window).getPerspectiveBarVisible();

    if (coolBarInitiallyVsible || perspectiveBarInitiallyVsible) {
        createDummyToolbar(window);
    }

    else {
        // add the dummby toolbar when its shown for the first time
        if (!(window instanceof WorkbenchWindow)) {
            return;
        }

        final WorkbenchWindow workbenchWindow = (WorkbenchWindow) window;
        workbenchWindow.addPropertyChangeListener(new IPropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent event) {
                if (WorkbenchWindow.PROP_COOLBAR_VISIBLE.equals(event.getProperty())) {
                    createDummyToolbar(window);
                    workbenchWindow.removePropertyChangeListener(this);
                }

            }

        });

    }

}

From source file:ar.com.tadp.xml.rinzo.core.preferences.ColorPreferenceEditor.java

License:Open Source License

public ColorChooser getColorChooserControl(Composite parent) {
    if (colorChooser == null) {
        colorChooser = new ColorChooser(parent, 0);

        colorChooser.addPropertyChangeListener(new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                int index = list.getSelectionIndex();
                ColorPreferenceModel cpm = colorModelList.get(index);
                cpm.setColorValue(colorChooser.getColorValue());
            }/*from  w ww.ja va 2s .c  om*/
        });

        colorChooser.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e) {
                int index = list.getSelectionIndex();
                ColorPreferenceModel cpm = colorModelList.get(index);
                cpm.setBold(colorChooser.isBold());
            }

            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });

        colorChooser.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent event) {
                colorChooser = null;
            }
        });
    } else {
        checkParent(colorChooser, parent);
    }
    return colorChooser;
}

From source file:au.gov.ga.earthsci.common.ui.color.ColorMapEditor.java

License:Apache License

/**
 * Add the entry editor area. Allows users to edit:
 * <ul>//from   www.j  a  v  a  2 s  .  c o m
 * <li>Value
 * <li>Colour
 * <li>Transparency
 * </ul>
 * For a single selected entry in the colour map
 */
private void addEntryEditor(Composite parent) {
    Composite editorContainer = new Composite(parent, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    editorContainer.setLayoutData(gd);
    editorContainer.setLayout(new GridLayout(7, false));

    Label valueLabel = new Label(editorContainer, SWT.NONE);
    valueLabel.setText(Messages.ColorMapEditor_EntryValueLabel);
    editorValueField = new NumericTextField(editorContainer, SWT.SINGLE | SWT.BORDER);
    editorValueField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            map.moveEntry(currentEntryValue, editorValueField.getNumber().doubleValue());
            currentEntryValue = editorValueField.getNumber().doubleValue();
        }
    });

    Label colorLabel = new Label(editorContainer, SWT.NONE);
    colorLabel.setText(Messages.ColorMapEditor_EntryColorLabel);
    editorColorField = new ColorSelector(editorContainer);
    editorColorField.addListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateCurrentEntryColor();
        }
    });

    Label alphaLabel = new Label(editorContainer, SWT.NONE);
    alphaLabel.setText(Messages.ColorMapEditor_EntryAlphaLabel);

    editorAlphaScale = new Scale(editorContainer, SWT.HORIZONTAL);
    editorAlphaScale.setMinimum(0);
    editorAlphaScale.setMaximum(255);
    editorAlphaScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    editorAlphaField = new NumericTextField(editorContainer, SWT.BORDER, false, false);
    editorAlphaField.setMinValue(0);
    editorAlphaField.setMaxValue(255);
    gd = new GridData();
    gd.widthHint = 35;
    editorAlphaField.setLayoutData(gd);

    editorAlphaScale.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateCurrentEntryColor();
            editorAlphaField.setNumber(editorAlphaScale.getSelection());
        }
    });

    editorAlphaField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            editorAlphaScale.setSelection(editorAlphaField.getNumber().intValue());
            updateCurrentEntryColor();
        }
    });

    disableEntryEditor();
}

From source file:au.gov.ga.earthsci.common.ui.color.ColorMapEditor.java

License:Apache License

/**
 * Add an editor area for changing the NODATA colour used
 *///w  ww. j  a v a2 s .c  om
private void addNodataEditor(Composite parent) {
    Composite editorContainer = new Composite(parent, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    editorContainer.setLayoutData(gd);
    editorContainer.setLayout(new GridLayout(7, false));

    nodataCheckBox = new Button(editorContainer, SWT.CHECK);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 7;
    nodataCheckBox.setLayoutData(gd);
    nodataCheckBox.setText(Messages.ColorMapEditor_NoDataOptionLabel);
    nodataCheckBox.setToolTipText(Messages.ColorMapEditor_NoDataOptionTooltip);
    nodataCheckBox.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            enableNodataEditor(nodataCheckBox.getSelection());
            updateNodataColorFromEditor();
        }
    });

    Label colorLabel = new Label(editorContainer, SWT.NONE);
    colorLabel.setText("Color:"); //$NON-NLS-1$
    nodataColorField = new ColorSelector(editorContainer);
    nodataColorField.addListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateNodataColorFromEditor();
        }
    });
    nodataColorField.setColorValue(toRGB(Color.BLACK));

    Label alphaLabel = new Label(editorContainer, SWT.NONE);
    alphaLabel.setText("Alpha:"); //$NON-NLS-1$

    nodataAlphaScale = new Scale(editorContainer, SWT.HORIZONTAL);
    nodataAlphaScale.setMinimum(0);
    nodataAlphaScale.setMaximum(255);
    nodataAlphaScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    nodataAlphaScale.setSelection(255);

    nodataAlphaField = new NumericTextField(editorContainer, SWT.BORDER, false, false);
    nodataAlphaField.setMinValue(0);
    nodataAlphaField.setMaxValue(255);
    gd = new GridData();
    gd.widthHint = 35;
    nodataAlphaField.setLayoutData(gd);
    nodataAlphaField.setNumber(255);

    nodataAlphaScale.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateNodataColorFromEditor();
            nodataAlphaField.setNumber(nodataAlphaScale.getSelection());
        }
    });

    nodataAlphaField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            nodataAlphaScale.setSelection(nodataAlphaField.getNumber().intValue());
            updateNodataColorFromEditor();
        }
    });

    updateNodataEditorFromMap();
}

From source file:br.org.isvi.mgadmin.cocoa.CocoaUIEnhancer.java

License:Open Source License

/**
 * Modify the given workbench window shell bits to show the tool bar toggle
 * button.//from  w w w  .j a v  a2s . c o m
 * 
 * @param window
 *            the window to modify
 * @since 3.2
 */
protected void modifyWindowShell(final IWorkbenchWindow window) {
    // only add the button when either the cool bar or perspective bar
    // is initially visible. This is so that RCP applications can choose to
    // use
    // this fragment without fear that their explicitly invisible bars
    // can't be shown.
    boolean coolBarInitiallyVsible = ((WorkbenchWindow) window).getCoolBarVisible();
    boolean perspectiveBarInitiallyVsible = ((WorkbenchWindow) window).getPerspectiveBarVisible();

    if (coolBarInitiallyVsible || perspectiveBarInitiallyVsible) {
        createDummyToolbar(window);
    } else {
        // add the dummby toolbar when its shown for the first time
        if (!(window instanceof WorkbenchWindow))
            return;
        final WorkbenchWindow workbenchWindow = (WorkbenchWindow) window;
        workbenchWindow.addPropertyChangeListener(new IPropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent event) {
                if (WorkbenchWindow.PROP_COOLBAR_VISIBLE.equals(event.getProperty())) {
                    createDummyToolbar(window);
                    workbenchWindow.removePropertyChangeListener(this);
                }
            }
        });
    }
}

From source file:ca.edchipman.silverstripepdt.dialogs.FilteredTypesSelectionDialog.java

License:Open Source License

protected void fillViewMenu(IMenuManager menuManager) {
    super.fillViewMenu(menuManager);

    if (fAllowScopeSwitching) {
        fFilterActionGroup = new WorkingSetFilterActionGroup(getShell(), DLTKUIPlugin.getActivePage(),
                new IPropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent event) {
                        IWorkingSet ws = (IWorkingSet) event.getNewValue();
                        if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
                            setSearchScope(SearchEngine.createWorkspaceScope(fToolkit));
                            setSubtitle(null);
                        } else {
                            setSearchScope(
                                    DLTKSearchScopeFactory.getInstance().createSearchScope(ws, true, fToolkit));
                            setSubtitle(ws.getLabel());
                        }// w  w  w.  ja  va2  s. co  m

                        applyFilter();
                    }
                });
        fFilterActionGroup.fillViewMenu(menuManager);
    }

    // menuManager.add(new Separator());
    // menuManager.add(new TypeFiltersPreferencesAction());
}

From source file:ca.uvic.cs.tagsea.monitoring.internal.Monitoring.java

License:Open Source License

/**
 * @param monitors2//from  w ww  .  j a va2 s  . c  o m
 */
private void hookPreferences() {
    IPreferenceStore prefs = TagSEAPlugin.getDefault().getPreferenceStore();
    prefs.addPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            String prop = event.getProperty();
            boolean active = false;
            try {
                active = Boolean.parseBoolean(event.getNewValue().toString());
            } catch (Exception e) {
                return;
            }
            ITagSEAMonitor monitor = getMonitorForPreference(prop);
            if (monitor != null) {
                synchronized (monitors) {
                    if (active) {
                        activate(monitor);
                        monitors.add(monitor);
                    } else {
                        monitors.remove(monitor);
                    }
                }
            }
        }
    });
}

From source file:carisma.ui.eclipse.editors.AdfEditorMasterDetailsBlock.java

License:Open Source License

/**
 * Creates the selected editor combo box.
 * /*from  w w w  . j av  a  2 s .  c o  m*/
 * @param toolkit
 *            The FormToolKit where the button is created
 * @param composite
 *            The corresponding Composite
 */
private void createSelectedEditorCombo(final FormToolkit toolkit, final Composite composite) {
    toolkit.createLabel(composite, "Associated Editor:");

    this.selectedEditorCombo = new Combo(composite, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
    gridData.horizontalIndent = 6;
    this.selectedEditorCombo.setLayoutData(gridData);
    // The enable state will be updated later. Have to false for now
    // See updateGuiEnableState(..) for more information
    this.selectedEditorCombo.setEnabled(false);

    // Information icon if priority queue is used
    this.selectedEditorDecoration = new ControlDecoration(this.selectedEditorCombo, SWT.LEFT | SWT.TOP);
    Image questionDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage();
    this.selectedEditorDecoration.setImage(questionDecoration);
    this.selectedEditorDecoration.setShowHover(true);

    // Change Listener for the EDITOR_SELECTION_ART property
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (event.getProperty().equals(Constants.EDITOR_SELECTION_ART)) {
                String editorSelectionArt = event.getNewValue().toString();
                if (editorSelectionArt.equals(Constants.AUTO)) {
                    AdfEditorMasterDetailsBlock.this.selectedEditorPriorityListEnabled = true;
                } else {
                    AdfEditorMasterDetailsBlock.this.selectedEditorPriorityListEnabled = false;
                }
                updateOpenModelButtonEnable();
            }
        }
    };
    CarismaGUI.INSTANCE.getPreferenceStore().addPropertyChangeListener(propertyChangeListener);

    // Selection Listener
    final EditorRegistry editorRegistry = CarismaGUI.INSTANCE.getEditorRegistry();
    this.selectedEditorCombo.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            String actualSelectedEditorName = AdfEditorMasterDetailsBlock.this.selectedEditorCombo
                    .getItem(AdfEditorMasterDetailsBlock.this.selectedEditorCombo.getSelectionIndex());
            if (!actualSelectedEditorName.equals(DEFAULT_EDITOR)) {
                EditorDescriptor actualEditorDescriptor = editorRegistry
                        .getEditorDescriptorByName(actualSelectedEditorName);
                AdfEditorMasterDetailsBlock.this.controller.setSelectedEditorId(actualEditorDescriptor.getId());
            } else {
                AdfEditorMasterDetailsBlock.this.controller.setSelectedEditorId(DEFAULT_EDITOR);
            }
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            //TODO: Why empty?
        }
    });

    // Add dispose listener to remove PropertyChangeListeners
    composite.getParent().addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent e) {
            CarismaGUI.INSTANCE.getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
        }
    });
}

From source file:carisma.ui.eclipse.preferences.pages.Carisma_index.java

License:Open Source License

/**
 * //  w  ww .ja v a 2 s. co m
 * @param composite the composite
 */
private void selectEditor(final Composite composite) {

    this.editors = new EditorRadioGroupFieldEditor(Constants.EDITOR_SELECTION_ART, "Open a Model with", 1,
            new String[][] { { "&Editor selection combo box", Constants.MANUALLY },
                    { "&Use editor priority list", Constants.AUTO }, },
            composite, true, getPreferenceStore().getString(Constants.EDITOR_SELECTION_ART));

    this.editors.setPage(this);
    this.editors.setPreferenceStore(getPreferenceStore());
    this.editors.load();

    this.edGroup = new Group(composite, SWT.NONE);

    this.list = new EditorPriorityList(Constants.EDITORS_LIST, "Editor priority list", this.edGroup);
    this.list.setPage(this);
    this.list.setPreferenceStore(getPreferenceStore());
    this.list.load();

    selectionArtChanged(getPreferenceStore().getString(Constants.EDITOR_SELECTION_ART));

    this.editors.setPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (!event.getNewValue().toString().equals(event.getOldValue().toString())) {
                //               updateApplyButton();               
                String newSelectionIdValue = event.getNewValue().toString();
                Carisma_index.this.editors.setEditorSelectionId(newSelectionIdValue);
                selectionArtChanged(newSelectionIdValue);
            }
        }
    });
}

From source file:cc.warlock.rcp.stormfront.ui.prefs.PresetsPreferencePage.java

License:Open Source License

private ColorSelector colorSelectorWithLabel(Composite parent, String text) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(text);//from   ww  w .j av  a  2s.  c  om

    ColorSelector selector = new ColorSelector(parent);
    selector.addListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            colorChanged((ColorSelector) event.getSource(), (RGB) event.getNewValue());
        }
    });

    return selector;
}