in src/com/intellij/idea/plugin/hybris/system/type/model/generator/DomGenPanel.java [61:107]
private void createUIComponents() {
mySchemaLocation = new TextFieldWithBrowseButton();
mySchemaLocation.addBrowseFolderListener(
myProject,
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withExtensionFilter("Files (.xsd, .dtd)", "xsd", "dtd")
.withTitle("Choose XSD or DTD Schema")
.withDescription("Make sure there are only necessary schemes in directory where your XSD or DTD schema is located")
);
mySchemaLocation.getTextField().setEditable(false);
mySchemaLocation.addActionListener(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;
final 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();
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
.withTitle("Select Output Directory For Generated Files");
myOutputDir.addBrowseFolderListener(myProject, descriptor);
}