com.intellij.openapi.application.ApplicationInfo Java Examples
The following examples show how to use
com.intellij.openapi.application.ApplicationInfo.
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: DesktopHelpManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static HelpSet createHelpSet() { String urlToHelp = ApplicationInfo.getInstance().getHelpURL() + "/" + HELP_HS; HelpSet mainHelpSet = loadHelpSet(urlToHelp); if (mainHelpSet == null) return null; // merge plugins help sets PluginDescriptor[] pluginDescriptors = PluginManagerCore.getPlugins(); for (PluginDescriptor pluginDescriptor : pluginDescriptors) { Collection<HelpSetPath> sets = pluginDescriptor.getHelpSets(); for (HelpSetPath hsPath : sets) { String url = "jar:file:///" + pluginDescriptor.getPath().getAbsolutePath() + "/help/" + hsPath.getFile() + "!"; if (!hsPath.getPath().startsWith("/")) { url += "/"; } url += hsPath.getPath(); HelpSet pluginHelpSet = loadHelpSet(url); if (pluginHelpSet != null) { mainHelpSet.add(pluginHelpSet); } } } return mainHelpSet; }
Example #2
Source File: RollbarErrorReportSubmitter.java From bamboo-soy with Apache License 2.0 | 6 votes |
private void log(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo) { IdeaLoggingEvent ideaEvent = events[0]; if (ideaEvent.getThrowable() == null) { return; } LinkedHashMap<String, Object> customData = new LinkedHashMap<>(); customData.put(TAG_PLATFORM_VERSION, ApplicationInfo.getInstance().getBuild().asString()); customData.put(TAG_OS, SystemInfo.OS_NAME); customData.put(TAG_OS_VERSION, SystemInfo.OS_VERSION); customData.put(TAG_OS_ARCH, SystemInfo.OS_ARCH); customData.put(TAG_JAVA_VERSION, SystemInfo.JAVA_VERSION); customData.put(TAG_JAVA_RUNTIME_VERSION, SystemInfo.JAVA_RUNTIME_VERSION); if (additionalInfo != null) { customData.put(EXTRA_ADDITIONAL_INFO, additionalInfo); } if (events.length > 1) { customData.put(EXTRA_MORE_EVENTS, Stream.of(events).map(Object::toString).collect(Collectors.joining("\n"))); } rollbar.codeVersion(getPluginVersion()).log(ideaEvent.getThrowable(), customData); }
Example #3
Source File: SpringFormatComponent.java From spring-javaformat with Apache License 2.0 | 6 votes |
private void registerCodeStyleManager(CodeStyleManager manager) { if (ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 193) { IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(PluginId.getId("spring-javaformat")); try { ((ComponentManagerImpl) this.project).registerServiceInstance(CodeStyleManager.class, manager, plugin); } catch (NoSuchMethodError ex) { Method method = findRegisterServiceInstanceMethod(this.project.getClass()); invokeRegisterServiceInstanceMethod(manager, plugin, method); } } else { MutablePicoContainer container = (MutablePicoContainer) this.project.getPicoContainer(); container.unregisterComponent(CODE_STYLE_MANAGER_KEY); container.registerComponentInstance(CODE_STYLE_MANAGER_KEY, manager); } }
Example #4
Source File: LSPQuickDocAction.java From lsp4intellij with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument()); Language language = PsiManager.getInstance(editor.getProject()).findFile(file).getLanguage(); //Hack for IntelliJ 2018 TODO proper way if (LanguageDocumentation.INSTANCE.allForLanguage(language).isEmpty() || (Integer.parseInt(ApplicationInfo.getInstance().getMajorVersion()) > 2017) && language == PlainTextLanguage.INSTANCE) { EditorEventManager manager = EditorEventManagerBase.forEditor(editor); if (manager != null) { manager.quickDoc(editor); } else { super.actionPerformed(e); } } else super.actionPerformed(e); }
Example #5
Source File: GoogleAnalyticsApplicationComponent.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
@Override public void initComponent() { applicationInfo = ApplicationInfo.getInstance(); AnalyticsListener.init(); ga = new CustomGoogleAnalytics(TRACKING_ID); ga.getConfig().setValidate(GraphConstants.IS_DEVELOPMENT); sessionStart(); ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override public void applicationExiting() { sessionEnd(); } }); }
Example #6
Source File: IdeaLightweightExtension.java From p4ic4idea with Apache License 2.0 | 6 votes |
private void initializeApplication(Application application) { DefaultPicoContainer pico = new DefaultPicoContainer(); when(application.getPicoContainer()).thenReturn(pico); MessageBus bus = new SingleThreadedMessageBus(null); when(application.getMessageBus()).thenReturn(bus); // Service setup. See ServiceManager pico.registerComponent(service(PasswordSafe.class, new MockPasswordSafe())); pico.registerComponent(service(VcsContextFactory.class, new MockVcsContextFactory())); VirtualFileManager vfm = mock(VirtualFileManager.class); when(application.getComponent(VirtualFileManager.class)).thenReturn(vfm); AccessToken readToken = mock(AccessToken.class); when(application.acquireReadActionLock()).thenReturn(readToken); ApplicationInfo appInfo = mock(ApplicationInfo.class); when(appInfo.getApiVersion()).thenReturn("IC-182.1.1"); registerApplicationService(ApplicationInfo.class, appInfo); }
Example #7
Source File: WakaTime.java From jetbrains-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void initComponent() { VERSION = PluginManager.getPlugin(PluginId.getId("com.wakatime.intellij.plugin")).getVersion(); log.info("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); //System.out.println("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // Set runtime constants IDE_NAME = PlatformUtils.getPlatformPrefix(); IDE_VERSION = ApplicationInfo.getInstance().getFullVersion(); setupDebugging(); setLoggingLevel(); Dependencies.configureProxy(); checkApiKey(); checkCli(); setupEventListeners(); setupQueueProcessor(); checkDebug(); log.info("Finished initializing WakaTime plugin"); }
Example #8
Source File: FrameTitleUtil.java From consulo with Apache License 2.0 | 6 votes |
public static String buildTitle() { ApplicationInfo applicationInfo = ApplicationInfo.getInstance(); StringBuilder builder = new StringBuilder(applicationInfo.getName()); builder.append(' '); builder.append(applicationInfo.getMajorVersion()); builder.append('.'); builder.append(applicationInfo.getMinorVersion()); UpdateChannel channel = UpdateSettings.getInstance().getChannel(); if (channel != UpdateChannel.release) { BuildNumber buildNumber = applicationInfo.getBuild(); builder.append(" #"); builder.append(buildNumber); builder.append(' '); builder.append(StringUtil.capitalize(channel.name())); } if (Platform.current().isUnderRoot()) { builder.append(" (Administrator)"); } return builder.toString(); }
Example #9
Source File: MacMainFrameDecorator.java From consulo with Apache License 2.0 | 6 votes |
private static void createProtocolHandler() { if (ourProtocolHandler == null) { // install uri handler final ID mainBundle = invoke("NSBundle", "mainBundle"); final ID urlTypes = invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleURLTypes")); final ApplicationInfo info = ApplicationInfo.getInstance(); final BuildNumber build = info != null ? info.getBuild() : null; if (urlTypes.equals(ID.NIL) && build != null && !build.isSnapshot()) { LOG.warn("no url bundle present. \n" + "To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file\n" + "Example: args.urlSchemes = [\"your-protocol\"] will handle following links: your-protocol://open?file=file&line=line"); return; } ourProtocolHandler = new CustomProtocolHandler(); Application.getApplication().setOpenURIHandler(new OpenURIHandler() { @Override public void openURI(AppEvent.OpenURIEvent event) { ourProtocolHandler.openLink(event.getURI()); } }); } }
Example #10
Source File: AppUIUtil.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") public static void updateWindowIcon(@Nonnull Window window, boolean isDark) { ApplicationInfo appInfo = ApplicationInfoImpl.getInstance(); List<Image> images = ContainerUtil.newArrayListWithCapacity(2); images.add(ImageLoader.loadFromResource(appInfo.getIconUrl(), isDark)); images.add(ImageLoader.loadFromResource(appInfo.getSmallIconUrl(), isDark)); for (int i = 0; i < images.size(); i++) { Image image = images.get(i); if (image instanceof JBHiDPIScaledImage) { images.set(i, ((JBHiDPIScaledImage)image).getDelegate()); } } window.setIconImages(images); }
Example #11
Source File: ContextHelpAction.java From consulo with Apache License 2.0 | 6 votes |
public void update(AnActionEvent event){ Presentation presentation = event.getPresentation(); if (!ApplicationInfo.contextHelpAvailable()) { presentation.setVisible(false); return; } if (ActionPlaces.MAIN_MENU.equals(event.getPlace())) { DataContext dataContext = event.getDataContext(); presentation.setEnabled(getHelpId(dataContext) != null); } else { presentation.setIcon(AllIcons.Actions.Help); presentation.setText(CommonBundle.getHelpButtonText()); } }
Example #12
Source File: StartupUtil.java From consulo with Apache License 2.0 | 6 votes |
private static void logStartupInfo(final Logger log) { LoggerFactory factory = LoggerFactoryInitializer.getFactory(); Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { @Override public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); factory.shutdown(); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); log.info("Using logger factory: " + factory.getClass().getSimpleName()); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); String buildDate = new SimpleDateFormat("dd MMM yyyy HH:ss", Locale.US).format(appInfo.getBuildDate().getTime()); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " + buildDate + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ", " + SystemInfo.OS_ARCH + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } }
Example #13
Source File: PluginsLoader.java From consulo with Apache License 2.0 | 6 votes |
public static void setVersionChecker() { PluginValidator.VALIDATOR = new PluginDescriptorVersionValidator() { @Override public boolean validateVersion(@Nonnull PluginDescriptor descriptor) { return !isIncompatible(descriptor); } private boolean isIncompatible(final PluginDescriptor descriptor) { String platformVersion = descriptor.getPlatformVersion(); if (StringUtil.isEmpty(platformVersion)) { return false; } try { BuildNumber buildNumber = ApplicationInfo.getInstance().getBuild(); BuildNumber pluginBuildNumber = BuildNumber.fromString(platformVersion); return !buildNumber.isSnapshot() && !pluginBuildNumber.isSnapshot() && !buildNumber.equals(pluginBuildNumber); } catch (RuntimeException ignored) { } return false; } }; }
Example #14
Source File: TabNineProcess.java From tabnine-intellij with MIT License | 6 votes |
void startTabNine() throws IOException { if (this.proc != null) { this.proc.destroy(); this.proc = null; } // When we tell TabNine that it's talking to IntelliJ, it won't suggest language server // setup since we assume it's already built into the IDE List<String> command = new ArrayList<>(); command.add(TabNineFinder.getTabNinePath()); List<String> metadata = new ArrayList<>(); metadata.add("--client-metadata"); metadata.add("pluginVersion=" + Utils.getPluginVersion()); metadata.add("clientIsUltimate=" + PlatformUtils.isIdeaUltimate()); final ApplicationInfo applicationInfo = ApplicationInfo.getInstance(); if (applicationInfo != null) { command.add("--client"); command.add(applicationInfo.getVersionName()); metadata.add("clientVersion=" + applicationInfo.getFullVersion()); metadata.add("clientApiVersion=" + applicationInfo.getApiVersion()); } command.addAll(metadata); ProcessBuilder builder = new ProcessBuilder(command); this.proc = builder.start(); this.procLineReader = new BufferedReader(new InputStreamReader(this.proc.getInputStream(), StandardCharsets.UTF_8)); }
Example #15
Source File: HttpRequests.java From leetcode-editor with Apache License 2.0 | 5 votes |
@Override public RequestBuilder productNameAsUserAgent() { Application app = ApplicationManager.getApplication(); if (app != null && !app.isDisposed()) { String productName = ApplicationNamesInfo.getInstance().getFullProductName(); String version = ApplicationInfo.getInstance().getBuild().asStringWithoutProductCode(); return userAgent(productName + '/' + version); } else { return userAgent("IntelliJ"); } }
Example #16
Source File: StatisticsConfigurationComponent.java From consulo with Apache License 2.0 | 5 votes |
public StatisticsConfigurationComponent() { String product = ApplicationNamesInfo.getInstance().getFullProductName(); String company = ApplicationInfo.getInstance().getCompanyName(); myTitle.setText(StatisticsBundle.message("stats.title", product, company)); myLabel.setText(StatisticsBundle.message("stats.config.details", company)); myLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); myAllowToSendUsagesCheckBox.setText(StatisticsBundle.message("stats.config.allow.send.stats.text", company)); myAllowToSendUsagesCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRadioButtonsEnabled(); } }); }
Example #17
Source File: FreezeLoggerImpl.java From consulo with Apache License 2.0 | 5 votes |
public ThreadDumpInfo(ThreadInfo[] threadInfos, boolean isInDumbMode) { this.threadInfos = threadInfos; this.product = ApplicationInfo.getInstance().getVersionName(); this.version = ApplicationInfo.getInstance().getFullVersion(); this.buildNumber = ApplicationInfo.getInstance().getBuild().toString(); this.isInDumbMode = isInDumbMode; }
Example #18
Source File: PlatformOrPluginUpdateChecker.java From consulo with Apache License 2.0 | 5 votes |
/** * Validate force bundle jre flag. If flag set version changed - it will be dropped */ private static void validateForceBundledJreVersion() { String oldVer = PropertiesComponent.getInstance().getValue(ourForceJREBuildVersion); String curVer = ApplicationInfo.getInstance().getBuild().toString(); if (!Objects.equals(oldVer, curVer)) { PropertiesComponent.getInstance().unsetValue(ourForceJREBuild); } }
Example #19
Source File: IdeBackgroundUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void initFramePainters(@Nonnull IdeGlassPaneImpl glassPane) { PaintersHelper painters = glassPane.getNamedPainters(FRAME_PROP); PaintersHelper.initWallpaperPainter(FRAME_PROP, painters); ApplicationInfo appInfo = ApplicationInfo.getInstance(); String path = /*UIUtil.isUnderDarcula()? appInfo.getEditorBackgroundImageUrl() : */null; URL url = path == null ? null : appInfo.getClass().getResource(path); Image centerImage = url == null ? null : ImageLoader.loadFromUrl(url); if (centerImage != null) { painters.addPainter(PaintersHelper.newImagePainter(centerImage, PaintersHelper.Fill.PLAIN, PaintersHelper.Place.TOP_CENTER, 1.0f, JBUI.insets(10, 0, 0, 0)), null); } painters.addPainter(new AbstractPainter() { EditorEmptyTextPainter p = EditorEmptyTextPainter.ourInstance; @Override public boolean needsRepaint() { return true; } @Override public void executePaint(Component component, Graphics2D g) { p.paintEmptyText((JComponent)component, g); } }, null); }
Example #20
Source File: DialogWrapper.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private Action[] filter(@Nonnull Action[] actions) { ArrayList<Action> answer = new ArrayList<>(); for (Action action : actions) { if (action != null && (ApplicationInfo.contextHelpAvailable() || action != getHelpAction())) { answer.add(action); } } return answer.toArray(new Action[answer.size()]); }
Example #21
Source File: StartupUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void prepareAndStart(String[] args, BiFunction<String, String, ImportantFolderLocker> lockFactory, PairConsumer<Boolean, CommandLineArgs> appStarter) { boolean newConfigFolder; CommandLineArgs commandLineArgs = CommandLineArgs.parse(args); if (commandLineArgs.isShowHelp()) { CommandLineArgs.printUsage(); System.exit(ExitCodes.USAGE_INFO); } if (commandLineArgs.isShowVersion()) { ApplicationInfo infoEx = ApplicationInfo.getInstance(); System.out.println(infoEx.getFullApplicationName()); System.exit(ExitCodes.VERSION_INFO); } AppUIUtil.updateFrameClass(); newConfigFolder = !new File(ContainerPathManager.get().getConfigPath()).exists(); ActivationResult result = lockSystemFolders(lockFactory, args); if (result == ActivationResult.ACTIVATED) { System.exit(0); } else if (result != ActivationResult.STARTED) { System.exit(ExitCodes.INSTANCE_CHECK_FAILED); } Logger log = Logger.getInstance(StartupUtil.class); logStartupInfo(log); loadSystemLibraries(log); fixProcessEnvironment(log); appStarter.consume(newConfigFolder, commandLineArgs); }
Example #22
Source File: QuarkusModelRegistry.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
private static String computeUserAgent() { StringBuilder builder = new StringBuilder(ApplicationInfo.getInstance().getBuild().getProductCode()); builder.append('/').append(ApplicationInfo.getInstance().getBuild().asStringWithoutProductCodeAndSnapshot()); builder.append(" (").append(System.getProperty("os.name")).append("; "); builder.append(System.getProperty("os.version")).append("; "); builder.append(System.getProperty("os.arch")).append("; "); builder.append("Java ").append(System.getProperty("java.version")).append(')'); return builder.toString(); }
Example #23
Source File: BuildNumberTest.java From CodeGen with MIT License | 5 votes |
public static void main(String[] args) { BuildNumber number = ApplicationInfo.getInstance().getBuild(); // IU-171.4249.39 System.out.println(number.asString()); // IU System.out.println(number.getProductCode()); // 171 System.out.println(number.getBaselineVersion()); // 171.4249.39 System.out.println(number.asStringWithoutProductCode()); System.out.println(number.asStringWithoutProductCodeAndSnapshot()); // false System.out.println(number.isSnapshot()); }
Example #24
Source File: Icons.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Icon getToolWindow() { // IntelliJ 2018.2+ has monochrome icons for tool windows so let's use one too if (ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 182) { return IconLoader.getIcon("/icons/org/antlr/intellij/plugin/toolWindowAntlr.svg"); } return IconLoader.getIcon("/icons/org/antlr/intellij/plugin/antlr.png"); }
Example #25
Source File: SendFeedbackAction.java From consulo with Apache License 2.0 | 5 votes |
public static void launchBrowser() { final ApplicationInfo appInfo = ApplicationInfo.getInstance(); String urlTemplate = appInfo.getReleaseFeedbackUrl(); urlTemplate = urlTemplate .replace("$BUILD", appInfo.getBuild().asString()) .replace("$TIMEZONE", System.getProperty("user.timezone")) .replace("$EVAL", "false"); BrowserUtil.browse(urlTemplate); }
Example #26
Source File: SymfonyInstallerUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable public static String getDownloadVersions() { String userAgent = String.format("%s / %s / Symfony Plugin %s", ApplicationInfo.getInstance().getVersionName(), ApplicationInfo.getInstance().getBuild(), PluginManager.getPlugin(PluginId.getId("fr.adrienbrault.idea.symfony2plugin")).getVersion() ); try { // @TODO: PhpStorm9: // simple replacement for: com.intellij.util.io.HttpRequests URL url = new URL("https://symfony.com/versions.json"); URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", userAgent); conn.connect(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String content = ""; String line; while ((line = in.readLine()) != null) { content += line; } in.close(); return content; } catch (IOException e) { return null; } }
Example #27
Source File: SuperBuilderInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void testBuilderDefaultValue() { final BuildNumber buildNumber = ApplicationInfo.getInstance().getBuild(); if (193 <= buildNumber.getBaselineVersion()) { doNamedTest(getTestName(false) + "193"); } else { doTest(); } }
Example #28
Source File: BuilderInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void testBuilderDefaultValue() { final BuildNumber buildNumber = ApplicationInfo.getInstance().getBuild(); if (193 <= buildNumber.getBaselineVersion()) { doNamedTest(getTestName(false) + "193"); } else { doTest(); } }
Example #29
Source File: StatisticsSendManager.java From consulo with Apache License 2.0 | 5 votes |
public Notification createNotification(@Nonnull final String groupDisplayId, @Nullable NotificationListener listener) { final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName(); final String companyName = ApplicationInfo.getInstance().getCompanyName(); String text = "<html>Please click <a href='allow'>I agree</a> if you want to help make " + fullProductName + " better or <a href='decline'>I don't agree</a> otherwise. <a href='settings'>more...</a></html>"; String title = "Help improve " + fullProductName + " by sending anonymous usage statistics to " + companyName; return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener); }
Example #30
Source File: WhatsNewAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { ApplicationInfo info = ApplicationInfo.getInstance(); boolean visible = info.getWhatsNewUrl() != null; e.getPresentation().setVisible(visible); if (visible) { e.getPresentation() .setText(IdeBundle.message("whatsnew.action.custom.text", info.getFullApplicationName())); e.getPresentation().setDescription( IdeBundle.message("whatsnew.action.custom.description", info.getFullApplicationName())); } }