List of usage examples for com.vaadin.ui Window Window
public Window(String caption, Component content)
From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java
private Window editDateEntryWindow(final String entryDate) { VerticalLayout vlayout = new VerticalLayout(); vlayout.setWidth("100%"); vlayout.setMargin(true);/*from w w w. j a v a 2 s . co m*/ vlayout.setSpacing(true); final Window window = new Window("EDIT DATE ENTRY", vlayout); window.setResizable(false); Button editBtn = new Button("EDIT DATE ENTRY?"); editBtn.setWidth("100%"); editBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean result = si.editEmploymentDateEntry(getEmployeeId(), entryDate); if (result) { getWindow().showNotification("Update Entry Date.", Window.Notification.TYPE_TRAY_NOTIFICATION); (window.getParent()).removeWindow(window); } } }); window.addComponent(editBtn); return window; }
From source file:com.openhris.payroll.AdjustmentWindow.java
private Window removeAdjustment(final int adjustmentId, final double amountToBeReceive, final double amountReceived, final double adjustment, final int payrollId) { VerticalLayout vlayout = new VerticalLayout(); vlayout.setMargin(true);//www.ja v a 2s . c o m vlayout.setSpacing(true); final Window subWindow = new Window("REMOVE ADVANCES", vlayout); subWindow.setWidth("200px"); Button removeAdjBtn = new Button("REMOVE ADJUSTMENT?"); removeAdjBtn.setWidth("100%"); removeAdjBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean result = payrollService.removeAdjustmentById(adjustmentId, amountToBeReceive, amountReceived, adjustment, payrollId); if (result) { (subWindow.getParent()).removeWindow(subWindow); adjustmentTable(); } } }); subWindow.addComponent(removeAdjBtn); return subWindow; }
From source file:com.openhris.payroll.PayrollSubModules.java
public Window perDiemWindow(Item item) { this.item = item; VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/*from ww w . ja v a 2s.c om*/ vlayout.setMargin(true); final Window sub = new Window("PER DIEM", vlayout); sub.setWidth("220px"); sub.setModal(true); sub.center(); final TextField perDiemAmount = new TextField("Amount: "); perDiemAmount.setWidth("100%"); perDiemAmount .setValue(util.convertStringToDouble(getPayrollTableItem().getItemProperty("per diem").toString())); perDiemAmount.setNullSettingAllowed(false); sub.addComponent(perDiemAmount); Button save = new Button("SAVE"); save.setWidth("100%"); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { int payrollId = util .convertStringToInteger(getPayrollTableItem().getItemProperty("id").getValue().toString()); double amountToBeReceive = util.convertStringToDouble( getPayrollTableItem().getItemProperty("amount to be receive").toString()); double amountReceived = util .convertStringToDouble(getPayrollTableItem().getItemProperty("amount received").toString()); double amount = util.convertStringToDouble(perDiemAmount.getValue().toString()) - util.convertStringToDouble( getPayrollTableItem().getItemProperty("per diem").getValue().toString()); boolean result = ps.addPerDiem(payrollId, util.convertStringToDouble(perDiemAmount.getValue().toString()), util.convertStringToDouble( getPayrollTableItem().getItemProperty("per diem").getValue().toString()), amountToBeReceive, amountReceived); if (result) { getPayrollTableItem().getItemProperty("amount to be receive") .setValue(amountToBeReceive + amount); getPayrollTableItem().getItemProperty("amount received").setValue(amountReceived + amount); getPayrollTableItem().getItemProperty("per diem").setValue(perDiemAmount.getValue()); (sub.getParent()).removeWindow(sub); } } }); sub.addComponent(save); return sub; }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Initializes a modal window to edit schedule event. * * @param event the event/* w ww.j av a 2 s. com*/ * @param newEvent the new event */ private void createCalendarEventPopup(CalendarCustomEvent event, boolean newEvent) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); scheduleEventPopup = new Window(null, layout); scheduleEventPopup.setWidth("400px"); scheduleEventPopup.setModal(true); scheduleEventPopup.center(); Date occurrence = event.getOccurrence(); if (!newEvent && occurrence != null) { Form form = new Form(); form.setCaption("This is a repeat occurrence"); layout.addComponent(form); DateField dateField = new DateField("Occurrence Start"); if (useSecondResolution) { dateField.setResolution(Resolution.SECOND); } else { dateField.setResolution(Resolution.MINUTE); } dateField.setValue(event.getStart()); dateField.setEnabled(false); form.addField("dateField", dateField); form.setFooter(null); HorizontalLayout editLayout = new HorizontalLayout(); editLayout.setSpacing(true); layout.addComponent(editLayout); final Label label = new Label("Click to change the original event below:"); editLayout.addComponent(label); editLayout.setComponentAlignment(label, Alignment.BOTTOM_LEFT); editOriginalButton = new Button("Edit", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent clickEvent) { scheduleEventForm.setEnabled(true); applyEventButton.setEnabled(true); label.setValue("Editing original event:"); editOriginalButton.setVisible(false); } }); editLayout.addComponent(editOriginalButton); scheduleEventForm.setEnabled(false); } else { scheduleEventForm.setEnabled(true); } layout.addComponent(scheduleEventForm); applyEventButton = new Button("Add", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { commitCalendarEvent(); } }); Button cancel = new Button("Cancel", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { discardCalendarEvent(); } }); deleteEventButton = new Button("Delete", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { deleteCalendarEvent(); } }); scheduleEventPopup.addListener(new CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { discardCalendarEvent(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(deleteEventButton); buttons.addComponent(cancel); buttons.addComponent(applyEventButton); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Show delete popup.//from w ww . j a v a 2s . c o m * * @param event the event */ private void showDeletePopup(final CalendarCustomEvent event) { if (event == null) { return; } VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); deleteSchedulePopup = new Window("Delete Recurring Event", layout); deleteSchedulePopup.setWidth("740px"); deleteSchedulePopup.setModal(true); deleteSchedulePopup.center(); deleteSchedulePopup.setContent(layout); deleteSchedulePopup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { UI.getCurrent().removeWindow(deleteSchedulePopup); } }); Label warning = new Label( "Do you want to delete the original event, or this and all future occurrences of the event, or only the selected occurrence?"); layout.addComponent(warning); Button cancel = new Button("Cancel", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(deleteSchedulePopup); } }); Button deleteAll = new Button("Delete Original Event", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); Schedule.delete(scheduleID); schedule.getScheduleList().remove(scheduleID); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); Button deleteFuture = new Button("Delete All Future Events", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID); VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal()); ManagerUI.log("before Delete All Future Events\n" + vEvent); iCalSupport.deleteAllFuture(vEvent, event.getStart()); ManagerUI.log("after Delete All Future Events\n" + vEvent); scheduleRecord.setICal(vEvent.toString()); Schedule.update(scheduleID, vEvent.toString()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } schedule.getScheduleList().put(scheduleID, scheduleRecord); addEventsToMap(scheduleID, vEvent, event.getNode()); eventsList = eventsMap.get(scheduleID); for (CalendarCustomEvent addEvent : eventsList) { if (!dataSource.containsEvent(addEvent)) { dataSource.addEvent(addEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); Button deleteSelected = new Button("Delete Only This Event", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID); VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal()); ManagerUI.log("before Exclude\n" + vEvent); iCalSupport.addExcludedDate(vEvent, event.getStart()); ManagerUI.log("after Exclude\n" + vEvent); scheduleRecord.setICal(vEvent.toString()); Schedule.update(scheduleID, vEvent.toString()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } schedule.getScheduleList().put(scheduleID, scheduleRecord); addEventsToMap(scheduleID, vEvent, event.getNode()); eventsList = eventsMap.get(scheduleID); for (CalendarCustomEvent addEvent : eventsList) { if (!dataSource.containsEvent(addEvent)) { dataSource.addEvent(addEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(cancel); buttons.addComponent(deleteAll); buttons.addComponent(deleteFuture); buttons.addComponent(deleteSelected); deleteSelected.focus(); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); if (!UI.getCurrent().getWindows().contains(deleteSchedulePopup)) { UI.getCurrent().addWindow(deleteSchedulePopup); } }
From source file:de.fatalix.timeline.web.root.block.TimelineConfigLayout.java
private Layout createRightSide() { status = new Label("STATUS"); timelineURL = new Link("Timeline Link", new ExternalResource("http://")); timelineURL.setTargetName("_blank"); saveTimeline = new Button("Save Timeline", new Button.ClickListener() { @Override//w ww. jav a 2 s . c o m public void buttonClick(Button.ClickEvent event) { saveEvent.select(new AnnotationLiteral<RootViewPresenter.Save>() { }).fire(new TimelineCallback.SaveTimeline() { @Override public void showResult(String message) { status.setValue(message); } @Override public Timeline getTimelineData() { data.setHeadline(headline.getValue()); data.setText(text.getValue()); data.setStartDate(startDate.getValue()); Collection<TimelineEvent> events = new ArrayList<>(); for (TimelineEventLayout eventLayout : eventLayouts) { events.add(eventLayout.getTimelineEventData()); } data.setEvents(events); return data; } }); loadEvent.select(new AnnotationLiteral<RootViewPresenter.Load>() { }).fire(new TimelineCallback.LoadTimeline() { @Override public void loadTimeline(Timeline data) { loadTimelineData(data); } @Override public int getTimelineId() { return data.getId(); } }); } }); exportTimeline = new Button("export", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { exportEvent.select(new AnnotationLiteral<RootViewPresenter.Export>() { }).fire(new TimelineCallback.ExportTimeline() { @Override public int getTimelineId() { return data.getId(); } @Override public void showJsonResult(String json) { Window dialog = new Window("JSON Format", new Label(json, ContentMode.PREFORMATTED)); dialog.setModal(true); UI.getCurrent().addWindow(dialog); } }); } }); return new VerticalLayout(saveTimeline, status, timelineURL, exportTimeline); }
From source file:fi.pss.cleanbeach.standalone.map.MapComponent.java
public void addPoint(final fi.pss.cleanbeach.data.Event e) { Location l = e.getLocation(); LMarker m = new LMarker(l.getLatitude(), l.getLongitude()); m.setData(l);/*from w ww . j av a 2 s .c om*/ addComponent(m); setIcon(m, l); m.setIconAnchor(new Point(16, 32)); m.addClickListener(new LeafletClickListener() { @Override public void onClick(LeafletClickEvent event) { details.update(e); Window pop = new Window(null, details); pop.setResizable(false); pop.addStyleName("detailpop"); pop.setModal(true); getUI().addWindow(pop); setCenter(e.getLocation().getLatitude(), e.getLocation().getLongitude() + getDetailsPosOffset()); } }); markers.put(l, m); }
From source file:fi.semantum.strategia.Main.java
License:Open Source License
@Override protected void init(VaadinRequest request) { getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { public void uriFragmentChanged(UriFragmentChangedEvent source) { applyFragment(source.getUriFragment(), true); }/*from w w w . ja v a2s . c om*/ }); String pathInfo = request.getPathInfo(); if (pathInfo.startsWith("/")) pathInfo = pathInfo.substring(1); if (pathInfo.endsWith("/")) pathInfo = pathInfo.substring(0, pathInfo.length() - 1); String databaseId = validatePathInfo(pathInfo); setWindowWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent().getBrowserWindowHeight()); // Find the application directory String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); // Image as a file resource redResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_red.png")); greenResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_green.png")); blackResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_black.png")); mapMagnify = new FileResource(new File(basepath + "/WEB-INF/images/map_magnify.png")); abs = new AbsoluteLayout(); final VerticalLayout vs = new VerticalLayout(); vs.setSizeFull(); abs.addComponent(vs); setContent(abs); // This will set the login cookie Wiki.login(this); // Make sure that the printing directory exists new File(Main.baseDirectory(), "printing").mkdirs(); database = Database.load(this, databaseId); database.getOrCreateTag("Tavoite"); database.getOrCreateTag("Painopiste"); for (Strategiakartta map : Strategiakartta.enumerate(database)) { Strategiakartta parent = map.getPossibleParent(database); if (parent == null) uiState.setCurrentMap(parent); } if (uiState.getCurrentMap() == null) uiState.setCurrentMap(database.getRoot()); uiState.currentPosition = uiState.getCurrentMap(); uiState.currentItem = uiState.getCurrentMap(); setPollInterval(10000); addPollListener(new PollListener() { @Override public void poll(PollEvent event) { if (database.checkChanges()) { String curr = uiState.getCurrentMap().uuid; database = Database.load(Main.this, database.getDatabaseId()); uiState.setCurrentMap((Strategiakartta) database.find(curr)); Updates.updateJS(Main.this, false); } } }); js.addListener(new MapListener(this, false)); js2.addListener(new MapListener(this, true)); browser_.addListener(new BrowserListener() { @Override public void select(double x, double y, String uuid) { Base b = database.find(uuid); Actions.selectAction(Main.this, x, y, null, b); } @Override public void save(String name, Map<String, BrowserNodeState> states) { UIState state = getUIState().duplicate(name); state.browserStates = states; account.uiStates.add(state); Updates.update(Main.this, true); } }); Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() { @Override public void browserWindowResized(BrowserWindowResizeEvent event) { setWindowWidth(event.getWidth(), event.getHeight()); Updates.updateJS(Main.this, false); } }); modeLabel = new Label("Katselutila"); modeLabel.setWidth("95px"); modeLabel.addStyleName("viewMode"); mode = new Button(); mode.setDescription("Siirry tiedon sytttilaan"); mode.setIcon(FontAwesome.EYE); mode.addStyleName(ValoTheme.BUTTON_TINY); mode.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if ("Siirry tiedon sytttilaan".equals(mode.getDescription())) { mode.setDescription("Siirry katselutilaan"); mode.setIcon(FontAwesome.PENCIL); modeLabel.setValue("Sytttila"); modeLabel.removeStyleName("viewMode"); modeLabel.addStyleName("editMode"); UIState s = uiState.duplicate(Main.this); s.input = true; setFragment(s, true); } else { mode.setDescription("Siirry tiedon sytttilaan"); mode.setIcon(FontAwesome.EYE); modeLabel.setValue("Katselutila"); modeLabel.removeStyleName("editMode"); modeLabel.addStyleName("viewMode"); UIState s = uiState.duplicate(Main.this); s.input = false; setFragment(s, true); } } }); meterMode = new Button(); meterMode.setDescription("Vaihda toteumamittareihin"); meterMode.setCaption("Ennuste"); meterMode.addStyleName(ValoTheme.BUTTON_TINY); meterMode.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if ("Vaihda toteumamittareihin".equals(meterMode.getDescription())) { meterMode.setDescription("Vaihda ennustemittareihin"); meterMode.setCaption("Toteuma"); UIState s = uiState.duplicate(Main.this); s.setActualMeters(); setFragment(s, true); } else { meterMode.setDescription("Vaihda toteumamittareihin"); meterMode.setCaption("Ennuste"); UIState s = uiState.duplicate(Main.this); s.setForecastMeters(); setFragment(s, true); } } }); pdf = new PDFButton(); pdf.setDescription("Tallenna kartta PDF-muodossa"); pdf.setIcon(FontAwesome.PRINT); pdf.addStyleName(ValoTheme.BUTTON_TINY); pdf.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Utils.print(Main.this); } }); propertyExcelButton = new Button(); propertyExcelButton.setDescription("Tallenna tiedot Excel-tiedostona"); propertyExcelButton.setIcon(FontAwesome.PRINT); propertyExcelButton.addStyleName(ValoTheme.BUTTON_TINY); OnDemandFileDownloader dl = new OnDemandFileDownloader(new OnDemandStreamSource() { private static final long serialVersionUID = 981769438054780731L; File f; Date date = new Date(); @Override public InputStream getStream() { String uuid = UUID.randomUUID().toString(); File printing = new File(Main.baseDirectory(), "printing"); f = new File(printing, uuid + ".xlsx"); Workbook w = new XSSFWorkbook(); Sheet sheet = w.createSheet("Sheet1"); int row = 1; for (List<String> cells : propertyCells) { Row r = sheet.createRow(row++); for (int i = 0; i < cells.size(); i++) { String value = cells.get(i); r.createCell(i).setCellValue(value); } } try { FileOutputStream s = new FileOutputStream(f); w.write(s); s.close(); } catch (Exception e) { e.printStackTrace(); } try { return new FileInputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } throw new IllegalStateException(); } @Override public void onRequest() { } @Override public long getFileSize() { return f.length(); } @Override public String getFileName() { return "Strategiakartta_" + Utils.dateString(date) + ".xlsx"; } }); dl.getResource().setCacheTime(0); dl.extend(propertyExcelButton); states = new ComboBox(); states.setWidth("250px"); states.addStyleName(ValoTheme.COMBOBOX_TINY); states.setInvalidAllowed(false); states.setNullSelectionAllowed(false); states.addValueChangeListener(statesListener); saveState = new Button(); saveState.setEnabled(false); saveState.setDescription("Tallenna nykyinen nkym"); saveState.setIcon(FontAwesome.BOOKMARK); saveState.addStyleName(ValoTheme.BUTTON_TINY); saveState.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Utils.saveCurrentState(Main.this); } }); class SearchTextField extends TextField { public boolean hasFocus = false; } final SearchTextField search = new SearchTextField(); search.setWidth("100%"); search.addStyleName(ValoTheme.TEXTFIELD_TINY); search.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); search.setInputPrompt("hae vapaasanahaulla valitun asian alta"); search.setId("searchTextField"); search.addShortcutListener(new ShortcutListener("Shortcut Name", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { if (!search.hasFocus) return; String text = search.getValue().toLowerCase(); try { Map<String, String> content = new HashMap<String, String>(); List<String> hits = Lucene.search(database.getDatabaseId(), text + "*"); for (String uuid : hits) { Base b = database.find(uuid); if (b != null) { String report = ""; Map<String, String> map = b.searchMap(database); for (Map.Entry<String, String> e : map.entrySet()) { if (e.getValue().contains(text)) { if (!report.isEmpty()) report += ", "; report += e.getKey(); } } if (!report.isEmpty()) content.put(uuid, report); } } uiState.setCurrentFilter(new SearchFilter(Main.this, content)); Updates.updateJS(Main.this, false); switchToBrowser(); } catch (IOException e) { e.printStackTrace(); } } }); search.addFocusListener(new FocusListener() { @Override public void focus(FocusEvent event) { search.hasFocus = true; } }); search.addBlurListener(new BlurListener() { @Override public void blur(BlurEvent event) { search.hasFocus = false; } }); hallinnoi = new Button("Hallinnoi"); hallinnoi.setWidthUndefined(); hallinnoi.setVisible(false); hallinnoi.addStyleName(ValoTheme.BUTTON_TINY); hallinnoi.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { if (account.isAdmin()) { Utils.manage(Main.this); } } } }); tili = new Button("Kyttjtili"); tili.setWidthUndefined(); tili.setVisible(false); tili.addStyleName(ValoTheme.BUTTON_TINY); tili.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { Utils.modifyAccount(Main.this); } } }); duplicate = new Button("Avaa ikkunassa"); duplicate2 = new Button("Avaa alas"); duplicate.setWidthUndefined(); duplicate.addStyleName(ValoTheme.BUTTON_TINY); duplicate.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { MapVis model = js2.getModel(); if (model == null) { UIState s = uiState.duplicate(Main.this); s.reference = s.current; mapDialog = new Window(s.reference.getText(database), new VerticalLayout()); mapDialog.setWidth(dialogWidth()); mapDialog.setHeight(dialogHeight()); mapDialog.setResizable(true); mapDialog.setContent(js2Container); mapDialog.setVisible(true); mapDialog.setResizeLazy(false); mapDialog.addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { duplicate.setCaption("Avaa ikkunassa"); duplicate2.setVisible(true); UIState s = uiState.duplicate(Main.this); mapDialog.close(); mapDialog = null; s.reference = null; setFragment(s, true); } }); mapDialog.addResizeListener(new ResizeListener() { @Override public void windowResized(ResizeEvent e) { Updates.updateJS(Main.this, false); } }); setFragment(s, true); addWindow(mapDialog); duplicate.setCaption("Sulje referenssi"); duplicate2.setVisible(false); } else { UIState s = uiState.duplicate(Main.this); if (mapDialog != null) { mapDialog.close(); mapDialog = null; } panelLayout.removeComponent(js2Container); s.reference = null; setFragment(s, true); duplicate.setCaption("Avaa ikkunassa"); duplicate2.setVisible(true); } } }); duplicate2.setWidthUndefined(); duplicate2.addStyleName(ValoTheme.BUTTON_TINY); duplicate2.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { MapVis model = js2.getModel(); assert (model == null); UIState s = uiState.duplicate(Main.this); s.reference = s.current; setFragment(s, true); panelLayout.addComponent(js2Container); duplicate.setCaption("Sulje referenssi"); duplicate2.setVisible(false); } }); login = new Button("Kirjaudu"); login.setWidthUndefined(); login.addStyleName(ValoTheme.BUTTON_TINY); login.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { account = null; hallinnoi.setVisible(false); tili.setVisible(false); Updates.update(Main.this, true); login.setCaption("Kirjaudu"); } else { Login.login(Main.this); } } }); times = new ComboBox(); times.setWidth("130px"); times.addStyleName(ValoTheme.COMBOBOX_SMALL); times.addItem(Property.AIKAVALI_KAIKKI); times.addItem("2016"); times.addItem("2017"); times.addItem("2018"); times.addItem("2019"); times.select("2016"); times.setInvalidAllowed(false); times.setNullSelectionAllowed(false); times.addValueChangeListener(timesListener); final HorizontalLayout hl0 = new HorizontalLayout(); hl0.setWidth("100%"); hl0.setHeight("32px"); hl0.setSpacing(true); hl0.addComponent(pdf); hl0.setComponentAlignment(pdf, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(pdf, 0.0f); hl0.addComponent(propertyExcelButton); hl0.setComponentAlignment(propertyExcelButton, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(propertyExcelButton, 0.0f); hl0.addComponent(states); hl0.setComponentAlignment(states, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(states, 0.0f); hl0.addComponent(saveState); hl0.setComponentAlignment(saveState, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(saveState, 0.0f); hl0.addComponent(times); hl0.setComponentAlignment(times, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(times, 0.0f); hl0.addComponent(search); hl0.setComponentAlignment(search, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(search, 1.0f); hl0.addComponent(modeLabel); hl0.setComponentAlignment(modeLabel, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(modeLabel, 0.0f); hl0.addComponent(mode); hl0.setComponentAlignment(mode, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(mode, 0.0f); hl0.addComponent(meterMode); hl0.setComponentAlignment(meterMode, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(meterMode, 0.0f); hl0.addComponent(hallinnoi); hl0.setComponentAlignment(hallinnoi, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(hallinnoi, 0.0f); hl0.addComponent(tili); hl0.setComponentAlignment(tili, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(tili, 0.0f); hl0.addComponent(duplicate); hl0.setComponentAlignment(duplicate, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(duplicate, 0.0f); hl0.addComponent(duplicate2); hl0.setComponentAlignment(duplicate2, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(duplicate2, 0.0f); hl0.addComponent(login); hl0.setComponentAlignment(login, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(login, 0.0f); propertiesPanel = new Panel(); propertiesPanel.setSizeFull(); properties = new VerticalLayout(); properties.setSpacing(true); properties.setMargin(true); propertiesPanel.setContent(properties); propertiesPanel.setVisible(false); tags = new VerticalLayout(); tags.setSpacing(true); Updates.updateTags(this); AbsoluteLayout tabs = new AbsoluteLayout(); tabs.setSizeFull(); { panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setSizeFull(); panel.setId("mapContainer1"); panelLayout = new VerticalLayout(); panelLayout.addComponent(js); panelLayout.setHeight("100%"); js2Container = new VerticalLayout(); js2Container.setHeight("100%"); js2Container.addComponent(new Label("<hr />", ContentMode.HTML)); js2Container.addComponent(js2); panel.setContent(panelLayout); tabs.addComponent(panel); } wiki = new BrowserFrame(); wiki.setSource(new ExternalResource(Wiki.wikiAddress() + "/")); wiki.setWidth("100%"); wiki.setHeight("100%"); { wiki_ = new VerticalLayout(); wiki_.setSizeFull(); Button b = new Button("Palaa sovellukseen"); b.setWidth("100%"); b.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { applyFragment(backFragment, true); String content = Wiki.get(wikiPage); if (content == null) return; int first = content.indexOf("<rev contentformat"); if (first == -1) return; content = content.substring(first); int term = content.indexOf(">"); content = content.substring(term + 1); int end = content.indexOf("</rev>"); content = content.substring(0, end); if (wikiBase.modifyMarkup(Main.this, content)) { Updates.update(Main.this, true); } } }); wiki_.addComponent(b); wiki_.addComponent(wiki); wiki_.setVisible(false); wiki_.setExpandRatio(b, 0.0f); wiki_.setExpandRatio(wiki, 1.0f); tabs.addComponent(wiki_); } hs = new HorizontalSplitPanel(); hs.setSplitPosition(0, Unit.PIXELS); hs.setHeight("100%"); hs.setWidth("100%"); browser = new VerticalLayout(); browser.setSizeFull(); HorizontalLayout browserWidgets = new HorizontalLayout(); browserWidgets.setWidth("100%"); hori = new Button(); hori.setDescription("Nyt asiat taulukkona"); hori.setEnabled(true); hori.setIcon(FontAwesome.ARROW_RIGHT); hori.addStyleName(ValoTheme.BUTTON_TINY); hori.addClickListener(new ClickListener() { boolean right = false; @Override public void buttonClick(ClickEvent event) { if (right) { hs.setSplitPosition(0, Unit.PIXELS); hori.setIcon(FontAwesome.ARROW_RIGHT); hori.setDescription("Nyt asiat taulukkona"); right = false; } else { hs.setSplitPosition(windowWidth / 2, Unit.PIXELS); hori.setIcon(FontAwesome.ARROW_LEFT); hori.setDescription("Piilota taulukko"); right = true; } } }); more = new Button(); more.setDescription("Laajenna nytettvien asioiden joukkoa"); more.setIcon(FontAwesome.PLUS_SQUARE); more.addStyleName(ValoTheme.BUTTON_TINY); more.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { uiState.level++; Updates.updateJS(Main.this, false); if (uiState.level >= 2) less.setEnabled(true); } }); less = new Button(); less.setDescription("Supista nytettvien asioiden joukkoa"); less.setIcon(FontAwesome.MINUS_SQUARE); less.addStyleName(ValoTheme.BUTTON_TINY); less.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (uiState.level > 1) { uiState.level--; Updates.updateJS(Main.this, false); } if (uiState.level <= 1) less.setEnabled(false); } }); reportAllButton = new Button(); reportAllButton.setCaption("Nkyvt tulokset"); reportAllButton.addStyleName(ValoTheme.BUTTON_TINY); reportAllButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (uiState.reportAll) { reportAllButton.setCaption("Nkyvt tulokset"); uiState.reportAll = false; } else { reportAllButton.setCaption("Kaikki tulokset"); uiState.reportAll = true; } Updates.updateJS(Main.this, false); } }); reportStatus = new Label("0 tulosta."); reportStatus.setWidth("100px"); filter = new ComboBox(); filter.setWidth("100%"); filter.addStyleName(ValoTheme.COMBOBOX_SMALL); filter.setInvalidAllowed(false); filter.setNullSelectionAllowed(false); filter.addValueChangeListener(filterListener); browserWidgets.addComponent(hori); browserWidgets.setComponentAlignment(hori, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(hori, 0.0f); browserWidgets.addComponent(more); browserWidgets.setComponentAlignment(more, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(more, 0.0f); browserWidgets.addComponent(less); browserWidgets.setComponentAlignment(less, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(less, 0.0f); browserWidgets.addComponent(reportAllButton); browserWidgets.setComponentAlignment(reportAllButton, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(reportAllButton, 0.0f); browserWidgets.addComponent(reportStatus); browserWidgets.setComponentAlignment(reportStatus, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(reportStatus, 0.0f); browserWidgets.addComponent(filter); browserWidgets.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(filter, 1.0f); browser.addComponent(browserWidgets); browser.addComponent(hs); browser.setExpandRatio(browserWidgets, 0.0f); browser.setExpandRatio(hs, 1.0f); browser.setVisible(false); tabs.addComponent(browser); { gridPanelLayout = new VerticalLayout(); gridPanelLayout.setMargin(false); gridPanelLayout.setSpacing(false); gridPanelLayout.setSizeFull(); hs.addComponent(gridPanelLayout); } CssLayout browserLayout = new CssLayout(); browserLayout.setSizeFull(); browserLayout.addComponent(browser_); hs.addComponent(browserLayout); tabs.addComponent(propertiesPanel); vs.addComponent(hl0); vs.addComponent(tabs); vs.setExpandRatio(hl0, 0.0f); vs.setExpandRatio(tabs, 1.0f); // Ground state fragments.put("", uiState); setCurrentItem(uiState.currentItem, (Strategiakartta) uiState.currentItem); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void setUserMeter(final Main main, final Base base, final Meter m) { final Database database = main.getDatabase(); final Window subwindow = new Window("Aseta mittarin arvo", new VerticalLayout()); subwindow.setModal(true);// w w w .jav a 2 s.com subwindow.setWidth("350px"); subwindow.setResizable(false); final VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); String caption = m.getCaption(database); if (caption != null && !caption.isEmpty()) { final Label header = new Label(caption); header.addStyleName(ValoTheme.LABEL_LARGE); winLayout.addComponent(header); } final Indicator indicator = m.getPossibleIndicator(database); if (indicator == null) return; Datatype dt = indicator.getDatatype(database); if (!(dt instanceof EnumerationDatatype)) return; final Label l = new Label("Selite: " + indicator.getValueShortComment()); AbstractField<?> forecastField = dt.getEditor(main, base, indicator, true, new CommentCallback() { @Override public void runWithComment(String shortComment, String comment) { l.setValue("Selite: " + indicator.getValueShortComment()); } @Override public void canceled() { } }); forecastField.setWidth("100%"); forecastField.setCaption("Ennuste"); winLayout.addComponent(forecastField); AbstractField<?> currentField = dt.getEditor(main, base, indicator, false, new CommentCallback() { @Override public void runWithComment(String shortComment, String comment) { l.setValue("Selite: " + indicator.getValueShortComment()); } @Override public void canceled() { } }); currentField.setWidth("100%"); currentField.setCaption("Toteuma"); winLayout.addComponent(currentField); winLayout.addComponent(l); l.setWidth("100%"); winLayout.setComponentAlignment(l, Alignment.BOTTOM_CENTER); HorizontalLayout hl = new HorizontalLayout(); winLayout.addComponent(hl); winLayout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER); Button ok = new Button("Sulje", new Button.ClickListener() { private static final long serialVersionUID = 1364802814012491490L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); } }); Button define = new Button("Mrit", new Button.ClickListener() { private static final long serialVersionUID = 1364802814012491490L; public void buttonClick(ClickEvent event) { Meter.editMeter(main, base, m); } }); hl.addComponent(ok); hl.setComponentAlignment(ok, Alignment.BOTTOM_LEFT); hl.addComponent(define); hl.setComponentAlignment(define, Alignment.BOTTOM_LEFT); main.addWindow(subwindow); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void editTextAndId(final Main main, String title, final Base container) { final Database database = main.getDatabase(); final Window subwindow = new Window(title, new VerticalLayout()); subwindow.setModal(true);//from w w w . ja v a 2 s . c om subwindow.setWidth("400px"); subwindow.setHeight("500px"); subwindow.setResizable(false); VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); final TextField tf = new TextField(); tf.setCaption("Lyhytnimi:"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.setValue(container.getId(database)); tf.setWidth("100%"); winLayout.addComponent(tf); final TextArea ta = new TextArea(); ta.setCaption("Teksti:"); ta.setValue(container.getText(database)); ta.setWidth("100%"); ta.setHeight("290px"); winLayout.addComponent(ta); Button save = new Button("Tallenna", new Button.ClickListener() { private static final long serialVersionUID = 6641880870005364983L; public void buttonClick(ClickEvent event) { String idValue = tf.getValue(); String value = ta.getValue(); main.removeWindow(subwindow); container.modifyId(main, idValue); container.modifyText(main, value); Collection<String> tags = Tag.extractTags(value); database.assertTags(tags); ArrayList<Tag> tagObjects = new ArrayList<Tag>(); for (String s : tags) tagObjects.add(database.getOrCreateTag(s)); container.assertRelatedTags(database, tagObjects); Updates.update(main, true); Property emails = Property.find(database, Property.EMAIL); String addr = emails.getPropertyValue(container); if (addr != null && !addr.isEmpty()) { String[] addrs = addr.split(","); if (addrs.length > 0) { try { Email.send(addrs, "Muutos strategiakartassa: " + container.getId(database), "Kyttj " + main.account.getId(database) + " on muuttanut strategiakarttaa.<br/><br/>Lyhytnimi: " + container.getId(database) + "<br/><br/>Teksti: " + container.getText(database)); } catch (MessagingException e) { e.printStackTrace(); } } } } }); Button discard = new Button("Peru muutokset", new Button.ClickListener() { private static final long serialVersionUID = -784522457615993823L; public void buttonClick(ClickEvent event) { Updates.update(main, true); main.removeWindow(subwindow); } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.addComponent(save); hl2.addComponent(discard); winLayout.addComponent(hl2); winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); main.addWindow(subwindow); ta.setCursorPosition(ta.getValue().length()); }