The updated version of the toolWindow sample plugin.
authorAlexey <Alexey.Chursin@jetbrains.com>
Thu, 26 Aug 2010 09:35:56 +0000 (13:35 +0400)
committerAlexey <Alexey.Chursin@jetbrains.com>
Thu, 26 Aug 2010 09:40:09 +0000 (13:40 +0400)
samples/toolWindow/src/META-INF/plugin.xml
samples/toolWindow/src/com/intellij/openapi/toolWindow/Calendar-icon.png [moved from samples/toolWindow/src/com/intellij/openapi/samples/Calendar-icon.png with 100% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/MyToolWindowFactory.java [moved from samples/toolWindow/src/com/intellij/openapi/samples/MyToolWindowFactory.java with 50% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/Time-icon.png [moved from samples/toolWindow/src/com/intellij/openapi/samples/Time-icon.png with 100% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/Time-zone-icon.png [moved from samples/toolWindow/src/com/intellij/openapi/samples/Time-zone-icon.png with 100% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/ToolDialog.form [moved from samples/toolWindow/src/com/intellij/openapi/samples/ToolDialog.form with 96% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/ToolDialog.java [moved from samples/toolWindow/src/com/intellij/openapi/samples/ToolDialog.java with 52% similarity]
samples/toolWindow/src/com/intellij/openapi/toolWindow/plus.png [moved from samples/toolWindow/src/com/intellij/openapi/samples/plus.png with 100% similarity]

index 6d2aceb4b87bfa4fd938a47d1a466cebc9426cb3..f03aff8fb4cefd47471cac606c3696cd04a8cce7 100644 (file)
@@ -21,7 +21,7 @@
 
   <extensions defaultExtensionNs="com.intellij">
     <!-- Add your extensions here -->                       
-     <toolWindow id="Sample Calendar"   icon="/com/intellij/openapi/samples/plus.png" anchor="right" factoryClass="com.intellij.openapi.samples.MyToolWindowFactory"   >
+     <toolWindow id="Sample Calendar"   icon="/com/intellij/openapi/toolWindow/plus.png" anchor="right" factoryClass="com.intellij.openapi.toolWindow.MyToolWindowFactory"   >
          
      </toolWindow>
   </extensions>
similarity index 50%
rename from samples/toolWindow/src/com/intellij/openapi/samples/MyToolWindowFactory.java
rename to samples/toolWindow/src/com/intellij/openapi/toolWindow/MyToolWindowFactory.java
index f3bef294c785f9ad2eae366d5da915b9b20b559f..2ed394c574e328b264e2a19e2ff9c9a8e0939154 100644 (file)
@@ -1,15 +1,12 @@
-package com.intellij.openapi.samples;
+package com.intellij.openapi.toolWindow;
 
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.wm.ToolWindow;
-import com.intellij.openapi.wm.ToolWindowEP;
 import com.intellij.openapi.wm.ToolWindowFactory;
 import com.intellij.ui.content.Content;
 import com.intellij.ui.content.ContentFactory;
-import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
-import java.awt.*;
 
 /**
  * Created by IntelliJ IDEA.
@@ -21,14 +18,14 @@ public class MyToolWindowFactory implements ToolWindowFactory {
 
     // Creates the tool window content.
     public void createToolWindowContent(Project project, ToolWindow toolWindow) {
-     ToolDialog myDialog = new ToolDialog();
-     myDialog.toolWin = toolWindow;
-     myDialog.currentDateTime();     
-     JPanel myContentPanel = myDialog.getPanel();
-     ContentFactory contentFactory =  ContentFactory.SERVICE.getInstance();
-     Content content = contentFactory.createContent(myContentPanel, "", false);
-     toolWindow.getContentManager().addContent(content);
-        
+        ToolDialog myDialog = new ToolDialog();
+        myDialog.toolWin = toolWindow;
+        myDialog.currentDateTime();
+        JPanel myContentPanel = myDialog.getPanel();
+        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
+        Content content = contentFactory.createContent(myContentPanel, "", false);
+        toolWindow.getContentManager().addContent(content);
+
     }
-    
+
 }
similarity index 96%
rename from samples/toolWindow/src/com/intellij/openapi/samples/ToolDialog.form
rename to samples/toolWindow/src/com/intellij/openapi/toolWindow/ToolDialog.form
index 9c708ef8742048424b6bd927a385f77f62056bfa..a338eb20f24e0edbedfb05384c7b71363fe46e48 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.samples.ToolDialog">
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.toolWindow.ToolDialog">
   <grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="10" left="10" bottom="10" right="10"/>
     <constraints>
@@ -52,7 +52,7 @@
         <properties/>
         <border type="none"/>
         <children>
-          <component id="d6483" class="javax.swing.JLabel" binding="Time22">
+          <component id="d6483" class="javax.swing.JLabel" binding="currentTime">
             <constraints>
               <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
@@ -60,7 +60,7 @@
               <text value="Time:"/>
             </properties>
           </component>
-          <component id="e7494" class="javax.swing.JLabel" binding="Date22">
+          <component id="e7494" class="javax.swing.JLabel" binding="cirrentDate">
             <constraints>
               <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
               <text value="Date: "/>
             </properties>
           </component>
-          <component id="575f3" class="javax.swing.JLabel" binding="TimeZone">
+          <component id="575f3" class="javax.swing.JLabel" binding="timeZone">
             <constraints>
               <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <text value=""/>
+              <text value="Time zone"/>
             </properties>
           </component>
         </children>
similarity index 52%
rename from samples/toolWindow/src/com/intellij/openapi/samples/ToolDialog.java
rename to samples/toolWindow/src/com/intellij/openapi/toolWindow/ToolDialog.java
index 10292664f378a4dfa4f0cf2658a27d6021858086..e7a9bcb0cb8fc55d1d9598f13cf0c0264d285d0d 100644 (file)
@@ -1,4 +1,4 @@
-package com.intellij.openapi.samples;
+package com.intellij.openapi.toolWindow;
 
 import com.intellij.openapi.wm.ToolWindow;
 
@@ -10,12 +10,11 @@ public class ToolDialog extends JDialog {
     private JPanel contentPane;
     private JButton buttonRefresh;
     private JButton buttonHide;
-    
-    private JLabel Date22;
-    private JLabel Time22;
-    private JLabel TimeZone;
+
+    private JLabel cirrentDate;
+    private JLabel currentTime;
+    private JLabel timeZone;
     public ToolWindow toolWin;
-    
 
 
     public ToolDialog() {
@@ -24,9 +23,6 @@ public class ToolDialog extends JDialog {
         getRootPane().setDefaultButton(buttonRefresh);
 
 
-
-        
-
         buttonRefresh.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 onOK();
@@ -63,7 +59,7 @@ public class ToolDialog extends JDialog {
 
     private void onCancel() {
 // Hide tool window.
-         toolWin.hide(null);
+        toolWin.hide(null);
         dispose();
     }
 
@@ -71,28 +67,28 @@ public class ToolDialog extends JDialog {
         return contentPane;
     }
 
-    public void currentDateTime()
-    {
-     // Get current date and time
-       Calendar instance = Calendar.getInstance();
-       Date22.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/"
-       + String.valueOf(instance.get(Calendar.MONTH)+1) + "/" +  String.valueOf(instance.get(Calendar.YEAR)) );
-       Date22.setIcon(new ImageIcon(getClass().getResource("/com/intellij/openapi/samples/Calendar-icon.png")));
-       int min = instance.get(Calendar.MINUTE);
-       String strMin;
-       if ( min < 10) {strMin = "0" + String.valueOf(min);}
-         else { strMin = String.valueOf(min);}
-       Time22.setText(instance.get(Calendar.HOUR_OF_DAY) + ":" + strMin);
-       Time22.setIcon(new ImageIcon(getClass().getResource("/com/intellij/openapi/samples/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("/com/intellij/openapi/samples/Time-zone-icon.png"))); 
-
-
-
-        
+    public void currentDateTime() {
+        // Get current date and time
+        Calendar instance = Calendar.getInstance();
+        cirrentDate.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/"
+                + String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" + String.valueOf(instance.get(Calendar.YEAR)));
+        cirrentDate.setIcon(new ImageIcon(getClass().getResource("/com/intellij/openapi/toolWindow/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("/com/intellij/openapi/toolWindow/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("/com/intellij/openapi/toolWindow/Time-zone-icon.png")));
+
+
     }
 }