Search in sources :

Example 1 with ChooseResourceDialog

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;
}
Also used : ItemResourceValue(com.android.ide.common.rendering.api.ItemResourceValue) ChooseResourceDialog(com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog) Module(com.intellij.openapi.module.Module) ResourceUrl(com.android.ide.common.resources.ResourceUrl) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ChooseResourceDialog

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();
    }
}
Also used : NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) ChooseResourceDialog(com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog)

Example 3 with ChooseResourceDialog

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;
}
Also used : ChooseResourceDialog(com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog) NlModel(com.android.tools.idea.uibuilder.model.NlModel) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ChooseResourceDialog (com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog)3 ItemResourceValue (com.android.ide.common.rendering.api.ItemResourceValue)1 ResourceUrl (com.android.ide.common.resources.ResourceUrl)1 NlModel (com.android.tools.idea.uibuilder.model.NlModel)1 NlProperty (com.android.tools.idea.uibuilder.property.NlProperty)1 Module (com.intellij.openapi.module.Module)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1