本文整理汇总了Java中org.netbeans.api.extexecution.ExecutionDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionDescriptor类的具体用法?Java ExecutionDescriptor怎么用?Java ExecutionDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionDescriptor类属于org.netbeans.api.extexecution包,在下文中一共展示了ExecutionDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCallback
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
public void testCallback() throws InterruptedException {
ExecutionDescriptor desc = new ExecutionDescriptor();
ExecutionService service = ExecutionService.newService(new Callable<Process>() {
@Override
public Process call() throws Exception {
return new TestProcess();
}
}, desc, "Test"); // NOI18N
CountDownLatch latch = new CountDownLatch(1);
TestCallback callback = new TestCallback(latch);
RerunAction action = new RerunAction();
action.setExecutionService(service);
action.setRerunCallback(callback);
action.actionPerformed(null);
assertTrue(latch.await(5, TimeUnit.SECONDS));
}
示例2: runRegular
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private Future<Integer> runRegular() {
Charset charset = descriptor.charset;
if (charset == null) {
charset = execCharset;
}
Logger.getInstance().log(Level.FINE, "Input stream charset: {0}", charset);
ExecutionDescriptor descr =
new ExecutionDescriptor().controllable(descriptor.controllable).
frontWindow(descriptor.frontWindow).
preExecution(new PreExecution()).
inputVisible(descriptor.inputVisible).
inputOutput(descriptor.inputOutput).
outLineBased(descriptor.outLineBased).
showProgress(descriptor.showProgress).
postExecution(descriptor.postExecution).
noReset(!descriptor.resetInputOutputOnFinish).
errConvertorFactory(descriptor.errConvertorFactory).
outConvertorFactory(descriptor.outConvertorFactory).
charset(charset);
return ExecutionService.newService(processBuilder, descr, displayName).run();
}
示例3: runInternal
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
@CheckForNull
private Future<Integer> runInternal(ExecutionDescriptor executionDescriptor, ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory) {
Parameters.notNull("executionDescriptor", executionDescriptor); // NOI18N
final String error = ExternalExecutableValidator.validateCommand(executable, executableName);
if (error != null) {
if (warnUser) {
ExternalExecutableUserWarning euw = Lookup.getDefault().lookup(ExternalExecutableUserWarning.class);
if (euw == null) {
LOGGER.info("No implementation of "+ExternalExecutableUserWarning.class);
} else {
euw.displayError(error, optionsPath);
}
}
return null;
}
ProcessBuilder processBuilder = getProcessBuilder();
executionDescriptor = getExecutionDescriptor(executionDescriptor, outProcessorFactory);
return ExecutionService.newService(processBuilder, executionDescriptor, getDisplayName()).run();
}
示例4: executeEclipseCommand
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
public static void executeEclipseCommand(PlayProject playProject) {
try {
addEclipseSBTPluginIfNeeded(playProject);
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.inputVisible(true)
.showProgress(true);
ExternalProcessBuilder processBuilderEclipseCommand = new ExternalProcessBuilder(PlayProjectUtil.getActivatorExecutablePath())
.workingDirectory(new File(playProject.getProjectDirectory().getPath()))
.addArgument("eclipse");
processBuilderEclipseCommand = PlayProjectUtil.addJavaHomeVariable(processBuilderEclipseCommand);
ExecutionService serviceEclipseCommand = ExecutionService.newService(processBuilderEclipseCommand,
descriptor,
"Configuring (" + playProject.getProjectName() + ") Classpath");
Future<Integer> eclipseCommandFuture = serviceEclipseCommand.run();
eclipseCommandFuture.get(); //wait for this to finish before leave this method
} catch (InterruptedException | ExecutionException ex) {
ExceptionManager.logException(ex);
}
}
示例5: attachOutputProcessor
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
/**
* Attach a Processor to collect the output of the running process
*/
public void attachOutputProcessor()
{
descriptor = descriptor.outProcessorFactory(new ExecutionDescriptor.InputProcessorFactory()
{
public InputProcessor newInputProcessor()
{
return outProcessor;
}
public InputProcessor newInputProcessor(InputProcessor defaultProcessor)
{
return outProcessor;
}
});
}
示例6: detectDefaultWebBrowser
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private static String detectDefaultWebBrowser() {
// XXX hotfix for #233047
// assert !EventQueue.isDispatchThread();
// #233145
if (!XDG_SETTINGS_AVAILABLE) {
return null;
}
OutputProcessorFactory outputProcessorFactory = new OutputProcessorFactory();
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(XDG_SETTINGS_COMMAND) // NOI18N
.addArgument("get") // NOI18N
.addArgument("default-web-browser"); // NOI18N
ExecutionDescriptor silentDescriptor = new ExecutionDescriptor()
.inputOutput(InputOutput.NULL)
.inputVisible(false)
.frontWindow(false)
.showProgress(false)
.outProcessorFactory(outputProcessorFactory);
Future<Integer> result = ExecutionService.newService(processBuilder, silentDescriptor, "Detecting default web browser") // NOI18N
.run();
try {
result.get(10, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
LOGGER.log(Level.INFO, null, ex);
}
String output = outputProcessorFactory.getOutput();
if (output == null) {
return null;
}
return output.toLowerCase(Locale.US);
}
示例7: getDescriptor
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor getDescriptor(Runnable postTask) {
return new ExecutionDescriptor()
.inputOutput(IOProvider.getDefault().getIO(Bundle.Less_compile(), false))
.inputVisible(false)
.frontWindow(false)
.frontWindowOnError(CssPrepOptions.getInstance().getLessOutputOnError())
.noReset(true)
.showProgress(true)
.postExecution(postTask);
}
示例8: getSilentDescriptor
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private static ExecutionDescriptor getSilentDescriptor() {
return new ExecutionDescriptor()
.inputOutput(InputOutput.NULL)
.inputVisible(false)
.frontWindow(false)
.showProgress(false);
}
示例9: getDescriptor
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor getDescriptor(Runnable postTask) {
return new ExecutionDescriptor()
.inputOutput(IOProvider.getDefault().getIO(Bundle.SassCli_compile(), false))
.inputVisible(false)
.frontWindow(false)
.frontWindowOnError(CssPrepOptions.getInstance().getSassOutputOnError())
.noReset(true)
.showProgress(true)
.postExecution(postTask);
}
示例10: runAndWait
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
/**
* Run this executable with the given execution descriptor and optional output processor factory, <b>blocking but not blocking the UI thread</b>
* (it displays progress dialog if it is running in it).
* @param executionDescriptor execution descriptor to be used
* @param outProcessorFactory output processor factory to be used, can be {@code null}
* @param progressMessage message displayed if the task is running in the UI thread
* @return exit code of the process or {@code null} if any error occured
* @throws ExecutionException if any error occurs
* @see #runAndWait(String)
* @see #runAndWait(ExecutionDescriptor, String)
*/
@CheckForNull
public Integer runAndWait(@NonNull ExecutionDescriptor executionDescriptor, @NullAllowed ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory,
@NonNull final String progressMessage) throws ExecutionException {
Parameters.notNull("progressMessage", progressMessage); // NOI18N
final Future<Integer> result = run(executionDescriptor, outProcessorFactory);
if (result == null) {
return null;
}
final AtomicReference<ExecutionException> executionException = new AtomicReference<>();
if (Mutex.EVENT.isReadAccess()) { // Is EDT
if (!result.isDone()) {
try {
// let's wait in EDT to avoid flashing dialogs
getResult(result, 90L);
} catch (TimeoutException ex) {
BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
@Override
public void run() {
try {
getResult(result);
} catch (ExecutionException extEx) {
executionException.set(extEx);
}
}
}, progressMessage);
}
}
}
if (executionException.get() != null) {
throw executionException.get();
}
return getResult(result);
}
示例11: getExecutionDescriptor
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor getExecutionDescriptor(ExecutionDescriptor executionDescriptor, ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory) {
final List<ExecutionDescriptor.InputProcessorFactory2> inputProcessors = new CopyOnWriteArrayList<>();
// colors
ExecutionDescriptor.InputProcessorFactory2 infoOutProcessorFactory = getInfoOutputProcessorFactory();
if (infoOutProcessorFactory != null) {
inputProcessors.add(infoOutProcessorFactory);
}
// output
ExecutionDescriptor.InputProcessorFactory2 outputOutProcessorFactory = getOutputProcessorFactory();
if (outputOutProcessorFactory != null) {
inputProcessors.add(outputOutProcessorFactory);
}
// file output
ExecutionDescriptor.InputProcessorFactory2 fileOutProcessorFactory = getFileOutputProcessorFactory();
if (fileOutProcessorFactory != null) {
inputProcessors.add(fileOutProcessorFactory);
if (fileOutputOnly) {
executionDescriptor = executionDescriptor
.inputOutput(InputOutput.NULL)
.frontWindow(false)
.frontWindowOnError(false);
}
}
if (outProcessorFactory != null) {
inputProcessors.add(outProcessorFactory);
}
if (!inputProcessors.isEmpty()) {
executionDescriptor = executionDescriptor.outProcessorFactory(new ExecutionDescriptor.InputProcessorFactory2() {
@Override
public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
InputProcessor[] processors = new InputProcessor[inputProcessors.size()];
for (int i = 0; i < inputProcessors.size(); ++i) {
processors[i] = inputProcessors.get(i).newInputProcessor(defaultProcessor);
}
return InputProcessors.proxy(processors);
}
});
}
return executionDescriptor;
}
示例12: getInfoOutputProcessorFactory
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor.InputProcessorFactory2 getInfoOutputProcessorFactory() {
if (noInfo) {
// no info
return null;
}
return new ExecutionDescriptor.InputProcessorFactory2() {
@Override
public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
return new InfoInputProcessor(defaultProcessor, fullCommand);
}
};
}
示例13: getOutputProcessorFactory
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor.InputProcessorFactory2 getOutputProcessorFactory() {
if (noOutput) {
// no output
return null;
}
return new ExecutionDescriptor.InputProcessorFactory2() {
@Override
public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
return defaultProcessor;
}
};
}
示例14: getFileOutputProcessorFactory
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
private ExecutionDescriptor.InputProcessorFactory2 getFileOutputProcessorFactory() {
if (fileOutput == null) {
return null;
}
return new ExecutionDescriptor.InputProcessorFactory2() {
@Override
public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
return new RedirectOutputProcessor(fileOutput);
}
};
}
示例15: actionPerformed
import org.netbeans.api.extexecution.ExecutionDescriptor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ev) {
FileObject fileObject = context.getPrimaryFile();
String fileDisplayName = FileUtil.getFileDisplayName(fileObject);
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.showProgress(true)
.inputVisible(true)
.controllable(true)
.preExecution(() -> {
try {
Runtime.getRuntime().exec("chmod +x " + fileDisplayName).waitFor();
} catch (IOException | InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
LifecycleManager.getDefault().saveAll();
});
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(fileDisplayName);
ExecutionService service = ExecutionService.newService(
processBuilder, descriptor, fileDisplayName);
service.run();
}