All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.future.earth.gwt.client.date.month.staend.AbstractMonthField Maven / Gradle / Ivy

There is a newer version: 3.3
Show newest version
/*
 * 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.month.staend;

import org.cobogw.gwt.user.client.CSS;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
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.EventPanel;
import eu.future.earth.gwt.client.date.TimeEventRenderer;

public abstract class AbstractMonthField extends EventPanel {

	private VerticalPanel whole = new VerticalPanel();

	protected Label title = new Label();

	public void setWidth(int width) {
		if (width > 0) {
			super.setWidth(width + "px");
		}
	}

	public AbstractMonthField(TimeEventRenderer newRenderer, T data) {
		super(newRenderer, data);
		super.setWidget(whole);
		whole.setSpacing(1);
		whole.setWidth("100%");
		super.setWidth("100%");
		title.setWordWrap(false);
		CSS.setProperty(title, CSS.A.FONT_SIZE, CSS.V.FONT_SIZE.X_SMALL);
		super.setEventStyleName(FtrGwtDateCss.EVENT_MONTH_PANEL);
		whole.setHeight(contentHeight + "px");
	}

	public int getContentHeight() {
		return contentHeight;
	}

	private int contentHeight = 15;

	public void setContentHeight(int contentHeight) {
		if (contentHeight > 0) {
			this.contentHeight = contentHeight;
			whole.setHeight(contentHeight + "px");
		}
	}

	private Widget dataWidget = null;

	protected void setBody(Widget newBody) {
		dataWidget = newBody;
		whole.add(title);
		clickable = getClickableItem();
		if (newBody != null) {
			whole.add(newBody);
			CSS.setProperty(newBody, CSS.A.OVERFLOW, CSS.V.OVERFLOW.HIDDEN);
			newBody.addStyleName(getEventStyleName());
		}

	}

	public void setEventStyleName(String eventStyleName, String header) {
		super.setEventStyleName(eventStyleName);
		title.setStyleName(header);
		// whole.setStyleName(eventStyleName);
		// title.setStyleName(eventStyleName);
	}

	public void setTitleDescription(String newDescription) {
		title.setTitle(newDescription);
	}

	public void setMainColor(String newColor) {
		// super.setMainColor(newColor);
		if (dataWidget != null) {
			CSS.setProperty(dataWidget, CSS.A.BACKGROUND_COLOR, newColor);
		}
	}

	public void setForeGroundColor(String newColor) {
		// super.setForeGroundColor(newColor);
		if (dataWidget != null) {
			CSS.setProperty(dataWidget, CSS.A.COLOR, newColor);
		}
		if (title != null) {
			CSS.setProperty(title, CSS.A.COLOR, newColor);
		}
	}

	public void setEventStyleName(String eventStyleName) {
		super.setEventStyleName(eventStyleName);
		// whole.setStyleName(eventStyleName);
		// title.setStyleName(eventStyleName);
	}

	public Widget getDraggableItem() {
		return title;
	}

	public void onClick(ClickEvent widget) {
		if (clickable != null) {
			if (widget.getSource() == clickable) {
				DateEvent.fire(this, DateEventActions.EDIT, getValue());
			}
		}
	}

	private Widget clickable = null;

	public Widget getPanel() {
		return whole;
	}

	public abstract Widget getClickableItem();

	public void setTitle(String newTitle) {
		title.setText(newTitle);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy