
eu.future.earth.gwt.client.date.week.staend.AbstractDayField Maven / Gradle / Ivy
/*
* Copyright 2007 Future Earth, [email protected]
*
* 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.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 extends DayField {
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);
top = new SimplePanel();
top.setWidget(tit);
int topHeight = renderer.getEventTopHeight();
if (topHeight > 0) {
top.setHeight(topHeight + "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 void sendEdit() {
DateEvent.fire(this, DateEventActions.EDIT, getValue());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy