X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=inline;f=eclipse%2Fplugins%2Fruntime%2Forg.argeo.slc.client.ui%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FProcessParametersView.java;fp=eclipse%2Fplugins%2Fruntime%2Forg.argeo.slc.client.ui%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FProcessParametersView.java;h=0000000000000000000000000000000000000000;hb=b8b8b7dcec14762561b0f429f99ee779bf50e487;hp=b45fb99815a618c8402bc73ba2257d049e547bf9;hpb=5e5b06fe0c831e66bc048d8bf8da40b32f79a5c9;p=gpl%2Fargeo-slc.git diff --git a/eclipse/plugins/runtime/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java b/eclipse/plugins/runtime/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java deleted file mode 100644 index b45fb9981..000000000 --- a/eclipse/plugins/runtime/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessParametersView.java +++ /dev/null @@ -1,210 +0,0 @@ -package org.argeo.slc.client.ui.views; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.client.ui.ClientUiPlugin; -import org.argeo.slc.client.ui.providers.ProcessParametersEditingSupport; -import org.argeo.slc.core.execution.PrimitiveAccessor; -import org.argeo.slc.execution.ExecutionSpecAttribute; -import org.argeo.slc.process.RealizedFlow; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.part.ViewPart; - -/** - * - * @author bsinou - * - * This view, directly linked with the ProcessBuilderView - * enables the display and editing the parameters of a given process. - * - * Note that for now we use ExecutionFlowDescriptor.values - * attribute to recall (and update ??) the various parameters. - */ -public class ProcessParametersView extends ViewPart { - private static final Log log = LogFactory - .getLog(ProcessParametersView.class); - - public static final String ID = "org.argeo.slc.client.ui.processParametersView"; - - // This map stores actual values set to default if existing at the begining - // and then the ones computed by the end user - private Map values; - // This map stores the spec of the attributes used to offer the end user - // some choices. - private Map specAttributes; - - // We must keep a reference to the current EditingSupport so that we can - // update the index of the process being updated - ProcessParametersEditingSupport ppEditingSupport; - - // view attributes - private TableViewer viewer; - - public void createPartControl(Composite parent) { - viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL | SWT.FULL_SELECTION); - createColumns(viewer); - - // WARNING - // for the moment being, we support only one process builder at a time - // we set the corresponding view in the editor here. - ProcessBuilderView pbView = (ProcessBuilderView) ClientUiPlugin - .getDefault().getWorkbench().getActiveWorkbenchWindow() - .getActivePage().findView(ProcessBuilderView.ID); - ppEditingSupport.setCurrentProcessBuilderView(pbView); - - viewer.setLabelProvider(new ViewLabelProvider()); - viewer.setContentProvider(new ViewContentProvider()); - viewer.setInput(getViewSite()); - - } - - // This will create the columns for the table - private void createColumns(TableViewer viewer) { - - String[] titles = { "Attribute name", "value" }; - int[] bounds = { 200, 200 }; - - for (int i = 0; i < titles.length; i++) { - TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); - column.getColumn().setText(titles[i]); - column.getColumn().setWidth(bounds[i]); - column.getColumn().setResizable(true); - column.getColumn().setMoveable(true); - if (i == 1) { - // we create the used EditingSupport and enable editing support - // for value Column - ppEditingSupport = new ProcessParametersEditingSupport(viewer, - i); - column.setEditingSupport(ppEditingSupport); - } - } - Table table = viewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - } - - public void setFocus() { - viewer.getControl().setFocus(); - } - - // set class attributes, refresh the lists of process paramaters to edit. - public void setRealizedFlow(int index, RealizedFlow rf) { - // force the cleaning of the view - if (index == -1) { - viewer.setInput(null); - return; - } - // we store the index of the edited Process in the editor so that it can - // save computed values. - ppEditingSupport.setCurrentProcessIndex(index); - - // TODO : - // We should handle ExecutionSpec here. need to be improved. - // ExecutionSpec es = rf.getExecutionSpec(); - // if (es != null && es.getAttributes() != null) - // parameters = es.getAttributes(); - // if (parameters != null) - // viewer.setInput(parameters); - - values = rf.getFlowDescriptor().getValues(); - specAttributes = rf.getFlowDescriptor().getExecutionSpec() - .getAttributes(); - - if (values != null) - viewer.setInput(values); - else - // No parameters to edit, we reset the view. - viewer.setInput(null); - - } - - // Inner Classes we should use ExecutionSpecAttribute instead of values - // see below - protected class ViewContentProvider implements IStructuredContentProvider { - public void inputChanged(Viewer arg0, Object arg1, Object arg2) { - } - - public void dispose() { - } - - @SuppressWarnings("unchecked") - // we cast the Map to List - public Object[] getElements(Object obj) { - - if (obj instanceof Map && ((Map) obj).size() != 0) { - List list = new ArrayList(); - Map map = (Map) obj; - for (String key : map.keySet()) { - list.add(new ObjectWithName(key, map.get(key))); - } - return list.toArray(); - } else { - return new Object[0]; - } - } - } - - protected class ViewLabelProvider extends LabelProvider implements - ITableLabelProvider { - - public String getColumnText(Object obj, int index) { - // NOTE : the passed object is a line of the table !!! - - if (obj instanceof ObjectWithName) { - ObjectWithName own = (ObjectWithName) obj; - switch (index) { - case 0: - return own.name; - case 1: - if (own.obj instanceof PrimitiveAccessor) { - PrimitiveAccessor pa = (PrimitiveAccessor) own.obj; - if ("string".equals(pa.getType())) - return (String) pa.getValue(); - else if ("integer".equals(pa.getType())) - return ((Integer) pa.getValue()).toString(); - else - return "Type " + pa.getType() - + " not yet supported"; - } else - return own.obj.toString(); - default: - return getText(obj); - } - } else - return getText(obj); - } - - public Image getColumnImage(Object obj, int index) { - return null; - } - - } - - // We add an inner class to enrich the ExecutionSpecAttribute with a name - // so that we can display it. - public class ObjectWithName { - public Object obj; - public String name; - - public ObjectWithName(String name, Object obj) { - this.name = name; - this.obj = obj; - } - - } -}