Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDavid Inglis2004-09-28 14:59:08 -0400
committerDavid Inglis2004-09-28 14:59:08 -0400
commit4b8468a823c7ba12ed8d2c25a6d4ebb8698c948e (patch)
tree5107f03ba205fea2e6791605a68023ca30ebcf78 /core
parent73941de92ed902f0e00f7d9ac3b8e349e664f3a6 (diff)
downloadorg.eclipse.cdt-4b8468a823c7ba12ed8d2c25a6d4ebb8698c948e.tar.gz
org.eclipse.cdt-4b8468a823c7ba12ed8d2c25a6d4ebb8698c948e.tar.xz
org.eclipse.cdt-4b8468a823c7ba12ed8d2c25a6d4ebb8698c948e.zip
update error parser page to handle restore defaults correctly
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java154
1 files changed, 103 insertions, 51 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
index 31588803055..bc6881ed2a5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
@@ -1,13 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
+ * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Common Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/cpl-v10.html
*
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
+ * Contributors: QNX Software Systems - Initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
import java.util.ArrayList;
@@ -44,19 +42,22 @@ import org.eclipse.ui.help.WorkbenchHelp;
public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
- private static final String PREFIX = "ErrorParserBlock"; // $NON-NLS-1$ //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$ //$NON-NLS-1$
- private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$ //$NON-NLS-1$
+ 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;
protected HashMap mapParsers = new HashMap();
private CheckedListDialogField fErrorParserList;
protected boolean listDirty = false;
+ private boolean usingDeprecatedContructor = false;
- class FieldListenerAdapter implements IDialogFieldListener {
+ class FieldListenerAdapter implements IDialogFieldListener {
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
*/
public void dialogFieldChanged(DialogField field) {
@@ -65,10 +66,23 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
}
+ /**
+ * @deprecated - use AbstractErrorParserBlock(), preferences setting should
+ * now be handled by extending classes, use
+ * setErrorParserIDs(boolean)/saveErrorParserIDs() to handle
+ * getting/setting of values.
+ *
+ * @param prefs
+ */
public AbstractErrorParserBlock(Preferences prefs) {
+ this();
+ usingDeprecatedContructor = true;
+ fPrefs = prefs;
+ }
+
+ public AbstractErrorParserBlock() {
super(CUIPlugin.getResourceString(LABEL));
setDescription(CUIPlugin.getResourceString(DESC));
- fPrefs = prefs;
}
public Image getImage() {
@@ -77,17 +91,20 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
public void updateValues() {
fErrorParserList.removeAllElements();
- setValues();
+ setValues();
}
-
+
/**
* Returns a label provider for the error parsers
- *
+ *
* @return the content provider
*/
protected ILabelProvider getLabelProvider() {
return new LabelProvider() {
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
@@ -101,8 +118,17 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
return new FieldListenerAdapter();
}
- protected String[] getErrorParserIDs(Preferences prefs) {
- String parserIDs = prefs.getString(ErrorParserManager.PREF_ERROR_PARSER);
+ protected String[] getErrorParserIDs(boolean defaults) {
+ String parserIDs = null;
+ if (fPrefs != null) {
+ if (defaults == true) {
+ parserIDs = fPrefs.getDefaultString(ErrorParserManager.PREF_ERROR_PARSER);
+ } else {
+ parserIDs = fPrefs.getString(ErrorParserManager.PREF_ERROR_PARSER);
+ }
+ } else {
+ return getErrorParserIDs();
+ }
String[] empty = new String[0];
if (parserIDs != null && parserIDs.length() > 0) {
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
@@ -110,21 +136,24 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
while (tok.hasMoreElements()) {
list.add(tok.nextToken());
}
- return (String[]) list.toArray(empty);
+ return (String[])list.toArray(empty);
}
return empty;
}
/**
* To be implemented, abstract method.
+ *
* @param project
* @return String[]
*/
protected abstract String[] getErrorParserIDs(IProject project);
/**
- * To be overloaded by subclasses with another method of getting the error parsers.
- * For example, the managed builder new project wizard uses the selected Target.
+ * To be overloaded by subclasses with another method of getting the error
+ * parsers. For example, the managed builder new project wizard uses the
+ * selected Target.
+ * @deprecated - use getErrorParserIDs(boolean defaults)
* @return String[]
*/
protected String[] getErrorParserIDs() {
@@ -133,11 +162,18 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
/**
* To be implemented. abstract method.
+ *
* @param project
* @param parsers
*/
protected abstract void saveErrorParsers(IProject project, String[] parserIDs) throws CoreException;
+ /**
+ * @deprecated - use saveErrorParser(String[])
+ * @param prefs
+ * @param parserIDs
+ */
+
protected void saveErrorParsers(Preferences prefs, String[] parserIDs) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < parserIDs.length; i++) {
@@ -146,9 +182,14 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
prefs.setValue(ErrorParserManager.PREF_ERROR_PARSER, buf.toString());
}
+ protected void saveErrorParsers(String[] parserIDs) throws CoreException {
+ saveErrorParsers(fPrefs, parserIDs);
+ }
+
protected void initMapParsers() {
mapParsers.clear();
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.ERROR_PARSER_SIMPLE_ID);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+ CCorePlugin.ERROR_PARSER_SIMPLE_ID);
if (point != null) {
IExtension[] exts = point.getExtensions();
for (int i = 0; i < exts.length; i++) {
@@ -164,28 +205,39 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
setValues();
}
+ protected void setDefaults() {
+ String[] parserIDs;
+ IProject project = getContainer().getProject();
+ if (project == null) {
+ // From a Preference.
+ parserIDs = getErrorParserIDs(true);
+ } else {
+ parserIDs = getErrorParserIDs(false);
+ }
+ updateListControl(parserIDs);
+ }
+
protected void setValues() {
String[] parserIDs;
IProject project = getContainer().getProject();
if (project == null) {
- if (fPrefs != null) {
- // From a Preference.
- parserIDs = getErrorParserIDs(fPrefs);
- } else {
- parserIDs = getErrorParserIDs();
- }
+ parserIDs = getErrorParserIDs(false);
} else {
// From the Project.
parserIDs = getErrorParserIDs(project);
}
+ updateListControl(parserIDs);
+ }
+ protected void updateListControl(String[] parserIDs) {
List checkedList = Arrays.asList(parserIDs);
fErrorParserList.setElements(checkedList);
fErrorParserList.setCheckedElements(checkedList);
- fErrorParserList.getTableViewer().setSelection(new StructuredSelection(checkedList.get(0)), true);
-
- Iterator items = mapParsers.keySet().iterator();
- while( items.hasNext()) {
+ if (checkedList.size() > 0) {
+ fErrorParserList.getTableViewer().setSelection(new StructuredSelection(checkedList.get(0)), true);
+ }
+ Iterator items = mapParsers.keySet().iterator();
+ while (items.hasNext()) {
String item = (String)items.next();
boolean found = false;
for (int i = 0; i < parserIDs.length; i++) {
@@ -206,28 +258,28 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.ERROR_PARSERS_PAGE);
- String[] buttonLabels = new String[] {
- /* 0 */
- CUIMessages.getString("AbstractErrorParserBlock.label.up"), //$NON-NLS-1$
- /* 1 */
- CUIMessages.getString("AbstractErrorParserBlock.label.down"), //$NON-NLS-1$
- /* 2 */
- null,
- /* 3 */
- CUIMessages.getString("AbstractErrorParserBlock.label.selectAll"), //$NON-NLS-1$
- /* 4 */
- CUIMessages.getString("AbstractErrorParserBlock.label.unselectAll") //$NON-NLS-1$
+ String[] buttonLabels = new String[]{
+ /* 0 */
+ CUIMessages.getString("AbstractErrorParserBlock.label.up"), //$NON-NLS-1$
+ /* 1 */
+ CUIMessages.getString("AbstractErrorParserBlock.label.down"), //$NON-NLS-1$
+ /* 2 */
+ null,
+ /* 3 */
+ CUIMessages.getString("AbstractErrorParserBlock.label.selectAll"), //$NON-NLS-1$
+ /* 4 */
+ CUIMessages.getString("AbstractErrorParserBlock.label.unselectAll") //$NON-NLS-1$
};
fErrorParserList = new CheckedListDialogField(null, buttonLabels, getLabelProvider());
fErrorParserList.setDialogFieldListener(getFieldListenerAdapter());
- fErrorParserList.setLabelText(CUIMessages.getString("AbstractErrorParserBlock.label.errorParsers")); //$NON-NLS-1$
+ fErrorParserList.setLabelText(CUIMessages.getString("AbstractErrorParserBlock.label.errorParsers")); //$NON-NLS-1$
fErrorParserList.setUpButtonIndex(0);
fErrorParserList.setDownButtonIndex(1);
fErrorParserList.setCheckAllButtonIndex(3);
fErrorParserList.setUncheckAllButtonIndex(4);
- LayoutUtil.doDefaultLayout(composite, new DialogField[] { fErrorParserList }, true);
+ LayoutUtil.doDefaultLayout(composite, new DialogField[]{fErrorParserList}, true);
LayoutUtil.setHorizontalGrabbing(fErrorParserList.getListControl(null));
initializeValues();
@@ -249,12 +301,12 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
list.add(obj);
}
}
-
+
String[] parserIDs = (String[])list.toArray(EMPTY);
if (project == null) {
// Save to preferences
- saveErrorParsers(fPrefs, parserIDs);
+ saveErrorParsers(parserIDs);
} else {
saveErrorParsers(project, parserIDs);
}
@@ -264,6 +316,6 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
}
public void performDefaults() {
- initializeValues();
+ setDefaults();
}
-}
+} \ No newline at end of file

Back to the top