Java Code Examples for com.intellij.openapi.project.Project#getName()
The following examples show how to use
com.intellij.openapi.project.Project#getName() .
These examples are extracted from open source projects.
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 Project: ok-gradle File: ProjectBuildModelImpl.java License: Apache License 2.0 | 6 votes |
/** * @param project the project this model should be built for * @param file the file contain the projects main build.gradle */ private ProjectBuildModelImpl(@NotNull Project project, @Nullable VirtualFile file) { myBuildModelContext = BuildModelContext.create(project); // First parse the main project build file. myProjectBuildFile = file != null ? new GradleBuildFile(file, project, project.getName(), myBuildModelContext) : null; if (myProjectBuildFile != null) { myBuildModelContext.setRootProjectFile(myProjectBuildFile); ApplicationManager.getApplication().runReadAction(() -> { populateWithParentModuleSubProjectsProperties(myProjectBuildFile, myBuildModelContext); populateSiblingDslFileWithGradlePropertiesFile(myProjectBuildFile, myBuildModelContext); myProjectBuildFile.parse(); }); myBuildModelContext.putBuildFile(file.getUrl(), myProjectBuildFile); } }
Example 2
Source Project: flutter-intellij File: AndroidUtils.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void enableCoeditIfAddToAppDetected(@NotNull Project project) { if (isCoeditTransformedProject(project)) { return; } // After a Gradle sync has finished we check the tasks that were run to see if any belong to Flutter. Map<ProjectData, MultiMap<String, String>> tasks = getTasksMap(project); @NotNull String projectName = project.getName(); for (ProjectData projectData : tasks.keySet()) { MultiMap<String, String> map = tasks.get(projectData); Collection<String> col = map.get(FLUTTER_PROJECT_NAME); if (col.isEmpty()) { col = map.get(""); // Android Studio uses this. } if (!col.isEmpty()) { if (col.parallelStream().anyMatch((x) -> x.startsWith(FLUTTER_TASK_PREFIX))) { ApplicationManager.getApplication().invokeLater(() -> enableCoEditing(project)); } } } }
Example 3
Source Project: flutter-intellij File: AndroidUtils.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void enableCoeditIfAddToAppDetected(@NotNull Project project) { if (isCoeditTransformedProject(project)) { return; } // After a Gradle sync has finished we check the tasks that were run to see if any belong to Flutter. Map<ProjectData, MultiMap<String, String>> tasks = getTasksMap(project); @NotNull String projectName = project.getName(); for (ProjectData projectData : tasks.keySet()) { MultiMap<String, String> map = tasks.get(projectData); Collection<String> col = map.get(FLUTTER_PROJECT_NAME); if (col.isEmpty()) { col = map.get(""); // Android Studio uses this. } if (!col.isEmpty()) { if (col.parallelStream().anyMatch((x) -> x.startsWith(FLUTTER_TASK_PREFIX))) { ApplicationManager.getApplication().invokeLater(() -> enableCoEditing(project)); } } } }
Example 4
Source Project: idea-php-toolbox File: ProjectHttpAction.java License: MIT License | 6 votes |
@Override protected Response handle(@NotNull Project project, @NotNull RequestMatcher requestMatcher) { ProjectStorageDic storageDic = new ProjectStorageDic(); storageDic.name = project.getName(); storageDic.presentableUrl = project.getPresentableUrl(); for (Map.Entry<String, ProviderStorageInterface> provider : RemoteStorage.getInstance(project).all().entrySet()) { try { storageDic.storages.put(provider.getKey(), provider.getValue().getData()); } catch (JsonSyntaxException ignored) { } } return new JsonResponse(storageDic); }
Example 5
Source Project: idea-php-toolbox File: ProjectHttpAction.java License: MIT License | 6 votes |
@Override protected Response handle(@NotNull Project project, @NotNull RequestMatcher requestMatcher) { ProjectStorageDic storageDic = new ProjectStorageDic(); storageDic.name = project.getName(); storageDic.presentableUrl = project.getPresentableUrl(); for (Map.Entry<String, ProviderStorageInterface> provider : RemoteStorage.getInstance(project).all().entrySet()) { try { storageDic.storages.put(provider.getKey(), provider.getValue().getData()); } catch (JsonSyntaxException ignored) { } } return new JsonResponse(storageDic); }
Example 6
Source Project: jetbrains-wakatime File: WakaTime.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void appendHeartbeat(final VirtualFile file, Project project, final boolean isWrite) { if (!shouldLogFile(file)) return; final String projectName = project != null ? project.getName() : null; final BigDecimal time = WakaTime.getCurrentTimestamp(); if (!isWrite && file.getPath().equals(WakaTime.lastFile) && !enoughTimePassed(time)) { return; } WakaTime.lastFile = file.getPath(); WakaTime.lastTime = time; final String language = WakaTime.getLanguage(file); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { Heartbeat h = new Heartbeat(); h.entity = file.getPath(); h.timestamp = time; h.isWrite = isWrite; h.project = projectName; h.language = language; heartbeatsQueue.add(h); } }); }
Example 7
Source Project: consulo File: ProgramParametersConfigurator.java License: Apache License 2.0 | 6 votes |
public void checkWorkingDirectoryExist(CommonProgramRunConfigurationParameters configuration, Project project, Module module) throws RuntimeConfigurationWarning { final String workingDir = getWorkingDir(configuration, project, module); if (workingDir == null) { throw new RuntimeConfigurationWarning("Working directory is null for " + "project '" + project.getName() + "' (" + project.getBasePath() + ")" + ", module " + (module == null ? "null" : "'" + module.getName() + "' (" + module.getModuleDirPath() + ")")); } if (!new File(workingDir).exists()) { throw new RuntimeConfigurationWarning("Working directory '" + workingDir + "' doesn't exist"); } }
Example 8
Source Project: consulo File: ProjectWindowActionGroup.java License: Apache License 2.0 | 6 votes |
public void addProject(@Nonnull Project project) { final String projectLocation = project.getPresentableUrl(); if (projectLocation == null) { return; } final String projectName = project.getName(); final ProjectWindowAction windowAction = new ProjectWindowAction(projectName, projectLocation, latest); final List<ProjectWindowAction> duplicateWindowActions = findWindowActionsWithProjectName(projectName); if (!duplicateWindowActions.isEmpty()) { for (ProjectWindowAction action : duplicateWindowActions) { action.getTemplatePresentation().setText(FileUtil.getLocationRelativeToUserHome(action.getProjectLocation())); } windowAction.getTemplatePresentation().setText(FileUtil.getLocationRelativeToUserHome(windowAction.getProjectLocation())); } add(windowAction); latest = windowAction; }
Example 9
Source Project: consulo File: ProjectWindowActionGroup.java License: Apache License 2.0 | 6 votes |
public void removeProject(@Nonnull Project project) { final ProjectWindowAction windowAction = findWindowAction(project.getPresentableUrl()); if (windowAction == null) { return; } if (latest == windowAction) { final ProjectWindowAction previous = latest.getPrevious(); if (previous != latest) { latest = previous; } else { latest = null; } } remove(windowAction); final String projectName = project.getName(); final List<ProjectWindowAction> duplicateWindowActions = findWindowActionsWithProjectName(projectName); if (duplicateWindowActions.size() == 1) { duplicateWindowActions.get(0).getTemplatePresentation().setText(projectName); } windowAction.dispose(); }
Example 10
Source Project: intellij-pants-plugin File: PantsOpenProjectProvider.java License: Apache License 2.0 | 5 votes |
private OpenProjectTask openTask(Project projectToClose, Project project, boolean forceOpenInNewFrame) { boolean useDefaultTemplate = false; boolean isNewProject = true; boolean isDummy = false; boolean sendFrameBack = false; boolean showWelcomeScreen = false; ProjectOpenedCallback callback = null; String projectId = null; FrameInfo frame = null; return new OpenProjectTask( forceOpenInNewFrame, projectToClose, useDefaultTemplate, isNewProject, project, project.getName(), isDummy, sendFrameBack, showWelcomeScreen, callback, frame, projectId, -1, -1 ); }
Example 11
Source Project: intellij-sdk-docs File: ShowSourceRootsActions.java License: Apache License 2.0 | 5 votes |
@Override public void actionPerformed(@NotNull final AnActionEvent event) { Project project = event.getProject(); if (project == null) return; String projectName = project.getName(); StringBuilder sourceRootsList = new StringBuilder(); VirtualFile[] vFiles = ProjectRootManager.getInstance(project).getContentSourceRoots(); for (VirtualFile file : vFiles) { sourceRootsList.append(file.getUrl()).append("\n"); } Messages.showInfoMessage("Source roots for the " + projectName + " plugin:\n" + sourceRootsList.toString(), "Project Properties"); }
Example 12
Source Project: consulo File: PlatformFrameTitleBuilder.java License: Apache License 2.0 | 5 votes |
@Override public String getProjectTitle(@Nonnull final Project project) { final String basePath = project.getBasePath(); if (basePath == null) return project.getName(); if (basePath.equals(project.getName())) { return "[" + FileUtil.getLocationRelativeToUserHome(basePath) + "]"; } else { return project.getName() + " - [" + FileUtil.getLocationRelativeToUserHome(basePath) + "]"; } }
Example 13
Source Project: EclipseCodeFormatter File: Notifier.java License: Apache License 2.0 | 5 votes |
public static void notifyDeletedSettings(final Project project) { String content = "Eclipse formatter settings profile was deleted for project " + project.getName() + ". Check the configuration."; final Notification notification = ProjectComponent.GROUP_DISPLAY_ID_ERROR.createNotification(content, NotificationType.ERROR); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, project); } }); }
Example 14
Source Project: consulo File: ProjectNameMacro.java License: Apache License 2.0 | 5 votes |
@Override public String expand(DataContext dataContext) { final Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) { return null; } return project.getName(); }
Example 15
Source Project: GitToolBox File: BehindNotifyTask.java License: Apache License 2.0 | 4 votes |
public BehindNotifyTask(@NotNull Project project) { this.project = project; projectName = project.getName(); }
Example 16
Source Project: saros File: ContactPopMenu.java License: GNU General Public License v2.0 | 4 votes |
/** * Prepares the JMenu for the given project. The menu contains entries for all modules that belong * to the project. The entries are grouped by whether they are shareable or not. Non-shareable * entries are disabled and have a tooltip explaining why/that they are not sharable. * * <p>If the module information for the given project can not be read, a disabled menu entry is * returned instead. The entry has a tooltip explaining that there was an issue reading the module * information. * * @param project the project whose menu to prepare * @return the <code>JMenu</code> for the project or a disabled <code>JMenuEntry</code> containing * only the project name if the module information could not be obtained for the project */ @NotNull private JMenuItem createProjectMenu(@NotNull Project project) { Pair<List<JMenuItem>, List<JMenuItem>> moduleItems = createModuleEntries(project); if (moduleItems == null) { JMenuItem errorMessageItem = new JMenuItem(project.getName()); errorMessageItem.setToolTipText(Messages.ContactPopMenu_menu_entry_error_processing_project); errorMessageItem.setEnabled(false); return errorMessageItem; } JMenu projectMenu = new JMenu(project.getName()); List<JMenuItem> shownModules = moduleItems.first; List<JMenuItem> nonCompliantModules = moduleItems.second; if (!shownModules.isEmpty()) { shownModules.sort(Comparator.comparing(JMenuItem::getText)); for (JMenuItem moduleItem : shownModules) { projectMenu.add(moduleItem); } } else { log.debug( "No modules shown to user as no modules " + (nonCompliantModules.isEmpty() ? "" : "complying with our current release restrictions ") + "were found"); JMenuItem noModulesFoundMenuItem = new JMenuItem( nonCompliantModules.isEmpty() ? Messages.ContactPopMenu_menu_entry_no_modules_found : Messages.ContactPopMenu_menu_entry_no_valid_modules_found); noModulesFoundMenuItem.setEnabled(false); projectMenu.add(noModulesFoundMenuItem); } // Show non-compliant modules as non-sharable if (!nonCompliantModules.isEmpty()) { projectMenu.addSeparator(); nonCompliantModules.sort(Comparator.comparing(JMenuItem::getText)); for (JMenuItem nonCompliantModuleItem : nonCompliantModules) { projectMenu.add(nonCompliantModuleItem); } } return projectMenu; }
Example 17
Source Project: saros File: ContactPopMenu.java License: GNU General Public License v2.0 | 4 votes |
/** * Creates the menu entries for the modules contained in the project. Returns the created entries * grouped by whether the described module is shareable or not. * * <p>Shareable module entries trigger the session negotiation when interacted with. Non-shareable * module entries are disabled and carry a tooltip explaining why the module can not be shared. * * @param project the project for whose modules to create menu entries * @return a <code>Pair</code> containing the entries for sharable modules (first element) and the * entries for non-shareable modules (second element) or <code>null</code> if the module * information for the project can not be read */ @Nullable private Pair<List<JMenuItem>, List<JMenuItem>> createModuleEntries(Project project) { ModuleManager moduleManager = ModuleManager.getInstance(project); if (moduleManager == null) { NotificationPanel.showError( MessageFormat.format( Messages.Contact_saros_message_conditional, Messages.ContactPopMenu_unsupported_ide_message_condition), Messages.ContactPopMenu_unsupported_ide_title); return null; } List<JMenuItem> shownModules = new ArrayList<>(); List<JMenuItem> nonCompliantModules = new ArrayList<>(); for (Module module : moduleManager.getModules()) { String moduleName = module.getName(); String fullModuleName = project.getName() + File.separator + moduleName; // TODO adjust once sharing multiple reference points is supported try { VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); if (contentRoots.length != 1) { throw new IllegalArgumentException("Unsupported number of content roots"); } VirtualFile contentRoot = contentRoots[0]; IReferencePoint wrappedModule = new IntellijReferencePoint(project, contentRoot); JMenuItem moduleItem = new JMenuItem(moduleName); moduleItem.setToolTipText(Messages.ContactPopMenu_menu_tooltip_share_module); moduleItem.addActionListener(new ShareDirectoryAction(project, moduleName, wrappedModule)); shownModules.add(moduleItem); } catch (IllegalArgumentException exception) { log.debug( "Ignoring module " + fullModuleName + " as it has multiple content roots and can't necessarily be completely shared."); JMenuItem invalidModuleEntry = new JMenuItem(moduleName); invalidModuleEntry.setEnabled(false); invalidModuleEntry.setToolTipText(Messages.ContactPopMenu_menu_tooltip_invalid_module); nonCompliantModules.add(invalidModuleEntry); } } return new Pair<>(shownModules, nonCompliantModules); }
Example 18
Source Project: dsl-compiler-client File: DslSyntaxHighlighterFactory.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
MapKey(Project project, String file) { this.project = project; this.file = file; id = project == null ? file : project.getName() + "/" + file; }
Example 19
Source Project: consulo File: ExternalSystemTaskId.java License: Apache License 2.0 | 4 votes |
@Nonnull public static String getProjectId(@Nonnull Project project) { return project.isDisposed() ? project.getName() : project.getName() + ":" + project.getLocationHash(); }
Example 20
Source Project: consulo File: IntegrationKey.java License: Apache License 2.0 | 4 votes |
public IntegrationKey(@Nonnull Project ideProject, @Nonnull ProjectSystemId externalSystemId, @Nonnull String externalProjectConfigPath) { this(ideProject.getName(), ideProject.getLocationHash(), externalSystemId, externalProjectConfigPath); }