eu.agrosense.client.activity.impl.NewActivityAction Maven / Gradle / Ivy
The newest version!
/**
* 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.client.activity.impl;
import eu.agrosense.api.session.Connection;
import eu.agrosense.api.session.Connections;
import eu.agrosense.api.task.Activity;
import eu.agrosense.client.model.NewActionHelper;
import eu.agrosense.client.util.javafx.CrudPanel;
import eu.agrosense.shared.model.AgroURI;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import org.opendolphin.core.PresentationModel;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
*
* @author johan
*/
@NbBundle.Messages("new activity action name=New activity")
public class NewActivityAction extends AbstractAction {
private static final Icon ICON = ImageUtilities.loadImageIcon("eu/agrosense/client/activity/activity.png", true);
private final AgroURI farmURI;
public NewActivityAction(AgroURI farmURI) {
super(Bundle.new_activity_action_name(), ICON);
this.farmURI = farmURI;
}
@Override
public void actionPerformed(ActionEvent e) {
Connection service = Connections.get();
PresentationModel model = service.presentationModel(this.farmURI.toString(),Activity.ITEM_ID_TYPE);
CrudPanel newActivityView = ActivityPane.createEmbedded(model);
NewActionHelper.showAndHandleDialog(newActivityView, Bundle.new_activity_action_name(), model, service);
}
}