<commit_before>/*******************************************************************************
 * This file is a component of the Taverna project, and is licensed  under the
 *  GNU LGPL. Copyright <NAME>, The BioMoby Project
 ******************************************************************************/
package net.sf.taverna.t2.activities.biomoby.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.util.Map.Entry;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;

import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
import net.sf.taverna.t2.activities.biomoby.BiomobyActivityConfigurationBean;
import net.sf.taverna.t2.activities.biomoby.actions.BiomobyActivityConfigurationAction;
import net.sf.taverna.t2.activities.biomoby.actions.MobyParserAction;
import net.sf.taverna.t2.activities.biomoby.actions.MobyServiceDetailsAction;
import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView;
import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;

@SuppressWarnings("serial")
public class BiomobyActivityContextualView extends HTMLBasedActivityContextualView<BiomobyActivityConfigurationBean> {

	@Override
	public Action getConfigureAction(Frame owner) {
		BiomobyActivity activity = (BiomobyActivity)getActivity();
		if (activity.getMobyService() != null && activity.containsSecondaries()) {
			return new BiomobyActivityConfigurationAction((BiomobyActivity)getActivity(),owner);
		}
		else {
			return null;
		}	
	}

	public BiomobyActivityContextualView(Activity<?> activity) {
		super(activity);
	}

	@Override
	protected String getRawTableRowsHtml() {
		String html = "<tr><td>Endpoint</td><td>"+getConfigBean().getMobyEndpoint()+"</td></tr>";
		html += "<tr><td>Authority</td><td>"+getConfigBean().getAuthorityName()+"</td></tr>";
		html += "<tr><td>Service</td><td>"+getConfigBean().getServiceName()+"</td></tr>";
		if (getConfigBean().getSecondaries().size()>0) {
			html+="<tr><th colspan='2' align='left'>Secondaries</th></tr>";
			for (Entry<String, String> entry : getConfigBean().getSecondaries().entrySet()) {
				html+="<tr><td>"+entry.getKey()+"</td><td>"+entry.getValue()+"</td></tr>";
			}
		}
		return html;
	}

	@Override
	public String getViewTitle() {
		return "Biomoby activity";
	}
	
	/**
	 * Gets the component from the {@link HTMLBasedActivityContextualView} and<commit_msg>Changed "activity" to "service" as per T2-446<commit_after>/*******************************************************************************
 * This file is a component of the Taverna project, and is licensed  under the
 *  GNU LGPL. Copyright <NAME>, The BioMoby Project
 ******************************************************************************/
package net.sf.taverna.t2.activities.biomoby.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.util.Map.Entry;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;

import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
import net.sf.taverna.t2.activities.biomoby.BiomobyActivityConfigurationBean;
import net.sf.taverna.t2.activities.biomoby.actions.BiomobyActivityConfigurationAction;
import net.sf.taverna.t2.activities.biomoby.actions.MobyParserAction;
import net.sf.taverna.t2.activities.biomoby.actions.MobyServiceDetailsAction;
import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView;
import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;

@SuppressWarnings("serial")
public class BiomobyActivityContextualView extends HTMLBasedActivityContextualView<BiomobyActivityConfigurationBean> {

	@Override
	public Action getConfigureAction(Frame owner) {
		BiomobyActivity activity = (BiomobyActivity)getActivity();
		if (activity.getMobyService() != null && activity.containsSecondaries()) {
			return new BiomobyActivityConfigurationAction((BiomobyActivity)getActivity(),owner);
		}
		else {
			return null;
		}	
	}

	public BiomobyActivityContextualView(Activity<?> activity) {
		super(activity);
	}

	@Override
	protected String getRawTableRowsHtml() {
		String html = "<tr><td>Endpoint</td><td>"+getConfigBean().getMobyEndpoint()+"</td></tr>";
		html += "<tr><td>Authority</td><td>"+getConfigBean().getAuthorityName()+"</td></tr>";
		html += "<tr><td>Service</td><td>"+getConfigBean().getServiceName()+"</td></tr>";
		if (getConfigBean().getSecondaries().size()>0) {
			html+="<tr><th colspan='2' align='left'>Secondaries</th></tr>";
			for (Entry<String, String> entry : getConfigBean().getSecondaries().entrySet()) {
				html+="<tr><td>"+entry.getKey()+"</td><td>"+entry.getValue()+"</td></tr>";
			}
		}
		return html;
	}

	@Override
	public String getViewTitle() {
		return "Biomoby service";
	}
	
	/**
	 * Gets the component from the {@link HTMLBasedActivityContextualView} and
{'fraction_non_alphanumeric': 0.20265647011471122, 'fraction_numerical': 0.00482994566311129, 'mean_word_length': 6.576219512195122, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6992083', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1519, 'n_words': 247}