mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
removing API for custom preference listeners in codan
- this is replaced by eclipse preference listeners framework Change-Id: Ia39041c79c643912c883d7fdf507aeb252f13ddc
This commit is contained in:
parent
7856453f30
commit
26d87d7b74
5 changed files with 8 additions and 131 deletions
|
@ -11,7 +11,6 @@
|
|||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
|
||||
/**
|
||||
* Problem Profile contains tree of categories and problems. For the user
|
||||
|
@ -67,26 +66,6 @@ public interface IProblemProfile extends IProblemElement {
|
|||
*/
|
||||
IProblem[] getProblems();
|
||||
|
||||
/**
|
||||
* Add a listener for profile changes
|
||||
*
|
||||
* @param listener
|
||||
* @since 2.0
|
||||
* @deprecated use {@link IEclipsePreferences} listener instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void addProfileChangeListener(IProblemProfileChangeListener listener);
|
||||
|
||||
/**
|
||||
* Remove a lister for profile changes
|
||||
*
|
||||
* @param listener
|
||||
* @since 2.0
|
||||
* @deprecated use {@link IEclipsePreferences} listener instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeProfileChangeListener(IProblemProfileChangeListener listener);
|
||||
|
||||
/**
|
||||
* Get an object associated with profile, usually the resource
|
||||
*
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2016 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
|
||||
/**
|
||||
* A listener used to receive changes to problem profile
|
||||
* <p>
|
||||
* Clients may implement this interface.
|
||||
* </p>
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated This interface is deprecated, use {@link IEclipsePreferences} listener instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IProblemProfileChangeListener {
|
||||
/**
|
||||
* Notification that a profile value has changed.
|
||||
* The given event object describes the change details and must not
|
||||
* be <code>null</code>.
|
||||
*
|
||||
* @param event the event details
|
||||
* @see ProblemProfileChangeEvent
|
||||
* @see IProblemProfile#addProfileChangeListener(IProblemProfileChangeListener)
|
||||
* @see IProblemProfile#removeProfileChangeListener(IProblemProfileChangeListener)
|
||||
*/
|
||||
public void profileChange(ProblemProfileChangeEvent event);
|
||||
}
|
|
@ -14,7 +14,6 @@ import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
|||
import org.eclipse.cdt.codan.core.model.IProblemMultiple;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||
import org.eclipse.cdt.codan.core.model.ProblemProfileChangeEvent;
|
||||
import org.eclipse.cdt.codan.core.param.IProblemPreference;
|
||||
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
|
||||
|
||||
|
@ -84,14 +83,12 @@ public class CodanProblem extends CodanProblemElement implements IProblemWorking
|
|||
throw new NullPointerException();
|
||||
checkSet();
|
||||
this.severity = sev;
|
||||
notifyChanged(ProblemProfileChangeEvent.PROBLEM_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean checked) {
|
||||
checkSet();
|
||||
this.enabled = checked;
|
||||
notifyChanged(ProblemProfileChangeEvent.PROBLEM_KEY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -114,7 +111,6 @@ public class CodanProblem extends CodanProblemElement implements IProblemWorking
|
|||
if (value == null)
|
||||
throw new NullPointerException();
|
||||
rootPreference = value;
|
||||
notifyChanged(ProblemProfileChangeEvent.PROBLEM_PREF_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,14 +86,4 @@ public class CodanProblemElement implements IProblemElement {
|
|||
protected boolean isFrozen() {
|
||||
return frozen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param problemKey
|
||||
*/
|
||||
@Deprecated
|
||||
protected void notifyChanged(String key) {
|
||||
if (getProfile() instanceof ProblemProfile) {
|
||||
((ProblemProfile) getProfile()).fireProfileChangeEvent(key, null, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,6 @@ import java.util.Collection;
|
|||
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemCategory;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemProfileChangeListener;
|
||||
import org.eclipse.cdt.codan.core.model.ProblemProfileChangeEvent;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.core.runtime.SafeRunner;
|
||||
|
||||
/**
|
||||
* @author Alena
|
||||
|
@ -28,7 +23,6 @@ import org.eclipse.core.runtime.SafeRunner;
|
|||
public class ProblemProfile implements IProblemProfile, Cloneable {
|
||||
private CodanProblemCategory rootCategory;
|
||||
private Object resource;
|
||||
private ListenerList preferenceChangeListeners;
|
||||
|
||||
/**
|
||||
* @param resource
|
||||
|
@ -108,51 +102,6 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
|
|||
return getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addProfileChangeListener(IProblemProfileChangeListener listener) {
|
||||
if (preferenceChangeListeners == null)
|
||||
preferenceChangeListeners = new ListenerList();
|
||||
preferenceChangeListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void removeProfileChangeListener(IProblemProfileChangeListener listener) {
|
||||
if (preferenceChangeListeners == null)
|
||||
return;
|
||||
preferenceChangeListeners.remove(listener);
|
||||
if (preferenceChangeListeners.isEmpty())
|
||||
preferenceChangeListeners = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for notifying preference change listeners.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void fireProfileChangeEvent(String key, Object oldValue, Object newValue) {
|
||||
if (preferenceChangeListeners == null)
|
||||
return;
|
||||
Object[] listeners = preferenceChangeListeners.getListeners();
|
||||
final ProblemProfileChangeEvent event =
|
||||
new ProblemProfileChangeEvent(this, this.resource, key, oldValue, newValue);
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
final IProblemProfileChangeListener listener = (IProblemProfileChangeListener) listeners[i];
|
||||
ISafeRunnable job = new ISafeRunnable() {
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
// already logged in Platform#run()
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
listener.profileChange(event);
|
||||
}
|
||||
};
|
||||
SafeRunner.run(job);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResource() {
|
||||
return resource;
|
||||
|
|
Loading…
Add table
Reference in a new issue