Example usage for com.vaadin.ui VerticalLayout getComponent

List of usage examples for com.vaadin.ui VerticalLayout getComponent

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout getComponent.

Prototype

public Component getComponent(int index) throws IndexOutOfBoundsException 

Source Link

Document

Returns the component at the given position.

Usage

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

/** This is an attempt to put more logic on the server and less into big client updates */
private void updateFollowers_oobTL(Card thisCard) {
    // Easiest to throw everything away and reload, but trying to increase performance here.

    // We've been informed that the parent card has been updated, the most obvious reason being that
    // some one has played a follow on card. Cards are immutable, so the only thing to check is the addition
    // of a new one -- i.e., don't have to worry about updated text or author, etc.
    // The follow-on list in a card is now maintained sorted by Hibernate, so start picking off the top until
    // we get to one we have, then stop; Then add the new ones to the top of the layout

    SortedSet<Card> children = thisCard.getFollowOns();
    //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollowers_oobTL(), num children = " + children.size());

    Vector<Card> newCards = new Vector<Card>();
    for (Card c : children) {
        //MSysOut.println(CARD_UPDATE_LOGS, "next child, id = " + c.getId());
        VerticalLayout vl = getCardColumnLayout(c);
        if (vl != null) {
            int numChil = vl.getComponentCount();
            if (numChil <= 1) {// want to miss header
                newCards.add(c);//from ww  w . ja  va2s  .c o m
            } else {
                CardSummary cs = (CardSummary) vl.getComponent(1);
                //MSysOut.println(CARD_UPDATE_LOGS,"CardChainPage.updateFollers_oobTL(), cs.cardId vs c.getId returns " + cs.getCardId().equals(c.getId()) + " " + cs.getCardId() + " " + c.getId());
                if (!cs.getCardId().equals(c.getId())) {
                    newCards.add(c);
                    //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollers_oobTL(), added card " + c.getId() + " to column");
                    continue; // next card
                } else {
                    //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollers_oobTL(), card " + c.getId() + " already in layout!");
                    break; // the card has been found already in the layout, we're done since they're already sorted
                }
            }
        } else {
            //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollowers_oobTL(), cant find card column for card " + c.getId());
        }
        //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollowers_oobTL(), new cards found: " + newCards.size());
    }

    // If we looked at all and found any new ones, add them to our
    // Add from the bottom
    int sz;
    if ((sz = newCards.size()) > 0) {
        for (int i = sz - 1; i >= 0; i--) {
            Card cd = newCards.get(i);
            VerticalLayout vl = getCardColumnLayout(cd);
            if (vl != null) {
                CardSummary csum = CardSummary.newCardSummary_oobTL(cd.getId());
                //MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.updateFollowers_oobTL(), new card added to layout, id: " + cd.getId());
                vl.addComponent(csum, 1); // under the header
                csum.initGui();
            }
        }
    }
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

@Override
public void drawerOpenedTL(Object cardTypeId) {
    int wcol = 0;
    for (CardType ct : followOnTypes) {

        if (ct.getId() != (Long) cardTypeId) {
            VerticalLayout vl = columnVLs.get(wcol);
            CardSummaryListHeader sumHdr = (CardSummaryListHeader) vl.getComponent(0);
            sumHdr.closeDrawer();//from  w w  w  .  jav  a  2s.  c  om
        }
        wcol++;
    }
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java

License:Open Source License

public boolean cardUpdated_oobTL(Serializable externCardId, long revision) {
    MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.cardUpdated_oobTL() externCardId/rev = " + externCardId
            + "/" + revision + " my cardId = " + cardId + " hash = " + hashCode());

    Card c = Card.getRevisionTL(externCardId, revision);
    if (c == null) // happens under load?
        return false;

    if (externCardId.equals(cardId)) { // Don't do this: externCardId == cardId  !
        MSysOut.println(CARD_UPDATE_LOGS, "CardChainPage.cardUpdated_oobTL / " + c.toString2());
        MSysOut.println(CARD_UPDATE_LOGS,
                "CardChainPage.cardUpdated_oobTL / num children: " + c.getFollowOns().size());
        loadMarkingPanel_oobTL(c);/*from w w  w  .  j a  v a  2 s .c  om*/
        cardLg.update_oobTL(c);
        updateFollowers_oobTL(c);

        for (VerticalLayout vl : columnVLs) {
            CardSummaryListHeader lstHdr = (CardSummaryListHeader) vl.getComponent(0);
            lstHdr.cardUpdated_oobTL();
        }
        return true; // ui
    } else
        return isDescendent(c); // child might have hidden or edited
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragGrabFilterDemo.java

License:Apache License

private Panel createCompositeChild(String caption) {
    Panel compositePanel = new Panel();
    compositePanel.setWidthUndefined();//from  ww  w  .j  ava2  s  . c om
    compositePanel.setCaption("Composite Widget " + caption);

    VerticalLayout content = new VerticalLayout();
    content.setWidthUndefined();
    compositePanel.setContent(content);

    content.addComponent(new Label("Grab me to drag Panel"));
    content.addComponent(new Button("Cannot be grabbed"));
    content.addComponent(new TextField("Cannot be grabbed TextField"));
    content.addComponent(new Label("Grab me too!"));

    for (int i = 0; i < content.getComponentCount(); i++) {
        content.getComponent(i).setWidth(100, Unit.PERCENTAGE);
    }

    return compositePanel;
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java

License:BSD License

@SuppressWarnings("unchecked")
@Override//from  w  w  w . j a v a 2s.  c  o  m
public void setEditable(boolean editable) {
    Collection<Long> itemIds = (Collection<Long>) this.getItemIds();

    Iterator<Long> itemIdsIter = itemIds.iterator();

    while (itemIdsIter.hasNext()) {
        Item item = this.getItem(itemIdsIter.next());
        Property<VerticalLayout> property = item.getItemProperty("Source Configuration Value");
        VerticalLayout layout = property.getValue();

        for (int i = 0; i < layout.getComponentCount(); i++) {
            ((TextField) layout.getComponent(i)).setReadOnly(!editable);
        }

        Property<TextField> targetProperty = item.getItemProperty("Target Configuration Value");
        targetProperty.getValue().setReadOnly(!editable);
    }

    super.setEditable(editable);
}

From source file:org.jdal.vaadin.ui.form.SimpleBoxFormBuilder.java

License:Apache License

/**
 * Builds the panel form.//  www  .j a v  a 2  s  .  co m
 * @return the form component
 */
public Component getForm() {

    for (int i = 0; i < columns.size(); i++) {
        VerticalLayout box = columns.get(i);
        int width = columnsWidth.get(i);

        if (width > SIZE_UNDEFINED && width < SIZE_FULL) {
            box.setWidth(width, Unit.PIXELS);
            // shrink container
            container.setExpandRatio(box, 0);
        } else if (width == SIZE_FULL) {
            box.setWidth("100%");
            container.setExpandRatio(box, 1);
        } else {
            container.setExpandRatio(box, 0);
            box.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS);
        }

        for (int j = 0; j < rowsHeight.size(); j++) {
            Component c = box.getComponent(j);
            int height = rowsHeight.get(j);

            if (height > SIZE_UNDEFINED && height < SIZE_FULL) {
                c.setHeight(height, Unit.PIXELS);
                box.setExpandRatio(c, 0);
            } else if (height == SIZE_FULL) {
                c.setHeight("100%");
                box.setExpandRatio(c, 1);
            } else {
                box.setExpandRatio(c, 0);
            }
        }
    }

    if (fixedHeight) {
        container.setHeight(getFormHeight(), Unit.PIXELS);
    } else {
        container.setHeight(100, Unit.PERCENTAGE);
    }

    if (fixedWidth) {
        container.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PIXELS);
    } else {
        container.setWidth(100, Unit.PERCENTAGE);
    }

    container.addStyleName("jd-box");

    if (debug)
        container.addStyleName("jd-box-debug");

    return container;
}

From source file:org.opennms.features.vaadin.config.EventAdminApplication.java

License:Open Source License

@Override
public void init(VaadinRequest request) {
    if (eventProxy == null)
        throw new RuntimeException("eventProxy cannot be null.");
    if (eventConfDao == null)
        throw new RuntimeException("eventConfDao cannot be null.");

    final VerticalLayout layout = new VerticalLayout();

    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.setMargin(true);/*  w w w  .  j  av a  2  s.  c om*/

    final Label comboLabel = new Label("Select Events Configuration File");
    toolbar.addComponent(comboLabel);
    toolbar.setComponentAlignment(comboLabel, Alignment.MIDDLE_LEFT);

    final File eventsDir = new File(ConfigFileConstants.getFilePathString(), "events");
    final XmlFileContainer container = new XmlFileContainer(eventsDir, true);
    container.addExcludeFile("default.events.xml"); // This is a protected file, should not be updated.
    final ComboBox eventSource = new ComboBox();
    toolbar.addComponent(eventSource);
    eventSource.setImmediate(true);
    eventSource.setNullSelectionAllowed(false);
    eventSource.setContainerDataSource(container);
    eventSource.setItemCaptionPropertyId(FilesystemContainer.PROPERTY_NAME);
    eventSource.addValueChangeListener(new ComboBox.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            final File file = (File) event.getProperty().getValue();
            if (file == null)
                return;
            try {
                LOG.info("Loading events from {}", file);
                final Events events = JaxbUtils.unmarshal(Events.class, file);
                addEventPanel(layout, file, events);
            } catch (Exception e) {
                LOG.error("an error ocurred while saving the event configuration {}: {}", file, e.getMessage(),
                        e);
                Notification.show("Can't parse file " + file + " because " + e.getMessage());
            }
        }
    });

    final Button add = new Button("Add New Events File");
    toolbar.addComponent(add);
    add.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            PromptWindow w = new PromptWindow("New Events Configuration", "Events File Name") {
                @Override
                public void textFieldChanged(String fieldValue) {
                    final File file = new File(eventsDir, normalizeFilename(fieldValue));
                    LOG.info("Adding new events file {}", file);
                    final Events events = new Events();
                    addEventPanel(layout, file, events);
                }
            };
            addWindow(w);
        }
    });

    final Button remove = new Button("Remove Selected Events File");
    toolbar.addComponent(remove);
    remove.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (eventSource.getValue() == null) {
                Notification.show("Please select an event configuration file.");
                return;
            }
            final File file = (File) eventSource.getValue();
            ConfirmDialog.show(getUI(), "Are you sure?", "Do you really want to remove the file "
                    + file.getName()
                    + "?\nThis cannot be undone and OpenNMS won't be able to handle the events configured on this file.",
                    "Yes", "No", new ConfirmDialog.Listener() {
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                LOG.info("deleting file {}", file);
                                if (file.delete()) {
                                    try {
                                        // Updating eventconf.xml
                                        boolean modified = false;
                                        File configFile = ConfigFileConstants
                                                .getFile(ConfigFileConstants.EVENT_CONF_FILE_NAME);
                                        Events config = JaxbUtils.unmarshal(Events.class, configFile);
                                        for (Iterator<String> it = config.getEventFileCollection()
                                                .iterator(); it.hasNext();) {
                                            String fileName = it.next();
                                            if (file.getAbsolutePath().contains(fileName)) {
                                                it.remove();
                                                modified = true;
                                            }
                                        }
                                        if (modified) {
                                            JaxbUtils.marshal(config, new FileWriter(configFile));
                                            EventBuilder eb = new EventBuilder(
                                                    EventConstants.EVENTSCONFIG_CHANGED_EVENT_UEI, "WebUI");
                                            eventProxy.send(eb.getEvent());
                                        }
                                        // Updating UI Components
                                        eventSource.select(null);
                                        if (layout.getComponentCount() > 1)
                                            layout.removeComponent(layout.getComponent(1));
                                    } catch (Exception e) {
                                        LOG.error("an error ocurred while saving the event configuration: {}",
                                                e.getMessage(), e);
                                        Notification.show("Can't save event configuration. " + e.getMessage(),
                                                Notification.Type.ERROR_MESSAGE);
                                    }
                                } else {
                                    Notification.show("Cannot delete file " + file,
                                            Notification.Type.WARNING_MESSAGE);
                                }
                            }
                        }
                    });
        }
    });

    layout.addComponent(toolbar);
    layout.addComponent(new Label(""));
    layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT);

    setContent(layout);
}

