Search in sources :

Example 41 with Component

use of com.vaadin.ui.Component in project ANNIS by korpling.

the class AdminView method enter.

@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    boolean kickstarter = Helper.isKickstarter(getSession());
    importPanel.updateMode(kickstarter, Helper.getUser() != null);
    // group and user management are not applicable in kickstarter
    tabSheet.getTab(groupManagementPanel).setVisible(!kickstarter);
    tabSheet.getTab(userManagementPanel).setVisible(!kickstarter);
    Component selectedTab = getComponentForFragment(event.getParameters());
    if (selectedTab != null && selectedTab != tabSheet.getSelectedTab()) {
        // Select the component given by the fragment, This will call
        // the selection change handler and thus we don't have
        // to call the listeners here.
        tabSheet.setSelectedTab(selectedTab);
    } else {
        // nothing to change in the tab selection, call the listeners manually
        selectedTab = tabSheet.getSelectedTab();
        for (UIView.Listener l : listeners) {
            l.loadedTab(selectedTab);
        }
        setFragmentParameter(getFragmentForComponent(selectedTab));
    }
}
Also used : UIView(annis.gui.admin.view.UIView) Component(com.vaadin.ui.Component)

Example 42 with Component

use of com.vaadin.ui.Component in project ANNIS by korpling.

the class AdminView method selectedTabChange.

@Override
public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
    Component selected = event.getTabSheet().getSelectedTab();
    for (UIView.Listener l : listeners) {
        l.loadedTab(selected);
    }
    setFragmentParameter(getFragmentForComponent(selected));
}
Also used : UIView(annis.gui.admin.view.UIView) Component(com.vaadin.ui.Component)

Example 43 with Component

use of com.vaadin.ui.Component in project ANNIS by korpling.

the class VisualizerPanel method loadVisualizer.

private void loadVisualizer(final LoadableVisualizer.Callback callback) {
    if (visPlugin != null) {
        btEntry.setIcon(ICON_COLLAPSE);
        progress.setIndeterminate(true);
        progress.setVisible(true);
        progress.setEnabled(true);
        progress.setDescription("Loading visualizer" + visPlugin.getShortName());
        ExecutorService execService = Executors.newSingleThreadExecutor();
        final Future<Component> future = execService.submit(new LoadComponentTask());
        // run the actual code to load the visualizer
        Background.run(new BackgroundJob(future, callback, UI.getCurrent()));
    }
// end if create input was needed
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Component(com.vaadin.ui.Component)

Example 44 with Component

use of com.vaadin.ui.Component in project linkki by linkki-framework.

the class Binder method addFieldBinding.

/**
 * Adds the descriptor and component for the given field to the given map.
 *
 * @param field a Component typed field that is annotated with {@link Bind}
 *
 * @throws IllegalStateException if the field does not hold a component
 * @throws NullPointerException if the component held by the field is {@code null}
 */
private void addFieldBinding(Field field, LinkedHashMap<BindingDescriptor, Component> bindings) {
    Validate.validState(Component.class.isAssignableFrom(field.getType()), "%s is not a Component-typed field and cannot be annotated with @Bind", field);
    try {
        if (!field.isAccessible()) {
            field.setAccessible(true);
        }
        Component component = requireNonNull((Component) field.get(view), () -> "Cannot create binding for field " + field + " as it is null");
        @SuppressWarnings("null") @Nonnull Bind bindAnnotation = field.getAnnotation(Bind.class);
        List<LinkkiAspectDefinition> aspectDefinitions = Arrays.asList(field.getAnnotations()).stream().flatMap(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a).stream()).collect(Collectors.toList());
        BindAnnotationDescriptor descriptor = new BindAnnotationDescriptor(bindAnnotation, aspectDefinitions);
        bindings.put(descriptor, component);
    } catch (IllegalArgumentException | IllegalAccessException e) {
        throw new LinkkiRuntimeException(e);
    }
}
Also used : Arrays(java.util.Arrays) LinkkiAspectDefinition(org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition) AspectAnnotationReader(org.linkki.core.binding.aspect.AspectAnnotationReader) BindingDescriptor(org.linkki.core.ui.section.descriptor.BindingDescriptor) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) Bind(org.linkki.core.binding.annotations.Bind) BeanUtils(org.linkki.util.BeanUtils) InvocationTargetException(java.lang.reflect.InvocationTargetException) LinkedHashMap(java.util.LinkedHashMap) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) List(java.util.List) Validate(org.apache.commons.lang3.Validate) Objects.requireNonNull(java.util.Objects.requireNonNull) LinkkiRuntimeException(org.linkki.core.exception.LinkkiRuntimeException) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) Method(java.lang.reflect.Method) Nonnull(javax.annotation.Nonnull) Component(com.vaadin.ui.Component) Bind(org.linkki.core.binding.annotations.Bind) LinkkiRuntimeException(org.linkki.core.exception.LinkkiRuntimeException) Nonnull(javax.annotation.Nonnull) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) LinkkiAspectDefinition(org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition) Component(com.vaadin.ui.Component)

