[475763] Improve Cache preference page UX
diff --git a/plugins/org.eclipse.wst.internet.cache/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.internet.cache/.settings/org.eclipse.jdt.core.prefs index 53d1a0e..a82f950 100644 --- a/plugins/org.eclipse.wst.internet.cache/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.wst.internet.cache/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,13 @@ -#Wed Mar 15 17:27:33 EST 2006 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve @@ -10,48 +18,88 @@ org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=error +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java index 863f379..0670efe 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
@@ -53,16 +53,16 @@ /** * String instances. */ - private static final String URI = "uri"; - private static final String LOCATION ="location"; - private static final String ENTRY = "entry"; - private static final String CACHE = "cache"; - private static final String LAST_MODIFIED = "lastModified"; - private static final String EXPIRATION_TIME = "expirationTime"; - private static final String FILE_PROTOCOL = "file:///"; - private static final String CACHE_FILE = "cache.xml"; - private static final String CACHE_EXTENSION = ".cache"; - private static final String CACHE_PREFIX = "wtpcache"; + private static final String URI = "uri"; //$NON-NLS-1$ + private static final String LOCATION ="location"; //$NON-NLS-1$ + private static final String ENTRY = "entry"; //$NON-NLS-1$ + private static final String CACHE = "cache"; //$NON-NLS-1$ + private static final String LAST_MODIFIED = "lastModified"; //$NON-NLS-1$ + private static final String EXPIRATION_TIME = "expirationTime"; //$NON-NLS-1$ + private static final String FILE_PROTOCOL = "file:///"; //$NON-NLS-1$ + private static final String CACHE_FILE = "cache.xml"; //$NON-NLS-1$ + private static final String CACHE_EXTENSION = ".cache"; //$NON-NLS-1$ + private static final String CACHE_PREFIX = "wtpcache"; //$NON-NLS-1$ private static final String CACHE_SUFFIX = null; @@ -145,12 +145,16 @@ { return null; } - return FILE_PROTOCOL + cacheLocation.toString() + "/" + result.getLocalFile(); + return FILE_PROTOCOL + cacheLocation.toString() + IPath.SEPARATOR + result.getLocalFile(); } + /** + * Return the preferred timeout in milliseconds + * @return + */ private static long getTimeout() { - return CachePlugin.getDefault().getCacheTimeout(); + return CachePlugin.getDefault().getCacheTimeout() * 60000; } /** @@ -202,10 +206,10 @@ URLConnection conn = url.openConnection(); /* XXX: This should really be implemented using HttpClient or similar */ int allowedRedirects = 5; - while(conn.getHeaderField("Location") != null && allowedRedirects > 0) + while(conn.getHeaderField("Location") != null && allowedRedirects > 0) //$NON-NLS-1$ { allowedRedirects--; - url = new URL(actualUri = conn.getHeaderField("Location")); + url = new URL(actualUri = conn.getHeaderField("Location")); //$NON-NLS-1$ conn = url.openConnection(); } // Determine if this resource can be cached. @@ -420,9 +424,10 @@ Result output = new StreamResult(stateLocation.toString() + "/" + CACHE_FILE); transformer.transform(input, output); - }catch(Exception e) + } + catch(Exception e) { - System.out.println("Unable to store internet cache."); + System.err.println("Unable to store internet cache."); //$NON-NLS-1$ } cacheInstance = null; }
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheMessages.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheMessages.java index d4ad4ea..e379613 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheMessages.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheMessages.java
@@ -1,5 +1,5 @@ /** - * Copyright (c) 2006 IBM Corporation and others. + * Copyright (c) 2006, 2017 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 @@ -33,6 +33,9 @@ public static String _UI_CACHE_MONITOR_NAME; public static String _UI_CACHE_MONITOR_CACHING; + public static String _NOT_A_VALID_NUMBER; + public static String _NUMBER_MUST_BE_GREATER_THAN_ZERO; + // Cache license dialog public static String _UI_CACHE_DIALOG_LICENSE_STATEMENT1; public static String _UI_CACHE_DIALOG_LICENSE_STATEMENT2;
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java index 7bf01fc..b8beba2 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java
@@ -25,7 +25,7 @@ /** * The ID of this plugin. */ - public static final String PLUGIN_ID = "org.eclipse.wst.internet.cache"; + public static final String PLUGIN_ID = "org.eclipse.wst.internet.cache"; //$NON-NLS-1$ /** * The shared instance. @@ -167,7 +167,7 @@ /** * Set the timeout for caching * - * @param timeout a timeout in ms + * @param timeout a timeout in minutes */ public void setCacheTimeout(long timeout) { @@ -175,9 +175,9 @@ } /** - * Returns the number of ms to cache a resource, or 86400000 (1 day) as default + * Returns the number of minutes to cache a resource, or 1440 (1 day) as default * - * @return a number of ms to cache a resource. The default is 86400000 (1 day) + * @return a number of minutes to cache a resource. The default is 1440 (1 day) */ public long getCacheTimeout() { @@ -187,7 +187,7 @@ return l; } // 1 day - return 86400000; + return 1440; }
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePluginResources.properties b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePluginResources.properties index 6409ec4..21d0e4b 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePluginResources.properties +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePluginResources.properties
@@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2005, 2006 IBM Corporation and others. +# Copyright (c) 2005, 2017 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -19,9 +19,11 @@ _UI_PREF_CACHE_ENTRIES_TITLE = &Cache entries: _UI_PREF_CACHE_CACHE_OPTION = &Disable caching _UI_PREF_CACHE_IGNORE_NO_CACHE_HEADER = Ignore no-cache header (always cache) -_UI_PREF_CACHE_CACHE_DURATION_LABEL = Cache Duration (ms): +_UI_PREF_CACHE_CACHE_DURATION_LABEL = Cache duration (minutes): _UI_PREF_CACHE_ABOUT = Manage the cache of remote resources, such as those downloaded from the internet. _UI_PREF_PROMPT_FOR_DISAGREED_LICENSES = &Prompt me for agreement for licenses for whose terms I have already disagreed +_NOT_A_VALID_NUMBER = Not a valid number +_NUMBER_MUST_BE_GREATER_THAN_ZERO = Value must be greater than zero # Cache monitor strings. _UI_CACHE_MONITOR_NAME = Caching Remote Resources
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheURIResolverExtension.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheURIResolverExtension.java index e8b2381..156ab43 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheURIResolverExtension.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheURIResolverExtension.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2012 IBM Corporation and others. + * Copyright (c) 2001, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,7 +35,7 @@ resource = URIHelper.normalize(systemId, baseLocation, null); } - if(resource != null && (resource.startsWith("http:") || resource.startsWith("ftp:"))) + if(resource != null && (resource.startsWith("http:") || resource.startsWith("ftp:"))) //$NON-NLS-1$ //$NON-NLS-2$ { // Handle resources prespecified to cache. ToCacheResource toCacheResource = ToCacheRegistryReader.getInstance().getResourceToCache(resource);
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java index 82119d8..7a4c471 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. + * Copyright (c) 2001, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ import java.util.Arrays; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -95,6 +96,7 @@ */ protected Control createContents(Composite parent) { + initializeDialogUnits(parent); noDefaultAndApplyButton(); composite = new Composite(parent, SWT.NULL); @@ -187,26 +189,41 @@ }); - // Created the cache duration setting + // Create the cache duration setting Composite durationWrapper = new Composite(composite, SWT.NONE); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gridData.horizontalSpan = 2; - durationWrapper.setLayoutData(gridData); + durationWrapper.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(2, 1).create()); GridLayout gl = new GridLayout(2, false); durationWrapper.setLayout(gl); Label cacheDurationLabel = new Label(durationWrapper, SWT.NONE); cacheDurationLabel.setText(CacheMessages._UI_PREF_CACHE_CACHE_DURATION_LABEL); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gridData = new GridData(SWT.FILL, SWT.FILL, false, false); cacheDurationLabel.setLayoutData(gridData); - cacheDuration = new Text(durationWrapper, SWT.BORDER | SWT.LEFT); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - cacheDuration.setLayoutData(gridData); + cacheDuration = new Text(durationWrapper, SWT.BORDER | SWT.TRAIL); cacheDuration.setText(Long.toString(CachePlugin.getDefault().getCacheTimeout())); + gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gridData.minimumWidth = gridData.widthHint = convertWidthInCharsToPixels(6); + cacheDuration.setLayoutData(gridData); cacheDuration.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - CachePlugin.getDefault().setCacheTimeout(Long.parseLong(cacheDuration.getText())); + try { + long newTimeout = Long.parseLong(cacheDuration.getText()); + CachePlugin.getDefault().setCacheTimeout(newTimeout); + + if (newTimeout < 1) { + setValid(newTimeout > 0); + setErrorMessage(CacheMessages._NUMBER_MUST_BE_GREATER_THAN_ZERO); + } + else { + setValid(true); + setErrorMessage(null); + } + } + catch (NumberFormatException e1) { + setValid(false); + setErrorMessage(CacheMessages._NOT_A_VALID_NUMBER); + } } });
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/PreferenceConstants.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/PreferenceConstants.java index a554eae..e8a426c 100644 --- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/PreferenceConstants.java +++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/PreferenceConstants.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. + * Copyright (c) 2001, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,11 +15,11 @@ * Constant definitions for plug-in preferences */ public class PreferenceConstants { - public static final String CACHE_ENABLED = "cacheEnabled"; + public static final String CACHE_ENABLED = "cacheEnabled"; //$NON-NLS-1$ - public static final String IGNORE_NO_CACHE_HEADER = "ignoreNoCacheHeader"; + public static final String IGNORE_NO_CACHE_HEADER = "ignoreNoCacheHeader"; //$NON-NLS-1$ - public static final String CACHE_DURATION = "cacheDuration"; + public static final String CACHE_DURATION = "cacheDuration"; //$NON-NLS-1$ - public static final String PROMPT_DISAGREED_LICENSES = "promptDisagreedLicenses"; + public static final String PROMPT_DISAGREED_LICENSES = "promptDisagreedLicenses"; //$NON-NLS-1$ }