Java Code Examples for com.intellij.openapi.project.Project#isDefault()

The following examples show how to use com.intellij.openapi.project.Project#isDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IncomingChangesIndicator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public IncomingChangesIndicator(Application application, Project project, CommittedChangesCache cache) {
  myProject = project;
  myCache = cache;

  if(project.isDefault()) {
    return;
  }

  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
    @Override
    public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
      application.invokeLater(() -> refreshIndicator());
    }
  });
  final VcsListener listener = () -> UIUtil.invokeLaterIfNeeded(this::updateIndicatorVisibility);
  connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, listener);
  connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED_IN_PLUGIN, listener);
}
 
Example 2
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
  myProject = project;
  myDebuggerManager = debuggerManager;
  myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class);
  myDependentBreakpointManager = new XDependentBreakpointManager(this);
  myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
  if (!project.isDefault()) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      HttpVirtualFileListener httpVirtualFileListener = this::updateBreakpointInFile;
      HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
    }
    for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
      addDefaultBreakpoint(type);
    }
  }
}
 
Example 3
Source File: FlutterMakeHostAppEditableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null || project.isDefault()) {
    e.getPresentation().setEnabled(false);
    return;
  }
  boolean enabled = false;
  for (PubRoot root : PubRoots.forProject(project)) {
    if (root.isNonEditableFlutterModule()) {
      enabled = true;
      break;
    }
  }
  e.getPresentation().setEnabled(enabled);
}
 
Example 4
Source File: FileTemplatesLoader.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected FileTemplatesLoader(@Nonnull FileTypeManager typeManager, @Nullable Project project) {
  myTypeManager = typeManager;
  File configDir = project == null || project.isDefault()
                   ? new File(ContainerPathManager.get().getConfigPath(), TEMPLATES_DIR)
                   : new File(UriUtil.trimTrailingSlashes(StorageUtil.getStoreDir(project) + "/" + TEMPLATES_DIR));
  myDefaultTemplatesManager = new FTManager(FileTemplateManager.DEFAULT_TEMPLATES_CATEGORY, configDir);
  myInternalTemplatesManager = new FTManager(FileTemplateManager.INTERNAL_TEMPLATES_CATEGORY, new File(configDir, INTERNAL_DIR), true);
  myPatternsManager = new FTManager(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, new File(configDir, INCLUDES_DIR));
  myCodeTemplatesManager = new FTManager(FileTemplateManager.CODE_TEMPLATES_CATEGORY, new File(configDir, CODE_TEMPLATES_DIR));
  myJ2eeTemplatesManager = new FTManager(FileTemplateManager.J2EE_TEMPLATES_CATEGORY, new File(configDir, J2EE_TEMPLATES_DIR));
  myAllManagers = new FTManager[]{myDefaultTemplatesManager, myInternalTemplatesManager, myPatternsManager, myCodeTemplatesManager, myJ2eeTemplatesManager};

  myDirToManagerMap.put("", myDefaultTemplatesManager);
  myDirToManagerMap.put(INTERNAL_DIR + "/", myInternalTemplatesManager);
  myDirToManagerMap.put(INCLUDES_DIR + "/", myPatternsManager);
  myDirToManagerMap.put(CODE_TEMPLATES_DIR + "/", myCodeTemplatesManager);
  myDirToManagerMap.put(J2EE_TEMPLATES_DIR + "/", myJ2eeTemplatesManager);

  loadDefaultTemplates();
  for (FTManager manager : myAllManagers) {
    manager.loadCustomizedContent();
  }
}
 
Example 5
Source File: UnityPluginFileValidator.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
@Inject
public UnityPluginFileValidator(Application application, Project project)
{
	if(project.isDefault())
	{
		return;
	}

	application.getMessageBus().connect(project).subscribe(ProjectManager.TOPIC, new ProjectManagerListener()
	{
		@Override
		public void projectOpened(Project target, UIAccess uiAccess)
		{
			if(project == target)
			{
				runValidation(project);
			}
		}
	});
}
 
Example 6
Source File: ImportAction.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public void update(final AnActionEvent anActionEvent) {
    final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
    if (project == null || project.isDefault()) {
        anActionEvent.getPresentation().setVisible(false);
        anActionEvent.getPresentation().setEnabled(false);
        return;
    }
    anActionEvent.getPresentation().setVisible(true);
    anActionEvent.getPresentation().setEnabled(true);

}
 
