The updated version of the toolWindow sample plugin. cidr/96.1039
authorAlexey <Alexey.Chursin@jetbrains.com>
Fri, 27 Aug 2010 12:56:36 +0000 (16:56 +0400)
committerAlexey <Alexey.Chursin@jetbrains.com>
Fri, 27 Aug 2010 13:13:35 +0000 (17:13 +0400)
samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form [deleted file]
samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java [deleted file]
samples/applicationConfigurable/src/fontConfigurable/MyButtonListener.java
samples/applicationConfigurable/src/fontConfigurable/MyExtensConfigurable.java
samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form [new file with mode: 0644]

diff --git a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form b/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form
deleted file mode 100644 (file)
index 5c0fe57..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="fontConfigurable.IDEDialog">
-  <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>
-      <xy x="48" y="54" width="436" height="297"/>
-    </constraints>
-    <properties/>
-    <border type="none"/>
-    <children>
-      <grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children/>
-      </grid>
-      <grid id="e3588" binding="name" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children>
-          <component id="b680c" class="javax.swing.JComboBox" binding="myFontSize">
-            <constraints>
-              <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties/>
-          </component>
-          <component id="cab70" class="javax.swing.JComboBox" binding="myFontCombo">
-            <constraints>
-              <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties/>
-          </component>
-          <component id="e0d0a" class="javax.swing.JLabel" binding="menuFontSettingsLabel">
-            <constraints>
-              <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <font name="Segoe UI" size="14" style="0"/>
-              <text value="Current menu font settings:"/>
-            </properties>
-          </component>
-          <component id="f84bf" class="javax.swing.JLabel">
-            <constraints>
-              <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <alignmentX value="1.0"/>
-              <text value="Font Name:"/>
-              <verifyInputWhenFocusTarget value="false"/>
-            </properties>
-          </component>
-          <component id="20945" class="javax.swing.JLabel">
-            <constraints>
-              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <alignmentX value="1.0"/>
-              <text value="Font Size:"/>
-            </properties>
-          </component>
-          <component id="a38e1" class="javax.swing.JButton" binding="buttonRestoreDefaultFont">
-            <constraints>
-              <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
-                <preferred-size width="5" height="50"/>
-                <maximum-size width="150" height="30"/>
-              </grid>
-            </constraints>
-            <properties>
-              <text value="Default Font"/>
-            </properties>
-          </component>
-          <vspacer id="de61d">
-            <constraints>
-              <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
-            </constraints>
-          </vspacer>
-        </children>
-      </grid>
-    </children>
-  </grid>
-</form>
diff --git a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java b/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java
deleted file mode 100644 (file)
index 1245217..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-package fontConfigurable;
-
-import com.intellij.ide.ui.UISettings;
-import com.intellij.util.ui.UIUtil;
-
-import javax.swing.*;
-import java.awt.event.*;
-
-public class IDEDialog extends JDialog {
-    private JPanel contentPane;
-    public JPanel name;
-    public JComboBox myFontCombo;
-    public JComboBox myFontSize;
-    public JLabel menuFontSettingsLabel;
-    public JButton buttonRestoreDefaultFont;
-
-
-    public IDEDialog() {
-        setContentPane(contentPane);
-        setModal(true);
-        UISettings settings = UISettings.getInstance();
-        myFontCombo.setModel(new DefaultComboBoxModel(UIUtil.getValidFontNames(false)));
-        myFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
-        myFontCombo.setSelectedItem(settings.FONT_FACE);
-        myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE));
-
-// Configure the Set Default Font myButton listener.
-
-        MyButtonListener actionListener = new MyButtonListener();
-        actionListener.myButton = buttonRestoreDefaultFont;
-        actionListener.myFontCombo = myFontCombo;
-        actionListener.myFontSize = myFontSize;
-        buttonRestoreDefaultFont.addActionListener(actionListener);
-
-
-// call onCancel() when cross is clicked
-        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
-        addWindowListener(new WindowAdapter() {
-            public void windowClosing(WindowEvent e) {
-                onCancel();
-            }
-        });
-
-// call onCancel() on ESCAPE
-        contentPane.registerKeyboardAction(new ActionListener() {
-            public void actionPerformed(ActionEvent e) {
-                onCancel();
-            }
-        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
-    }
-
-    private void onOK() {
-// add your code here
-
-
-        dispose();
-    }
-
-
-    private void onCancel() {
-// add your code here if necessary
-        dispose();
-    }
-
-
-}
index d37220aa01e404bf6e81b5f6660fba07c0133a83..87e4a624edb0786674b6f6b4f84a8625f999e690 100644 (file)
@@ -16,8 +16,7 @@ import java.awt.event.ActionListener;
 public class MyButtonListener implements ActionListener {
 
 
-    public JButton myButton;
-    public JComboBox myFontCombo;
+    public JComboBox myFontName;
     public JComboBox myFontSize;
 
 
@@ -28,7 +27,7 @@ public class MyButtonListener implements ActionListener {
         // Restore default font
         settings.FONT_FACE = "Segoe UI";
         settings.FONT_SIZE = 12;
-        myFontCombo.setSelectedItem(settings.FONT_FACE);
+        myFontName.setSelectedItem(settings.FONT_FACE);
         myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE));
         settings.fireUISettingsChanged();
         lafManager.updateUI();
