1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

Generics.

This commit is contained in:
Sergey Prigogin 2012-04-29 17:49:07 -07:00
parent cc3dcd0e96
commit cb0906c2ab

View file

@ -46,8 +46,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
public class FileScopePreferencePage extends PreferencePage { public class FileScopePreferencePage extends PreferencePage {
private ListDialogField fInclusionPatternList; private ListDialogField<String> fInclusionPatternList;
private ListDialogField fExclusionPatternList; private ListDialogField<String> fExclusionPatternList;
private FileScopeProblemPreference fCurrElement; private FileScopeProblemPreference fCurrElement;
private IProject fCurrProject; private IProject fCurrProject;
private IContainer fCurrSourceFolder; private IContainer fCurrSourceFolder;
@ -69,13 +69,13 @@ public class FileScopePreferencePage extends PreferencePage {
if (res == null) if (res == null)
fCurrSourceFolder = root; fCurrSourceFolder = root;
String excLabel = CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_label; String excLabel = CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_label;
ImageDescriptor excDescriptor = null; //JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB; // ImageDescriptor excDescriptor = null; //JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB;
String[] excButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add, String[] excButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add,
CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add_multiple, CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add_multiple,
CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit, null, CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit, null,
CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_remove }; CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_remove };
String incLabel = CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_label; String incLabel = CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_label;
ImageDescriptor incDescriptor = null; //JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB; // ImageDescriptor incDescriptor = null; //JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB;
String[] incButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add, String[] incButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add,
CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add_multiple, CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add_multiple,
CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit, null, CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit, null,
@ -126,15 +126,15 @@ public class FileScopePreferencePage extends PreferencePage {
} }
} }
private ListDialogField createListContents(FileScopeProblemPreference entryToEdit, String key, String label, String descriptor, private ListDialogField<String> createListContents(FileScopeProblemPreference entryToEdit, String key, String label, String descriptor,
String[] buttonLabels) { String[] buttonLabels) {
ExclusionPatternAdapter adapter = new ExclusionPatternAdapter(); ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
ListDialogField patternList = new ListDialogField(adapter, buttonLabels, new ExclusionInclusionLabelProvider(descriptor)); ListDialogField<String> patternList = new ListDialogField<String>(adapter, buttonLabels, new ExclusionInclusionLabelProvider(descriptor));
patternList.setDialogFieldListener(adapter); patternList.setDialogFieldListener(adapter);
patternList.setLabelText(label); patternList.setLabelText(label);
patternList.enableButton(IDX_EDIT, false); patternList.enableButton(IDX_EDIT, false);
IPath[] pattern = entryToEdit.getAttribute(key); IPath[] pattern = entryToEdit.getAttribute(key);
ArrayList elements = new ArrayList(pattern.length); ArrayList<String> elements = new ArrayList<String>(pattern.length);
for (int i = 0; i < pattern.length; i++) { for (int i = 0; i < pattern.length; i++) {
String patternName = pattern[i].toString(); String patternName = pattern[i].toString();
if (patternName.length() > 0) if (patternName.length() > 0)
@ -147,7 +147,7 @@ public class FileScopePreferencePage extends PreferencePage {
return patternList; return patternList;
} }
protected void doCustomButtonPressed(ListDialogField field, int index) { protected void doCustomButtonPressed(ListDialogField<String> field, int index) {
if (index == IDX_ADD) { if (index == IDX_ADD) {
addEntry(field); addEntry(field);
} else if (index == IDX_EDIT) { } else if (index == IDX_EDIT) {
@ -165,27 +165,27 @@ public class FileScopePreferencePage extends PreferencePage {
fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION, getExclusionPattern()); fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION, getExclusionPattern());
} }
protected void doDoubleClicked(ListDialogField field) { protected void doDoubleClicked(ListDialogField<String> field) {
editEntry(field); editEntry(field);
updateStatus(); updateStatus();
} }
protected void doSelectionChanged(ListDialogField field) { protected void doSelectionChanged(ListDialogField<String> field) {
List selected = field.getSelectedElements(); List<String> selected = field.getSelectedElements();
field.enableButton(IDX_EDIT, canEdit(selected)); field.enableButton(IDX_EDIT, canEdit(selected));
} }
private boolean canEdit(List selected) { private boolean canEdit(List<String> selected) {
return selected.size() == 1; return selected.size() == 1;
} }
private void editEntry(ListDialogField field) { private void editEntry(ListDialogField<String> field) {
List selElements = field.getSelectedElements(); List<String> selElements = field.getSelectedElements();
if (selElements.size() != 1) { if (selElements.size() != 1) {
return; return;
} }
List existing = field.getElements(); List<String> existing = field.getElements();
String entry = (String) selElements.get(0); String entry = selElements.get(0);
ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), entry, existing, ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), entry, existing,
fCurrElement); fCurrElement);
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
@ -193,12 +193,12 @@ public class FileScopePreferencePage extends PreferencePage {
} }
} }
private boolean isExclusion(ListDialogField field) { private boolean isExclusion(ListDialogField<String> field) {
return field == fExclusionPatternList; return field == fExclusionPatternList;
} }
private void addEntry(ListDialogField field) { private void addEntry(ListDialogField<String> field) {
List existing = field.getElements(); List<String> existing = field.getElements();
ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), null, existing, ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), null, existing,
fCurrElement); fCurrElement);
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
@ -207,13 +207,13 @@ public class FileScopePreferencePage extends PreferencePage {
} }
// -------- ExclusionPatternAdapter -------- // -------- ExclusionPatternAdapter --------
private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener { private class ExclusionPatternAdapter implements IListAdapter<String>, IDialogFieldListener {
/** /**
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField, * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField,
* int) * int)
*/ */
@Override @Override
public void customButtonPressed(ListDialogField field, int index) { public void customButtonPressed(ListDialogField<String> field, int index) {
doCustomButtonPressed(field, index); doCustomButtonPressed(field, index);
} }
@ -221,7 +221,7 @@ public class FileScopePreferencePage extends PreferencePage {
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField) * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
*/ */
@Override @Override
public void selectionChanged(ListDialogField field) { public void selectionChanged(ListDialogField<String> field) {
doSelectionChanged(field); doSelectionChanged(field);
} }
@ -229,7 +229,7 @@ public class FileScopePreferencePage extends PreferencePage {
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField) * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
*/ */
@Override @Override
public void doubleClicked(ListDialogField field) { public void doubleClicked(ListDialogField<String> field) {
doDoubleClicked(field); doDoubleClicked(field);
} }
@ -247,7 +247,7 @@ public class FileScopePreferencePage extends PreferencePage {
protected void checkIfPatternValid() { protected void checkIfPatternValid() {
} }
private IPath[] getPattern(ListDialogField field) { private IPath[] getPattern(ListDialogField<String> field) {
Object[] arr = field.getElements().toArray(); Object[] arr = field.getElements().toArray();
Arrays.sort(arr); Arrays.sort(arr);
IPath[] res = new IPath[arr.length]; IPath[] res = new IPath[arr.length];
@ -271,7 +271,7 @@ public class FileScopePreferencePage extends PreferencePage {
protected void configureShell(Shell newShell) { protected void configureShell(Shell newShell) {
} }
private void addMultipleEntries(ListDialogField field) { private void addMultipleEntries(ListDialogField<String> field) {
String title, message; String title, message;
if (isExclusion(field)) { if (isExclusion(field)) {
title = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_title; title = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_title;