Example 7
Source File: FileDocumentContentImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Navigatable getNavigatable(@Nonnull LineCol position) {
  Project project = getProject();
  if (project == null || project.isDefault() || !myFile.isValid()) return null;
  return new OpenFileDescriptor(project, myFile, position.line, position.column);
}
 
Example 8
Source File: DirDiffPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void focusTable() {
  final Project project = myModel.getProject();
  final IdeFocusManager focusManager = project == null || project.isDefault() ?
                                       IdeFocusManager.getGlobalInstance() :
                                       IdeFocusManager.getInstance(project);
  focusManager.requestFocus(myTable, true);
}
 
Example 9
Source File: VcsGeneralConfigurationPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public VcsGeneralConfigurationPanel(final Project project) {

    myProject = project;

    myOnFileAddingGroup = new JRadioButton[]{
      myShowDialogOnAddingFile,
      myPerformActionOnAddingFile,
      myDoNothingOnAddingFile
    };

    myOnFileRemovingGroup = new JRadioButton[]{
      myShowDialogOnRemovingFile,
      myPerformActionOnRemovingFile,
      myDoNothingOnRemovingFile
    };

    myPromptsPanel.setLayout(new GridLayout(3, 0));

    List<VcsShowOptionsSettingImpl> options = ProjectLevelVcsManagerEx.getInstanceEx(project).getAllOptions();

    for (VcsShowOptionsSettingImpl setting : options) {
      if (!setting.getApplicableVcses().isEmpty() || project.isDefault()) {
        final JCheckBox checkBox = new JCheckBox(setting.getDisplayName());
        myPromptsPanel.add(checkBox);
        myPromptOptions.put(setting, checkBox);
      }
    }

    myPromptsPanel.setSize(myPromptsPanel.getPreferredSize());                           // todo check text!
    myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") +
                              ShowFilePathAction.getFileManagerName() + " after creation:");
  }
 
Example 10
Source File: AbstractExternalModuleImportProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void executeAndRestoreDefaultProjectSettings(@Nonnull Project project, @Nonnull Runnable task) {
  if (!project.isDefault()) {
    task.run();
    return;
  }

  AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
  Object systemStateToRestore = null;
  if (systemSettings instanceof PersistentStateComponent) {
    systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
  }
  systemSettings.copyFrom(myControl.getSystemSettings());
  Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
  systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
  try {
    task.run();
  }
  finally {
    if (systemStateToRestore != null) {
      ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
    }
    else {
      systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
    }
  }
}
 
Example 11
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public IdeFrame findFrameFor(@Nullable final Project project) {
  IdeFrame frame = null;
  if (project != null) {
    frame = project.isDefault() ? WelcomeFrameManager.getInstance().getCurrentFrame() : getIdeFrame(project);
    if (frame == null) {
      frame = myProject2Frame.get(null);
    }
  }
  else {
    Container eachParent = TargetAWT.to(getMostRecentFocusedWindow());
    while (eachParent != null) {
      if (eachParent instanceof Window) {
        consulo.ui.Window uiWIndow = TargetAWT.from((Window)eachParent);
        IdeFrame ideFrame = uiWIndow.getUserData(IdeFrame.KEY);
        if(ideFrame != null) {
          frame = ideFrame;
          break;
        }
      }
      eachParent = eachParent.getParent();
    }

    if (frame == null) {
      frame = tryToFindTheOnlyFrame();
    }
  }

  return frame;
}
 
Example 12
Source File: ConfigMigrator.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
private boolean applyConfigOverrides(@NotNull Project project,
                                     @NotNull GitToolBoxConfig2 appConfig,
                                     @NotNull GitToolBoxConfigPrj prjConfig) {
  if (project.isDefault()) {
    return false;
  }
  ExtrasConfig override = appConfig.getExtrasConfig();
  ConfigOverridesMigrator migrator = new ConfigOverridesMigrator(project, override);
  boolean migrated = migrator.migrate(prjConfig);
  if (migrated) {
    log.info("Project overrides applied");
  }
  return migrated;
}
 
