public static void registerObjectsExportedDefinitions(
      @NotNull VirtualFile key,
      @NotNull final JsonSchemaExportedDefinitions definitionsObject,
      @NotNull final JsonSchemaObject object) {
    String id = object.getId();
    if (!StringUtil.isEmptyOrSpaces(id)) {
      id = id.endsWith("#") ? id.substring(0, id.length() - 1) : id;
      final BiFunction<String, Map<String, JsonSchemaObject>, Map<String, JsonSchemaObject>>
          convertor =
              (s, map) -> {
                final Map<String, JsonSchemaObject> converted = new HashMap<>();
                for (Map.Entry<String, JsonSchemaObject> entry : map.entrySet()) {
                  String key1 = entry.getKey();
                  key1 = key1.startsWith("/") ? key1.substring(1) : key1;
                  converted.put(s + key1, entry.getValue());
                }
                return converted;
              };

      final HashMap<String, JsonSchemaObject> map = new HashMap<>();
      map.put("", object);
      final Map<String, JsonSchemaObject> definitions = object.getDefinitions();
      if (definitions != null && !definitions.isEmpty()) {
        map.putAll(convertor.apply("#/definitions/", definitions));
      }
      final Map<String, JsonSchemaObject> properties = object.getProperties();
      if (properties != null && !properties.isEmpty()) {
        map.putAll(convertor.apply("#/properties/", properties));
      }
      definitionsObject.register(key, id, map);
    }
  }
  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;
  }
  @NotNull
  private static Pair<VcsLogTextFilter, VcsLogHashFilter> getFiltersFromTextArea(
      @Nullable VcsLogTextFilter filter) {
    if (filter == null) {
      return Pair.empty();
    }
    String text = filter.getText().trim();
    if (StringUtil.isEmptyOrSpaces(text)) {
      return Pair.empty();
    }
    List<String> hashes = ContainerUtil.newArrayList();
    for (String word : StringUtil.split(text, " ")) {
      if (!StringUtil.isEmptyOrSpaces(word) && word.matches(HASH_PATTERN)) {
        hashes.add(word);
      } else {
        break;
      }
    }

    VcsLogTextFilter textFilter;
    VcsLogHashFilterImpl hashFilter;
    if (!hashes.isEmpty()) { // text is ignored if there are hashes in the text
      textFilter = null;
      hashFilter = new VcsLogHashFilterImpl(hashes);
    } else {
      textFilter = new VcsLogTextFilterImpl(text);
      hashFilter = null;
    }
    return Pair.<VcsLogTextFilter, VcsLogHashFilter>create(textFilter, hashFilter);
  }
 public static void notifyMessages(
     Project project,
     @Nullable String title,
     @Nullable String description,
     NotificationType type,
     boolean important,
     @Nullable Collection<String> messages) {
   if (title == null) {
     title = "";
   }
   String desc = (description != null ? description.replace("\n", "<br/>") : "");
   if (messages != null && !messages.isEmpty()) {
     desc += "<hr/>" + StringUtil.join(messages, "<br/>");
   }
   if (StringUtil.isEmptyOrSpaces(desc)) {
     desc =
         StringUtil.isEmptyOrSpaces(title)
             ? "Error"
             : title; // description is not allowed to be empty, title is => moving title text to
                      // description
     title = "";
   }
   NotificationGroup group =
       important ? GitVcs.IMPORTANT_ERROR_NOTIFICATION : GitVcs.NOTIFICATION_GROUP_ID;
   group.createNotification(title, desc, type, null).notify(project.isDefault() ? null : project);
 }
  public void loadState(final Element element) {
    List groups = element.getChildren(GROUP_TAG);

    for (Object group : groups) {
      Element groupElement = (Element) group;
      String groupName = groupElement.getAttributeValue(GROUP_NAME_ATTR);

      final GroupDescriptor groupDescriptor = GroupDescriptor.create(groupName);

      List projectsList = groupElement.getChildren(PROJECT_TAG);
      for (Object project : projectsList) {
        Element projectElement = (Element) project;
        String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR);
        String frameworks = projectElement.getAttributeValue(VALUES_ATTR);
        if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) {
          Set<UsageDescriptor> frameworkDescriptors = new HashSet<UsageDescriptor>();
          for (String key : StringUtil.split(frameworks, TOKENIZER)) {
            final UsageDescriptor descriptor = getUsageDescriptor(key);
            if (descriptor != null) frameworkDescriptors.add(descriptor);
          }
          getApplicationData(groupDescriptor).put(projectId, frameworkDescriptors);
        }
      }
    }
  }
