From 31c790f2cee57694eebf9e31afbd9cb82d0eff55 Mon Sep 17 00:00:00 2001 From: Hendrik Still Date: Wed, 24 Jul 2013 14:16:38 +0200 Subject: Bug 413624 - Fix compiler warnings in org.eclipse.jface.dialogs caused by moving JFace to Java 1.5 Change-Id: Id41cbdbfeedc2a44cc5e48072a9489a8cf8526fa Signed-off-by: Hendrik Still --- .../eclipse/jface/dialogs/ControlEnableState.java | 12 ++--- .../src/org/eclipse/jface/dialogs/Dialog.java | 6 +-- .../org/eclipse/jface/dialogs/DialogSettings.java | 62 +++++++++++----------- .../src/org/eclipse/jface/dialogs/ErrorDialog.java | 10 ++-- .../src/org/eclipse/jface/dialogs/PopupDialog.java | 12 ++--- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ControlEnableState.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ControlEnableState.java index cba792b489d..10bc3bb271c 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ControlEnableState.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ControlEnableState.java @@ -25,12 +25,12 @@ public class ControlEnableState { * List of exception controls (element type: Control); * null if none. */ - private List exceptions = null; + private List exceptions = null; /** * List of saved states (element type: ItemState). */ - private List states; + private List states; /** * Internal class for recording the enable/disable state of a single @@ -89,9 +89,9 @@ public class ControlEnableState { * the list of controls to not disable (element type: * Control), or null if none */ - protected ControlEnableState(Control w, List exceptions) { + protected ControlEnableState(Control w, List exceptions) { super(); - states = new ArrayList(); + states = new ArrayList(); this.exceptions = exceptions; readStateForAndDisable(w); } @@ -120,7 +120,7 @@ public class ControlEnableState { * Control) * @return an object capturing the enable/disable state */ - public static ControlEnableState disable(Control w, List exceptions) { + public static ControlEnableState disable(Control w, List exceptions) { return new ControlEnableState(w, exceptions); } @@ -152,7 +152,7 @@ public class ControlEnableState { public void restore() { int size = states.size(); for (int i = 0; i < size; i++) { - ((ItemState) states.get(i)).restore(); + states.get(i).restore(); } } } diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java index edbef2ca9ef..033ef2f71d3 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java @@ -209,7 +209,7 @@ public abstract class Dialog extends Window { /** * Collection of buttons created by the createButton method. */ - private HashMap buttons = new HashMap(); + private HashMap buttons = new HashMap(); /** * Font metrics to use for determining pixel sizes. @@ -839,7 +839,7 @@ public abstract class Dialog extends Window { * @since 2.0 */ protected Button getButton(int id) { - return (Button) buttons.get(new Integer(id)); + return buttons.get(new Integer(id)); } /** @@ -997,7 +997,7 @@ public abstract class Dialog extends Window { boolean returnValue = super.close(); if (returnValue) { - buttons = new HashMap(); + buttons = new HashMap(); buttonBar = null; dialogArea = null; } diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java index 381ab94165a..a5d7ca4b6f2 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java @@ -76,14 +76,14 @@ public class DialogSettings implements IDialogSettings { /* A Map of DialogSettings representing each sections in a DialogSettings. It maps the DialogSettings' name to the DialogSettings */ - private Map sections; + private Map sections; /* A Map with all the keys and values of this sections. Either the keys an values are restricted to strings. */ - private Map items; + private Map items; // A Map with all the keys mapped to array of strings. - private Map arrayItems; + private Map arrayItems; private static final String TAG_SECTION = "section";//$NON-NLS-1$ @@ -107,9 +107,9 @@ public class DialogSettings implements IDialogSettings { */ public DialogSettings(String sectionName) { name = sectionName; - items = new HashMap(); - arrayItems = new HashMap(); - sections = new HashMap(); + items = new HashMap(); + arrayItems = new HashMap(); + sections = new HashMap(); } /* (non-Javadoc) @@ -152,35 +152,35 @@ public class DialogSettings implements IDialogSettings { * @since 3.9 */ public IDialogSettings removeSection(String sectionName) { - return (IDialogSettings) sections.remove(sectionName); + return sections.remove(sectionName); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public String get(String key) { - return (String) items.get(key); + return items.get(key); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public String[] getArray(String key) { - return (String[]) arrayItems.get(key); + return arrayItems.get(key); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public boolean getBoolean(String key) { - return Boolean.valueOf((String) items.get(key)).booleanValue(); + return Boolean.valueOf(items.get(key)).booleanValue(); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public double getDouble(String key) throws NumberFormatException { - String setting = (String) items.get(key); + String setting = items.get(key); if (setting == null) { throw new NumberFormatException( "There is no setting associated with the key \"" + key + "\"");//$NON-NLS-1$ //$NON-NLS-2$ @@ -193,7 +193,7 @@ public class DialogSettings implements IDialogSettings { * Method declared on IDialogSettings. */ public float getFloat(String key) throws NumberFormatException { - String setting = (String) items.get(key); + String setting = items.get(key); if (setting == null) { throw new NumberFormatException( "There is no setting associated with the key \"" + key + "\"");//$NON-NLS-1$ //$NON-NLS-2$ @@ -206,7 +206,7 @@ public class DialogSettings implements IDialogSettings { * Method declared on IDialogSettings. */ public int getInt(String key) throws NumberFormatException { - String setting = (String) items.get(key); + String setting = items.get(key); if (setting == null) { //new Integer(null) will throw a NumberFormatException and meet our spec, but this message //is clearer. @@ -221,7 +221,7 @@ public class DialogSettings implements IDialogSettings { * Method declared on IDialogSettings. */ public long getLong(String key) throws NumberFormatException { - String setting = (String) items.get(key); + String setting = items.get(key); if (setting == null) { //new Long(null) will throw a NumberFormatException and meet our spec, but this message //is clearer. @@ -264,14 +264,14 @@ public class DialogSettings implements IDialogSettings { * Method declared on IDialogSettings. */ public IDialogSettings getSection(String sectionName) { - return (IDialogSettings) sections.get(sectionName); + return sections.get(sectionName); } /* (non-Javadoc) * Method declared on IDialogSettings. */ public IDialogSettings[] getSections() { - Collection values = sections.values(); + Collection values = sections.values(); DialogSettings[] result = new DialogSettings[values.size()]; values.toArray(result); return result; @@ -336,7 +336,7 @@ public class DialogSettings implements IDialogSettings { Element child = (Element) l.item(i); String key = child.getAttribute(TAG_KEY); NodeList list = child.getElementsByTagName(TAG_ITEM); - List valueList = new ArrayList(); + List valueList = new ArrayList(); for (int j = 0; j < list.getLength(); j++) { Element node = (Element) list.item(j); if (child == node.getParentNode()) { @@ -431,25 +431,25 @@ public class DialogSettings implements IDialogSettings { * Save the settings in the document. */ private void save(XMLWriter out) throws IOException { - HashMap attributes = new HashMap(2); + HashMap attributes = new HashMap(2); attributes.put(TAG_NAME, name == null ? "" : name); //$NON-NLS-1$ out.startTag(TAG_SECTION, attributes); attributes.clear(); - for (Iterator i = items.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (Iterator i = items.keySet().iterator(); i.hasNext();) { + String key = i.next(); attributes.put(TAG_KEY, key == null ? "" : key); //$NON-NLS-1$ - String string = (String) items.get(key); + String string = items.get(key); attributes.put(TAG_VALUE, string == null ? "" : string); //$NON-NLS-1$ out.printTag(TAG_ITEM, attributes, true); } attributes.clear(); - for (Iterator i = arrayItems.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (Iterator i = arrayItems.keySet().iterator(); i.hasNext();) { + String key = i.next(); attributes.put(TAG_KEY, key == null ? "" : key); //$NON-NLS-1$ out.startTag(TAG_LIST, attributes); - String[] value = (String[]) arrayItems.get(key); + String[] value = arrayItems.get(key); attributes.clear(); if (value != null) { for (int index = 0; index < value.length; index++) { @@ -461,7 +461,7 @@ public class DialogSettings implements IDialogSettings { out.endTag(TAG_LIST); attributes.clear(); } - for (Iterator i = sections.values().iterator(); i.hasNext();) { + for (Iterator i = sections.values().iterator(); i.hasNext();) { ((DialogSettings) i.next()).save(out); } out.endTag(TAG_SECTION); @@ -527,18 +527,18 @@ public class DialogSettings implements IDialogSettings { * @param close should the tag be ended automatically (=> empty tag) * @throws IOException */ - public void printTag(String name, HashMap parameters, boolean close) throws IOException { + public void printTag(String name, HashMap parameters, boolean close) throws IOException { printTag(name, parameters, true, true, close); } - private void printTag(String name, HashMap parameters, boolean shouldTab, boolean newLine, boolean close) throws IOException { + private void printTag(String name, HashMap parameters, boolean shouldTab, boolean newLine, boolean close) throws IOException { StringBuffer sb = new StringBuffer(); sb.append('<'); sb.append(name); if (parameters != null) { - for (Enumeration e = Collections.enumeration(parameters.keySet()); e.hasMoreElements();) { + for (Enumeration e = Collections.enumeration(parameters.keySet()); e.hasMoreElements();) { sb.append(" "); //$NON-NLS-1$ - String key = (String) e.nextElement(); + String key = e.nextElement(); sb.append(key); sb.append("=\""); //$NON-NLS-1$ sb.append(getEscaped(String.valueOf(parameters.get(key)))); @@ -565,12 +565,12 @@ public class DialogSettings implements IDialogSettings { * @param parameters map of parameters * @throws IOException */ - public void startTag(String name, HashMap parameters) throws IOException { + public void startTag(String name, HashMap parameters) throws IOException { startTag(name, parameters, true); tab++; } - private void startTag(String name, HashMap parameters, boolean newLine) throws IOException { + private void startTag(String name, HashMap parameters, boolean newLine) throws IOException { printTag(name, parameters, true, newLine, false); } diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ErrorDialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ErrorDialog.java index 923e31e411a..b6208dae21d 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ErrorDialog.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/ErrorDialog.java @@ -495,9 +495,9 @@ public class ErrorDialog extends IconAndMessageDialog { } String message = buildingStatus.getMessage(); sb.append(message); - java.util.List lines = readLines(sb.toString()); - for (Iterator iterator = lines.iterator(); iterator.hasNext();) { - String line = (String) iterator.next(); + java.util.List lines = readLines(sb.toString()); + for (Iterator iterator = lines.iterator(); iterator.hasNext();) { + String line = iterator.next(); listToPopulate.add(line); } incrementNesting = true; @@ -541,8 +541,8 @@ public class ErrorDialog extends IconAndMessageDialog { } } - private static java.util.List readLines(final String s) { - java.util.List lines = new ArrayList(); + private static java.util.List readLines(final String s) { + java.util.List lines = new ArrayList(); BufferedReader reader = new BufferedReader(new StringReader(s)); String line; try { diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java index ebab941d168..ad19c7fc45e 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java @@ -1488,7 +1488,7 @@ public class PopupDialog extends Window { * color assigned */ private void applyForegroundColor(Color color, Control control, - List exclusions) { + List exclusions) { if (!exclusions.contains(control)) { control.setForeground(color); } @@ -1513,7 +1513,7 @@ public class PopupDialog extends Window { * color assigned */ private void applyBackgroundColor(Color color, Control control, - List exclusions) { + List exclusions) { if (!exclusions.contains(control)) { control.setBackground(color); } @@ -1567,8 +1567,8 @@ public class PopupDialog extends Window { * * @return the List of controls */ - protected List getForegroundColorExclusions() { - List list = new ArrayList(3); + protected List getForegroundColorExclusions() { + List list = new ArrayList(3); if (infoLabel != null) { list.add(infoLabel); } @@ -1588,8 +1588,8 @@ public class PopupDialog extends Window { * * @return the List of controls */ - protected List getBackgroundColorExclusions() { - List list = new ArrayList(2); + protected List getBackgroundColorExclusions() { + List list = new ArrayList(2); if (titleSeparator != null) { list.add(titleSeparator); } -- cgit v1.2.3