1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 04:25:21 +02:00

[219952][dstore] Use MessageFormat for download progress message

This commit is contained in:
Martin Oberhuber 2008-02-22 14:34:54 +00:00
parent 366b44c415
commit 622ba5c5b6
3 changed files with 28 additions and 49 deletions

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2006, 2007 IBM Corporation and others.
# Copyright (c) 2006, 2008 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
@ -12,7 +12,7 @@
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
#
# Contributors:
# {Name} (company) - description of contribution.
# Martin Oberhuber (Wind River) - [219952] Use MessageFormat for download progress message
###############################################################################
# NLS_MESSAGEFORMAT_VAR
@ -24,7 +24,7 @@ DStore_File_Service_Label=DStore File Service
DStore_Process_Service_Label=DStore Process Service
DStore_Service_ProgMon_Initializing_Message=Initializing &1...
DStore_Service_Percent_Complete_Message=&0 of &1 complete (&2)
DStore_Service_Percent_Complete_Message={0} KB of {1} KB complete ({2,number,percent})
DStore_Shell_Service_Description=The DStore Shell Service uses the RSE DataStore to provide service for the Shells subsystem. It requires a DataStore server or daemon to be running on the host machine.
DStore_Search_Service_Description=The DStore Search Service uses the RSE DataStore to provide service for remote searches. It requires a DataStore server or daemon to be running on the host machine.

View file

@ -35,6 +35,7 @@
* Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [219952] Use MessageFormat for download progress message
*******************************************************************************/
package org.eclipse.rse.internal.services.dstore.files;
@ -47,6 +48,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -59,7 +61,6 @@ import org.eclipse.dstore.core.model.DataStore;
import org.eclipse.dstore.core.model.DataStoreAttributes;
import org.eclipse.dstore.core.model.DataStoreResources;
import org.eclipse.dstore.core.model.IDataStoreProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
import org.eclipse.rse.dstore.universal.miners.UniversalByteStreamHandler;
import org.eclipse.rse.internal.services.dstore.ServiceResources;
@ -98,12 +99,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
private int _bufferDownloadSize = IUniversalDataStoreConstants.BUFFER_SIZE;
protected ISystemFileTypes _fileTypeRegistry;
private String remoteEncoding;
protected boolean unixStyle = false;
private static String _percentMsg = SystemMessage.sub(SystemMessage.sub(SystemMessage.sub(ServiceResources.DStore_Service_Percent_Complete_Message, "&0", "{0}"), "&1", "{1}"), "&2", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
private static String[] _filterAttributes = {
"attributes", //$NON-NLS-1$
"filter", //$NON-NLS-1$
@ -579,26 +577,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
if (/*display != null &&*/ monitor != null)
{
long percent = (totalSent * 100) / totalBytes;
StringBuffer totalSentBuf = new StringBuffer();
totalSentBuf.append((totalSent / IUniversalDataStoreConstants.KB_IN_BYTES));
totalSentBuf.append(" KB"); //$NON-NLS-1$
StringBuffer totalBuf = new StringBuffer();
totalBuf.append(totalBytes / IUniversalDataStoreConstants.KB_IN_BYTES);
totalBuf.append(" KB"); //$NON-NLS-1$
StringBuffer percentBuf = new StringBuffer();
percentBuf.append(percent);
percentBuf.append("%"); //$NON-NLS-1$
double percent = (totalSent * 1.0) / totalBytes;
monitor.worked(bytesRead);
String str = NLS.bind(_percentMsg, new Object[] {totalSentBuf, totalBuf, percentBuf});
String str = MessageFormat.format(
ServiceResources.DStore_Service_Percent_Complete_Message,
new Object[] {
new Long(totalSent / IUniversalDataStoreConstants.KB_IN_BYTES),
new Long(totalBytes / IUniversalDataStoreConstants.KB_IN_BYTES),
new Double(percent)
});
monitor.subTask(str);
isCancelled = monitor.isCanceled();
}
@ -1848,9 +1836,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
/**
*
* @param path
* @return could be null if there isn't one mapped right now
* Get a dstore IHostFile object for the given absolute path, provided
* that the file object has been accessed before and is available in our
* file map.
* @param path absolute file path identifying the remote object
* @return Requested file object or <code>null</code> if there isn't one mapped right now
*/
public IHostFile getHostFile(String path)
{

View file

@ -15,6 +15,7 @@
* David McKnight (IBM) - [162195] new APIs for upload multi and download multi
* David McKnight (IBM) - [197480] eliminating UI dependencies
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [219952] Use MessageFormat for download progress message
********************************************************************************/
package org.eclipse.rse.services.dstore.util;
@ -22,6 +23,7 @@ package org.eclipse.rse.services.dstore.util;
import java.io.File;
import java.text.MessageFormat;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.dstore.core.model.DE;
@ -29,10 +31,7 @@ import org.eclipse.dstore.core.model.DataElement;
import org.eclipse.dstore.core.model.DataStore;
import org.eclipse.dstore.extra.DomainEvent;
import org.eclipse.dstore.extra.IDomainListener;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
import org.eclipse.rse.internal.services.dstore.ServiceResources;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
public class DownloadListener implements IDomainListener
{
@ -48,8 +47,6 @@ public class DownloadListener implements IDomainListener
private long _totalBytesNotified = 0;
private long _totalLength;
private static String _percentMsg = SystemMessage.sub(SystemMessage.sub(SystemMessage.sub(ServiceResources.DStore_Service_Percent_Complete_Message, "&0", "{0}"), "&1", "{1}"), "&2", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
public DownloadListener(DataElement status, File localFile, String remotePath, long totalLength, IProgressMonitor monitor)
{
_monitor = monitor;
@ -151,22 +148,14 @@ public class DownloadListener implements IDomainListener
try
{
long percent = (currentLength * 100) / _totalLength;
StringBuffer current = new StringBuffer();
current.append(currentLength /IUniversalDataStoreConstants.KB_IN_BYTES);
current.append(" KB"); //$NON-NLS-1$
StringBuffer total = new StringBuffer();
total.append(_totalLength / IUniversalDataStoreConstants.KB_IN_BYTES);
total.append(" KB"); //$NON-NLS-1$
StringBuffer percentBuf = new StringBuffer();
percentBuf.append(percent);
percentBuf.append("%"); //$NON-NLS-1$
String str = NLS.bind(_percentMsg, new Object[] {current, total, percentBuf});
double percent = (currentLength * 1.0) / _totalLength;
String str = MessageFormat.format(
ServiceResources.DStore_Service_Percent_Complete_Message,
new Object[] {
new Long(currentLength/1024),
new Long(_totalLength/1024),
new Double(percent)
});
_monitor.subTask(str);