use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureArtifactManager method getModuleFromAzureArtifact.
@Nullable
@AzureOperation(name = "common|artifact.get_module", params = { "azureArtifact.getName()" }, type = AzureOperation.Type.TASK)
public Module getModuleFromAzureArtifact(AzureArtifact azureArtifact) {
if (azureArtifact == null || azureArtifact.getReferencedObject() == null) {
return null;
}
switch(azureArtifact.getType()) {
case Gradle:
final String gradleModulePath = ((ExternalProjectPojo) azureArtifact.getReferencedObject()).getPath();
final VirtualFile gradleVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(gradleModulePath));
return ProjectFileIndex.getInstance(project).getModuleForFile(gradleVirtualFile);
case Maven:
return ProjectFileIndex.getInstance(project).getModuleForFile(((MavenProject) azureArtifact.getReferencedObject()).getFile());
default:
// IntelliJ artifact is bind to project, can not get the related module, same for File artifact
return null;
}
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class CreateWebAppAction method deploy.
@AzureOperation(name = "webapp.deploy_artifact", params = { "webapp.name()" }, type = AzureOperation.Type.ACTION)
private void deploy(final IWebApp webapp, final Path application, final Project project) {
final AzureString title = title("webapp.deploy_artifact", webapp.name());
final AzureTask<Void> task = new AzureTask<>(null, title, false, () -> {
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
final RunProcessHandler processHandler = new RunProcessHandler();
processHandler.addDefaultListener();
final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
processHandler.startNotify();
consoleView.attachToProcess(processHandler);
AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(webapp, application.toFile(), true, processHandler);
});
AzureTaskManager.getInstance().runInModalAsObservable(task).single().subscribe((none) -> {
this.notifyDeploymentSuccess(webapp);
});
// let root exception handler to show the error.
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class CreateWebAppAction method openDialog.
@AzureOperation(name = "webapp.open_creation_dialog", type = AzureOperation.Type.ACTION)
private void openDialog(final Project project, @Nullable final WebAppConfig data) {
final WebAppCreationDialog dialog = new WebAppCreationDialog(project);
if (Objects.nonNull(data)) {
dialog.setData(data);
}
dialog.setOkActionListener((config) -> {
dialog.close();
this.createWebApp(config).subscribe(webapp -> {
final Path artifact = config.getApplication();
if (Objects.nonNull(artifact) && artifact.toFile().exists()) {
AzureTaskManager.getInstance().runLater("deploy", () -> deploy(webapp, artifact, project));
}
}, (error) -> {
final String title = String.format("Reopen dialog \"%s\"", dialog.getTitle());
final Consumer<Object> act = t -> AzureTaskManager.getInstance().runLater("open dialog", () -> this.openDialog(project, config));
final Action<?> action = new Action<>(act, new ActionView.Builder(title));
AzureMessager.getMessager().error(error, null, action);
});
});
dialog.show();
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class WebAppOnLinuxAction method onActionPerformed.
@Override
@AzureOperation(name = "docker.start.configuration", type = AzureOperation.Type.ACTION)
public boolean onActionPerformed(@NotNull AnActionEvent event, @Nullable Operation operation) {
Module module = DataKeys.MODULE.getData(event.getDataContext());
if (module == null) {
return true;
}
AzureSignInAction.requireSignedIn(module.getProject(), () -> runConfiguration(module));
return false;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class WebDeployAction method runConfiguration.
@SuppressWarnings("deprecation")
@AzureOperation(name = "webapp.deploy_module", params = { "module.getName()" }, type = AzureOperation.Type.ACTION)
private void runConfiguration(Module module) {
Project project = module.getProject();
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final ConfigurationFactory factory = configType.getWebAppConfigurationFactory();
RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()));
if (settings == null) {
settings = manager.createConfiguration(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()), factory);
}
if (RunDialog.editConfiguration(project, settings, message("webapp.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
manager.addConfiguration(settings, false, tasks, false);
manager.setSelectedConfiguration(settings);
ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
}
}
Aggregations