UsageViewSettings — use BaseState

This commit is contained in:
Vladimir Krivosheev
2017-12-21 12:21:00 +01:00
parent c7185f48fa
commit 405223081d
17 changed files with 99 additions and 314 deletions
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 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.
* Copyright 2000-2017 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.unscramble;
@@ -47,14 +35,15 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static com.intellij.icons.AllIcons.Debugger.ThreadStates.*;
@@ -413,17 +402,6 @@ public class ThreadDumpPanel extends JPanel implements DataProvider {
myThreadStates = threadStates;
}
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {}
@NotNull
@Override
public String getReportText() {
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2013 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.
* Copyright 2000-2017 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.usages.impl.rules;
@@ -169,7 +157,7 @@ public class MethodGroupingRule extends SingleParentUsageGroupingRule {
if (SmartPointerManager.getInstance(myProject).pointToTheSameElement(myMethodPointer, other.myMethodPointer)) {
return 0;
}
if (!UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY) {
if (!UsageViewSettings.getInstance().isSortAlphabetically()) {
Segment segment1 = myMethodPointer.getRange();
Segment segment2 = other.myMethodPointer.getRange();
if (segment1 != null && segment2 != null) {
@@ -1,4 +1,6 @@
// Copyright 2000-2017 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-2017 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.java.psi.usages;
import com.intellij.openapi.util.Disposer;
@@ -23,10 +25,10 @@ public class JavaUsageViewTreeTest extends LightCodeInsightFixtureTestCase {
XmlSerializerUtil.copyBean(settings.getState(), oldSettingsState);
disposeOnTearDown(() -> settings.loadState(oldSettingsState));
settings.GROUP_BY_MODULE = false;
settings.GROUP_BY_FILE_STRUCTURE = true;
settings.GROUP_BY_USAGE_TYPE = false;
settings.GROUP_BY_PACKAGE = false;
settings.setGroupByModule(false);
settings.setGroupByFileStructure(true);
settings.setGroupByUsageType(false);
settings.setGroupByPackage(false);
}
public void testSimpleModule() {
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 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.
* Copyright 2000-2017 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.favoritesTreeView;
@@ -68,7 +56,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
@@ -258,19 +245,6 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
private ExporterToTextFile createTextExporter() {
return new ExporterToTextFile() {
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
@Override
public String getReportText() {
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2015 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.
* Copyright 2000-2017 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.hierarchy;
@@ -20,11 +8,8 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Enumeration;
import java.util.TooManyListenersException;
class ExporterToTextFileHierarchy implements ExporterToTextFile {
private static final Logger LOG = Logger.getInstance(ExporterToTextFileHierarchy.class);
@@ -34,19 +19,6 @@ class ExporterToTextFileHierarchy implements ExporterToTextFile {
myHierarchyBrowserBase = hierarchyBrowserBase;
}
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
@Override
public String getReportText() {
@@ -60,7 +60,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
@@ -673,22 +672,7 @@ public class DependenciesPanel extends JPanel implements Disposable, DataProvide
}
}
private class DependenciesExporterToTextFile implements ExporterToTextFile {
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
@Override
public String getReportText() {
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2016 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.
* Copyright 2000-2017 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.slicer;
@@ -143,7 +131,7 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.RIGHT));
boolean vertical = myToolWindow.getAnchor() == ToolWindowAnchor.LEFT || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT;
Splitter splitter = new Splitter(vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
Splitter splitter = new Splitter(vertical, UsageViewSettings.getInstance().getPreviewUsagesSplitterProportion());
splitter.setFirstComponent(pane);
myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation());
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
@@ -167,7 +155,7 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
@Override
public void dispose() {
if (myUsagePreviewPanel != null) {
UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS = ((Splitter)myUsagePreviewPanel.getParent()).getProportion();
UsageViewSettings.getInstance().setPreviewUsagesSplitterProportion(((Splitter)myUsagePreviewPanel.getParent()).getProportion());
myUsagePreviewPanel = null;
}
@@ -175,7 +163,7 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
ToolTipManager.sharedInstance().unregisterComponent(myTree);
}
class MultiLanguageTreeCellRenderer implements TreeCellRenderer {
static class MultiLanguageTreeCellRenderer implements TreeCellRenderer {
@NotNull
private final SliceUsageCellRendererBase rootRenderer;
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 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.
* Copyright 2000-2017 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.slicer;
@@ -20,10 +8,7 @@ import com.intellij.usages.UsageViewSettings;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.util.List;
import java.util.TooManyListenersException;
/**
* @author nik
@@ -36,19 +21,6 @@ public class SliceToTextFileExporter implements ExporterToTextFile {
myBuilder = builder;
}
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
@Override
public String getReportText() {
@@ -78,12 +50,12 @@ public class SliceToTextFileExporter implements ExporterToTextFile {
@NotNull
@Override
public String getDefaultFilePath() {
return UsageViewSettings.getInstance().EXPORT_FILE_NAME;
return UsageViewSettings.getInstance().getExportFileName();
}
@Override
public void exportedTo(String filePath) {
UsageViewSettings.getInstance().EXPORT_FILE_NAME = filePath;
UsageViewSettings.getInstance().setExportFileName(filePath);
}
@Override
@@ -1,32 +1,34 @@
/*
* Copyright 2000-2009 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.
* Copyright 2000-2017 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;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.util.TooManyListenersException;
public interface ExporterToTextFile {
JComponent getSettingsEditor();
void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException;
void removeSettingsChangedListener(ChangeListener listener);
@NotNull String getReportText();
@NotNull String getDefaultFilePath();
@Nullable
default JComponent getSettingsEditor() {
return null;
}
default void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
default void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
String getReportText();
@NotNull
String getDefaultFilePath();
void exportedTo(String filePath);
boolean canExport();
}
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 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.
* Copyright 2000-2017 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.usages.impl;
@@ -61,9 +49,9 @@ public class UsageViewTreeTest extends UsefulTestCase {
XmlSerializerUtil.copyBean(settings.getState(), oldSettingsState);
disposeOnTearDown(() -> settings.loadState(oldSettingsState));
settings.GROUP_BY_FILE_STRUCTURE = false;
settings.GROUP_BY_USAGE_TYPE = false;
settings.GROUP_BY_PACKAGE = false;
settings.setGroupByFileStructure(false);
settings.setGroupByUsageType(false);
settings.setGroupByPackage(false);
}
public void testSimpleModule() throws Exception {
@@ -81,7 +69,7 @@ public class UsageViewTreeTest extends UsefulTestCase {
addModule("xxx.main");
PsiFile file = myFixture.addFileToProject("xxx.main/A.txt", "hello");
Usage[] usages = {new UsageInfo2UsageAdapter(new UsageInfo(file))};
UsageViewSettings.getInstance().FLATTEN_MODULES = false;
UsageViewSettings.getInstance().setFlattenModules(false);
ModuleGroupTestsKt.runWithQualifiedModuleNamesEnabled(() -> {
assertUsageViewStructureEquals(usages, "Usage (1 usage)\n" +
" Non-code usages (1 usage)\n" +
@@ -1,4 +1,6 @@
// Copyright 2000-2017 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-2017 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.usages;
import com.intellij.openapi.components.PersistentStateComponent;
@@ -6,14 +8,10 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@State(
name = "ShowUsagesSettings",
storages = {
@Storage("usageView.xml")
}
)
@State(name = "ShowUsagesSettings", storages = @Storage("usageView.xml"))
public class ShowUsagesSettings implements PersistentStateComponent<UsageViewSettings> {
private final UsageViewSettings myState = new UsageViewSettings();
@@ -24,7 +22,7 @@ public class ShowUsagesSettings implements PersistentStateComponent<UsageViewSet
}
@Override
public void loadState(UsageViewSettings state) {
public void loadState(@NotNull UsageViewSettings state) {
XmlSerializerUtil.copyBean(state, myState);
}
@@ -33,10 +31,10 @@ public class ShowUsagesSettings implements PersistentStateComponent<UsageViewSet
}
public ShowUsagesSettings() {
myState.GROUP_BY_FILE_STRUCTURE = false;
myState.GROUP_BY_MODULE = false;
myState.GROUP_BY_PACKAGE = false;
myState.GROUP_BY_USAGE_TYPE = false;
myState.GROUP_BY_SCOPE = false;
myState.setGroupByFileStructure(false);
myState.setGroupByModule(false);
myState.setGroupByPackage(false);
myState.setGroupByUsageType(false);
myState.setGroupByScope(false);
}
}
@@ -17,16 +17,20 @@ class UsageViewSettings : BaseState(), PersistentStateComponent<UsageViewSetting
get() = ServiceManager.getService(UsageViewSettings::class.java)
}
var EXPORT_FILE_NAME by string("report.txt")
@Suppress("MemberVisibilityCanPrivate")
@get:OptionTag("EXPORT_FILE_NAME")
internal var EXPORT_FILE_NAME by property("report.txt")
@get:OptionTag("IS_EXPANDED")
var isExpanded by property(false)
var isShowPackages by property(true)
var isShowMethods by property(false)
@get:OptionTag("IS_AUTOSCROLL_TO_SOURCE")
var isAutoScrollToSource by property(false)
@get:OptionTag("IS_FILTER_DUPLICATED_LINE")
var isFilterDuplicatedLine by property(true)
@get:OptionTag("IS_SHOW_METHODS")
var isShowModules by property(false)
@get:OptionTag("IS_PREVIEW_USAGES")
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2013 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.
* Copyright 2000-2017 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.usages.impl;
@@ -22,11 +10,8 @@ import com.intellij.usages.UsageViewSettings;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Enumeration;
import java.util.TooManyListenersException;
/**
* @author max
@@ -38,19 +23,6 @@ public class ExporterToTextFile implements com.intellij.ide.ExporterToTextFile {
myUsageView = usageView;
}
@Override
public JComponent getSettingsEditor() {
return null;
}
@Override
public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
}
@Override
public void removeSettingsChangedListener(ChangeListener listener) {
}
@NotNull
@Override
public String getReportText() {
@@ -114,12 +86,12 @@ public class ExporterToTextFile implements com.intellij.ide.ExporterToTextFile {
@NotNull
@Override
public String getDefaultFilePath() {
return UsageViewSettings.getInstance().EXPORT_FILE_NAME;
return UsageViewSettings.getInstance().getExportFileName();
}
@Override
public void exportedTo(String filePath) {
UsageViewSettings.getInstance().EXPORT_FILE_NAME = filePath;
UsageViewSettings.getInstance().setExportFileName(filePath);
}
@Override
@@ -1,17 +1,5 @@
/*
* 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.
* Copyright 2000-2017 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.usages.impl;
@@ -32,11 +20,11 @@ class PreviewUsageAction extends RuleAction {
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().IS_PREVIEW_USAGES;
return UsageViewSettings.getInstance().isPreviewUsages();
}
@Override
protected void setOptionValue(final boolean value) {
UsageViewSettings.getInstance().IS_PREVIEW_USAGES = value;
UsageViewSettings.getInstance().setPreviewUsages(value);
}
}
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2009 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.
* Copyright 2000-2017 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.usages.impl;
@@ -23,18 +11,17 @@ import com.intellij.usages.UsageViewSettings;
* @author cdr
*/
class SortMembersAlphabeticallyAction extends RuleAction {
SortMembersAlphabeticallyAction(UsageViewImpl usageView) {
super(usageView, UsageViewBundle.message("sort.alphabetically.action.text"), AllIcons.ObjectBrowser.Sorted);
}
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY;
return UsageViewSettings.getInstance().isSortAlphabetically();
}
@Override
protected void setOptionValue(final boolean value) {
UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY = value;
UsageViewSettings.getInstance().setSortAlphabetically(value);
}
}
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2009 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.
* Copyright 2000-2017 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.usages.impl;
@@ -60,19 +48,19 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
if (supportsNonCodeRule()) {
rules.add(new NonCodeUsageGroupingRule(project));
}
if (supportsScopesRule() && UsageViewSettings.getInstance().GROUP_BY_SCOPE) {
if (supportsScopesRule() && UsageViewSettings.getInstance().isGroupByScope()) {
rules.add(new UsageScopeGroupingRule());
}
if (UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE) {
if (UsageViewSettings.getInstance().isGroupByUsageType()) {
rules.add(new UsageTypeGroupingRule());
}
if (supportsModuleRule() && UsageViewSettings.getInstance().GROUP_BY_MODULE) {
rules.add(new ModuleGroupingRule(project, UsageViewSettings.getInstance().FLATTEN_MODULES));
if (supportsModuleRule() && UsageViewSettings.getInstance().isGroupByModule()) {
rules.add(new ModuleGroupingRule(project, UsageViewSettings.getInstance().isFlattenModules()));
}
if (UsageViewSettings.getInstance().GROUP_BY_PACKAGE) {
if (UsageViewSettings.getInstance().isGroupByPackage()) {
rules.add(DirectoryGroupingRule.getInstance(project));
}
if (UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE) {
if (UsageViewSettings.getInstance().isGroupByFileStructure()) {
FileStructureGroupRuleProvider[] providers = Extensions.getExtensions(FileStructureGroupRuleProvider.EP_NAME);
for (FileStructureGroupRuleProvider ruleProvider : providers) {
ContainerUtil.addIfNotNull(rules, ruleProvider.getUsageGroupingRule(project));
@@ -143,11 +131,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE;
return UsageViewSettings.getInstance().isGroupByUsageType();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE = value;
UsageViewSettings.getInstance().setGroupByUsageType(value);
}
}
@@ -157,11 +145,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().GROUP_BY_SCOPE;
return UsageViewSettings.getInstance().isGroupByScope();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().GROUP_BY_SCOPE = value;
UsageViewSettings.getInstance().setGroupByScope(value);
}
}
@@ -172,12 +160,12 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().GROUP_BY_MODULE;
return UsageViewSettings.getInstance().isGroupByModule();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().GROUP_BY_MODULE = value;
UsageViewSettings.getInstance().setGroupByModule(value);
}
}
@@ -188,18 +176,18 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().FLATTEN_MODULES;
return UsageViewSettings.getInstance().isFlattenModules();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().FLATTEN_MODULES = value;
UsageViewSettings.getInstance().setFlattenModules(value);
}
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(UsageViewSettings.getInstance().GROUP_BY_MODULE);
e.getPresentation().setEnabled(UsageViewSettings.getInstance().isGroupByModule());
}
}
@@ -209,11 +197,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().GROUP_BY_PACKAGE;
return UsageViewSettings.getInstance().isGroupByPackage();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().GROUP_BY_PACKAGE = value;
UsageViewSettings.getInstance().setGroupByPackage(value);
}
}
@@ -223,11 +211,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
return UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE;
return UsageViewSettings.getInstance().isGroupByFileStructure();
}
@Override
protected void setOptionValue(boolean value) {
UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE = value;
UsageViewSettings.getInstance().setGroupByFileStructure(value);
}
}
}
@@ -504,8 +504,8 @@ public class UsageViewImpl implements UsageView {
myCentralPanel.add(myPreviewSplitter, BorderLayout.CENTER);
if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
myPreviewSplitter.setProportion(UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
if (UsageViewSettings.getInstance().isPreviewUsages()) {
myPreviewSplitter.setProportion(UsageViewSettings.getInstance().getPreviewUsagesSplitterProportion());
treePane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);
final JBTabbedPane tabbedPane = new JBTabbedPane(SwingConstants.BOTTOM){
@NotNull
@@ -1268,7 +1268,7 @@ public class UsageViewImpl implements UsageView {
}
private void saveSplitterProportions() {
UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS = myPreviewSplitter.getProportion();
UsageViewSettings.getInstance().setPreviewUsagesSplitterProportion(myPreviewSplitter.getProportion());
}
@Override
@@ -1767,12 +1767,12 @@ public class UsageViewImpl implements UsageView {
private static class MyAutoScrollToSourceOptionProvider implements AutoScrollToSourceOptionProvider {
@Override
public boolean isAutoScrollMode() {
return UsageViewSettings.getInstance().IS_AUTOSCROLL_TO_SOURCE;
return UsageViewSettings.getInstance().isAutoScrollToSource();
}
@Override
public void setAutoScrollMode(boolean state) {
UsageViewSettings.getInstance().IS_AUTOSCROLL_TO_SOURCE = state;
UsageViewSettings.getInstance().setAutoScrollToSource(state);
}
}