index f53725e2be768c7bcdff9bccc093f7f55e650cbe..2d9b48277924641bde19dc6f844bcfc8db68e54f 100644 (file)
@@ -4,6 +4,7 @@ package fontConfigurable;
 import com.intellij.ide.ui.LafManager;
 import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.options.Configurable;
+import com.intellij.util.ui.UIUtil;
 
 
 import javax.swing.*;
@@ -16,7 +17,10 @@ import javax.swing.*;
  */
 public class MyExtensConfigurable implements Configurable {
     private JComponent myComponent;
-    private IDEDialog myDialog;
+    private JComboBox myFontName;
+    private JComboBox myFontSize;
+    private JButton MyDefaultFontButton;
+    private JPanel myPanel;
 
     public String getDisplayName() {
         return "Menu Font";
@@ -29,8 +33,20 @@ public class MyExtensConfigurable implements Configurable {
     }
 
     public JComponent createComponent() {
-        myDialog = new IDEDialog();
-        myComponent = (JComponent) myDialog.getComponent(0);
+        // Add listener to the Default Font button
+        MyButtonListener actionListener = new MyButtonListener();
+        actionListener.myFontName = myFontName;
+        actionListener.myFontSize = myFontSize;
+        MyDefaultFontButton.addActionListener(actionListener);
+        // Define a set of possible values for combo boxes.
+        UISettings settings = UISettings.getInstance();
+        myFontName.setModel(new DefaultComboBoxModel(UIUtil.getValidFontNames(false)));
+        myFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
+        myFontName.setSelectedItem(settings.FONT_FACE);
+        myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE));
+
+
+        myComponent = (JComponent) myPanel;
         return myComponent;
 
     }
@@ -43,8 +59,8 @@ public class MyExtensConfigurable implements Configurable {
     public void apply() {
         UISettings settings = UISettings.getInstance();
         LafManager lafManager = LafManager.getInstance();
-        String _fontFace = (String) myDialog.myFontCombo.getSelectedItem();
-        String _fontSize_STR = (String) myDialog.myFontSize.getSelectedItem();
+        String _fontFace = (String) myFontName.getSelectedItem();
+        String _fontSize_STR = (String) myFontSize.getSelectedItem();
         int _fontSize = Integer.parseInt(_fontSize_STR);
 
         if (_fontSize != settings.FONT_SIZE || !settings.FONT_FACE.equals(_fontFace)) {
@@ -68,4 +84,5 @@ public class MyExtensConfigurable implements Configurable {
 
     }
 
+
 }
diff --git a/samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form b/samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form
new file mode 100644 (file)
index 0000000..12f0f51
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="fontConfigurable.MyExtensConfigurable">
+  <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+    <margin top="0" left="0" bottom="0" right="0"/>
+    <constraints>
+      <xy x="20" y="20" width="500" height="400"/>
+    </constraints>
+    <properties/>
+    <border type="none"/>
+    <children>
+      <component id="574ae" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <font name="Segoe UI" size="14"/>
+          <text value="Current menu font settings:"/>
+        </properties>
+      </component>
+      <component id="caf6b" class="javax.swing.JComboBox" binding="myFontName">
+        <constraints>
+          <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+      </component>
+      <component id="cc83d" class="javax.swing.JComboBox" binding="myFontSize">
+        <constraints>
+          <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+      </component>
+      <component id="d75e2" class="javax.swing.JButton" binding="MyDefaultFontButton">
+        <constraints>
+          <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
+            <maximum-size width="150" height="30"/>
+          </grid>
+        </constraints>
+        <properties>
+          <text value="Default Font"/>
+        </properties>
+      </component>
+      <vspacer id="e99c">
+        <constraints>
+          <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </vspacer>
+      <component id="20f5e" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="1" 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>
+        <properties>
+          <text value="Font name:"/>
+        </properties>
+      </component>
+      <component id="defdb" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="2" 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>
+        <properties>
+          <text value="Font size:"/>
+        </properties>
+      </component>
+    </children>
+  </grid>
+</form>