mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Add bek button.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs.log.graph;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BekGraphAction implements GraphAction {
|
||||
|
||||
@NotNull
|
||||
private final PermanentGraph.SortType mySortType;
|
||||
|
||||
public BekGraphAction(@NotNull PermanentGraph.SortType sortType) {
|
||||
mySortType = sortType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PermanentGraph.SortType getSortType() {
|
||||
return mySortType;
|
||||
}
|
||||
}
|
||||
@@ -78,8 +78,6 @@ public interface GraphFacade {
|
||||
*/
|
||||
void setFilter(@Nullable Condition<Integer> visibilityPredicate);
|
||||
|
||||
void setSortType(@NotNull PermanentGraph.SortType sortType);
|
||||
|
||||
/**
|
||||
* Returns the provider of some information about the graph.
|
||||
*/
|
||||
|
||||
@@ -36,6 +36,21 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class DelegateGraphFacade implements GraphFacade {
|
||||
@NotNull
|
||||
public static final GraphAnswer JUMP_TO_0_GRAPH_ANSWER = new GraphAnswer() {
|
||||
@Nullable
|
||||
@Override
|
||||
public GraphChange getGraphChange() {
|
||||
return new GraphChange() {
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GraphActionRequest getActionRequest() {
|
||||
return new JumpToRowActionRequest(0);
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
private final PermanentGraph<Integer> myPermanentGraph;
|
||||
@@ -124,19 +139,13 @@ public class DelegateGraphFacade implements GraphFacade {
|
||||
if (action instanceof LinearBranchesExpansionAction) {
|
||||
boolean shouldExpand = ((LinearBranchesExpansionAction)action).shouldExpand();
|
||||
actionController.setLinearBranchesExpansion(!shouldExpand);
|
||||
return new GraphAnswer() {
|
||||
@Nullable
|
||||
@Override
|
||||
public GraphChange getGraphChange() {
|
||||
return new GraphChange() {};
|
||||
}
|
||||
return JUMP_TO_0_GRAPH_ANSWER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GraphActionRequest getActionRequest() {
|
||||
return new JumpToRowActionRequest(0);
|
||||
}
|
||||
};
|
||||
if (action instanceof BekGraphAction) {
|
||||
mySortType = ((BekGraphAction)action).getSortType();
|
||||
updateVisibleGraph();
|
||||
return JUMP_TO_0_GRAPH_ANSWER;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -211,12 +220,6 @@ public class DelegateGraphFacade implements GraphFacade {
|
||||
updateVisibleGraph();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortType(@NotNull PermanentGraph.SortType sortType) {
|
||||
mySortType = sortType;
|
||||
updateVisibleGraph();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GraphInfoProvider getInfoProvider() {
|
||||
|
||||
@@ -79,10 +79,6 @@ class EmptyGraphFacade implements GraphFacade {
|
||||
public void setFilter(@Nullable Condition<Integer> visibilityPredicate) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortType(@NotNull PermanentGraph.SortType sortType) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GraphInfoProvider getInfoProvider() {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class VcsLogUiProperties implements PersistentStateComponent<VcsLogUiProp
|
||||
public static class State {
|
||||
public boolean SHOW_DETAILS = true;
|
||||
public boolean LONG_EDGES_VISIBLE = false;
|
||||
public boolean BEK_SORT = false;
|
||||
public Deque<UserGroup> RECENTLY_FILTERED_USER_GROUPS = new ArrayDeque<UserGroup>();
|
||||
public Deque<UserGroup> RECENTLY_FILTERED_BRANCH_GROUPS = new ArrayDeque<UserGroup>();
|
||||
}
|
||||
@@ -117,6 +118,14 @@ public class VcsLogUiProperties implements PersistentStateComponent<VcsLogUiProp
|
||||
myState.LONG_EDGES_VISIBLE = visible;
|
||||
}
|
||||
|
||||
public boolean isBek() {
|
||||
return myState.BEK_SORT;
|
||||
}
|
||||
|
||||
public void setBek(boolean isBek) {
|
||||
myState.BEK_SORT = isBek;
|
||||
}
|
||||
|
||||
public static class UserGroup {
|
||||
public List<String> users = new ArrayList<String>();
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
@Override
|
||||
public void run() {
|
||||
handleAnswer(answer);
|
||||
jumpToRow(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -150,7 +149,6 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
@Override
|
||||
public void run() {
|
||||
handleAnswer(answer);
|
||||
jumpToRow(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -166,6 +164,27 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
return myDataPack.getGraphFacade().getInfoProvider().areLongEdgesHidden();
|
||||
}
|
||||
|
||||
public void setBek(boolean bek) {
|
||||
myUiProperties.setBek(bek);
|
||||
final BekGraphAction bekGraphAction = new BekGraphAction(bek ? PermanentGraph.SortType.Bek : PermanentGraph.SortType.Normal);
|
||||
runUnderModalProgress("Apply sort type...", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final GraphAnswer answer = myDataPack.getGraphFacade().performAction(bekGraphAction);
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleAnswer(answer);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isBek() {
|
||||
return myUiProperties.isBek();
|
||||
}
|
||||
|
||||
public void click(int rowIndex) {
|
||||
handleAnswer(myDataPack.getGraphFacade().performAction(new ClickGraphAction(rowIndex, null)));
|
||||
}
|
||||
@@ -300,6 +319,7 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
setModel(newModel, myDataPack, previouslySelected);
|
||||
myMainFrame.updateDataPack(myDataPack);
|
||||
setLongEdgeVisibility(myUiProperties.areLongEdgesVisible());
|
||||
setBek(myUiProperties.isBek());
|
||||
fireFilterChangeEvent();
|
||||
repaintUI();
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@ public class MainFrame extends JPanel implements TypeSafeDataProvider {
|
||||
}
|
||||
|
||||
private JComponent createActionsToolbar() {
|
||||
AnAction bekAction = new BekAction();
|
||||
|
||||
AnAction hideBranchesAction = new GraphAction("Collapse linear branches", "Collapse linear branches", VcsLogIcons.CollapseBranches) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
@@ -194,7 +196,7 @@ public class MainFrame extends JPanel implements TypeSafeDataProvider {
|
||||
|
||||
refreshAction.registerShortcutOn(this);
|
||||
|
||||
DefaultActionGroup toolbarGroup = new DefaultActionGroup(hideBranchesAction, showBranchesAction, showFullPatchAction, refreshAction,
|
||||
DefaultActionGroup toolbarGroup = new DefaultActionGroup(bekAction, hideBranchesAction, showBranchesAction, showFullPatchAction, refreshAction,
|
||||
showDetailsAction);
|
||||
toolbarGroup.add(ActionManager.getInstance().getAction(VcsLogUiImpl.TOOLBAR_ACTION_GROUP));
|
||||
|
||||
@@ -276,6 +278,28 @@ public class MainFrame extends JPanel implements TypeSafeDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private class BekAction extends ToggleAction implements DumbAware {
|
||||
public BekAction() {
|
||||
super("BEK", "BEK", AllIcons.Actions.Lightning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return myUI.isBek();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
myUI.setBek(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(areGraphActionsEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowDetailsAction extends ToggleAction implements DumbAware {
|
||||
|
||||
public ShowDetailsAction() {
|
||||
|
||||
Reference in New Issue
Block a user