use of com.haulmont.cuba.gui.xml.layout.ComponentsFactory in project cuba by cuba-platform.
the class WebComponentsHelper method createButton.
public static Button createButton(String icon) {
ComponentsFactory cf = AppBeans.get(ComponentsFactory.NAME);
com.haulmont.cuba.gui.components.Button button = cf.createComponent(com.haulmont.cuba.gui.components.Button.class);
button.setIcon(icon);
return (Button) unwrap(button);
}
use of com.haulmont.cuba.gui.xml.layout.ComponentsFactory in project cuba by cuba-platform.
the class WebAccordion method addLazyTab.
@Override
public Accordion.Tab addLazyTab(String name, Element descriptor, ComponentLoader loader) {
// todo replace
ComponentsFactory cf = AppBeans.get(ComponentsFactory.NAME);
CssLayout tabContent = cf.createComponent(CssLayout.NAME);
tabContent.setStyleName("c-tabsheet-lazytab");
tabContent.setSizeFull();
Tab tab = new Tab(name, tabContent);
tabs.put(name, tab);
com.vaadin.ui.Component tabComponent = tabContent.unwrapComposition(com.vaadin.ui.Component.class);
tabMapping.put(tabComponent, new ComponentDescriptor(name, tabContent));
com.vaadin.ui.Accordion.Tab tabControl = this.component.addTab(tabComponent);
getLazyTabs().add(tabComponent);
this.component.addSelectedTabChangeListener(new LazyTabChangeListener(tabContent, descriptor, loader));
context = loader.getContext();
if (!postInitTaskAdded && context instanceof ComponentLoader.ComponentContext) {
((ComponentLoader.ComponentContext) context).addPostInitTask((c, w) -> initComponentTabChangeListener());
postInitTaskAdded = true;
}
if (getDebugId() != null) {
this.component.setTestId(tabControl, AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "." + name));
}
if (AppUI.getCurrent().isTestMode()) {
this.component.setCubaId(tabControl, name);
}
if (context instanceof ComponentLoader.ComponentContext) {
tabContent.setFrame(((ComponentLoader.ComponentContext) context).getFrame());
} else {
throw new IllegalStateException("'context' must implement " + "com.haulmont.cuba.gui.xml.layout.ComponentLoader.ComponentContext");
}
return tab;
}
use of com.haulmont.cuba.gui.xml.layout.ComponentsFactory in project cuba by cuba-platform.
the class PropertyOperationEditor method createComponent.
@Override
protected Component createComponent() {
OpManager opManager = AppBeans.get(OpManager.class);
MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
componentsFactory = AppBeans.get(ComponentsFactory.class);
popupButton = componentsFactory.createComponent(PopupButton.class);
MetaClass metaClass = condition.getEntityMetaClass();
MetaPropertyPath propertyPath = metaClass.getPropertyPath(condition.getName());
if (propertyPath == null) {
throw new IllegalStateException(String.format("Unable to find property '%s' in entity %s", condition.getName(), metaClass));
}
MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
for (Op op : opManager.availableOps(propertyMetaClass, propertyPath.getMetaProperty())) {
OperatorChangeAction operatorChangeAction = new OperatorChangeAction(op);
popupButton.addAction(operatorChangeAction);
}
popupButton.setCaption(condition.getOperator().getLocCaption());
popupButton.setStyleName("condition-operation-button");
return popupButton;
}
use of com.haulmont.cuba.gui.xml.layout.ComponentsFactory in project cuba by cuba-platform.
the class DynamicAttributesOperationEditor method createComponent.
@Override
protected Component createComponent() {
ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class);
Label label = componentsFactory.createComponent(Label.class);
label.setValue(condition.getOperationCaption());
return label;
}
use of com.haulmont.cuba.gui.xml.layout.ComponentsFactory in project cuba by cuba-platform.
the class FileDownloadHelper method initGeneratedColumn.
/**
* Initializes a column for downloading files in a table displaying {@link FileDescriptor}s.
*
* @param table table that displays instances of the {@link FileDescriptor} entity
*/
public static void initGeneratedColumn(final Table table) {
final ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.NAME);
final ExportDisplay exportDisplay = AppBeans.get(ExportDisplay.NAME);
table.addGeneratedColumn("name", new Table.ColumnGenerator<FileDescriptor>() {
@Override
public Component generateCell(final FileDescriptor fd) {
if (fd == null) {
return componentsFactory.createComponent(Label.NAME);
}
if (PersistenceHelper.isNew(fd)) {
Label label = componentsFactory.createComponent(Label.class);
label.setValue(fd.getName());
return label;
} else {
Button button = componentsFactory.createComponent(Button.class);
button.setStyleName("link");
button.setAction(new AbstractAction("download") {
@Override
public void actionPerform(Component component) {
exportDisplay.show(fd);
}
@Override
public String getCaption() {
return fd.getName();
}
});
return button;
}
}
});
}
Aggregations