private void checkFsSanity() {
    try {
      String path = myProject.getProjectFilePath();
      if (path == null || FileUtil.isAncestor(PathManager.getConfigPath(), path, true)) {
        return;
      }

      boolean actual = FileUtil.isFileSystemCaseSensitive(path);
      LOG.info(path + " case-sensitivity: " + actual);
      if (actual != SystemInfo.isFileSystemCaseSensitive) {
        int prefix =
            SystemInfo.isFileSystemCaseSensitive ? 1 : 0; // IDE=true -> FS=false -> prefix='in'
        String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
        String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
        Notifications.Bus.notify(
            new Notification(
                Notifications.SYSTEM_MESSAGES_GROUP_ID,
                title,
                text,
                NotificationType.WARNING,
                NotificationListener.URL_OPENING_LISTENER),
            myProject);
      }
    } catch (FileNotFoundException e) {
      LOG.warn(e);
    }
  }
Exemplo n.º 2
0
  private static synchronized boolean checkSystemFolders() {
    final String configPath = PathManager.getConfigPath();
    if (configPath == null || !new File(configPath).isDirectory()) {
      showError(
          "Invalid config path",
          "Config path '"
              + configPath
              + "' is invalid.\n"
              + "If you have modified the 'idea.config.path' property please make sure it is correct,\n"
              + "otherwise please re-install the IDE.");
      return false;
    }

    final String systemPath = PathManager.getSystemPath();
    if (systemPath == null || !new File(systemPath).isDirectory()) {
      showError(
          "Invalid system path",
          "System path '"
              + systemPath
              + "' is invalid.\n"
              + "If you have modified the 'idea.system.path' property please make sure it is correct,\n"
              + "otherwise please re-install the IDE.");
      return false;
    }

    return true;
  }
 @NotNull
 public static List<String> getDisabledPlugins() {
   if (ourDisabledPlugins == null) {
     ourDisabledPlugins = new ArrayList<String>();
     if (System.getProperty("idea.ignore.disabled.plugins") == null && !isUnitTestMode()) {
       loadDisabledPlugins(PathManager.getConfigPath(), ourDisabledPlugins);
     }
   }
   return ourDisabledPlugins;
 }
 private JBZipFile getTasksArchive(String postfix) throws IOException {
   String configPath = PathManager.getConfigPath(true);
   File tasksFolder = new File(configPath, TASKS_FOLDER);
   if (!tasksFolder.exists()) {
     //noinspection ResultOfMethodCallIgnored
     tasksFolder.mkdir();
   }
   String projectName = myProject.getName();
   return new JBZipFile(new File(tasksFolder, projectName + postfix));
 }
 public ShelveChangesManager(final Project project, final MessageBus bus) {
   myProject = project;
   myBus = bus;
   if (!project.isDefault()) {
     myFileProcessor = new CompoundShelfFileProcessor("shelf");
   } else {
     myFileProcessor =
         new CompoundShelfFileProcessor(
             new StreamProvider[] {}, PathManager.getConfigPath() + File.separator + "shelf");
   }
 }
Exemplo n.º 6
0
  public void load(String path) throws IOException, InvalidDataException {
    getStateStore().setOptionsPath(path);
    getStateStore().setConfigPath(PathManager.getConfigPath());
    myIsFiringLoadingEvent = true;
    try {
      fireBeforeApplicationLoaded();
    } finally {
      myIsFiringLoadingEvent = false;
    }

    loadComponentRoamingTypes();

    try {
      getStateStore().load();
    } catch (StateStorage.StateStorageException e) {
      throw new IOException(e.getMessage());
    }
  }
  @NotNull
  private static Course getCourse(
      @NotNull Project project,
      @NotNull String name,
      @NotNull String[] authors,
      @NotNull String description) {
    final Course course = new Course();
    course.setName(name);
    course.setAuthors(authors);
    course.setDescription(description);
    course.setLanguage(PythonLanguage.getInstance().getID());
    course.setCourseMode(CCUtils.COURSE_MODE);

    File coursesDir = new File(PathManager.getConfigPath(), "courses");
    File courseDir = new File(coursesDir, name + "-" + project.getName());
    course.setCourseDirectory(courseDir.getPath());

    StudyTaskManager.getInstance(project).setCourse(course);
    StudyProjectComponent.getInstance(project).registerStudyToolWindow(course);
    return course;
  }
