private void updateWidth() { if (getWidth() == 0) { setWidth(DEFAULT_SIZE); return; } if (orientation == HORIZONTAL) { incButton.setX(getWidth() - incButton.getWidth()); slider.setX(decButton.getWidth()); slider.setWidth(getWidth() - (incButton.getWidth() + decButton.getWidth())); } else { // VERTICAL incButton.setWidth(Math.min(getWidth(), incButton.getWidth())); decButton.setWidth(Math.min(getWidth(), decButton.getWidth())); slider.setWidth(Math.min(getWidth(), slider.getWidth())); slider.setX(getWidth() / 2f - slider.getWidth() / 2f); incButton.setX(getWidth() / 2f - incButton.getWidth() / 2f); decButton.setX(getWidth() / 2f - incButton.getWidth() / 2f); } }
public HeroesSelectGUI(HeroesHUD plugin, SpoutPlayer spoutp) { this.plugin = plugin; this.spoutp = spoutp; GenericTexture backgroundMain = new GenericTexture(); int screenWidth = spoutp.getMainScreen().getWidth(); int screenHeight = spoutp.getMainScreen().getHeight(); int x = (screenWidth / 2) - 170; int y = (screenHeight / 2) - 100; // BackgroundMain! backgroundMain.setX(x).setY(y); backgroundMain.setWidth(340).setHeight(200); backgroundMain.setUrl(plugin.HeroesSelectGuiBackgroundMain); backgroundMain.setFixed(false); backgroundMain.setPriority(RenderPriority.Highest); // Button1 Main button1 = new GenericButton(); button1.setText("Primary"); button1 .setWidth(GenericLabel.getStringWidth(button1.getText()) + 5 + 30) .setHeight(GenericLabel.getStringHeight(button1.getText()) + 5); button1.setX(backgroundMain.getX() + 20); button1.setY(backgroundMain.getY() + 65); button1.setDirty(true); button1.setAutoDirty(true); // Button2 Main button2 = new GenericButton(); button2.setText("Profession"); button2 .setWidth(GenericLabel.getStringWidth(button2.getText()) + 5 + 30) .setHeight(GenericLabel.getStringHeight(button2.getText()) + 5); button2.setX(backgroundMain.getX() + 235); button2.setY(backgroundMain.getY() + 65); button2.setDirty(true); button2.setAutoDirty(true); super.attachWidgets(plugin, backgroundMain, button1, button2); super.setAnchor(WidgetAnchor.TOP_LEFT); }
public LoginModule() { setMargin(true); setSpacing(true); grid.setSizeFull(); grid.setSpacing(true); final TextField username = new TextField(); username.setValue("username"); username.setWidth("120px"); username.setStyleName("small"); grid.addComponent(username, 0, 0); final PasswordField password = new PasswordField(); password.setValue("password"); password.setWidth("120px"); password.setStyleName("small"); grid.addComponent(password, 0, 1); Button button = new Button("Login"); button.setWidth("120px"); button.setStyleName("small"); button.addListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { login.setUsername(username.getValue().toString()); login.setPassword(password.getValue().toString()); String user = login.getUsername(); String pass = login.getPassword(); // login.setResult(authLog.login(user, pass)); boolean result = authLog.login(user, pass); if (result == true) { label.setCaption("Successfully Login"); } else { label.setCaption("SQL Error"); } } }); grid.addComponent(button, 0, 2); panel.addComponent(grid); addComponent(panel); addComponent(label); }
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Filter:")); final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox(); savedFilterComboBox.addQuerySelectListener( new SavedFilterComboBox.QuerySelectListener() { @Override public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) { List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos(); TaskSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos); criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria)); } }); groupWrapLayout.addComponent(savedFilterComboBox); groupWrapLayout.addComponent(new Label("Sort:")); final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING); sortCombo.setWidth("100px"); sortCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (ASCENDING.equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by:")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST); groupCombo.setWidth("100px"); groupCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); } }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); Button exportBtn = new Button("Export"); final SplitButton exportSplitBtn = new SplitButton(exportBtn); exportBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { exportSplitBtn.setPopupVisible(true); } }); exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button exportPdfBtn = new Button("PDF"); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF)); pdfFileDownloder.extend(exportPdfBtn); popupButtonsControl.addOption(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); FileDownloader excelFileDownloader = new FileDownloader(buildStreamSource(ReportExportType.EXCEL)); excelFileDownloader.extend(exportExcelBtn); popupButtonsControl.addOption(exportExcelBtn); exportSplitBtn.setContent(popupButtonsControl); groupWrapLayout.with(exportSplitBtn); Button newTaskBtn = new Button( AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP)); newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button(); advanceDisplayBtn.setWidth("50px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription( AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP)); Button calendarBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this)); } }); calendarBtn.setWidth("50px"); calendarBtn.setDescription("Calendar View"); calendarBtn.setIcon(FontAwesome.CALENDAR); Button chartDisplayBtn = new Button( null, new Button.ClickListener() { private static final long serialVersionUID = -5707546605789537298L; @Override public void buttonClick(ClickEvent event) { displayGanttChartView(); } }); chartDisplayBtn.setWidth("50px"); chartDisplayBtn.setDescription("Display Gantt chart"); chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O); Button kanbanBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("50px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(calendarBtn); viewButtons.addButton(kanbanBtn); viewButtons.addButton(chartDisplayBtn); viewButtons.setDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout() .withWidth("350px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); }
/** @param el */ public BookImage(Books el, String user) { super(); this.Book = el; this.setStyleName("cells"); this.setHeight("250px"); this.setWidth("200px"); rating.setAnimated(true); rating.setCaption(null); rating.setMaxValue(5); rating.setStyleName("rating"); rating.setReadOnly(true); rating_my.setAnimated(true); rating_my.setCaption(null); rating_my.setMaxValue(5); rating_my.setStyleName("rating_my"); IRaitingService iRaitingService = new IRaitingService(); try { double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); double myrate = iRaitingService.getRaiting(user, el.getId()); rating_my.setValue(myrate); } catch (SQLException e) { e.printStackTrace(); } rating_my.addValueChangeListener( e -> { try { Rating rat = iRaitingService.getUser( getUI().getSession().getAttribute("user").toString(), el.getId()); rat.setRaiting(rating_my.getValue()); iRaitingService.update(rat); double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION) .show(Page.getCurrent()); } catch (SQLException e1) { e1.printStackTrace(); } }); rating_layout.addComponent(rating); rating_layout.addComponent(rating_my); rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT); rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT); rating_layout.setStyleName("ratinglayout"); imageEmbedded.setSource(new FileResource(new File(Book.getImage()))); title.setValue(Book.getTitle()); author.setValue(Book.getAuthor()); if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false); buttonDownload.setWidth("80%"); imageEmbedded.setWidth("100%"); imageEmbedded.setHeight("100%"); title.setWidth(null); author.setWidth(null); VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded); bodyLayout.setExpandRatio(title, 12); bodyLayout.setExpandRatio(author, 8); bodyLayout.setExpandRatio(imageEmbedded, 80); bodyLayout.setSizeFull(); bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER); buttonDownload.setStyleName("super-button"); title.setStyleName("name-label"); author.setStyleName("author-label"); this.addComponent(rating_layout); this.addComponent(bodyLayout); this.addComponent(buttonDownload); this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER); this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER); this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER); this.setExpandRatio(rating_layout, 5); this.setExpandRatio(bodyLayout, 85); this.setExpandRatio(buttonDownload, 10); StreamResource sr = getStream(); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(buttonDownload); bodyLayout.addLayoutClickListener( e -> { BookWin win = new BookWin(this.Book); UI.getCurrent().addWindow(win); }); }
@Override public void execute() { List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good); Window subWindow = new Window(); subWindow.setModal(true); subWindow.setHeight("650px"); subWindow.setWidth("700px"); subWindow.setClosable(true); view.getUi().addWindow(subWindow); final Button pdfButton = new Button(bundle.getString("pdf.export")); pdfButton.setIcon(new ThemeResource("img/pdf.png")); pdfButton.setWidth("150"); StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good)); pdfStream.setMIMEType("application/pdf"); FileDownloader pdfDownloader = new FileDownloader(pdfStream); pdfDownloader.extend(pdfButton); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(pdfButton); for (ChangeRecord record : historyList) { for (ChangeRecord.PropertyChange p : record.getChangeList()) { p.setName(bundle.getString(p.getName())); } Panel panel = new Panel(); BeanItemContainer<ChangeRecord.PropertyChange> container = new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList()); Table table = new Table(); table.setContainerDataSource(container); table.setVisibleColumns("name", "oldValue", "newValue"); table.setColumnHeaders( bundle.getString("history.property"), bundle.getString("history.old"), bundle.getString("history.new")); table.setColumnExpandRatio("name", 0.33f); table.setColumnExpandRatio("oldValue", 0.33f); table.setColumnExpandRatio("newValue", 0.33f); table.setPageLength(0); table.setWidth("100%"); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.addComponent( new Label( "<b>" + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate()) + ": " + record.getUser().getName() + " " + record.getUser().getSurname() + "</b><br/>", ContentMode.HTML)); panelLayout.addComponent(table); panel.setContent(panelLayout); layout.addComponent(panel); } subWindow.setContent(layout); }