From source file:org.opennms.features.vaadin.config.EventAdminApplication.java

License:Open Source License

/**
 * Removes the event panel.//w ww  . ja v  a  2 s  . c  o m
 *
 * @param layout the layout
 */
private void removeEventPanel(final VerticalLayout layout) {
    if (layout.getComponentCount() > 1)
        layout.removeComponent(layout.getComponent(1));
}

From source file:org.opennms.features.vaadin.mibcompiler.MibConsolePanel.java

License:Open Source License

/**
 * Scroll into view./*from w w w.ja v  a2s  . c o m*/
 */
private void scrollIntoView() {
    final VerticalLayout layout = (VerticalLayout) getContent();
    if (getUI() != null && layout.getComponentCount() > 0)
        getUI().scrollIntoView(layout.getComponent(layout.getComponentCount() - 1));
}

From source file:ru.codeinside.gses.webui.declarant.DeclarantFactory.java

License:Mozilla Public License

public static Component create() {

    // TODO: ??   ??!
    final ServiceQueryDefinition amSQ = new ServiceQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amSC = new LazyQueryContainer(amSQ, new ServiceQueryFactory(false));
    final ProcedureQueryDefinition amPQ = new ProcedureQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amPC = new LazyQueryContainer(amPQ,
            new ProcedureQueryFactory(Flash.login(), false));

    final ProcedureQueryDefinition mmQ = new ProcedureQueryDefinition(ProcedureType.Interdepartmental);
    final LazyQueryContainer mmC = new LazyQueryContainer(mmQ, new ProcedureQueryFactory(Flash.login(), false));

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//  w w w  .jav a 2 s. com
    layout.setMargin(true);
    final Label header = new Label(
            " ?  ?? ?? ?");
    header.addStyleName("h1");
    layout.addComponent(header);

    final Select amS = new Select("", amPC);
    String selectWidth = "400px";
    amS.setWidth(selectWidth);
    amS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amS.setItemCaptionPropertyId("name");
    amS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amS.setNullSelectionAllowed(true);
    amS.setNewItemsAllowed(false);
    amS.setImmediate(true);

    final Select amSS = new Select("?", amSC);
    amSS.setWidth(selectWidth);
    amSS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amSS.setItemCaptionPropertyId("name");
    amSS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amSS.setNullSelectionAllowed(true);
    amSS.setNewItemsAllowed(false);
    amSS.setImmediate(true);

    final FormLayout amLayout = new FormLayout();

    final Panel amPanel = new Panel();
    amLayout.addComponent(amSS);
    amLayout.addComponent(amS);
    amPanel.addComponent(amLayout);

    final Select mmS = new Select("", mmC);
    mmS.setFilteringMode(Select.FILTERINGMODE_OFF);
    mmS.setWidth(selectWidth);
    mmS.setItemCaptionPropertyId("name");
    mmS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    mmS.setNullSelectionAllowed(true);
    mmS.setNewItemsAllowed(false);
    mmS.setImmediate(true);

    final FormLayout mmLayout = new FormLayout();
    final Panel mmPanel = new Panel();
    //    mmLayout.addComponent(mmSS);
    mmLayout.addComponent(mmS);
    mmPanel.addComponent(mmLayout);

    final VerticalLayout amWrapper = new VerticalLayout();
    amWrapper.setSizeFull();
    amWrapper.addComponent(amPanel);

    final VerticalLayout imWrapper = new VerticalLayout();
    imWrapper.setSizeFull();
    imWrapper.addComponent(mmPanel);

    final TabSheet typeSheet = new TabSheet();
    typeSheet.setSizeFull();
    typeSheet.addTab(amWrapper, "?? ");
    typeSheet.addTab(imWrapper, "? ");
    layout.addComponent(typeSheet);
    layout.setExpandRatio(typeSheet, 1);

    // 

    amSS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                amPQ.serviceId = -1;
            } else {
                amPQ.serviceId = (Long) amSC.getItem(prop.getValue()).getItemProperty("id").getValue();
            }
            amS.select(null);
            amPC.refresh();
        }
    });

    final ProcedureSelectListener administrativeProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (amWrapper.getComponentCount() > 1) {
                amWrapper.removeComponent(amWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    amWrapper.addComponent(cmp);
                    amWrapper.setExpandRatio(cmp, 1f);
                } else {
                    amS.select(null);
                    amPC.refresh();
                    amSC.refresh();
                }
            }
        }
    };
    final ProcedureSelectListener interdepartamentalProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (imWrapper.getComponentCount() > 1) {
                imWrapper.removeComponent(imWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    imWrapper.addComponent(cmp);
                    imWrapper.setExpandRatio(cmp, 1f);
                }
            }
        }
    };
    amS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) amPC.getItem(itemId).getItemProperty("id").getValue();
            administrativeProcedureSelectListener.selectProcedure(procedureId);
        }
    });
    mmS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) mmC.getItem(itemId).getItemProperty("id").getValue();
            interdepartamentalProcedureSelectListener.selectProcedure(procedureId);
        }
    });

    return layout;
}