use of com.intellij.openapi.fileChooser.FileTypeDescriptor in project intellij-plugins by JetBrains.
the class JsFileRunSettingsSection method createComponent.
@NotNull
@Override
public JComponent createComponent(@NotNull CreationContext creationContext) {
JPanel panel = new JPanel(new GridBagLayout());
{
GridBagConstraints c = new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
JComponent configComponent = myConfigFileRunSettingsSection.getComponent(creationContext);
panel.add(configComponent, c);
}
{
myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
myLabel.setDisplayedMnemonic('J');
myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton.getTextField());
GridBagConstraints c = new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, UIUtil.DEFAULT_HGAP), 0, 0);
panel.add(myLabel, c);
}
{
GridBagConstraints c = new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, 0), 0, 0);
FileChooserDescriptor jsFileChooserDescriptor = new FileTypeDescriptor("Select JavaScript test file", ".js");
myJsTestFileTextFieldWithBrowseButton.addBrowseFolderListener(null, null, creationContext.getProject(), jsFileChooserDescriptor);
panel.add(myJsTestFileTextFieldWithBrowseButton, c);
myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton);
}
SwingUtils.addGreedyBottomRow(panel);
return panel;
}
use of com.intellij.openapi.fileChooser.FileTypeDescriptor in project intellij-community by JetBrains.
the class DomGenPanel method createUIComponents.
private void createUIComponents() {
mySchemaLocation = new TextFieldWithBrowseButton();
final String title = "Choose XSD or DTD schema";
mySchemaLocation.addBrowseFolderListener(title, "Make sure there are only necessary schemes in directory where your XSD or DTD schema is located", myProject, new FileTypeDescriptor(title, "xsd", "dtd"));
mySchemaLocation.getTextField().setEditable(false);
mySchemaLocation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final File file = new File(mySchemaLocation.getText());
if (file.exists() && file.getName().toLowerCase().endsWith(".xsd")) {
final VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file);
if (vf != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
if (psiFile instanceof XmlFile) {
final XmlDocument xml = ((XmlFile) psiFile).getDocument();
if (xml != null) {
final XmlTag rootTag = xml.getRootTag();
if (rootTag != null) {
String target = null;
ArrayList<String> ns = new ArrayList<>();
for (XmlAttribute attr : rootTag.getAttributes()) {
if ("targetNamespace".equals(attr.getName())) {
target = attr.getValue();
} else if (attr.getName().startsWith("xmlns")) {
ns.add(attr.getValue());
}
}
ns.remove(target);
if (target != null) {
myNamespace.setText(target);
}
mySkipSchemas.setText(StringUtil.join(ArrayUtil.toStringArray(ns), "\n"));
}
}
}
}
}
}
});
myOutputDir = new TextFieldWithBrowseButton();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myOutputDir.addBrowseFolderListener("Select Output Directory For Generated Files", "", myProject, descriptor);
}
Aggregations