示例#6
0
  /**
   * Fetches all specified roots. Once a root has failed, stops and displays the notification. If
   * needed, displays the successful notification at the end.
   *
   * @param roots roots to fetch.
   * @param errorNotificationTitle if specified, this notification title will be used instead of the
   *     standard "Fetch failed". Use this when fetch is a part of a compound process.
   * @param notifySuccess if set to {@code true} successful notification will be displayed.
   * @return true if all fetches were successful, false if at least one fetch failed.
   */
  public boolean fetchRootsAndNotify(
      @NotNull Collection<GitRepository> roots,
      @Nullable String errorNotificationTitle,
      boolean notifySuccess) {
    Map<VirtualFile, String> additionalInfo = new HashMap<VirtualFile, String>();
    for (GitRepository repository : roots) {
      LOG.info("fetching " + repository);
      GitFetchResult result = fetch(repository);
      String ai = result.getAdditionalInfo();
      if (!StringUtil.isEmptyOrSpaces(ai)) {
        additionalInfo.put(repository.getRoot(), ai);
      }
      if (!result.isSuccess()) {
        Collection<Exception> errors = new ArrayList<Exception>(getErrors());
        errors.addAll(result.getErrors());
        displayFetchResult(myProject, result, errorNotificationTitle, errors);
        return false;
      }
    }
    if (notifySuccess) {
      GitUIUtil.notifySuccess(myProject, "", "Fetched successfully");
    }

    String addInfo = makeAdditionalInfoByRoot(additionalInfo);
    if (!StringUtil.isEmptyOrSpaces(addInfo)) {
      Notificator.getInstance(myProject)
          .notify(
              GitVcs.MINOR_NOTIFICATION, "Fetch details", addInfo, NotificationType.INFORMATION);
    }

    return true;
  }
  private void onStateChangedToSuccess(final AuthenticationRequest obj) {
    myCopiesPassiveResults.put(getKey(obj), true);
    myVcs.invokeRefreshSvnRoots(false);

    final List<SVNURL> outdatedRequests = new LinkedList<SVNURL>();
    final Collection<SVNURL> keys = getAllCurrentKeys();
    for (SVNURL key : keys) {
      final SVNURL commonURLAncestor = SVNURLUtil.getCommonURLAncestor(key, obj.getUrl());
      if ((commonURLAncestor != null)
          && (!StringUtil.isEmptyOrSpaces(commonURLAncestor.getHost()))
          && (!StringUtil.isEmptyOrSpaces(commonURLAncestor.getPath()))) {
        // final AuthenticationRequest currObj = getObj(key);
        // if ((currObj != null) && passiveValidation(myVcs.getProject(), key, true,
        // currObj.getRealm(), currObj.getKind())) {
        outdatedRequests.add(key);
        // }
      }
    }
    log("on state changed ");
    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                for (SVNURL key : outdatedRequests) {
                  removeLazyNotificationByKey(key);
                }
              }
            },
            ModalityState.NON_MODAL);
  }
