List of usage examples for com.vaadin.ui ColorPicker setPosition
public void setPosition(int x, int y)
From source file:com.hybridbpm.ui.component.chart.color.ChartColorLayout.java
License:Apache License
private void fillTable() { colorTable.removeAllItems();//from ww w . 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. ja va 2 s .c o m*/ 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:org.tltv.gantt.demo.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);//from w w w . j av a 2s.c om win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); CheckBox showProgress = new CheckBox("Show progress"); group.bind(showProgress, "showProgress"); showProgress.setVisible(false); hidden.add(showProgress); Slider progress = new Slider("Progress"); progress.setWidth(100, Unit.PERCENTAGE); group.bind(progress, "progress"); progress.setVisible(false); hidden.add(progress); NativeSelect predecessorSelect = new NativeSelect("Predecessor Step"); predecessorSelect.setWidth(100, Unit.PERCENTAGE); fillPredecessorCanditatesToSelect(step, predecessorSelect); predecessorSelect.setEnabled(step instanceof Step); if (step instanceof Step) { group.bind(predecessorSelect, "predecessor"); } predecessorSelect.setVisible(false); hidden.add(predecessorSelect); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setWidth(100, Unit.PERCENTAGE); parentStepSelect.setEnabled(false); fillParentStepCanditatesToSelect(step, parentStepSelect); parentStepSelect.setVisible(false); hidden.add(parentStepSelect); HorizontalLayout colorLayout = new HorizontalLayout(); colorLayout.setWidth(100, Unit.PERCENTAGE); colorLayout.setVisible(false); hidden.add(colorLayout); final TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setEnabled(false); final ColorPicker bgColorPicker = new ColorPicker(); bgColorPicker.setPosition(300, 100); bgColorPicker.setColor(new CssColorToColorPickerConverter().convertToModel(step.getBackgroundColor())); bgColorPicker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { bgField.setValue(event.getColor().getCSS()); } }); colorLayout.addComponent(bgField); colorLayout.addComponent(bgColorPicker); colorLayout.setExpandRatio(bgField, 1); colorLayout.setComponentAlignment(bgColorPicker, Alignment.BOTTOM_LEFT); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(showProgress); content.addComponent(progress); content.addComponent(predecessorSelect); content.addComponent(parentStepSelect); content.addComponent(colorLayout); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { commit(win, group, parentStepSelect); } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { cancel(win, group); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { delete(win, group); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); getUI().addWindow(win); }