List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:com.haulmont.cuba.web.widgets.CubaTable.java
License:Apache License
@Override public void changeVariables(Object source, Map<String, Object> variables) { if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) { focus();/*from ww w. j a va2s . co m*/ } super.changeVariables(source, variables); if (shortcutActionManager != null) { shortcutActionManager.handleActions(variables, this); } }
From source file:com.hris.payroll.alphalist.AlphaListMainUI.java
private Button exportToExcelButton() { ExportDataGridToExcel exportGrid = new ExportDataGridToExcel(grid); exportToExcelButton.setEnabled(false); exportToExcelButton.setWidth("200px"); exportToExcelButton.setIcon(FontAwesome.EXCLAMATION_CIRCLE); exportToExcelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportToExcelButton.addStyleName(ValoTheme.BUTTON_SMALL); exportToExcelButton.addClickListener((Button.ClickEvent e) -> { exportGrid.workSheet();/*from ww w . ja v a2s.co m*/ StreamResource.StreamSource source = () -> { try { File f = new File(exportGrid.getFilePath()); FileInputStream fis = new FileInputStream(f); return fis; } catch (Exception e1) { e1.getMessage(); return null; } }; Date date = new Date(); String branchName = cs.getBranchById(getBranchId()); int tradeId = cs.getTradeIdByBranchId(getBranchId()); String tradeName = cs.getTradeById(tradeId); int corporateId = cs.getCorporateIdByTradeId(tradeId); String corporateName = cs.getCorporateById(corporateId); StreamResource resource = new StreamResource(source, "AlphaList-" + corporateName + "-" + tradeName + "-" + branchName + "-" + date.getTime() + ".xls"); resource.setMIMEType("application/vnd.ms-office"); Page.getCurrent().open(resource, null, false); }); return exportToExcelButton; }
From source file:com.hris.payroll.thirteenthmonth.ThirteenthMonth.java
private Button exportToExcelButton() { exportToExcelButton.setWidth("200px"); exportToExcelButton.setIcon(FontAwesome.EXCLAMATION_CIRCLE); exportToExcelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportToExcelButton.addStyleName(ValoTheme.BUTTON_SMALL); exportToExcelButton.addClickListener((Button.ClickEvent e) -> { ExportDataGridToExcel exportGrid = new ExportDataGridToExcel(grid); exportGrid.workSheet();//from w ww. ja v a 2 s. c o m StreamResource.StreamSource source = () -> { try { File f = new File(exportGrid.getFilePath()); FileInputStream fis = new FileInputStream(f); return fis; } catch (Exception e1) { e1.getMessage(); return null; } }; Date date = new Date(); String branchName = cs.getBranchById(getBranchId()); int tradeId = cs.getTradeIdByBranchId(getBranchId()); String tradeName = cs.getTradeById(tradeId); int corporateId = cs.getCorporateIdByTradeId(tradeId); String corporateName = cs.getCorporateById(corporateId); StreamResource resource = new StreamResource(source, "ThirteenthMonth-" + corporateName + "-" + tradeName + "-" + branchName + "-" + date.getTime() + ".xls"); resource.setMIMEType("application/vnd.ms-office"); Page.getCurrent().open(resource, null, false); }); return exportToExcelButton; }
From source file:com.hybridbpm.ui.component.chart.color.ChartColorLayout.java
License:Apache License
private void fillTable() { colorTable.removeAllItems();// w ww.j a v a2 s. c o m int rowIndex = 0; final Map<String, String> valueColourMap = getPreferenceValue(DiagrammePreference.VALUE_COLOUR_MAP, preferences); Iterator<Map.Entry<String, String>> it = valueColourMap.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, String> entry = it.next(); int[] d = ColourUtil.decode(entry.getValue()); final Color c = new SolidColor(d[0], d[1], d[2]); ColorPicker picker = new ColorPicker(); picker.setColor(new com.vaadin.shared.ui.colorpicker.Color(ColourUtil.decode(c.toString())[0], ColourUtil.decode(c.toString())[1], ColourUtil.decode(c.toString())[2])); picker.setPosition(Page.getCurrent().getBrowserWindowWidth() / 2 - 246 / 2, Page.getCurrent().getBrowserWindowHeight() / 2 - 507 / 2); picker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { valueColourMap.put(entry.getKey(), event.getColor().getCSS()); preferences.getItemDataSource().getItemProperty(DiagrammePreference.VALUE_COLOUR_MAP) .setValue(valueColourMap); // chartLayout.getConfigurationLayout().getLookAndFeelLayout().renderChart(); } }); colorTable.addItem(new Object[] { entry.getKey(), picker }, rowIndex); rowIndex++; } }
From source file:com.hybridbpm.ui.component.chart.color.GaugeBandLayout.java
License:Apache License
public GaugeBandLayout(final BeanFieldGroup<DiagrammePreference> preferences) { super(preferences); setCaption("Gauge Band Colors"); setSizeFull();/*w w w . j a v a 2 s. c om*/ setSpacing(true); setMargin(false); addBandButton.setIcon(FontAwesome.PLUS); addBandButton.setStyleName(ValoTheme.BUTTON_BORDERLESS); addBandButton.addStyleName(ValoTheme.BUTTON_SMALL); bandAdditionButtonFrame.setSpacing(true); bandAdditionButtonFrame.addComponent(addBandButton); bandAdditionButtonFrame.setComponentAlignment(addBandButton, Alignment.MIDDLE_RIGHT); addComponent(bandAdditionButtonFrame); addBandButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addBand(); } }); colorTable.setHeight("100%"); colorTable.setWidth("100%"); colorTable.addStyleName(ValoTheme.TABLE_COMPACT); colorTable.addStyleName(ValoTheme.TABLE_SMALL); colorTable.addStyleName("color-table"); colorTable.addContainerProperty(Translate.getMessage("colour"), ColorPicker.class, null); colorTable.addContainerProperty(Translate.getMessage("start"), TextField.class, null); colorTable.addContainerProperty(Translate.getMessage("end"), TextField.class, null); colorTable.addContainerProperty("remove", Button.class, null); // COLOR COLUMN colorTable.addGeneratedColumn(Translate.getMessage("colour"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<String> colorProp = tableContainer.getItem(itemId).getItemProperty("color"); int[] col = ColourUtil.decode(colorProp.getValue()); ColorPicker picker = new ColorPicker(); picker.addStyleName("diagramme"); picker.setPosition(Page.getCurrent().getBrowserWindowWidth() / 2 - 246 / 2, Page.getCurrent().getBrowserWindowHeight() / 2 - 507 / 2); picker.setColor(new com.vaadin.shared.ui.colorpicker.Color(col[0], col[1], col[2])); picker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { colorProp.setValue(event.getColor().getCSS()); updateDiagramme(); } }); picker.setWidth("25px"); return picker; } }); // BAND START COLUMN colorTable.addGeneratedColumn(Translate.getMessage("start"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<Double> startProp = tableContainer.getContainerProperty(itemId, "startValue"); final ObjectProperty<Double> startValue = new ObjectProperty<Double>(0.0); TextField startField = new TextField(startValue); //startField.setWidth("60px"); startField.setSizeFull(); startField.setNullRepresentation("0"); startField.addStyleName("tfwb"); startField.setConvertedValue(startProp.getValue()); startField.setImmediate(true); startValue.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { startProp.setValue((Double) event.getProperty().getValue()); updateDiagramme(); } }); return startField; } }); // BAND END COLUMN colorTable.addGeneratedColumn(Translate.getMessage("end"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<Double> endProp = tableContainer.getContainerProperty(itemId, "endValue"); final ObjectProperty<Double> endValue = new ObjectProperty<Double>(0.0); TextField endField = new TextField(endValue); //endField.setWidth("60px"); endField.setSizeFull(); endField.setNullRepresentation("0"); endField.addStyleName("tfwb"); endField.setConvertedValue(endProp.getValue()); endField.setImmediate(true); endValue.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { endProp.setValue((Double) valueChangeEvent.getProperty().getValue()); updateDiagramme(); } }); return endField; } }); // DELETE BAND COLUMN colorTable.addGeneratedColumn("remove", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, final Object itemId, Object columnId) { Button delete = new Button(FontAwesome.TIMES); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { removeBand(itemId); } }); delete.setWidth("43px"); return delete; } }); colorTable.setColumnWidth(Translate.getMessage("colour"), 33); colorTable.setColumnWidth("remove", 48); colorTable.setColumnExpandRatio(Translate.getMessage("start"), 0.5f); colorTable.setColumnExpandRatio(Translate.getMessage("end"), 0.5f); colorTable.setSortEnabled(false); colorTable.setPageLength(0); colorTable.setEditable(true); colorTable.setImmediate(true); addComponent(colorTable); setExpandRatio(colorTable, 1f); setComponentAlignment(colorTable, Alignment.TOP_LEFT); }
From source file:com.klwork.explorer.NotificationManager.java
License:Apache License
public void showWarningNotification(String captionKey, String descriptionKey, Object... params) { Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>", MessageFormat.format(i18nManager.getMessage(descriptionKey), params), Notification.Type.WARNING_MESSAGE); notification.setDelayMsec(5000); // click to hide notification.show(Page.getCurrent()); }
From source file:com.klwork.explorer.ViewToolManager.java
License:Apache License
public static void logout() { UI.getCurrent().close(); Page.getCurrent().setLocation(webContextPath + "/logout/"); LoginHandler.logout(); }
From source file:com.logicbomb.newschool.pages.LoginPage.java
public LoginPage() { int pageWidth = Page.getCurrent().getBrowserWindowWidth(); int pageHeight = Page.getCurrent().getBrowserWindowHeight(); addStyleName("body"); setWidth(pageWidth, Unit.PIXELS);/*from ww w . ja v a 2 s.co m*/ setHeight(pageHeight, Unit.PIXELS); LoginWidget iLoginWidget = new LoginWidget(); ComponentPosition iComponentPosition = new ComponentPosition(); iComponentPosition.setLeft((float) pageWidth - 700, Unit.PIXELS); iComponentPosition.setTop((float) pageHeight - 400, Unit.PIXELS); addComponent(iLoginWidget); setPosition(iLoginWidget, iComponentPosition); }
From source file:com.logicbomb.newschool.pages.masterpages.PrimaryMasterPage.java
public PrimaryMasterPage() { //ContextWidget c= new ContextWidget(); HorizontalLayout iHorizontalLayout = new HorizontalLayout(); //addComponent(iHorizontalLayout,"top:0px;left:0px"); iHorizontalLayout.setWidth(String.valueOf(Page.getCurrent().getBrowserWindowWidth())); iHorizontalLayout.setHeight(String.valueOf(Page.getCurrent().getBrowserWindowHeight())); iHorizontalLayout.setStyleName("backColorBlack"); //String[] captions1 = {"Logo Here", "My Cool School", "Third"}; //Layout A and its sub components Panel AP = new Panel(); iHorizontalLayout.addComponent(AP);//from www . ja va 2 s . c o m AP.setSizeFull(); AP.setStyleName("backColorBlack"); VerticalLayout A1 = new VerticalLayout(); AP.setContent(A1); //A.setSizeFull(); A1.setSpacing(true); iHorizontalLayout.setExpandRatio(AP, 1); A1.setStyleName("backColorBlack"); A1.setMargin(new MarginInfo(true, true, true, true)); Button logoImage = new Button(); logoImage.setIcon(FontAwesome.PICTURE_O); logoImage.setWidth("80px"); logoImage.setHeight(logoImage.getWidth(), Unit.PIXELS); //logoImage.setWidth("100px"); A1.addComponent(logoImage); A1.setComponentAlignment(logoImage, Alignment.TOP_CENTER); Label schoolName = new Label("The School Of Future"); schoolName.setStyleName("v-label-big"); A1.addComponent(schoolName); //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER); Label schoolMinorName = new Label("Random Branch"); schoolMinorName.setStyleName("v-label-small"); A1.addComponent(schoolMinorName); VerticalLayout A2 = new VerticalLayout(); A1.addComponent(A2); MainMenuWidget iMainMenuWidget = new MainMenuWidget(); A2.addComponent(iMainMenuWidget); //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER); //Layout B ContextWidgetTop c = new ContextWidgetTop(); c = ContextWidgetTop.ContextWidgetTransformer(c, new UserDetailsWidget(), SliderMode.TOP, SliderPanelStyles.COLOR_RED); VerticalLayout B = new VerticalLayout(); B.setSizeFull(); //B.setSpacing(true); iHorizontalLayout.addComponent(c); c.addComponent(B); iHorizontalLayout.setExpandRatio(c, 7); //Layout B1 and its sub Components HorizontalLayout B1 = new HorizontalLayout(); B.addComponent(B1); //B.setExpandRatio(B1, 1); //B1.setHeight("70px"); B1.setSizeFull(); //B1=ContextWidget.ContextWidgetTransformer(B1, new SliderMasterPage(),SliderMode.RIGHT,SliderPanelStyles.COLOR_RED); HorizontalLayout B11 = new HorizontalLayout(); B1.addComponent(B11); B1.setStyleName("backColorBlack"); B11.setSizeFull(); B1.setHeight("45px"); //B1.setStyleName("backColorWhite"); //B1.setMargin(new MarginInfo(false, true, false, true)); TextField iTextField = new TextField(); iTextField.setWidth("200px"); iTextField.setInputPrompt("Search!"); iTextField.setStyleName("v-text-type-search"); iTextField.focus(); B11.addComponent(iTextField); B11.setComponentAlignment(iTextField, Alignment.MIDDLE_LEFT); //Layout B2 and its Sub Components ContextWidget B2 = new ContextWidget(); B2.setSizeFull(); B.addComponent(B2); B.setExpandRatio(B2, 10); B2 = ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(), SliderMode.RIGHT, SliderPanelStyles.COLOR_BLUE); //B2=ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(),SliderMode.TOP,SliderPanelStyles.COLOR_RED); VerticalLayout v = new VerticalLayout(); B2.addComponent(v); Button b1111 = new Button( "Put all the inner components like this Put all the inner components like this Put all the inner components like this Put all the inner components like this"); v.addComponent(b1111); Button b1112 = new Button("Put all the inner components like this"); v.addComponent(b1112); /* Panel p = new Panel(); VerticalLayout v= new VerticalLayout(); v.addComponent(new TextField("Name")); v.addComponent(new TextField("Street address")); v.addComponent(new TextField("Postal code")); p.setContent(v); B2.addComponent(p); v.setWidth(String.valueOf(B2.getWidth()*10)+"px"); //v.setSizeFull();// <- This will cause issues. Don't do this p.setSizeFull(); */ //ContextWidget iContextPanel= new ContextWidget(p); //B2.addComponent(iContextPanel); //setPosition(p, iComponentPositionPanel); addComponent(iHorizontalLayout); }
From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java
License:Open Source License
@Override public void showNotification(Notification notif) { notif.show(Page.getCurrent()); }