示例#8
0
 @NotNull
 public static List<VcsDirectoryMapping> addMapping(
     @NotNull List<VcsDirectoryMapping> existingMappings,
     @NotNull String path,
     @NotNull String vcs) {
   List<VcsDirectoryMapping> mappings = new ArrayList<VcsDirectoryMapping>(existingMappings);
   for (Iterator<VcsDirectoryMapping> iterator = mappings.iterator(); iterator.hasNext(); ) {
     VcsDirectoryMapping mapping = iterator.next();
     if (mapping.isDefaultMapping() && StringUtil.isEmptyOrSpaces(mapping.getVcs())) {
       LOG.debug("Removing <Project> -> <None> mapping");
       iterator.remove();
     } else if (FileUtil.pathsEqual(mapping.getDirectory(), path)) {
       if (!StringUtil.isEmptyOrSpaces(mapping.getVcs())) {
         LOG.warn(
             "Substituting existing mapping ["
                 + path
                 + "] -> ["
                 + mapping.getVcs()
                 + "] with ["
                 + vcs
                 + "]");
       } else {
         LOG.debug("Removing [" + path + "] -> <None> mapping");
       }
       iterator.remove();
     }
   }
   mappings.add(new VcsDirectoryMapping(path, vcs));
   return mappings;
 }
 @Override
 public void checkConfiguration() throws RuntimeConfigurationException {
   super.checkConfiguration();
   if (StringUtil.isEmptyOrSpaces(getInputFile()))
     throw new RuntimeConfigurationError("Please specify input directory name.");
   if (StringUtil.isEmptyOrSpaces(getOutputFile()))
     throw new RuntimeConfigurationError("Please specify output directory name.");
 }
 private void updateTokenButton() {
   if (StringUtil.isEmptyOrSpaces(getHost())
       || StringUtil.isEmptyOrSpaces(getRepoAuthor())
       || StringUtil.isEmptyOrSpaces(getRepoName())) {
     myTokenButton.setEnabled(false);
   } else {
     myTokenButton.setEnabled(true);
   }
 }
  @Nullable
  private static String createId(MavenDomDependency coordinates) {
    String groupId = coordinates.getGroupId().getStringValue();
    String artifactId = coordinates.getArtifactId().getStringValue();

    if (StringUtil.isEmptyOrSpaces(groupId) || StringUtil.isEmptyOrSpaces(artifactId)) return null;

    String version = coordinates.getVersion().getStringValue();
    String type = coordinates.getType().getStringValue();
    String classifier = coordinates.getClassifier().getStringValue();

    return groupId + ":" + artifactId + ":" + version + ":" + type + ":" + classifier;
  }
  public TestComparisionFailedState(
      @Nullable final String localizedMessage,
      @Nullable final String stackTrace,
      @NotNull final String actualText,
      @NotNull final String expectedText,
      @Nullable final String expectedFilePath,
      @Nullable final String actualFilePath) {
    super(localizedMessage, stackTrace);
    myHyperlink =
        new DiffHyperlink(expectedText, actualText, expectedFilePath, actualFilePath, true);

    myErrorMsgPresentation = StringUtil.isEmptyOrSpaces(localizedMessage) ? "" : localizedMessage;
    myStacktracePresentation = StringUtil.isEmptyOrSpaces(stackTrace) ? "" : stackTrace;
  }
 public MavenDomProjectModelFileMemberChooserObjectBase(
     @NotNull final PsiFile psiFile, @Nullable String projectName) {
   super(
       psiFile,
       StringUtil.isEmptyOrSpaces(projectName) ? psiFile.getName() : projectName,
       MavenIcons.MavenProject);
 }
  public Process createProcess() throws ExecutionException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Executing [" + getCommandLineString() + "]");
    }

    List<String> commands;
    try {
      checkWorkingDirectory();

      if (StringUtil.isEmptyOrSpaces(myExePath)) {
        throw new ExecutionException(
            IdeBundle.message("run.configuration.error.executable.not.specified"));
      }

      commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList());
    } catch (ExecutionException e) {
      LOG.info(e);
      throw e;
    }

    try {
      return startProcess(commands);
    } catch (IOException e) {
      LOG.info(e);
      throw new ProcessNotCreatedException(e.getMessage(), e, this);
    }
  }
  private boolean isValid() {
    if (myUseHTTPProxyRb.isSelected()) {
      String host = getText(myProxyHostTextField);
      if (host == null) {
        return false;
      }

      try {
        HostAndPort parsedHost = HostAndPort.fromString(host);
        if (parsedHost.hasPort()) {
          return false;
        }
        host = parsedHost.getHostText();

        try {
          InetAddresses.forString(host);
          return true;
        } catch (IllegalArgumentException e) {
          // it is not an IPv4 or IPv6 literal
        }

        InternetDomainName.from(host);
      } catch (IllegalArgumentException e) {
        return false;
      }

      if (myProxyAuthCheckBox.isSelected()) {
        return !StringUtil.isEmptyOrSpaces(myProxyLoginTextField.getText())
            && myProxyPasswordTextField.getPassword().length > 0;
      }
    }
    return true;
  }
  @Override
  public void reset(@NotNull HttpConfigurable settings) {
    myNoProxyRb.setSelected(true); // default
    myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(settings.USE_PAC_URL);
    myPacUrlTextField.setText(settings.PAC_URL);
    myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION);

    enableProxy(settings.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(settings.getProxyLogin());
    myProxyPasswordTextField.setText(settings.getPlainProxyPassword());

    myProxyPortTextField.setNumber(settings.PROXY_PORT);
    myProxyHostTextField.setText(settings.PROXY_HOST);
    myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS));

    myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS);

    boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR);
    myErrorLabel.setVisible(showError);
    myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null);

    final String oldStyleText =
        CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
      myOtherWarning.setText(oldStyleText);
      myOtherWarning.setIcon(Messages.getWarningIcon());
    }
  }
  @Override
  public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) {
    if (!Registry.is("vcs.showConsole")) {
      return;
    }
    if (StringUtil.isEmptyOrSpaces(message)) {
      return;
    }

    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              @Override
              public void run() {
                // for default and disposed projects the ContentManager is not available.
                if (myProject.isDisposed() || myProject.isDefault()) return;
                final ContentManager contentManager = getContentManager();
                if (contentManager == null) {
                  myPendingOutput.add(Pair.create(message, attributes));
                } else {
                  getOrCreateConsoleContent(contentManager);
                  myEditorAdapter.appendString(message, attributes);
                }
              }
            },
            ModalityState.defaultModalityState());
  }
  public void reset() {
    myNoProxyRb.setSelected(true); // default
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    myAutoDetectProxyRb.setSelected(httpConfigurable.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(httpConfigurable.USE_PAC_URL);
    myPacUrlTextField.setText(httpConfigurable.PAC_URL);
    myUseHTTPProxyRb.setSelected(httpConfigurable.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(httpConfigurable.PROXY_AUTHENTICATION);

    enableProxy(httpConfigurable.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(httpConfigurable.PROXY_LOGIN);
    myProxyPasswordTextField.setText(httpConfigurable.getPlainProxyPassword());

    myProxyPortTextField.setText(Integer.toString(httpConfigurable.PROXY_PORT));
    myProxyHostTextField.setText(httpConfigurable.PROXY_HOST);
    myProxyExceptions.setText(httpConfigurable.PROXY_EXCEPTIONS);

    myRememberProxyPasswordCheckBox.setSelected(httpConfigurable.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(httpConfigurable.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!httpConfigurable.PROXY_TYPE_IS_SOCKS);

    final boolean showError = !StringUtil.isEmptyOrSpaces(httpConfigurable.LAST_ERROR);
    myErrorLabel.setVisible(showError);
    myErrorLabel.setText(showError ? errorText(httpConfigurable.LAST_ERROR) : "");

    final String oldStyleText =
        CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
      myOtherWarning.setText(oldStyleText);
      myOtherWarning.setUI(new MultiLineLabelUI());
      myOtherWarning.setIcon(Messages.getWarningIcon());
    }
  }
  public static boolean isValidName(
      final Project project, final PsiElement psiElement, final String newName) {
    if (newName == null || newName.length() == 0) {
      return false;
    }
    final Condition<String> inputValidator =
        RenameInputValidatorRegistry.getInputValidator(psiElement);
    if (inputValidator != null) {
      return inputValidator.value(newName);
    }
    if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
      return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0;
    }
    if (psiElement instanceof PomTargetPsiElement) {
      return !StringUtil.isEmptyOrSpaces(newName);
    }

    final PsiFile file = psiElement.getContainingFile();
    final Language elementLanguage = psiElement.getLanguage();

    final Language fileLanguage = file == null ? null : file.getLanguage();
    Language language =
        fileLanguage == null
            ? elementLanguage
            : fileLanguage.isKindOf(elementLanguage) ? fileLanguage : elementLanguage;

    return LanguageNamesValidation.INSTANCE
        .forLanguage(language)
        .isIdentifier(newName.trim(), project);
  }
 private String doGetFullVersion() {
   if (myFullVersionFormat == null) {
     if (!StringUtil.isEmptyOrSpaces(myMajorVersion)) {
       if (!StringUtil.isEmptyOrSpaces(myMinorVersion)) {
         return myMajorVersion + "." + myMinorVersion;
       } else {
         return myMajorVersion + ".0";
       }
     } else {
       return getVersionName();
     }
   } else {
     return MessageFormat.format(
         myFullVersionFormat, myMajorVersion, myMinorVersion, myMicroVersion, myPatchVersion);
   }
 }
 @Override
 protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock)
     throws SAXException {
   final String name = attributes.getValue("name");
   assertSAX(!StringUtil.isEmptyOrSpaces(name));
   myName = name;
 }
    public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
      if (!myHandler.isEnabled(project)) return false;

      Editor editor = event.getData(PlatformDataKeys.EDITOR);
      if (editor == null) return false;

      InputEvent inputEvent = event.getInputEvent();
      if (inputEvent instanceof MouseEvent && inputEvent.isAltDown()) {
        MouseEvent mouseEvent = (MouseEvent) inputEvent;
        Component component =
            SwingUtilities.getDeepestComponentAt(
                mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        if (SwingUtilities.isDescendingFrom(component, editor.getComponent())) {
          MouseEvent convertedEvent =
              SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, component);
          EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent);
          if (area != EditorMouseEventArea.EDITING_AREA) {
            return false;
          }
        }
      } else {
        if (StringUtil.isEmptyOrSpaces(editor.getSelectionModel().getSelectedText())) {
          return false;
        }
      }

      return true;
    }
  public void validate() throws IllegalArgumentException {
    if (StringUtil.isEmptyOrSpaces(myRuleRegex)) {
      throw new IllegalArgumentException("Empty regex");
    }
    if (!".*".equals(myRuleRegex)) {
      Pattern.compile(myRuleRegex);
    }

    if (!StringUtil.isEmptyOrSpaces(myAdditionalProperties)) {
      try {
        new Properties().load(new ByteArrayInputStream(myAdditionalProperties.getBytes("UTF-8")));
      } catch (Exception e) {
        throw new IllegalArgumentException("Malformed manifest entries");
      }
    }
  }
  public Process createProcess() throws ExecutionException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Executing [" + getCommandLineString() + "]");
    }

    List<String> commands;
    try {
      checkWorkingDirectory();

      if (StringUtil.isEmptyOrSpaces(myExePath)) {
        throw new ExecutionException(
            IdeBundle.message("run.configuration.error.executable.not.specified"));
      }

      commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList());
    } catch (ExecutionException e) {
      LOG.warn(e);
      throw e;
    }

    try {
      ProcessBuilder builder = new ProcessBuilder(commands);
      setupEnvironment(builder.environment());
      builder.directory(myWorkDirectory);
      builder.redirectErrorStream(myRedirectErrorStream);
      return builder.start();
    } catch (IOException e) {
      LOG.warn(e);
      throw new ProcessNotCreatedException(e.getMessage(), e, this);
    }
  }
  private void doValidateInput() {
    List<String> errors = new ArrayList<>();
    if (StringUtil.isEmptyOrSpaces(myGroupIdField.getText())) errors.add("GroupId");
    if (StringUtil.isEmptyOrSpaces(myArtifactIdField.getText())) errors.add("ArtifactId");
    if (StringUtil.isEmptyOrSpaces(myVersionField.getText())) errors.add("Version");

    if (errors.isEmpty()) {
      setErrorText(null);
      getOKAction().setEnabled(true);
      return;
    }
    String message = "Please specify " + StringUtil.join(errors, ", ");
    setErrorText(message);
    getOKAction().setEnabled(false);
    getRootPane().revalidate();
  }
