List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(String width)
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the info layout.//from ww w. j ava 2s.c o m */ private void createInfoLayout() { infoLayout = new VerticalLayout(); infoLayout.addStyleName("infoLayout"); infoLayout.setWidth(PANEL_SPLIT_X, Unit.PIXELS); infoLayout.setSpacing(true); addComponent(infoLayout); final HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.addStyleName("panelHeaderLayout"); headerLayout.setWidth("100%"); headerLayout.setSpacing(true); headerLayout.setMargin(new MarginInfo(false, true, false, true)); infoLayout.addComponent(headerLayout); nameLabel = new Label(); nameLabel.addStyleName("nameLabel"); nameLabel.setSizeUndefined(); headerLayout.addComponent(nameLabel); headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); final Button editButton = new Button("Edit"); editButton.setEnabled(false); headerLayout.addComponent(editButton); headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT); // this will become the editing function of what properties are displayed in the info layout /*** final Button saveButton = new Button("Done"); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { nameField = new TextField(); nameField.setImmediate(true); nameField.setValue(nameLabel.getValue()); nameField.setWidth("12em"); nameField.focus(); nameField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { saveButton.click(); } }); headerLayout.replaceComponent(nameLabel, nameField); headerLayout.setComponentAlignment(nameField, Alignment.MIDDLE_LEFT); headerLayout.replaceComponent(editButton, saveButton); headerLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { String name = nameField.getValue(); nameLabel.setValue(name); headerLayout.replaceComponent(nameField, nameLabel); headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); headerLayout.replaceComponent(saveButton, editButton); headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT); lastComponent.setName(name); if (lastComponent instanceof NodeInfo) { //((NodeInfo) lastComponent).saveName(name); } else if (lastComponent instanceof SystemRecord) { //systemInfo.saveName(name); } ComponentButton componentButton = lastComponent.getButton(); componentButton.setName(name); } }); ***/ systemLabels = new Label[systemLabelsStrings.length]; systemGrid = createCurrentInfo(systemLabels, systemLabelsStrings); nodeLabels = new Label[nodeLabelsStrings.length]; nodeGrid = createCurrentInfo(nodeLabels, nodeLabelsStrings); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout.// w w w .j ava 2s .c o m */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:com.skysql.manager.ui.SystemDialog.java
License:Open Source License
/** * Instantiates a new system dialog./* w w w. ja v a 2 s . c o m*/ * * @param systemRecord the system record * @param button the button */ public SystemDialog(final SystemRecord systemRecord, final ComponentButton button) { this.button = button; String windowTitle = (systemRecord != null) ? "Edit System: " + systemRecord.getName() : "Add System"; dialogWindow = new ModalWindow(windowTitle, "350px"); dialogWindow.addCloseListener(this); UI.getCurrent().addWindow(dialogWindow); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth("100%"); wrapper.setMargin(true); buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); commitButton = new Button(); if (systemRecord == null) { this.systemRecord = new SystemRecord(SystemInfo.SYSTEM_ROOT); systemForm = new SystemForm(this.systemRecord, "Add a System", commitButton); saveSystem("Add System"); } else { this.systemRecord = systemRecord; systemForm = new SystemForm(systemRecord, "Edit an existing System", commitButton); saveSystem("Save Changes"); } wrapper.addComponent(systemForm); }
From source file:com.skysql.manager.ui.UserDialog.java
License:Open Source License
/** * Instantiates a new user dialog./* www . jav a2 s . c o m*/ * * @param userInfo the user info * @param userObject the user object * @param usersSettings the users settings */ public UserDialog(final UserInfo userInfo, final UserObject userObject, final UsersSettings usersSettings) { this.userInfo = userInfo; this.usersSettings = usersSettings; String windowTitle = (userObject != null) ? "Edit User: " + userObject.getName() : "Add User"; dialogWindow = new ModalWindow(windowTitle, "350px"); dialogWindow.addCloseListener(this); UI.getCurrent().addWindow(dialogWindow); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth("100%"); wrapper.setMargin(true); buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); commitButton = new Button(); if (userObject == null) { isAdding = true; this.userObject = new UserObject(); userForm = new UserForm(userInfo, this.userObject, "Add a new User", commitButton); saveUser("Add User"); } else { this.userObject = userObject; userForm = new UserForm(userInfo, userObject, "Edit an existing User", commitButton); saveUser("Save Changes"); } wrapper.addComponent(userForm); }
From source file:com.skysql.manager.ui.WarningWindow.java
License:Open Source License
/** * Instantiates a new warning window.//from w ww .java 2s .c o m * * @param caption the caption * @param message the message * @param label the label * @param okListener the ok listener */ public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) { super(caption, "60%"); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth("100%"); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/warning.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setSizeFull(); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); Label msgLabel = new Label(message); msgLabel.addStyleName("warning"); textLayout.addComponent(msgLabel); textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { warningWindow.close(); } }); Button okButton = new Button(label); okButton.addClickListener(okListener); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) this.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); }
From source file:com.squadd.chat.ChatController.java
public static HorizontalLayout createDateLayout(ChatMessage mess) { HorizontalLayout dateLayout = new HorizontalLayout(); Label dateLabel = new Label(mess.getFormattedDate()); dateLabel.addStyleName("dateLabel"); dateLayout.addComponent(dateLabel);/*from w w w .ja va2 s . co m*/ dateLayout.setWidth("100px"); dateLayout.setHeight("50px"); return dateLayout; }
From source file:com.squadd.UI.ChatAndParticipantsLayout.java
public ChatAndParticipantsLayout(Group group) { Label label = new Label("Participants"); label.setSizeUndefined();/*from w w w . j a v a2 s .co m*/ HorizontalLayout hor = new HorizontalLayout(); hor.setWidth(0.67 * Display.width + "px"); hor.addComponent(label); hor.setComponentAlignment(label, Alignment.TOP_CENTER); parts.setWidth(0.68 * Display.width + "px"); parts.setContent(hor); parts.setStyleName("backColorGrey"); Label label1 = new Label("Group Chat"); label1.setSizeUndefined(); HorizontalLayout hor1 = new HorizontalLayout(); hor1.setWidth(0.67 * Display.width + "px"); hor1.addComponent(label); hor1.setComponentAlignment(label, Alignment.TOP_CENTER); grChat.setWidth(0.68 * Display.width + "px"); grChat.setContent(hor); grChat.setStyleName("backColorGrey"); }
From source file:com.squadd.UI.EditVersionLayout.java
private void buildLayout() { HorizontalLayout knopki = new HorizontalLayout(save, cancel); knopki.setSizeUndefined();/*from www.j a va 2 s .c o m*/ knopki.setSpacing(true); HorizontalLayout hor = new HorizontalLayout(knopki); hor.setWidth(0.4 * Display.width + "px"); hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT); FormLayout data = new FormLayout(groupName, placeName, date, description); HorizontalLayout first = new HorizontalLayout(); groupPhoto.setWidth(0.2 * Display.width + "px"); groupPhoto.setHeight(0.2 * Display.width + "px"); first.addComponent(groupPhoto); VerticalLayout lst = new VerticalLayout(); lst.setSpacing(true); lst.addComponents(hor, data); HorizontalLayout uploadAndUsers = new HorizontalLayout(uploadPhoto); uploadAndUsers.setWidth(0.2 * Display.width + "px"); uploadPhoto.setSizeUndefined(); uploadAndUsers.setComponentAlignment(uploadPhoto, Alignment.MIDDLE_CENTER); VerticalLayout vert = new VerticalLayout(groupPhoto, uploadAndUsers); HorizontalLayout second = new HorizontalLayout(vert); HorizontalLayout photoAndInfo = new HorizontalLayout(second, lst); addComponent(photoAndInfo); }
From source file:com.squadd.UI.GroupChatLayout.java
public GroupChatLayout(Group group) { name = new Panel(); Label label = new Label("Group Chat"); label.setSizeUndefined();/*from w w w. j a v a2s.com*/ HorizontalLayout hor = new HorizontalLayout(); hor.setWidth(0.67 * Display.width + "px"); hor.addComponent(label); hor.setComponentAlignment(label, Alignment.TOP_CENTER); name.setWidth(0.68 * Display.width + "px"); name.setContent(hor); name.setStyleName("backColorGrey"); message = new TextArea(); msg = new ArrayList(); send = new Button("send"); content = new VerticalLayout(); dateComparator = new Comparator<GroupChat>() { @Override public int compare(GroupChat o1, GroupChat o2) { return -o1.getDate().compareTo(o2.getDate()); } }; configureLayout(group); configureActions(group); }
From source file:com.squadd.UI.GroupChatLayout.java
private void configureLayout(Group group) { HorizontalLayout sendL = new HorizontalLayout(message, send); sendL.setWidth(Display.width * 0.68 + "px"); send.setSizeUndefined();// ww w . j av a 2 s. c om message.setWidth(0.61 * Display.width - send.getWidth() + "px"); sendL.setComponentAlignment(send, Alignment.MIDDLE_RIGHT); DBManager db = new DBManager(); List<GroupChat> jb = (ArrayList) db.getAllGroupMessages(group.getGroupId()); Collections.sort(jb, dateComparator); msg = new ArrayList<MessageLayout>(); for (int i = 0; i < jb.size(); ++i) { Label when = new Label(jb.get(i).getDate().toString()); Image photo = new ImageGetter().get(group); Label text = new Label(jb.get(i).getMessage()); msg.add(new MessageLayout(when, photo, text)); } for (int i = 0; i < msg.size(); ++i) { content.addComponent(msg.get(i)); } cont = new VerticalLayout(sendL, content); cont.setVisible(false); VerticalLayout all = new VerticalLayout(name, cont); addComponent(all); }