Search in sources :

Example 16 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.

the class DateFormatPreferencePage method initialize.

@Override
protected void initialize() {
    super.initialize();
    // When the chooser's selection changes, update the dateFormat &
    // enablement
    formatChooser.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (FieldEditor.VALUE.equals(event.getProperty())) {
                GitDateFormatter.Format format = fromString((String) event.getOldValue());
                if (format == null) {
                    lastCustomValue = dateFormat.getStringValue();
                }
                updateFields((String) event.getNewValue());
            }
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat)

Example 17 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.

the class GitDecoratorPreferencePage method createContents.

/**
 * @see PreferencePage#createContents(Composite)
 */
@Override
protected Control createContents(Composite parent) {
    Composite composite = SWTUtils.createHVFillComposite(parent, SWTUtils.MARGINS_NONE);
    SWTUtils.createLabel(composite, UIText.DecoratorPreferencesPage_description);
    Composite folderComposite = SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE);
    TabFolder tabFolder = new TabFolder(folderComposite, SWT.NONE);
    tabFolder.setLayoutData(SWTUtils.createHVFillGridData());
    tabFolder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (navigatorPreview != null && changeSetPreview != null) {
                if (UIText.DecoratorPreferencesPage_otherDecorations.equals(e.item.getData())) {
                    navigatorPreview.hide();
                    changeSetPreview.show();
                } else {
                    changeSetPreview.hide();
                    navigatorPreview.show();
                }
            }
        }
    });
    changeSetPreview = new ChangeSetPreview(composite);
    navigatorPreview = new NavigatorPreview(composite);
    generalTab = new GeneralTab(tabFolder);
    textDecorationTab = new TextDecorationTab(tabFolder);
    iconDecorationTab = new IconDecorationTab(tabFolder);
    otherDecorationTab = new OtherDecorationTab(tabFolder);
    initializeValues();
    changeSetPreview.hide();
    changeSetPreview.refresh();
    navigatorPreview.refresh();
    generalTab.addObserver(navigatorPreview);
    textDecorationTab.addObserver(navigatorPreview);
    iconDecorationTab.addObserver(navigatorPreview);
    otherDecorationTab.addObserver(changeSetPreview);
    // TODO: Add help text for this preference page
    themeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            navigatorPreview.refresh();
            changeSetPreview.refresh();
        }
    };
    PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener);
    uiPrefsListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            String property = event.getProperty();
            if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property)) {
                changeSetPreview.refresh();
            }
        }
    };
    getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
    Dialog.applyDialogFont(parent);
    return tabFolder;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 18 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdq-studio-se by Talend.

the class ResourceViewContentProvider method registerMergeRefListener.

/**
 * DOC sgandon Comment method "registerMergeRefListgener".
 */
private void registerMergeRefListener() {
    if (mergeRefListener == null) {
        mergeRefListener = new IPropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent event) {
                if (IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT.equals(event.getProperty())) {
                    try {
                        ProxyRepositoryFactory.getInstance().initialize();
                    } catch (PersistenceException e) {
                        log.error(e, e);
                    }
                    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    CommonNavigator findView = (CommonNavigator) activePage.findView(DQRespositoryView.ID);
                    if (findView != null) {
                        CommonViewer commonViewer = findView.getCommonViewer();
                        if (commonViewer != null) {
                            commonViewer.refresh();
                        }
                    }
                }
            }
        };
        // the merge only for DI repository,need to judge null for other product
        IRepositoryService repositoryService = CoreRuntimePlugin.getInstance().getRepositoryService();
        if (repositoryService != null) {
            IPreferenceStore preferenceStore = repositoryService.getRepositoryPreferenceStore();
            preferenceStore.addPropertyChangeListener(mergeRefListener);
        }
    }
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) CommonViewer(org.eclipse.ui.navigator.CommonViewer) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 19 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdq-studio-se by Talend.

