@Test public void shouldHaveCorrectTerminals() { assertThat(component.getTerminals().size(), is(2)); InputTerminal incoming = (InputTerminal) component.getTerminalByName(OnOffCategory.STATE_TERMINAL); assertThat(incoming.getLabel(), is("Component activation")); OutputTerminal scheduler = (OutputTerminal) component.getTerminalByName(SchedulerCategory.OUTGOING_TERMINAL); assertThat(scheduler.getLabel(), is("Scheduling Terminal")); }
@Nonnull @Override public Connection connect(@Nonnull OutputTerminal output, @Nonnull InputTerminal input) { // Locate the correct CanvasItem for the Connection. CanvasItem canvas = output.getTerminalHolder().getCanvas(); if (canvas == input.getTerminalHolder().getCanvas()) { if (canvas != this) return canvas.connect(output, input); } // If the two Terminals are in separate CanvasItems, the connection should // be made in the ProjectItem. else if (!(this instanceof ProjectItem && canvas.getProject() == this)) return canvas.getProject().connect(output, input); // Make sure an identical Connection doesn't already exist. for (Connection connection : output.getConnections()) if (connection.getInputTerminal().equals(input)) return connection; // Create the Connection. final Connection connection = createConnection(output, input); connectionList.addItem( connection, new Runnable() { @Override public void run() { connection .getOutputTerminal() .addEventListener(TerminalConnectionEvent.class, connectionListener); } }); return connection; }