Java Methods for URCap Development

Creating Installation Node

public class MyInstallationNodeContribution implements InstallationNodeContribution {
    private final InstallationAPIProvider apiProvider;
    private final DataModel model;

    public MyInstallationNodeContribution(InstallationAPIProvider apiProvider, DataModel model) {
        this.apiProvider = apiProvider;
        this.model = model;
    }

    @Override
    public void openView() {
        // Logic to handle view opening
    }

    @Override
    public void closeView() {
        // Logic to handle view closing
    }

    @Override
    public void generateScript(ScriptWriter writer) {
        // Logic to generate script
    }
}

Creating Program Node

public class MyProgramNodeContribution implements ProgramNodeContribution {
    private final ProgramAPIProvider apiProvider;
    private final ProgramModel model;

    public MyProgramNodeContribution(ProgramAPIProvider apiProvider, ProgramModel model) {
        this.apiProvider = apiProvider;
        this.model = model;
    }

    @Override
    public void openView() {
        // Logic to handle view opening
    }

    @Override
    public void closeView() {
        // Logic to handle view closing
    }

    @Override
    public void generateScript(ScriptWriter writer) {
        // Logic to generate script
    }
}

Daemon Process

public class MyDaemonService implements DaemonContribution {
    private final DaemonService daemonService;

    public MyDaemonService(DaemonService daemonService) {
        this.daemonService = daemonService;
    }

    public void startDaemon() {
        daemonService.start();
    }

    public void stopDaemon() {
        daemonService.stop();
    }

    public boolean isRunning() {
        return daemonService.getState() == DaemonContribution.State.RUNNING;
    }
}

Example Program Node View

public class MyProgramNodeView implements ProgramNodeView<MyProgramNodeContribution> {
    @Override
    public void buildUI(JPanel panel, ProgramNodeViewApiProvider apiProvider) {
        // Build the user interface for the program node
        JLabel label = new JLabel("My Program Node");
        panel.add(label);
    }
}

Example Installation Node View

public class MyInstallationNodeView implements InstallationNodeView<MyInstallationNodeContribution> {
    @Override
    public void buildUI(JPanel panel, InstallationNodeViewApiProvider apiProvider) {
        // Build the user interface for the installation node
        JLabel label = new JLabel("My Installation Node");
        panel.add(label);
    }
}

URCap Setup in Activator

public class MyActivator implements BundleActivator {
    @Override
    public void start(BundleContext context) {
        URCapAPI urCapAPI = new URCapAPI(context);
        urCapAPI.register(new MyInstallationNodeService());
        urCapAPI.register(new MyProgramNodeService());
    }

    @Override
    public void stop(BundleContext context) {
        // Clean up resources if needed
    }
}

Example Installation Node Service

public class MyInstallationNodeService implements InstallationNodeService {
    @Override
    public InstallationNodeContribution createInstallationNode(InstallationAPIProvider apiProvider, DataModel model) {
        return new MyInstallationNodeContribution(apiProvider, model);
    }

    @Override
    public String getTitle() {
        return "My Installation Node";
    }

    @Override
    public InstallationNodeView<MyInstallationNodeContribution> createView(InstallationAPIProvider apiProvider) {
        return new MyInstallationNodeView();
    }
}

Example Program Node Service

public class MyProgramNodeService implements ProgramNodeService {
    @Override
    public ProgramNodeContribution createProgramNode(ProgramAPIProvider apiProvider, ProgramModel model) {
        return new MyProgramNodeContribution(apiProvider, model);
    }

    @Override
    public String getTitle() {
        return "My Program Node";
    }

    @Override
    public ProgramNodeView<MyProgramNodeContribution> createView(ProgramAPIProvider apiProvider) {
        return new MyProgramNodeView();
    }
}