mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
- update progress monitor to show complete build command
- update progress monitor to normailize over each build.
This commit is contained in:
parent
becb0a5d20
commit
44e85901c9
5 changed files with 106 additions and 73 deletions
|
@ -37,6 +37,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
|
||||
public class MakeBuilder extends ACBuilder {
|
||||
|
@ -129,9 +130,6 @@ public class MakeBuilder extends ACBuilder {
|
|||
if (targets.length != 0 && targets[targets.length - 1].equals("clean")) //$NON-NLS-1$
|
||||
isClean = true;
|
||||
|
||||
// Before launching give visual cues via the monitor
|
||||
monitor.subTask(MakeCorePlugin.getResourceString("MakeBuilder.Invoking_Command") + buildCommand.toString()); //$NON-NLS-1$
|
||||
|
||||
String errMsg = null;
|
||||
CommandLauncher launcher = new CommandLauncher();
|
||||
// Print the command for visual interaction.
|
||||
|
@ -168,14 +166,17 @@ public class MakeBuilder extends ACBuilder {
|
|||
System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
|
||||
}
|
||||
}
|
||||
if (true) {
|
||||
// MakeRecon recon = new MakeRecon(buildCommand, buildArguments, env, workingDirectory, makeMonitor, cos);
|
||||
// recon.invokeMakeRecon();
|
||||
// cos = recon;
|
||||
cos = new StreamMonitor(new SubProgressMonitor(monitor, 100), cos);
|
||||
QualifiedName qName = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "progressMonitor");
|
||||
Integer last = (Integer)getProject().getSessionProperty(qName);
|
||||
if (last == null) {
|
||||
last = new Integer(100);
|
||||
}
|
||||
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), cos, last.intValue());
|
||||
ErrorParserManager epm = new ErrorParserManager(getProject(), this, info.getErrorParsers());
|
||||
epm.setOutputStream(cos);
|
||||
epm.setOutputStream(streamMon);
|
||||
OutputStream stdout = epm.getOutputStream();
|
||||
OutputStream stderr = epm.getOutputStream();
|
||||
Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
|
||||
|
@ -186,6 +187,8 @@ public class MakeBuilder extends ACBuilder {
|
|||
p.getOutputStream().close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
// Before launching give visual cues via the monitor
|
||||
monitor.subTask(MakeCorePlugin.getResourceString("MakeBuilder.Invoking_Command") + launcher.getCommandLine()); //$NON-NLS-1$
|
||||
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor, 0))
|
||||
!= CommandLauncher.OK)
|
||||
errMsg = launcher.getErrorMessage();
|
||||
|
@ -201,7 +204,7 @@ public class MakeBuilder extends ACBuilder {
|
|||
} else {
|
||||
errMsg = launcher.getErrorMessage();
|
||||
}
|
||||
// makeMonitor.done();
|
||||
getProject().setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null);
|
||||
|
||||
if (errMsg != null) {
|
||||
StringBuffer buf = new StringBuffer(buildCommand.toString() + " "); //$NON-NLS-1$
|
||||
|
|
|
@ -52,23 +52,24 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
private static MakeScannerProvider defaultProvider;
|
||||
|
||||
public static MakeScannerProvider getDefault() {
|
||||
if ( defaultProvider == null) {
|
||||
if (defaultProvider == null) {
|
||||
defaultProvider = new MakeScannerProvider();
|
||||
}
|
||||
return defaultProvider;
|
||||
}
|
||||
|
||||
|
||||
public MakeScannerInfo getMakeScannerInfo(IProject project, boolean cacheInfo) throws CoreException {
|
||||
MakeScannerInfo scannerInfo = null;
|
||||
// See if there's already one associated with the resource for this session
|
||||
// See if there's already one associated with the resource for this
|
||||
// session
|
||||
scannerInfo = (MakeScannerInfo)project.getSessionProperty(scannerInfoProperty);
|
||||
|
||||
// Try to load one for the project
|
||||
if (scannerInfo == null ) {
|
||||
// Try to load one for the project
|
||||
if (scannerInfo == null) {
|
||||
scannerInfo = loadScannerInfo(project);
|
||||
}
|
||||
|
||||
// There is nothing persisted for the session, or saved in a file so
|
||||
// There is nothing persisted for the session, or saved in a file so
|
||||
// create a build info object
|
||||
if (scannerInfo != null && cacheInfo == true) {
|
||||
project.setSessionProperty(scannerInfoProperty, scannerInfo);
|
||||
|
@ -98,14 +99,16 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
ListIterator iter = listeners.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
((IScannerInfoChangeListener)iter.next()).changeNotification(project, (IScannerInfo)info);
|
||||
((IScannerInfoChangeListener)iter.next()).changeNotification(project, info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IScannerInfo getScannerInformation(IResource resource) {
|
||||
IScannerInfo info = null;
|
||||
try {
|
||||
|
@ -117,8 +120,8 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
|
||||
/*
|
||||
* Loads the build file and parses the nodes for build information. The
|
||||
* information is then associated with the resource for the duration of
|
||||
* the session.
|
||||
* information is then associated with the resource for the duration of the
|
||||
* session.
|
||||
*/
|
||||
private MakeScannerInfo loadScannerInfo(IProject project) throws CoreException {
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||
|
@ -143,11 +146,11 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
|
||||
/**
|
||||
* The build model manager for standard builds only caches the build
|
||||
* information for a resource on a per-session basis. This method
|
||||
* allows clients of the build model manager to programmatically
|
||||
* remove the association between the resource and the information
|
||||
* while the reource is still open or in the workspace. The Eclipse core
|
||||
* will take care of removing it if a resource is closed or deleted.
|
||||
* information for a resource on a per-session basis. This method allows
|
||||
* clients of the build model manager to programmatically remove the
|
||||
* association between the resource and the information while the reource
|
||||
* is still open or in the workspace. The Eclipse core will take care of
|
||||
* removing it if a resource is closed or deleted.
|
||||
*
|
||||
* @param resource
|
||||
*/
|
||||
|
@ -159,21 +162,22 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
|
||||
/**
|
||||
* Persists build-specific information in the build file. Build
|
||||
* information for standard make projects consists of preprocessor
|
||||
* symbols and includes paths. Other project-related information is
|
||||
* stored in the persistent properties of the project.
|
||||
* Persists build-specific information in the build file. Build information
|
||||
* for standard make projects consists of preprocessor symbols and includes
|
||||
* paths. Other project-related information is stored in the persistent
|
||||
* properties of the project.
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
static void updateScannerInfo(MakeScannerInfo scannerInfo) throws CoreException {
|
||||
IProject project = scannerInfo.getProject();
|
||||
|
||||
// See if there's already one associated with the resource for this session
|
||||
if ( project.getSessionProperty(scannerInfoProperty) != null ) {
|
||||
// See if there's already one associated with the resource for this
|
||||
// session
|
||||
if (project.getSessionProperty(scannerInfoProperty) != null) {
|
||||
project.setSessionProperty(scannerInfoProperty, scannerInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||
|
||||
Element rootElement = descriptor.getProjectData(CDESCRIPTOR_ID);
|
||||
|
@ -208,8 +212,11 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
notifyInfoListeners(project, scannerInfo);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource,
|
||||
* org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
|
||||
*/
|
||||
public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) {
|
||||
IResource project = null;
|
||||
|
@ -234,8 +241,11 @@ public class MakeScannerProvider extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource,
|
||||
* org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
|
||||
*/
|
||||
public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
|
||||
IResource project = null;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
public IMakeTarget createTarget(IProject project, String name, String targetBuilderID) throws CoreException {
|
||||
return new MakeTarget(this, project, targetBuilderID, name);
|
||||
}
|
||||
|
||||
|
||||
public void addTarget(IContainer container, IMakeTarget target) throws CoreException {
|
||||
if (container instanceof IWorkspaceRoot) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeCorePlugin.getResourceString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$
|
||||
|
@ -70,7 +70,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeCorePlugin.getResourceString("MakeTargetManager.add_temporary_target"), null)); //$NON-NLS-1$
|
||||
}
|
||||
IProject project = container.getProject();
|
||||
ProjectTargets projectTargets = (ProjectTargets) projectMap.get(project);
|
||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(project);
|
||||
if (projectTargets == null) {
|
||||
projectTargets = readTargets(project);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
|
||||
public void removeTarget(IMakeTarget target) throws CoreException {
|
||||
IProject project = target.getContainer().getProject();
|
||||
ProjectTargets projectTargets = (ProjectTargets) projectMap.get(project);
|
||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(project);
|
||||
if (projectTargets == null) {
|
||||
projectTargets = readTargets(project);
|
||||
}
|
||||
|
@ -93,20 +93,20 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
|
||||
public void renameTarget(IMakeTarget target, String name) throws CoreException {
|
||||
IProject project = target.getContainer().getProject();
|
||||
ProjectTargets projectTargets = (ProjectTargets) projectMap.get(project);
|
||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(project);
|
||||
if (projectTargets == null) {
|
||||
projectTargets = readTargets(project);
|
||||
}
|
||||
if (!projectTargets.contains((MakeTarget) target)) {
|
||||
if (!projectTargets.contains((MakeTarget)target)) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeCorePlugin.getResourceString("MakeTargetManager.target_exists"), null)); //$NON-NLS-1$
|
||||
}
|
||||
((MakeTarget) target).setName(name);
|
||||
((MakeTarget)target).setName(name);
|
||||
writeTargets(projectTargets);
|
||||
notifyListeners(new MakeTargetEvent(this, MakeTargetEvent.TARGET_CHANGED, target));
|
||||
}
|
||||
|
||||
public IMakeTarget[] getTargets(IContainer container) throws CoreException {
|
||||
ProjectTargets projectTargets = (ProjectTargets) projectMap.get(container.getProject());
|
||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
|
||||
if (projectTargets == null) {
|
||||
projectTargets = readTargets(container.getProject());
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
|
||||
public IMakeTarget findTarget(IContainer container, String name) {
|
||||
ProjectTargets projectTargets = (ProjectTargets) projectMap.get(container.getProject());
|
||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
|
||||
if (projectTargets == null) {
|
||||
projectTargets = readTargets(container.getProject());
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
|
||||
public IProject[] getTargetBuilderProjects() throws CoreException {
|
||||
return (IProject[]) fProjects.toArray(new IProject[fProjects.size()]);
|
||||
return (IProject[])fProjects.toArray(new IProject[fProjects.size()]);
|
||||
}
|
||||
|
||||
public String[] getTargetBuilders(IProject project) {
|
||||
|
@ -134,13 +134,13 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
for (int i = 0; i < builder.length; i++) {
|
||||
Iterator entries = builderMap.entrySet().iterator();
|
||||
while (entries.hasNext()) {
|
||||
Map.Entry entry = (Entry) entries.next();
|
||||
Map.Entry entry = (Entry)entries.next();
|
||||
if (entry.getValue().equals(builder[i].getBuilderName())) {
|
||||
ids.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
return (String[]) ids.toArray(new String[ids.size()]);
|
||||
return (String[])ids.toArray(new String[ids.size()]);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,6 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
MakeCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MakeTargetVisitor implements IResourceDeltaVisitor {
|
||||
|
@ -200,7 +199,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
IResource resource = delta.getResource();
|
||||
if (resource.getType() == IResource.PROJECT) {
|
||||
IProject project = (IProject) resource;
|
||||
IProject project = (IProject)resource;
|
||||
int flags = delta.getFlags();
|
||||
int deltaKind = delta.getKind();
|
||||
if (deltaKind == IResourceDelta.ADDED) {
|
||||
|
@ -210,6 +209,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
} else if (deltaKind == IResourceDelta.REMOVED) {
|
||||
if (fProjects.contains(project)) {
|
||||
deleteTargets(project);
|
||||
fProjects.remove(project);
|
||||
notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project));
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
if (0 != (flags & IResourceDelta.DESCRIPTION)) {
|
||||
if (fProjects.contains(project) && !hasTargetBuilder(project)) {
|
||||
fProjects.remove(project);
|
||||
projectMap.remove(project);
|
||||
notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project));
|
||||
} else if (!fProjects.contains(project) && hasTargetBuilder(project)) {
|
||||
fProjects.add(project);
|
||||
|
@ -226,6 +227,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
if (0 != (flags & IResourceDelta.OPEN)) {
|
||||
if (!project.isOpen() && fProjects.contains(project)) {
|
||||
fProjects.remove(project);
|
||||
projectMap.remove(project);
|
||||
notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project));
|
||||
} else if (project.isOpen() && hasTargetBuilder(project) && !fProjects.contains(project)) {
|
||||
fProjects.add(project);
|
||||
|
@ -240,7 +242,9 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
|
||||
protected void writeTargets(ProjectTargets projectTargets) throws CoreException {
|
||||
IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(projectTargets.getProject().getName()).addFileExtension(TARGETS_EXT);
|
||||
IPath targetFilePath =
|
||||
MakeCorePlugin.getDefault().getStateLocation().append(projectTargets.getProject().getName()).addFileExtension(
|
||||
TARGETS_EXT);
|
||||
File targetFile = targetFilePath.toFile();
|
||||
try {
|
||||
FileOutputStream file = new FileOutputStream(targetFile);
|
||||
|
@ -249,11 +253,11 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
throw new CoreException(
|
||||
new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, "Error writing target file", e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected ProjectTargets readTargets(IProject project) {
|
||||
IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
|
||||
IPath targetFilePath =
|
||||
MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
|
||||
File targetFile = targetFilePath.toFile();
|
||||
ProjectTargets projectTargets = null;
|
||||
if (targetFile.exists()) {
|
||||
|
@ -262,12 +266,21 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
} catch (FileNotFoundException e) {
|
||||
}
|
||||
}
|
||||
if ( projectTargets == null) {
|
||||
projectTargets = new ProjectTargets(this, project);
|
||||
if (projectTargets == null) {
|
||||
projectTargets = new ProjectTargets(this, project);
|
||||
}
|
||||
projectMap.put(project, projectTargets);
|
||||
return projectTargets;
|
||||
}
|
||||
|
||||
protected void deleteTargets(IProject project) {
|
||||
IPath targetFilePath =
|
||||
MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
|
||||
File targetFile = targetFilePath.toFile();
|
||||
if (targetFile.exists()) {
|
||||
targetFile.delete();
|
||||
}
|
||||
projectMap.remove(project);
|
||||
}
|
||||
|
||||
protected void initializeBuilders() {
|
||||
|
@ -289,7 +302,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
protected void notifyListeners(MakeTargetEvent event) {
|
||||
Object[] list = listeners.getListeners();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
((IMakeTargetListener) list[i]).targetChanged(event);
|
||||
((IMakeTargetListener)list[i]).targetChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,6 +315,6 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
|
||||
public String getBuilderID(String targetBuilderID) {
|
||||
return (String) builderMap.get(targetBuilderID);
|
||||
return (String)builderMap.get(targetBuilderID);
|
||||
}
|
||||
}
|
|
@ -131,19 +131,19 @@ public class ProjectTargets {
|
|||
}
|
||||
|
||||
public IMakeTarget[] get(IContainer container) {
|
||||
ArrayList list = (ArrayList) targetMap.get(container);
|
||||
ArrayList list = (ArrayList)targetMap.get(container);
|
||||
if (list != null) {
|
||||
return (IMakeTarget[]) list.toArray(new IMakeTarget[list.size()]);
|
||||
return (IMakeTarget[])list.toArray(new IMakeTarget[list.size()]);
|
||||
}
|
||||
return new IMakeTarget[0];
|
||||
}
|
||||
|
||||
public IMakeTarget findTarget(IContainer container, String name) {
|
||||
ArrayList list = (ArrayList) targetMap.get(container);
|
||||
ArrayList list = (ArrayList)targetMap.get(container);
|
||||
if (list != null) {
|
||||
Iterator targets = list.iterator();
|
||||
while (targets.hasNext()) {
|
||||
IMakeTarget target = (IMakeTarget) targets.next();
|
||||
IMakeTarget target = (IMakeTarget)targets.next();
|
||||
if (target.getName().equals(name)) {
|
||||
return target;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class ProjectTargets {
|
|||
}
|
||||
|
||||
public void add(MakeTarget target) throws CoreException {
|
||||
ArrayList list = (ArrayList) targetMap.get(target.getContainer());
|
||||
ArrayList list = (ArrayList)targetMap.get(target.getContainer());
|
||||
if (list != null && list.contains(target)) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeCorePlugin.getResourceString("MakeTargetManager.target_exists"), null)); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class ProjectTargets {
|
|||
}
|
||||
|
||||
public boolean contains(MakeTarget target) {
|
||||
ArrayList list = (ArrayList) targetMap.get(target.getContainer());
|
||||
ArrayList list = (ArrayList)targetMap.get(target.getContainer());
|
||||
if (list != null && list.contains(target)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class ProjectTargets {
|
|||
}
|
||||
|
||||
public void remove(IMakeTarget target) {
|
||||
ArrayList list = (ArrayList) targetMap.get(target.getContainer());
|
||||
ArrayList list = (ArrayList)targetMap.get(target.getContainer());
|
||||
if (list == null || !list.contains(target)) {
|
||||
return;
|
||||
}
|
||||
|
@ -193,9 +193,9 @@ public class ProjectTargets {
|
|||
doc.appendChild(targetsRootElement);
|
||||
Iterator container = targetMap.entrySet().iterator();
|
||||
while (container.hasNext()) {
|
||||
List targets = (List) ((Map.Entry) container.next()).getValue();
|
||||
List targets = (List) ((Map.Entry)container.next()).getValue();
|
||||
for (int i = 0; i < targets.size(); i++) {
|
||||
MakeTarget target = (MakeTarget) targets.get(i);
|
||||
MakeTarget target = (MakeTarget)targets.get(i);
|
||||
targetsRootElement.appendChild(createTargetElement(doc, target));
|
||||
}
|
||||
}
|
||||
|
@ -239,5 +239,4 @@ public class ProjectTargets {
|
|||
SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(output, "UTF8"), format);
|
||||
serializer.asDOMSerializer().serialize(doc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,28 +19,32 @@ public class StreamMonitor extends OutputStream {
|
|||
|
||||
IProgressMonitor monitor;
|
||||
OutputStream console;
|
||||
public static final int TOTAL_WORK = 10;
|
||||
private int halfWay = TOTAL_WORK / 2;
|
||||
private int currentIncrement = 1;
|
||||
public final int fTotalWork;
|
||||
private int halfWay;
|
||||
private int currentIncrement = 2;
|
||||
private int nextProgress = currentIncrement;
|
||||
private int worked = 0;
|
||||
|
||||
public StreamMonitor(IProgressMonitor mon, OutputStream cos) {
|
||||
public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
|
||||
monitor = mon;
|
||||
console = cos;
|
||||
monitor.beginTask("", TOTAL_WORK);
|
||||
fTotalWork = totalWork;
|
||||
halfWay = fTotalWork / 2;
|
||||
monitor.beginTask("", fTotalWork);
|
||||
}
|
||||
|
||||
private void progressUpdate() {
|
||||
if (--nextProgress <= 0) {
|
||||
//we have exhausted the current increment, so report progress
|
||||
monitor.worked(1);
|
||||
if (fTotalWork > worked) {
|
||||
monitor.worked(1);
|
||||
}
|
||||
worked++;
|
||||
if (worked >= halfWay) {
|
||||
//we have passed the current halfway point, so double the
|
||||
//increment and reset the halfway point.
|
||||
currentIncrement *= 2;
|
||||
halfWay += (TOTAL_WORK - halfWay) / 2;
|
||||
halfWay += (fTotalWork - halfWay) / 2;
|
||||
}
|
||||
//reset the progress counter to another full increment
|
||||
nextProgress = currentIncrement;
|
||||
|
@ -91,4 +95,8 @@ public class StreamMonitor extends OutputStream {
|
|||
}
|
||||
progressUpdate();
|
||||
}
|
||||
|
||||
public int getWorkDone() {
|
||||
return worked;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue