public static boolean putProxyCredentialsIntoServerFile(
      @NotNull final File configDir,
      @NotNull final String host,
      @NotNull final PasswordAuthentication authentication) {
    final IdeaSVNConfigFile configFile =
        new IdeaSVNConfigFile(new File(configDir, SERVERS_FILE_NAME));
    configFile.updateGroups();

    String groupName = SvnAuthenticationManager.getGroupForHost(host, configFile);
    // no proxy defined in group -> no sense in password
    if (StringUtil.isEmptyOrSpaces(groupName)) return false;
    final Map<String, String> properties = configFile.getAllGroups().get(groupName).getProperties();
    if (StringUtil.isEmptyOrSpaces(properties.get(SvnAuthenticationManager.HTTP_PROXY_HOST)))
      return false;
    if (StringUtil.isEmptyOrSpaces(properties.get(SvnAuthenticationManager.HTTP_PROXY_PORT)))
      return false;

    configFile.setValue(
        groupName, SvnAuthenticationManager.HTTP_PROXY_USERNAME, authentication.getUserName());
    configFile.setValue(
        groupName,
        SvnAuthenticationManager.HTTP_PROXY_PASSWORD,
        String.valueOf(authentication.getPassword()));
    configFile.save();
    return true;
  }
  private static void patchGtkDefaults(UIDefaults defaults) {
    if (!UIUtil.isUnderGTKLookAndFeel()) return;

    Map<String, Icon> map =
        ContainerUtil.newHashMap(
            Arrays.asList(
                "OptionPane.errorIcon",
                "OptionPane.informationIcon",
                "OptionPane.warningIcon",
                "OptionPane.questionIcon"),
            Arrays.asList(
                AllIcons.General.ErrorDialog,
                AllIcons.General.InformationDialog,
                AllIcons.General.WarningDialog,
                AllIcons.General.QuestionDialog));
    // GTK+ L&F keeps icons hidden in style
    SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
    for (String key : map.keySet()) {
      if (defaults.get(key) != null) continue;

      Object icon = style == null ? null : style.get(null, key);
      defaults.put(key, icon instanceof Icon ? icon : map.get(key));
    }

    Color fg = defaults.getColor("Label.foreground");
    Color bg = defaults.getColor("Label.background");
    if (fg != null && bg != null) {
      defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
    }
  }
  private void doUpdate(@Nullable Runnable onComplete) {
    try {
      List<Task> issues =
          getIssuesFromRepositories(
              null, myConfig.updateIssuesCount, 0, false, new EmptyProgressIndicator());
      if (issues == null) return;

      synchronized (myIssueCache) {
        myIssueCache.clear();
        for (Task issue : issues) {
          myIssueCache.put(issue.getId(), issue);
        }
      }
      // update local tasks
      synchronized (myTasks) {
        for (Map.Entry<String, LocalTask> entry : myTasks.entrySet()) {
          Task issue = myIssueCache.get(entry.getKey());
          if (issue != null) {
            entry.getValue().updateFromIssue(issue);
          }
        }
      }
    } finally {
      if (onComplete != null) {
        onComplete.run();
      }
      myUpdating = false;
    }
  }
 @Override
 public void removeTask(LocalTask task) {
   if (task.isDefault()) return;
   if (myActiveTask.equals(task)) {
     activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true);
   }
   myTasks.remove(task.getId());
   myDispatcher.getMulticaster().taskRemoved(task);
   myContextManager.removeContext(task);
 }
  @NotNull
  public FileHighlightingSetting getHighlightingSettingForRoot(@NotNull PsiElement root) {
    final PsiFile containingFile = root.getContainingFile();
    final VirtualFile virtualFile = containingFile.getVirtualFile();
    FileHighlightingSetting[] fileHighlightingSettings = myHighlightSettings.get(virtualFile);
    final int index = PsiUtilBase.getRootIndex(root);

    if (fileHighlightingSettings == null || fileHighlightingSettings.length <= index) {
      return getDefaultHighlightingSetting(root.getProject(), virtualFile);
    }
    return fileHighlightingSettings[index];
  }
 public void setHighlightingSettingForRoot(
     @NotNull PsiElement root, @NotNull FileHighlightingSetting setting) {
   final PsiFile containingFile = root.getContainingFile();
   final VirtualFile virtualFile = containingFile.getVirtualFile();
   if (virtualFile == null) return;
   FileHighlightingSetting[] defaults = myHighlightSettings.get(virtualFile);
   int rootIndex = PsiUtilBase.getRootIndex(root);
   if (defaults != null && rootIndex >= defaults.length) defaults = null;
   if (defaults == null) defaults = getDefaults(containingFile);
   defaults[rootIndex] = setting;
   boolean toRemove = true;
   for (FileHighlightingSetting aDefault : defaults) {
     if (aDefault != FileHighlightingSetting.NONE) toRemove = false;
   }
   if (toRemove) {
     myHighlightSettings.remove(virtualFile);
   } else {
     myHighlightSettings.put(virtualFile, defaults);
   }
 }
  @Override
  public void loadState(final Element element) {
    String className = null;
    Element lafElement = element.getChild(ELEMENT_LAF);
    if (lafElement != null) {
      className = lafElement.getAttributeValue(ATTRIBUTE_CLASS_NAME);
      if (className != null && ourLafClassesAliases.containsKey(className)) {
        className = ourLafClassesAliases.get(className);
      }
    }

    UIManager.LookAndFeelInfo laf = findLaf(className);
    // If LAF is undefined (wrong class name or something else) we have set default LAF anyway.
    if (laf == null) {
      laf = getDefaultLaf();
    }

    if (myCurrentLaf != null && !laf.getClassName().equals(myCurrentLaf.getClassName())) {
      setCurrentLookAndFeel(laf);
      updateUI();
    }

    myCurrentLaf = laf;
  }
 public UpdateRootInfo getUpdateRootInfo(File file, final SvnVcs svnVcs) {
   if (!myUpdateRootInfos.containsKey(file)) {
     myUpdateRootInfos.put(file, new UpdateRootInfo(file, svnVcs));
   }
   return myUpdateRootInfos.get(file);
 }
 public MergeRootInfo getMergeRootInfo(final File file, final SvnVcs svnVcs) {
   if (!myMergeRootInfos.containsKey(file)) {
     myMergeRootInfos.put(file, new MergeRootInfo(file, svnVcs));
   }
   return myMergeRootInfos.get(file);
 }
 public Object getData(String kind, String realm) {
   return myStorage.get(kind + "$" + realm);
 }
 @Nullable
 @Override
 public LocalTask findTask(String id) {
   return myTasks.get(id);
 }