Skip to content

Commit 037c5d7

Browse files
committed
Use static IStatus factories in JFace
1 parent 2e549bb commit 037c5d7

19 files changed

+33
-93
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/action/ExternalActionManager.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.eclipse.core.commands.NotEnabledException;
3434
import org.eclipse.core.commands.ParameterizedCommand;
3535
import org.eclipse.core.commands.common.NotDefinedException;
36-
import org.eclipse.core.runtime.IStatus;
3736
import org.eclipse.core.runtime.ListenerList;
3837
import org.eclipse.core.runtime.Status;
3938
import org.eclipse.jface.bindings.BindingManager;
@@ -358,14 +357,10 @@ public final boolean isActive(final String commandId) {
358357
if (!command.isDefined()
359358
&& (!loggedCommandIds.contains(commandId))) {
360359
// The command is not yet defined, so we should log this.
361-
final String message = MessageFormat.format(Util
362-
.translateString(RESOURCE_BUNDLE,
363-
"undefinedCommand.WarningMessage", null), //$NON-NLS-1$
360+
String message = MessageFormat.format(
361+
Util.translateString(RESOURCE_BUNDLE, "undefinedCommand.WarningMessage", null), //$NON-NLS-1$
364362
command.getId());
365-
IStatus status = new Status(IStatus.ERROR,
366-
"org.eclipse.jface", //$NON-NLS-1$
367-
0, message, new Exception());
368-
Policy.getLog().log(status);
363+
Policy.getLog().log(Status.error(message));
369364

370365
// And remember this item so we don't log it again.
371366
loggedCommandIds.add(commandId);

bundles/org.eclipse.jface/src/org/eclipse/jface/bindings/BindingManager.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,7 @@ private final void computeBindings(final Map activeContextTree,
655655
} catch (IOException e) {
656656
// we should not get this
657657
}
658-
conflicts.add(new Status(IStatus.WARNING,
659-
"org.eclipse.jface", //$NON-NLS-1$
660-
sw.toString()));
658+
conflicts.add(Status.warning(sw.toString()));
661659
}
662660
if (DEBUG) {
663661
Tracing.printTrace("BINDINGS", //$NON-NLS-1$
@@ -861,9 +859,7 @@ private final Map createFilteredContextTreeFor(final Set contextIds) {
861859
bindingErrors.add(context.getId());
862860

863861
// now log like you've never logged before!
864-
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.OK,
865-
"Undefined context while filtering dialog/window contexts", e); //$NON-NLS-1$
866-
Policy.getLog().log(status);
862+
Policy.getLog().log(Status.error("Undefined context while filtering dialog/window contexts", e)); //$NON-NLS-1$
867863
}
868864
}
869865
}
@@ -1568,10 +1564,7 @@ private final String[] getSchemeIds(String schemeId) {
15681564
try {
15691565
schemeId = getScheme(schemeId).getParentId();
15701566
} catch (final NotDefinedException e) {
1571-
Policy.getLog().log(
1572-
new Status(IStatus.ERROR, Policy.JFACE, IStatus.OK,
1573-
"Failed ascending scheme parents", //$NON-NLS-1$
1574-
e));
1567+
Policy.getLog().log(Status.error("Failed ascending scheme parents", e)); //$NON-NLS-1$
15751568
return new String[0];
15761569
}
15771570
}

bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,7 @@ public void showBlocked(Shell parentShell, IProgressMonitor blocking,
420420
protected Dialog(Shell parentShell) {
421421
this(new SameShellProvider(parentShell));
422422
if (parentShell == null && Policy.DEBUG_DIALOG_NO_PARENT) {
423-
Policy.getLog().log(
424-
new Status(IStatus.INFO, Policy.JFACE, IStatus.INFO, this
425-
.getClass()
426-
+ " created with no shell",//$NON-NLS-1$
427-
new Exception()));
423+
Policy.getLog().log(Status.info(this.getClass() + " created with no shell")); //$NON-NLS-1$
428424
}
429425
}
430426

bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public abstract class StatusDialog extends TrayDialog {
5858
*/
5959
public StatusDialog(Shell parent) {
6060
super(parent);
61-
fLastStatus = new Status(IStatus.OK, Policy.JFACE, IStatus.OK,
62-
Util.ZERO_LENGTH_STRING, null);
61+
fLastStatus = new Status(IStatus.OK, Policy.JFACE, Util.ZERO_LENGTH_STRING);
6362
}
6463

6564
/**

bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.eclipse.core.runtime.Assert;
2020
import org.eclipse.core.runtime.IProgressMonitor;
21-
import org.eclipse.core.runtime.IStatus;
2221
import org.eclipse.core.runtime.OperationCanceledException;
2322
import org.eclipse.core.runtime.ProgressMonitorWrapper;
2423
import org.eclipse.core.runtime.Status;
@@ -194,8 +193,8 @@ public void block() {
194193
throw new RuntimeException(t);
195194
}
196195
}
197-
Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE,
198-
"Unhandled event loop exception during blocked modal context.", t)); //$NON-NLS-1$
196+
Policy.getLog()
197+
.log(Status.error("Unhandled event loop exception during blocked modal context.", t)); //$NON-NLS-1$
199198
}
200199
}
201200
} else {

bundles/org.eclipse.jface/src/org/eclipse/jface/preference/PreferenceDialog.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.eclipse.core.runtime.Assert;
2727
import org.eclipse.core.runtime.ISafeRunnable;
28-
import org.eclipse.core.runtime.IStatus;
2928
import org.eclipse.core.runtime.ListenerList;
3029
import org.eclipse.core.runtime.SafeRunner;
3130
import org.eclipse.core.runtime.Status;
@@ -816,8 +815,7 @@ protected void handleSave() {
816815
} catch (IOException e) {
817816
String message = JFaceResources.format("PreferenceDialog.saveErrorMessage", page.getTitle(), //$NON-NLS-1$
818817
e.getMessage());
819-
Policy.getStatusHandler().show(
820-
new Status(IStatus.ERROR, Policy.JFACE, message, e),
818+
Policy.getStatusHandler().show(Status.error(message, e),
821819
JFaceResources.getString("PreferenceDialog.saveErrorTitle")); //$NON-NLS-1$
822820

823821
}
@@ -932,15 +930,11 @@ public void run() {
932930
public void handleException(Throwable e) {
933931
errorOccurred = true;
934932

935-
Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e));
933+
Policy.getLog().log(Status.error(e.toString(), e));
936934

937935
clearSelectedNode();
938936
String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$
939-
940-
Policy.getStatusHandler().show(
941-
new Status(IStatus.ERROR, Policy.JFACE, message, e),
942-
JFaceResources.getString("Error")); //$NON-NLS-1$
943-
937+
Policy.getStatusHandler().show(Status.error(message, e), JFaceResources.getString("Error")); //$NON-NLS-1$
944938
}
945939
});
946940
}

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FileImageDescriptor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.eclipse.core.runtime.FileLocator;
3030
import org.eclipse.core.runtime.IAdaptable;
3131
import org.eclipse.core.runtime.IPath;
32-
import org.eclipse.core.runtime.IStatus;
3332
import org.eclipse.core.runtime.Status;
3433
import org.eclipse.jface.internal.InternalPolicy;
3534
import org.eclipse.jface.util.Policy;
@@ -303,7 +302,7 @@ String getFilePath(String name, boolean logIOException) {
303302
} else if (InternalPolicy.DEBUG_LOG_URL_IMAGE_DESCRIPTOR_MISSING_2x) {
304303
if (name.endsWith("@2x.png") || name.endsWith("@1.5x.png")) { //$NON-NLS-1$ //$NON-NLS-2$
305304
String message = "High-resolution image missing: " + location + ' ' + name; //$NON-NLS-1$
306-
Policy.getLog().log(new Status(IStatus.WARNING, Policy.JFACE, message, e));
305+
Policy.getLog().log(Status.warning(message, e));
307306
}
308307
}
309308
return null;

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.eclipse.core.runtime.FileLocator;
2929
import org.eclipse.core.runtime.IAdaptable;
3030
import org.eclipse.core.runtime.IPath;
31-
import org.eclipse.core.runtime.IStatus;
3231
import org.eclipse.core.runtime.Status;
3332
import org.eclipse.jface.internal.InternalPolicy;
3433
import org.eclipse.jface.util.Policy;
@@ -172,7 +171,7 @@ private static ImageData getImageData(URL url) {
172171
// fall through otherwise
173172
}
174173
} catch (IOException e) {
175-
Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, e.getLocalizedMessage(), e));
174+
Policy.getLog().log(Status.error(e.getLocalizedMessage(), e));
176175
}
177176
return result;
178177
}
@@ -204,8 +203,7 @@ private static InputStream getStream(URL url) {
204203
if (InternalPolicy.DEBUG_LOG_URL_IMAGE_DESCRIPTOR_MISSING_2x) {
205204
String path = url.getPath();
206205
if (path.endsWith("@2x.png") || path.endsWith("@1.5x.png")) { //$NON-NLS-1$ //$NON-NLS-2$
207-
String message = "High-resolution image missing: " + url; //$NON-NLS-1$
208-
Policy.getLog().log(new Status(IStatus.WARNING, Policy.JFACE, message, e));
206+
Policy.getLog().log(Status.warning("High-resolution image missing: " + url, e)); //$NON-NLS-1$
209207
}
210208
}
211209
return null;
@@ -244,7 +242,7 @@ private static URL getxURL(URL url, int zoom) {
244242
}
245243
return new URL(url.getProtocol(), url.getHost(), url.getPort(), file);
246244
} catch (MalformedURLException e) {
247-
Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, e.getLocalizedMessage(), e));
245+
Policy.getLog().log(Status.error(e.getLocalizedMessage(), e));
248246
}
249247
}
250248
return null;
@@ -282,8 +280,7 @@ private static String getFilePath(URL url, boolean logIOException) {
282280
} else if (InternalPolicy.DEBUG_LOG_URL_IMAGE_DESCRIPTOR_MISSING_2x) {
283281
String path = url.getPath();
284282
if (path.endsWith("@2x.png") || path.endsWith("@1.5x.png")) { //$NON-NLS-1$ //$NON-NLS-2$
285-
String message = "High-resolution image missing: " + url; //$NON-NLS-1$
286-
Policy.getLog().log(new Status(IStatus.WARNING, Policy.JFACE, message, e));
283+
Policy.getLog().log(Status.warning("High-resolution image missing: " + url, e)); //$NON-NLS-1$
287284
}
288285
}
289286
return null;
@@ -363,7 +360,7 @@ private static URL getURL(String urlString) {
363360
try {
364361
result = new URL(urlString);
365362
} catch (MalformedURLException e) {
366-
Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, e.getLocalizedMessage(), e));
363+
Policy.getLog().log(Status.error(e.getLocalizedMessage(), e));
367364
}
368365
return result;
369366
}

bundles/org.eclipse.jface/src/org/eclipse/jface/util/LocalSelectionTransfer.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package org.eclipse.jface.util;
1515

1616

17-
import org.eclipse.core.runtime.IStatus;
1817
import org.eclipse.core.runtime.Status;
1918
import org.eclipse.jface.resource.JFaceResources;
2019
import org.eclipse.jface.viewers.ISelection;
@@ -129,11 +128,7 @@ public void javaToNative(Object object, TransferData transferData) {
129128
public Object nativeToJava(TransferData transferData) {
130129
Object result = super.nativeToJava(transferData);
131130
if (result != null && isInvalidNativeType(result)) {
132-
Policy.getLog().log(new Status(
133-
IStatus.ERROR,
134-
Policy.JFACE,
135-
IStatus.ERROR,
136-
JFaceResources.getString("LocalSelectionTransfer.errorMessage"), null)); //$NON-NLS-1$
131+
Policy.getLog().log(Status.error(JFaceResources.getString("LocalSelectionTransfer.errorMessage"))); //$NON-NLS-1$
137132
}
138133
return selection;
139134
}

bundles/org.eclipse.jface/src/org/eclipse/jface/util/Policy.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ public static ErrorSupportProvider getErrorSupportProvider() {
259259
* @since 3.4
260260
*/
261261
public static void logException(Exception exception) {
262-
getLog().log(
263-
new Status(IStatus.ERROR, JFACE, exception
264-
.getLocalizedMessage(), exception));
265-
262+
getLog().log(Status.error(exception.getLocalizedMessage(), exception));
266263
}
267264

268265
}

0 commit comments

Comments
 (0)