eu.agrosense.spi.activity.ActivityRegistrationWidget Maven / Gradle / Ivy
/**
* Copyright (C) 2008-2013 LimeTri. All rights reserved.
*
* AgroSense is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it
* is applied to this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* AgroSense. If not, see .
*/
package eu.agrosense.spi.activity;
import eu.agrosense.api.task.Task;
import eu.agrosense.api.widget.DefaultWidget;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javafx.scene.layout.Pane;
import org.opendolphin.core.PresentationModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author kenrik
*/
public class ActivityRegistrationWidget extends DefaultWidget {
private static final Logger log = LoggerFactory.getLogger(ActivityRegistrationWidget.class);
private final ActivityRegistration activityRegistration;
private static final SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
/**
* Creates new widget and creates new task on the fly
*
* @param model
* @throws java.io.IOException
*/
public ActivityRegistrationWidget(PresentationModel model) throws IOException {
activityRegistration = new ActivityRegistration(model.getAt(Task.PROP_ID).getValue().toString());
activityRegistration.setTaskModel(model);
activityRegistration.setDate(sdf.format(Calendar.getInstance().getTime()));
activityRegistration.setName("newTask");
}
public ActivityRegistrationWidget(String taskId) throws IOException {
this(taskId, "newTask", sdf.format(Calendar.getInstance().getTime()));
}
public ActivityRegistrationWidget(String taskId, String name, String date) throws IOException {
activityRegistration = new ActivityRegistration(taskId);
activityRegistration.setDate(date);
activityRegistration.setName(name);
}
/**
* expand the widget to full size
*/
public void expand() {
activityRegistration.expand();
}
/**
* collapse widget to minimal size
*/
public void collapse() {
activityRegistration.collapse();
}
/**
* add collapse/expand and delete buttons
*/
public void addButtons() {
activityRegistration.buttonPane.visibleProperty().setValue(Boolean.TRUE);
}
@Override
public double getMinWidth() {
return activityRegistration.getMinWidth();
}
@Override
public double getMinHeight() {
return activityRegistration.getMinHeight();
}
@Override
public Pane getAsNode() {
return activityRegistration;
}
public String getId() {
return activityRegistration.getId();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy