private Component buildFormContent() { VerticalLayout formContent = new VerticalLayout(); formContent.setSpacing(true); Panel frmPanel = new Panel(); frmPanel.setStyleName(AitTheme.PANEL_FORM); frmPanel.setIcon(FontAwesome.EDIT); frmPanel.setWidth("100%"); frmPanel.setCaption("Datos a eliminar"); frmPanel.setContent(this.frm_organismo); this.frm_organismo.enabled(); formContent.setMargin(true); Panel gridPanel = new Panel(); gridPanel.setStyleName(AitTheme.PANEL_GRID); gridPanel.setIcon(FontAwesome.TABLE); gridPanel.setWidth("100%"); gridPanel.setCaption("Organismos Financiadores registrados"); gridPanel.setContent(this.grid_organismo); formContent.setMargin(true); formContent.addComponent(gridPanel); formContent.addComponent(frmPanel); this.frm_organismo.update(); Responsive.makeResponsive(formContent); return formContent; }
private Component buildFormContent() { VerticalLayout formContent = new VerticalLayout(); formContent.setSpacing(true); Panel frmPanel = new Panel(); frmPanel.setStyleName(AitTheme.PANEL_FORM); frmPanel.setIcon(FontAwesome.EDIT); frmPanel.setWidth("100%"); frmPanel.setCaption("Servidor con Atribuciones de Autorizacion"); GridLayout gridlFunionario = new GridLayout(3, 1); gridlFunionario.addComponent(txtDependencia, 0, 0); gridlFunionario.addComponent(txtUnidadOrganizacional, 1, 0); gridlFunionario.addComponent(txt_nombre_servidor, 2, 0); gridlFunionario.setMargin(true); gridlFunionario.setSpacing(true); gridlFunionario.setWidth("100%"); frmPanel.setContent(gridlFunionario); formContent.setMargin(true); formContent.addComponent(frmPanel); Panel gridPanel = new Panel(); gridPanel.setWidth("100%"); gridPanel.setCaption("Documentos que Puede Autorizar"); gridPanel.setContent(this.gridTipoAutorizacion); gridPanel.setStyleName(AitTheme.PANEL_GRID); gridPanel.setIcon(FontAwesome.TABLE); formContent.setMargin(true); Panel gridpin = new Panel(); gridpin.setStyleName(AitTheme.PANEL_FORM); gridpin.setIcon(FontAwesome.TABLE); gridpin.setWidth("100%"); gridpin.setCaption("N. PIN"); gridpin.setContent(this.frm_pin); formContent.setMargin(true); formContent.addComponent(frmPanel); formContent.addComponent(gridPanel); formContent.addComponent(gridpin); Responsive.makeResponsive(formContent); return formContent; }
private Component buildFormContent() { VerticalLayout formContent = new VerticalLayout(); formContent.setSpacing(true); Panel frmPanel = new Panel(); frmPanel.setWidth("100%"); frmPanel.setCaption("Datos a registrar"); frmPanel.setContent(this.frm_unidad); formContent.setMargin(true); formContent.addComponent(frmPanel); Panel gridPanel = new Panel(); gridPanel.setWidth("100%"); gridPanel.setCaption("Dependencias registradas"); gridPanel.setContent(this.grid_unidad); formContent.setMargin(true); formContent.addComponent(frmPanel); formContent.addComponent(gridPanel); Responsive.makeResponsive(formContent); return formContent; }
@Override public void attach() { super.attach(); rootPanel = new Panel("Connect to..."); rootPanel.addStyleName(ValoTheme.PANEL_WELL); rootPanel.setWidth("500px"); rootPanel.setHeight("300px"); recreateRootLayout(); setSizeFull(); addComponent(rootPanel); setComponentAlignment(rootPanel, Alignment.MIDDLE_CENTER); }
@AutoGenerated private Panel buildPanel_1() { // common part: create layout panel_1 = new Panel(); panel_1.setImmediate(false); panel_1.setWidth("100.0%"); panel_1.setHeight("100.0%"); // verticalLayout_1 verticalLayout_1 = buildVerticalLayout_1(); panel_1.setContent(verticalLayout_1); return panel_1; }
@AutoGenerated private Panel buildPanCaracteristicas() { // common part: create layout panCaracteristicas = new Panel(); panCaracteristicas.setImmediate(false); panCaracteristicas.setWidth("100.0%"); panCaracteristicas.setHeight("-1px"); // verLCaracteristicas verLCaracteristicas = buildVerLCaracteristicas(); panCaracteristicas.setContent(verLCaracteristicas); return panCaracteristicas; }
@AutoGenerated private Panel buildPanAvanceRecesion() { // common part: create layout panAvanceRecesion = new Panel(); panAvanceRecesion.setCaption("Avance-Recesión"); panAvanceRecesion.setImmediate(false); panAvanceRecesion.setWidth("100.0%"); panAvanceRecesion.setHeight("-1px"); // absLAvanceRecesion absLAvanceRecesion = buildAbsLAvanceRecesion(); panAvanceRecesion.setContent(absLAvanceRecesion); return panAvanceRecesion; }
public SettingsLayout(String userName, MainPage mainPage) { this.mainPage = mainPage; this.userName = userName; WebApplicationContext context = (WebApplicationContext) mainPage.getContext(); WebBrowser webBrowser = context.getBrowser(); height = webBrowser.getScreenHeight() - 310; setMargin(true); setSpacing(true); vl.setMargin(true); vl.setSpacing(true); panelEmail.setWidth("100%"); addComponent(hl); hl.setFirstComponent(panelEmail); hl.setSecondComponent(panelPassword); oldEmail.setValue(GeneralController.getEmailFromUserName(userName)); oldEmail.setWidth("250"); oldEmail.setReadOnly(false); newEmail.setWidth("250"); newEmail.addValidator(new EmailValidator("Email должен содержать знак '@' и полный домен.")); saveButton = new Button("Сохранить изменения"); saveButton.setVisible(true); saveButton.setIcon(new ThemeResource("icons/32/save.png")); resetUserPasswordButton.setVisible(true); resetUserPasswordButton.setIcon(new ThemeResource("icons/32/group_key.png")); resetUserPasswordButton.addListener(this); oldEmailInscription.setReadOnly(true); panelEmail.addComponent(oldEmailInscription); panelEmail.addComponent(oldEmail); panelEmail.addComponent(newEmail); panelEmail.addComponent(saveButton); panelPassword.addComponent(label); panelPassword.addComponent(resetUserPasswordButton); panelEmail.setHeight(height); panelPassword.setHeight(height); saveButton.addListener(this); }
@Override protected void setup(VaadinRequest request) { Panel panel = new Panel(); panel.setId("mainPanel"); panel.setWidth("200px"); panel.setHeight("200px"); VerticalLayout layout = new VerticalLayout(); layout.setWidth("500px"); layout.setHeight("500px"); Button btn = new Button("Button 1"); Button btn2 = new Button("Button 2"); layout.addComponent(btn); layout.setComponentAlignment(btn, Alignment.TOP_RIGHT); layout.addComponent(btn2); layout.setComponentAlignment(btn2, Alignment.BOTTOM_LEFT); panel.setContent(layout); addComponent(panel); }
private VerticalLayout buildAppointmentPStructure() { appointmentPhoneScreen = new VerticalLayout(); appointmentPhoneScreen.setWidth("420px"); appointmentPhoneScreen.setHeight("250px"); phoneLayout = new VerticalLayout(); phoneLayout.setSpacing(true); phoneLayout.setSizeFull(); Panel panel = new Panel("Arzt anrufen"); panel.setWidth("420px"); panel.addComponent(phoneLayout); phoneLayout.addComponent(contactList); appointmentPhoneScreen.addComponent(panel); return appointmentPhoneScreen; }
private void setupLayout() { HorizontalLayout horizontal = new HorizontalLayout(); horizontal.setSpacing(false); horizontal.addComponent(buttonPrevious); horizontal.addComponent(buttonStop); horizontal.addComponent(buttonPlay); horizontal.addComponent(buttonNext); horizontal.setComponentAlignment(buttonPrevious, Alignment.TOP_CENTER); horizontal.setComponentAlignment(buttonStop, Alignment.TOP_CENTER); horizontal.setComponentAlignment(buttonPlay, Alignment.TOP_CENTER); horizontal.setComponentAlignment(buttonNext, Alignment.TOP_CENTER); panel.setWidth("300px"); panel.addComponent(labelMusic); panel.addComponent(labelDuration); panel.addComponent(indicator); panel.addComponent(horizontal); this.addComponent(panel); this.setComponentAlignment(panel, Alignment.TOP_CENTER); }
private void addLayoutTest(Layout l) { l.setSizeFull(); Label lbl = new Label("First (expand ratio 1)"); lbl.setSizeUndefined(); l.addComponent(lbl); lbl = new Label("Second (margin 10px)"); lbl.setSizeUndefined(); lbl.addStyleName("hugemargin"); l.addComponent(lbl); lbl = new Label("Third (margin+xr)"); lbl.setSizeUndefined(); lbl.addStyleName("hugemargin"); l.addComponent(lbl); Panel p = new Panel(l.getClass().getSimpleName(), l); p.setWidth("600px"); p.setHeight("200px"); addComponent(p); }
@Override public Component buildMainComponent(Object... argumente) { project = TestsuiteWebUtils.getProjectFromArguments(argumente); testrun = TestsuiteWebUtils.getTestrunFromArguments(argumente); if (project == null) { throw new IllegalArgumentException("project is not Set"); } if (testrun == null) { testrun = new Testrun(); } Panel mainPanel = new Panel("Neuer Testlauf"); mainPanel.setWidth(WINDOW_WIDTH); mainPanel.addComponent(buildNewTestrunTextFieldPanel()); return mainPanel; }
public AccountActivationView(String activationId) { this.activationId = activationId; activationPanel = new Panel(); activationPanel.setImmediate(true); activationPanel.setWidth("400px"); VerticalLayout vl = new VerticalLayout(); activateMyUserButton = new Button(); activateMyUserButton.setStyleName(BaseTheme.BUTTON_LINK); activateMyUserButton.setIcon(IconManager.getIcon(IconManager.ACTIVATE_USER)); activateMyUserButton.addListener(this); vl.addComponent(activateMyUserButton); vl.setComponentAlignment(activateMyUserButton, Alignment.MIDDLE_CENTER); activationPanel.addComponent(vl); addComponent(activationPanel); setComponentAlignment(activationPanel, Alignment.MIDDLE_CENTER); setExpandRatio(activationPanel, 1); buildStringsFromLocale(); }
public Layout buildLayout() { VerticalLayout layout = new VerticalLayout(); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setMargin(true); final Panel widePanel = new Panel("too big", panelLayout); widePanel.setSizeUndefined(); widePanel.setWidth("2000px"); widePanel.setHeight("200px"); layout.addComponent(widePanel); Button button = new Button( "Change panel size", new ClickListener() { @Override public void buttonClick(ClickEvent event) { switch (step++ % 4) { case 0: widePanel.setWidth("200px"); break; case 1: widePanel.setHeight("2000px"); break; case 2: widePanel.setWidth("2000px"); break; case 3: widePanel.setHeight("200px"); break; } } }); panelLayout.addComponent(button); layout.setSizeUndefined(); return layout; }
private Panel designLoginPanel() { final Panel loginPanel = new Panel("Login"); HashMap<String, String> users = null; loginPanel.setWidth("100%"); loginPanel.setHeight("100%"); // Create absolute layout specifying its properties final AbsoluteLayout loginLayout = new AbsoluteLayout(); loginLayout.setSizeFull(); // Create components Objects and specify their properties int startLeft = 200, startTop = 300; try { users = getLoginInfo("jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Button btnLogin = new Button("Login"); final ComboBox cmbUser = new ComboBox("Select your USER ID"); final ComboBox cmbTask = new ComboBox("Select your TASK"); cmbUser.setNullSelectionAllowed(false); cmbTask.setNullSelectionAllowed(false); // Add data Iterator it = users.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); cmbUser.addItem(pairs.getKey()); cmbUser.setItemCaption(pairs.getKey(), pairs.getValue().toString()); it.remove(); // avoids a ConcurrentModificationException } cmbUser.setValue(cmbUser.getItemIds().iterator().next()); // Listeners btnLogin.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { userId = String.valueOf( cmbUser .getValue()); // which is his Id in tabel as this combo box shows names as // captions and Ids as values userName = cmbUser.getItemCaption(userId); task = String.valueOf(cmbTask.getValue()); if (task != "" && userId != "") { VerticalSplitPanel vsplit = new VerticalSplitPanel(); displayedPanel = designMainPanel(); vsplit.setSecondComponent(displayedPanel); vsplit.setFirstComponent(allLinksDetails()); UI.getCurrent().setContent(vsplit); } } }); cmbUser.addFocusListener( new FocusListener() { @Override public void focus(FocusEvent event) { // TODO Auto-generated method stub cmbUser.setValue(cmbUser.getItemIds().iterator().next()); } }); cmbUser.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String valueString = String.valueOf(event.getProperty().getValue()); try { List<String> tasks = getTasksInfo( "jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo", valueString); cmbTask.removeAllItems(); if (tasks != null) { for (String task : tasks) { cmbTask.addItem(task); } cmbTask.setValue(cmbTask.getItemIds().iterator().next()); } } catch (SQLException e) { // TODO Auto-generated catch block Notification.show(e.getMessage()); } } }); loginLayout.addComponent(cmbUser, "left: 800px; top: 200px;"); loginLayout.addComponent(cmbTask, "left: 800px; top: 300px;"); loginLayout.addComponent(btnLogin, "left: 900px; top: 400px;"); loginPanel.setContent(loginLayout); return loginPanel; }
private Panel designMainPanel() { // positioning indices final int leftStart = 450, topStart = 10, space = 100; // create the panel that will hold all components Panel pnlURIsProperties = new Panel("URI Display"); pnlURIsProperties.setWidth("100%"); pnlURIsProperties.setHeight("100%"); // Create absolute layout specifying its properties final AbsoluteLayout layout = new AbsoluteLayout(); layout.setWidth("100%"); layout.setHeight("100%"); layout.setSizeFull(); // Create components Objects and specify their properties Button btnCorrect = new Button("Correct"); Button btnIncorrect = new Button("Incorrect"); Button btnUnsure = new Button("Unsure"); Button btnGetProperties = new Button("Get properties"); final NativeSelect cmbSourceEndpoint = new NativeSelect("Source Endpoint"); final NativeSelect cmbDestinationEndpoint = new NativeSelect("Destination Endpoint"); final ListSelect lstSuggestedProperties = new ListSelect("Lookup Properties"); // to load properties of loaded resources automatically final CheckBox chkAutomaticPropertiesLoad = new CheckBox("Automatic Properties loading (next time)"); chkAutomaticPropertiesLoad.setValue(false); cmbSourceEndpoint.setNullSelectionAllowed(false); cmbDestinationEndpoint.setNullSelectionAllowed(false); lstSuggestedProperties.setRows(4); lstSuggestedProperties.setNullSelectionAllowed(false); source = new Label("Source URI"); destination = new Label("Destination URI"); final Table tblSourcePropertiesMapping = new Table("Source Properties"); final Table tblDestinationPropertiesMapping = new Table("Destination Properties"); tblSourcePropertiesParam = tblSourcePropertiesMapping; tblDestinationPropertiesParam = tblDestinationPropertiesMapping; tblSourcePropertiesMapping.setWidth("50%"); tblDestinationPropertiesMapping.setWidth("100%"); tblSourcePropertiesMapping.setSelectable(true); tblDestinationPropertiesMapping.setSelectable(true); /* Define the names and data types of columns. * The "default value" parameter is meaningless here. */ tblSourcePropertiesMapping.addContainerProperty("Property", String.class, null); tblSourcePropertiesMapping.addContainerProperty("Value", String.class, null); tblDestinationPropertiesMapping.addContainerProperty("Property", String.class, null); tblDestinationPropertiesMapping.addContainerProperty("Value", String.class, null); tblDestinationPropertiesMapping.setMultiSelect(true); /// get data for comboboxes SQLContainer cmbContainer = connectToDB("root", "mofo", "Endpoints"); // fill endpoints cmbSourceEndpoint.setContainerDataSource(cmbContainer); cmbDestinationEndpoint.setContainerDataSource(cmbContainer); cmbSourceEndpoint.setValue(cmbSourceEndpoint.getItemIds().iterator().next()); cmbDestinationEndpoint.setValue(cmbDestinationEndpoint.getItemIds().iterator().next()); SQLContainer lstContainer = getSuggestedProperties("root", "mofo"); int lstSize = lstContainer.size(); int i = 0; for (Object cityItemId : lstContainer.getItemIds()) { lstSuggestedProperties.addItem(i); String g = lstContainer.getItem(cityItemId).getItemProperty("property").getValue().toString(); lstSuggestedProperties.setItemCaption(i, g); i++; } lstSuggestedProperties.setValue(lstSuggestedProperties.getItemIds().iterator().next()); btnCorrect.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); long lEllapsedTime = lEndTime - lStartTime; tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Correct"); tblSourceDestinationparam .getContainerProperty(rowId, "time") .setValue(String.valueOf(lEllapsedTime)); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } /////////////////////////////////// } }); btnIncorrect.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); long lEllapsedTime = lEndTime - lStartTime; tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam .getContainerProperty(rowId, "decision") .setValue("Incorrect"); tblSourceDestinationparam .getContainerProperty(rowId, "time") .setValue(String.valueOf(lEllapsedTime)); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR Not Properties queried"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } /////////////////////////////////// } }); btnUnsure.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); float lEllapsedTime = lEndTime - lStartTime; String elapsedTime = String.valueOf(lEllapsedTime); tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Unsure"); tblSourceDestinationparam.getContainerProperty(rowId, "time").setValue(elapsedTime); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } // int selectedId=Integer.parseInt(tblSourceDestination.getValue().toString()); int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR Not Properties queried"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } } }); btnGetProperties.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); lStartTime = System.currentTimeMillis(); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties(sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show( "ERROR while sparqling the endpoint for resources' properties (Are they selected/loaded ?)"); } // cachingForTriples(tblSourceDestination, sourceEndpoint); } }); lstSuggestedProperties.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String valueString = String.valueOf(event.getProperty().getValue()); // Notification.show(valueString); List<Object> Ids = new ArrayList<Object>(); Object first = null; for (Iterator i = tblSourcePropertiesMapping.getItemIds().iterator(); i.hasNext(); ) { // Get the current item identifier, which is an integer. first = i.next(); int iid = (Integer) first; String other = tblSourcePropertiesMapping.getItem(iid).getItemProperty("Property").toString(); // Notification.show(other); if (other.equals(valueString)) // if(other.equals(property)) { Ids.add(iid); break; } } tblSourcePropertiesMapping.setImmediate(true); tblSourcePropertiesMapping.setValue(Ids); tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first); } }); tblSourcePropertiesMapping.addItemClickListener( new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { String property = tblSourcePropertiesMapping .getContainerProperty(event.getItemId(), event.getPropertyId()) .toString(); List<String> res = getRelatedProperties(property); if (res == null) { Notification.show("No related Properties"); return; } boolean Found = false; List<Object> Ids = new ArrayList<Object>(); Object first = null; int x = 0; for (String relatedProperty : res) { for (Iterator i = tblDestinationPropertiesMapping.getItemIds().iterator(); i.hasNext(); ) { // Get the current item identifier, which is an integer. Object theId = i.next(); int iid = (Integer) theId; String other = tblDestinationPropertiesMapping .getItem(iid) .getItemProperty(event.getPropertyId()) .toString(); if (other.equals(relatedProperty)) // if(other.equals(property)) { Ids.add(iid); if (x == 0) { first = theId; x = 1; } Found = true; } } } if (!Found) Notification.show( "Related property is not Found in destination table try manual search"); else { Notification.show("Found in destination table"); tblDestinationPropertiesMapping.setValue(Ids); tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first); } } }); // add component to the layout specifying its position on the layout layout.addComponent(btnCorrect, "left: " + leftStart + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnIncorrect, "left: " + (leftStart + space) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnUnsure, "left: " + (leftStart + 2 * space) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnGetProperties, "left: " + (leftStart + 3 * space + 50) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( chkAutomaticPropertiesLoad, "left: " + (leftStart + 3 * space + 250) + "px; top: " + (topStart + 450) + "px;"); /*layout.addComponent(sourceURI,"left: "+(leftStart-space/2)+"px; top: "+(topStart+space/2)+"px;"); layout.addComponent(destinationURI,"left: "+(leftStart+2*space)+"px; top: "+(topStart+space/2)+"px;");*/ layout.addComponent(source, "left: 30px; top: " + (topStart + space / 2) + "px;"); layout.addComponent( destination, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space / 2) + "px;"); layout.addComponent(cmbSourceEndpoint, "left: 50px; top: " + (topStart + 20) + "px;"); layout.addComponent( cmbDestinationEndpoint, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + 20) + "px;"); layout.addComponent( lstSuggestedProperties, "left: " + (leftStart + 100) + "px; top: " + (topStart + 20) + "px;"); layout.addComponent( tblSourcePropertiesMapping, "left: 10px; top: " + (topStart + space) + "px;"); layout.addComponent( tblDestinationPropertiesMapping, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space) + "px;"); pnlURIsProperties.setContent(layout); return pnlURIsProperties; }
private Panel allLinksDetails() { // positioning indices // final int leftStart=10,topStart=10, space=100; // create the panel that will hold all components Panel linksDetails = new Panel("Links Details"); // set panel's properties linksDetails.setWidth("100%"); linksDetails.setHeight("100%"); // Create absolute layout specifying its properties final AbsoluteLayout layout = new AbsoluteLayout(); // set layout's properties layout.setSizeFull(); // Create components Objects and specify their properties Button btnLoad = new Button("Load task"); // final Table tblSourceDestination = new Table("Source and Destination URIs"); tblSourceDestination.setSelectable(true); tblSourceDestination.setWidth("90%"); // fill the Source and Destination URIs table SQLContainer container = connectToDB("root", "mofo", userName); Notification.show("Welcome " + userName + " you loaded task Nr.: " + task); Compare.Equal suburbFilter = new Compare.Equal("taskId", Integer.valueOf(task)); container.addContainerFilter(suburbFilter); // Fill the main (tblSourceDestination) table with resources tblSourceDestination.setContainerDataSource(container); tblSourceDestinationparam = tblSourceDestination; // add component to the layout specifying its position on the layout int tableWidth = (int) tblSourceDestination.getWidth(); layout.addComponent(btnLoad, "left:1500px; top: 10px;"); layout.addComponent(tblSourceDestination, "left: 10px; top: 20px;"); linksDetails.setContent(layout); // Add EventHandlers for some of the components btnLoad.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // lStartTime= System.currentTimeMillis(); try { Object rowId = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } }); tblSourceDestination.addItemClickListener( new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { /*lStartTime= System.currentTimeMillis(); try { Object rowId =tblSourceDestination.getValue(); Property sourceProperty=tblSourceDestination.getContainerProperty(rowId,"sourceURI"); Property destinationProperty=tblSourceDestination.getContainerProperty(rowId,"destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI= new Notification(""); loadURI.show("Links' URIs are successfully loaded "); } catch(Exception e) { Notification error= new Notification("Error"); error.show("You did not select an item in the links table"); }*/ } }); return linksDetails; }
public ExceptionDialog(Throwable ex, String caption) { this.cause = ex; Preconditions.checkNotNull(ex); layout = new VerticalLayout(); setContent(layout); layout.setWidth("100%"); layout.setHeight("-1"); if (caption == null) { setCaption("Unexpected error"); } else { setCaption(caption); } Label lblInfo = new Label("An unexpected error occured.<br />The error message was:", ContentMode.HTML); lblInfo.setHeight("-1px"); lblInfo.setWidth("100%"); layout.addComponent(lblInfo); lblInfo.addStyleName("exception-message-caption"); String message = ex.getMessage(); if (message == null || message.isEmpty()) { message = "<no message>"; } Label lblMessage = new Label(message); lblMessage.addStyleName("exception-message-content"); lblMessage.setHeight("-1px"); lblMessage.setWidth("100%"); layout.addComponent(lblMessage); actionsLayout = new HorizontalLayout(); actionsLayout.addStyleName("exception-dlg-details"); actionsLayout.setWidth("100%"); actionsLayout.setHeight("-1px"); layout.addComponent(actionsLayout); btDetails = new Button("Show Details", this); btDetails.setStyleName(BaseTheme.BUTTON_LINK); actionsLayout.addComponent(btDetails); btReportBug = new Button("Report Problem", this); btReportBug.setStyleName(BaseTheme.BUTTON_LINK); btReportBug.setVisible(false); btReportBug.setIcon(FontAwesome.ENVELOPE_O); UI ui = UI.getCurrent(); if (ui instanceof SearchUI) { btReportBug.setVisible(((SearchUI) ui).canReportBugs()); } actionsLayout.addComponent(btReportBug); actionsLayout.setComponentAlignment(btDetails, Alignment.TOP_LEFT); actionsLayout.setComponentAlignment(btReportBug, Alignment.TOP_RIGHT); lblStacktrace = new Label(Helper.convertExceptionToMessage(ex), ContentMode.PREFORMATTED); detailsPanel = new Panel(lblStacktrace); detailsPanel.setWidth("100%"); detailsPanel.setHeight("300px"); detailsPanel.setVisible(false); lblStacktrace.setSizeUndefined(); lblStacktrace.setVisible(true); layout.addComponent(detailsPanel); btClose = new Button("OK", this); layout.addComponent(btClose); layout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER); layout.setExpandRatio(detailsPanel, 0.0f); layout.setExpandRatio(actionsLayout, 1.0f); }
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setColumnExpandRatio(0, .05f); mapLayout.setColumnExpandRatio(1, .425f); mapLayout.setColumnExpandRatio(2, .05f); mapLayout.setColumnExpandRatio(3, .425f); mapLayout.setColumnExpandRatio(4, .05f); mapLayout.setMargin(true); mapLayout.setSpacing(true); mapLayout.setWidth("100%"); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setValue(key); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setValue(valueMap.get(key)); valueField.setNullSettingAllowed(false); valueField.addValidator( new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.addComponent(keyLabel, 0, i); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setNullSettingAllowed(false); valueField.addValidator( new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); mapPanel.setContent(mapLayout); Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.validate(); textField.value.validate(); } usernameField.validate(); passwordField.validate(); } catch (InvalidValueException e) { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.setValidationVisible(true); textField.value.setValidationVisible(true); usernameField.setValidationVisible(true); passwordField.setValidationVisible(true); } Notification.show("Validation errors have occurred!", Type.ERROR_MESSAGE); return; } HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); userParam.setValue(usernameField.getValue()); passwordParam.setValue(passwordField.getValue()); PlatformConfigurationPanel.this.configurationManagement.saveConfiguration( platformConfiguration); Notification notification = new Notification( "Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); Button deleteButton = new Button("Re-create"); deleteButton.addStyleName(ValoTheme.BUTTON_SMALL); deleteButton.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { configurationManagement.deleteConfiguration(platformConfiguration); refresh(); } }); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight("100%"); buttonLayout.setSpacing(true); buttonLayout.setWidth(200, Unit.PIXELS); buttonLayout.setMargin(true); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(deleteButton); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramLayout.addComponent(buttonLayout, 0, 2, 1, 2); paramLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); return paramPanel; }
protected Panel createTextFieldPanel(ConfigurationParameter parameter, Validator validator) { Panel paramPanel = new Panel(); paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(3, 3); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label configLabel = new Label("Platform Configuration"); configLabel.addStyleName(ValoTheme.LABEL_HUGE); configLabel.setSizeUndefined(); paramLayout.addComponent(configLabel, 0, 0, 1, 0); paramLayout.setComponentAlignment(configLabel, Alignment.TOP_LEFT); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 1, 1, 1); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); logger.info(parameter.getName() + " " + parameter.getValue()); Label valueLabel = new Label("Value:"); valueLabel.setSizeUndefined(); usernameField = new TextField(); usernameField.addValidator(validator); usernameField.setNullSettingAllowed(true); usernameField.setNullRepresentation(""); usernameField.setValidationVisible(false); usernameField.setWidth("80%"); usernameField.setId(parameter.getName()); if (parameter instanceof ConfigurationParameterIntegerImpl) { StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields usernameField.setConverter(plainIntegerConverter); } else if (parameter instanceof ConfigurationParameterLongImpl) { StringToLongConverter plainLongConverter = new StringToLongConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields usernameField.setConverter(plainLongConverter); } BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter); if (parameter.getValue() != null) { usernameField.setPropertyDataSource(parameterItem.getItemProperty("value")); } paramLayout.addComponent(valueLabel, 0, 2); paramLayout.addComponent(usernameField, 1, 2); paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT); paramPanel.setContent(paramLayout); return paramPanel; }
protected void addProcessImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null) { boolean didDrawImage = false; if (ExplorerApp.get().isUseJavascriptDiagram()) { try { final InputStream definitionStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition.getResourceName()); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getFlowLocationMap().size() > 0) { int maxX = 0; int maxY = 0; for (String key : bpmnModel.getLocationMap().keySet()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key); double elementX = graphicInfo.getX() + graphicInfo.getWidth(); if (maxX < elementX) { maxX = (int) elementX; } double elementY = graphicInfo.getY() + graphicInfo.getHeight(); if (maxY < elementY) { maxY = (int) elementY; } } Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); URL explorerURL = ExplorerApp.get().getURL(); URL url = new URL( explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId() + "&processInstanceId=" + processInstance.getId()); Embedded browserPanel = new Embedded("", new ExternalResource(url)); browserPanel.setType(Embedded.TYPE_BROWSER); browserPanel.setWidth(maxX + 350 + "px"); browserPanel.setHeight(maxY + 220 + "px"); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(browserPanel); panelLayout.addComponent(imagePanel); didDrawImage = true; } } catch (Exception e) { LOGGER.error("Error loading process diagram component", e); } } if (didDrawImage == false && processDefinitionEntity.isGraphicalNotationDefined()) { StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder() .buildStreamResource(processInstance, repositoryService, runtimeService); if (diagram != null) { Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_NO_LINE); panelLayout.addComponent(header); Embedded embedded = new Embedded(null, diagram); embedded.setType(Embedded.TYPE_IMAGE); embedded.setSizeUndefined(); Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.setScrollable(true); imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(embedded); panelLayout.addComponent(imagePanel); } } } }
public void init(final Window main) { VerticalLayout mainLayout = new VerticalLayout(); main.setContent(mainLayout); mainLayout.setSizeFull(); HorizontalLayout titlebar = new HorizontalLayout(); titlebar.addStyleName("titlebar"); titlebar.setWidth("100%"); Label title = new Label("Book of Vaadin Examples"); title.addStyleName("title"); titlebar.addComponent(title); titlebar.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); Embedded logo = new Embedded(null, new ThemeResource("img/vaadin-logo.png")); titlebar.addComponent(logo); titlebar.setComponentAlignment(logo, Alignment.MIDDLE_RIGHT); main.addComponent(titlebar); HorizontalLayout hor = new HorizontalLayout(); hor.setSizeFull(); main.addComponent(hor); mainLayout.setExpandRatio(hor, 1.0f); final Panel menupanel = new Panel("Examples"); menupanel.addStyleName("menupanel"); menupanel.setWidth(null); menupanel.setHeight("100%"); menupanel.getContent().setWidth(null); // menupanel.getContent().setHeight("100%"); hor.addComponent(menupanel); final Tree menu = new Tree(); menu.setWidth(null); // menu.setHeight("100%"); menu.setImmediate(true); menupanel.addComponent(menu); final Panel viewpanel = new Panel("Selected Example"); viewpanel.addStyleName("viewpanel"); viewpanel.setSizeFull(); VerticalLayout viewlayout = new VerticalLayout(); viewlayout.addStyleName("viewlayout"); viewlayout.setSpacing(true); viewlayout.setMargin(true); viewpanel.setContent(viewlayout); hor.addComponent(viewpanel); hor.setExpandRatio(viewpanel, 1.0f); WebApplicationContext ctx = (WebApplicationContext) getContext(); BookExampleLibrary library = BookExampleLibrary.getInstance(ctx.getBaseDirectory()); AbstractExampleItem[] examples = library.getAllExamples(); // Collect redirects here final HashMap<String, String> redirects = new HashMap<String, String>(); // Collect examples here final HashMap<String, CaptionedExampleItem> exampleitems = new HashMap<String, CaptionedExampleItem>(); // Build the menu and collect redirections for (int i = 0; i < examples.length; i++) if (examples[i] instanceof BookExample || examples[i] instanceof ExampleCtgr) { CaptionedExampleItem example = (CaptionedExampleItem) examples[i]; exampleitems.put(example.getExampleId(), example); String itemid = example.getExampleId(); menu.addItem(itemid); menu.setItemCaption(itemid, example.getShortName()); if (examples[i].getParentId() != null) menu.setParent(itemid, examples[i].getParentId()); } else if (examples[i] instanceof RedirctItem) { RedirctItem redirect = (RedirctItem) examples[i]; redirects.put(redirect.getExampleId(), redirect.redirectid); } // Expand the menu for (int i = 0; i < examples.length; i++) { if (examples[i].getParentId() == null) menu.expandItemsRecursively(examples[i].getExampleId()); if (examples[i].isCollapsed()) menu.collapseItem(examples[i].getExampleId()); if (menu.getChildren(examples[i].getExampleId()) == null) menu.setChildrenAllowed(examples[i].getExampleId(), false); } // Set selected example as given in the URI fragment final UriFragmentUtility urifu = new UriFragmentUtility(); urifu.addListener( new FragmentChangedListener() { private static final long serialVersionUID = -6588416218607827834L; public void fragmentChanged(FragmentChangedEvent source) { String fragment = source.getUriFragmentUtility().getFragment(); if (fragment != null) { // Handle redirection while (redirects.containsKey(fragment)) fragment = redirects.get(fragment); menu.setValue(fragment); // Open the tree nodes leading to the example for (Object parent = menu.getParent(fragment); parent != null; parent = menu.getParent(parent)) menu.expandItem(parent); } } }); mainLayout.addComponent(urifu); // Handle menu selection menu.addListener( new Property.ValueChangeListener() { private static final long serialVersionUID = 8236533959795019956L; public void valueChange(ValueChangeEvent event) { viewpanel.removeAllComponents(); String selection = (String) event.getProperty().getValue(); // Find the example CaptionedExampleItem exampleItem = exampleitems.get(selection); if (selection != null && exampleItem == null) main.showNotification("Invalid item " + selection); else if (exampleItem != null) { if (exampleItem.getClass().isAssignableFrom(ExampleCtgr.class)) { if (menu.hasChildren(exampleItem.getExampleId())) { menu.select((String) menu.getChildren(exampleItem.getExampleId()).toArray()[0]); } } else { // A leaf BookExample example = (BookExample) exampleItem; // Load unless already loaded WebApplicationContext ctx = (WebApplicationContext) getContext(); example.loadExample(ctx.getBaseDirectory()); if (example.getDescription() != null) { Label descLabel = new Label(example.getDescription(), Label.CONTENT_XHTML); descLabel.addStyleName("example-description"); viewpanel.addComponent(descLabel); } // The actual example component viewpanel.addComponent(example.createInstance()); // Java sources on the left, CSS on the right HorizontalLayout horizontalOrder = new HorizontalLayout(); horizontalOrder.addStyleName("sourcecontainer"); horizontalOrder.setSpacing(true); horizontalOrder.setMargin(true); Panel bookRefs = null; Panel forumLinks = null; Panel kbRefs = null; List<SourceFragment> fragments = example.getSourceFragments(); if (fragments != null) { // Java Sources are laid out vertically VerticalLayout verticalListings = new VerticalLayout(); verticalListings.setSizeUndefined(); verticalListings.setSpacing(true); horizontalOrder.addComponent(verticalListings); // Find the widest source fragment int widestIndex = 0; int widestWidth = 0; for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) if (fragments.get(fragmentNum).getSrcWidth() > widestWidth) { widestIndex = fragmentNum; widestWidth = fragments.get(fragmentNum).getSrcWidth(); } System.out.println("Widest listing: " + widestIndex + " which is " + widestWidth); for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) { SourceFragment fragment = fragments.get(fragmentNum); // Have caption only in the beginning of the listings String listingCaption = fragmentNum == 0 ? "Source Code" : ""; String srcurl = "http://dev.vaadin.com/browser/doc/book-examples/trunk/src" + fragment.getSrcName(); SourceListing listing = new SourceListing(listingCaption, srcurl, fragment); verticalListings.addComponent(listing); // Use the width of the widest listing for all listings if (fragmentNum == widestIndex) listing.setWidth(Sizeable.SIZE_UNDEFINED, 0); else listing.setWidth("100%"); if (!fragment.getBookRefs().isEmpty()) { bookRefs = new Panel("Book References"); bookRefs.setSizeUndefined(); for (Iterator<String> iter = fragment.getBookRefs().iterator(); iter.hasNext(); ) { String ref = iter.next(); int hashPos = ref.indexOf('#'); String refFragment = ""; if (hashPos != -1) { refFragment = "#" + ref.replace('#', '.'); ref = ref.substring(0, hashPos); } String bookUrl = "http://vaadin.com/book/-/page/" + ref + ".html" + refFragment; Link link = new Link(bookUrl, new ExternalResource(bookUrl)); link.setTargetName("_new"); bookRefs.addComponent(link); } } if (!fragment.getForumLinks().isEmpty()) { forumLinks = new Panel("Forum Messages"); forumLinks.setSizeUndefined(); for (Iterator<String> iter = fragment.getForumLinks().iterator(); iter.hasNext(); ) { String url = iter.next(); Link link = new Link(url, new ExternalResource(url)); link.setTargetName("_new"); forumLinks.addComponent(link); } } if (!fragment.getKbRefs().isEmpty()) { kbRefs = new Panel("Pro Account Knowledge Base Articles"); kbRefs.setSizeUndefined(); for (Iterator<SourceFragment.Ref> iter = fragment.getKbRefs().iterator(); iter.hasNext(); ) { SourceFragment.Ref ref = iter.next(); String url = "http://vaadin.com/knowledge-base#" + ref.ref; Link link = new Link(ref.caption, new ExternalResource(url)); link.setTargetName("_new"); forumLinks.addComponent(link); } } } } // Show associated CSS if (example.getCssFragments() != null && example.getCssFragments().size() > 0) { SourceFragment csscode = example.getCssFragments().get(0); String srcurl = "http://dev.vaadin.com/browser/doc/book-examples/trunk/WebContent/VAADIN/themes/book-examples/styles.css"; horizontalOrder.addComponent(new SourceListing("CSS Code", srcurl, csscode)); } if (horizontalOrder.getComponentIterator().hasNext()) viewpanel.addComponent(horizontalOrder); if (bookRefs != null) viewpanel.addComponent(bookRefs); if (forumLinks != null) viewpanel.addComponent(forumLinks); if (kbRefs != null) viewpanel.addComponent(kbRefs); urifu.setFragment(example.getExampleId()); } } } }); Tree.ItemStyleGenerator itemStyleGenerator = new Tree.ItemStyleGenerator() { private static final long serialVersionUID = -3231268865512947125L; public String getStyle(Object itemId) { // Chapter title items do not contain a period if (!((String) itemId).contains(".")) return "chaptertitle"; return null; } }; menu.setItemStyleGenerator(itemStyleGenerator); }