Exemplo n.º 8
0
  private static synchronized boolean lockSystemFolders(String[] args) {
    if (ourLock == null) {
      ourLock = new SocketLock();
    }

    SocketLock.ActivateStatus activateStatus =
        ourLock.lock(PathManager.getConfigPath(false), true, args);
    if (activateStatus == SocketLock.ActivateStatus.NO_INSTANCE) {
      activateStatus = ourLock.lock(PathManager.getSystemPath(), false);
    }

    if (activateStatus != SocketLock.ActivateStatus.NO_INSTANCE) {
      if (isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
        showError(
            "Error",
            "Only one instance of "
                + ApplicationNamesInfo.getInstance().getFullProductName()
                + " can be run at a time.");
      }
      return false;
    }

    return true;
  }
 public static void saveDisabledPlugins(Collection<String> ids, boolean append)
     throws IOException {
   File plugins = new File(PathManager.getConfigPath(), DISABLED_PLUGINS_FILENAME);
   savePluginsList(ids, append, plugins);
   ourDisabledPlugins = null;
 }
Exemplo n.º 10
0
/** @author oleg */
public class VimKeyMapUtil {
  private static final Joiner PATH_JOINER = Joiner.on(File.separatorChar);
  public static final String VIM_KEYMAP_NAME = "Vim";

  private static final String VIM_XML = "Vim.xml";
  private static final String KEYMAPS_PATH =
      PATH_JOINER.join(PathManager.getConfigPath(), "keymaps");
  private static final String INSTALLED_VIM_KEYMAP_PATH = PATH_JOINER.join(KEYMAPS_PATH, VIM_XML);

  private static Logger LOG = Logger.getInstance(VimKeyMapUtil.class);

  public static boolean isVimKeymapInstalled() {
    return KeymapManager.getInstance().getKeymap(VIM_KEYMAP_NAME) != null;
  }

