Java Code Examples for com.intellij.openapi.application.ApplicationInfo#getInstance()

The following examples show how to use com.intellij.openapi.application.ApplicationInfo#getInstance() . 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: TabNineProcess.java    From tabnine-intellij with MIT License 6 votes vote down vote up
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 2
Source File: FrameTitleUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 3
Source File: FlutterStudioInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run() {
  // Unlike StartupActivity, this runs before the welcome screen (FlatWelcomeFrame) is displayed.
  // StartupActivity runs just before a project is opened.
  ApplicationInfo info = ApplicationInfo.getInstance();
  if ("Google".equals(info.getCompanyName())) {
    String version = info.getFullVersion();
    if (version.startsWith("2.")) {
      reportVersionIncompatibility(info);
    }
  }
}
 
Example 4
Source File: IdeBackgroundUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 5
Source File: ProjectOrModuleNameStep.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean validateNameAndPath(@Nonnull NewModuleWizardContext context) throws WizardStepValidationException {
  final String name = myNamePathComponent.getNameValue();
  if (name.length() == 0) {
    final ApplicationInfo info = ApplicationInfo.getInstance();
    throw new WizardStepValidationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), context.getTargetId()));
  }

  final String projectFileDirectory = myNamePathComponent.getPath();
  if (projectFileDirectory.length() == 0) {
    throw new WizardStepValidationException(IdeBundle.message("prompt.enter.project.file.location", context.getTargetId()));
  }

  final boolean shouldPromptCreation = myNamePathComponent.isPathChangedByUser();
  if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.project.file.directory", context.getTargetId()), projectFileDirectory, shouldPromptCreation)) {
    return false;
  }

  final File file = new File(projectFileDirectory);
  if (file.exists() && !file.canWrite()) {
    throw new WizardStepValidationException(String.format("Directory '%s' is not writable!\nPlease choose another project location.", projectFileDirectory));
  }

  boolean shouldContinue = true;
  final File projectDir = new File(myNamePathComponent.getPath(), Project.DIRECTORY_STORE_FOLDER);
  if (projectDir.exists()) {
    int answer = Messages
            .showYesNoDialog(IdeBundle.message("prompt.overwrite.project.folder", projectDir.getAbsolutePath(), context.getTargetId()), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
    shouldContinue = (answer == Messages.YES);
  }

  return shouldContinue;
}
 
Example 6
Source File: AboutRestHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public JsonResponse handle() {
  ApplicationInfo info = ApplicationInfo.getInstance();
  AboutInfo data = new AboutInfo();
  data.name = info.getName();
  data.build = info.getBuild().getBuildNumber();
  data.channel = UpdateSettings.getInstance().getChannel();
  return JsonResponse.asSuccess(data);
}
 
Example 7
Source File: HttpRequests.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public RequestBuilder productNameAsUserAgent() {
  Application app = ApplicationManager.getApplication();
  if (app != null && !app.isDisposed()) {
    ApplicationInfo info = ApplicationInfo.getInstance();
    return userAgent(info.getVersionName() + '/' + info.getBuild().asString());
  }
  else {
    return userAgent("Consulo");
  }
}
 
Example 8
Source File: SendFeedbackAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 9
Source File: IdeaIDEBridge.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public IdeaIDEBridge() {
  final ApplicationInfo info = ApplicationInfo.getInstance();
  final long major = safeNumberExtraction(info.getMajorVersion());
  final long minor = safeNumberExtraction(info.getMinorVersion());
  final long micro = safeNumberExtraction(IdeaUtils.safeInvokeMethodForResult(info, "0", "getMicroVersion", new Class<?>[0], new Object[0]));
  this.ideVersion = new Version("intellij", new long[] {major, minor, micro}, info.getVersionName());
}
 
Example 10
Source File: StartupUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 11
Source File: FlutterUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static int getBaselineVersion() {
  final ApplicationInfo appInfo = ApplicationInfo.getInstance();
  if (appInfo != null) {
    return appInfo.getBuild().getBaselineVersion();
  }
  return -1;
}
 
Example 12
Source File: FlutterInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void performAndroidStudioCanaryCheck() {
  if (!FlutterUtils.isAndroidStudio()) {
    return;
  }

  final ApplicationInfo info = ApplicationInfo.getInstance();
  if (info.getFullVersion().contains("Canary") && !info.getBuild().isSnapshot()) {
    FlutterMessages.showWarning(
      "Unsupported Android Studio version",
      "Canary versions of Android Studio are not supported by the Flutter plugin.");
  }
}
 
Example 13
Source File: FlutterUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static int getBaselineVersion() {
  final ApplicationInfo appInfo = ApplicationInfo.getInstance();
  if (appInfo != null) {
    return appInfo.getBuild().getBaselineVersion();
  }
  return -1;
}
 
Example 14
Source File: FlutterInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void performAndroidStudioCanaryCheck() {
  if (!FlutterUtils.isAndroidStudio()) {
    return;
  }

  final ApplicationInfo info = ApplicationInfo.getInstance();
  if (info.getFullVersion().contains("Canary") && !info.getBuild().isSnapshot()) {
    FlutterMessages.showWarning(
      "Unsupported Android Studio version",
      "Canary versions of Android Studio are not supported by the Flutter plugin.");
  }
}
 
Example 15
Source File: FlutterProjectOpenProcessor.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean canOpenProject(@Nullable VirtualFile file) {
  if (file == null) return false;
  final ApplicationInfo info = ApplicationInfo.getInstance();
  if (FlutterUtils.isAndroidStudio()) {
    return false;
  }
  final PubRoot root = PubRoot.forDirectory(file);
  return root != null && root.declaresFlutter();
}
 
Example 16
Source File: FlutterStudioInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run() {
  // Unlike StartupActivity, this runs before the welcome screen (FlatWelcomeFrame) is displayed.
  // StartupActivity runs just before a project is opened.
  ApplicationInfo info = ApplicationInfo.getInstance();
  if ("Google".equals(info.getCompanyName())) {
    String version = info.getFullVersion();
    if (version.startsWith("2.")) {
      reportVersionIncompatibility(info);
    }
  }
}
 
Example 17
Source File: ApplicationInfoImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Deprecated
public static ApplicationInfo getShadowInstance() {
  return ApplicationInfo.getInstance();
}
 
Example 18
Source File: VersionUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static boolean productVersionGreaterThanOrEqual(int major, int minor) {
    ApplicationInfo instance = ApplicationInfo.getInstance();

    return Integer.valueOf(instance.getMajorVersion()) > major || (Integer.valueOf(instance.getMajorVersion()).equals(major) && Integer.valueOf(instance.getMinorVersionMainPart()) >= minor);
}
 
Example 19
Source File: FloobitsApplication.java    From floobits-intellij with Apache License 2.0 4 votes vote down vote up
public void initComponent() {
    BrowserOpener.replaceSingleton(new IntelliBrowserOpener());
    ApplicationInfo instance = ApplicationInfo.getInstance();
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("com.floobits.unique.plugin.id"));
    createAccount = Bootstrap.bootstrap(instance.getVersionName(), instance.getMajorVersion(), instance.getMinorVersion(), plugin != null ? plugin.getVersion() : "???");
}
 
Example 20
Source File: ApplicationInfoImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Deprecated
public static ApplicationInfo getInstance() {
  return ApplicationInfo.getInstance();
}