Java Code Examples for org.eclipse.jface.util.PropertyChangeEvent#getNewValue()

The following examples show how to use org.eclipse.jface.util.PropertyChangeEvent#getNewValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThemeableEditorExtension.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void handlePreferenceStoreChanged(PropertyChangeEvent event)
{
	if (event.getProperty().equals(IThemeManager.THEME_CHANGED))
	{
		IThemeableEditor editor = this.fEditor.get();
		overrideThemeColors();
		if (editor != null)
		{
			editor.getISourceViewer().invalidateTextPresentation();
		}
	}
	else if (event.getProperty().equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE))
	{
		Object newValue = event.getNewValue();
		if (newValue instanceof Boolean)
		{
			boolean on = (Boolean) newValue;
			fFullLineBackgroundPainter.setHighlightLineEnabled(on);
		}
	}
	else if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT))
	{
		overrideRulerColors();
	}
}
 
Example 2
Source File: CSSPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event)
{
	if (event.getSource() == enableFolding)
	{
		Object newValue = event.getNewValue();
		if (Boolean.TRUE == newValue)
		{
			foldComments.setEnabled(true, foldingGroup);
			foldRules.setEnabled(true, foldingGroup);
		}
		else
		{
			foldComments.setEnabled(false, foldingGroup);
			foldRules.setEnabled(false, foldingGroup);
		}
	}
	super.propertyChange(event);
}
 
Example 3
Source File: JSPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event)
{
	if (event.getSource() == enableFolding) // $codepro.audit.disable useEquals
	{
		Object newValue = event.getNewValue();
		if (Boolean.TRUE == newValue) // $codepro.audit.disable useEquals
		{
			foldComments.setEnabled(true, foldingGroup);
			foldFunctions.setEnabled(true, foldingGroup);
			foldObjects.setEnabled(true, foldingGroup);
			foldArrays.setEnabled(true, foldingGroup);
		}
		else
		{
			foldComments.setEnabled(false, foldingGroup);
			foldFunctions.setEnabled(false, foldingGroup);
			foldObjects.setEnabled(false, foldingGroup);
			foldArrays.setEnabled(false, foldingGroup);
		}
	}
	super.propertyChange(event);
}
 
Example 4
Source File: KbdMacroPreferencePage.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Listen for changes in the radio and directory dialogs
 * 
 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent event) {
	super.propertyChange(event);
	if (event.getSource().equals(radioEditor)) {
		// new value is different form old value when enabling new value
		if (!event.getNewValue().equals(event.getOldValue())){
			// validate the current active set, as the directory may have changed and
			// Eclipse doesn't force a change event on the directory editor when selection changes 
			someListEditor.validate();
			String newValue = (String)event.getNewValue();
			setSomeListEnabled(newValue);	
			setLoadButtonEnabled(newValue);	
		}
	} else if (event.getSource().equals(directoryEditor)) {
		// the interface thinks the directory has changed, so validate the current active set
		// if we're in the select some auto-load state
		if (someListEditor.isEnabled()) {
			someListEditor.validate();
		}
	}
}
 
Example 5
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adapts the behavior of the contained components to the change
 * encoded in the given event.
 * <p>
 * Clients are not allowed to call this method if the old setup with
 * text tools is in use.
 * </p>
 *
 * @param event the event to which to adapt
 * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
 * @since 3.0
 */
public void handlePropertyChangeEvent(PropertyChangeEvent event) {
	Assert.isTrue(isNewSetup());
	if (fCodeScanner.affectsBehavior(event))
		fCodeScanner.adaptToPreferenceChange(event);
	if (fMultilineCommentScanner.affectsBehavior(event))
		fMultilineCommentScanner.adaptToPreferenceChange(event);
	if (fSinglelineCommentScanner.affectsBehavior(event))
		fSinglelineCommentScanner.adaptToPreferenceChange(event);
	if (fStringScanner.affectsBehavior(event))
		fStringScanner.adaptToPreferenceChange(event);
	if (fJavaDocScanner.affectsBehavior(event))
		fJavaDocScanner.adaptToPreferenceChange(event);
	if (fJavaDoubleClickSelector != null && JavaCore.COMPILER_SOURCE.equals(event.getProperty()))
		if (event.getNewValue() instanceof String)
			fJavaDoubleClickSelector.setSourceVersion((String) event.getNewValue());
}
 
Example 6
Source File: AbstractJavaScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
	boolean eventValue= false;
	Object value= event.getNewValue();
	if (value instanceof Boolean)
		eventValue= ((Boolean) value).booleanValue();
	else if (IPreferenceStore.TRUE.equals(value))
		eventValue= true;

	Object data= token.getData();
	if (data instanceof TextAttribute) {
		TextAttribute oldAttr= (TextAttribute) data;
		boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
		if (activeValue != eventValue)
			token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
	}
}
 
