use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.
the class ExternalSystemProjectsWatcher method scheduleUpdate.
private void scheduleUpdate(String projectPath) {
Pair<ExternalSystemManager, ExternalProjectSettings> linkedProject = findLinkedProjectSettings(projectPath);
if (linkedProject == null)
return;
ExternalSystemManager<?, ?, ?, ?, ?> manager = linkedProject.first;
ProjectSystemId systemId = manager.getSystemId();
boolean useAutoImport = linkedProject.second.isUseAutoImport();
if (useAutoImport) {
final ExternalSystemTask resolveTask = ServiceManager.getService(ExternalSystemProcessingManager.class).findTask(ExternalSystemTaskType.RESOLVE_PROJECT, systemId, projectPath);
final ExternalSystemTaskState taskState = resolveTask == null ? null : resolveTask.getState();
if (taskState == null || taskState.isStopped()) {
scheduleRefresh(myProject, projectPath, systemId, false);
} else if (taskState != ExternalSystemTaskState.NOT_STARTED) {
// TODO re-schedule to wait for the project import task end
}
} else {
myUpdatesQueue.queue(new Update(Pair.create(systemId, projectPath)) {
public void run() {
doUpdateNotifications(false, systemId, projectPath);
}
});
}
}
use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.
the class RefreshExternalProjectAction method perform.
@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
assert externalSystemNode != null;
final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
assert externalConfigPathAware != null;
// We save all documents because there is a possible case that there is an external system config file changed inside the ide.
FileDocumentManager.getInstance().saveAllDocuments();
final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
ExternalSystemUtil.refreshProject(project, projectSystemId, externalProjectPath, false, ProgressExecutionMode.IN_BACKGROUND_ASYNC);
}
use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.
the class ToggleAutoImportAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
final ExternalProjectSettings projectSettings = getProjectSettings(e);
if (projectSettings != null) {
if (state != projectSettings.isUseAutoImport()) {
projectSettings.setUseAutoImport(state);
ExternalSystemApiUtil.getSettings(getProject(e), getSystemId(e)).getPublisher().onUseAutoImportChange(state, projectSettings.getExternalProjectPath());
}
}
}
use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.
the class ExternalSystemApiUtil method isOneToOneMapping.
/**
* Allows to answer if given ide project has 1-1 mapping with the given external project, i.e. the ide project has been
* imported from external system and no other external projects have been added.
* <p/>
* This might be necessary in a situation when project-level setting is changed (e.g. project name). We don't want to rename
* ide project if it doesn't completely corresponds to the given ide project then.
*
* @param ideProject target ide project
* @param projectData target external project
* @return <code>true</code> if given ide project has 1-1 mapping to the given external project;
* <code>false</code> otherwise
*/
public static boolean isOneToOneMapping(@NotNull Project ideProject, @NotNull ProjectData projectData) {
String linkedExternalProjectPath = null;
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : getAllManagers()) {
ProjectSystemId externalSystemId = manager.getSystemId();
AbstractExternalSystemSettings systemSettings = getSettings(ideProject, externalSystemId);
Collection projectsSettings = systemSettings.getLinkedProjectsSettings();
int linkedProjectsNumber = projectsSettings.size();
if (linkedProjectsNumber > 1) {
// More than one external project of the same external system type is linked to the given ide project.
return false;
} else if (linkedProjectsNumber == 1) {
if (linkedExternalProjectPath == null) {
// More than one external project of different external system types is linked to the current ide project.
linkedExternalProjectPath = ((ExternalProjectSettings) projectsSettings.iterator().next()).getExternalProjectPath();
} else {
return false;
}
}
}
if (linkedExternalProjectPath != null && !linkedExternalProjectPath.equals(projectData.getLinkedExternalProjectPath())) {
// New external project is being linked.
return false;
}
for (Module module : ModuleManager.getInstance(ideProject).getModules()) {
if (!isExternalSystemAwareModule(projectData.getOwner(), module)) {
return false;
}
}
return true;
}
use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.
the class GradleRefreshProjectDependenciesAction method perform.
@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
assert externalSystemNode != null;
final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
assert externalConfigPathAware != null;
// We save all documents because there is a possible case that there is an external system config file changed inside the ide.
FileDocumentManager.getInstance().saveAllDocuments();
final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
ExternalSystemUtil.refreshProject(externalProjectPath, new ImportSpecBuilder(project, projectSystemId).useDefaultCallback().use(ProgressExecutionMode.IN_BACKGROUND_ASYNC).withArguments("--refresh-dependencies").build());
}
Aggregations