Example usage for com.vaadin.ui Component setWidth

List of usage examples for com.vaadin.ui Component setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Component setWidth.

Prototype

public void setWidth(String width);

Source Link

Document

Sets the width of the component using String presentation.

Usage

From source file:com.esofthead.mycollab.vaadin.ui.GridFormLayoutHelper.java

License:Open Source License

public void addComponentNoWrapper(final Component field, final String caption, final int columns,
        final int rows) {
    if (caption != null) {
        final Label l = new Label(caption);
        l.setWidth(this.defaultCaptionWidth);
        this.layout.addComponent(l, 2 * columns, rows);
        this.layout.setComponentAlignment(l, this.captionAlignment);
    }/*  w  ww. ja v a  2  s . c  o m*/
    if (!(field instanceof Button))
        field.setCaption(null);

    if (field instanceof MultiSelectComp) {
        field.setWidth("200px");
    } else {
        field.setWidth(fieldControlWidth);
    }

    this.layout.addComponent(field, 2 * columns + 1, rows);
    this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f);
}

From source file:com.esofthead.mycollab.vaadin.ui.VerticalTabsheet.java

License:Open Source License

public void setNavigatorWidth(String width) {
    navigatorContainer.setWidth(width);/*from w ww. j a  va  2s.  c o m*/
    Iterator<Component> i = navigatorContainer.iterator();
    while (i.hasNext()) {
        Component childComponent = i.next();
        childComponent.setWidth(width);
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.grid.GridCellWrapper.java

License:Open Source License

public void addComponent(Component component) {
    if (!(component instanceof Button))
        component.setCaption(null);//from   www  .  j a va2  s .c om

    if (component instanceof MultiSelectComp) {
        component.setWidth("200px");
    } else if (component instanceof AbstractTextField || component instanceof RichTextArea) {
        component.setWidth("100%");
    }
    super.addComponent(component);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.OptionPopupContent.java

License:Open Source License

public void addDangerOption(Component btn) {
    CssLayout wrap = new CssLayout();
    btn.setWidth("100%");
    btn.addStyleName("action");
    wrap.addStyleName("action-wrap danger");
    wrap.addComponent(btn);//  w w w  . j  av a2  s.  c o m
    ((ComponentContainer) this.getCompositionRoot()).addComponent(wrap);
}

From source file:com.foc.vaadin.FocCentralPanel.java

License:Apache License

protected void adjustToFullScreen(ICentralPanel newCentralPanel, boolean fullScreen) {
    //Panel-Vertical

    if (newCentralPanel != null && newCentralPanel instanceof Component) {
        if (fullScreen) {
            centralPanel.setContent((Component) newCentralPanel);
            centralPanel.markAsDirty();/*w  ww  .j a  va 2 s  .c o  m*/
            ((Component) newCentralPanel).setWidth("100%");
            //getCentralPanelWrapper().setWidth("100%");
        } else {
            Component newCentralPanleComponent = (Component) newCentralPanel;

            HorizontalLayout wrapperOfCentralLayout = new HorizontalLayout();
            wrapperOfCentralLayout.addComponent(newCentralPanleComponent);
            wrapperOfCentralLayout.setComponentAlignment(newCentralPanleComponent, Alignment.TOP_CENTER);
            centralPanel.setContent(wrapperOfCentralLayout);
            centralPanel.markAsDirty();
            newCentralPanleComponent.setWidth(WIDTH_PORTRAIT);
            wrapperOfCentralLayout.setWidth("100%");

            //Apply same style to the wrapper
            if (newCentralPanleComponent instanceof FocXMLLayout) {
                Component firstComp = ((FocXMLLayout) newCentralPanleComponent).getFirstRootComponent();
                if (firstComp != null && firstComp instanceof FocXMLGuiComponent) {
                    Attributes attrib = ((FocXMLGuiComponent) firstComp).getAttributes();

                    String style = attrib != null ? attrib.getValue(FXML.ATT_STYLE) : null;
                    if (style != null) {
                        FocXMLGuiComponentStatic.applyStyle(wrapperOfCentralLayout, style);
                    }
                }
            }

            //            centralPanel.setContent((Component) newCentralPanel);
            //            centralPanel.markAsDirty();
            //            ((Component)newCentralPanel).setWidth(WIDTH_PORTRAIT);
        }
    }
}

From source file:com.foc.vaadin.gui.components.TableTreeDelegate.java

License:Apache License

public Component newGuiComponent(FocObject focObject, FVTableColumn tableColumn, FProperty property) {
    Component component = null;
    if (property != null) {
        FocXMLLayout xmlLayout = getFocXMLLayout();
        if (xmlLayout != null) {

            String tableName = getTableName();
            String objRef = focObject.getReference().toString();
            String columnName = tableColumn.getName();

            String compName = newComponentName(tableName, objRef, columnName);
            component = xmlLayout.getComponentByName(compName);

            boolean createANewConmponent = component == null;
            if (!createANewConmponent) {
                FocXMLGuiComponent xmlGuiComp = (FocXMLGuiComponent) component;
                String componentXMLType = xmlGuiComp.getXMLType();
                String newComponentXMLType = FVGUIFactory.getInstance().getKeyForProperty(property);

                if (componentXMLType != null && newComponentXMLType != null
                        && !newComponentXMLType.equals(componentXMLType)) {
                    createANewConmponent = true;
                }//  w w  w .j  a  v a2  s  . co m
            }

            if (createANewConmponent) {
                component = xmlLayout.newGuiField(compName, focObject, tableColumn.getDataPath(), property,
                        tableColumn.getAttributes());
            }
            //We want the default width to be 100% for the component so that the resizing of the component is automatic with the column  
            if (tableColumn.getAttributes() != null
                    && tableColumn.getAttributes().getValue(FXML.ATT_WIDTH) == null) {
                component.setWidth("100%");
            }

            /*
            if(itemClickListener == null){
               itemClickListener = new Listener() {
                  @Override
                  public void componentEvent(Event event) {
             if(event != null && event.getComponent() != null && event.getComponent() instanceof FocXMLGuiComponent){
                FocXMLGuiComponentDelegate delegate = ((FocXMLGuiComponent)event.getComponent()).getDelegate();
                if(delegate != null){
                   lastClickedFocDataByPath = ((FocXMLGuiComponent)event.getComponent()).getDelegate().getDataPath();
                }
             }
                  }
               }; 
            }
                    
            component.addListener(itemClickListener);
            */
        }

        /*
         * FocXMLGuiComponent guiField =
         * FVFieldFactory.getInstance().newGuiComponent(property, null);
         * AbstractComponent component = (AbstractComponent) guiField;
         */
    }
    return component;
}

From source file:com.foc.vaadin.gui.FocXMLGuiComponentStatic.java

License:Apache License

public static void applyAttributes_WidthHeight(Component component, Attributes attributes) {
    if (attributes != null) {
        try {//from w w w .  j a  v  a  2  s  .c  o m
            String width = attributes.getValue(FXML.ATT_WIDTH);
            if (width != null) {
                component.setWidth(width);
                //01-Dec-15 when we set table height or width we need to set it to wrapper layout too
                if (component instanceof FVTable) {
                }
                //01-Dec-15
            }

            String height = attributes.getValue(FXML.ATT_HEIGHT);
            if (height != null) {
                component.setHeight(height);
                //hadi 01-Dec-15
                if (component instanceof FVTable) {
                    FVTable table = (FVTable) component;
                    if (table.getTableTreeDelegate() != null
                            && table.getTableTreeDelegate().getWrapperLayout() != null) {
                        table.getTableTreeDelegate().getWrapperLayout().setHeight(height);
                    }
                }
                //hadi 01-Dec-15
            }
        } catch (Exception e) {
            Globals.logException(e);
        }
    }
}

From source file:com.foc.vaadin.gui.FVGuiComponent.java

License:Apache License

public static void applyCommonAttributes(Component component, Attributes attributes) {
    String width = attributes.getValue(FXML.ATT_WIDTH);
    if (width != null)
        component.setWidth(width);

    String height = attributes.getValue(FXML.ATT_HEIGHT);
    if (height != null)
        component.setHeight(height);//from ww w  .j  a va2  s  .  c  om

    String text = attributes.getValue(FXML.ATT_CAPTION);
    String captPos = attributes.getValue(FXML.ATT_CAPTION_POSITION);

    if (captPos != null) {
        if (text != null && !captPos.equals("left") && !captPos.equals("right"))
            component.setCaption(text);
    } else {
        if (text != null)
            component.setCaption(text);
    }
}

From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java

License:Apache License

@Override
public Word[] getWords() {
    return new Word[] {

            new BaseWord("new-button", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2492817908731559368L;

                @Override/*from   w w  w .  j a v  a 2s  .  com*/
                public void execute(final Interpreter interpreter) {

                    Button b = new Button("", new Button.ClickListener() {
                        private static final long serialVersionUID = -4622489800920283752L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            Button b = event.getButton();
                            Word command = (Word) b.getData();
                            if (command != null) {
                                interpreter.execute(command);
                            }
                        }
                    });
                    interpreter.pushData(b);
                }
            },

            new BaseWord("set-click-listener", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5749856686458297558L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Button b = (Button) interpreter.popData();
                    b.setData(o);
                    interpreter.pushData(b);
                }
            },

            new BaseWord("new-hl", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8813556668649386248L;

                @Override
                public void execute(Interpreter interpreter) {
                    HorizontalLayout hl = new HorizontalLayout();
                    hl.setSpacing(true);
                    interpreter.pushData(hl);
                }
            },

            new BaseWord("new-vl", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1848213448504804229L;

                @Override
                public void execute(Interpreter interpreter) {
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) {

                private static final long serialVersionUID = 4079634885691605257L;

                @Override
                public void execute(Interpreter interpreter) {
                    Integer height = (Integer) interpreter.popData();
                    Integer width = (Integer) interpreter.popData();
                    interpreter.pushData(new GridLayout(width, height));
                }
            },

            new BaseWord("gl-new-line", "", Word.POSTPONED) {

                private static final long serialVersionUID = 975877390052961807L;

                @Override
                public void execute(Interpreter interpreter) {
                    ((GridLayout) interpreter.peekData()).newLine();
                }
            },

            new BaseWord("new-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6887364362728545090L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = new Window();
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    w.setContent(vl);
                    interpreter.pushData(w);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("main-panel", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8622281600566696475L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(interpreter.getMainPanel());
                }
            },

            new BaseWord("add-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = 7106029415576813922L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = (Window) interpreter.popData();
                    interpreter.getView().getUI().addWindow(w);
                }
            },

            new BaseWord("add-component", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5640824046985354091L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.addComponent(comp);
                    interpreter.pushData(cc);
                }
            },

            new BaseWord("set-caption", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5497598050469462487L;

                @Override
                public void execute(Interpreter interpreter) {
                    String s = (String) interpreter.popData();
                    Component c = (Component) interpreter.popData();
                    c.setCaption(s);
                    interpreter.pushData(c);
                }
            },

            new BaseWord("set-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1769743552659215058L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Property p = (Property) interpreter.popData();
                    p.setValue(o);
                    interpreter.pushData(p);
                }
            },

            new BaseWord("get-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8445550546521886374L;

                @Override
                public void execute(Interpreter interpreter) {
                    Field f = (Field) interpreter.popData();
                    interpreter.pushData(f);
                    interpreter.pushData(f.getValue());

                }
            },

            new BaseWord("set-size-full", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1206491811133054467L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeFull();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-size-undefined", "", Word.POSTPONED) {

                private static final long serialVersionUID = -3450618729379622987L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeUndefined();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-height", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8426734568403715950L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setHeight(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-width", "", Word.POSTPONED) {

                private static final long serialVersionUID = -4558264143049463814L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setWidth(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("clear-container", "", Word.POSTPONED) {

                private static final long serialVersionUID = 1070175466682034329L;

                @Override
                public void execute(Interpreter interpreter) {
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.removeAllComponents();
                }
            },

            new BaseWord("new-check-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 4018632924389912599L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new CheckBox());
                }
            },

            new BaseWord("new-date-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = 6313296566085274642L;

                @Override
                public void execute(final Interpreter interpreter) {
                    interpreter.pushData(new DateField());
                    final String dfCommand = (String) interpreter.popData();
                    DateField df = new DateField();
                    df.setImmediate(true);
                    df.addValueChangeListener(new ValueChangeListener() {
                        /**
                        * 
                        */
                        private static final long serialVersionUID = 1472139878970514093L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(dfCommand);
                        }

                    });
                    interpreter.pushData(df);
                }
            },

            new BaseWord("new-label", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2825285195439247251L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new Label());
                }
            },

            new BaseWord("new-text-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1064489458253275380L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tfCommand = interpreter.getNextNonNopWord();
                    TextField tf = new TextField();
                    tf.setCaption((String) interpreter.popData());
                    tf.setValue("");
                    tf.setImmediate(true);
                    tf.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = 4325104922208051065L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(tfCommand);
                        }
                    });
                    interpreter.pushData(tf);
                }
            },

            new BaseWord("new-table", "", Word.POSTPONED) {

                private static final long serialVersionUID = -5052653341575232035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tableCommand = interpreter.getParser().getNextWord();
                    Table table = new Table();
                    table.setCaption((String) interpreter.popData());
                    table.setImmediate(true);
                    table.setSelectable(true);
                    table.addItemClickListener(new ItemClickListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3585546076571010729L;

                        public void itemClick(ItemClickEvent event) {

                            interpreter.pushData(event.getItem());
                            interpreter.execute(interpreter.getDictionary().get(tableCommand));
                        }
                    });
                    interpreter.pushData(table);
                }
            },

            new BaseWord("new-combo-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 3881577354424928897L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String newItemCommand = interpreter.getParser().getNextWord();
                    final String itemSelectedCommand = interpreter.getParser().getNextWord();
                    final ComboBox cb = new ComboBox();
                    String str = (String) interpreter.popData();
                    cb.setNullSelectionAllowed(false);
                    cb.setCaption(str);
                    cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    cb.setNewItemsAllowed(true);
                    cb.setNewItemHandler(new NewItemHandler() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3340658590351611289L;

                        public void addNewItem(String newItemCaption) {
                            cb.setImmediate(false);
                            interpreter.pushData(newItemCaption);
                            interpreter.interpret(newItemCommand);
                            cb.setImmediate(true);
                        }
                    });

                    cb.addValueChangeListener(new ValueChangeListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 2706579869793251379L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(
                                    cb.getContainerDataSource().getItem(event.getProperty().getValue()));
                            interpreter.interpret(itemSelectedCommand);
                        }
                    });
                    cb.setImmediate(true);
                    interpreter.pushData(cb);
                }
            },

            new BaseWord("new-select", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6142351970812196488L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String selCommand = interpreter.getParser().getNextWord();
                    final ComboBox sel = new ComboBox();
                    sel.setCaption((String) interpreter.popData());
                    sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    sel.setNullSelectionAllowed(false);
                    sel.setImmediate(true);
                    sel.addValueChangeListener(new ValueChangeListener() {
                        /**
                        *
                        */
                        private static final long serialVersionUID = -7705548618092166199L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(selCommand);
                        }
                    });
                    interpreter.pushData(sel);
                }
            },

            new BaseWord("new-list-select", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8686093227035249035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String lselCommand = interpreter.getParser().getNextWord();
                    final ListSelect lsel = new ListSelect();
                    lsel.setCaption((String) interpreter.popData());
                    lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    lsel.setNullSelectionAllowed(false);
                    lsel.setImmediate(true);
                    lsel.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = -5523488417834167806L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(lselCommand);
                        }
                    });
                    interpreter.pushData(lsel);
                }
            },

            new BaseWord("set-container-data-source", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8644721936358613031L;

                @Override
                public void execute(Interpreter interpreter) {
                    Container cont = (Container) interpreter.popData();
                    AbstractSelect as = (AbstractSelect) interpreter.popData();
                    as.setContainerDataSource(cont);
                    interpreter.pushData(as);
                }
            },

            new BaseWord("set-column-headers", "", Word.POSTPONED) {
                private static final long serialVersionUID = -7296881714369214846L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0]));
                }
            },

            new BaseWord("set-visible-columns", "", Word.POSTPONED) {
                private static final long serialVersionUID = 5674765074478598320L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0]));
                }
            }

    };
}

From source file:com.haulmont.cuba.web.app.folders.CubaFoldersPane.java

License:Apache License

protected void setupSearchFoldersPane(Component searchFoldersPane) {
    searchFoldersPane.setHeight("100%");
    searchFoldersPane.setWidth("100%");
    if (isNeedFoldersTitle()) {
        searchFoldersLabel = new Label(messages.getMainMessage("folders.searchFoldersRoot"));
        searchFoldersLabel.setStyleName("c-folders-pane-caption");
    } else {//from  www.ja v a  2s  .c o  m
        searchFoldersLabel = null;
    }
}