mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
fixed parser block
This commit is contained in:
parent
f6e061b3e0
commit
d6a9483ed2
3 changed files with 32 additions and 18 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2003-09-03 David Inglis
|
||||||
|
Fixed parser block to save ids properly.
|
||||||
|
Use shared preference key for error parsers.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CPluginResources.properties
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/ErrorParserBlock.java
|
||||||
|
|
||||||
2003-09-03 David Inglis
|
2003-09-03 David Inglis
|
||||||
- src/org/eclipse/cdt/ui/TabFolderOptionBlock.java
|
- src/org/eclipse/cdt/ui/TabFolderOptionBlock.java
|
||||||
- src/org/eclipse/cdt/ui/AbstractCOptionPage.java
|
- src/org/eclipse/cdt/ui/AbstractCOptionPage.java
|
||||||
|
|
|
@ -342,3 +342,6 @@ NewConfiguration.label.name=Configuration name:
|
||||||
NewConfiguration.label.copy=Copy settings from:
|
NewConfiguration.label.copy=Copy settings from:
|
||||||
NewConfiguration.error.title=Error
|
NewConfiguration.error.title=Error
|
||||||
NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.
|
NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.
|
||||||
|
|
||||||
|
ErrorParserBlock.label=Error Parsers
|
||||||
|
ErrorParserBlock.desc=Set the error parser for this project
|
|
@ -11,16 +11,19 @@
|
||||||
package org.eclipse.cdt.ui.dialogs;
|
package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ErrorParserManager;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -40,8 +43,6 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
private static final String LABEL = PREFIX + ".label"; // $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 final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
|
||||||
|
|
||||||
private final static String PREF_ERROR_PARSER = "errorOutputParser"; // $NON-NLS-1$
|
|
||||||
|
|
||||||
private static String[] EMPTY = new String[0];
|
private static String[] EMPTY = new String[0];
|
||||||
private Preferences fPrefs;
|
private Preferences fPrefs;
|
||||||
private HashMap mapParsers = new HashMap();
|
private HashMap mapParsers = new HashMap();
|
||||||
|
@ -60,8 +61,9 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorParserBlock(Preferences prefs) {
|
public ErrorParserBlock(Preferences prefs) {
|
||||||
super("Error Parsers");
|
super(CUIPlugin.getResourceString(LABEL));
|
||||||
setDescription("Set the error parser for this project");
|
setDescription(CUIPlugin.getResourceString(DESC));
|
||||||
|
fPrefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
|
@ -74,7 +76,15 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
* @return the content provider
|
* @return the content provider
|
||||||
*/
|
*/
|
||||||
protected ILabelProvider getLabelProvider() {
|
protected ILabelProvider getLabelProvider() {
|
||||||
return new LabelProvider();
|
return new LabelProvider() {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public String getText(Object element) {
|
||||||
|
String name = (String)mapParsers.get(element.toString());
|
||||||
|
return name != null ? name : "";
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FieldListenerAdapter getFieldListenerAdapter() {
|
protected FieldListenerAdapter getFieldListenerAdapter() {
|
||||||
|
@ -82,7 +92,7 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getErrorParserIDs(Preferences prefs) {
|
protected String[] getErrorParserIDs(Preferences prefs) {
|
||||||
String parserIDs = prefs.getString(PREF_ERROR_PARSER);
|
String parserIDs = prefs.getString(ErrorParserManager.PREF_ERROR_PARSER);
|
||||||
String[] empty = new String[0];
|
String[] empty = new String[0];
|
||||||
if (parserIDs != null && parserIDs.length() > 0) {
|
if (parserIDs != null && parserIDs.length() > 0) {
|
||||||
StringTokenizer tok = new StringTokenizer(parserIDs, ";");
|
StringTokenizer tok = new StringTokenizer(parserIDs, ";");
|
||||||
|
@ -107,14 +117,14 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
* @param project
|
* @param project
|
||||||
* @param parsers
|
* @param parsers
|
||||||
*/
|
*/
|
||||||
public abstract void saveErrorParsers(IProject project, String[] parserIDs);
|
protected abstract void saveErrorParsers(IProject project, String[] parserIDs) throws CoreException;
|
||||||
|
|
||||||
public void saveErrorParsers(Preferences prefs, String[] parserIDs) {
|
protected void saveErrorParsers(Preferences prefs, String[] parserIDs) {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int i = 0; i < parserIDs.length; i++) {
|
for (int i = 0; i < parserIDs.length; i++) {
|
||||||
buf.append(parserIDs[i]).append(';');
|
buf.append(parserIDs[i]).append(';');
|
||||||
}
|
}
|
||||||
prefs.setValue(PREF_ERROR_PARSER, buf.toString());
|
prefs.setValue(ErrorParserManager.PREF_ERROR_PARSER, buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initMapParsers() {
|
protected void initMapParsers() {
|
||||||
|
@ -131,7 +141,7 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
protected void initializeValues() {
|
protected void initializeValues() {
|
||||||
initMapParsers();
|
initMapParsers();
|
||||||
List list = new ArrayList(mapParsers.size());
|
List list = new ArrayList(mapParsers.size());
|
||||||
Iterator items = mapParsers.values().iterator();
|
Iterator items = mapParsers.keySet().iterator();
|
||||||
while( items.hasNext()) {
|
while( items.hasNext()) {
|
||||||
list.add((String)items.next());
|
list.add((String)items.next());
|
||||||
}
|
}
|
||||||
|
@ -149,14 +159,7 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
parserIDs = getErrorParserIDs(project);
|
parserIDs = getErrorParserIDs(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < parserIDs.length; i++) {
|
fErrorParserList.setCheckedElements(Arrays.asList(parserIDs));
|
||||||
String value = (String)mapParsers.get(parserIDs[i]);
|
|
||||||
if (value != null) {
|
|
||||||
list.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fErrorParserList.setCheckedElements(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
@ -200,6 +203,7 @@ public abstract class ErrorParserBlock extends AbstractCOptionPage {
|
||||||
List list = fErrorParserList.getCheckedElements();
|
List list = fErrorParserList.getCheckedElements();
|
||||||
|
|
||||||
String[] parserIDs = (String[])list.toArray(EMPTY);
|
String[] parserIDs = (String[])list.toArray(EMPTY);
|
||||||
|
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
saveErrorParsers(fPrefs, parserIDs);
|
saveErrorParsers(fPrefs, parserIDs);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue