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

jdplus.tramoseats.desktop.plugin.tramo.ui.actions.CreateTramoDoc Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017 National Bank of Belgium
 *
 * Licensed under the EUPL, Version 1.1 or – as soon they will be approved
 * by the European Commission - subsequent versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://ec.europa.eu/idabc/eupl
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 */
package jdplus.tramoseats.desktop.plugin.tramo.ui.actions;

import jdplus.tramoseats.desktop.plugin.tramo.documents.TramoDocumentManager;
import jdplus.tramoseats.desktop.plugin.tramo.documents.TramoSpecManager;
import jdplus.tramoseats.desktop.plugin.tramo.ui.TramoTopComponent;
import jdplus.toolkit.desktop.plugin.workspace.WorkspaceFactory;
import jdplus.toolkit.desktop.plugin.workspace.WorkspaceItem;
import jdplus.toolkit.desktop.plugin.workspace.nodes.WsNode;
import jdplus.tramoseats.base.api.tramo.TramoSpec;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import jdplus.tramoseats.base.core.tramo.TramoDocument;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;

@ActionID(category = "Tools",
        id = "demetra.desktop.tramo.ui.actions.CreateTramoDoc")
@ActionRegistration(displayName = "#CTL_CreateTramoDoc")
@ActionReferences({
    @ActionReference(path = TramoSpecManager.ITEMPATH, position = 1620, separatorBefore = 1300)
})
@Messages("CTL_CreateTramoDoc=Create Document")
public final class CreateTramoDoc implements ActionListener {

    private final WsNode context;

    public CreateTramoDoc(WsNode context) {
        this.context = context;
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        final WorkspaceItem xdoc = context.getWorkspace().searchDocument(context.lookup(), TramoSpec.class);
        if (xdoc == null || xdoc.getElement() == null) {
            return;
        }
        TramoDocumentManager dmgr = (TramoDocumentManager) WorkspaceFactory.getInstance().getManager(TramoDocumentManager.ID);
        WorkspaceItem doc = dmgr.create(context.getWorkspace());
        doc.setComments(xdoc.getComments());
        doc.getElement().set(xdoc.getElement());
        TramoTopComponent view = new TramoTopComponent(doc);
        view.open();
        view.requestActive();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy