mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Added "Show Unversioned Files" toggle button to commit dialog
Removed previously used "Show/Hide unversioned files" link.
This commit is contained in:
@@ -342,7 +342,8 @@ public abstract class ChangesBrowserBase<T> extends JPanel implements TypeSafeDa
|
||||
myViewer.setAlwaysExpandList(value);
|
||||
}
|
||||
|
||||
private JComponent createToolbar() {
|
||||
@NotNull
|
||||
protected JComponent createToolbar() {
|
||||
DefaultActionGroup toolbarGroups = new DefaultActionGroup();
|
||||
myToolBarGroup = new DefaultActionGroup();
|
||||
toolbarGroups.add(myToolBarGroup);
|
||||
|
||||
+10
-47
@@ -19,7 +19,9 @@ import com.intellij.diff.util.DiffPlaces;
|
||||
import com.intellij.diff.util.DiffUserDataKeysEx;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
@@ -49,13 +51,14 @@ import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SplitterWithSecondHideable;
|
||||
import com.intellij.ui.components.labels.ActionLink;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.OnOffListener;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import com.intellij.util.ui.components.BorderLayoutPanel;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -292,8 +295,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
myBrowser = new AlienChangeListBrowser(project, changeLists, changes, initialSelection, true, true, singleVcs);
|
||||
} else {
|
||||
//noinspection unchecked
|
||||
boolean showUnversioned =
|
||||
myShowVcsCommit && myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT && Registry.is("vcs.unversioned.files.in.commit");
|
||||
boolean unversionedFilesEnabled = myShowVcsCommit && Registry.is("vcs.unversioned.files.in.commit");
|
||||
MultipleChangeListBrowser browser = new MultipleChangeListBrowser(project, changeLists, (List)changes, initialSelection, true, true,
|
||||
new Runnable() {
|
||||
@Override
|
||||
@@ -308,7 +310,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
handler.includedChangesChanged();
|
||||
}
|
||||
}
|
||||
}, showUnversioned) {
|
||||
}, unversionedFilesEnabled) {
|
||||
@Override
|
||||
protected void afterDiffRefresh() {
|
||||
myBrowser.rebuildList();
|
||||
@@ -1009,11 +1011,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
myChangesInfoCalculator = new ChangeInfoCalculator();
|
||||
myLegend = new CommitLegendPanel(myChangesInfoCalculator);
|
||||
|
||||
BorderLayoutPanel bottomPanel = JBUI.Panels.simplePanel().addToRight(myLegend.getComponent());
|
||||
if (myShowVcsCommit && !myIsAlien && Registry.is("vcs.unversioned.files.in.commit")) {
|
||||
bottomPanel.addToLeft(createShowUnversionedFilesLabel());
|
||||
}
|
||||
myBrowser.getBottomPanel().add(bottomPanel, BorderLayout.SOUTH);
|
||||
myBrowser.getBottomPanel().add(JBUI.Panels.simplePanel().addToRight(myLegend.getComponent()), BorderLayout.SOUTH);
|
||||
|
||||
JPanel mainPanel;
|
||||
if (myAdditionalOptionsPanel != null) {
|
||||
@@ -1110,20 +1108,6 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
return myDetailsSplitter.getComponent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JComponent createShowUnversionedFilesLabel() {
|
||||
ShowHideUnversionedFilesAction action = new ShowHideUnversionedFilesAction();
|
||||
ActionLink link = new ActionLink(action.getText(myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT), null, action);
|
||||
|
||||
JLabel label = new JLabel(" unversioned files");
|
||||
label.setEnabled(false);
|
||||
|
||||
JPanel panel = SwingHelper.newHorizontalPanel(Component.CENTER_ALIGNMENT, link, label);
|
||||
panel.setFont(JBUI.Fonts.smallFont());
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void initMainSplitter() {
|
||||
mySplitter.setProportion(PropertiesComponent.getInstance().getFloat(SPLITTER_PROPORTION_OPTION, SPLITTER_PROPORTION_OPTION_DEFAULT));
|
||||
}
|
||||
@@ -1401,25 +1385,4 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
myOptions.setBounds(new Rectangle(bounds.width - optionsWidth, 0, optionsWidth, bounds.height));
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowHideUnversionedFilesAction extends ToggleAction {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent e) {
|
||||
return myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull AnActionEvent e, boolean state) {
|
||||
myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT = state;
|
||||
((MultipleChangeListBrowser)myBrowser).setShowUnversioned(state);
|
||||
myBrowser.rebuildList();
|
||||
((JLabel)e.getInputEvent().getSource()).setText(getText(state));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getText(boolean showUnversionedState) {
|
||||
return showUnversionedState ? "Hide" : "Show";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-12
@@ -24,10 +24,10 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.actions.MoveChangesToAnotherListAction;
|
||||
@@ -57,7 +57,8 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
@NotNull private final EventDispatcher<SelectedListChangeListener> myDispatcher =
|
||||
EventDispatcher.create(SelectedListChangeListener.class);
|
||||
@Nullable private final Runnable myRebuildListListener;
|
||||
private boolean myShowUnversioned;
|
||||
@NotNull private final VcsConfiguration myVcsConfiguration;
|
||||
private final boolean myUnversionedFilesEnabled;
|
||||
private Collection<Change> myAllChanges;
|
||||
private boolean myInRebuildList;
|
||||
private AnAction myMoveActionWithCustomShortcut;
|
||||
@@ -71,14 +72,18 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
boolean highlightProblems,
|
||||
@Nullable Runnable rebuildListListener,
|
||||
@Nullable Runnable inclusionListener,
|
||||
boolean showUnversioned) {
|
||||
boolean unversionedFilesEnabled) {
|
||||
super(project, changeLists, changes, initialListSelection, capableOfExcludingChanges, highlightProblems, inclusionListener,
|
||||
ChangesBrowser.MyUseCase.LOCAL_CHANGES, null, Object.class);
|
||||
myRebuildListListener = rebuildListListener;
|
||||
myShowUnversioned = showUnversioned;
|
||||
myVcsConfiguration = ObjectUtils.assertNotNull(VcsConfiguration.getInstance(myProject));
|
||||
myUnversionedFilesEnabled = unversionedFilesEnabled;
|
||||
|
||||
myChangeListChooser = new ChangeListChooser();
|
||||
myChangeListChooser.updateLists(changeLists);
|
||||
// rebuild toolbar to ensure "myUnversionedFilesEnabled" is considered
|
||||
myHeaderPanel.removeAll();
|
||||
myHeaderPanel.add(createToolbar(), BorderLayout.CENTER);
|
||||
myHeaderPanel.add(myChangeListChooser, BorderLayout.EAST);
|
||||
ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener);
|
||||
|
||||
@@ -104,8 +109,8 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
}, this);
|
||||
}
|
||||
|
||||
public void setShowUnversioned(boolean showUnversioned) {
|
||||
myShowUnversioned = showUnversioned;
|
||||
private boolean isShowUnversioned() {
|
||||
return myUnversionedFilesEnabled && myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,7 +195,7 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
TreeModelBuilder builder = new TreeModelBuilder(myProject, showFlatten);
|
||||
|
||||
builder.setChanges(findChanges(objects), changeNodeDecorator);
|
||||
if (myShowUnversioned) {
|
||||
if (isShowUnversioned()) {
|
||||
builder.setUnversioned(ChangesViewManager.getUnversionedFilesInfo(manager));
|
||||
}
|
||||
|
||||
@@ -203,7 +208,7 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
List<Object> result = ContainerUtil.newArrayList();
|
||||
|
||||
result.addAll(node.getAllChangesUnder());
|
||||
if (myShowUnversioned && isUnderUnversioned(node)) {
|
||||
if (isShowUnversioned() && isUnderUnversioned(node)) {
|
||||
result.addAll(node.getAllFilesUnder());
|
||||
}
|
||||
|
||||
@@ -216,7 +221,7 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
Object result = null;
|
||||
Object userObject = node.getUserObject();
|
||||
|
||||
if (userObject instanceof Change || myShowUnversioned && isUnderUnversioned(node) && userObject instanceof VirtualFile) {
|
||||
if (userObject instanceof Change || isShowUnversioned() && isUnderUnversioned(node) && userObject instanceof VirtualFile) {
|
||||
result = userObject;
|
||||
}
|
||||
|
||||
@@ -233,7 +238,7 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<VirtualFile> getIncludedUnversionedFiles() {
|
||||
return myShowUnversioned
|
||||
return isShowUnversioned()
|
||||
? ContainerUtil.findAll(myViewer.getIncludedChanges(), VirtualFile.class)
|
||||
: Collections.<VirtualFile>emptyList();
|
||||
}
|
||||
@@ -242,7 +247,7 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
public int getUnversionedFilesCount() {
|
||||
int result = 0;
|
||||
|
||||
if (myShowUnversioned) {
|
||||
if (isShowUnversioned()) {
|
||||
ChangesBrowserNode<?> node = findUnversionedFilesNode();
|
||||
|
||||
if (node != null) {
|
||||
@@ -311,7 +316,8 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
rebuildList();
|
||||
}
|
||||
});
|
||||
if (Registry.is("vcs.unversioned.files.in.commit")) {
|
||||
if (myUnversionedFilesEnabled) {
|
||||
toolBarGroup.add(new ShowHideUnversionedFilesAction());
|
||||
toolBarGroup.add(UnversionedViewDialog.getUnversionedActionGroup());
|
||||
}
|
||||
else {
|
||||
@@ -423,6 +429,24 @@ public class MultipleChangeListBrowser extends ChangesBrowserBase<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowHideUnversionedFilesAction extends ToggleAction {
|
||||
|
||||
private ShowHideUnversionedFilesAction() {
|
||||
super("Show Unversioned Files", null, AllIcons.Debugger.Disable_value_calculation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent e) {
|
||||
return myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull AnActionEvent e, boolean state) {
|
||||
myVcsConfiguration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT = state;
|
||||
rebuildList();
|
||||
}
|
||||
}
|
||||
|
||||
private class MoveAction extends MoveChangesToAnotherListAction {
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull AnActionEvent e) {
|
||||
|
||||
Reference in New Issue
Block a user