mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Registered Patterns. Toolbar decorator.
This commit is contained in:
+29
-30
@@ -33,9 +33,9 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ListUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -494,43 +494,42 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
|
||||
|
||||
public static class PatternsPanel extends JPanel {
|
||||
private JBList myPatternsList;
|
||||
private JButton myAddButton;
|
||||
private JButton myRemoveButton;
|
||||
private JComponent myAddButton;
|
||||
private JPanel myWholePanel;
|
||||
private JButton myEditButton;
|
||||
private FileTypeConfigurable myController;
|
||||
|
||||
public PatternsPanel() {
|
||||
super(new BorderLayout());
|
||||
add(myWholePanel, BorderLayout.CENTER);
|
||||
myPatternsList = new JBList(new DefaultListModel());
|
||||
myPatternsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myPatternsList.setCellRenderer(new ExtensionRenderer());
|
||||
myPatternsList.setModel(new DefaultListModel());
|
||||
myPatternsList.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
myRemoveButton.setEnabled(myPatternsList.getSelectedIndex() != -1 && getListModel().size() > 0);
|
||||
}
|
||||
});
|
||||
|
||||
myPatternsList.getEmptyText().setText(FileTypesBundle.message("filetype.settings.no.patterns"));
|
||||
|
||||
myWholePanel = ToolbarDecorator.createDecorator(myPatternsList)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
myController.addPattern();
|
||||
}
|
||||
}).setEditAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
myController.editPattern();
|
||||
}
|
||||
}).setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
myController.removePattern();
|
||||
}
|
||||
}).disableUpDownActions().createPanel();
|
||||
UIUtil.addBorder(myWholePanel, IdeBorderFactory.createTitledBorder(FileTypesBundle.message("filetype.registered.patterns.group"), false));
|
||||
myAddButton = ToolbarDecorator.findAddButton(myWholePanel).getContextComponent();
|
||||
|
||||
add(myWholePanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void attachActions(final FileTypeConfigurable controller) {
|
||||
myAddButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.addPattern();
|
||||
}
|
||||
});
|
||||
myEditButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.editPattern();
|
||||
}
|
||||
});
|
||||
|
||||
myRemoveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.removePattern();
|
||||
}
|
||||
});
|
||||
|
||||
myController = controller;
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.fileTypes.impl.FileTypeConfigurable.PatternsPanel">
|
||||
<grid id="2f1ff" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="4" 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="255" y="126" width="612" height="152"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/FileTypesBundle" title-key="filetype.registered.patterns.group"/>
|
||||
<children>
|
||||
<scrollpane id="6d594" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="4" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="80" height="80"/>
|
||||
<preferred-size width="200" height="150"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5f100" class="com.intellij.ui.components.JBList" binding="myPatternsList">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<selectionMode value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<component id="bf532" class="javax.swing.JButton" binding="myAddButton">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/FileTypesBundle" key="filetype.registered.pattern.add.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6bc56" class="javax.swing.JButton" binding="myRemoveButton">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/FileTypesBundle" key="filetype.registered.pattern.remove.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="ca6cc">
|
||||
<constraints>
|
||||
<grid row="3" 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="cbe18" class="javax.swing.JButton" binding="myEditButton">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Ed&it..."/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
Reference in New Issue
Block a user