summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/ExecutionPane.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
commitb086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch)
tree8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/gui/tabs/ExecutionPane.java
parent22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff)
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/gui/tabs/ExecutionPane.java')
-rw-r--r--source/com/c2kernel/gui/tabs/ExecutionPane.java208
1 files changed, 0 insertions, 208 deletions
diff --git a/source/com/c2kernel/gui/tabs/ExecutionPane.java b/source/com/c2kernel/gui/tabs/ExecutionPane.java
deleted file mode 100644
index a853695..0000000
--- a/source/com/c2kernel/gui/tabs/ExecutionPane.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.c2kernel.gui.tabs;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.swing.Box;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.entity.proxy.EntityProxyObserver;
-import com.c2kernel.entity.proxy.ItemProxy;
-import com.c2kernel.entity.proxy.MemberSubscription;
-import com.c2kernel.gui.MainFrame;
-import com.c2kernel.gui.tabs.execution.ActivityItem;
-import com.c2kernel.gui.tabs.execution.ActivityViewer;
-import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.utils.Language;
-import com.c2kernel.utils.Logger;
-
-public class ExecutionPane extends EntityTabPane implements EntityProxyObserver<Workflow> {
-
- ArrayList<Job> jobList = null;
- Object jobLock = new Object();
- ActivityItem emptyAct = new ActivityItem();
- JLabel noActs = new JLabel(Language.translate("There are currently no activities that you can execute in this item."));
- JPanel view = new JPanel(new GridLayout(1, 1));
- ActivityViewer currentActView;
- JComboBox activitySelector = new JComboBox();
- Box activityBox = Box.createHorizontalBox();
- String selAct = null;
- ArrayList<ActivityItem> activities;
- String autoRun = null;
- boolean init = false;
- boolean formIsActive = false;
- public ExecutionPane() {
- super("Execution", "Activity Execution");
- super.initPanel();
- // add view panel
- c = new GridBagConstraints();
- c.gridx = 0; c.gridy = 1; c.weightx = 1.0; c.weighty = 2.0;
- c.insets = new Insets(5, 5, 5, 5);
- c.anchor = GridBagConstraints.CENTER;
- c.fill = GridBagConstraints.BOTH;
- gridbag.setConstraints(view, c);
-
- add(view);
- // create activity selection box
- activityBox.add(new JLabel(Language.translate("Select Activity") + ": "));
- activityBox.add(Box.createHorizontalStrut(5));
- activitySelector.setEditable(false);
- activityBox.add(activitySelector);
- activitySelector.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent selection) {
- if (selection.getStateChange() == ItemEvent.SELECTED) {
- selectActivity(selection.getItem());
- }
- }
- });
- }
- @Override
- public void run() {
- Thread.currentThread().setName("Execution Pane Builder");
- sourceEntity.getEntity().subscribe(new MemberSubscription<Workflow>(this, ClusterStorage.LIFECYCLE, false));
- loadJobList();
- init = true;
- if (autoRun != null) {
- runCommand(autoRun);
- autoRun = null;
- }
- }
- private void loadJobList() {
- synchronized (jobLock) {
- activitySelector.removeAllItems();
- view.removeAll();
- activities = new ArrayList<ActivityItem>();
- try {
- jobList = ((ItemProxy)sourceEntity.getEntity()).getJobList(MainFrame.userAgent);
- activitySelector.addItem(emptyAct);
- for (Job thisJob : jobList) {
- Logger.msg(7, "ExecutionPane - loadJobList " + thisJob.isOutcomeUsed() + "|" + thisJob.getSchemaType() + "|" + thisJob.getSchemaVersion() + "|");
- ActivityItem newAct = new ActivityItem(thisJob);
- if (activities.contains(newAct)) {
- int actIndex = activities.indexOf(newAct);
- activities.get(actIndex).addJob(thisJob);
- } else {
- Logger.msg(2, "ExecutionPane - Adding activity " + thisJob.getStepPath());
- addActivity(newAct);
- }
- }
- } catch (Exception e) {
- Logger.debug("Error fetching joblist");
- Logger.error(e);
- }
-
- switch (activities.size()) {
- case 0 :
- view.add(noActs);
- break;
- case 1 :
- currentActView = new ActivityViewer(activities.get(0), (ItemProxy)sourceEntity.getEntity(), this);
- c.fill = GridBagConstraints.BOTH;
- gridbag.setConstraints(view, c);
- view.add(currentActView);
- currentActView.init();
- break;
- default :
- c.fill = GridBagConstraints.HORIZONTAL;
- gridbag.setConstraints(view, c);
- view.add(activityBox);
- }
- }
- revalidate();
- updateUI();
- }
- @Override
- public void reload() {
- loadJobList();
- }
- private void addActivity(ActivityItem newAct) {
- if (activities.contains(newAct)) {
- Logger.msg(6, "ExecutionPane.addActivity(): Already in " + newAct.getStepPath());
- int actIndex = activities.indexOf(newAct);
- activitySelector.removeItemAt(actIndex);
- activitySelector.insertItemAt(newAct, actIndex);
- activities.set(actIndex, newAct);
- } else {
- Logger.msg(6, "ExecutionPane.addActivity(): New " + newAct.getStepPath());
- activities.add(newAct);
- activitySelector.addItem(newAct);
- }
- }
- private void selectActivity(Object selObj) {
- if (selObj.equals(emptyAct))
- return;
- view.removeAll();
- c.fill = GridBagConstraints.BOTH;
- gridbag.setConstraints(view, c);
- currentActView = new ActivityViewer((ActivityItem)selObj, (ItemProxy)sourceEntity.getEntity(), this);
- view.add(currentActView);
- revalidate();
- updateUI();
- currentActView.init();
- }
- @Override
- public void runCommand(String command) {
- if (init) {
- for (ActivityItem act : activities) {
- if (act.name.equals(command)) {
- selectActivity(act);
- }
- }
- } else
- autoRun = command;
- }
- /**
- * when the workflow changes, reload this pane.
- */
- @Override
- public void add(Workflow contents) {
- if (!formIsActive)
- reload();
- else { // look to see if this form is now invalid
- // get the new joblist
- try {
- jobList = ((ItemProxy)sourceEntity.getEntity()).getJobList(MainFrame.userAgent);
- } catch (Exception ex) {
- return;
- }
- // compare to currently editing jobs
- ArrayList<?> currentActJobs = currentActView.getActivity().getJobs();
- boolean allValid = true;
- for (Iterator<?> iter = currentActJobs.iterator(); iter.hasNext() && allValid;) {
- Job thisJob = (Job)iter.next();
- boolean stillValid = false;
- for (Job newJob : jobList) {
- if (thisJob.equals(newJob)) {
- stillValid = true;
- break;
- }
- }
- allValid &= stillValid;
- }
- if (!allValid) { // not all transitions are now valid
- reload(); // refresh the execution pane
- }
- }
- }
- /**
- * Not pertinent for this one
- */
- @Override
- public void remove(String id) {
- }
- @Override
- public void control(String control, String msg) {
- // TODO Auto-generated method stub
-
- }
-}