@Override public void init() { LegacyWindow w = new LegacyWindow(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); GridLayout gl = new GridLayout(4, 2); Button button = new Button( "1", new ClickListener() { @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); l.setValue(l.getValue() + b.getCaption()); } }); gl.addComponent(l, 0, 0, 3, 0); gl.addComponent(button); gl.addComponent(new Label("2")); gl.addComponent(new Label("3")); gl.addComponent(new Label("4")); w.setContent(gl); }
/** * Adds a new browser level window to this application. Please note that UI doesn't have a name * that is used in the URL - to add a named window you should instead use {@link #addWindow(UI, * String)} * * @param uI the UI window to add to the application * @return returns the name that has been assigned to the window * @see #addWindow(UI, String) */ public void addWindow(LegacyWindow uI) { if (uI.getName() == null) { String name = Integer.toString(namelessUIIndex++); uI.setName(name); } uI.setApplication(this); legacyUINames.put(uI.getName(), uI); uI.setSession(VaadinSession.getCurrent()); }
public void close() { isRunning = false; Collection<LegacyWindow> windows = getWindows(); for (LegacyWindow legacyWindow : windows) { String logoutUrl = getLogoutURL(); if (logoutUrl == null) { URL url = getURL(); if (url != null) { logoutUrl = url.toString(); } } if (logoutUrl != null) { legacyWindow.getPage().setLocation(logoutUrl); } legacyWindow.close(); } }
@Override public void init() { LegacyWindow main = new LegacyWindow("Testing...."); setMainWindow(main); final VerticalLayout lo = new VerticalLayout(); lo.setSizeUndefined(); lo.setWidth("100%"); TextArea tf = new TextArea(); tf.setValue( "The textfield should fill the window." + "\n - Try to resize window\n - Try to push REdo button"); tf.setRows(10); tf.setWidth("100%"); lo.addComponent(tf); Window subWin = new Window("This window should initially be as wide as the caption", lo); main.addWindow(subWin); // subWin.setWidth("500px"); }
@Override public void init() { LegacyWindow main = new LegacyWindow(); setMainWindow(main); ComboBox combobox = new ComboBox("My ComboBox"); // Enable null selection combobox.setNullSelectionAllowed(true); // Add the item that marks 'null' value String nullitem = "-- none --"; combobox.addItem(nullitem); // Designate it was the 'null' value marker combobox.setNullSelectionItemId(nullitem); // Add some other items for (int i = 0; i < 10; i++) { combobox.addItem("Item " + i); } main.addComponent(combobox); }
/** * Sets the main window of this application. Setting window as a main window of this application * also adds the window to this application. * * @param mainWindow the UI to set as the default window */ public void setMainWindow(LegacyWindow mainWindow) { if (this.mainWindow != null) { throw new IllegalStateException("mainWindow has already been set"); } if (mainWindow.isAttached()) { throw new IllegalStateException("mainWindow is attached to another application"); } if (UI.getCurrent() == null) { // Assume setting a main window from Application.init if there's // no current UI -> set the main window as the current UI UI.setCurrent(mainWindow); } addWindow(mainWindow); this.mainWindow = mainWindow; }
@Override public void init() { setMainWindow(main); setTheme("reindeer"); themeToggle = new CheckBox("Runo theme"); themeToggle.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (getTheme() == "reindeer") { setTheme("runo"); } else { setTheme("reindeer"); } } }); themeToggle.setStyleName("small"); themeToggle.setImmediate(true); styleToggle = new CheckBox("Black style"); styleToggle.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (!main.getContent().getStyleName().contains("black")) { main.getContent().setStyleName("black"); } else { main.getContent().setStyleName(""); } } }); styleToggle.setImmediate(true); styleToggle.setStyleName("small"); iconToggle = new CheckBox("64x icons"); iconToggle.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { largeIcons = !largeIcons; recreateAll(); } }); iconToggle.setImmediate(true); iconToggle.setStyleName("small"); nativeToggle = new CheckBox("Native buttons"); nativeToggle.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { nativeButtons = !nativeButtons; recreateAll(); } }); nativeToggle.setImmediate(true); nativeToggle.setStyleName("small"); toggles.setSpacing(true); toggles.addComponent(themeToggle); toggles.addComponent(styleToggle); toggles.addComponent(iconToggle); toggles.addComponent(nativeToggle); main.addComponent(toggles); recreateAll(); }
private void recreateAll() { main.removeAllComponents(); main.addComponent(toggles); main.addComponent(buildButtons(false, false, false, false)); main.addComponent(buildButtons(false, false, true, false)); main.addComponent(buildButtons(false, true, false, false)); main.addComponent(buildButtons(false, true, true, false)); main.addComponent(buildButtons(true, false, false, false)); main.addComponent(buildButtons(true, false, true, false)); main.addComponent(buildButtons(true, true, false, false)); main.addComponent(buildButtons(true, true, true, false)); main.addComponent(buildButtons(false, false, false, true)); main.addComponent(buildButtons(false, false, true, true)); main.addComponent(buildButtons(false, true, false, true)); main.addComponent(buildButtons(false, true, true, true)); main.addComponent(buildButtons(true, false, false, true)); main.addComponent(buildButtons(true, false, true, true)); main.addComponent(buildButtons(true, true, false, true)); main.addComponent(buildButtons(true, true, true, true)); final Button b = new Button("Tabindex"); b.setTabIndex(1); main.addComponent(b); Button c = new Button( "toggle enabled", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { b.setEnabled(!b.isEnabled()); } }); main.addComponent(c); }