Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] ErrorParserBlock changes.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.154
diff -u -r1.154 ChangeLog
--- ChangeLog	3 Sep 2003 13:35:33 -0000	1.154
+++ ChangeLog	3 Sep 2003 18:33:52 -0000
@@ -1,4 +1,10 @@
-2003-09-3 Alain Magloire
+2003-09-03 Alain Magloire
+
+	Change to abstract and let the client provides the saving algorithm.
+
+	* src/org/eclipse/cdt/uui/ErroParserBlock.java
+
+2003-09-03 Alain Magloire
 
 	Wrong fix to a warning the call is needed but not the variable.
 	Thanks to Hoda for noticing.
Index: src/org/eclipse/cdt/ui/ErrorParserBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ErrorParserBlock.java,v
retrieving revision 1.1
diff -u -r1.1 ErrorParserBlock.java
--- src/org/eclipse/cdt/ui/ErrorParserBlock.java	31 Aug 2003 04:45:53 -0000	1.1
+++ src/org/eclipse/cdt/ui/ErrorParserBlock.java	3 Sep 2003 18:33:53 -0000
@@ -26,18 +26,21 @@
 import org.eclipse.core.runtime.IExtensionPoint;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Composite;
 
-public class ErrorParserBlock extends AbstractCOptionPage {
+public abstract class ErrorParserBlock extends AbstractCOptionPage {
 
 	private static final String PREFIX = "ErrorParserBlock"; // $NON-NLS-1$
 	private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$
 	private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
 
+	private static String[] EMPTY = new String[0];
+	private Preferences fPrefs;
 	private HashMap mapParsers = new HashMap();
 	private CheckedListDialogField fErrorParserList;
 	protected boolean listDirty = false;
@@ -53,9 +56,11 @@
 
 	}
 
-	public ErrorParserBlock() {
-		super(CUIPlugin.getResourceString(LABEL));
-		setDescription(CUIPlugin.getResourceString(DESC));
+	public ErrorParserBlock(Preferences prefs) {
+		//super(CUIPlugin.getResourceString(LABEL));
+		//setDescription(CUIPlugin.getResourceString(DESC));
+		super("Error Parsers");
+		setDescription("Set the error parser for this project");
 	}
 
 	public Image getImage() {
@@ -75,14 +80,8 @@
 		return new FieldListenerAdapter();
 	}
 
-	protected void getPreferenceErrorParsers(List list) {
-		String[] parserIDs = CCorePlugin.getDefault().getPreferenceErrorParserIDs();
-		for (int i = 0; i < parserIDs.length; i++) {
-			String parserName = (String)mapParsers.get(parserIDs[i]);
-			if (parserName != null) {
-				list.add(parserName);
-			}
-		}
+	protected String[] getErrorParserIDs(Preferences prefs) {
+		return CCorePlugin.getDefault().getPreferenceErrorParserIDs(prefs);
 	}
 
 	/**
@@ -90,15 +89,17 @@
 	 * @param project
 	 * @param list
 	 */
-	protected void getErrorParsers(IProject project, List list) {
-	}
+	protected abstract String[] getErrorParserIDs(IProject project);
 
 	/**
 	 * To be implemented. abstract method.
 	 * @param project
 	 * @param parsers
 	 */
-	public void saveErrorParsers(IProject project, List parsers) {
+	public abstract void saveErrorParsers(IProject project, String[] parserIDs);
+
+	public void saveErrorParsers(Preferences prefs, String[] parserIDs) {
+		CCorePlugin.getDefault().setPreferenceErrorParser(prefs, parserIDs);
 	}
 
 	protected void initMapParsers() {
@@ -121,15 +122,25 @@
 		}
 		fErrorParserList.setElements(list);
 
-		list.clear();	
+		list.clear();
+		String[] parserIDs = EMPTY;
+
 		IProject project = getContainer().getProject();
 		if (project == null) {
-			// Preference Page.
-			getPreferenceErrorParsers(list);
+			// From a Preference.
+			parserIDs =getErrorParserIDs(fPrefs);
 		} else {
 			// From the Project.
-			getErrorParsers(project, list);
+			parserIDs = getErrorParserIDs(project);
 		}
+
+		for (int i = 0; i < parserIDs.length; i++) {
+			String value = (String)mapParsers.get(parserIDs[i]);
+			if (value != null) {
+				list.add(value);
+			}
+		}
+
 		fErrorParserList.setCheckedElements(list);
 	}
 
@@ -165,14 +176,20 @@
 	}
 
 	public void performApply(IProgressMonitor monitor) throws CoreException {
-		List list = fErrorParserList.getCheckedElements();
 		if (listDirty) {
 			IProject project = getContainer().getProject();
 			if (monitor == null) {
 				monitor = new NullProgressMonitor();
 			}
 			monitor.beginTask("Reference Projects", 1);
-			saveErrorParsers(project, list);
+			List list = fErrorParserList.getCheckedElements();
+			
+			String[] parserIDs = (String[])list.toArray(EMPTY);
+			if (project == null) {
+				saveErrorParsers(fPrefs, parserIDs);
+			} else {
+				saveErrorParsers(project, parserIDs);
+			}
 		}
 	}
 



Back to the top