the class AnalysisTuningPreferencePage method createContents.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createContents(Composite parent) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(new GridLayout());
    mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group group2 = new Group(mainComposite, SWT.SHADOW_ETCHED_IN);
    // $NON-NLS-1$
    group2.setText(DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.MemoryGroup"));
    GridLayout gridLayout1 = new GridLayout(2, false);
    group2.setLayout(gridLayout1);
    GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
    group2.setLayoutData(gridData1);
    Composite composite2 = new Composite(group2, SWT.NONE);
    autoComboField = new CheckBoxFieldEditor(AnalysisThreadMemoryChangeNotifier.ANALYSIS_AUTOMATIC_MEMORY_CONTROL, DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.EnableThreadControl"), // $NON-NLS-1$
    composite2);
    final Composite composite4 = new Composite(composite2, SWT.NONE);
    composite4.setLayout(new GridLayout(4, false));
    composite4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    autoComboField.setPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            memoryScaleField.getScaleControl().setEnabled(Boolean.valueOf(event.getNewValue().toString()));
        }
    });
    autoComboField.setPreferenceStore(PlatformUI.getPreferenceStore());
    autoComboField.setPage(this);
    autoComboField.load();
    Label labelScale1 = new Label(composite4, SWT.NONE);
    // $NON-NLS-1$
    labelScale1.setText(DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.ForceToStop"));
    final Label labelScale2 = new Label(composite4, SWT.RIGHT);
    Label labelScale3 = new Label(composite4, SWT.NONE);
    // $NON-NLS-1$
    labelScale3.setText(DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.Mb"));
    Composite compositeScale = new Composite(composite4, SWT.NONE);
    compositeScale.setLayout(new GridLayout());
    // MOD yyi 2012-04-18 TDQ-4916 scale layout fixed.
    compositeScale.setLayoutData(gridData1);
    // MOD yyi 2012-06-19 TDQ-4916 if the value is set to zero the threshold function would be disabled.
    memoryScaleField = new ScaleFieldEditor(AnalysisThreadMemoryChangeNotifier.ANALYSIS_MEMORY_THRESHOLD, "", compositeScale, 0, memMax, 1, // $NON-NLS-1$
    8);
    memoryScaleField.setPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            labelScale2.setText(event.getNewValue().toString());
            composite4.pack();
        }
    });
    memoryScaleField.setPreferenceStore(PlatformUI.getPreferenceStore());
    memoryScaleField.setPage(this);
    memoryScaleField.load();
    labelScale2.setText(String.valueOf(memoryScaleField.getMaximum()));
    labelScale2.setText(String.valueOf(memoryScaleField.getScaleControl().getSelection()));
    if (!autoComboField.getBooleanValue()) {
        memoryScaleField.getScaleControl().setEnabled(false);
    }
    Composite composite3 = new Composite(composite2, SWT.NONE);
    composite3.setLayout(new GridLayout(4, false));
    composite3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label label3 = new Label(composite3, SWT.NONE);
    // $NON-NLS-1$
    label3.setText(DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.HeapStatus"));
    HeapStatus heap = new HeapStatus(composite3, PlatformUI.getPreferenceStore());
    heap.setEnabled(false);
    heap.setMenu(null);
    CLabel label2 = new CLabel(composite2, SWT.WRAP);
    // $NON-NLS-1$
    label2.setText(DefaultMessagesImpl.getString("AnalysisTuningPreferencePage.JvmWarning"));
    label2.setImage(ImageLib.getImage(ImageLib.RED_WARNING_PNG));
    return mainComposite;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) CLabel(org.eclipse.swt.custom.CLabel) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) HeapStatus(org.eclipse.ui.internal.HeapStatus) CheckBoxFieldEditor(org.talend.commons.ui.swt.preferences.CheckBoxFieldEditor) ScaleFieldEditor(org.eclipse.jface.preference.ScaleFieldEditor)

Example 20 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdq-studio-se by Talend.

the class OverlaidPreferencePage method addField.

/* (non-JavaDoc)
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#addField(org.eclipse.jface.preference.FieldEditor)
	 */
protected void addField(final FieldEditor editor) {
    // Make sure that FieldEditors automatically write their changes straight to the store
    editor.setPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            editor.store();
        }
    });
    super.addField(editor);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent)

Aggregations

IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)126 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)120 Composite (org.eclipse.swt.widgets.Composite)55 GridData (org.eclipse.swt.layout.GridData)44 Label (org.eclipse.swt.widgets.Label)39 GridLayout (org.eclipse.swt.layout.GridLayout)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 Button (org.eclipse.swt.widgets.Button)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)20 ColorSelector (org.eclipse.jface.preference.ColorSelector)14 ComboViewer (org.eclipse.jface.viewers.ComboViewer)12 Text (org.eclipse.swt.widgets.Text)11 Iterator (java.util.Iterator)10 ISelection (org.eclipse.jface.viewers.ISelection)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)10 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 SashForm (org.eclipse.swt.custom.SashForm)9