use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class MavenProjectImporter method scheduleRefreshResolvedArtifacts.
private void scheduleRefreshResolvedArtifacts(List<MavenProjectsProcessorTask> postTasks) {
// We have to refresh all the resolved artifacts manually in order to
// update all the VirtualFilePointers. It is not enough to call
// VirtualFileManager.refresh() since the newly created files will be only
// picked by FS when FileWatcher finishes its work. And in the case of import
// it doesn't finish in time.
// I couldn't manage to write a test for this since behaviour of VirtualFileManager
// and FileWatcher differs from real-life execution.
List<MavenArtifact> artifacts = new ArrayList<>();
for (MavenProject each : myProjectsToImportWithChanges.keySet()) {
artifacts.addAll(each.getDependencies());
}
final Set<File> files = new THashSet<>();
for (MavenArtifact each : artifacts) {
if (each.isResolved())
files.add(each.getFile());
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
doRefreshFiles(files);
} else {
postTasks.add(new MavenProjectsProcessorTask() {
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator) throws MavenProcessCanceledException {
indicator.setText("Refreshing files...");
doRefreshFiles(files);
}
});
}
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class MavenRunConfigurationMenu method update.
@Override
public void update(AnActionEvent e) {
for (AnAction action : getChildActionsOrStubs()) {
if (action instanceof ExecuteMavenRunConfigurationAction) {
remove(action);
}
}
final Project project = e.getProject();
final RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
if (settings == null || project == null)
return;
Executor[] executors = ExecutorRegistry.getInstance().getRegisteredExecutors();
for (int i = executors.length; --i >= 0; ) {
final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executors[i].getId(), settings.getConfiguration());
AnAction action = new ExecuteMavenRunConfigurationAction(executors[i], runner != null, project, settings);
addAction(action, Constraints.FIRST);
}
super.update(e);
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class RemoveMavenRunConfigurationAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
Project project = e.getProject();
RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
boolean enabled = settings != null && project != null;
e.getPresentation().setEnabledAndVisible(enabled);
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class RemoveMavenRunConfigurationAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
assert settings != null && project != null;
int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation", Messages.getQuestionIcon());
if (res == Messages.YES) {
((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
}
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class SvnCheckinHandlerFactory method createVcsHandler.
@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
final Project project = panel.getProject();
final Collection<VirtualFile> commitRoots = panel.getRoots();
return new CheckinHandler() {
private Collection<Change> myChanges = panel.getSelectedChanges();
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
return null;
}
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
if (executor instanceof LocalCommitExecutor)
return ReturnResult.COMMIT;
final SvnVcs vcs = SvnVcs.getInstance(project);
final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges);
final List<String> repoUrls = new ArrayList<>();
for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) {
if (entry.getValue().size() > 1) {
repoUrls.add(entry.getKey());
}
}
if (!repoUrls.isEmpty()) {
final String join = StringUtil.join(repoUrls, ",\n");
final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon());
return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL;
}
return ReturnResult.COMMIT;
}
@Override
public void includedChangesChanged() {
myChanges = panel.getSelectedChanges();
}
@Override
public void checkinSuccessful() {
if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) {
final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project));
final List<FilePath> paths = new ArrayList<>();
for (VirtualFile root : roots) {
boolean take = false;
for (VirtualFile commitRoot : commitRoots) {
if (VfsUtilCore.isAncestor(root, commitRoot, false)) {
take = true;
break;
}
}
if (take) {
paths.add(VcsUtil.getFilePath(root));
}
}
if (paths.isEmpty())
return;
ApplicationManager.getApplication().invokeLater(() -> AutoSvnUpdater.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName()), ModalityState.NON_MODAL);
}
}
};
}
Aggregations