enable telemetry via registry

remove unnecessary interfaces, utility and form
This commit is contained in:
Bas Leijdekkers
2010-12-16 17:00:09 +01:00
parent cdb78dded3
commit 4111cddd28
15 changed files with 200 additions and 279 deletions
@@ -108,4 +108,6 @@ frameworks.download.libraries.server.url=http://pluginsrepo-test:8080
caches.indexerThreadsCount=-1
vcs.show.history.numbers=true
navbar.updateMergeTime=250
navbar.userActivityMergeTime=500
navbar.userActivityMergeTime=500
inspectionGadgets.telemetry.enabled=false
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2008 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.ui.DocumentAdapter;
@@ -46,9 +47,6 @@ public abstract class BaseInspection extends BaseJavaLocalInspectionTool {
private static final Logger LOG = Logger.getInstance("#com.siyeh.ig.BaseInspection");
private InspectionRunListener listener = null;
@NonNls private static final String INSPECTION_GADGETS_COMPONENT_NAME =
"InspectionGadgets";
@NonNls private static final String INSPECTION = "Inspection";
@NonNls private static final Map<String, String> packageGroupDisplayNameMap = new HashMap<String, String>();
static {
@@ -93,7 +91,9 @@ public abstract class BaseInspection extends BaseJavaLocalInspectionTool {
}
private String m_shortName = null;
private long timeStamp = -1;
private long timestamp = -1L;
private InspectionGadgetsPlugin inspectionGadgetsPlugin;
@Override @NotNull
public final String getShortName() {
@@ -238,39 +238,41 @@ public abstract class BaseInspection extends BaseJavaLocalInspectionTool {
}
}
private void initializeTelemetryIfNecessary() {
if (InspectionGadgetsPlugin.TELEMETRY_ENABLED && listener == null) {
final Application application = ApplicationManager.getApplication();
final InspectionGadgetsPlugin plugin = (InspectionGadgetsPlugin)
application.getComponent(INSPECTION_GADGETS_COMPONENT_NAME);
listener = plugin.getTelemetry();
@Override
public void inspectionStarted(LocalInspectionToolSession session) {
super.inspectionStarted(session);
if (inspectionGadgetsPlugin.isTelemetryEnabled()) {
timestamp = System.currentTimeMillis();
}
}
@Override
public void inspectionStarted(LocalInspectionToolSession session) {
super.inspectionStarted(session);
if (InspectionGadgetsPlugin.TELEMETRY_ENABLED) {
if (timeStamp > 0) {
System.out.println("start reported without corresponding finish");
}
initializeTelemetryIfNecessary();
timeStamp = System.currentTimeMillis();
@Override
public void inspectionFinished(LocalInspectionToolSession session,
ProblemsHolder problemsHolder) {
super.inspectionFinished(session, problemsHolder);
if (inspectionGadgetsPlugin.isTelemetryEnabled()) {
if (timestamp < 0L) {
LOG.warn("finish reported without corresponding start");
return;
}
final long end = System.currentTimeMillis();
final String displayName = getDisplayName();
inspectionGadgetsPlugin.getTelemetry().reportRun(displayName, end - timestamp);
timestamp = -1L;
}
}
}
@Override
public void inspectionFinished(LocalInspectionToolSession session, ProblemsHolder problemsHolder) {
super.inspectionFinished(session, problemsHolder);
if (InspectionGadgetsPlugin.TELEMETRY_ENABLED) {
if (timeStamp < 0) {
System.out.println("finish reported without corresponding start");
return;
}
final long end = System.currentTimeMillis();
final String displayName = getDisplayName();
listener.reportRun(displayName, end - timeStamp);
timeStamp = -1;
@Override
public void projectOpened(Project project) {
super.projectOpened(project);
final Application application = ApplicationManager.getApplication();
inspectionGadgetsPlugin = (InspectionGadgetsPlugin)
application.getComponent("InspectionGadgets");
}
@Override
public void projectClosed(Project project) {
super.projectClosed(project);
inspectionGadgetsPlugin = null;
}
}
}
@@ -19,7 +19,13 @@ import com.intellij.codeInspection.GlobalInspectionTool;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionToolProvider;
import com.intellij.codeInspection.booleanIsAlwaysInverted.BooleanMethodIsAlwaysInvertedInspection;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.registry.RegistryValue;
import com.intellij.openapi.util.registry.RegistryValueListener;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.abstraction.*;
import com.siyeh.ig.assignment.*;
@@ -70,6 +76,7 @@ import com.siyeh.ig.security.*;
import com.siyeh.ig.serialization.*;
import com.siyeh.ig.style.*;
import com.siyeh.ig.telemetry.InspectionGadgetsTelemetry;
import com.siyeh.ig.telemetry.TelemetryToolWindow;
import com.siyeh.ig.threading.*;
import com.siyeh.ig.visibility.*;
import org.jetbrains.annotations.NonNls;
@@ -85,16 +92,16 @@ import java.util.*;
public class InspectionGadgetsPlugin implements ApplicationComponent,
InspectionToolProvider {
private final List<Class<? extends InspectionProfileEntry>> m_inspectionClasses =
new ArrayList();
@NonNls private static final String DESCRIPTION_DIRECTORY_NAME =
"src/inspectionDescriptions/";
private final InspectionGadgetsTelemetry telemetry =
new InspectionGadgetsTelemetry();
public static final boolean TELEMETRY_ENABLED = false;
@NonNls private static final String INSPECTION = "Inspection";
@NonNls private static final String BUILD_FIXES_ONLY_ON_THE_FLY = "(r)";
private final List<Class<? extends InspectionProfileEntry>> m_inspectionClasses =
new ArrayList();
private volatile InspectionGadgetsTelemetry telemetry = null;
public volatile boolean telemetryEnabled = true;
public static void main(String[] args) throws FileNotFoundException {
final PrintStream out;
if (args.length == 0) {
@@ -337,6 +344,34 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
}
public void initComponent() {
final RegistryValue registryValue =
Registry.get("inspectionGadgets.telemetry.enabled");
telemetryEnabled = registryValue.asBoolean();
if (telemetryEnabled) {
telemetry = new InspectionGadgetsTelemetry();
}
registryValue.addListener(new RegistryValueListener.Adapter() {
@Override
public void afterValueChanged(RegistryValue registryValue) {
telemetryEnabled = registryValue.asBoolean();
final ProjectManager projectManager = ProjectManager.getInstance();
final Project[] openProjects = projectManager.getOpenProjects();
if (telemetryEnabled) {
telemetry = new InspectionGadgetsTelemetry();
for (Project project : openProjects) {
final TelemetryToolWindow toolWindow =
new TelemetryToolWindow(telemetry);
toolWindow.register(project);
}
} else {
for (Project project : openProjects) {
TelemetryToolWindow.unregister(project);
}
telemetry = null;
}
}
}, ApplicationManager.getApplication());
}
private void registerResourceManagementInspections() {
@@ -1080,8 +1115,8 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
public void disposeComponent() {
}
public static boolean isTelemetryEnabled() {
return TELEMETRY_ENABLED;
public boolean isTelemetryEnabled() {
return telemetryEnabled;
}
public InspectionGadgetsTelemetry getTelemetry() {
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,11 @@
*/
package com.siyeh.ig;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import com.siyeh.ig.telemetry.TelemetryToolWindow;
import com.siyeh.ig.telemetry.TelemetryToolWindowImpl;
public class InspectionGadgetsProjectComponent implements ProjectComponent{
@@ -27,21 +28,24 @@ public class InspectionGadgetsProjectComponent implements ProjectComponent{
private final Project project;
public InspectionGadgetsProjectComponent(Project project){
super();
this.project = project;
}
public void projectOpened(){
telemetryEnabled = InspectionGadgetsPlugin.isTelemetryEnabled();
final Application application = ApplicationManager.getApplication();
final InspectionGadgetsPlugin inspectionGadgetsPlugin =
(InspectionGadgetsPlugin)
application.getComponent("InspectionGadgets");
telemetryEnabled = inspectionGadgetsPlugin.isTelemetryEnabled();
if(telemetryEnabled){
toolWindow = new TelemetryToolWindowImpl();
toolWindow = new TelemetryToolWindow(inspectionGadgetsPlugin.getTelemetry());
toolWindow.register(project);
}
}
public void projectClosed(){
if(telemetryEnabled && toolWindow != null){
toolWindow.unregister(project);
TelemetryToolWindow.unregister(project);
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2003-2005 Dave Griffith
*
* 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.siyeh.ig.telemetry;
import org.jetbrains.annotations.NonNls;
import javax.swing.ImageIcon;
import java.net.URL;
class IconHelper{
private IconHelper(){
super();
}
public static ImageIcon getIcon(@NonNls String location){
final Class<IconHelper> thisClass = IconHelper.class;
final URL resource = thisClass.getResource(location);
return new ImageIcon(resource);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
*/
package com.siyeh.ig.telemetry;
import com.siyeh.ig.InspectionRunListener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -34,17 +32,17 @@ public class InspectionGadgetsTelemetry implements InspectionRunListener {
synchronized (lock) {
final Integer count = totalRunCount.get(inspectionID);
if (count == null) {
totalRunCount.put(inspectionID, 1);
totalRunCount.put(inspectionID, Integer.valueOf(1));
} else {
totalRunCount.put(inspectionID,
count + 1);
Integer.valueOf(count.intValue() + 1));
}
final Long runTimeSoFar = totalRunTime.get(inspectionID);
if (runTimeSoFar == null) {
totalRunTime.put(inspectionID, runTime);
totalRunTime.put(inspectionID, Long.valueOf(runTime));
} else {
totalRunTime.put(inspectionID,
runTimeSoFar + runTime);
Long.valueOf(runTimeSoFar.longValue() + runTime));
}
}
}
@@ -62,7 +60,7 @@ public class InspectionGadgetsTelemetry implements InspectionRunListener {
if (runTime == null) {
return 0L;
}
return runTime;
return runTime.longValue();
}
}
@@ -72,7 +70,7 @@ public class InspectionGadgetsTelemetry implements InspectionRunListener {
if (runCount == null) {
return 0;
}
return runCount;
return runCount.intValue();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.ig;
package com.siyeh.ig.telemetry;
public interface InspectionRunListener{
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,28 +18,25 @@ package com.siyeh.ig.telemetry;
import com.intellij.CommonBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.util.IconLoader;
import com.siyeh.InspectionGadgetsBundle;
import javax.swing.Icon;
class ResetTelemetryAction extends AnAction{
private final InspectionGadgetsTelemetry telemetry;
private final TelemetryDisplay display;
private static final Icon resetIcon =
IconHelper.getIcon("/actions/reset.png");
ResetTelemetryAction(InspectionGadgetsTelemetry telemetry,
TelemetryDisplay display){
super(CommonBundle.message("button.reset"),
InspectionGadgetsBundle.message(
"action.reset.telemetry.description"),
resetIcon);
IconLoader.getIcon("/actions/reset.png"));
this.telemetry = telemetry;
this.display = display;
}
@Override
public void actionPerformed(AnActionEvent event){
telemetry.reset();
display.update();
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,32 @@
*/
package com.siyeh.ig.telemetry;
import javax.swing.JComponent;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.table.JBTable;
public interface TelemetryDisplay{
import javax.swing.*;
import javax.swing.table.JTableHeader;
JComponent getContentPane();
public class TelemetryDisplay {
void update();
private final JTable table;
private final JScrollPane scrollPane;
private final TableSorter model;
public TelemetryDisplay(InspectionGadgetsTelemetry telemetry){
model = new TableSorter(new TelemetryTableModel(telemetry));
table = new JBTable(model);
final JTableHeader tableHeader = table.getTableHeader();
model.setTableHeader(tableHeader);
scrollPane = ScrollPaneFactory.createScrollPane(table);
}
public JComponent getContentPane(){
return scrollPane;
}
public void update(){
table.setModel(model);
table.repaint();
}
}
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.siyeh.ig.telemetry.TelemetryDisplayImpl">
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="2507" binding="scrollPane">
<constraints>
<xy x="104" y="60" width="174" height="154"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d0712" class="com.intellij.ui.table.JBTable" binding="table">
<constraints/>
<properties>
<rowSelectionAllowed value="true"/>
<showVerticalLines value="false"/>
<enabled value="false"/>
</properties>
</component>
</children>
</scrollpane>
</form>
@@ -1,45 +0,0 @@
/*
* Copyright 2003-2005 Dave Griffith
*
* 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.siyeh.ig.telemetry;
import javax.swing.*;
import javax.swing.table.JTableHeader;
public class TelemetryDisplayImpl implements TelemetryDisplay{
private JTable table;
private JScrollPane scrollPane;
private final TableSorter model;
public TelemetryDisplayImpl(InspectionGadgetsTelemetry telemetry){
super();
model = new TableSorter(new TelemetryTableModel(telemetry));
table.setModel(model);
final JTableHeader tableHeader = table.getTableHeader();
model.setTableHeader(tableHeader);
}
public JComponent getContentPane(){
return scrollPane;
}
public void update(){
table.setModel(model);
table.repaint();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,16 +28,17 @@ class TelemetryTableModel extends DefaultTableModel {
private final NumberFormat format = NumberFormat.getNumberInstance();
TelemetryTableModel(InspectionGadgetsTelemetry telemetry) {
super();
this.telemetry = telemetry;
format.setMaximumFractionDigits(2);
format.setMinimumFractionDigits(2);
}
@Override
public int getColumnCount() {
return 4;
}
@Override
@Nullable
public Class getColumnClass(int column) {
switch (column) {
@@ -54,6 +55,7 @@ class TelemetryTableModel extends DefaultTableModel {
}
}
@Override
public int getRowCount() {
if (telemetry == null) {
return 0;
@@ -61,6 +63,7 @@ class TelemetryTableModel extends DefaultTableModel {
return telemetry.getInspections().length;
}
@Override
@Nullable
public Object getValueAt(int row, int column) {
if (telemetry == null) {
@@ -88,11 +91,13 @@ class TelemetryTableModel extends DefaultTableModel {
}
}
@Override
public void setValueAt(Object object, int i,
int i1) {
//don't do anything
}
@Override
@Nullable
public String getColumnName(int column) {
switch (column) {
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,66 @@
*/
package com.siyeh.ig.telemetry;
import org.jetbrains.annotations.NonNls;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.intellij.ui.content.ContentManager;
import com.siyeh.InspectionGadgetsBundle;
import org.jetbrains.annotations.NonNls;
public interface TelemetryToolWindow{
import javax.swing.*;
import java.awt.*;
@NonNls String TOOL_WINDOW_ID = "IG Telemetry";
public class TelemetryToolWindow {
void register(Project project);
@NonNls
private static final String TOOL_WINDOW_ID = "IG Telemetry";
void show();
private final JPanel contentPanel;
void close();
public TelemetryToolWindow(InspectionGadgetsTelemetry telemetry) {
final TelemetryDisplay telemetryDisplay =
new TelemetryDisplay(telemetry);
final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
toolbarGroup.add(new UpdateTelemetryViewAction(telemetryDisplay));
toolbarGroup.add(new ResetTelemetryAction(telemetry, telemetryDisplay));
final ActionManager actionManager = ActionManager.getInstance();
final ActionToolbar toolbar =
actionManager.createActionToolbar(TOOL_WINDOW_ID,
toolbarGroup, true);
contentPanel = new JPanel(new BorderLayout());
contentPanel.setBackground(Color.gray);
final JComponent toolbarComponent = toolbar.getComponent();
contentPanel.add(toolbarComponent, BorderLayout.NORTH);
final JComponent displayContentPane = telemetryDisplay.getContentPane();
contentPanel.add(displayContentPane, BorderLayout.CENTER);
}
void unregister(Project project);
}
public void register(Project project){
final ToolWindowManager toolWindowManager =
ToolWindowManager.getInstance(project);
final ToolWindow toolWindow =
toolWindowManager.registerToolWindow(TOOL_WINDOW_ID, false,
ToolWindowAnchor.LEFT);
toolWindow.setTitle(InspectionGadgetsBundle.message(
"telemetry.toolwindow.title"));
final ContentManager contentManager = toolWindow.getContentManager();
final ContentFactory contentFactory = contentManager.getFactory();
final Content content = contentFactory.createContent(contentPanel,
"", true);
contentManager.addContent(content);
toolWindow.setAvailable(true, null);
}
public static void unregister(Project project){
final ToolWindowManager toolWindowManager =
ToolWindowManager.getInstance(project);
toolWindowManager.unregisterToolWindow(TOOL_WINDOW_ID);
}
}
@@ -1,89 +0,0 @@
/*
* Copyright 2003-2005 Dave Griffith
*
* 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.siyeh.ig.telemetry;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import com.siyeh.ig.InspectionGadgetsPlugin;
import com.siyeh.InspectionGadgetsBundle;
import javax.swing.*;
import java.awt.*;
public class TelemetryToolWindowImpl implements TelemetryToolWindow{
private final TelemetryDisplay telemetryDisplay;
private final JPanel myContentPanel;
private ToolWindow myToolWindow = null;
public TelemetryToolWindowImpl() {
super();
final Application application = ApplicationManager.getApplication();
final InspectionGadgetsPlugin plugin =
application.getComponent(InspectionGadgetsPlugin.class);
final InspectionGadgetsTelemetry telemetry = plugin.getTelemetry();
telemetryDisplay = new TelemetryDisplayImpl(telemetry);
final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
toolbarGroup.add(new UpdateTelemetryViewAction(telemetryDisplay));
toolbarGroup.add(new ResetTelemetryAction(telemetry, telemetryDisplay));
final ActionManager actionManager = ActionManager.getInstance();
final ActionToolbar toolbar =
actionManager.createActionToolbar(TOOL_WINDOW_ID,
toolbarGroup, true);
myContentPanel = new JPanel(new BorderLayout());
myContentPanel.setBackground(Color.gray);
final JComponent toolbarComponent = toolbar.getComponent();
myContentPanel.add(toolbarComponent, BorderLayout.NORTH);
final JComponent displayContentPane = telemetryDisplay.getContentPane();
myContentPanel.add(displayContentPane, BorderLayout.CENTER);
}
public void register(Project project){
final ToolWindowManager toolWindowManager =
ToolWindowManager.getInstance(project);
myToolWindow =
toolWindowManager.registerToolWindow(TOOL_WINDOW_ID,
myContentPanel,
ToolWindowAnchor.LEFT);
myToolWindow.setTitle(InspectionGadgetsBundle.message(
"telemetry.toolwindow.title"));
myToolWindow.setAvailable(true, null);
}
public void show(){
myToolWindow.setAvailable(true, null);
telemetryDisplay.update();
myToolWindow.show(null);
}
public void close(){
myToolWindow.hide(null);
myToolWindow.setAvailable(false, null);
}
public void unregister(Project project){
final ToolWindowManager toolWindowManager =
ToolWindowManager.getInstance(project);
toolWindowManager.unregisterToolWindow(TOOL_WINDOW_ID);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005 Dave Griffith
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,27 +15,25 @@
*/
package com.siyeh.ig.telemetry;
import com.intellij.CommonBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.CommonBundle;
import com.intellij.openapi.util.IconLoader;
import com.siyeh.InspectionGadgetsBundle;
import javax.swing.*;
class UpdateTelemetryViewAction extends AnAction{
private final TelemetryDisplay telemetryDisplay;
private static final Icon refreshIcon =
IconHelper.getIcon("/actions/sync.png");
UpdateTelemetryViewAction(TelemetryDisplay telemetryDisplay){
super(CommonBundle.message("action.refresh"),
InspectionGadgetsBundle.message(
"action.telemetry.refresh.description"), refreshIcon);
"action.telemetry.refresh.description"),
IconLoader.getIcon("/actions/sync.png"));
this.telemetryDisplay = telemetryDisplay;
}
@Override
public void actionPerformed(AnActionEvent event){
telemetryDisplay.update();
}