示例#26
0
 private boolean setServiceParameter(
     GlobalEnvironment.PropertyType type, JLabel label, JTextField textField) {
   String name = String.valueOf(type).toLowerCase();
   String startDirectory =
       StringUtil.isEmptyOrSpaces(textField.getText())
           ? System.getProperty("user.home")
           : textField.getText();
   JFileChooser fileChooser = new JFileChooser(startDirectory);
   fileChooser.setDialogTitle("Select Emacs " + name + " directory");
   fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
     String dir = fileChooser.getSelectedFile().getAbsolutePath();
     textField.setText(dir);
     if (GlobalEnvironment.testProperty(type, dir)) {
       infoLabel.setText("Emacs " + name + " directory successfully set");
       label.setForeground(Color.black);
       return true;
     } else {
       onWrongProperty(label, type);
       return false;
     }
   } else {
     if (GlobalEnvironment.isEmacsPropertyOk(type)) return true;
     onWrongProperty(label, type);
     return false;
   }
 }
  // relativePaths are guaranteed to fit into command line length limitations.
  @Override
  @NotNull
  public Collection<VirtualFile> untrackedFilesNoChunk(
      @NotNull Project project, @NotNull VirtualFile root, @Nullable List<String> relativePaths)
      throws VcsException {
    final Set<VirtualFile> untrackedFiles = new HashSet<VirtualFile>();
    GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LS_FILES);
    h.setNoSSH(true);
    h.setSilent(true);
    h.addParameters("--exclude-standard", "--others", "-z");
    h.endOptions();
    if (relativePaths != null) {
      h.addParameters(relativePaths);
    }

    final String output = h.run();
    if (StringUtil.isEmptyOrSpaces(output)) {
      return untrackedFiles;
    }

    for (String relPath : output.split("\u0000")) {
      VirtualFile f = root.findFileByRelativePath(relPath);
      if (f == null) {
        // files was created on disk, but VirtualFile hasn't yet been created,
        // when the GitChangeProvider has already been requested about changes.
        LOG.info(String.format("VirtualFile for path [%s] is null", relPath));
      } else {
        untrackedFiles.add(f);
      }
    }

    return untrackedFiles;
  }
