From 89c331076ba0483a96ba77d3450417d102131c28 Mon Sep 17 00:00:00 2001 From: breandan Date: Wed, 2 Dec 2015 01:07:44 -0500 Subject: [PATCH] Migrate tool window sample, fixes IJSDK-103 Migrate "Creation of Tool Windows" (https://confluence.jetbrains.com/display/IDEADEV/Creation+of+Tool+Windows) and associated code sample (http://git.jetbrains.org/?p=idea/community.git;a=commit;h=cca55289efa57e969f90c12a064dde3f388adaa1) to the SDK docs. --- tool_window/.idea/compiler.xml | 23 + .../.idea/copyright/profiles_settings.xml | 3 + tool_window/.idea/encodings.xml | 6 + .../inspectionProfiles/Project_Default.xml | 11 + .../inspectionProfiles/profiles_settings.xml | 7 + tool_window/.idea/misc.xml | 82 ++ tool_window/.idea/modules.xml | 8 + tool_window/.idea/uiDesigner.xml | 124 +++ tool_window/.idea/workspace.xml | 811 ++++++++++++++++++ tool_window/resources/META-INF/plugin.xml | 33 + .../src/myToolWindow/MyToolWindowFactory.java | 79 ++ tool_window/tool_window.iml | 15 + 12 files changed, 1202 insertions(+) create mode 100644 tool_window/.idea/compiler.xml create mode 100644 tool_window/.idea/copyright/profiles_settings.xml create mode 100644 tool_window/.idea/encodings.xml create mode 100644 tool_window/.idea/inspectionProfiles/Project_Default.xml create mode 100644 tool_window/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 tool_window/.idea/misc.xml create mode 100644 tool_window/.idea/modules.xml create mode 100644 tool_window/.idea/uiDesigner.xml create mode 100644 tool_window/.idea/workspace.xml create mode 100644 tool_window/resources/META-INF/plugin.xml create mode 100644 tool_window/src/myToolWindow/MyToolWindowFactory.java create mode 100644 tool_window/tool_window.iml diff --git a/tool_window/.idea/compiler.xml b/tool_window/.idea/compiler.xml new file mode 100644 index 000000000..a85231498 --- /dev/null +++ b/tool_window/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/tool_window/.idea/copyright/profiles_settings.xml b/tool_window/.idea/copyright/profiles_settings.xml new file mode 100644 index 000000000..e7bedf337 --- /dev/null +++ b/tool_window/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tool_window/.idea/encodings.xml b/tool_window/.idea/encodings.xml new file mode 100644 index 000000000..97626ba45 --- /dev/null +++ b/tool_window/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tool_window/.idea/inspectionProfiles/Project_Default.xml b/tool_window/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..04a92ab1d --- /dev/null +++ b/tool_window/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/tool_window/.idea/inspectionProfiles/profiles_settings.xml b/tool_window/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..3b312839b --- /dev/null +++ b/tool_window/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/tool_window/.idea/misc.xml b/tool_window/.idea/misc.xml new file mode 100644 index 000000000..1d712c0fe --- /dev/null +++ b/tool_window/.idea/misc.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + sass-stdlib + + + + + + + + 1.8 + + + + + + + + 1.6 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool_window/.idea/modules.xml b/tool_window/.idea/modules.xml new file mode 100644 index 000000000..3fa641aa0 --- /dev/null +++ b/tool_window/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tool_window/.idea/uiDesigner.xml b/tool_window/.idea/uiDesigner.xml new file mode 100644 index 000000000..e96534fb2 --- /dev/null +++ b/tool_window/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool_window/.idea/workspace.xml b/tool_window/.idea/workspace.xml new file mode 100644 index 000000000..2bc4f6746 --- /dev/null +++ b/tool_window/.idea/workspace.xml @@ -0,0 +1,811 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1449033553755 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool_window/resources/META-INF/plugin.xml b/tool_window/resources/META-INF/plugin.xml new file mode 100644 index 000000000..332a2a997 --- /dev/null +++ b/tool_window/resources/META-INF/plugin.xml @@ -0,0 +1,33 @@ + + org.jetbrains.plugins.sample.ToolWindow + Tool Window + This sample plugin illustrates how to create your custom tool window. + 2.0 + YourCompany + + + most HTML tags may be used + ]]> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool_window/src/myToolWindow/MyToolWindowFactory.java b/tool_window/src/myToolWindow/MyToolWindowFactory.java new file mode 100644 index 000000000..1082183c6 --- /dev/null +++ b/tool_window/src/myToolWindow/MyToolWindowFactory.java @@ -0,0 +1,79 @@ +package myToolWindow; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.ToolWindow; +import com.intellij.openapi.wm.ToolWindowFactory; +import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentFactory; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Calendar; + +/** + * Created by IntelliJ IDEA. + * User: Alexey.Chursin + * Date: Aug 25, 2010 + * Time: 2:09:00 PM + */ +public class MyToolWindowFactory implements ToolWindowFactory { + + private JButton refreshToolWindowButton; + private JButton hideToolWindowButton; + private JLabel currentDate; + private JLabel currentTime; + private JLabel timeZone; + private JPanel myToolWindowContent; + private ToolWindow myToolWindow; + + + public MyToolWindowFactory() { + hideToolWindowButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + myToolWindow.hide(null); + } + }); + refreshToolWindowButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + MyToolWindowFactory.this.currentDateTime(); + } + }); + } + + // Create the tool window content. + public void createToolWindowContent(Project project, ToolWindow toolWindow) { + myToolWindow = toolWindow; + this.currentDateTime(); + ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); + Content content = contentFactory.createContent(myToolWindowContent, "", false); + toolWindow.getContentManager().addContent(content); + + } + + public void currentDateTime() { + // Get current date and time + Calendar instance = Calendar.getInstance(); + currentDate.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/" + + String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" + String.valueOf(instance.get(Calendar.YEAR))); + currentDate.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Calendar-icon.png"))); + int min = instance.get(Calendar.MINUTE); + String strMin; + if (min < 10) { + strMin = "0" + String.valueOf(min); + } else { + strMin = String.valueOf(min); + } + currentTime.setText(instance.get(Calendar.HOUR_OF_DAY) + ":" + strMin); + currentTime.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-icon.png"))); + // Get time zone + long gmt_Offset = instance.get(Calendar.ZONE_OFFSET); // offset from GMT in milliseconds + String str_gmt_Offset = String.valueOf(gmt_Offset / 3600000); + str_gmt_Offset = (gmt_Offset > 0) ? "GMT + " + str_gmt_Offset : "GMT - " + str_gmt_Offset; + timeZone.setText(str_gmt_Offset); + timeZone.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-zone-icon.png"))); + + + } + +} diff --git a/tool_window/tool_window.iml b/tool_window/tool_window.iml new file mode 100644 index 000000000..dd6e2bd1a --- /dev/null +++ b/tool_window/tool_window.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file