This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LANG: refactor BuildManager, BuildTarget, related classes.
Added initial Build Target tools.
- Loading branch information
1 parent
8382d8d
commit 5c06e86
Showing
24 changed files
with
782 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/AbstractToolManagerOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015, 2015 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 | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Bruno Medeiros - initial API and implementation | ||
*******************************************************************************/ | ||
package melnorme.lang.ide.core.operations; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
|
||
import melnorme.lang.ide.core.LangCore; | ||
import melnorme.utilbox.concurrency.OperationCancellation; | ||
import melnorme.utilbox.core.CommonException; | ||
import melnorme.utilbox.process.ExternalProcessHelper.ExternalProcessResult; | ||
|
||
public abstract class AbstractToolManagerOperation implements IBuildTargetOperation { | ||
|
||
protected final IProject project; | ||
|
||
public AbstractToolManagerOperation(IProject project) { | ||
this.project = project; | ||
} | ||
|
||
public IProject getProject() { | ||
return project; | ||
} | ||
|
||
protected AbstractToolManager getToolManager() { | ||
return LangCore.getToolManager(); | ||
} | ||
|
||
protected Path getBuildToolPath() throws CommonException { | ||
return getToolManager().getSDKToolPath(); | ||
} | ||
|
||
protected ExternalProcessResult runBuildTool(IProgressMonitor monitor, ProcessBuilder pb) | ||
throws CommonException, OperationCancellation { | ||
return getToolManager().newRunToolTask(pb, getProject(), monitor).runProcess(); | ||
} | ||
|
||
} |
133 changes: 133 additions & 0 deletions
133
plugin_ide.core/src-lang/melnorme/lang/ide/core/operations/BuildOperationCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015, 2015 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 | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Bruno Medeiros - initial API and implementation | ||
*******************************************************************************/ | ||
package melnorme.lang.ide.core.operations; | ||
|
||
import static java.text.MessageFormat.format; | ||
import static melnorme.lang.ide.core.utils.TextMessageUtils.headerBIG; | ||
import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; | ||
|
||
import java.nio.file.Path; | ||
import java.util.concurrent.Callable; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
|
||
import melnorme.lang.ide.core.LangCore; | ||
import melnorme.lang.ide.core.LangCore_Actual; | ||
import melnorme.lang.ide.core.project_model.BuildManager; | ||
import melnorme.lang.ide.core.project_model.BuildManagerMessages; | ||
import melnorme.lang.ide.core.project_model.ProjectBuildInfo; | ||
import melnorme.utilbox.collections.ArrayList2; | ||
import melnorme.utilbox.concurrency.OperationCancellation; | ||
import melnorme.utilbox.core.CommonException; | ||
|
||
public class BuildOperationCreator implements BuildManagerMessages { | ||
|
||
protected final BuildManager buildMgr = LangCore.getBuildManager(); | ||
|
||
protected final IProject project; | ||
protected final OperationInfo parentOpInfo; | ||
protected final boolean fullBuild; | ||
|
||
public BuildOperationCreator(IProject project, OperationInfo parentOpInfo, boolean fullBuild) { | ||
this.project = project; | ||
this.fullBuild = fullBuild; | ||
this.parentOpInfo = assertNotNull(parentOpInfo); | ||
} | ||
|
||
public IBuildTargetOperation getBuildOperation() throws CommonException { | ||
return new CompositeBuildOperation(createBuildOperations()); | ||
} | ||
|
||
protected ArrayList2<IBuildTargetOperation> createBuildOperations() throws CommonException { | ||
ArrayList2<IBuildTargetOperation> operations = ArrayList2.create(); | ||
|
||
String startMsg = headerBIG(format(MSG_BuildingProject, LangCore_Actual.LANGUAGE_NAME, project.getName())); | ||
operations.add(newMessageOperation(project, startMsg, true)); | ||
|
||
ProjectBuildInfo buildInfo = buildMgr.getBuildInfo(project); | ||
if(buildInfo == null) { | ||
operations.add(newMessageOperation(project, headerBIG(MSG_NoBuildTargetsEnabled), false)); | ||
return operations; | ||
} | ||
|
||
for(BuildTarget buildTarget : buildInfo.getBuildTargets()) { | ||
if(buildTarget.isEnabled()) { | ||
operations.add(newBuildTargetOperation(project, buildTarget)); | ||
} | ||
} | ||
|
||
operations.add(newMessageOperation(project, headerBIG(MSG_BuildTerminated), false)); | ||
|
||
return operations; | ||
} | ||
|
||
protected CommonBuildTargetOperation newBuildTargetOperation(IProject project, BuildTarget buildTarget) | ||
throws CommonException { | ||
return buildTarget.newBuildTargetOperation(parentOpInfo, project, fullBuild); | ||
} | ||
|
||
protected IBuildTargetOperation newMessageOperation(IProject project, String msg, boolean clearConsole) { | ||
return new BuildMessageOperation(parentOpInfo.createSubOperation(project, clearConsole, msg)); | ||
} | ||
|
||
protected class BuildMessageOperation implements IBuildTargetOperation, Callable<OperationInfo> { | ||
|
||
protected final OperationInfo opInfo; | ||
|
||
public BuildMessageOperation(OperationInfo opInfo) { | ||
this.opInfo = opInfo; | ||
} | ||
|
||
@Override | ||
public void execute(IProgressMonitor monitor) { | ||
executeDo(); | ||
} | ||
|
||
protected void executeDo() { | ||
call(); | ||
} | ||
|
||
@Override | ||
public OperationInfo call() throws RuntimeException { | ||
LangCore.getToolManager().notifyOperationStarted(opInfo); | ||
return opInfo; | ||
} | ||
} | ||
|
||
public static abstract class CommonBuildTargetOperation implements IBuildTargetOperation { | ||
|
||
protected final OperationInfo parentOperationInfo; | ||
protected final BuildTarget buildTarget; | ||
protected final Path buildToolPath; | ||
|
||
public CommonBuildTargetOperation(OperationInfo parentOperationInfo, Path buildToolPath, | ||
BuildTarget buildTarget) { | ||
this.buildToolPath = buildToolPath; | ||
this.parentOperationInfo = assertNotNull(parentOperationInfo); | ||
this.buildTarget = assertNotNull(buildTarget); | ||
} | ||
|
||
protected Path getBuildToolPath() throws CommonException { | ||
return buildToolPath; | ||
} | ||
|
||
protected String getBuildTargetName() { | ||
return buildTarget.getTargetName(); | ||
} | ||
|
||
@Override | ||
public abstract void execute(IProgressMonitor pm) throws CoreException, CommonException, OperationCancellation; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.