示例#28
0
  /**
   * Returns absolute paths which have changed remotely comparing to the current branch, i.e.
   * performs <code>git diff --name-only master..origin/master</code>
   *
   * <p>Paths are absolute, Git-formatted (i.e. with forward slashes).
   */
  @NotNull
  public static Collection<String> getPathsDiffBetweenRefs(
      @NotNull Git git,
      @NotNull GitRepository repository,
      @NotNull String beforeRef,
      @NotNull String afterRef)
      throws VcsException {
    List<String> parameters = Arrays.asList("--name-only", "--pretty=format:");
    String range = beforeRef + ".." + afterRef;
    GitCommandResult result = git.diff(repository, parameters, range);
    if (!result.success()) {
      LOG.info(
          String.format(
              "Couldn't get diff in range [%s] for repository [%s]",
              range, repository.toLogString()));
      return Collections.emptyList();
    }

    final Collection<String> remoteChanges = new HashSet<String>();
    for (StringScanner s = new StringScanner(result.getOutputAsJoinedString()); s.hasMoreData(); ) {
      final String relative = s.line();
      if (StringUtil.isEmptyOrSpaces(relative)) {
        continue;
      }
      final String path = repository.getRoot().getPath() + "/" + unescapePath(relative);
      remoteChanges.add(path);
    }
    return remoteChanges;
  }
 public BeanBinding(Class<?> beanClass) {
   assert !beanClass.isArray() : "Bean is an array: " + beanClass;
   assert !beanClass.isPrimitive() : "Bean is primitive type: " + beanClass;
   myBeanClass = beanClass;
   myTagName = getTagName(beanClass);
   assert !StringUtil.isEmptyOrSpaces(myTagName) : "Bean name is empty: " + beanClass;
 }
  @NotNull
  private static HttpClient getHttpClient(
      @Nullable final String login, @Nullable final String password) {
    final HttpClient client = new HttpClient();
    HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
    params.setConnectionTimeout(
        CONNECTION_TIMEOUT); // set connection timeout (how long it takes to connect to remote host)
    params.setSoTimeout(
        CONNECTION_TIMEOUT); // set socket timeout (how long it takes to retrieve data from remote
                             // host)

    client.getParams().setContentCharset("UTF-8");
    // Configure proxySettings if it is required
    final HttpConfigurable proxySettings = HttpConfigurable.getInstance();
    if (proxySettings.USE_HTTP_PROXY && !StringUtil.isEmptyOrSpaces(proxySettings.PROXY_HOST)) {
      client.getHostConfiguration().setProxy(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
      if (proxySettings.PROXY_AUTHENTICATION) {
        client
            .getState()
            .setProxyCredentials(
                AuthScope.ANY,
                new UsernamePasswordCredentials(
                    proxySettings.PROXY_LOGIN, proxySettings.getPlainProxyPassword()));
      }
    }
    if (login != null && password != null) {
      client.getParams().setCredentialCharset("UTF-8");
      client.getParams().setAuthenticationPreemptive(true);
      client
          .getState()
          .setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(login, password));
    }
    return client;
  }