Example 7
Source File: MedicationSettings.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event){
	super.propertyChange(event);
	
	// make sure custom sorting is disabled
	if (event.getSource() == sortingFieldEditor) {
		MedicationView view =
			(MedicationView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
			.getActivePage().findView(MedicationView.PART_ID);
		if (view != null) {
			if (event.getNewValue() == Boolean.FALSE) {
				view.setMedicationTableViewerComparator(ViewerSortOrder.DEFAULT);
			}
		}
	}
}
 
Example 8
Source File: TmfTimestampFormatPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
    Object source = event.getSource();
    Object value = event.getNewValue();
    if (source instanceof RadioGroupFieldEditor && value instanceof String &&
            !(value.equals(fChangedProperty) && source.equals(fProperty)))
    {
        fProperty = ((RadioGroupFieldEditor) source).getPreferenceName();
        fChangedProperty = (String) value;
        refresh();
    }
}
 
Example 9
Source File: Beeper.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (RING_BELL_FUNCTION.getPref().equals(event.getProperty())) {
		setRingBellOption((String)event.getNewValue());
	} else if (VISIBLE_BELL.getPref().equals(event.getProperty())) {
		visibleBell = (Boolean)event.getNewValue();
	}
}
 
Example 10
Source File: EclipsePreferenceStoreAdapter.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void propertyChange(final PropertyChangeEvent event) {
  final PreferenceChangeEvent eventToFire =
      new PreferenceChangeEvent(
          event.getProperty(), event.getOldValue(), event.getNewValue());

  for (final IPreferenceChangeListener listener : listeners)
    listener.preferenceChange(eventToFire);
}
 
Example 11
Source File: XLIFFEditorActionHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (viewer != null) {
		return;
	}
	if (event.getProperty().equals(IAction.ENABLED)) {
		Boolean bool = (Boolean) event.getNewValue();
		actionHandler.setEnabled(bool.booleanValue());
	}
}
 
Example 12
Source File: ViewPartWithOrientation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
    if (event.getProperty().equals(this.getOrientationPreferencesKey())) {
        orientationPreference = (Integer) event.getNewValue();
        updateOrientation();
    }
}
 
Example 13
Source File: CommonOccurrencesUpdater.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	final String property = event.getProperty();

	if (IPreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
		boolean newBooleanValue = false;
		Object newValue = event.getNewValue();

		if (newValue != null) {
			newBooleanValue = Boolean.valueOf(newValue.toString()).booleanValue();
		}

		if (newBooleanValue) {
			install();
		} else {
			uninstall();
		}

		// force update
		if (editor != null) {
			ISelectionProvider selectionProvider = editor.getSelectionProvider();

			if (selectionProvider != null) {
				updateAnnotations(selectionProvider.getSelection());
			}
		}
	}
}
 
Example 14
Source File: OthersWorkingSetUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(event.getProperty())) {
		IWorkingSet changedWorkingSet= (IWorkingSet) event.getNewValue();
		if (changedWorkingSet != fWorkingSet && fWorkingSetModel.isActiveWorkingSet(changedWorkingSet)) {
			updateElements();
		}
	}
}
 
Example 15
Source File: BonitaDatabasePreferencePage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void propertyChange(final PropertyChangeEvent event) {
    if (event.getSource() == dropDB) {
        if (!(Boolean) event.getNewValue()) {
            BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
                    .setValue(BonitaPreferenceConstants.LOAD_ORGANIZATION, false);
            checkbox.setSelection(false);
        }
        usersAndRoles.setEnabled((Boolean) event.getNewValue(), getFieldEditorParent());
    }
    super.propertyChange(event);
}
 
Example 16
Source File: AbstractToggleActionContributor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void addPropertyChangeListener() {
	propertyChangeListener = new IPropertyChangeListener() {
		@Override
		public void propertyChange(PropertyChangeEvent event) {
			if (getPreferenceKey().equals(event.getProperty()) && event.getOldValue() != event.getNewValue()) {
				boolean newValue = Boolean.parseBoolean(event.getNewValue().toString());
				stateChanged(newValue);
				getAction().setChecked(newValue);
			}
		}
	};
	preferenceStore = preferenceStoreAccess.getPreferenceStore();
	preferenceStore.addPropertyChangeListener(propertyChangeListener);
}
 
Example 17
Source File: XLIFFEditorActionHandler.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	if (viewer != null) {
		return;
	}
	if (event.getProperty().equals(IAction.ENABLED)) {
		Boolean bool = (Boolean) event.getNewValue();
		actionHandler.setEnabled(bool.booleanValue());
	}
}
 