Example 13
Source File: GitLabOpenInBrowserAction.java    From IDEA-GitLab-Integration with MIT License 5 votes vote down vote up
@Override
public void update(final AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (project == null || project.isDefault() || virtualFile == null) {
        setVisibleEnabled(e, false, false);
        return;
    }

    final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
    if (gitRepository == null) {
        setVisibleEnabled(e, false, false);
        return;
    }

    ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    if (changeListManager.isUnversioned(virtualFile)) {
        setVisibleEnabled(e, true, false);
        return;
    }

    Change change = changeListManager.getChange(virtualFile);
    if (change != null && change.getType() == Change.Type.NEW) {
        setVisibleEnabled(e, true, false);
        return;
    }

    setVisibleEnabled(e, true, true);
}
 
Example 14
Source File: IdeaGateway.java    From consulo with Apache License 2.0 5 votes vote down vote up
VersionedFilterData() {
  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();

  for (Project each : openProjects) {
    if (each.isDefault()) continue;
    if (!each.isInitialized()) continue;

    myWorkspaceFiles.add(each.getWorkspaceFile());
    myOpenedProjects.add(each);
    myProjectFileIndices.add(ProjectRootManager.getInstance(each).getFileIndex());
  }
}
 
Example 15
Source File: SmartPointerManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static String anonymize(@Nonnull Project project) {
  return (project.isDisposed() ? "(Disposed)" : "") + (project.isDefault() ? "(Default)" : "") + project.hashCode();
}
 
Example 16
Source File: AttachDebuggerAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) {
  // NOTE: When making changes here, consider making similar changes to RunFlutterAction.
  FlutterInitializer.sendAnalyticsAction(this);

  RunConfiguration configuration = findRunConfig(project);
  if (configuration == null) {
    RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration();
    if (settings == null) {
      showSelectConfigDialog();
      return;
    }
    configuration = settings.getConfiguration();
    if (!(configuration instanceof SdkRunConfig)) {
      if (project.isDefault() || !FlutterSdkUtil.hasFlutterModules(project)) {
        return;
      }
      showSelectConfigDialog();
      return;
    }
  }

  SdkAttachConfig sdkRunConfig = new SdkAttachConfig((SdkRunConfig)configuration);
  SdkFields fields = sdkRunConfig.getFields();
  String additionalArgs = fields.getAdditionalArgs();

  String flavorArg = null;
  if (fields.getBuildFlavor() != null) {
    flavorArg = "--flavor=" + fields.getBuildFlavor();
  }

  List<String> args = new ArrayList<>();
  if (additionalArgs != null) {
    args.add(additionalArgs);
  }
  if (flavorArg != null) {
    args.add(flavorArg);
  }
  if (!args.isEmpty()) {
    fields.setAdditionalArgs(Joiner.on(" ").join(args));
  }

  Executor executor = RunFlutterAction.getExecutor(ToolWindowId.DEBUG);
  if (executor == null) {
    return;
  }

  ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig);

  ExecutionEnvironment env = builder.activeTarget().dataContext(context).build();
  FlutterLaunchMode.addToEnvironment(env, FlutterLaunchMode.DEBUG);

  if (project.getUserData(ATTACH_IS_ACTIVE) == null) {
    project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(false));
    onAttachTermination(project, (p) -> p.putUserData(ATTACH_IS_ACTIVE, null));
  }
  ProgramRunnerUtil.executeConfiguration(env, false, true);
}
 
Example 17
Source File: ProjectKt.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isDirectoryBased(@Nonnull Project project) {
  if(project.isDefault()) {
    return false;
  }
  return true;
}
 
Example 18
Source File: SpeedSearchBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void manageSearchPopup(@Nullable SearchPopup searchPopup) {
  Project project = null;
  if (ApplicationManager.getApplication() != null && !ApplicationManager.getApplication().isDisposed()) {
    project = DataManager.getInstance().getDataContext(myComponent).getData(CommonDataKeys.PROJECT);
  }
  if (project != null && project.isDefault()) {
    project = null;
  }
  if (mySearchPopup != null) {
    if (myPopupLayeredPane != null) {
      myPopupLayeredPane.remove(mySearchPopup);
      myPopupLayeredPane.validate();
      myPopupLayeredPane.repaint();
      myPopupLayeredPane = null;
    }

    if (myListenerDisposable != null) {
      Disposer.dispose(myListenerDisposable);
      myListenerDisposable = null;
    }
  }
  else if (searchPopup != null) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.tree.speedsearch");
  }

  mySearchPopup = myComponent.isShowing() ? searchPopup : null;

  fireStateChanged();

  //select here!


  if (mySearchPopup == null || !myComponent.isDisplayable()) return;

  if (project != null) {
    myListenerDisposable = Disposable.newDisposable();
    project.getMessageBus().connect(myListenerDisposable).subscribe(ToolWindowManagerListener.TOPIC, myWindowManagerListener);
  }
  JRootPane rootPane = myComponent.getRootPane();
  myPopupLayeredPane = rootPane == null ? null : rootPane.getLayeredPane();
  if (myPopupLayeredPane == null) {
    LOG.error(this + " in " + myComponent);
    return;
  }
  myPopupLayeredPane.add(mySearchPopup, JLayeredPane.POPUP_LAYER);
  moveSearchPopup();

  mySearchPopup.refreshSelection();
}
 
