use of com.intellij.openapi.application.AccessToken in project moe-ide-integration by multi-os-engine.
the class MOEMavenRunner method runBatch.
public boolean runBatch(List<MavenRunnerParameters> commands, @Nullable MavenGeneralSettings coreSettings, @Nullable MavenRunnerSettings runnerSettings, @Nullable final String action, @Nullable ProgressIndicator indicator) {
LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed());
if (commands.isEmpty())
return true;
MavenConsole console;
AccessToken accessToken = ReadAction.start();
try {
if (myProject.isDisposed())
return false;
console = createConsole();
} finally {
accessToken.finish();
}
try {
int count = 0;
for (MavenRunnerParameters command : commands) {
if (indicator != null) {
indicator.setFraction(((double) count++) / commands.size());
}
MavenExecutor executor;
accessToken = ReadAction.start();
try {
if (myProject.isDisposed())
break;
executor = createExecutor(command, coreSettings, runnerSettings, console);
} finally {
accessToken.finish();
}
executor.setAction(action);
if (!executor.execute(indicator)) {
updateTargetFolders();
return false;
}
}
updateTargetFolders();
} finally {
console.finish();
}
return true;
}
use of com.intellij.openapi.application.AccessToken in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudAttachDialog method stash.
private boolean stash() {
if (!syncResult.hasLocalRepository()) {
LOG.error("unexpected null local repro in call to stash");
return false;
}
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
if (changeListManager.isFreezedWithNotification("Can not stash changes now")) {
return false;
}
final GitLineHandler handler = new GitLineHandler(project, sourceRepository.getRoot(), GitCommand.STASH);
handler.addParameters("save");
handler.addParameters("--keep-index");
String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date());
stashMessage = "Cloud Debugger saved changes from branch " + originalBranchName + " at " + date;
handler.addParameters(stashMessage);
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
try {
GitHandlerUtil.doSynchronously(handler, GitBundle.getString("stashing.title"), handler.printableCommandLine());
} finally {
token.finish();
}
return true;
}
use of com.intellij.openapi.application.AccessToken in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPanel method configureAzureSDK.
private void configureAzureSDK() {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
return;
}
}
final LibrariesContainer.LibraryLevel level = LibrariesContainer.LibraryLevel.MODULE;
AccessToken token = WriteAction.start();
try {
Library newLibrary = LibrariesContainerFactory.createContainer(modifiableModel).createLibrary(AzureLibrary.APP_INSIGHTS.getName(), level, new ArrayList<OrderRoot>());
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
((ModuleLibraryOrderEntryImpl) orderEntry).setExported(true);
break;
}
}
Library.ModifiableModel newLibraryModel = newLibrary.getModifiableModel();
AddLibraryUtility.addLibraryFiles(new File(PluginHelper.getAzureLibLocation()), newLibraryModel, AzureLibrary.APP_INSIGHTS.getFiles());
newLibraryModel.commit();
modifiableModel.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
token.finish();
}
}
use of com.intellij.openapi.application.AccessToken in project azure-tools-for-java by Microsoft.
the class LibrariesConfigurationDialog method removeLibrary.
private void removeLibrary() {
AzureLibrary azureLibrary = (AzureLibrary) librariesList.getSelectedValue();
AccessToken token = WriteAction.start();
try {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
modifiableModel.getModuleLibraryTable().removeLibrary(modifiableModel.getModuleLibraryTable().getLibraryByName(azureLibrary.getName()));
modifiableModel.commit();
} finally {
token.finish();
}
((DefaultListModel) librariesList.getModel()).removeElement(azureLibrary);
tempList.remove(azureLibrary);
}
use of com.intellij.openapi.application.AccessToken in project azure-tools-for-java by Microsoft.
the class LibrariesConfigurationDialog method editLibrary.
private void editLibrary() {
AzureLibrary azureLibrary = (AzureLibrary) librariesList.getSelectedValue();
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
OrderEntry libraryOrderEntry = null;
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && azureLibrary.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
libraryOrderEntry = orderEntry;
break;
}
}
if (libraryOrderEntry != null) {
LibraryPropertiesPanel libraryPropertiesPanel = new LibraryPropertiesPanel(module, azureLibrary, true, ((ModuleLibraryOrderEntryImpl) libraryOrderEntry).isExported());
DefaultDialogWrapper libraryProperties = new DefaultDialogWrapper(module.getProject(), libraryPropertiesPanel);
libraryProperties.show();
if (libraryProperties.isOK()) {
AccessToken token = WriteAction.start();
try {
((ModuleLibraryOrderEntryImpl) libraryOrderEntry).setExported(libraryPropertiesPanel.isExported());
modifiableModel.commit();
} finally {
token.finish();
}
LocalFileSystem.getInstance().findFileByPath(PluginUtil.getModulePath(module)).refresh(true, true);
}
} else {
PluginUtil.displayInfoDialog("Library not found", "Library was not found");
}
}
Aggregations