mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[vcs-log] extract an interface to encapsulate text filter field in the log tab
GitOrigin-RevId: 4f22449068be456e9a71226a59d81a673ec3a98d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
eb9a7fe812
commit
e1dde99c3b
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.vcs.log.ui.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
@@ -37,7 +37,7 @@ public class FocusTextFilterAction extends DumbAwareAction {
|
||||
IdeFocusManager.getInstance(project).requestFocus(logUi.getTable(), true);
|
||||
}
|
||||
else {
|
||||
IdeFocusManager.getInstance(project).requestFocus(logUi.getFilterUi().getTextFilterComponent().getTextField(), true);
|
||||
IdeFocusManager.getInstance(project).requestFocus(logUi.getFilterUi().getTextFilterComponent().getFocusedComponent(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUiEx {
|
||||
private final @NotNull VcsLogData myLogData;
|
||||
private final @NotNull MainVcsLogUiProperties myUiProperties;
|
||||
private final @NotNull VcsLogColorManager myColorManager;
|
||||
private final @NotNull SearchFieldWithExtension mySearchComponent;
|
||||
|
||||
private @NotNull VcsLogDataPack myDataPack;
|
||||
|
||||
@@ -82,6 +81,8 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUiEx {
|
||||
protected final @NotNull FileFilterModel myStructureFilterModel;
|
||||
protected final @NotNull TextFilterModel myTextFilterModel;
|
||||
|
||||
private final @NotNull VcsLogTextFilterField myTextFilterField;
|
||||
|
||||
private final @NotNull EventDispatcher<VcsLogFilterListener> myFilterListenerDispatcher = EventDispatcher.create(VcsLogFilterListener.class);
|
||||
|
||||
public VcsLogClassicFilterUi(@NotNull VcsLogData logData,
|
||||
@@ -104,7 +105,7 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUiEx {
|
||||
|
||||
TextFilterField textFilterField = new TextFilterField(myTextFilterModel, parentDisposable);
|
||||
ActionToolbar toolbar = createTextActionsToolbar(textFilterField.getTextEditor());
|
||||
mySearchComponent = new SearchFieldWithExtension(toolbar.getComponent(), textFilterField);
|
||||
myTextFilterField = new MyVcsLogTextFilterField(new SearchFieldWithExtension(toolbar.getComponent(), textFilterField));
|
||||
|
||||
FilterModel[] models = {myBranchFilterModel, myUserFilterModel, myDateFilterModel, myStructureFilterModel, myTextFilterModel};
|
||||
for (FilterModel<?> model : models) {
|
||||
@@ -168,8 +169,37 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUiEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull SearchFieldWithExtension getTextFilterComponent() {
|
||||
return mySearchComponent;
|
||||
public @NotNull VcsLogTextFilterField getTextFilterComponent() {
|
||||
return myTextFilterField;
|
||||
}
|
||||
|
||||
private static final class MyVcsLogTextFilterField implements VcsLogTextFilterField {
|
||||
private final @NotNull SearchFieldWithExtension mySearchField;
|
||||
|
||||
private MyVcsLogTextFilterField(@NotNull SearchFieldWithExtension field) { mySearchField = field; }
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return mySearchField;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getFocusedComponent() {
|
||||
return mySearchField.getTextField();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return mySearchField.getTextField().getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(@NotNull String s) {
|
||||
mySearchField.getTextField().setText(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.vcs.log.ui.filter;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.ui.components.SearchFieldWithExtension;
|
||||
import com.intellij.util.ui.StatusText;
|
||||
import com.intellij.vcs.log.VcsLogBundle;
|
||||
import com.intellij.vcs.log.VcsLogDataPack;
|
||||
@@ -37,7 +36,7 @@ public interface VcsLogFilterUiEx extends VcsLogFilterUi {
|
||||
ActionGroup createActionGroup();
|
||||
|
||||
@NotNull
|
||||
SearchFieldWithExtension getTextFilterComponent();
|
||||
VcsLogTextFilterField getTextFilterComponent();
|
||||
|
||||
/**
|
||||
* Informs the filter UI components that the actual VcsLogDataPack has been updated (e.g. due to a log refresh).
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.vcs.log.ui.filter
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import javax.swing.JComponent
|
||||
|
||||
@ApiStatus.Experimental
|
||||
interface VcsLogTextFilterField {
|
||||
val component: JComponent
|
||||
val focusedComponent: JComponent
|
||||
var text: String
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
ActionToolbar toolbar = actionManager.createActionToolbar(ActionPlaces.VCS_LOG_TOOLBAR_PLACE, mainGroup, true);
|
||||
toolbar.setTargetComponent(this);
|
||||
|
||||
Wrapper textFilter = new Wrapper(myFilterUi.getTextFilterComponent());
|
||||
Wrapper textFilter = new Wrapper(myFilterUi.getTextFilterComponent().getComponent());
|
||||
textFilter.setVerticalSizeReferent(toolbar.getComponent());
|
||||
String vcsDisplayName = VcsLogUtil.getVcsDisplayName(myLogData.getProject(), myLogData.getLogProviders().values());
|
||||
textFilter.getAccessibleContext().setAccessibleName(VcsLogBundle.message("vcs.log.text.filter.accessible.name", vcsDisplayName));
|
||||
@@ -414,7 +414,7 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
return List.of(myGraphTable,
|
||||
myChangesBrowser.getPreferredFocusedComponent(),
|
||||
myDiffPreview.getPreviewDiff().getPreferredFocusedComponent(),
|
||||
myFilterUi.getTextFilterComponent());
|
||||
myFilterUi.getTextFilterComponent().getFocusedComponent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package training.git.lesson
|
||||
|
||||
import com.intellij.diff.tools.util.SimpleDiffPanel
|
||||
@@ -169,7 +169,7 @@ class GitProjectHistoryLesson : GitLesson("Git.ProjectHistory", GitLessonsBundle
|
||||
}
|
||||
restoreState {
|
||||
val vcsLogUi = VcsProjectLog.getInstance(project).mainLogUi ?: return@restoreState false
|
||||
vcsLogUi.filterUi.textFilterComponent.textField.text == ""
|
||||
vcsLogUi.filterUi.textFilterComponent.text == ""
|
||||
}
|
||||
showWarningIfGitWindowClosed()
|
||||
test {
|
||||
|
||||
@@ -155,7 +155,7 @@ internal class BranchesDashboardUi(project: Project, private val logUi: Branches
|
||||
private val BRANCHES_UI_FOCUS_TRAVERSAL_POLICY = object : ComponentsListFocusTraversalPolicy() {
|
||||
override fun getOrderedComponents(): List<Component> = listOf(filteringTree.component, logUi.table,
|
||||
logUi.changesBrowser.preferredFocusedComponent,
|
||||
logUi.filterUi.textFilterComponent.textField)
|
||||
logUi.filterUi.textFilterComponent.focusedComponent)
|
||||
}
|
||||
|
||||
private val showBranches get() = logUi.properties.get(SHOW_GIT_BRANCHES_LOG_PROPERTY)
|
||||
|
||||
Reference in New Issue
Block a user