本文整理匯總了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();
}
示例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);
}
};
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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());
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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));
}