Example 45 with Component

use of com.vaadin.ui.Component in project linkki by linkki-framework.

the class Binder method addMethodBinding.

/**
 * Adds the descriptor and component (returned by the method) for the given method to the given
 * map.
 *
 * @throws IllegalArgumentException if the method does not return a component or requires
 *             parameters
 * @throws NullPointerException if the component returned by the method is {@code null}
 */
private void addMethodBinding(Method method, LinkedHashMap<BindingDescriptor, Component> bindings) {
    Validate.isAssignableFrom(Component.class, method.getReturnType(), "%s does not return a Component and cannot be annotated with @Bind", method);
    Validate.isTrue(method.getParameterCount() == 0, "%s has parameters and cannot be annotated with @Bind", method);
    try {
        Component component = (Component) method.invoke(view);
        if (component == null) {
            throw new NullPointerException("Cannot create binding for method " + method + " as it returned null");
        }
        @SuppressWarnings("null") @Nonnull Bind bindAnnotation = method.getAnnotation(Bind.class);
        List<LinkkiAspectDefinition> aspectDefinitions = Arrays.asList(method.getAnnotations()).stream().flatMap(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a).stream()).collect(Collectors.toList());
        BindAnnotationDescriptor descriptor = new BindAnnotationDescriptor(bindAnnotation, aspectDefinitions);
        bindings.put(descriptor, component);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new LinkkiRuntimeException(e);
    }
}
Also used : Arrays(java.util.Arrays) LinkkiAspectDefinition(org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition) AspectAnnotationReader(org.linkki.core.binding.aspect.AspectAnnotationReader) BindingDescriptor(org.linkki.core.ui.section.descriptor.BindingDescriptor) LabelComponentWrapper(org.linkki.core.ui.components.LabelComponentWrapper) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) Bind(org.linkki.core.binding.annotations.Bind) BeanUtils(org.linkki.util.BeanUtils) InvocationTargetException(java.lang.reflect.InvocationTargetException) LinkedHashMap(java.util.LinkedHashMap) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) List(java.util.List) Validate(org.apache.commons.lang3.Validate) Objects.requireNonNull(java.util.Objects.requireNonNull) LinkkiRuntimeException(org.linkki.core.exception.LinkkiRuntimeException) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) Method(java.lang.reflect.Method) Nonnull(javax.annotation.Nonnull) Component(com.vaadin.ui.Component) Bind(org.linkki.core.binding.annotations.Bind) Nonnull(javax.annotation.Nonnull) BindAnnotationDescriptor(org.linkki.core.ui.section.descriptor.BindAnnotationDescriptor) InvocationTargetException(java.lang.reflect.InvocationTargetException) LinkkiRuntimeException(org.linkki.core.exception.LinkkiRuntimeException) LinkkiAspectDefinition(org.linkki.core.binding.aspect.definition.LinkkiAspectDefinition) Component(com.vaadin.ui.Component)

Aggregations

Component (com.vaadin.ui.Component)96 HorizontalLayout (com.vaadin.ui.HorizontalLayout)11 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)10 VerticalLayout (com.vaadin.ui.VerticalLayout)10 Button (com.vaadin.ui.Button)9 Label (com.vaadin.ui.Label)9 Test (org.junit.Test)8 Window (com.haulmont.cuba.gui.components.Window)6 CssLayout (com.vaadin.ui.CssLayout)6 List (java.util.List)6 WebWindow (com.haulmont.cuba.web.gui.WebWindow)5 Item (com.vaadin.data.Item)5 ClickEvent (com.vaadin.ui.Button.ClickEvent)5 ClickListener (com.vaadin.ui.Button.ClickListener)5 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)4 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)4 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)4 CubaFileUpload (com.haulmont.cuba.web.toolkit.ui.CubaFileUpload)4 com.vaadin.ui (com.vaadin.ui)4 com.haulmont.cuba.web.toolkit.ui (com.haulmont.cuba.web.toolkit.ui)3