blob: d410a66b7cbfeefb2d61e568dffc4da8f978526c [file] [log] [blame]
/*
* 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.internal.statistic;
import com.intellij.ide.GeneralSettings;
import com.intellij.ide.ui.UISettings;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.project.Project;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.HashSet;
import java.util.Set;
/**
* @author Konstantin Bulenkov
*/
public class UiInfoUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages(@Nullable Project project) throws CollectUsagesException {
final HashSet<UsageDescriptor> set = new HashSet<UsageDescriptor>();
add(set, "Nav Bar visible", navbar() ? 1 : 0);
add(set, "Nav Bar floating", navbar() ? 0 : 1);
add(set, "Toolbar visible", toolbar() ? 1 : 0);
add(set, "Toolbar hidden", toolbar() ? 0 : 1);
add(set, "Toolbar + NavBar", !toolbar() && navbar() ? 1 : 0);
add(set, "Toolbar and NavBar hidden", !toolbar() && !navbar() ? 1 : 0);
add(set, "Status bar visible", status() ? 1 : 0);
add(set, "Status bar hidden", status() ? 0 : 1);
add(set, "Tool Window buttons visible", stripes() ? 1 : 0);
add(set, "Tool Window buttons hidden", stripes() ? 0 : 1);
add(set, "Recent Files = 15", recent() == 15 ? 1 : 0);
add(set, "Recent Files (15, 30]", 15 < recent() && recent() < 31 ? 1 : 0);
add(set, "Recent Files (30, 50]", 30 < recent() && recent() < 51 ? 1 : 0);
add(set, "Recent Files > 50", 50 < recent() ? 1 : 0);
add(set, "Block cursor", EditorSettingsExternalizable.getInstance().isBlockCursor() ? 1 : 0);
add(set, "Line Numbers", EditorSettingsExternalizable.getInstance().isLineNumbersShown() ? 1 : 0);
add(set, "Soft Wraps", EditorSettingsExternalizable.getInstance().isUseSoftWraps() ? 1 : 0);
add(set, "Tabs None", tabPlace() == 0 ? 1 : 0);
add(set, "Tabs Top", tabPlace() == SwingConstants.TOP ? 1 : 0);
add(set, "Tabs Bottom", tabPlace() == SwingConstants.BOTTOM ? 1 : 0);
add(set, "Tabs Left", tabPlace() == SwingConstants.LEFT ? 1 : 0);
add(set, "Tabs Right", tabPlace() == SwingConstants.RIGHT ? 1 : 0);
add(set, "Retina", UIUtil.isRetina() ? 1 : 0);
add(set, "Show tips on startup", GeneralSettings.getInstance().showTipsOnStartup() ? 1 : 0);
return set;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("UI Features");
}
private static void add(HashSet<UsageDescriptor> set, String key, int value) {
set.add(new UsageDescriptor(key, value));
}
private static int tabPlace() {
return UISettings.getInstance().EDITOR_TAB_PLACEMENT;
}
private static int recent() {
return UISettings.getInstance().RECENT_FILES_LIMIT;
}
private static boolean stripes() {
return UISettings.getInstance().HIDE_TOOL_STRIPES;
}
private static boolean status() {
return UISettings.getInstance().SHOW_STATUS_BAR;
}
private static boolean toolbar() {
return UISettings.getInstance().SHOW_MAIN_TOOLBAR;
}
private static boolean navbar() {
return UISettings.getInstance().SHOW_NAVIGATION_BAR;
}
}