mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
file name combo box
This commit is contained in:
@@ -45,18 +45,9 @@
|
||||
<grid row="3" 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>
|
||||
<labelFor value="185f7"/>
|
||||
<text value="&File name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="185f7" class="javax.swing.JTextField" binding="myFileNameField">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="8a4e8" binding="myDirectoriesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -70,7 +61,7 @@
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Directories:"/>
|
||||
<text value="&Create the resource in directories:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8e835" class="com.intellij.ui.components.JBLabel" binding="myValueLabel">
|
||||
@@ -90,6 +81,14 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="bb5b8" class="javax.swing.JComboBox" binding="myFileNameCombo">
|
||||
<constraints>
|
||||
<grid row="3" 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>
|
||||
<editable value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -66,12 +66,12 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
private JTextField myNameField;
|
||||
private JComboBox myModuleCombo;
|
||||
private JBLabel myModuleLabel;
|
||||
private JTextField myFileNameField;
|
||||
private JPanel myDirectoriesPanel;
|
||||
private JBLabel myDirectoriesLabel;
|
||||
private JTextField myValueField;
|
||||
private JBLabel myValueLabel;
|
||||
private JBLabel myNameLabel;
|
||||
private JComboBox myFileNameCombo;
|
||||
|
||||
private final Module myModule;
|
||||
private final ResourceType myResourceType;
|
||||
@@ -146,7 +146,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
final String defaultFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType);
|
||||
|
||||
if (defaultFileName != null) {
|
||||
myFileNameField.setText(defaultFileName);
|
||||
myFileNameCombo.getEditor().setItem(defaultFileName);
|
||||
}
|
||||
}
|
||||
myDirectoriesList = new CheckBoxList();
|
||||
@@ -188,12 +188,12 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
|
||||
myDirectoriesPanel.add(decorator.createPanel());
|
||||
|
||||
updateDirectories();
|
||||
updateDirectories(true);
|
||||
|
||||
myModuleCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateDirectories();
|
||||
updateDirectories(true);
|
||||
}
|
||||
});
|
||||
final JCheckBox valuesCheckBox = myCheckBoxes.get(AndroidConstants.FD_RES_VALUES);
|
||||
@@ -240,7 +240,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
checkBox1.setSelected(false);
|
||||
}
|
||||
checkBox.setSelected(true);
|
||||
myFileNameField.setText(file.getName());
|
||||
myFileNameCombo.getEditor().setItem(file.getName());
|
||||
}
|
||||
|
||||
private void doDeleteDirectory() {
|
||||
@@ -271,7 +271,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
});
|
||||
updateDirectories();
|
||||
updateDirectories(false);
|
||||
}
|
||||
|
||||
private void doSelectAllDirs() {
|
||||
@@ -303,12 +303,12 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
final PsiElement[] createdElements = new CreateResourceDirectoryAction(ResourceFolderType.VALUES).invokeDialog(project, psiResDir);
|
||||
|
||||
if (createdElements.length > 0) {
|
||||
updateDirectories();
|
||||
updateDirectories(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDirectories() {
|
||||
private void updateDirectories(boolean updateFileCombo) {
|
||||
final Module module = getModule();
|
||||
List<VirtualFile> valuesDirs = Collections.emptyList();
|
||||
|
||||
@@ -366,6 +366,21 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
if (checkBoxList.size() == 1) {
|
||||
checkBoxList.get(0).setSelected(true);
|
||||
}
|
||||
|
||||
if (updateFileCombo) {
|
||||
final Object oldItem = myFileNameCombo.getEditor().getItem();
|
||||
final Set<String> fileNameSet = new HashSet<String>();
|
||||
|
||||
for (VirtualFile valuesDir : valuesDirs) {
|
||||
for (VirtualFile file : valuesDir.getChildren()) {
|
||||
fileNameSet.add(file.getName());
|
||||
}
|
||||
}
|
||||
final List<String> fileNames = new ArrayList<String>(fileNameSet);
|
||||
Collections.sort(fileNames);
|
||||
myFileNameCombo.setModel(new DefaultComboBoxModel(fileNames.toArray()));
|
||||
myFileNameCombo.getEditor().setItem(oldItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,7 +397,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
return new ValidationInfo(resourceName + " is not correct resource name", myNameField);
|
||||
}
|
||||
else if (fileName.length() == 0) {
|
||||
return new ValidationInfo("specify file name", myFileNameField);
|
||||
return new ValidationInfo("specify file name", myFileNameCombo);
|
||||
}
|
||||
else if (selectedModule == null) {
|
||||
return new ValidationInfo("specify module", myModuleCombo);
|
||||
@@ -458,7 +473,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
return myModuleCombo;
|
||||
}
|
||||
else {
|
||||
return myFileNameField;
|
||||
return myFileNameCombo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,7 +529,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
|
||||
|
||||
@NotNull
|
||||
public String getFileName() {
|
||||
return myFileNameField.getText().trim();
|
||||
return ((String)myFileNameCombo.getEditor().getItem()).trim();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user