mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Refactored "ChangeListColumn" - cleanup, @Override
This commit is contained in:
@@ -14,22 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: yole
|
||||
* Date: 27.11.2006
|
||||
* Time: 20:22:50
|
||||
*/
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.changes.ChangeList;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import static com.intellij.openapi.util.Comparing.compare;
|
||||
import static com.intellij.openapi.vcs.VcsBundle.message;
|
||||
import static com.intellij.util.text.DateFormatUtil.formatPrettyDateTime;
|
||||
import static java.util.Comparator.comparing;
|
||||
import static java.util.Comparator.comparingLong;
|
||||
|
||||
public abstract class ChangeListColumn<T extends ChangeList> {
|
||||
public abstract String getTitle();
|
||||
public abstract Object getValue(T changeList);
|
||||
@@ -41,90 +40,96 @@ public abstract class ChangeListColumn<T extends ChangeList> {
|
||||
|
||||
// TODO: CompositeCommittedChangesProvider.getColumns() needs to be updated if new standard columns are added
|
||||
|
||||
public static ChangeListColumn<CommittedChangeList> DATE = new ChangeListColumn<CommittedChangeList>() {
|
||||
public static final ChangeListColumn<CommittedChangeList> DATE = new ChangeListColumn<CommittedChangeList>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
return VcsBundle.message("column.name.revision.list.date");
|
||||
return message("column.name.revision.list.date");
|
||||
}
|
||||
|
||||
public Object getValue(final CommittedChangeList changeList) {
|
||||
return DateFormatUtil.formatPrettyDateTime(changeList.getCommitDate());
|
||||
@Override
|
||||
@NotNull
|
||||
public Object getValue(@NotNull CommittedChangeList changeList) {
|
||||
return formatPrettyDateTime(changeList.getCommitDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Comparator<CommittedChangeList> getComparator() {
|
||||
// TODO: CommittedChangeListByDateComparator could be utilized here. But currently it is placed in vcs-impl.
|
||||
// TODO: Think of either moving these ChangeListColumn instances to vcs-impl or move comparator to vcs-api.
|
||||
return new Comparator<CommittedChangeList>() {
|
||||
public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
|
||||
return o1.getCommitDate().compareTo(o2.getCommitDate());
|
||||
}
|
||||
};
|
||||
return comparing(CommittedChangeList::getCommitDate);
|
||||
}
|
||||
};
|
||||
|
||||
public static ChangeListColumn<CommittedChangeList> NAME = new ChangeListColumn<CommittedChangeList>() {
|
||||
public static final ChangeListColumn<CommittedChangeList> NAME = new ChangeListColumn<CommittedChangeList>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
return VcsBundle.message("column.name.revision.list.committer");
|
||||
return message("column.name.revision.list.committer");
|
||||
}
|
||||
|
||||
public Object getValue(final CommittedChangeList changeList) {
|
||||
@Override
|
||||
public Object getValue(@NotNull CommittedChangeList changeList) {
|
||||
return changeList.getCommitterName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Comparator<CommittedChangeList> getComparator() {
|
||||
return new Comparator<CommittedChangeList>() {
|
||||
public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
|
||||
return Comparing.compare((String) getValue(o1), (String) getValue(o2));
|
||||
}
|
||||
};
|
||||
return (changeList1, changeList2) -> compare(changeList1.getCommitterName(), changeList2.getCommitterName());
|
||||
}
|
||||
};
|
||||
|
||||
public static ChangeListColumn<CommittedChangeList> NUMBER = new ChangeListNumberColumn(VcsBundle.message("column.name.revision.list.number"));
|
||||
public static final ChangeListColumn<CommittedChangeList> NUMBER =
|
||||
new ChangeListNumberColumn(message("column.name.revision.list.number"));
|
||||
|
||||
public static ChangeListColumn<CommittedChangeList> DESCRIPTION = new ChangeListColumn<CommittedChangeList>() {
|
||||
public static final ChangeListColumn<CommittedChangeList> DESCRIPTION = new ChangeListColumn<CommittedChangeList>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
return VcsBundle.message("column.name.revision.list.description");
|
||||
return message("column.name.revision.list.description");
|
||||
}
|
||||
|
||||
public Object getValue(final CommittedChangeList changeList) {
|
||||
@Override
|
||||
@NotNull
|
||||
public Object getValue(@NotNull CommittedChangeList changeList) {
|
||||
return changeList.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Comparator<CommittedChangeList> getComparator() {
|
||||
return new Comparator<CommittedChangeList>() {
|
||||
public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
};
|
||||
return comparing(ChangeList::getName);
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean isCustom(final ChangeListColumn column) {
|
||||
return column != DATE && column != DESCRIPTION &&
|
||||
column != NAME && !(column instanceof ChangeListNumberColumn);
|
||||
public static boolean isCustom(@NotNull ChangeListColumn column) {
|
||||
return column != DATE && column != DESCRIPTION && column != NAME && !(column instanceof ChangeListNumberColumn);
|
||||
}
|
||||
|
||||
public static class ChangeListNumberColumn extends ChangeListColumn<CommittedChangeList> {
|
||||
private final String myTitle;
|
||||
|
||||
public ChangeListNumberColumn(final String title) {
|
||||
public ChangeListNumberColumn(String title) {
|
||||
myTitle = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
public Object getValue(final CommittedChangeList changeList) {
|
||||
@Override
|
||||
@NotNull
|
||||
public Object getValue(@NotNull CommittedChangeList changeList) {
|
||||
return changeList.getNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Comparator<CommittedChangeList> getComparator() {
|
||||
return new Comparator<CommittedChangeList>() {
|
||||
public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
|
||||
return (int)(o1.getNumber() - o2.getNumber());
|
||||
}
|
||||
};
|
||||
return comparingLong(CommittedChangeList::getNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user