  /** @return true if keymap was installed or was successfully installed */
  public static boolean installKeyBoardBindings() {
    LOG.debug("Check for keyboard bindings");
    final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
    if (localFileSystem.refreshAndFindFileByPath(KEYMAPS_PATH) == null) {
      reportError("Failed to install vim keymap. Empty keymaps folder");
      return false;
    }

    LOG.debug("No vim keyboard installed found. Installing");
    try {
      final byte[] bytes = toByteArray(retrieveSourceKeymapStream());
      Files.write(bytes, new File(INSTALLED_VIM_KEYMAP_PATH));
      final Document document = StorageUtil.loadDocument(bytes);
      if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
        // Prompt user to select the parent for the Vim keyboard
        if (!configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true)) {
          return false;
        }
      }
      installKeymap(document);
    } catch (IOException e) {
      reportError("Source keymap not found", e);
      return false;
    } catch (InvalidDataException e) {
      reportError("Failed to install vim keymap. Vim.xml file is corrupted", e);
      return false;
    } catch (Exception e) {
      reportError("Failed to install vim keymap.\n", e);
      return false;
    }

    return true;
  }

  private static void installKeymap(@Nullable Document document) throws InvalidDataException {
    if (document == null) {
      throw new InvalidDataException();
    }
    final KeymapImpl vimKeyMap = new KeymapImpl();
    final KeymapManagerImpl keymapManager = (KeymapManagerImpl) KeymapManager.getInstance();
    final Keymap[] allKeymaps = keymapManager.getAllKeymaps();
    vimKeyMap.readExternal(document.getRootElement(), allKeymaps);
    keymapManager.addKeymap(vimKeyMap);
  }

  /**
   * Changes parent keymap for the Vim
   *
   * @return true if document was changed successfully
   */
  private static boolean configureVimParentKeymap(
      final String path, @NotNull final Document document, final boolean showNotification)
      throws IOException, InvalidDataException {
    final Element rootElement = document.getRootElement();
    final String parentKeymapName = rootElement.getAttributeValue("parent");
    final VimKeymapDialog vimKeymapDialog = new VimKeymapDialog(parentKeymapName);
    vimKeymapDialog.show();
    if (vimKeymapDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
      return false;
    }
    rootElement.removeAttribute("parent");
    final Keymap parentKeymap = vimKeymapDialog.getSelectedKeymap();
    final String keymapName = parentKeymap.getName();
    VimKeymapConflictResolveUtil.resolveConflicts(rootElement, parentKeymap);
    // We cannot set a user-defined modifiable keymap as the parent of our Vim keymap so we have to
    // copy its shortcuts
    if (parentKeymap.canModify()) {
      final KeymapImpl vimKeyMap = new KeymapImpl();
      final KeymapManager keymapManager = KeymapManager.getInstance();
      final KeymapManagerImpl keymapManagerImpl = (KeymapManagerImpl) keymapManager;
      final Keymap[] allKeymaps = keymapManagerImpl.getAllKeymaps();
      vimKeyMap.readExternal(rootElement, allKeymaps);
      final HashSet<String> ownActions =
          new HashSet<String>(Arrays.asList(vimKeyMap.getOwnActionIds()));
      final KeymapImpl parentKeymapImpl = (KeymapImpl) parentKeymap;
      for (String parentAction : parentKeymapImpl.getOwnActionIds()) {
        if (!ownActions.contains(parentAction)) {
          final List<Shortcut> shortcuts = Arrays.asList(parentKeymap.getShortcuts(parentAction));
          rootElement.addContent(
              VimKeymapConflictResolveUtil.createActionElement(parentAction, shortcuts));
        }
      }
      final Keymap grandParentKeymap = parentKeymap.getParent();
      rootElement.setAttribute("parent", grandParentKeymap.getName());
    } else {
      rootElement.setAttribute("parent", keymapName);
    }
    VimPlugin.getInstance().setPreviousKeyMap(keymapName);
    // Save modified keymap to the file
    JDOMUtil.writeDocument(document, path, "\n");
    if (showNotification) {
      Notifications.Bus.notify(
          new Notification(
              VimPlugin.IDEAVIM_NOTIFICATION_ID,
              VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
              "Successfully configured vim keymap to be based on "
                  + parentKeymap.getPresentableName(),
              NotificationType.INFORMATION));
    }

    return true;
  }

  public static boolean isVimKeymapUsed() {
    return KeymapManager.getInstance().getActiveKeymap().getName().equals(VIM_KEYMAP_NAME);
  }

  /** @return true if keymap was switched successfully, false otherwise */
  public static boolean switchKeymapBindings(final boolean enableVimKeymap) {
    LOG.debug("Enabling keymap");

    // In case if Vim keymap is already in use or we don't need it, we have nothing to do
    if (isVimKeymapUsed() == enableVimKeymap) {
      return false;
    }

    final KeymapManagerImpl manager = (KeymapManagerImpl) KeymapManager.getInstance();
    // Get keymap to enable
    final String keymapName2Enable =
        enableVimKeymap ? VIM_KEYMAP_NAME : VimPlugin.getInstance().getPreviousKeyMap();
    if (keymapName2Enable.isEmpty()) {
      return false;
    }
    if (keymapName2Enable.equals(manager.getActiveKeymap().getName())) {
      return false;
    }

    LOG.debug("Enabling keymap:" + keymapName2Enable);
    final Keymap keymap = manager.getKeymap(keymapName2Enable);
    if (keymap == null) {
      reportError("Failed to enable keymap: " + keymapName2Enable);
      return false;
    }

    // Save previous keymap to enable after VIM emulation is turned off
    if (enableVimKeymap) {
      VimPlugin.getInstance().setPreviousKeyMap(manager.getActiveKeymap().getName());
    }

    manager.setActiveKeymap(keymap);

    final String keyMapPresentableName = keymap.getPresentableName();
    Notifications.Bus.notify(
        new Notification(
            VimPlugin.IDEAVIM_NOTIFICATION_ID,
            VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
            keyMapPresentableName + " keymap was successfully enabled",
            NotificationType.INFORMATION));
    LOG.debug(keyMapPresentableName + " keymap was successfully enabled");
    return true;
  }

  @NotNull
  private static InputStream retrieveSourceKeymapStream() throws IOException {
    String keymapPath =
        PATH_JOINER.join(
            PathManager.getPluginsPath(), VimPlugin.IDEAVIM_NOTIFICATION_TITLE, VIM_XML);
    try {
      return new FileInputStream(keymapPath);
    } catch (FileNotFoundException e) {
      if (ApplicationManager.getApplication().isInternal()) {
        LOG.debug("Development mode on. Trying to retrieve source keymap from resources");
        return Resources.getResource(VimKeyMapUtil.class, "/" + VIM_XML).openStream();
      }
      throw e;
    }
  }

  private static void reportError(final String message) {
    reportError(message, null);
  }

  private static void reportError(final String message, @Nullable final Exception e) {
    LOG.error(message, e);
    Notifications.Bus.notify(
        new Notification(
            VimPlugin.IDEAVIM_NOTIFICATION_ID,
            VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
            message + String.valueOf(e),
            NotificationType.ERROR));
  }
}
Exemplo n.º 11
0
  private PluginGroups() {
    myAllPlugins = PluginManager.loadDescriptors(null);
    try {
      myPluginsFromRepository.addAll(RepositoryHelper.loadPluginsFromRepository(null));
    } catch (Exception e) {
      // OK, it's offline
    }
    PluginManager.loadDisabledPlugins(
        new File(PathManager.getConfigPath()).getPath(), myDisabledPluginIds);

    myTree.put(
        CORE,
        Pair.create(
            (String) null,
            Arrays.asList(
                "com.intellij.copyright",
                "com.intellij.java-i18n",
                "org.intellij.intelliLang",
                "com.intellij.properties",
                "Refactor-X", // ?
                "Structural Search",
                "Type Migration",
                "ZKM")));
    myTree.put(
        "Java Frameworks",
        Pair.create(
            "/plugins/JavaFrameworks.png",
            Arrays.asList(
                "com.intellij.appengine",
                "org.intellij.grails",
                "com.intellij.gwt",
                "com.intellij.vaadin",
                "JBoss Seam:com.intellij.seam,com.intellij.seam.pages,com.intellij.seam.pageflow",
                "JBoss jBPM:JBPM",
                "Struts:StrutsAssistant,com.intellij.struts2",
                "com.intellij.hibernate",
                "Spring:com.intellij.spring.batch,"
                    + "com.intellij.spring.data,"
                    + "com.intellij.spring.integration,"
                    + "com.intellij.spring.osgi,"
                    + "com.intellij.spring.security,"
                    + "com.intellij.spring,"
                    + "com.intellij.spring.webflow,"
                    + "com.intellij.spring.ws,com.intellij.aop",
                "J2EE:com.intellij.javaee.batch,"
                    + "com.intellij.beanValidation,"
                    + "com.intellij.cdi,"
                    + "com.intellij.javaee,"
                    + "com.intellij.jsf,"
                    + "com.intellij.javaee.extensions,"
                    + "com.jetbrains.restWebServices,"
                    + "Java EE: Web Services (JAX-WS),"
                    + "com.intellij.javaee.webSocket,"
                    + "com.intellij.jsp,"
                    + "com.intellij.persistence",
                "com.intellij.freemarker",
                "com.intellij.tapestry",
                "com.intellij.velocity",
                "GuiceyIDEA",
                "com.intellij.aspectj",
                "Osmorc")));
    myTree.put(
        "Build Tools",
        Pair.create(
            "/plugins/BuildTools.png",
            Arrays.asList(
                "AntSupport",
                "Maven:org.jetbrains.idea.maven,org.jetbrains.idea.maven.ext",
                "org.jetbrains.plugins.gradle")));
    myTree.put(
        "Web Development",
        Pair.create(
            "/plugins/WebDevelopment.png",
            Arrays.asList(
                "HTML:HtmlTools,QuirksMode,W3Validators",
                "org.jetbrains.plugins.haml",
                "com.jetbrains.plugins.jade",
                "com.intellij.css",
                "org.jetbrains.plugins.less",
                "org.jetbrains.plugins.sass",
                "org.jetbrains.plugins.stylus",
                "JavaScript:JavaScript,JavaScriptDebugger,JSIntentionPowerPack", // TODO:
                                                                                 // Inspection-JS
                "org.coffeescript",
                "com.intellij.flex",
                "com.intellij.plugins.html.instantEditing",
                "com.jetbrains.restClient")));
    myTree.put(
        "Version Controls",
        Pair.create(
            "/plugins/VersionControls.png",
            Arrays.asList(
                "ClearcasePlugin",
                "CVS",
                "Git4Idea",
                "org.jetbrains.plugins.github",
                "hg4idea",
                "PerforceDirectPlugin",
                "Subversion",
                "TFS")));
    myTree.put(
        "Test Tools",
        Pair.create(
            "/plugins/TestTools.png",
            Arrays.asList(
                "JUnit", "TestNG-J", "cucumber-java", "cucumber", "Coverage:Coverage,Emma")));
    myTree.put(
        "Application Servers",
        Pair.create(
            "/plugins/ApplicationServers.png",
            Arrays.asList(
                "com.intellij.javaee.view",
                "Geronimo",
                "GlassFish",
                "JBoss",
                "Jetty",
                "Resin",
                "Tomcat",
                "Weblogic",
                "WebSphere",
                "com.intellij.dmserver",
                "JSR45Plugin")));
    myTree.put(
        "Clouds",
        Pair.create(
            "/plugins/Clouds.png",
            Arrays.asList("CloudFoundry", "CloudBees", "Heroku", "OpenShift")));
    // myTree.put("Groovy", Arrays.asList("org.intellij.grails"));
    // TODO Scala -> Play 2.x (Play 2.0 Support)
    myTree.put(
        "Swing",
        Pair.create(
            "/plugins/Swing.png",
            Arrays.asList(
                "com.intellij.uiDesigner" // TODO JavaFX?
                )));
    myTree.put(
        "Android",
        Pair.create(
            "/plugins/Android.png",
            Arrays.asList("org.jetbrains.android", "com.intellij.android-designer")));
    myTree.put(
        "Database Tools",
        Pair.create(
            "/plugins/DatabaseTools.png",
            Arrays.asList("com.intellij.sql", "com.intellij.persistence.database")));
    myTree.put(
        "Other Tools",
        Pair.create(
            "/plugins/OtherTools.png",
            Arrays.asList(
                "ByteCodeViewer",
                "com.intellij.dsm",
                "org.jetbrains.idea.eclipse",
                "Remote Access:com.jetbrains.plugins.webDeployment,org.jetbrains.plugins.remote-run",
                "Task Management:com.intellij.tasks,com.intellij.tasks.timeTracking",
                "org.jetbrains.plugins.terminal",
                "com.intellij.diagram",
                "org.jetbrains.plugins.yaml",
                "XSLT and XPath:XPathView,XSLT-Debugger")));
    myTree.put(
        "Plugin Development",
        Pair.create("/plugins/PluginDevelopment.png", Arrays.asList("DevKit")));

    myFeaturedPlugins.put(
        "Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
    myFeaturedPlugins.put(
        "Live Edit Tool",
        "Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
    myFeaturedPlugins.put(
        "IdeaVIM", "Editor:Vim emulation plug-in for IDEs based on the IntelliJ platform:IdeaVIM");
    myFeaturedPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
    myFeaturedPlugins.put(
        "Atlassian Connector",
        "Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
  }