use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class BrowsePanel method createDesignAction.
private AnAction createDesignAction() {
return new AnAction() {
@Override
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
switch(checkDesignState()) {
case MISSING_DESIGN_PROPERTY:
presentation.setIcon(AndroidIcons.NeleIcons.DesignProperty);
presentation.setText("Specify Design Property");
presentation.setVisible(true);
presentation.setEnabled(true);
break;
case IS_REMOVABLE_DESIGN_PROPERTY:
presentation.setIcon(AllIcons.Actions.Delete);
presentation.setText("Remove this Design Property");
presentation.setVisible(true);
presentation.setEnabled(true);
break;
default:
presentation.setIcon(null);
presentation.setText(null);
presentation.setVisible(false);
presentation.setEnabled(false);
break;
}
}
@Override
public void actionPerformed(AnActionEvent event) {
switch(checkDesignState()) {
case MISSING_DESIGN_PROPERTY:
myContext.addDesignProperty();
break;
case IS_REMOVABLE_DESIGN_PROPERTY:
myContext.removeDesignProperty();
break;
default:
}
}
private DesignState checkDesignState() {
NlProperty property = myContext.getProperty();
if (property == null || myDesignButton == null) {
return DesignState.NOT_APPLICABLE;
}
if (TOOLS_URI.equals(property.getNamespace())) {
NlProperty runtimeProperty = myContext.getRuntimeProperty();
return runtimeProperty != null ? DesignState.IS_REMOVABLE_DESIGN_PROPERTY : DesignState.NOT_APPLICABLE;
} else {
NlProperty designProperty = myContext.getDesignProperty();
return designProperty != null ? DesignState.HAS_DESIGN_PROPERTY : DesignState.MISSING_DESIGN_PROPERTY;
}
}
};
}
use of com.android.tools.idea.uibuilder.property.NlProperty 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.uibuilder.property.NlProperty in project android by JetBrains.
the class InspectorPanel method activatePreferredEditor.
private void activatePreferredEditor(@NotNull String propertyName) {
myActivateEditorAfterLoad = false;
myPropertyNameForActivation = null;
boolean designPropertyRequired = propertyName.startsWith(TOOLS_NS_NAME_PREFIX);
propertyName = StringUtil.trimStart(propertyName, TOOLS_NS_NAME_PREFIX);
for (InspectorComponent component : myInspectors) {
for (NlComponentEditor editor : component.getEditors()) {
NlProperty property = editor.getProperty();
if (property != null && propertyName.equals(property.getName()) && !(designPropertyRequired && !TOOLS_URI.equals(property.getNamespace()))) {
editor.requestFocus();
return;
}
}
}
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class ProgressBarInspectorProviderTest method testChangingIndeterminateChangesVisibilityOfEditors.
public void testChangingIndeterminateChangesVisibilityOfEditors() {
List<NlComponent> components = ImmutableList.of(myProgressBar);
Map<String, NlProperty> properties = getPropertyMap(components);
assertThat(myProvider.isApplicable(components, properties, myPropertiesManager)).isTrue();
InspectorComponent inspector = myProvider.createCustomInspector(components, properties, myPropertiesManager);
inspector.refresh();
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
NlBaseComponentEditor indeterminateEditor = (NlBaseComponentEditor) getEditor(inspector, ATTR_INDETERMINATE, ANDROID_URI);
indeterminateEditor.stopEditing("true");
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
indeterminateEditor.stopEditing("false");
assertThat(isEditorVisible(inspector, ATTR_STYLE, "")).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_DRAWABLE)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_DRAWABLE)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS_TINT)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE_TINT)).isFalse();
assertThat(isEditorVisible(inspector, ATTR_MAXIMUM)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_PROGRESS)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_VISIBILITY, TOOLS_URI)).isTrue();
assertThat(isEditorVisible(inspector, ATTR_INDETERMINATE)).isTrue();
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class ProgressBarInspectorProviderTest method hasProperty.
private static boolean hasProperty(@NotNull NlComponentEditor editor, @NotNull String attributeName, @NotNull String namespace) {
NlProperty property = editor.getProperty();
assertThat(property).isNotNull();
return property.getName().equals(attributeName) && namespace.equals(property.getNamespace());
}
Aggregations