use of com.android.tools.idea.ui.properties.swing.VisibleProperty in project android by JetBrains.
the class ModelWizardDialog method createJButtonForAction.
@Override
protected JButton createJButtonForAction(Action action) {
final JButton button = super.createJButtonForAction(action);
if (action instanceof ModelWizardDialogAction) {
ModelWizardDialogAction wizardAction = (ModelWizardDialogAction) action;
myBindings.bind(new EnabledProperty(button), wizardAction.shouldBeEnabled());
myBindings.bind(new VisibleProperty(button), wizardAction.shouldBeVisible());
myListeners.receiveAndFire(wizardAction.shouldBeDefault(), isDefault -> {
JRootPane rootPane = getRootPane();
if (rootPane != null && isDefault) {
rootPane.setDefaultButton(button);
}
});
}
return button;
}
use of com.android.tools.idea.ui.properties.swing.VisibleProperty in project android by JetBrains.
the class ConfigureTemplateParametersStep method onEntering.
@Override
protected void onEntering() {
// The Model TemplateHandle may have changed, rebuild the panel
resetPanel();
final TemplateHandle templateHandle = getModel().getTemplateHandle();
ApplicationManager.getApplication().invokeLater(() -> {
// We want to set the label's text AFTER the wizard has been packed. Otherwise, its
// width calculation gets involved and can really stretch out some wizards if the label is
// particularly long (see Master/Detail Activity for example).
myTemplateDescriptionLabel.setText(WizardUtils.toHtmlString(Strings.nullToEmpty(templateHandle.getMetadata().getDescription())));
}, ModalityState.any());
final IconProperty thumb = new IconProperty(myTemplateThumbLabel);
BoolProperty thumbVisibility = new VisibleProperty(myTemplateThumbLabel);
myBindings.bind(thumb, new Expression<Optional<Icon>>(myThumbPath) {
@NotNull
@Override
public Optional<Icon> get() {
return myThumbnailsCache.getUnchecked(new File(templateHandle.getRootPath(), myThumbPath.get()));
}
});
myBindings.bind(thumbVisibility, new Expression<Boolean>(thumb) {
@NotNull
@Override
public Boolean get() {
return thumb.get().isPresent();
}
});
myThumbPath.set(getDefaultThumbnailPath());
final TextProperty parameterDescription = new TextProperty(myParameterDescriptionLabel);
myBindings.bind(new VisibleProperty(myFooterSeparator), new Expression<Boolean>(parameterDescription) {
@NotNull
@Override
public Boolean get() {
return !parameterDescription.get().isEmpty();
}
});
Module module = myFacet == null ? null : myFacet.getModule();
final Collection<Parameter> parameters = templateHandle.getMetadata().getParameters();
for (final Parameter parameter : parameters) {
RowEntry row = createRowForParameter(module, parameter);
final ObservableValue<?> property = row.getProperty();
if (property != null) {
property.addListener(sender -> {
if (myEvaluationState != EvaluationState.EVALUATING) {
myUserValues.put(parameter, property.get());
enqueueEvaluateParameters();
}
});
final ActionGroup resetParameterGroup = new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return new AnAction[] { new ResetParameterAction(parameter) };
}
};
row.getComponent().addMouseListener(new PopupHandler() {
@Override
public void invokePopup(Component comp, int x, int y) {
ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, resetParameterGroup).getComponent().show(comp, x, y);
}
});
}
myParameterRows.put(parameter, row);
row.addToPanel(myParametersPanel);
}
if (mySourceSets.size() > 1) {
RowEntry row = new RowEntry<>("Target Source Set", new SourceSetComboProvider(mySourceSets));
row.setEnabled(mySourceSets.size() > 1);
row.addToPanel(myParametersPanel);
//noinspection unchecked
SelectedItemProperty<AndroidSourceSet> sourceSet = (SelectedItemProperty<AndroidSourceSet>) row.getProperty();
// SourceSetComboProvider always sets this
assert sourceSet != null;
myBindings.bind(getModel().getSourceSet(), new OptionalToValuePropertyAdapter<>(sourceSet));
sourceSet.addListener(sender -> enqueueEvaluateParameters());
}
myValidatorPanel.registerValidator(myInvalidParameterMessage, message -> (message.isEmpty() ? Validator.Result.OK : new Validator.Result(Validator.Severity.ERROR, message)));
// TODO: This code won't be needed until we migrate this enough to support
// NewAndroidApplication/template.xml and NewAndroidLibrary/template.xml
// Add it in then. Probably we can add an optional validator API to ComponentProvider? Then we
// could move this code into EnumComboProvider and it won't be a hack anymore.
//
// if (value instanceof ApiComboBoxItem) {
// ApiComboBoxItem selectedItem = (ApiComboBoxItem)value;
//
// if (minApi != null && selectedItem.minApi > minApi.getFeatureLevel()) {
// setErrorHtml(String.format("The \"%s\" option for %s requires a minimum API level of %d",
// selectedItem.label, param.name, selectedItem.minApi));
// return false;
// }
// if (buildApi != null && selectedItem.minBuildApi > buildApi) {
// setErrorHtml(String.format("The \"%s\" option for %s requires a minimum API level of %d",
// selectedItem.label, param.name, selectedItem.minBuildApi));
// return false;
// }
//}
evaluateParameters();
}
Aggregations