use of com.android.tools.adtui.LabelWithEditLink in project android by JetBrains.
the class TemplateParameterStep2 method createComponents.
@NotNull
private List<JComponent> createComponents(final Parameter parameter) {
JLabel label = new JLabel(parameter.name + ":");
final JComponent dataComponent;
if (AddAndroidActivityPath.PACKAGE_NAME_PARAMETERS.contains(parameter.id)) {
Module module = getModule();
if (module != null) {
dataComponent = createPackageEntry(parameter, module);
} else {
dataComponent = new LabelWithEditLink();
}
} else if (AddAndroidActivityPath.CLASS_NAME_PARAMETERS.contains(parameter.id)) {
Module module = getModule();
if (module != null) {
dataComponent = createClassEntry(parameter, module);
} else {
dataComponent = new JTextField();
}
} else {
switch(parameter.type) {
case BOOLEAN:
label = null;
dataComponent = new JCheckBox(parameter.name);
break;
case ENUM:
dataComponent = createEnumCombo(parameter);
break;
case STRING:
dataComponent = new JTextField();
break;
case SEPARATOR:
return Collections.singletonList(new JSeparator(SwingConstants.HORIZONTAL));
default:
throw new IllegalStateException(parameter.type.toString());
}
}
if (!StringUtil.isEmpty(parameter.help) && dataComponent.getAccessibleContext() != null) {
dataComponent.getAccessibleContext().setAccessibleDescription(parameter.help);
}
register(parameter, dataComponent);
if (label != null) {
label.setLabelFor(dataComponent);
}
return label != null ? Arrays.asList(label, dataComponent) : Arrays.asList(dataComponent);
}
use of com.android.tools.adtui.LabelWithEditLink in project android by JetBrains.
the class TemplateParameterStep2 method addComponent.
private static int addComponent(JComponent parent, JComponent component, int row, int column, boolean isLast) {
GridConstraints gridConstraints = new GridConstraints();
gridConstraints.setRow(row);
gridConstraints.setColumn(column);
boolean isGreedyComponent = component instanceof JTextField || component instanceof Spacer || component instanceof LabelWithEditLink || component instanceof TextAccessor || component instanceof EditorComboBox;
int columnSpan = (isLast && isGreedyComponent) ? COLUMN_COUNT - column : 1;
gridConstraints.setColSpan(columnSpan);
gridConstraints.setAnchor(GridConstraints.ALIGN_LEFT);
gridConstraints.setHSizePolicy(isGreedyComponent ? GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW : GridConstraints.SIZEPOLICY_CAN_SHRINK);
gridConstraints.setVSizePolicy(component instanceof Spacer ? GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW : GridConstraints.SIZEPOLICY_FIXED);
gridConstraints.setFill(GridConstraints.FILL_HORIZONTAL);
parent.add(component, gridConstraints);
if (isLast && !isGreedyComponent && column < COLUMN_COUNT - 1) {
addComponent(parent, new Spacer(), row, column + 1, true);
}
return columnSpan;
}
use of com.android.tools.adtui.LabelWithEditLink in project android by JetBrains.
the class ConfigureAndroidProjectStepFixture method enterPackageName.
@NotNull
public ConfigureAndroidProjectStepFixture enterPackageName(@NotNull String text) {
LabelWithEditLink link = robot().finder().findByType(target(), LabelWithEditLink.class);
HyperlinkLabel editLabel = robot().finder().findByType(link, HyperlinkLabel.class);
robot().click(editLabel);
JTextComponent textField = findTextFieldWithLabel("Package name:");
replaceText(textField, text);
// click "Done"
robot().click(editLabel);
return this;
}
use of com.android.tools.adtui.LabelWithEditLink in project android by JetBrains.
the class TextPropertyTest method textPropertyCanWrapLabelWithEditLink.
@Test
public void textPropertyCanWrapLabelWithEditLink() {
LabelWithEditLink editLabel = new LabelWithEditLink();
TextProperty textProperty = new TextProperty(editLabel);
CountListener listener = new CountListener();
textProperty.addListener(listener);
assertThat(textProperty.get()).isEqualTo("");
assertThat(listener.getCount()).isEqualTo(0);
editLabel.setText("Edit label set directly");
assertThat(textProperty.get()).isEqualTo("Edit label set directly");
assertThat(listener.getCount()).isEqualTo(1);
textProperty.set("Edit label updated via property");
assertThat(editLabel.getText()).isEqualTo("Edit label updated via property");
assertThat(listener.getCount()).isEqualTo(2);
}
Aggregations