use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class DefaultTabSheetDropHandler method handleComponentReordering.
@Override
protected void handleComponentReordering(DragAndDropEvent event) {
LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
TabSheetTargetDetails details = (TabSheetTargetDetails) event.getTargetDetails();
DDTabSheet tabSheet = (DDTabSheet) details.getTarget();
Component c = transferable.getComponent();
Tab tab = tabSheet.getTab(c);
HorizontalDropLocation location = details.getDropLocation();
int idx = details.getOverIndex();
if (location == HorizontalDropLocation.LEFT) {
// Left of previous tab
int originalIndex = tabSheet.getTabPosition(tab);
if (originalIndex > idx) {
tabSheet.setTabPosition(tab, idx);
} else if (idx - 1 >= 0) {
tabSheet.setTabPosition(tab, idx - 1);
}
} else if (location == HorizontalDropLocation.RIGHT) {
// Right of previous tab
int originalIndex = tabSheet.getTabPosition(tab);
if (originalIndex > idx) {
tabSheet.setTabPosition(tab, idx + 1);
} else {
tabSheet.setTabPosition(tab, idx);
}
}
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class CubaTreeTable method iterator.
@Override
@Nonnull
public Iterator<Component> iterator() {
List<Component> additionalConnectors = null;
CubaTreeTableState tableState = getState(false);
if (tableState.presentations != null) {
additionalConnectors = new LinkedList<>();
additionalConnectors.add((Component) tableState.presentations);
}
if (tableState.contextMenu != null) {
if (additionalConnectors == null) {
additionalConnectors = new LinkedList<>();
}
additionalConnectors.add((Component) tableState.contextMenu);
}
if (tableState.customPopup != null) {
if (additionalConnectors == null) {
additionalConnectors = new LinkedList<>();
}
additionalConnectors.add((Component) tableState.customPopup);
}
if (additionalConnectors == null) {
return super.iterator();
} else if (_visibleComponents() != null) {
return Iterables.concat(_visibleComponents(), additionalConnectors).iterator();
} else {
return additionalConnectors.iterator();
}
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class DDAccordion method getTransferable.
/**
* {@inheritDoc}
*/
public Transferable getTransferable(Map<String, Object> rawVariables) {
if (rawVariables.get("index") != null) {
int index = Integer.parseInt(rawVariables.get("index").toString());
Iterator<Component> iter = getComponentIterator();
int counter = 0;
Component c = null;
while (iter.hasNext()) {
c = iter.next();
if (counter == index) {
break;
}
counter++;
}
rawVariables.put("component", c);
} else if (rawVariables.get("component") == null) {
rawVariables.put("component", DDAccordion.this);
}
return new LayoutBoundTransferable(this, rawVariables);
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class CubaMainTabSheet method silentCloseTabAndSelectPrevious.
public void silentCloseTabAndSelectPrevious(Component tab) {
while (openedComponents.removeElement(tab)) {
openedComponents.removeElement(tab);
}
if ((!openedComponents.empty()) && (_selected().equals(tab))) {
Component c = openedComponents.pop();
while (!_components().contains(c) && !openedComponents.isEmpty()) {
c = openedComponents.pop();
}
setSelectedTab(c);
}
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class CubaUI method isAccessibleForUser.
/**
* Check if users can interact with the component - there are no modal windows that prevent user action.
*
* @param component component
* @return whether it accessible or not
*/
public boolean isAccessibleForUser(Component component) {
Collection<Window> windows = this.getWindows();
if (windows.isEmpty()) {
// there are no windows - all components are accessible
return true;
}
boolean hasModalWindows = windows.stream().anyMatch(Window::isModal);
if (!hasModalWindows) {
// there are no modal windows - all components are accessible
return true;
}
Component windowOrUI = CubaUIUtils.getWindowOrUI(component);
if (windowOrUI == null) {
// something went wrong
return false;
}
if (windowOrUI instanceof UI) {
// there are modal windows, component belongs to UI
return false;
}
if (windowOrUI instanceof Window) {
Window currentWindow = (Window) windowOrUI;
if (!currentWindow.isModal()) {
// there are modal windows, component belongs to non-modal window
return false;
}
// CAUTION we cannot sort windows in UI, because they are ordered only on client side
}
// we cannot reliably check if access is permitted
return true;
}
Aggregations