mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Move custom ShowExcludedFiles to ProjectViewImpl (IDEA-196319)
This commit is contained in:
@@ -85,6 +85,10 @@ public abstract class ProjectView {
|
||||
public void setCompactDirectories(boolean compactDirectories, @NotNull String paneId) {
|
||||
}
|
||||
|
||||
public boolean isShowExcludedFiles(String paneId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract boolean isShowLibraryContents(String paneId);
|
||||
|
||||
public abstract void setShowLibraryContents(boolean showLibraryContents, @NotNull String paneId);
|
||||
|
||||
@@ -77,8 +77,8 @@ public interface ProjectViewSettings extends ViewSettings {
|
||||
|
||||
@Override
|
||||
public boolean isShowExcludedFiles() {
|
||||
ProjectViewSettings settings = getProjectViewSettings();
|
||||
return settings != null && settings.isShowExcludedFiles();
|
||||
ProjectView view = getProjectView();
|
||||
return view != null && view.isShowExcludedFiles(getPaneID(view));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -120,6 +120,8 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
private static final boolean ourShowModulesDefaults = true;
|
||||
private final Map<String, Boolean> myFlattenModules = new THashMap<>();
|
||||
private static final boolean ourFlattenModulesDefaults = false;
|
||||
private final Map<String, Boolean> myShowExcludedFiles = new THashMap<>();
|
||||
private static final boolean ourShowExcludedFilesDefaults = true;
|
||||
private final Map<String, Boolean> myShowLibraryContents = new THashMap<>();
|
||||
private static final boolean ourShowLibraryContentsDefaults = true;
|
||||
private final Map<String, Boolean> myHideEmptyPackages = new THashMap<>();
|
||||
@@ -162,6 +164,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
@NonNls private static final String ELEMENT_FLATTEN_PACKAGES = "flattenPackages";
|
||||
@NonNls private static final String ELEMENT_SHOW_MEMBERS = "showMembers";
|
||||
@NonNls private static final String ELEMENT_SHOW_MODULES = "showModules";
|
||||
@NonNls private static final String ELEMENT_SHOW_EXCLUDED_FILES = "showExcludedFiles";
|
||||
@NonNls private static final String ELEMENT_SHOW_LIBRARY_CONTENTS = "showLibraryContents";
|
||||
@NonNls private static final String ELEMENT_HIDE_EMPTY_PACKAGES = "hideEmptyPackages";
|
||||
@NonNls private static final String ELEMENT_COMPACT_DIRECTORIES = "compactDirectories";
|
||||
@@ -690,6 +693,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
myActionGroup.addAction(new ManualOrderAction()).setAsSecondary(true);
|
||||
myActionGroup.addAction(new SortByTypeAction()).setAsSecondary(true);
|
||||
myActionGroup.addAction(new FoldersAlwaysOnTopAction()).setAsSecondary(true);
|
||||
myActionGroup.addAction(ShowExcludedFilesAction.INSTANCE).setAsSecondary(true);
|
||||
|
||||
if (!myAutoScrollFromSourceHandler.isAutoScrollEnabled()) {
|
||||
titleActions.add(new ScrollFromSourceAction());
|
||||
@@ -1370,6 +1374,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
readOption(navigatorElement.getChild(ELEMENT_FLATTEN_PACKAGES), myFlattenPackages);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_MEMBERS), myShowMembers);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_MODULES), myShowModules);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_EXCLUDED_FILES), myShowExcludedFiles);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_LIBRARY_CONTENTS), myShowLibraryContents);
|
||||
readOption(navigatorElement.getChild(ELEMENT_HIDE_EMPTY_PACKAGES), myHideEmptyPackages);
|
||||
readOption(navigatorElement.getChild(ELEMENT_COMPACT_DIRECTORIES), myCompactDirectories);
|
||||
@@ -1449,6 +1454,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
writeOption(navigatorElement, myFlattenPackages, ELEMENT_FLATTEN_PACKAGES);
|
||||
writeOption(navigatorElement, myShowMembers, ELEMENT_SHOW_MEMBERS);
|
||||
writeOption(navigatorElement, myShowModules, ELEMENT_SHOW_MODULES);
|
||||
writeOption(navigatorElement, myShowExcludedFiles, ELEMENT_SHOW_EXCLUDED_FILES);
|
||||
writeOption(navigatorElement, myShowLibraryContents, ELEMENT_SHOW_LIBRARY_CONTENTS);
|
||||
writeOption(navigatorElement, myHideEmptyPackages, ELEMENT_HIDE_EMPTY_PACKAGES);
|
||||
writeOption(navigatorElement, myCompactDirectories, ELEMENT_COMPACT_DIRECTORIES);
|
||||
@@ -1620,6 +1626,41 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return getPaneOptionValue(myAbbreviatePackageNames, paneId, ourAbbreviatePackagesDefaults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowExcludedFiles(String paneId) {
|
||||
boolean showExcludedFiles = isGlobalOptions()
|
||||
? getGlobalOptions().getShowExcludedFiles()
|
||||
: getPaneOptionValue(myShowExcludedFiles, paneId, ourShowExcludedFilesDefaults);
|
||||
|
||||
if (showExcludedFiles == ourShowExcludedFilesDefaults) {
|
||||
AbstractProjectViewPane pane = getProjectViewPaneById(ProjectViewPane.ID);
|
||||
if (pane instanceof ProjectViewPane) {
|
||||
ProjectViewPane old = (ProjectViewPane)pane;
|
||||
showExcludedFiles = old.myShowExcludedFiles;
|
||||
if (showExcludedFiles != ourShowExcludedFilesDefaults) {
|
||||
setShowExcludedFiles(showExcludedFiles, paneId, false);
|
||||
setPaneOption(myShowExcludedFiles, showExcludedFiles, ProjectViewPane.ID, false);
|
||||
old.myShowExcludedFiles = ourShowExcludedFilesDefaults; // reset old state after copying it
|
||||
}
|
||||
}
|
||||
}
|
||||
return showExcludedFiles;
|
||||
}
|
||||
|
||||
void setShowExcludedFiles(boolean showExcludedFiles, @NotNull String paneId, boolean updatePane) {
|
||||
if (isGlobalOptions()) {
|
||||
getGlobalOptions().setShowExcludedFiles(showExcludedFiles);
|
||||
for (String id : getPaneIds()) {
|
||||
if (ShowExcludedFilesAction.INSTANCE.isSupported(this, id)) {
|
||||
setPaneOption(myShowExcludedFiles, showExcludedFiles, id, updatePane);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ShowExcludedFilesAction.INSTANCE.isSupported(this, paneId)) {
|
||||
setPaneOption(myShowExcludedFiles, showExcludedFiles, paneId, updatePane);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowLibraryContents(String paneId) {
|
||||
if (isGlobalOptions()) {
|
||||
|
||||
@@ -11,12 +11,10 @@ import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.ProjectViewSettings;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.impl.nodes.*;
|
||||
import com.intellij.ide.scopeView.EditScopesAction;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeUpdater;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -33,14 +31,12 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.intellij.openapi.application.Experiments.isFeatureEnabled;
|
||||
|
||||
public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
@NonNls public static final String ID = "ProjectPane";
|
||||
public static final String SHOW_EXCLUDED_FILES_OPTION = "show-excluded-files";
|
||||
private static final String USE_FILE_NESTING_RULES = "use-file-nesting-rules";
|
||||
|
||||
private boolean myShowExcludedFiles = true;
|
||||
boolean myShowExcludedFiles = true;
|
||||
private boolean myUseFileNestingRules = true;
|
||||
|
||||
public ProjectViewPane(Project project) {
|
||||
@@ -114,9 +110,6 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
if (!myShowExcludedFiles) {
|
||||
JDOMExternalizerUtil.writeField(element, SHOW_EXCLUDED_FILES_OPTION, String.valueOf(false));
|
||||
}
|
||||
if (!myUseFileNestingRules) {
|
||||
JDOMExternalizerUtil.writeField(element, USE_FILE_NESTING_RULES, String.valueOf(false));
|
||||
}
|
||||
@@ -128,7 +121,6 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
// special module nodes so it's better to hide 'Flatten Modules' action to avoid confusion
|
||||
actionGroup.addAction(createFlattenModulesAction(this::hasSeveralTopLevelModuleNodes)).setAsSecondary(true);
|
||||
|
||||
actionGroup.addAction(new ShowExcludedFilesAction()).setAsSecondary(true);
|
||||
actionGroup.addAction(new ConfigureFilesNestingAction()).setAsSecondary(true);
|
||||
AnAction editScopesAction = ActionManager.getInstance().getAction("ScopeView.EditScopes");
|
||||
if (editScopesAction != null) actionGroup.addAction(editScopesAction).setAsSecondary(true);
|
||||
@@ -217,7 +209,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
|
||||
@Override
|
||||
public boolean isShowExcludedFiles() {
|
||||
return myShowExcludedFiles;
|
||||
return ProjectView.getInstance(myProject).isShowExcludedFiles(ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -231,33 +223,6 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
}
|
||||
|
||||
private final class ShowExcludedFilesAction extends ToggleAction implements DumbAware {
|
||||
private ShowExcludedFilesAction() {
|
||||
super(IdeBundle.message("action.show.excluded.files"), IdeBundle.message("action.show.hide.excluded.files"), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
return myShowExcludedFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
if (myShowExcludedFiles != flag) {
|
||||
myShowExcludedFiles = flag;
|
||||
updateFromRoot(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final ProjectView projectView = ProjectView.getInstance(myProject);
|
||||
presentation.setEnabledAndVisible(projectView.getCurrentProjectViewPane() == ProjectViewPane.this);
|
||||
}
|
||||
}
|
||||
|
||||
private class ConfigureFilesNestingAction extends DumbAwareAction {
|
||||
private ConfigureFilesNestingAction() {
|
||||
super(IdeBundle.message("action.file.nesting.in.project.view"));
|
||||
|
||||
@@ -17,6 +17,7 @@ class ProjectViewSharedSettings : PersistentStateComponent<ProjectViewSharedSett
|
||||
var sortByType: Boolean = false
|
||||
var showModules: Boolean = true
|
||||
var flattenModules: Boolean = false
|
||||
var showExcludedFiles: Boolean = true
|
||||
var showLibraryContents: Boolean = true
|
||||
var hideEmptyPackages: Boolean = true
|
||||
var compactDirectories: Boolean = false
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright 2000-2018 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.
|
||||
package com.intellij.ide.projectView.impl;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
abstract class ProjectViewToggleAction extends ToggleAction implements DumbAware {
|
||||
ProjectViewToggleAction(@NotNull String text, @Nullable String description) {
|
||||
super(text, description, null);
|
||||
}
|
||||
|
||||
abstract boolean isSupported(@NotNull ProjectViewImpl view, @NotNull String id);
|
||||
|
||||
abstract boolean isSelected(@NotNull ProjectViewImpl view, @NotNull String id);
|
||||
|
||||
abstract void setSelected(@NotNull ProjectViewImpl view, @NotNull String id, boolean flag);
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
ProjectViewImpl view = getProjectView(event);
|
||||
String id = view == null ? null : view.getCurrentViewId();
|
||||
return id != null && isSelected(view, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
ProjectViewImpl view = getProjectView(event);
|
||||
String id = view == null ? null : view.getCurrentViewId();
|
||||
if (id != null) setSelected(view, id, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent event) {
|
||||
super.update(event);
|
||||
ProjectViewImpl view = getProjectView(event);
|
||||
String id = view == null ? null : view.getCurrentViewId();
|
||||
event.getPresentation().setEnabledAndVisible(id != null && isSupported(view, id));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ProjectViewImpl getProjectView(AnActionEvent event) {
|
||||
Project project = event == null ? null : event.getProject();
|
||||
ProjectView view = project == null ? null : ProjectView.getInstance(project);
|
||||
return view instanceof ProjectViewImpl ? (ProjectViewImpl)view : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2000-2018 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.
|
||||
package com.intellij.ide.projectView.impl;
|
||||
|
||||
import com.intellij.ide.scopeView.ScopeViewPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.ide.IdeBundle.message;
|
||||
|
||||
final class ShowExcludedFilesAction extends ProjectViewToggleAction {
|
||||
static final ShowExcludedFilesAction INSTANCE = new ShowExcludedFilesAction();
|
||||
|
||||
ShowExcludedFilesAction() {
|
||||
super(message("action.show.excluded.files"), message("action.show.hide.excluded.files"));
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isSupported(@NotNull ProjectViewImpl view, @NotNull String id) {
|
||||
return id.equals(ProjectViewPane.ID) || id.equals(ScopeViewPane.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isSelected(@NotNull ProjectViewImpl view, @NotNull String id) {
|
||||
return view.isShowExcludedFiles(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
void setSelected(@NotNull ProjectViewImpl view, @NotNull String id, boolean showExcludedFiles) {
|
||||
view.setShowExcludedFiles(showExcludedFiles, id, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user