Search in sources :

Example 1 with DeviceConfiguratorPanel

use of org.jetbrains.android.uipreview.DeviceConfiguratorPanel in project android by JetBrains.

the class CreateResourceFileDialogBase method setupDeviceConfigurationPanel.

protected DeviceConfiguratorPanel setupDeviceConfigurationPanel(final JTextField directoryNameTextField, final TemplateKindCombo resourceTypeCombo, final JBLabel errorLabel) {
    return new DeviceConfiguratorPanel() {

        @Override
        public void applyEditors() {
            try {
                doApplyEditors();
                final FolderConfiguration config = this.getConfiguration();
                final CreateTypedResourceFileAction selectedAction = getSelectedAction(resourceTypeCombo);
                errorLabel.setText("");
                directoryNameTextField.setText("");
                if (selectedAction != null) {
                    final ResourceFolderType resFolderType = selectedAction.getResourceFolderType();
                    directoryNameTextField.setText(config.getFolderName(resFolderType));
                }
            } catch (InvalidOptionValueException e) {
                errorLabel.setText(new HtmlBuilder().openHtmlBody().coloredText(JBColor.RED, e.getMessage()).closeHtmlBody().getHtml());
                directoryNameTextField.setText("");
            }
            updateOkAction();
        }
    };
}
Also used : ResourceFolderType(com.android.resources.ResourceFolderType) HtmlBuilder(com.android.utils.HtmlBuilder) InvalidOptionValueException(org.jetbrains.android.uipreview.InvalidOptionValueException) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) DeviceConfiguratorPanel(org.jetbrains.android.uipreview.DeviceConfiguratorPanel)

Example 2 with DeviceConfiguratorPanel

use of org.jetbrains.android.uipreview.DeviceConfiguratorPanel in project android by JetBrains.

the class CreateResourceDirectoryDialogBase method setupDeviceConfigurationPanel.

protected DeviceConfiguratorPanel setupDeviceConfigurationPanel(final JComboBox resourceTypeComboBox, final JTextField directoryNameTextField, final JBLabel errorLabel) {
    return new DeviceConfiguratorPanel() {

        @Override
        public void applyEditors() {
            try {
                doApplyEditors();
                final FolderConfiguration config = this.getConfiguration();
                final ResourceFolderType selectedResourceType = (ResourceFolderType) resourceTypeComboBox.getSelectedItem();
                directoryNameTextField.setText(selectedResourceType != null ? config.getFolderName(selectedResourceType) : "");
                errorLabel.setText("");
            } catch (InvalidOptionValueException e) {
                errorLabel.setText(new HtmlBuilder().openHtmlBody().coloredText(JBColor.RED, e.getMessage()).closeHtmlBody().getHtml());
                directoryNameTextField.setText("");
            }
            setOKActionEnabled(directoryNameTextField.getText().length() > 0);
        }
    };
}
Also used : ResourceFolderType(com.android.resources.ResourceFolderType) HtmlBuilder(com.android.utils.HtmlBuilder) InvalidOptionValueException(org.jetbrains.android.uipreview.InvalidOptionValueException) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) DeviceConfiguratorPanel(org.jetbrains.android.uipreview.DeviceConfiguratorPanel)

Aggregations

FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)2 ResourceFolderType (com.android.resources.ResourceFolderType)2 HtmlBuilder (com.android.utils.HtmlBuilder)2 DeviceConfiguratorPanel (org.jetbrains.android.uipreview.DeviceConfiguratorPanel)2 InvalidOptionValueException (org.jetbrains.android.uipreview.InvalidOptionValueException)2