Example 18
Source File: WorkingSetActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
	
	if (ignoreFilterChangeEvents)
		return;
	
	IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();

	setWorkingSet(newWorkingSet);
	if (newWorkingSet != null) {
		if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
			contentService.getActivationService().activateExtensions(
					new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
			contentService.getActivationService().persistExtensionActivations();
		}
		if (newWorkingSet.isAggregateWorkingSet()) {
			IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
			IWorkingSet[] comps = agWs.getComponents();
			if (comps.length > 1) {
				viewer.getCommonNavigator().setWorkingSetLabel(
						WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
			} else if (comps.length > 0) {
				viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
			} else {
				viewer.getCommonNavigator().setWorkingSetLabel(null);
			}
		} else
			viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
	} else {
		viewer.getCommonNavigator().setWorkingSetLabel(null);
	}

	viewer.getFrameList().reset();
}
 
Example 19
Source File: GlobalsTwoPanelElementSelector2.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * We need to add the action for the working set.
 */
@Override
protected void fillViewMenu(IMenuManager menuManager) {
    super.fillViewMenu(menuManager);

    workingSetFilterActionGroup = new WorkingSetFilterActionGroup(getShell(), new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            String property = event.getProperty();

            if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {

                IWorkingSet workingSet = (IWorkingSet) event.getNewValue();

                if (workingSet != null && !(workingSet.isAggregateWorkingSet() && workingSet.isEmpty())) {
                    workingSetFilter.setWorkingSet(workingSet);
                    setSubtitle(workingSet.getLabel());
                } else {
                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

                    if (window != null) {
                        IWorkbenchPage page = window.getActivePage();
                        workingSet = page.getAggregateWorkingSet();

                        if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
                            workingSet = null;
                        }
                    }

                    workingSetFilter.setWorkingSet(workingSet);
                    setSubtitle(null);
                }

                scheduleRefresh();
            }
        }
    });

    menuManager.add(new Separator());
    workingSetFilterActionGroup.fillContextMenu(menuManager);
}
 
Example 20
Source File: TLCChainedPreferenceStore.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * Handle property change event from the child listener with the given child preference store.
 *
 * @param childPreferenceStore the child preference store
 * @param event the event
 */
private void handlePropertyChangeEvent(IPreferenceStore childPreferenceStore, PropertyChangeEvent event) {
	String property= event.getProperty();
	Object oldValue= event.getOldValue();
	Object newValue= event.getNewValue();

	IPreferenceStore visibleStore= getVisibleStore(property);

	/*
	 * Assume that the property is there but has no default value (its owner relies on the default-default value)
	 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827
	 */
	if (visibleStore == null && newValue != null)
		visibleStore= childPreferenceStore;

	if (visibleStore == null) {
		// no visible store
		if (oldValue != null)
			// removal in child, last in chain -> removal in this chained preference store
			firePropertyChangeEvent(event);
	} else if (visibleStore == childPreferenceStore) {
		// event from visible store
		if (oldValue != null) {
			// change in child, visible store -> change in this chained preference store
			firePropertyChangeEvent(event);
		} else {
			// insertion in child
			IPreferenceStore oldVisibleStore= null;
			int i= 0;
			int length= fPreferenceStores.length;
			while (i < length && fPreferenceStores[i++] != visibleStore) {
				// do nothing
			}
			while (oldVisibleStore == null && i < length) {
				if (fPreferenceStores[i].contains(property))
					oldVisibleStore= fPreferenceStores[i];
				i++;
			}

			if (oldVisibleStore == null) {
				// insertion in child, first in chain -> insertion in this chained preference store
				firePropertyChangeEvent(event);
			} else {
				// insertion in child, not first in chain
				oldValue= getOtherValue(property, oldVisibleStore, newValue);
				if (!oldValue.equals(newValue))
					// insertion in child, different old value -> change in this chained preference store
					firePropertyChangeEvent(property, oldValue, newValue);
				// else: insertion in child, same old value -> no change in this chained preference store
			}
		}
	} else {
		// event from other than the visible store
		boolean eventBeforeVisibleStore= false;
		for (int i= 0, length= fPreferenceStores.length; i < length; i++) {
			IPreferenceStore store= fPreferenceStores[i];
			if (store == visibleStore)
				break;
			if (store == childPreferenceStore) {
				eventBeforeVisibleStore= true;
				break;
			}
		}

		if (eventBeforeVisibleStore) {
			// removal in child, before visible store

			/*
			 * The original event's new value can be non-null (removed assertion).
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=69419
			 */

			newValue= getOtherValue(property, visibleStore, oldValue);
			if (!newValue.equals(oldValue))
				// removal in child, before visible store, different old value -> change in this chained preference store
				firePropertyChangeEvent(property, oldValue, newValue);
			// else: removal in child, before visible store, same old value -> no change in this chained preference store
		}
		// else: event behind visible store -> no change in this chained preference store
	}
}