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); }
private void addAgent(com.samebug.clients.common.tracking.RawEvent e) { final Map<String, String> agent = new HashMap<String, String>(); final LookAndFeel laf = UIManager.getLookAndFeel(); final ApplicationInfo appInfo = ApplicationInfo.getInstance(); final IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId(IdeaSamebugPlugin.ID)); final String pluginVersion = plugin == null ? null : plugin.getVersion(); final String instanceId = config.instanceId; agent.put("type", "ide-plugin"); agent.put("ideCodeName", appInfo.getBuild().getProductCode()); if (laf != null) agent.put("lookAndFeel", laf.getName()); if (pluginVersion != null) agent.put("pluginVersion", pluginVersion); if (instanceId != null) agent.put("instanceId", instanceId); agent.put("isRetina", Boolean.toString(UIUtil.isRetina())); agent.put("ideBuild", appInfo.getApiVersion()); e.withField("agent", agent); }
public ProjectNameStep(WizardContext wizardContext) { myWizardContext = wizardContext; myNamePathComponent = new NamePathComponent(IdeBundle.message("label.project.name"), IdeBundle.message("label.component.file.location", StringUtil.capitalize(myWizardContext.getPresentationName())), 'a', 'l', IdeBundle.message("title.select.project.file.directory", myWizardContext.getPresentationName()), IdeBundle.message("description.select.project.file.directory", myWizardContext.getPresentationName())); myPanel = new JPanel(new GridBagLayout()); myPanel.setBorder(BorderFactory.createEtchedBorder()); ApplicationInfo info = ApplicationInfo.getInstance(); String appName = info.getVersionName(); myPanel.add(new JLabel(IdeBundle.message("label.please.enter.project.name", appName, wizardContext.getPresentationName())), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); }
public void update(AnActionEvent event){ Presentation presentation = event.getPresentation(); if (!ApplicationInfo.contextHelpAvailable()) { presentation.setVisible(false); return; } if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) { DataContext dataContext = event.getDataContext(); presentation.setEnabled(getHelpId(dataContext) != null); } else { presentation.setIcon(AllIcons.Actions.Help); presentation.setText(CommonBundle.getHelpButtonText()); } }
@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 IdeaPluginDescriptor[] pluginDescriptors = PluginManagerCore.getPlugins(); for (IdeaPluginDescriptor pluginDescriptor : pluginDescriptors) { 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; }
public static void updateTitle(JFrame frame, final String title, final String fileTitle, final File currentFile) { if (myUpdatingTitle) return; try { myUpdatingTitle = true; frame.getRootPane().putClientProperty("Window.documentFile", currentFile); final String applicationName = ((ApplicationInfoEx)ApplicationInfo.getInstance()).getFullApplicationName(); final Builder builder = new Builder(); if (SystemInfo.isMac) { boolean addAppName = StringUtil.isEmpty(title) || ProjectManager.getInstance().getOpenProjects().length == 0 || ((ApplicationInfoEx)ApplicationInfo.getInstance()).isEAP() && !applicationName.endsWith("SNAPSHOT"); builder.append(fileTitle).append(title).append(addAppName ? applicationName : null); } else { builder.append(title).append(fileTitle).append(applicationName); } frame.setTitle(builder.sb.toString()); } finally { myUpdatingTitle = false; } }
@NotNull private static String getUrl(@NotNull IdeaPluginDescriptor descriptor, @Nullable String host, @Nullable BuildNumber buildNumber) throws URISyntaxException, MalformedURLException { if (host != null && descriptor instanceof PluginNode) { String url = ((PluginNode)descriptor).getDownloadUrl(); return new URI(url).isAbsolute() ? url : new URL(new URL(host), url).toExternalForm(); } else { Application app = ApplicationManager.getApplication(); ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance(); String buildNumberAsString = buildNumber != null ? buildNumber.asString() : app != null ? ApplicationInfo.getInstance().getApiVersion() : appInfo.getBuild().asString(); String uuid = app != null ? UpdateChecker.getInstallationUID(PropertiesComponent.getInstance()) : UUID.randomUUID().toString(); URIBuilder uriBuilder = new URIBuilder(appInfo.getPluginsDownloadUrl()); uriBuilder.addParameter("action", "download"); uriBuilder.addParameter("id", descriptor.getPluginId().getIdString()); uriBuilder.addParameter("build", buildNumberAsString); uriBuilder.addParameter("uuid", uuid); return uriBuilder.build().toString(); } }
private void scheduleOnStartCheck(@NotNull Application app) { if (!mySettings.isCheckNeeded()) { return; } app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) { String currentBuild = ApplicationInfo.getInstance().getBuild().asString(); long timeToNextCheck = mySettings.getLastTimeChecked() + CHECK_INTERVAL - System.currentTimeMillis(); if (StringUtil.compareVersionNumbers(mySettings.getLasBuildChecked(), currentBuild) < 0 || timeToNextCheck <= 0) { myCheckRunnable.run(); } else { queueNextCheck(timeToNextCheck); } } }); }
@Override public Notification createNotification(@NotNull 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); }
private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { @Override public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); 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().asStringWithAllDetails() + ", " + 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, " ")); } }
public void render(int indentX, int indentY, List<AboutBoxLine> lines) throws OverflowException { x = indentX; y = indentY; ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance(); for (AboutBoxLine line : lines) { final String s = line.getText(); setFont(line.isBold() ? myBoldFont : myFont); if (line.getUrl() != null) { g2.setColor(myLinkColor); FontMetrics metrics = g2.getFontMetrics(font); myLinks.add(new Link(new Rectangle(x, yBase + y - fontAscent, metrics.stringWidth(s), fontHeight), line.getUrl())); } else { g2.setColor(Registry.is("ide.new.about") ? Gray.x33 : appInfo.getAboutForeground()); } renderString(s, indentX); if (!line.isKeepWithNext() && !line.equals(lines.get(lines.size()-1))) { lineFeed(indentX, s); } } }
private void processClose() { if (Registry.getInstance().isRestartNeeded()) { final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication(); final ApplicationInfo info = ApplicationInfo.getInstance(); final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required", app.isRestartCapable() ? "Restart Now" : "Shutdown Now", app.isRestartCapable() ? "Restart Later": "Shutdown Later" , Messages.getQuestionIcon()); if (r == Messages.OK) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { app.restart(true); } }, ModalityState.NON_MODAL); } } }
private static void checkExpiredPreviewBuild(@NotNull Project project) { if (project.isDisposed() || ourCheckedExpiration) { return; } String fullVersion = ApplicationInfo.getInstance().getFullVersion(); if (fullVersion.contains("Preview") || fullVersion.contains("Beta") || fullVersion.contains("RC")) { // Expire preview builds two months after their build date (which is going to be roughly six weeks after release; by // then will definitely have updated the build Calendar expirationDate = (Calendar)ApplicationInfo.getInstance().getBuildDate().clone(); expirationDate.add(Calendar.MONTH, 2); Calendar now = Calendar.getInstance(); if (now.after(expirationDate)) { OpenUrlHyperlink hyperlink = new OpenUrlHyperlink("http://tools.android.com/download/studio/", "Show Available Versions"); String message = String.format("This preview build (%1$s) is old; please update to a newer preview or a stable version", fullVersion); AndroidGradleNotification.getInstance(project).showBalloon("Old Preview Build", message, INFORMATION, hyperlink); // If we show an expiration message, don't also show a second balloon regarding available SDKs ourNewSdkVersionToolsInfoAlreadyShown = true; } } ourCheckedExpiration = true; }
@NonNull @Override public Notification createNotification(@NotNull 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 usage statistics to " + companyName; return new Notification(groupDisplayId, title, text, NotificationType.INFORMATION, listener); }
@Nullable @Override public Map<String, String> getStatisticsConfigurationLabels() { Map<String, String> labels = new HashMap<String, String>(); final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName(); final String companyName = ApplicationInfo.getInstance().getCompanyName(); labels.put(StatisticsService.TITLE, "Help improve " + fullProductName + " by sending usage statistics to " + companyName); labels.put(StatisticsService.ALLOW_CHECKBOX, "Send usage statistics to " + companyName); labels.put(StatisticsService.DETAILS, "<html>This allows " + companyName + " to collect usage information, such as data about your feature usage," + "<br>resource usage and plugin configuration.</html>"); // Note: we inline the constants corresponding to the following keys since the corresponding change in IJ // may not be in upstream as yet. labels.put("linkUrl", "http://www.google.com/policies/privacy/"); labels.put("linkBeforeText", "This data is collected in accordance with " + companyName + "'s "); labels.put("linkText", "privacy policy"); labels.put("linkAfterText", "."); return labels; }
/** * Constructs a usage tracker configured with analytics and plugin name configured from its * environment. */ public GoogleUsageTracker() { analyticsId = UsageTrackerManager.getInstance().getAnalyticsProperty(); AccountPluginInfoService pluginInfo = ServiceManager.getService(AccountPluginInfoService.class); externalPluginName = pluginInfo.getExternalPluginName(); userAgent = pluginInfo.getUserAgent(); String intellijPlatformName = PlatformUtils.getPlatformPrefix(); String intellijPlatformVersion = ApplicationInfo.getInstance().getStrictVersion(); String cloudToolsPluginVersion = pluginInfo.getPluginVersion(); Map<String, String> systemMetadataMap = ImmutableMap.of( PLATFORM_NAME_KEY, METADATA_ESCAPER.escape(intellijPlatformName), PLATFORM_VERSION_KEY, METADATA_ESCAPER.escape(intellijPlatformVersion), JDK_VERSION_KEY, METADATA_ESCAPER.escape(JDK_VERSION_VALUE), OPERATING_SYSTEM_KEY, METADATA_ESCAPER.escape(OPERATING_SYSTEM_VALUE), PLUGIN_VERSION_KEY, METADATA_ESCAPER.escape(cloudToolsPluginVersion)); systemMetadataKeyValues = METADATA_JOINER.join(systemMetadataMap); }
private static MultiMap<String, ArchivedProjectTemplate> getTemplates() { InputStream stream = null; HttpURLConnection connection = null; String code = ApplicationInfo.getInstance().getBuild().getProductCode(); try { connection = getConnection(code + "_templates.xml"); stream = connection.getInputStream(); String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8); return createFromText(text); } catch (IOException ex) { // timeouts, lost connection etc LOG.info(ex); return MultiMap.emptyInstance(); } catch (Exception e) { LOG.error(e); return MultiMap.emptyInstance(); } finally { StreamUtil.closeStream(stream); if (connection != null) { connection.disconnect(); } } }
public ProjectNameStep(WizardContext wizardContext) { myWizardContext = wizardContext; myNamePathComponent = new NamePathComponent(IdeBundle.message("label.project.name"), IdeBundle.message("label.component.file.location", StringUtil.capitalize(myWizardContext.getPresentationName())), 'a', 'l', IdeBundle.message("title.select.project.file.directory", myWizardContext.getPresentationName()), IdeBundle.message("description.select.project.file.directory", myWizardContext.getPresentationName())); myPanel = new JPanel(new GridBagLayout()); myPanel.setBorder(BorderFactory.createEtchedBorder()); ApplicationInfo info = ApplicationManager.getApplication().getComponent(ApplicationInfo.class); String appName = info.getVersionName(); myPanel.add(new JLabel(IdeBundle.message("label.please.enter.project.name", appName, wizardContext.getPresentationName())), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); }
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()); } }
@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 IdeaPluginDescriptor[] pluginDescriptors = PluginManager.getPlugins(); for (IdeaPluginDescriptor pluginDescriptor : pluginDescriptors) { 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; }
public static void updateTitle(JFrame frame, final String title, final String fileTitle, final File currentFile) { if (myUpdatingTitle) return; try { myUpdatingTitle = true; frame.getRootPane().putClientProperty("Window.documentFile", currentFile); final String applicationName = ((ApplicationInfoEx)ApplicationInfo.getInstance()).getFullApplicationName(); final Builder builder = new Builder(); if (SystemInfo.isMac) { builder.append(fileTitle).append(title) .append(ProjectManager.getInstance().getOpenProjects().length == 0 || ((ApplicationInfoEx)ApplicationInfo.getInstance()).isEAP() && !applicationName.endsWith("SNAPSHOT") ? applicationName : null); } else { builder.append(title).append(fileTitle).append(applicationName); } frame.setTitle(builder.sb.toString()); } finally { myUpdatingTitle = false; } }
@NotNull public static CheckForUpdateResult doCheckForUpdates(final UpdateSettings settings) { ApplicationInfo appInfo = ApplicationInfo.getInstance(); BuildNumber currentBuild = appInfo.getBuild(); int majorVersion = Integer.parseInt(appInfo.getMajorVersion()); final UpdatesXmlLoader loader = new UpdatesXmlLoader(getUpdateUrl()); final UpdatesInfo info; try { info = loader.loadUpdatesInfo(); if (info == null) { return new CheckForUpdateResult(UpdateStrategy.State.NOTHING_LOADED); } } catch (ConnectionException e) { return new CheckForUpdateResult(UpdateStrategy.State.CONNECTION_ERROR, e); } UpdateStrategy strategy = new UpdateStrategy(majorVersion, currentBuild, info, settings); return strategy.checkForUpdates(); }
public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor) throws UnsupportedEncodingException { String url = null; if (descriptor instanceof PluginNode) { url = ((PluginNode)descriptor).getDownloadUrl(); } if (url == null) { String uuid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance()); String buildNumber = ApplicationInfo.getInstance().getBuild().asString(); url = RepositoryHelper.getDownloadUrl() + URLEncoder.encode(descriptor.getPluginId().getIdString(), "UTF8") + "&build=" + buildNumber + "&uuid=" + URLEncoder.encode(uuid, "UTF8"); } PluginDownloader downloader = new PluginDownloader(descriptor.getPluginId().getIdString(), url, null, null, descriptor.getName()); downloader.setDescriptor(descriptor); return downloader; }
private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " + DateFormatUtilRt.formatBuildDate(appInfo.getBuildDate()) + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.vendor", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } }
public void render(int indentX, int indentY, List<AboutBoxLine> lines) throws OverflowException { x = indentX; y = indentY; ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance(); for (AboutBoxLine line : lines) { final String s = line.getText(); setFont(line.isBold() ? myBoldFont : myFont); if (line.getUrl() != null) { g2.setColor(linkCol); FontMetrics metrics = g2.getFontMetrics(font); myLinks.add(new Link(new Rectangle(x, yBase + y - fontAscent, metrics.stringWidth(s), fontHeight), line.getUrl())); } else { g2.setColor(appInfo.getAboutForeground()); } renderString(s, indentX); if (!line.isKeepWithNext() && !line.equals(lines.get(lines.size()-1))) { lineFeed(indentX, s); } } }
private void processClose() { if (Registry.getInstance().isRestartNeeded()) { final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication(); final ApplicationInfo info = ApplicationInfo.getInstance(); final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required", (app.isRestartCapable() ? "Restart Now" : "Shutdown Now"), (app.isRestartCapable() ? "Restart Later": "Shutdown Later") , Messages.getQuestionIcon()); if (r == 0) { LaterInvocator.invokeLater(new Runnable() { @Override public void run() { app.restart(true); } }, ModalityState.NON_MODAL); } } }
@Override public void initComponent() { LOG.info("Lombok plugin initialized for IntelliJ"); final LombokSettings settings = LombokSettings.getInstance(); updated = !Version.PLUGIN_VERSION.equals(settings.getVersion()); if (updated) { settings.setVersion(Version.PLUGIN_VERSION); } final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode(); if (unitTestMode || settings.isEnableRuntimePatch()) { LOG.info("Runtime path support is enabled"); injectAgent(); } else { LOG.info("Runtime path support is disabled"); } final BuildNumber currentBuild = ApplicationInfo.getInstance().getBuild(); if (currentBuild.getBaselineVersion() < 173) { // Overwrite IntelliJ Diamond inspection, to filter out val declarations only for IntelliJ < 2017.3 addCustomDiamondInspectionExtension(); } }
@Override 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); }
private void processClose() { if (Registry.getInstance().isRestartNeeded()) { final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication(); final ApplicationInfo info = ApplicationInfo.getInstance(); final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required", (app.isRestartCapable() ? "Restart Now" : "Shutdown Now"), (app.isRestartCapable() ? "Restart Later": "Shutdown Later") , Messages.getQuestionIcon()); if (r == 0) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { app.restart(true); } }, ModalityState.NON_MODAL); } } }
@javax.annotation.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 IdeaPluginDescriptor[] pluginDescriptors = PluginManagerCore.getPlugins(); for (IdeaPluginDescriptor pluginDescriptor : pluginDescriptors) { 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; }
public static String getStackTraceAsString(Throwable throwable) { StringWriter stringWriter = new StringWriter(); throwable.printStackTrace(new PrintWriter(stringWriter)); BuildNumber number = ApplicationInfo.getInstance().getBuild(); stringWriter.append("\n").append("BuildNumber:").append(number.asString()); return stringWriter.toString(); }
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()); }
@Override public boolean isEnabledForModuleType( @NotNull ModuleType moduleType ) { // ? return moduleType instanceof JavaModuleType; // We are using RepositoryLibrarySupportInModuleConfigurable, which is available starting in IDEA v17.x return ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 17; }
@NotNull private Action[] filter(@NotNull Action[] actions) { ArrayList<Action> answer = new ArrayList<Action>(); for (Action action : actions) { if (action != null && (ApplicationInfo.contextHelpAvailable() || action != getHelpAction())) { answer.add(action); } } return answer.toArray(new Action[answer.size()]); }
@NotNull public RequestBuilder productNameAsUserAgent() { Application app = ApplicationManager.getApplication(); if (app != null && !app.isDisposed()) { return userAgent(ApplicationInfo.getInstance().getVersionName()); } else { return userAgent("IntelliJ"); } }
private static JPanel createFooterPanel() { JLabel versionLabel = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName() + " " + ApplicationInfo.getInstance().getFullVersion() + " Build " + ApplicationInfo.getInstance().getBuild().asStringWithoutProductCode()); makeSmallFont(versionLabel); versionLabel.setForeground(WelcomeScreenColors.FOOTER_FOREGROUND); JPanel footerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); footerPanel.setBackground(WelcomeScreenColors.FOOTER_BACKGROUND); footerPanel.setBorder(new EmptyBorder(2, 5, 2, 5) { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { g.setColor(WelcomeScreenColors.BORDER_COLOR); g.drawLine(x, y, x + width, y); } }); footerPanel.add(versionLabel); footerPanel.add(makeSmallFont(new JLabel(". "))); footerPanel.add(makeSmallFont(new LinkLabel("Check", null, new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { UpdateChecker.updateAndShowResult(null, null); } }))); footerPanel.add(makeSmallFont(new JLabel(" for updates now."))); return footerPanel; }