List of usage examples for com.vaadin.ui GridLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupToutAutorise.java
License:Open Source License
/** * Permet de dessiner le tableau /*from w w w .j av a2 s . c om*/ */ public void drawTab(Tab tab) { GridLayout gl = new GridLayout(3, 1 + tab.lines.size()); gl.setWidth("600px"); gl.setSpacing(false); contentLayout.addComponent(gl); // Construction du titre Label l = new Label(tab.titre); l.addStyleName(tab.styleTitre); l.setWidth("100%"); gl.addComponent(l, 0, 0, 2, 0); List<TabLine> lines = tab.lines; for (int i = 0; i < lines.size(); i++) { TabLine line = lines.get(i); int height = computeHeight(line); // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire height = Math.max(height, 36); Label l1 = new Label(line.col1); l1.addStyleName(line.styleCol1); l1.setWidth("100%"); l1.setHeight(height + "px"); gl.addComponent(l1, 0, i + 1); Label l2 = new Label(line.col2); l2.addStyleName(line.styleCol2); l2.setWidth("100%"); l2.setHeight(height + "px"); gl.addComponent(l2, 1, i + 1); if (line.col3 != null) { Button b = new Button(line.col3); b.addStyleName(line.styleCol3); b.addClickListener(e -> handleButton(line.cell)); b.setWidth("100%"); gl.addComponent(b, 2, i + 1); gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER); } else { Label l3 = new Label(""); l3.addStyleName(line.styleCol3); l3.setWidth("100%"); l3.setHeight(height + "px"); gl.addComponent(l3, 2, i + 1); } } }
From source file:fr.amapj.view.views.saisiecontrat.PopupSaisieJoker.java
License:Open Source License
@Override protected void createContent(VerticalLayout contentLayout) { String msg = getTitre(abo.dateJokers.size()); titre = new Label(msg, ContentMode.HTML); contentLayout.addComponent(titre);//from ww w . j a v a 2s. c o m GridLayout gl = new GridLayout(3, contratDTO.jokerNbMax); gl.setMargin(true); gl.setSpacing(true); SimpleDateFormat df = FormatUtils.getFullDate(); for (int i = 0; i < contratDTO.jokerNbMax; i++) { ContratLigDTO dateJoker = (i < abo.dateJokers.size()) ? abo.dateJokers.get(i) : null; boolean isModifiable = isModifiable(dateJoker); // Label l1 = new Label("Joker " + (i + 1)); l1.setWidth("80px"); gl.addComponent(l1, 0, i); // if (isModifiable && readOnly == false) { ComboBox box = createComboBox(dateJoker, df); box.setWidth("220px"); gl.addComponent(box, 1, i); combos.add(box); } else { String caption = dateJoker == null ? "Non utilis" : df.format(dateJoker.date); gl.addComponent(new Label(caption), 1, i); if (dateJoker != null) { nonModifiableJokers.add(dateJoker); } } String l3msg = isModifiable ? "" : " (Non modifiable)"; Label l3 = new Label(l3msg); gl.addComponent(l3, 2, i); } contentLayout.addComponent(gl); }
From source file:fr.univlorraine.mondossierweb.views.windows.FiltreInscritsMobileWindow.java
License:Apache License
/** * Cre une fentre/*ww w .j a v a 2s. c o m*/ */ public FiltreInscritsMobileWindow() { setWidth("95%"); setModal(true); setResizable(false); setClosable(true); setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); setStyleName("v-popover-blank"); typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits(); GridLayout layout = new GridLayout(1, 2); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(true); setContent(layout); //Si on affiche la liste des inscrits un ELP //on doit affiche l'tape d'appartenance et ventuellement les groupes //Affichage d'une liste droulante contenant la liste des annes if (typeIsElp()) { //GESTION DES ETAPES List<VersionEtape> letapes = MdwTouchkitUI.getCurrent().getListeEtapesInscrits(); if (letapes != null && letapes.size() > 0) { Label etapeLabel = new Label(applicationContext.getMessage(NAME + ".etape", null, getLocale())); layout.addComponent(etapeLabel); layout.setComponentAlignment(etapeLabel, Alignment.BOTTOM_LEFT); listeEtapes = new NativeSelect(); listeEtapes.setNullSelectionAllowed(false); listeEtapes.setRequired(false); listeEtapes.setWidth("100%"); listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL); listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL); for (VersionEtape etape : letapes) { String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet(); listeEtapes.addItem(idEtape); listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet()); } if (MdwTouchkitUI.getCurrent().getEtapeInscrits() != null) { listeEtapes.setValue(MdwTouchkitUI.getCurrent().getEtapeInscrits()); } else { listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL); } //Gestion de l'vnement sur le changement d'tape listeEtapes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { vetSelectionnee = (String) event.getProperty().getValue(); if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } MdwTouchkitUI.getCurrent().setEtapeInscrits(vetSelectionnee); //faire le changement groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null) ? (String) listeGroupes.getValue() : null); if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } //update de l'affichage //initListe(); } }); layout.addComponent(listeEtapes); } //GESTION DES GROUPES List<ElpDeCollection> lgroupes = MdwTouchkitUI.getCurrent().getListeGroupesInscrits(); if (lgroupes != null && lgroupes.size() > 0) { // Label "GROUPE" HorizontalLayout gLayout = new HorizontalLayout(); gLayout.setSizeFull(); Label groupeLabel = new Label(applicationContext.getMessage(NAME + ".groupe", null, getLocale())); gLayout.addComponent(groupeLabel); gLayout.setComponentAlignment(groupeLabel, Alignment.MIDDLE_LEFT); layout.addComponent(gLayout); //Liste droulante pour choisir le groupe listeGroupes = new NativeSelect(); listeGroupes.setNullSelectionAllowed(false); listeGroupes.setRequired(false); listeGroupes.setWidth("100%"); listeGroupes.addItem(TOUS_LES_GROUPES_LABEL); listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL); for (ElpDeCollection edc : lgroupes) { for (CollectionDeGroupes cdg : edc.getListeCollection()) { for (Groupe groupe : cdg.getListeGroupes()) { listeGroupes.addItem(groupe.getCleGroupe()); listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe()); } } } //On pr-remplie le groupe choisi si on en a dj choisi un if (MdwTouchkitUI.getCurrent().getGroupeInscrits() != null) { listeGroupes.setValue(MdwTouchkitUI.getCurrent().getGroupeInscrits()); } else { listeGroupes.setValue(TOUS_LES_GROUPES_LABEL); } //Gestion de l'vnement sur le changement de groupe listeGroupes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { groupeSelectionne = (String) event.getProperty().getValue(); if (groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } MdwTouchkitUI.getCurrent().setGroupeInscrits(groupeSelectionne); //faire le changement vetSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null) ? (String) listeEtapes.getValue() : null); if (vetSelectionnee != null && vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } } }); layout.addComponent(listeGroupes); } } // Bouton "Filtrer" HorizontalLayout bLayout = new HorizontalLayout(); bLayout.setSizeFull(); Button closeButton = new Button(applicationContext.getMessage(NAME + ".filtrerBtn", null, getLocale())); closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY); closeButton.addStyleName("v-popover-button"); demandeFiltrage = false; closeButton.addClickListener(e -> { //retourner vetSelectionnee et groupeSelectionne; demandeFiltrage = true; close(); }); bLayout.addComponent(closeButton); bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER); layout.addComponent(bLayout); }
From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java
public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker, final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes, final NodeType nodeType) { super("Add New Node"); setModal(true);/*ww w .j av a2 s . co m*/ setWidth(650, Unit.PIXELS); setHeight(450, Unit.PIXELS); GridLayout content = new GridLayout(1, 3); content.setSizeFull(); content.setMargin(true); content.setSpacing(true); HorizontalLayout topContent = new HorizontalLayout(); topContent.setSpacing(true); content.addComponent(topContent); topContent.addComponent(new Label("Nodes:")); final ComboBox hadoopNodes = new ComboBox(); hadoopNodes.setId("HadoopNodesCb"); hadoopNodes.setImmediate(true); hadoopNodes.setTextInputAllowed(false); hadoopNodes.setNullSelectionAllowed(false); hadoopNodes.setRequired(true); hadoopNodes.setWidth(200, Unit.PIXELS); for (EnvironmentContainerHost node : nodes) { hadoopNodes.addItem(node); hadoopNodes.setItemCaption(node, node.getHostname()); } if (nodes.size() == 0) { return; } hadoopNodes.setValue(nodes.iterator().next()); topContent.addComponent(hadoopNodes); final Button addNodeBtn = new Button("Add"); addNodeBtn.setId("AddSelectedNode"); topContent.addComponent(addNodeBtn); final Button ok = new Button("Ok"); addNodeBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addNodeBtn.setEnabled(false); ok.setEnabled(false); showProgress(); EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue(); final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), nodeType); executorService.execute(new Runnable() { public void run() { while (track) { TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY, trackID); if (po != null) { setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n" + po.getLog()); if (po.getState() != OperationState.RUNNING) { hideProgress(); ok.setEnabled(true); break; } } else { setOutput("Product operation not found. Check logs"); break; } try { Thread.sleep(1000); } catch (InterruptedException ex) { break; } } } }); } }); outputTxtArea = new TextArea("Operation output"); outputTxtArea.setId("outputTxtArea"); outputTxtArea.setRows(13); outputTxtArea.setColumns(43); outputTxtArea.setImmediate(true); outputTxtArea.setWordwrap(true); content.addComponent(outputTxtArea); indicator = new Label(); indicator.setId("indicator"); indicator.setIcon(new ThemeResource("img/spinner.gif")); indicator.setContentMode(ContentMode.HTML); indicator.setHeight(11, Unit.PIXELS); indicator.setWidth(50, Unit.PIXELS); indicator.setVisible(false); ok.setId("btnOk"); ok.setStyleName("default"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //close window track = false; close(); } }); HorizontalLayout bottomContent = new HorizontalLayout(); bottomContent.addComponent(indicator); bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT); bottomContent.addComponent(ok); content.addComponent(bottomContent); content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT); setContent(content); }
From source file:io.subutai.plugin.accumulo.ui.wizard.VerificationStep.java
public VerificationStep(final Accumulo accumulo, final Hadoop hadoop, final ExecutorService executorService, final Tracker tracker, EnvironmentManager environmentManager, final Wizard wizard) { setSizeFull();/*from w ww. j a v a 2 s . com*/ GridLayout grid = new GridLayout(1, 5); grid.setSpacing(true); grid.setMargin(true); grid.setSizeFull(); Label confirmationLbl = new Label("<strong>Please verify the installation settings " + "(you may change them by clicking on Back button)</strong><br/>"); confirmationLbl.setContentMode(ContentMode.HTML); ConfigView cfgView = new ConfigView("Installation configuration"); cfgView.addStringCfg("Cluster Name", wizard.getConfig().getClusterName()); cfgView.addStringCfg("Instance name", wizard.getConfig().getInstanceName()); cfgView.addStringCfg("Password", wizard.getConfig().getPassword()); cfgView.addStringCfg("Hadoop cluster", wizard.getConfig().getHadoopClusterName()); cfgView.addStringCfg("Zookeeper cluster", wizard.getConfig().getZookeeperClusterName()); if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { try { Environment hadoopEnvironment = environmentManager.loadEnvironment( hadoop.getCluster(wizard.getConfig().getHadoopClusterName()).getEnvironmentId()); EnvironmentContainerHost master = hadoopEnvironment .getContainerHostById(wizard.getConfig().getMasterNode()); EnvironmentContainerHost gc = hadoopEnvironment .getContainerHostById(wizard.getConfig().getGcNode()); EnvironmentContainerHost monitor = hadoopEnvironment .getContainerHostById(wizard.getConfig().getMonitor()); Set<EnvironmentContainerHost> tracers = hadoopEnvironment .getContainerHostsByIds(wizard.getConfig().getTracers()); Set<EnvironmentContainerHost> slaves = hadoopEnvironment .getContainerHostsByIds(wizard.getConfig().getSlaves()); cfgView.addStringCfg("Master node", master.getHostname()); cfgView.addStringCfg("GC node", gc.getHostname()); cfgView.addStringCfg("Monitor node", monitor.getHostname()); for (EnvironmentContainerHost containerHost : tracers) { cfgView.addStringCfg("Tracers", containerHost.getHostname()); } for (EnvironmentContainerHost containerHost : slaves) { cfgView.addStringCfg("Slaves", containerHost.getHostname()); } } catch (EnvironmentNotFoundException | ContainerHostNotFoundException e) { LOGGER.error("Error applying operations on environment/container", e); } } else { cfgView.addStringCfg("Number of Hadoop slaves", wizard.getHadoopClusterConfig().getCountOfSlaveNodes() + ""); cfgView.addStringCfg("Hadoop replication factor", wizard.getHadoopClusterConfig().getReplicationFactor() + ""); cfgView.addStringCfg("Hadoop domain name", wizard.getHadoopClusterConfig().getDomainName() + ""); cfgView.addStringCfg("Number of tracers", wizard.getConfig().getNumberOfTracers() + ""); cfgView.addStringCfg("Number of slaves", wizard.getConfig().getNumberOfSlaves() + ""); } Button install = new Button("Install"); install.setId("installBtn"); install.addStyleName("default"); install.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UUID trackID; if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { trackID = accumulo.installCluster(wizard.getConfig()); } else { trackID = accumulo.installCluster(wizard.getConfig()); } ProgressWindow window = new ProgressWindow(executorService, tracker, trackID, AccumuloClusterConfig.PRODUCT_KEY); window.getWindow().addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent closeEvent) { wizard.init(); } }); getUI().addWindow(window.getWindow()); } }); Button back = new Button("Back"); back.setId("verBack"); back.addStyleName("default"); back.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.back(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(back); buttons.addComponent(install); grid.addComponent(confirmationLbl, 0, 0); grid.addComponent(cfgView.getCfgTable(), 0, 1, 0, 3); grid.addComponent(buttons, 0, 4); setContent(grid); }
From source file:io.subutai.plugin.accumulo.ui.wizard.WelcomeStep.java
public WelcomeStep(final Wizard wizard) { setSizeFull();/*from w w w .j a v a 2 s .co m*/ GridLayout grid = new GridLayout(10, 6); grid.setSpacing(true); grid.setMargin(true); grid.setSizeFull(); Label welcomeMsg = new Label("<center><h2>Welcome to Accumulo Installation Wizard!</h2>"); welcomeMsg.setContentMode(ContentMode.HTML); grid.addComponent(welcomeMsg, 3, 1, 6, 2); Label logoImg = new Label(); // Image as a file resource logoImg.setIcon(new FileResource(FileUtil.getFile(AccumuloPortalModule.MODULE_IMAGE, this))); logoImg.setContentMode(ContentMode.HTML); logoImg.setHeight(56, Unit.PIXELS); logoImg.setWidth(220, Unit.PIXELS); grid.addComponent(logoImg, 1, 3, 2, 5); Button startOverHadoopNZK = new Button("Start over Hadoop & ZK installation"); startOverHadoopNZK.setId("startOverHadoopNZK"); startOverHadoopNZK.addStyleName("default"); grid.addComponent(startOverHadoopNZK, 4, 4, 4, 4); grid.setComponentAlignment(startOverHadoopNZK, Alignment.BOTTOM_RIGHT); startOverHadoopNZK.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.init(); wizard.getConfig().setSetupType(SetupType.OVER_HADOOP_N_ZK); wizard.next(); } }); setContent(grid); }
From source file:life.qbic.components.qOfferManager.java
License:Open Source License
private void init() { DBManager.setCredentials();//from ww w.j ava 2s . c om DBManager.getDatabaseInstance(); db = Database.Instance; managerTabs = new TabSheet(); /* System.out.println(ft.format(dNow) + " INFO Offer Manager accessed! - User: " + LiferayAndVaadinUtils.getUser().getScreenName());*/ managerTabs.addStyleName(ValoTheme.TABSHEET_FRAMED); managerTabs.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS); final GridLayout gridLayout = new GridLayout(6, 6); gridLayout.setMargin(true); gridLayout.setSpacing(true); try { managerTabs.addTab(createOfferGeneratorTab(), "Offer Generator"); managerTabs.addTab(createOfferManagerTab(), "Offer Manager"); managerTabs.addTab(createPackageManagerTab(), "Package Manager"); managerTabs.setSelectedTab(1); // show the offer manager first, since this will probably be mostly in use // TODO: make this more elegant // if one changes the tab e.g. from the offer manager to the package manager, creates a new package and goes // back to the offer manager tab, the package won't be updated -> workaround: // since the selected offer in the offer manager grid won't requery the database for the information needed, we // deselect the current offer (if any has been selected), so the user has to select the offer again -> information // for the database is queried again and e.g. the newly created packages are shown properly) managerTabs.addSelectedTabChangeListener((TabSheet.SelectedTabChangeListener) event -> { OfferManagerTab.getOfferManagerGrid().deselectAll(); OfferManagerTab.getDetailsLayout().removeAllComponents(); }); } catch (SQLException e1) { e1.printStackTrace(); } try { gridLayout.addComponent(managerTabs, 0, 1, 5, 1); } catch (OverlapsException | OutOfBoundsException e) { e.printStackTrace(); } gridLayout.setSizeFull(); setCompositionRoot(gridLayout); }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
License:Open Source License
public AdminAuthView() { setSizeFull();//from w w w . j a v a2 s .c om VerticalLayout header = new VerticalLayout(); header.setSizeFull(); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); addComponents(header, content); setExpandRatio(header, 1); setExpandRatio(content, 6); welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>"); welcomeText.setContentMode(ContentMode.HTML); welcomeText.setSizeUndefined(); header.addComponent(welcomeText); header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER); Panel controlPanel = new Panel("Administrator control panel"); controlPanel.setSizeUndefined(); Panel addCoordPanel = new Panel("Create a new coordinator"); addCoordPanel.setSizeUndefined(); Panel messagesPanel = new Panel("Administrator messages"); messagesPanel.setWidth("580px"); Table adminMessagesTable = new Table(); adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource()); adminMessagesTable.setColumnWidth("inputEvent", 180); adminMessagesTable.setSizeFull(); VerticalLayout controlLayout = new VerticalLayout(controlPanel); controlLayout.setSizeFull(); controlLayout.setMargin(false); controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER); VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel); coordOperationsLayout.setSizeFull(); coordOperationsLayout.setMargin(false); coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER); /******************************************/ coordOperationsLayout.setVisible(true); // main layout in the middle addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator" /******************************************/ HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel); VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable); messagesExternalLayout.setSizeFull(); messagesExternalLayout.setMargin(false); messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER); messagesInternalLayout.setMargin(false); messagesInternalLayout.setSizeFull(); messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER); messagesPanel.setContent(messagesInternalLayout); TextField idCoordAdd = new TextField(); TextField loginCoord = new TextField(); PasswordField pwdCoord = new PasswordField(); Label idCaptionAdd = new Label("ID"); Label loginCaption = new Label("Login"); Label pwdCaption = new Label("Password"); idCaptionAdd.setSizeUndefined(); idCoordAdd.setSizeUndefined(); loginCaption.setSizeUndefined(); loginCoord.setSizeUndefined(); pwdCaption.setSizeUndefined(); pwdCoord.setSizeUndefined(); Button validateNewCoord = new Button("Validate"); validateNewCoord.setClickShortcut(KeyCode.ENTER); validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY); GridLayout addCoordinatorLayout = new GridLayout(2, 4); addCoordinatorLayout.setSpacing(true); addCoordinatorLayout.setMargin(true); addCoordinatorLayout.setSizeFull(); addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption, pwdCoord); addCoordinatorLayout.addComponent(validateNewCoord, 1, 3); addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT); addCoordPanel.setContent(addCoordinatorLayout); content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setExpandRatio(controlLayout, 20); content.setExpandRatio(coordOperationsLayout, 10); content.setExpandRatio(messagesExternalLayout, 28); Button addCoordinator = new Button("Add coordinator"); Button deleteCoordinator = new Button("Delete coordinator"); addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE); VerticalLayout buttons = new VerticalLayout(); buttons.setMargin(true); buttons.setSpacing(true); buttons.setSizeFull(); buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlPanel.setContent(buttons); buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn); /******* DELETE COORDINATOR PANEL BEGIN *********/ Label idCaptionDel = new Label("ID"); TextField idCoordDel = new TextField(); Panel delCoordPanel = new Panel("Delete a coordinator"); coordOperationsLayout.addComponent(delCoordPanel); delCoordPanel.setVisible(false); coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER); delCoordPanel.setSizeUndefined(); GridLayout delCoordinatorLayout = new GridLayout(2, 2); delCoordinatorLayout.setSpacing(true); delCoordinatorLayout.setMargin(true); delCoordinatorLayout.setSizeFull(); Button deleteCoordBtn = new Button("Delete"); deleteCoordBtn.setClickShortcut(KeyCode.ENTER); deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY); delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel); delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1); delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT); delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT); delCoordPanel.setContent(delCoordinatorLayout); /******* DELETE COORDINATOR PANEL END *********/ /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/ addCoordinator.addClickListener(event -> { if (!addCoordPanel.isVisible()) { delCoordPanel.setVisible(false); addCoordPanel.setVisible(true); idCoordAdd.focus(); } else addCoordPanel.setVisible(false); }); deleteCoordinator.addClickListener(event -> { if (!delCoordPanel.isVisible()) { addCoordPanel.setVisible(false); delCoordPanel.setVisible(true); idCoordDel.focus(); } else delCoordPanel.setVisible(false); }); /************************************************* MAIN BUTTONS LOGIC END *************************************************/ /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/ validateNewCoord.addClickListener(event -> { String currentURL = Page.getCurrent().getLocation().toString(); int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName); String iCrashURL = currentURL.substring(0, strIndexCreator); String googleShebang = "#!"; String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang; try { sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())), new DtLogin(new PtString(loginCoord.getValue())), new DtPassword(new PtString(pwdCoord.getValue()))); // open new browser tab with the newly created coordinator console... // "_blank" instructs the browser to open a new tab instead of a new window... // unhappily not all browsers interpret it correctly, // some versions of some browsers might still open a new window instead (notably Firefox)! Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank"); } catch (Exception e) { e.printStackTrace(); } idCoordAdd.setValue(""); loginCoord.setValue(""); pwdCoord.setValue(""); idCoordAdd.focus(); }); /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/ /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/ deleteCoordBtn.addClickListener(event -> { IcrashSystem sys = IcrashSystem.getInstance(); try { sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue()))); } catch (Exception e) { e.printStackTrace(); } idCoordDel.setValue(""); idCoordDel.focus(); }); /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/ }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private void initView() { setCompositionRoot(root);/* ww w.j a v a 2 s . c o m*/ root.setSizeFull(); root.setSplitPosition(15); root.setStyleName("small previews"); previewArea.setWidth("100%"); previewTabs = new VerticalLayout(); previewTabs.setSizeFull(); previewTabs.setHeight(null); compoundTabs = new VerticalLayout(); compoundTabs.setSizeFull(); compoundTabs.setHeight(null); bennuStylesTabs = new VerticalLayout(); bennuStylesTabs.setSizeFull(); bennuStylesTabs.setHeight(null); VerticalLayout menu = new VerticalLayout(); menu.setSizeFull(); menu.setStyleName("sidebar-menu"); Button syncThemes = new Button("Sync Themes", new ClickListener() { @Override public void buttonClick(ClickEvent event) { syncThemes(); } }); menu.addComponent(syncThemes); menu.addComponent(new Label("Single Components")); menu.addComponent(previewTabs); menu.addComponent(new Label("Compound Styles")); menu.addComponent(compoundTabs); menu.addComponent(new Label("Bennu Styles")); menu.addComponent(bennuStylesTabs); root.setFirstComponent(menu); CssLayout toolbar = new CssLayout(); toolbar.setWidth("100%"); toolbar.setStyleName("toolbar"); toolbar.addComponent(editorToggle); final Window downloadWindow = new Window("Download Theme"); GridLayout l = new GridLayout(3, 2); l.setSizeUndefined(); l.setMargin(true); l.setSpacing(true); downloadWindow.setContent(l); downloadWindow.setModal(true); downloadWindow.setResizable(false); downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null); downloadWindow.addStyleName("opaque"); Label caption = new Label("Theme Name"); l.addComponent(caption); l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); final TextField name = new TextField(); name.setValue("my-chameleon"); name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed")); name.setRequired(true); name.setRequiredError("Please give a name for the theme"); downloadWindow.addComponent(name); Label info = new Label( "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.", Label.CONTENT_XHTML); info.addStyleName("tiny"); info.setWidth("200px"); l.addComponent(info, 1, 1, 2, 1); Button download = new Button(null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(downloadWindow); name.focus(); } }); download.setDescription("Donwload the current theme"); download.setIcon(new ThemeResource("download.png")); download.setStyleName("icon-only"); toolbar.addComponent(download); menu.addComponent(toolbar); menu.setExpandRatio(toolbar, 1); menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
GridLayout getPreviewLayout(String caption) { GridLayout grid = new GridLayout(3, 1) { @Override//from www . j a v a 2 s . co m public void addComponent(Component c) { super.addComponent(c); setComponentAlignment(c, "center middle"); if (c.getStyleName() != "") { ((AbstractComponent) c).setDescription( c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")"); } else { ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()"); } } }; grid.setWidth("100%"); grid.setSpacing(true); grid.setMargin(true); grid.setCaption(caption); grid.setStyleName("preview-grid"); return grid; }