本文整理匯總了Java中com.vaadin.ui.AbstractComponent類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractComponent類的具體用法?Java AbstractComponent怎麽用?Java AbstractComponent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractComponent類屬於com.vaadin.ui包,在下文中一共展示了AbstractComponent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createStartDatePopupField
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public AbstractComponent createStartDatePopupField(SimpleMilestone milestone) {
if (milestone.getStartdate() == null) {
Div divHint = new Div().setCSSClass("nonValue");
divHint.appendText(VaadinIcons.TIME_FORWARD.getHtml());
divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
return new MetaFieldBuilder().withCaption(divHint.write())
.withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
} else {
return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_FORWARD.getHtml(),
UserUIContext.formatDate(milestone.getStartdate())))
.withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
}
}
示例2: dragSource
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public B dragSource(Consumer<DragSourceExtension<? extends AbstractComponent>> configurator) {
final DragSourceExtension<I> extension = new DragSourceExtension<>(getInstance());
if (configurator != null) {
configurator.accept(extension);
}
return builder();
}
示例3: getFormat
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
/**
* Returns the format used by
* {@link #convertToPresentation(Object, ValueContext)} and
* {@link #convertToModel(Object, ValueContext)}.
*
* @param context
* value context to use
* @return A NumberFormat instance
*/
protected NumberFormat getFormat(ValueContext context) {
String pattern = null;
Object data = context.getComponent().map(AbstractComponent.class::cast).map(component -> component.getData())
.orElse(null);
if (data instanceof ColumnDefinition) {
pattern = ((ColumnDefinition) data).getFormat()
.orElse(configurationProvider.getNumberFormatPattern().orElse(null));
}
Locale locale = context.getLocale().orElse(configurationProvider.getLocale());
if (pattern == null) {
return NumberFormat.getNumberInstance(locale);
}
return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
}
示例4: addDropTarget
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void addDropTarget(VerticalLayout layout, boolean remove) {
// make the layout accept drops
DropTargetExtension<VerticalLayout> dropTarget = new DropTargetExtension<>(layout);
// the drop effect must match the allowed effect in the drag source for a successful drop
dropTarget.setDropEffect(DropEffect.MOVE);
// catch the drops
dropTarget.addDropListener(event -> {
// if the drag source is in the same UI as the target
Optional<AbstractComponent> dragSource = event.getDragSourceComponent();
if (dragSource.isPresent() && dragSource.get() instanceof SubSetSelectorDraggable.DraggableButton) {
if (remove) {
event.getDragData().ifPresent(data -> removeSelectedOption((ET) data));
} else {
event.getDragData().ifPresent(data -> addSelectedOption((ET) data));
}
}
});
}
示例5: initContextMenu
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public void initContextMenu(Window window, Component contextMenuTarget) {
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (clientConfig.getLayoutAnalyzerEnabled()) {
ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
MenuItem menuItem = contextMenu.addItem(messages.getMainMessage("actions.analyzeLayout"), c -> {
LayoutAnalyzer analyzer = new LayoutAnalyzer();
List<LayoutTip> tipsList = analyzer.analyze(window);
if (tipsList.isEmpty()) {
window.showNotification("No layout problems found", Frame.NotificationType.HUMANIZED);
} else {
window.openWindow("layoutAnalyzer", WindowManager.OpenType.DIALOG,
ParamsMap.of("tipsList", tipsList)
);
}
});
menuItem.setStyleName("c-cm-item");
}
}
示例6: handle
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public boolean handle(ErrorEvent event, App app) {
boolean handled = super.handle(event, app);
//noinspection ThrowableResultOfMethodCallIgnored
if (handled && event.getThrowable() != null) {
// Finds the original source of the error/exception
AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
if (component != null) {
component.markAsDirty();
}
if (component instanceof Component.Focusable) {
((Component.Focusable) component).focus();
}
//noinspection ThrowableResultOfMethodCallIgnored
if (event.getThrowable() instanceof Validator.InvalidValueException) {
app.getAppUI().discardAccumulatedEvents();
}
}
return handled;
}
示例7: setVisible
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
/**
* Sets visibility of the object attached to.
*
* @param o
* @param visible
*/
protected void setVisible(Object o, boolean visible) {
if (attached == null)
return;
if (o instanceof AbstractComponent) {
((AbstractComponent) o).setVisible(visible);
} else if (o instanceof MenuItem) {
((MenuItem) o).setVisible(visible);
} else if (o instanceof ContextMenuItem) {
((ContextMenuItem) o).setEnabled(enabled); // not possible to hide
} else {
throw new WrongObjectTypeException(
"VHL-014: Cannot control visibility state of the object type:"
+ o.getClass().getName());
}
}
示例8: PrimeCountUserStory
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
public PrimeCountUserStory(final AbstractComponent vaadinParent)
{
super(vaadinParent, null, CAPTION);
this.outcomeUserStory = new OutcomeOfUserStory(this);
this.userStoryToolbar = new UserStoryToolbar(this);
this.inUserStory = new InUserStory(this, new UserStoryCleaner(this));
defineWithin(super.layout);
SimpleEventManager.getInstance().attach(new AbstractEventHandler<PrimeCountResultReady>(PrimeCountResultReady.class)
{
@Override
public void handle(final PrimeCountResultReady event)
{
assert null != event : "Parameter 'event' of method 'handle' must not be null";
final IPrototypeComponentVisitor visitor = new UserStoryOutputFeeder(event.getController());
accept(visitor);
}
});
}
示例9: ContextMenu
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
/**
* @param parentComponent
* The component to whose lifecycle the context menu is tied to.
* @param setAsMenuForParentComponent
* Determines if this menu will be shown for the parent
* component.
*/
public ContextMenu(AbstractComponent parentComponent,
boolean setAsMenuForParentComponent) {
extend(parentComponent);
registerRpc(new ContextMenuServerRpc() {
@Override
public void itemClicked(int itemId, boolean menuClosed) {
menu.itemClicked(itemId);
}
});
if (setAsMenuForParentComponent) {
setAsContextMenuOf(parentComponent);
}
}
示例10: buildButtonFooter
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
protected HorizontalLayout buildButtonFooter(AbstractComponent... toTheRightButtons) {
HorizontalLayout footer = new HorizontalLayout();
footer.setWidth("100%");
footer.setSpacing(true);
footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
Label footerText = new Label("");
footerText.setSizeUndefined();
footer.addComponents(footerText);
footer.setExpandRatio(footerText, 1);
if (toTheRightButtons != null) {
footer.addComponents(toTheRightButtons);
}
return footer;
}
示例11: getLayout
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public AbstractComponent getLayout() {
final AddViewLayout formAddLayout = new AddViewLayout(initFormHeader(), initFormIconResource());
final ComponentContainer buttonControls = createButtonControls();
if (buttonControls != null) {
formAddLayout.addHeaderRight(buttonControls);
}
formAddLayout.setTitle(initFormTitle());
wrappedLayoutFactory = initFormLayoutFactory();
formAddLayout.addBody(wrappedLayoutFactory.getLayout());
final ComponentContainer bottomPanel = createBottomPanel();
if (bottomPanel != null) {
formAddLayout.addBottom(bottomPanel);
}
return formAddLayout;
}
示例12: getFieldValue
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public Object getFieldValue(FormInstance formInstance, AbstractComponent field) {
Property prop = (Property) field;
Object value = prop.getValue();
if (value != null && !numberClass.isAssignableFrom(value.getClass())) {
try {
// Gets the string constructor
final Constructor<? extends Number> constr = numberClass.getConstructor(new Class[] { String.class });
// Creates new object from the string
value = constr.newInstance(new Object[] { value.toString() });
} catch (final java.lang.Exception e) {
throw new Property.ConversionException(e);
}
}
return value;
}
示例13: buildForm
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
@Override
public VaadinFormInstance buildForm(Form form, Map<String, Object> extraObjects) {
VerticalLayout layout = new VerticalLayout();
Map<String, AbstractComponent> mapComponents = new HashMap<String, AbstractComponent>();
List<String> fieldIdList = new ArrayList<String>();
layout.setSpacing(true);
layout.setSizeFull();
for (Component part : form.getChildList()) {
ComponentContainer container = buildComponent(part, mapComponents, fieldIdList, extraObjects);
if (container != null) {
layout.addComponent(container);
}
}
addComponent(mapComponents, form, layout);
VaadinFormInstance formInstance = new VaadinFormInstanceImpl(layout, Collections.unmodifiableMap(mapComponents),
Collections.unmodifiableList(fieldIdList));
//build SelectorProviders
buildSelectorProviders(mapComponents, formInstance);
return formInstance;
}
示例14: buildSelectorProviders
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
protected void buildSelectorProviders(Map<String, AbstractComponent> mapComponents, VaadinFormInstance formInstance) {
for (AbstractComponent component : mapComponents.values()) {
if (component.getData() instanceof VaadinDataObject) {
VaadinDataObject dataObject = (VaadinDataObject) component.getData();
Field field = dataObject.getField();
if (field.getType().equals(SelectorConstants.TYPE_SELECTOR)) {
if (component instanceof Container.Viewer) {
Container.Viewer viewer = (Container.Viewer) component;
SelectorProviderFactory factory = (SelectorProviderFactory) field
.getExtra(SelectorConstants.EXTRA_SELECTOR_PROVIDER_FACTORY);
viewer.setContainerDataSource(new VaadinSelectorContainer(factory.createSelectorProvider(formInstance)));
}
}
}
}
}
示例15: buildComponent
import com.vaadin.ui.AbstractComponent; //導入依賴的package包/類
private ComponentContainer buildComponent(Component component, Map<String, AbstractComponent> mapComponents,
List<String> fieldIdList, Map<String, Object> extraObjects) {
AbstractComponentContainer container;
if (component instanceof Drawer) {
container = buildDrawer((Drawer) component, mapComponents, fieldIdList, extraObjects);
} else if (component instanceof Section) {
container = buildSection((Section) component, mapComponents, fieldIdList, extraObjects);
} else if (component instanceof SubForm) {
container = buildSubForm((SubForm) component, mapComponents, fieldIdList, extraObjects);
} else if (component instanceof TabSheet) {
container = buildTabSheet((TabSheet) component, mapComponents, fieldIdList, extraObjects);
} else {
throw new UnsupportedOperationException();
}
addComponent(mapComponents, component, container);
return container;
}