Example 19
Source File: AttachDebuggerAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) {
  // NOTE: When making changes here, consider making similar changes to RunFlutterAction.
  FlutterInitializer.sendAnalyticsAction(this);

  RunConfiguration configuration = findRunConfig(project);
  if (configuration == null) {
    RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration();
    if (settings == null) {
      showSelectConfigDialog();
      return;
    }
    configuration = settings.getConfiguration();
    if (!(configuration instanceof SdkRunConfig)) {
      if (project.isDefault() || !FlutterSdkUtil.hasFlutterModules(project)) {
        return;
      }
      showSelectConfigDialog();
      return;
    }
  }

  SdkAttachConfig sdkRunConfig = new SdkAttachConfig((SdkRunConfig)configuration);
  SdkFields fields = sdkRunConfig.getFields();
  String additionalArgs = fields.getAdditionalArgs();

  String flavorArg = null;
  if (fields.getBuildFlavor() != null) {
    flavorArg = "--flavor=" + fields.getBuildFlavor();
  }

  List<String> args = new ArrayList<>();
  if (additionalArgs != null) {
    args.add(additionalArgs);
  }
  if (flavorArg != null) {
    args.add(flavorArg);
  }
  if (!args.isEmpty()) {
    fields.setAdditionalArgs(Joiner.on(" ").join(args));
  }

  Executor executor = RunFlutterAction.getExecutor(ToolWindowId.DEBUG);
  if (executor == null) {
    return;
  }

  ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig);

  ExecutionEnvironment env = builder.activeTarget().dataContext(context).build();
  FlutterLaunchMode.addToEnvironment(env, FlutterLaunchMode.DEBUG);

  if (project.getUserData(ATTACH_IS_ACTIVE) == null) {
    project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(false));
    onAttachTermination(project, (p) -> p.putUserData(ATTACH_IS_ACTIVE, null));
  }
  ProgramRunnerUtil.executeConfiguration(env, false, true);
}
 
Example 20
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void openOrImportProject(@NotNull VirtualFile projectFile,
                                        @Nullable Project project,
                                        @Nullable VirtualFile sourceFile,
                                        boolean forceOpenInNewFrame) {
  // This is very similar to AndroidOpenFileAction.openOrImportProject().
  if (canImportAsGradleProject(projectFile)) {
    VirtualFile target = findGradleTarget(projectFile);
    if (target != null) {
      Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
      if (openProjects.length > 0) {
        int exitCode = forceOpenInNewFrame ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : confirmOpenNewProject(false);
        if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
          Project toClose = ((project != null) && !project.isDefault()) ? project : openProjects[openProjects.length - 1];
          if (!closeAndDispose(toClose)) {
            return;
          }
        }
        else if (exitCode != GeneralSettings.OPEN_PROJECT_NEW_WINDOW) {
          return;
        }
      }

      GradleProjectImporter gradleImporter = GradleProjectImporter.getInstance();
      gradleImporter.importAndOpenProjectCore(null, true, projectFile);
      for (Project proj : ProjectManager.getInstance().getOpenProjects()) {
        if (projectFile.equals(proj.getBaseDir()) || projectFile.equals(proj.getProjectFile())) {
          if (sourceFile != null && !sourceFile.isDirectory()) {
            OpenFileAction.openFile(sourceFile, proj);
          }
          break;
        }
      }
      return;
    }
  }
  Project newProject = openOrImport(projectFile.getPath(), project, false);
  if (newProject != null) {
    setLastOpenedFile(newProject, projectFile);
    if (sourceFile != null && !sourceFile.isDirectory()) {
      OpenFileAction.openFile(sourceFile, newProject);
    }
  }
}