Search in sources :

Example 16 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project flutter-intellij by flutter.

the class FlutterStudioProjectOpenProcessor method canOpenProject.

@Override
public boolean canOpenProject(@Nullable VirtualFile file) {
    if (file == null)
        return false;
    ApplicationInfo info = ApplicationInfo.getInstance();
    final PubRoot root = PubRoot.forDirectory(file);
    return root != null && root.declaresFlutter();
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) PubRoot(io.flutter.pub.PubRoot)

Example 17 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project flutter-intellij by flutter.

the class DeviceService method daemonStopped.

private void daemonStopped(String details) {
    if (project.isDisposed())
        return;
    final DeviceDaemon current = deviceDaemon.getNow();
    if (current == null || current.isRunning()) {
        // The active daemon didn't die, so it must be some older process. Just log it.
        LOG.info("A Flutter device daemon stopped.\n" + details);
        return;
    }
    // If we haven't tried restarting recently, try again.
    final long now = System.currentTimeMillis();
    final long millisSinceLastRestart = now - lastRestartTime.get();
    if (millisSinceLastRestart > TimeUnit.SECONDS.toMillis(20)) {
        LOG.info("A Flutter device daemon stopped. Automatically restarting it.\n" + details);
        refreshDeviceDaemon();
        lastRestartTime.set(now);
        return;
    }
    // Display as a notification to the user.
    final ApplicationInfo info = ApplicationInfo.getInstance();
    FlutterMessages.showWarning("Flutter daemon terminated", "Consider re-starting " + info.getVersionName() + ".");
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 18 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project flutter-intellij by flutter.

the class FlutterProjectOpenProcessor method canOpenProject.

@Override
public boolean canOpenProject(@Nullable VirtualFile file) {
    if (file == null)
        return false;
    ApplicationInfo info = ApplicationInfo.getInstance();
    if (FlutterUtils.isAndroidStudio()) {
        return false;
    }
    final PubRoot root = PubRoot.forDirectory(file);
    return root != null && root.declaresFlutter();
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) PubRoot(io.flutter.pub.PubRoot)

Example 19 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project liferay-ide by liferay.

the class LiferayNamePathComponent method validateNameAndPath.

public boolean validateNameAndPath(WizardContext context, boolean defaultFormat) throws ConfigurationException {
    String name = getNameValue();
    if (StringUtil.isEmptyOrSpaces(name)) {
        ApplicationInfo applicationInfo = ApplicationInfo.getInstance();
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", applicationInfo.getVersionName(), context.getPresentationName()));
    }
    String projectDirectory = getPath();
    if (StringUtil.isEmptyOrSpaces(projectDirectory)) {
        throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
    }
    if (_shouldBeAbsolute && !new File(projectDirectory).isAbsolute()) {
        throw new ConfigurationException(StringUtil.capitalize(IdeBundle.message("file.location.should.be.absolute", context.getPresentationName())));
    }
    String message = IdeBundle.message("directory.project.file.directory", context.getPresentationName());
    if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectory, isPathChangedByUser())) {
        return false;
    }
    File file = new File(projectDirectory);
    if (file.exists() && !file.canWrite()) {
        String msg = String.format("Directory '%s' is not seem to be writable. Please consider another location.", projectDirectory);
        throw new ConfigurationException(msg);
    }
    ProjectManager projectManager = ProjectManager.getInstance();
    for (Project project : projectManager.getOpenProjects()) {
        if (ProjectUtil.isSameProject(projectDirectory, project)) {
            String msg = String.format("Directory '%s' is already taken by the project '%s'. Please consider another location.", projectDirectory, project.getName());
            throw new ConfigurationException(msg);
        }
    }
    boolean shouldContinue = true;
    String fileName = defaultFormat ? name + ProjectFileType.DOT_DEFAULT_EXTENSION : Project.DIRECTORY_STORE_FOLDER;
    File projectFile = new File(file, fileName);
    if (projectFile.exists()) {
        message = IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), context.getPresentationName());
        int answer = Messages.showYesNoDialog(message, IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
        shouldContinue = answer == Messages.YES;
    }
    return shouldContinue;
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 20 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project azure-tools-for-java by Microsoft.

the class QualtricsSurveyAction method getRequestUrl.

private String getRequestUrl() {
    IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(PluginId.getId("com.microsoft.tooling.msservices.intellij.azure"));
    ApplicationInfo applicationInfo = ApplicationInfo.getInstance();
    String toolkit = pluginDescriptor.getVersion();
    String ide = String.format("%s %s", applicationInfo.getFullVersion(), applicationInfo.getBuild());
    String os = System.getProperty("os.name");
    String jdk = String.format("%s %s", System.getProperty("java.vendor"), System.getProperty("java.version"));
    String id = AppInsightsClient.getInstallationId();
    return String.format(SURVEY_URL, toolkit, ide, os, jdk, id);
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor)

Aggregations

ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)20 File (java.io.File)5 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 Project (com.intellij.openapi.project.Project)3 NotNull (org.jetbrains.annotations.NotNull)3 PubRoot (io.flutter.pub.PubRoot)2 MemoryUsage (java.lang.management.MemoryUsage)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 MergedManifest (com.android.tools.idea.model.MergedManifest)1 ScratchRootType (com.intellij.ide.scratch.ScratchRootType)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)1 PluginId (com.intellij.openapi.extensions.PluginId)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1