PageRenderTime 40ms CodeModel.GetById 13ms app.highlight 22ms RepoModel.GetById 2ms app.codeStats 0ms

/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
  1/*
  2 * Copyright 2007 Future Earth, info@future-earth.eu
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5 * use this file except in compliance with the License. You may obtain a copy of
  6 * the License at
  7 *
  8 * http://www.apache.org/licenses/LICENSE-2.0
  9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13 * License for the specific language governing permissions and limitations under
 14 * the License.
 15 */
 16
 17package eu.future.earth.gwt.client.date.week.staend;
 18
 19import org.cobogw.gwt.user.client.CSS;
 20import org.cobogw.gwt.user.client.ui.RoundedPanel;
 21
 22import com.google.gwt.event.dom.client.ClickEvent;
 23import com.google.gwt.event.dom.client.ClickHandler;
 24import com.google.gwt.user.client.ui.HTML;
 25import com.google.gwt.user.client.ui.HorizontalPanel;
 26import com.google.gwt.user.client.ui.Label;
 27import com.google.gwt.user.client.ui.SimplePanel;
 28import com.google.gwt.user.client.ui.Widget;
 29
 30import eu.future.earth.gwt.client.FtrGwtDateCss;
 31import eu.future.earth.gwt.client.date.DateEvent;
 32import eu.future.earth.gwt.client.date.DateEvent.DateEventActions;
 33import eu.future.earth.gwt.client.date.TimeEventRendererVertical;
 34
 35public abstract class AbstractDayField<T> extends DayField<T> implements ClickHandler {
 36
 37	protected Label title;
 38
 39	private SimplePanel top;
 40
 41	private SimplePanel bottom;
 42
 43	private Label titleDescription = null;
 44
 45	private HTML space = new HTML("&nbsp;");
 46
 47	private HorizontalPanel tit = new HorizontalPanel();
 48
 49	public AbstractDayField(TimeEventRendererVertical<? extends T> renderer, T data) {
 50		super(renderer, data);
 51		title = new Label();
 52		titleDescription = new Label();
 53
 54		tit.setBorderWidth(0);
 55		tit.setSpacing(0);
 56		tit.add(title);
 57		tit.add(space);
 58		tit.add(titleDescription);
 59		title.setWordWrap(false);
 60		if (renderer.getEventCornerSize() > 0) {
 61			top = new RoundedPanel(tit, RoundedPanel.TOP, renderer.getEventCornerSize());
 62			top.setHeight(renderer.getEventTopHeight() + "px");
 63			bottom = new RoundedPanel(RoundedPanel.BOTTOM, renderer.getEventCornerSize());
 64			bottom.setWidget(new SimplePanel());
 65			bottom.setHeight(renderer.getEventBottomHeight() + "px");
 66		} else {
 67			top = new SimplePanel();
 68			top.setWidget(tit);
 69			top.setHeight(renderer.getEventTopHeight() + "px");
 70			bottom = new SimplePanel();
 71			bottom.setHeight(renderer.getEventBottomHeight() + "px");
 72		}
 73		tit.setWidth("100%");
 74		setEventStyleName(FtrGwtDateCss.EVENT_DAY_PANEL, FtrGwtDateCss.EVENT_DAY_HEADER);
 75	}
 76
 77	public void setEventStyleName(String newStyleName, String tileStyle) {
 78		super.setEventStyleName(newStyleName);
 79		if (top instanceof RoundedPanel) {
 80			((RoundedPanel) top).setCornerStyleName(tileStyle);
 81			((RoundedPanel) bottom).setCornerStyleName(newStyleName);
 82		} else {
 83			top.setStyleName(tileStyle);
 84			bottom.setStyleName(newStyleName);
 85		}
 86		space.setStyleName(tileStyle);
 87		tit.setStyleName(tileStyle);
 88		title.setStyleName(tileStyle);
 89		titleDescription.setStyleName(tileStyle);
 90	}
 91
 92	public void setMainColor(String newColor) {
 93		super.setMainColor(newColor);
 94		if (dataWidget != null) {
 95			CSS.setProperty(dataWidget, CSS.A.BACKGROUND_COLOR, newColor);
 96		}
 97		if (top instanceof RoundedPanel) {
 98			((RoundedPanel) bottom).setBorderColor(newColor);
 99		} else {
100			CSS.setProperty(bottom, CSS.A.BACKGROUND_COLOR, newColor);
101		}
102	}
103
104	public void setForeGroundColor(String newColor) {
105		super.setForeGroundColor(newColor);
106		if (dataWidget != null) {
107			CSS.setProperty(dataWidget, CSS.A.COLOR, newColor);
108		}
109		if (titleDescription != null) {
110			CSS.setProperty(titleDescription, CSS.A.COLOR, newColor);
111		}
112		CSS.setProperty(bottom, CSS.A.COLOR, newColor);
113	}
114
115	public void setWidth(int width) {
116		if (width > 0) {
117			super.setWidth(width + "px");
118		}
119	}
120
121	protected void setBody(Widget body) {
122		// clickable = getClickableItem();
123		body.setStyleName(getEventStyleName());
124		setWidgetInsizeResize(top, body, bottom);
125	}
126
127	public Widget getDraggableItem() {
128		return title;
129	}
130
131	// private Widget clickable = null;
132
133	public void setTitle(String newTitle) {
134		title.setText(newTitle);
135	}
136
137	public void setTitleDescription(String newTitle) {
138		titleDescription.setText(newTitle);
139		titleDescription.setTitle(newTitle);
140	}
141
142	// public abstract Widget getClickableItem();
143
144	public void onClick(ClickEvent event) {
145		DateEvent.fire(this, DateEventActions.EDIT, getValue());
146	}
147
148}