blob: 461696dac7558f7d287b360054544628cc0c269f [file] [log] [blame]
/*******************************************************************************
* Copyright (C) 2007 The University of Manchester
*
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
******************************************************************************/
package net.sf.taverna.t2.activities.localworker.views;
import java.awt.Frame;
import javax.swing.Action;
import net.sf.taverna.t2.activities.localworker.actions.LocalworkerActivityConfigurationAction;
import net.sf.taverna.t2.activities.localworker.servicedescriptions.LocalworkerServiceProvider;
import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
import net.sf.taverna.t2.workbench.edits.EditManager;
import net.sf.taverna.t2.workbench.file.FileManager;
import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView;
import uk.org.taverna.configuration.app.ApplicationConfiguration;
import org.apache.taverna.scufl2.api.activity.Activity;
import org.apache.taverna.scufl2.api.configurations.Configuration;
import org.apache.taverna.scufl2.api.port.InputActivityPort;
import org.apache.taverna.scufl2.api.port.OutputActivityPort;
import com.fasterxml.jackson.databind.JsonNode;
@SuppressWarnings("serial")
public class LocalworkerActivityContextualView extends HTMLBasedActivityContextualView {
private final EditManager editManager;
private final FileManager fileManager;
private final ActivityIconManager activityIconManager;
private final ServiceDescriptionRegistry serviceDescriptionRegistry;
private final ApplicationConfiguration applicationConfiguration;
public LocalworkerActivityContextualView(Activity activity, EditManager editManager,
FileManager fileManager, ColourManager colourManager,
ActivityIconManager activityIconManager,
ServiceDescriptionRegistry serviceDescriptionRegistry,
ApplicationConfiguration applicationConfiguration) {
super(activity, colourManager);
this.editManager = editManager;
this.fileManager = fileManager;
this.activityIconManager = activityIconManager;
this.serviceDescriptionRegistry = serviceDescriptionRegistry;
this.applicationConfiguration = applicationConfiguration;
}
@Override
protected String getRawTableRowsHtml() {
StringBuilder html = new StringBuilder();
html.append("<tr><th>Input Port Name</th><th>Depth</th></tr>");
for (InputActivityPort inputActivityPort : getActivity().getInputPorts()) {
html.append("<tr><td>" + inputActivityPort.getName() + "</td><td>");
html.append(inputActivityPort.getDepth() + "</td></tr>");
}
html.append("<tr><th>Output Port Name</th><th>Depth</th></tr>");
for (OutputActivityPort outputActivityPort : getActivity().getOutputPorts()) {
html.append("<tr><td>" + outputActivityPort.getName() + "</td><td>");
html.append(outputActivityPort.getDepth() + "</td></tr>");
}
return html.toString();
}
@Override
public String getViewTitle() {
String result = "";
Configuration configuration = getConfigBean();
JsonNode json = configuration.getJson();
String workerName = LocalworkerServiceProvider.getServiceNameFromClassname(json.get(
"localworkerName").textValue());
if (json.get("isAltered").booleanValue()) {
result = "Altered local worker service";
if ((workerName != null) && !workerName.equals("")) {
result += " - originally " + workerName;
}
} else {
result = "Local worker service";
if ((workerName != null) && !workerName.equals("")) {
result += " - " + workerName;
}
}
return result;
}
@Override
public Action getConfigureAction(Frame owner) {
return new LocalworkerActivityConfigurationAction(getActivity(), owner, editManager,
fileManager, activityIconManager, serviceDescriptionRegistry,
applicationConfiguration);
}
@Override
public int getPreferredPosition() {
return 100;
}
}