当前位置: 首页>>代码示例>>Java>>正文


Java Comparing.compare方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.Comparing.compare方法的典型用法代码示例。如果您正苦于以下问题:Java Comparing.compare方法的具体用法?Java Comparing.compare怎么用?Java Comparing.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.Comparing的用法示例。


在下文中一共展示了Comparing.compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copy

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
private void copy(Task issue) {
  mySummary = issue.getSummary();
  myDescription = issue.getDescription();
  myComments = issue.getComments();
  myClosed = issue.isClosed();
  myCreated = issue.getCreated();
  if (Comparing.compare(myUpdated, issue.getUpdated()) < 0) {
    myUpdated = issue.getUpdated();
  }
  myType = issue.getType();
  myPresentableName = issue.getPresentableName();
  myCustomIcon = issue.getCustomIcon();
  myIssueUrl = issue.getIssueUrl();
  myRepository = issue.getRepository();

  myProject = issue.getProject();
  myNumber = issue.getNumber();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LocalTaskImpl.java

示例2: getComparator

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Nullable
@Override
public Comparator<SystemImageDescription> getComparator() {
  return new Comparator<SystemImageDescription>() {
    @Override
    public int compare(SystemImageDescription o1, SystemImageDescription o2) {
      String s1 = valueOf(o1);
      String s2 = valueOf(o2);
      return Comparing.compare(s1, s2);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:SystemImageList.java

示例3: compare

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compare(Sdk o1, Sdk o2) {
  if (!(o1.getSdkType() instanceof PythonSdkType) ||
      !(o2.getSdkType() instanceof PythonSdkType)) {
    return -Comparing.compare(o1.getName(), o2.getName());
  }

  final boolean isVEnv1 = PythonSdkType.isVirtualEnv(o1);
  final boolean isVEnv2 = PythonSdkType.isVirtualEnv(o2);
  final boolean isRemote1 = PySdkUtil.isRemote(o1);
  final boolean isRemote2 = PySdkUtil.isRemote(o2);

  if (isVEnv1) {
    if (isVEnv2) {
      if (myProject != null && associatedWithCurrent(o1, myProject)) {
        if (associatedWithCurrent(o2, myProject)) return compareSdk(o1, o2);
        return -1;
      }
      return compareSdk(o1, o2);
    }
    return -1;
  }
  if (isVEnv2) return 1;
  if (isRemote1) {
    if (isRemote2) {
      return compareSdk(o1, o2);
    }
    return 1;
  }
  if (isRemote2) return -1;

  return compareSdk(o1, o2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PyConfigurableInterpreterList.java

示例4: compare

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compare(final Object o1, final Object o2) {
  final Pair<Integer, String> w1 = getWeightedName(o1);
  final Pair<Integer, String> w2 = getWeightedName(o2);
  if (w1 == null) return w2 == null ? 0 : -1;
  if (w2 == null) return 1;
  if (!w1.first.equals(w2.first)) {
    return -w1.first.intValue() + w2.first.intValue();
  }
  return Comparing.compare(w1.second, w2.second, String.CASE_INSENSITIVE_ORDER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:NavBarModel.java

示例5: extractRevision

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
protected String extractRevision(LocalPathIndifferentLogOperation operation, Convertor<CvsRevisionNumber, Boolean> chooser) {
  final List<LogInformation> informations = operation.getLogInformationList();
  for (LogInformation information : informations) {
    final List<Revision> revisionList = information.getRevisionList();
    for (Revision revision : revisionList) {
      if (revision.getNumber().startsWith(myTagStart)) {
        if (Comparing.compare(revision.getDate(), myStickyDate) <= 0) {
          return revision.getNumber();
        }
      }
    }
  }
  return myStickyData;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:StickyHeadGetter.java

示例6: compareTo

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compareTo(@NotNull TemplatesGroup o) {
  int i = o.myWeight - myWeight;
  if (i != 0) return i;
  int i1 = Comparing.compare(o.getParentGroup(), getParentGroup());
  if (i1 != 0) return i1;
  return o.getName().compareTo(getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:TemplatesGroup.java

示例7: findMostRecentSdk

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Nullable
public Sdk findMostRecentSdk(Condition<Sdk> condition) {
  Sdk found = null;
  for (Sdk each : getAllJdks()) {
    if (!condition.value(each)) continue;
    if (found == null) {
      found = each;
      continue;
    }
    if (Comparing.compare(each.getVersionString(), found.getVersionString()) > 0) found = each;
  }
  return found;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ProjectJdkTable.java

示例8: getComparator

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Nullable
@Override
public Comparator<AvdInfo> getComparator() {
  return new Comparator<AvdInfo>() {
    @Override
    public int compare(AvdInfo o1, AvdInfo o2) {
      Storage s1 = getSize(o1);
      Storage s2 = getSize(o2);
      return Comparing.compare(s1.getSize(), s2.getSize());
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AvdDisplayList.java

示例9: compare

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compare(MavenProject o1, MavenProject o2) {
  MavenId id1 = o1.getMavenId();
  MavenId id2 = o2.getMavenId();

  int res = Comparing.compare(id1.getGroupId(), id2.getGroupId());
  if (res != 0) return res;

  res = Comparing.compare(id1.getArtifactId(), id2.getArtifactId());
  if (res != 0) return res;

  res = Comparing.compare(id1.getVersion(), id2.getVersion());
  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MavenProjectNamer.java

示例10: compareTo

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compareTo(Entry o) {
  if (myNode == o.myNode) return 0;
  int res = Comparing.compare(myOffset, o.myOffset);
  if (res == 0) {
    return XValueNodeImpl.COMPARATOR.compare(myNode, o.myNode);
  }
  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:XVariablesView.java

示例11: compareTo

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compareTo(@NotNull ActionWrapper o) {
  int compared = myMode.compareTo(o.getMode());
  if (compared != 0) return compared;
  Presentation myPresentation = myAction.getTemplatePresentation();
  Presentation oPresentation = o.getAction().getTemplatePresentation();
  int byText = StringUtil.compare(myPresentation.getText(), oPresentation.getText(), true);
  if (byText != 0) return byText;
  int byGroup = Comparing.compare(myGroupName, o.getGroupName());
  if (byGroup !=0) return byGroup;
  int byDesc = StringUtil.compare(myPresentation.getDescription(), oPresentation.getDescription(), true);
  if (byDesc != 0) return byDesc;
  return 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GotoActionModel.java

示例12: PercentageCoverageColumnInfo

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
PercentageCoverageColumnInfo(int columnIdx,
                             String name,
                             final CoverageSuitesBundle suitesBundle,
                             CoverageViewManager.StateBean stateBean) {
  super(name);
  this.myColumnIdx = columnIdx;
  myComparator = new Comparator<NodeDescriptor>() {
    @Override
    public int compare(NodeDescriptor o1, NodeDescriptor o2) {
      final String val1 = valueOf(o1);
      final String val2 = valueOf(o2);
      if (val1 != null && val2 != null) {
        final int percentageIndex1 = val1.indexOf('%');
        final int percentageIndex2 = val2.indexOf('%');
        if (percentageIndex1 > -1 && percentageIndex2 >-1) {
          final String percentage1 = val1.substring(0, percentageIndex1);
          final String percentage2 = val2.substring(0, percentageIndex2);
          final int compare = Comparing.compare(Integer.parseInt(percentage1), Integer.parseInt(percentage2));
          if (compare == 0) {
            final int total1 = val1.indexOf('/');
            final int total2 = val2.indexOf('/');
            if (total1 > -1 && total2 > -1) {
              final int r1 = val1.indexOf(')', total1);
              final int r2 = val2.indexOf(')', total2);
              if (r1 > -1 && r2 > -1) {
                return Integer.parseInt(val2.substring(total2 + 1, r2)) - Integer.parseInt(val1.substring(total1 + 1, r1)) ;
              }
            }
          }
          return compare;
        }
        if (percentageIndex1 > -1) return 1;
        if (percentageIndex2 > -1) return -1;
      }
      return Comparing.compare(val1, val2);
    }
  };
  mySuitesBundle = suitesBundle;
  myStateBean = stateBean;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:PercentageCoverageColumnInfo.java

示例13: JrePathEditor

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
/**
 * This constructor can be used in UI forms. <strong>Don't forget to call {@link #setDefaultJreSelector(DefaultJreSelector)}!</strong>
 */
public JrePathEditor() {
  myLabel = new JBLabel(ExecutionBundle.message("run.configuration.jre.label"));

  myComboBoxModel = new SortedComboBoxModel<JreComboBoxItem>(new Comparator<JreComboBoxItem>() {
    @Override
    public int compare(JreComboBoxItem o1, JreComboBoxItem o2) {
      int result = Comparing.compare(o1.getOrder(), o2.getOrder());
      if (result != 0) {
        return result;
      }
      return o1.getPresentableText().compareToIgnoreCase(o2.getPresentableText());
    }
  });
  myDefaultJreItem = new DefaultJreItem();
  myComboBoxModel.add(myDefaultJreItem);
  final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks();
  for (Sdk sdk : allJDKs) {
    myComboBoxModel.add(new SdkAsJreItem(sdk));
  }

  final Set<String> jrePaths = new HashSet<String>();
  for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) {
    String path = provider.getJrePath();
    if (!StringUtil.isEmpty(path)) {
      jrePaths.add(path);
      myComboBoxModel.add(new CustomJreItem(path));
    }
  }

  for (Sdk jdk : allJDKs) {
    String homePath = jdk.getHomePath();

    if (!SystemInfo.isMac) {
      final File jre = new File(jdk.getHomePath(), "jre");
      if (jre.isDirectory()) {
        homePath = jre.getPath();
      }
    }
    if (jrePaths.add(homePath)) {
      myComboBoxModel.add(new CustomJreItem(homePath));
    }
  }
  ComboBox comboBox = new ComboBox(myComboBoxModel);
  comboBox.setEditable(true);
  comboBox.setRenderer(new ColoredListCellRendererWrapper<JreComboBoxItem>() {
    @Override
    protected void doCustomize(JList list, JreComboBoxItem value, int index, boolean selected, boolean hasFocus) {
      value.render(this, selected);
    }
  });
  myComboboxEditor = new JreComboboxEditor(myComboBoxModel);
  myComboboxEditor.getEditorComponent().setTextToTriggerEmptyTextStatus(DEFAULT_JRE_TEXT);
  comboBox.setEditor(myComboboxEditor);
  myPathField = new ComboboxWithBrowseButton(comboBox);
  myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
                                      ExecutionBundle.message("run.configuration.select.jre.dir.label"),
                                      null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
                                      JreComboboxEditor.TEXT_COMPONENT_ACCESSOR);

  setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
  add(myLabel, "shrinkx");
  add(myPathField, "growx, pushx");

  InsertPathAction.addTo(myComboboxEditor.getEditorComponent());

  setAnchor(myLabel);

  updateUI();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:73,代码来源:JrePathEditor.java

示例14: annotateExternally

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
private void annotateExternally(@NotNull final PsiModifierListOwner listOwner,
                                @NotNull final String annotationFQName,
                                @Nullable final XmlFile xmlFile,
                                @NotNull final PsiFile codeUsageFile,
                                @Nullable final PsiNameValuePair[] values) {
  if (xmlFile == null) {
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
    return;
  }
  try {
    final XmlDocument document = xmlFile.getDocument();
    if (document != null) {
      final XmlTag rootTag = document.getRootTag();
      final String externalName = getExternalName(listOwner, false);
      if (externalName == null) {
        LOG.info("member without external name: " + listOwner);
      }
      if (rootTag != null && externalName != null) {
        XmlTag anchor = null;
        for (XmlTag item : rootTag.getSubTags()) {
          int compare = Comparing.compare(externalName, StringUtil.unescapeXml(item.getAttributeValue("name")));
          if (compare == 0) {
            anchor = null;
            for (XmlTag annotation : item.getSubTags()) {
              compare = Comparing.compare(annotationFQName, annotation.getAttributeValue("name"));
              if (compare == 0) {
                annotation.delete();
                break;
              }
              anchor = annotation;
            }
            XmlTag newTag = XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(
              createAnnotationTag(annotationFQName, values));
            item.addAfter(newTag, anchor);
            commitChanges(xmlFile);
            notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
            return;
          }
          if (compare < 0) break;
          anchor = item;
        }
        @NonNls String text =
          "<item name=\'" + StringUtil.escapeXml(externalName) + "\'>\n";
        text += createAnnotationTag(annotationFQName, values);
        text += "</item>";
        rootTag.addAfter(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(text), anchor);
        commitChanges(xmlFile);
        notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
        return;
      }
    }
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
  }
  finally {
    dropCache();
    if (codeUsageFile.getVirtualFile().isInLocalFileSystem()) {
      UndoUtil.markPsiFileForUndo(codeUsageFile);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:ExternalAnnotationsManagerImpl.java

示例15: compare

import com.intellij.openapi.util.Comparing; //导入方法依赖的package包/类
@Override
public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
  final ModuleFileIndex fileIndex = ModuleRootManager.getInstance(myModule).getFileIndex();
  return Comparing.compare(fileIndex.getOrderEntryForFile(file2), fileIndex.getOrderEntryForFile(file1));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PackageUtil.java


注:本文中的com.intellij.openapi.util.Comparing.compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。