/ftr-gwt-library-date/src/main/java/eu/future/earth/gwt/client/date/week/staend/AbstractDayField.java
http://ftr-gwt-library.googlecode.com/ · Java · 148 lines · 105 code · 25 blank · 18 comment · 13 complexity · 5f76d3711449df2632a63e2735517eb4 MD5 · raw file
- /*
- * Copyright 2007 Future Earth, info@future-earth.eu
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
- package eu.future.earth.gwt.client.date.week.staend;
- import org.cobogw.gwt.user.client.CSS;
- import org.cobogw.gwt.user.client.ui.RoundedPanel;
- import com.google.gwt.event.dom.client.ClickEvent;
- import com.google.gwt.event.dom.client.ClickHandler;
- import com.google.gwt.user.client.ui.HTML;
- import com.google.gwt.user.client.ui.HorizontalPanel;
- import com.google.gwt.user.client.ui.Label;
- import com.google.gwt.user.client.ui.SimplePanel;
- import com.google.gwt.user.client.ui.Widget;
- import eu.future.earth.gwt.client.FtrGwtDateCss;
- import eu.future.earth.gwt.client.date.DateEvent;
- import eu.future.earth.gwt.client.date.DateEvent.DateEventActions;
- import eu.future.earth.gwt.client.date.TimeEventRendererVertical;
- public abstract class AbstractDayField<T> extends DayField<T> implements ClickHandler {
- protected Label title;
- private SimplePanel top;
- private SimplePanel bottom;
- private Label titleDescription = null;
- private HTML space = new HTML(" ");
- private HorizontalPanel tit = new HorizontalPanel();
- public AbstractDayField(TimeEventRendererVertical<? extends T> renderer, T data) {
- super(renderer, data);
- title = new Label();
- titleDescription = new Label();
- tit.setBorderWidth(0);
- tit.setSpacing(0);
- tit.add(title);
- tit.add(space);
- tit.add(titleDescription);
- title.setWordWrap(false);
- if (renderer.getEventCornerSize() > 0) {
- top = new RoundedPanel(tit, RoundedPanel.TOP, renderer.getEventCornerSize());
- top.setHeight(renderer.getEventTopHeight() + "px");
- bottom = new RoundedPanel(RoundedPanel.BOTTOM, renderer.getEventCornerSize());
- bottom.setWidget(new SimplePanel());
- bottom.setHeight(renderer.getEventBottomHeight() + "px");
- } else {
- top = new SimplePanel();
- top.setWidget(tit);
- top.setHeight(renderer.getEventTopHeight() + "px");
- bottom = new SimplePanel();
- bottom.setHeight(renderer.getEventBottomHeight() + "px");
- }
- tit.setWidth("100%");
- setEventStyleName(FtrGwtDateCss.EVENT_DAY_PANEL, FtrGwtDateCss.EVENT_DAY_HEADER);
- }
- public void setEventStyleName(String newStyleName, String tileStyle) {
- super.setEventStyleName(newStyleName);
- if (top instanceof RoundedPanel) {
- ((RoundedPanel) top).setCornerStyleName(tileStyle);
- ((RoundedPanel) bottom).setCornerStyleName(newStyleName);
- } else {
- top.setStyleName(tileStyle);
- bottom.setStyleName(newStyleName);
- }
- space.setStyleName(tileStyle);
- tit.setStyleName(tileStyle);
- title.setStyleName(tileStyle);
- titleDescription.setStyleName(tileStyle);
- }
- public void setMainColor(String newColor) {
- super.setMainColor(newColor);
- if (dataWidget != null) {
- CSS.setProperty(dataWidget, CSS.A.BACKGROUND_COLOR, newColor);
- }
- if (top instanceof RoundedPanel) {
- ((RoundedPanel) bottom).setBorderColor(newColor);
- } else {
- CSS.setProperty(bottom, CSS.A.BACKGROUND_COLOR, newColor);
- }
- }
- public void setForeGroundColor(String newColor) {
- super.setForeGroundColor(newColor);
- if (dataWidget != null) {
- CSS.setProperty(dataWidget, CSS.A.COLOR, newColor);
- }
- if (titleDescription != null) {
- CSS.setProperty(titleDescription, CSS.A.COLOR, newColor);
- }
- CSS.setProperty(bottom, CSS.A.COLOR, newColor);
- }
- public void setWidth(int width) {
- if (width > 0) {
- super.setWidth(width + "px");
- }
- }
- protected void setBody(Widget body) {
- // clickable = getClickableItem();
- body.setStyleName(getEventStyleName());
- setWidgetInsizeResize(top, body, bottom);
- }
- public Widget getDraggableItem() {
- return title;
- }
- // private Widget clickable = null;
- public void setTitle(String newTitle) {
- title.setText(newTitle);
- }
- public void setTitleDescription(String newTitle) {
- titleDescription.setText(newTitle);
- titleDescription.setTitle(newTitle);
- }
- // public abstract Widget getClickableItem();
- public void onClick(ClickEvent event) {
- DateEvent.fire(this, DateEventActions.EDIT, getValue());
- }
- }