use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WindowBreadCrumbs method update.
public void update() {
AppUI ui = AppUI.getCurrent();
boolean isTestMode = ui.isTestMode();
linksLayout.removeAllComponents();
btn2win.clear();
for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
Window window = it.next();
Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
button.setSizeUndefined();
button.setStyleName(BaseTheme.BUTTON_LINK);
button.setTabIndex(-1);
if (isTestMode) {
button.setCubaId("breadCrubms_Button_" + window.getId());
button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
}
btn2win.put(button, window);
if (it.hasNext()) {
linksLayout.addComponent(button);
Label separatorLab = new Label(" > ");
separatorLab.setStyleName("c-breadcrumbs-separator");
separatorLab.setSizeUndefined();
separatorLab.setContentMode(ContentMode.HTML);
linksLayout.addComponent(separatorLab);
} else {
Label captionLabel = new Label(window.getCaption());
captionLabel.setStyleName("c-breadcrumbs-win-caption");
captionLabel.setSizeUndefined();
linksLayout.addComponent(captionLabel);
this.label = captionLabel;
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebAbstractTable method createColumns.
protected Collection<MetaPropertyPath> createColumns(com.vaadin.data.Container ds) {
@SuppressWarnings("unchecked") final Collection<MetaPropertyPath> properties = (Collection<MetaPropertyPath>) ds.getContainerPropertyIds();
Window window = ComponentsHelper.getWindowImplementation(this);
boolean isLookup = window instanceof Window.Lookup;
for (MetaPropertyPath propertyPath : properties) {
final Table.Column column = columns.get(propertyPath);
if (column != null && !(editable && BooleanUtils.isTrue(column.isEditable()))) {
final String isLink = column.getXmlDescriptor() == null ? null : column.getXmlDescriptor().attributeValue("link");
if (propertyPath.getRange().isClass()) {
if (!isLookup && StringUtils.isNotEmpty(isLink)) {
setClickListener(propertyPath.toString(), new LinkCellClickListener());
}
} else if (propertyPath.getRange().isDatatype()) {
if (!isLookup && !StringUtils.isEmpty(isLink)) {
setClickListener(propertyPath.toString(), new LinkCellClickListener());
} else if (editable && BooleanUtils.isTrue(column.isCalculatable())) {
addGeneratedColumn(propertyPath, new CalculatableColumnGenerator());
} else {
if (column.getMaxTextLength() != null) {
addGeneratedColumn(propertyPath, new AbbreviatedColumnGenerator(column));
setClickListener(propertyPath.toString(), new AbbreviatedCellClickListener());
}
}
} else if (!propertyPath.getRange().isEnum()) {
throw new UnsupportedOperationException();
}
}
}
return properties;
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebAbstractTable method handleClickAction.
protected void handleClickAction() {
Action action = getItemClickAction();
if (action == null) {
action = getEnterAction();
if (action == null) {
action = getAction("edit");
if (action == null) {
action = getAction("view");
}
}
}
if (action != null && action.isEnabled()) {
Window window = ComponentsHelper.getWindowImplementation(WebAbstractTable.this);
if (window instanceof Window.Wrapper) {
window = ((Window.Wrapper) window).getWrappedWindow();
}
if (!(window instanceof Window.Lookup)) {
action.actionPerform(WebAbstractTable.this);
} else {
Window.Lookup lookup = (Window.Lookup) window;
com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
if (lookupComponent != this)
action.actionPerform(WebAbstractTable.this);
else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
action.actionPerform(WebAbstractTable.this);
}
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class FileBrowser method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
filesTable.addAction(new ItemTrackingAction("download").withCaption(getMessage("download")).withHandler(event -> {
FileDescriptor fileDescriptor = filesTable.getSingleSelected();
if (fileDescriptor != null) {
exportDisplay.show(fileDescriptor, null);
}
}));
BaseAction multiUploadAction = new BaseAction("multiupload").withCaption(getMessage("multiupload")).withHandler(event -> {
if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.READ)) {
throw new AccessDeniedException(PermissionType.ENTITY_OP, FileDescriptor.class.getSimpleName());
}
Window window = openWindow("multiuploadDialog", OpenType.DIALOG);
window.addCloseListener(actionId -> {
if (COMMIT_ACTION_ID.equals(actionId)) {
Collection<FileDescriptor> items = ((MultiUploader) window).getFiles();
for (FileDescriptor fdesc : items) {
boolean modified = filesDs.isModified();
filesDs.addItem(fdesc);
((DatasourceImplementation) filesDs).setModified(modified);
}
filesTable.requestFocus();
}
});
});
multiUploadAction.setEnabled(security.isEntityOpPermitted(FileDescriptor.class, EntityOp.CREATE));
multiUploadBtn.setAction(multiUploadAction);
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopAbstractTable method handleClickAction.
protected void handleClickAction() {
Action action = getItemClickAction();
if (action == null) {
action = getEnterAction();
if (action == null) {
action = getAction("edit");
if (action == null) {
action = getAction("view");
}
}
}
if (action != null && action.isEnabled() && action.isVisible()) {
Window window = ComponentsHelper.getWindow(DesktopAbstractTable.this);
if (window instanceof Window.Wrapper) {
window = ((Window.Wrapper) window).getWrappedWindow();
}
if (!(window instanceof Window.Lookup)) {
action.actionPerform(DesktopAbstractTable.this);
} else {
Window.Lookup lookup = (Window.Lookup) window;
com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
if (lookupComponent != this) {
action.actionPerform(DesktopAbstractTable.this);
} else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
action.actionPerform(DesktopAbstractTable.this);
}
}
}
}
Aggregations