mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
The updated version of the applicationConfigurable sample plugin.
This commit is contained in:
@@ -22,6 +22,6 @@
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
<applicationConfigurable implementation="MyPack.MyExtensConfigurable"></applicationConfigurable>
|
||||
<applicationConfigurable implementation="fontConfigurable.MyExtensConfigurable"></applicationConfigurable>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -1,45 +0,0 @@
|
||||
package MyPack;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ButtonUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Alexey.Chursin
|
||||
* Date: Aug 7, 2010
|
||||
* Time: 9:36:45 PM
|
||||
|
||||
*/
|
||||
public class MyButtonListener implements ActionListener {
|
||||
|
||||
|
||||
public JButton button;
|
||||
public JComboBox myFontCombo;
|
||||
public JComboBox myFontSize;
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
UISettings settings = UISettings.getInstance();
|
||||
LafManager lafManager = LafManager.getInstance();
|
||||
// Restore default font
|
||||
settings.FONT_FACE="Segoe UI";
|
||||
settings.FONT_SIZE=12;
|
||||
myFontCombo.setSelectedItem(settings.FONT_FACE);
|
||||
myFontSize.setSelectedItem( String.valueOf(settings.FONT_SIZE));
|
||||
settings.fireUISettingsChanged();
|
||||
lafManager.updateUI();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MyPack.IDEdialog">
|
||||
<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>
|
||||
@@ -17,7 +17,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="e3588" binding="Name" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<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"/>
|
||||
@@ -65,7 +65,7 @@
|
||||
<text value="Font Size:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a38e1" class="javax.swing.JButton" binding="ButtonRestoreDefaultFont">
|
||||
<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"/>
|
||||
@@ -76,6 +76,11 @@
|
||||
<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>
|
||||
+13
-24
@@ -1,38 +1,36 @@
|
||||
package MyPack;
|
||||
package fontConfigurable;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class IDEdialog extends JDialog {
|
||||
public class IDEDialog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
public JPanel Name;
|
||||
public JPanel name;
|
||||
public JComboBox myFontCombo;
|
||||
public JComboBox myFontSize;
|
||||
public JLabel menuFontSettingsLabel;
|
||||
public JButton ButtonRestoreDefaultFont;
|
||||
public JButton buttonRestoreDefaultFont;
|
||||
|
||||
|
||||
|
||||
public IDEdialog() {
|
||||
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));
|
||||
myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE));
|
||||
|
||||
// Configure the Set Default Font button listener.
|
||||
// Configure the Set Default Font myButton listener.
|
||||
|
||||
MyButtonListener actionListener = new MyButtonListener();
|
||||
actionListener.button=ButtonRestoreDefaultFont;
|
||||
actionListener.myFontCombo= myFontCombo;
|
||||
actionListener.myFontSize= myFontSize;
|
||||
ButtonRestoreDefaultFont.addActionListener(actionListener);
|
||||
actionListener.myButton = buttonRestoreDefaultFont;
|
||||
actionListener.myFontCombo = myFontCombo;
|
||||
actionListener.myFontSize = myFontSize;
|
||||
buttonRestoreDefaultFont.addActionListener(actionListener);
|
||||
|
||||
|
||||
// call onCancel() when cross is clicked
|
||||
@@ -53,25 +51,16 @@ public class IDEdialog extends JDialog {
|
||||
|
||||
private void onOK() {
|
||||
// add your code here
|
||||
|
||||
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onCancel() {
|
||||
// add your code here if necessary
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
IDEdialog dialog = new IDEdialog();
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,40 @@
|
||||
package fontConfigurable;
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Alexey.Chursin
|
||||
* Date: Aug 7, 2010
|
||||
* Time: 9:36:45 PM
|
||||
*/
|
||||
public class MyButtonListener implements ActionListener {
|
||||
|
||||
|
||||
public JButton myButton;
|
||||
public JComboBox myFontCombo;
|
||||
public JComboBox myFontSize;
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
UISettings settings = UISettings.getInstance();
|
||||
LafManager lafManager = LafManager.getInstance();
|
||||
// Restore default font
|
||||
settings.FONT_FACE = "Segoe UI";
|
||||
settings.FONT_SIZE = 12;
|
||||
myFontCombo.setSelectedItem(settings.FONT_FACE);
|
||||
myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE));
|
||||
settings.fireUISettingsChanged();
|
||||
lafManager.updateUI();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-16
@@ -1,25 +1,22 @@
|
||||
package MyPack;
|
||||
package fontConfigurable;
|
||||
|
||||
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Alexey.Chursin
|
||||
* Date: Jul 30, 2010
|
||||
* Time: 5:59:43 PM
|
||||
|
||||
*/
|
||||
public class MyExtensConfigurable implements Configurable {
|
||||
private JComponent myComponent;
|
||||
private IDEdialog Mydialog;
|
||||
private IDEDialog myDialog;
|
||||
|
||||
public String getDisplayName() {
|
||||
return "Menu Font";
|
||||
@@ -28,13 +25,13 @@ public class MyExtensConfigurable implements Configurable {
|
||||
public boolean isModified() {
|
||||
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
Mydialog = new IDEdialog();
|
||||
myComponent= (JComponent) Mydialog.getComponent(0);
|
||||
return myComponent ;
|
||||
myDialog = new IDEDialog();
|
||||
myComponent = (JComponent) myDialog.getComponent(0);
|
||||
return myComponent;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,16 +43,16 @@ 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();
|
||||
int _fontSize= Integer.parseInt(_fontSize_STR);
|
||||
|
||||
String _fontFace = (String) myDialog.myFontCombo.getSelectedItem();
|
||||
String _fontSize_STR = (String) myDialog.myFontSize.getSelectedItem();
|
||||
int _fontSize = Integer.parseInt(_fontSize_STR);
|
||||
|
||||
if (_fontSize != settings.FONT_SIZE || !settings.FONT_FACE.equals(_fontFace)) {
|
||||
settings.FONT_SIZE = _fontSize;
|
||||
settings.FONT_FACE = _fontFace;
|
||||
settings.fireUISettingsChanged();
|
||||
lafManager.updateUI();
|
||||
}
|
||||
lafManager.updateUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +65,7 @@ public class MyExtensConfigurable implements Configurable {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user