Example usage for com.vaadin.ui AbstractComponent getData

List of usage examples for com.vaadin.ui AbstractComponent getData

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractComponent getData.

Prototype

public Object getData() 

Source Link

Document

Gets the application specific data.

Usage

From source file:com.github.peholmst.mvp4vaadin.navigation.ui.NavigationBar.java

License:Apache License

@Override
public void currentViewChanged(ViewController source, ControllableView oldView, ControllableView newView,
        Direction direction, boolean newViewIsTopMost) {
    if (source != viewController) {
        return;//from w  w w .jav a2 s  .  c  o  m
    }
    if (!newViewIsTopMost) {
        /*
         * The view is already in the bread crumbs, so we just have to check
         * if there are any views at the end that need to be removed
         */
        ControllableView lastView = source.getTrail().get(source.getTrail().size() - 1);
        Iterator<Component> it = components.descendingIterator();
        while (it.hasNext()) {
            AbstractComponent c = (AbstractComponent) it.next();
            if (c.getData() == lastView) {
                break;
            } else {
                it.remove();
            }
        }
        requestRepaint();
    } else {
        if (direction.equals(Direction.FORWARD)) {
            // Add another button to the bread crumbs
            addBreadcrumbForView(newView);
        } else if (direction.equals(Direction.BACKWARD)) {
            // Remove buttons from the end of the bread crumbs until we
            // reach the new view
            Iterator<Component> it = components.descendingIterator();
            while (it.hasNext()) {
                AbstractComponent c = (AbstractComponent) it.next();
                if (c.getData() == newView) {
                    break;
                } else {
                    it.remove();
                }
            }
            requestRepaint();
        }
    }
}

From source file:org.abstractform.binding.vaadin.internal.VaadinBindingFormInstanceImpl.java

License:Apache License

@Override
public Object getFieldValue(String fieldId) {
    AbstractComponent component = (AbstractComponent) getComponentById(fieldId);
    VaadinDataObject dataObject = (VaadinDataObject) component.getData();
    return dataObject.getAccessor().getFieldValue(this, component);
}

From source file:org.abstractform.binding.vaadin.internal.VaadinBindingFormInstanceImpl.java

License:Apache License

@Override
public void setFieldValue(String fieldId, Object value) {
    AbstractComponent component = (AbstractComponent) getComponentById(fieldId);
    VaadinDataObject dataObject = (VaadinDataObject) component.getData();
    dataObject.getAccessor().setFieldValue(this, component, value);
}

From source file:org.abstractform.binding.vaadin.VaadinBindingFormToolkit.java

License:Apache License

private void replaceFormInstanceReferences(VaadinFormInstance delegate, VaadinBindingFormInstance<?> real) {
    for (String fieldId : delegate.getFieldIds()) {
        AbstractComponent component = delegate.getComponentById(fieldId);
        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) {
                    final Container.Viewer viewer = (Container.Viewer) component;
                    SelectorProviderFactory factory = (SelectorProviderFactory) field
                            .getExtra(SelectorConstants.EXTRA_SELECTOR_PROVIDER_FACTORY);
                    final VaadinSelectorContainer container = new VaadinSelectorContainer(
                            factory.createSelectorProvider(real));

                    if (viewer instanceof AbstractSelect) {
                        final AbstractSelect abstractSelect = (AbstractSelect) viewer;
                        container.addListener(new Container.ItemSetChangeListener() {

                            @Override
                            public void containerItemSetChange(ItemSetChangeEvent event) {
                                boolean readOnly = abstractSelect.isReadOnly();
                                abstractSelect.setReadOnly(false);
                                abstractSelect.sanitizeSelection();
                                abstractSelect.setReadOnly(readOnly);
                            }/*from w  w  w  .j ava 2 s. c o m*/

                        });
                        viewer.setContainerDataSource(container);
                    }
                }
            }
        }
    }
}

From source file:org.abstractform.vaadin.VaadinFormToolkit.java

License:Apache License

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)));
                }/*from ww w.  ja  v  a2s .  co m*/
            }
        }
    }

}

From source file:org.apache.ace.webui.vaadin.component.ConfirmationDialog.java

License:Apache License

/**
 * @see com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.Button.ClickEvent)
 *//*from w w w  . j  av a 2 s .c  o  m*/
public void buttonClick(ClickEvent event) {
    Window parent = getParent();
    if (parent != null) {
        parent.removeWindow(this);
        parent.focus();
    }

    AbstractComponent comp = (AbstractComponent) event.getComponent();
    m_callback.onDialogResult((String) comp.getData());
}

From source file:org.eclipse.emf.ecp.controls.vaadin.AbstractVaadinSimpleControlRenderer.java

License:Open Source License

