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

eu.agrosense.client.worker.WorkersNodeProvider 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.client.worker;

import eu.agrosense.client.farm.FarmAssetNodeProvider;
import eu.agrosense.client.model.PresentationModelChildFactory;
import eu.agrosense.shared.model.AgroURI;
import eu.agrosense.shared.model.Worker;
import javax.swing.Action;
import org.opendolphin.core.PresentationModel;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;

/**
 *
 * @author johan
 */
@ServiceProvider(service=FarmAssetNodeProvider.class)
@NbBundle.Messages("workers node name=Workers")
public class WorkersNodeProvider implements FarmAssetNodeProvider {

    @Override
    public Node[] getNodes(AgroURI farmURI) {
        return new Node[]{new WorkersNode(farmURI)};
    }
}

class WorkersNode extends AbstractNode {

    private final AgroURI farmURI;
    
    public WorkersNode(AgroURI farmURI) {
        super(Children.create(new WorkerNodeFactory(farmURI), true));
        this.farmURI = farmURI;
        // FIXME: create new composite icon from blank folder and worker icons
        setIconBaseWithExtension("eu/agrosense/client/worker/workers_folder16.png");
        setName(Bundle.workers_node_name());
    }

    @Override
    public Action[] getActions(boolean context) {
        return new Action[]{new NewWorkerAction(farmURI)};
    }
}

class WorkerNodeFactory extends PresentationModelChildFactory {

    public WorkerNodeFactory(AgroURI farmURI) {
        super(farmURI, Worker.ITEM_ID_TYPE);
    }

    @Override
    protected Node createNodeForKey(PresentationModel key) {
        return new WorkerNode(key);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy