use of com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog in project android by JetBrains.
the class ThemeEditorUtils method getResourceDialog.
@NotNull
public static ChooseResourceDialog getResourceDialog(@NotNull EditedStyleItem item, @NotNull ThemeEditorContext context, EnumSet<ResourceType> allowedTypes) {
Module module = context.getModuleForResources();
ItemResourceValue itemSelectedValue = item.getSelectedValue();
String value = itemSelectedValue.getValue();
boolean isFrameworkValue = itemSelectedValue.isFramework();
String nameSuggestion = value;
ResourceUrl url = ResourceUrl.parse(value, isFrameworkValue);
if (url != null) {
nameSuggestion = url.name;
}
nameSuggestion = getDefaultResourceName(context, nameSuggestion);
ChooseResourceDialog.ResourceNameVisibility resourceNameVisibility = ChooseResourceDialog.ResourceNameVisibility.FORCE;
if (nameSuggestion.startsWith("#")) {
nameSuggestion = null;
resourceNameVisibility = ChooseResourceDialog.ResourceNameVisibility.SHOW;
}
ChooseResourceDialog dialog = ChooseResourceDialog.builder().setModule(module).setTypes(allowedTypes).setCurrentValue(value).setIsFrameworkValue(isFrameworkValue).setResourceNameVisibility(resourceNameVisibility).setResourceNameSuggestion(nameSuggestion).build();
dialog.setUseGlobalUndo(true);
return dialog;
}
use of com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog in project android by JetBrains.
the class NlBaseComponentEditor method displayResourcePicker.
protected void displayResourcePicker() {
NlProperty property = getProperty();
if (property == null) {
return;
}
ChooseResourceDialog dialog = BrowsePanel.showResourceChooser(property);
if (dialog.showAndGet()) {
stopEditing(dialog.getResourceName());
} else {
cancelEditing();
}
}
use of com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog in project android by JetBrains.
the class ViewEditorImpl method displayResourceInput.
@Nullable
@Override
public String displayResourceInput(@NotNull String title, @NotNull EnumSet<ResourceType> types) {
NlModel model = myScreen.getModel();
ChooseResourceDialog dialog = ChooseResourceDialog.builder().setModule(model.getModule()).setTypes(types).setConfiguration(model.getConfiguration()).build();
if (!title.isEmpty()) {
dialog.setTitle(title);
}
dialog.show();
if (dialog.isOK()) {
String resource = dialog.getResourceName();
if (resource != null && !resource.isEmpty()) {
return resource;
}
}
return null;
}
Aggregations