private Component getBindingComponent(Component component) {
    if (!(component instanceof AbstractComponent)) {
        return component;

    }/*from   w  w  w.j  a  v  a  2  s . c o  m*/
    final AbstractComponent abstractComponent = (AbstractComponent) component;
    return (Component) (abstractComponent.getData() == null ? component : abstractComponent.getData());

}

From source file:org.eclipse.emf.ecp.view.core.vaadin.AbstractVaadinRenderer.java

License:Open Source License

/**
 * Returns the control for the caption./*from  ww  w. j  a  v  a 2 s. c  o  m*/
 *
 * @param component the parent component
 * @return the caption component
 */
protected Component getCaptionControlComponent(Component component) {
    if (!(component instanceof AbstractComponent)) {
        return component;
    }
    final AbstractComponent abstractComponent = (AbstractComponent) component;
    if (abstractComponent.getData() instanceof Component) {
        return (Component) abstractComponent.getData();
    }
    return component;
}

From source file:org.lucidj.explorer.ExplorerView.java

License:Apache License

private void build_explorer_view() {
    setMargin(true);// w ww.  ja va  2s . com
    setSpacing(true);

    List<Map<String, Object>> components = new ArrayList<>();

    if (System.getProperty("user.conf") != null) {
        components.add(new_component("My Home", System.getProperty("user.home"), "places/user-home"));
    }
    components.add(new_component("My Files", userdir.toString(), "places/folder"));
    components.add(new_component("LucidJ Home", System.getProperty("system.home"), "places/folder-script"));
    components.add(new_component("Applications", System.getProperty("system.home") + "/system/apps",
            "apps/preferences-desktop-icons"));

    //        components.add (new_component ("Your Unbelievable Projects", "org.Buga", "places/folder-development"));
    //        components.add (new_component ("Strange Project", "org.Buga", "some awkward thing"));

    Panel bookmarks = new Panel("Bookmarks");
    bookmarks.setWidth(100, Unit.PERCENTAGE);
    ObjectRenderer component_renderer = rendererFactory.newRenderer(components);
    bookmarks.setContent(component_renderer);
    bookmarks.setWidth(100, Unit.PERCENTAGE);
    addComponent(bookmarks);

    component_renderer.addListener(new Listener() {
        @Override
        public void componentEvent(Event event) {
            log.info("[EVENT] ====> {}", event);

            if (event instanceof LayoutEvents.LayoutClickEvent) {
                LayoutEvents.LayoutClickEvent layoutClickEvent = (LayoutEvents.LayoutClickEvent) event;

                if (layoutClickEvent.isDoubleClick()) {
                    log.info("**--DOUBLE-CLICK--** component => {}", layoutClickEvent.getClickedComponent());
                    fireEvent(layoutClickEvent);
                }
            } else if (event instanceof Button.ClickEvent) {
                Button.ClickEvent clickEvent = (Button.ClickEvent) event;

                log.info("**--CLICK--** CLICK! component = {}", clickEvent.getButton());
                AbstractComponent c = clickEvent.getButton();

                if (c.getData() instanceof Map) {
                    Map<String, Object> data = (Map<String, Object>) c.getData();
                    log.info("Component Data = {}", data);

                    if (data.containsKey("directory")) {
                        log.info("---> BROWSE DIR: {}", data.get("directory"));
                        view_directory(data);
                    }
                }
            }
        }
    });

    HorizontalLayout browse_and_shortcuts = new HorizontalLayout();
    browse_and_shortcuts.setWidth(100, Unit.PERCENTAGE);
    browse_and_shortcuts.setSpacing(true);

    browse_files = new Panel("Your files");
    browse_files.setWidth(100, Unit.PERCENTAGE);

    // Show the first directory
    view_directory(components.get(0));

    browse_and_shortcuts.addComponent(browse_files);

    VerticalLayout shortcuts = new VerticalLayout();
    shortcuts.setSpacing(true);

    Panel today_last_opened = new_shortcuts_panel("Today");
    shortcuts.addComponent(today_last_opened);

    Panel this_week_last_opened = new_shortcuts_panel("Yesterday");
    shortcuts.addComponent(this_week_last_opened);

    Panel full_history = new_shortcuts_panel("History");
    shortcuts.addComponent(full_history);

    browse_and_shortcuts.addComponent(shortcuts);
    addComponent(browse_and_shortcuts);
}

From source file:org.lucidj.iconlist.renderer.IconListRenderer.java

License:Apache License

private void update_components() {
    // Delete all excess vaadin components
    for (int index = getComponentCount() - 1; index >= 0; index--) {
        AbstractComponent c = (AbstractComponent) getComponent(index);

        if (!source.contains(c.getData())) {
            removeComponent(c);//from  w  w w.j  a v  a 2  s  .co m
        }
    }

    // Add all missing vaadin components
    for (int index = 0; index < source.size(); index++) {
        Map<String, Object> component_object = source.get(index);

        if (!component_to_vaadin.containsKey(component_object)) {
            addComponent(create_icon(component_object), index);
        }
    }
}