fixed : long line in description

Project: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/commit/9a0c7a8c
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/9a0c7a8c
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/9a0c7a8c

Branch: refs/heads/cwl-browse
Commit: 9a0c7a8c01b0207469fd6d544add4e6d848c038f
Parents: c191822
Author: ThilinaManamgoda <maanafun...@gmail.com>
Authored: Wed Jul 6 15:09:28 2016 +0530
Committer: ThilinaManamgoda <maanafun...@gmail.com>
Committed: Wed Jul 6 15:09:28 2016 +0530

----------------------------------------------------------------------
 .../CWLFiles/customtool1.cwl                    |  7 +-
 .../taverna/cwl/ui/serviceprovider/Testing.java | 93 ++++++++++++--------
 .../taverna/cwl/ui/view/CwlContextualView.java  | 44 ++++++---
 .../taverna/cwl/utilities/CWLUtilTest.java      | 18 +++-
 4 files changed, 107 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/9a0c7a8c/taverna-cwl-activity-ui/CWLFiles/customtool1.cwl
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity-ui/CWLFiles/customtool1.cwl 
b/taverna-cwl-activity-ui/CWLFiles/customtool1.cwl
index 8ead5e4..7af2826 100644
--- a/taverna-cwl-activity-ui/CWLFiles/customtool1.cwl
+++ b/taverna-cwl-activity-ui/CWLFiles/customtool1.cwl
@@ -62,6 +62,11 @@ label: This is a short description of the tool
 
 description: |
  This is a much longer description of the tool. This can be displayed in
- the service detail panel               
+ the service detail panel. A Command Line Tool is a non-interactive executable 
+ program that reads some input, performs a computation, and terminates after 
+ producing some output. Command line programs are a flexible unit of code 
sharing
+ and reuse, unfortunately the syntax and input/output semantics among command 
+ line programs is extremely heterogeneous. A common layer for describing the 
+ syntax and semantics of programs can reduce this incidental complexity by 
providing a consistent way to connect programs together.             
 
 basecommand: echo

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/9a0c7a8c/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
----------------------------------------------------------------------
diff --git 
a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
 
b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
index 96da500..64aaf16 100644
--- 
a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
+++ 
b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
@@ -30,7 +30,6 @@ import java.util.stream.StreamSupport;
 
 import org.yaml.snakeyaml.Yaml;
 
-
 public class Testing {
        private static final String INPUTS = "inputs";
        private static final String ID = "id";
@@ -43,56 +42,72 @@ public class Testing {
        private static final int DEPTH_1 = 1;
        private static final int DEPTH_2 = 2;
        private static final String LABEL = "label";
-       
-       interface my{
+
+       interface my {
                public void printName();
        }
-       public void print(){
+
+       public void print() {
                System.out.println("ok");
        }
-       public static Yaml getReader(){
+
+       public static Yaml getReader() {
                Yaml reader = new Yaml();
                return reader;
        }
+
        public static void main(String[] args) {
 
-//             Path path1 = Paths.get("/home/maanadev/cwlTools");
-//             Path path2 = path1.normalize();
-//
-//             boolean pathExits = Files.exists(path2, new LinkOption[] { 
LinkOption.NOFOLLOW_LINKS });
-//
-//             
-//             try {
-//                     DirectoryStream<Path> stream = 
Files.newDirectoryStream(path2,"*.cwl");
-//                     Stream<Path> parrale = 
StreamSupport.stream(stream.spliterator(), true);
-//             
-//                     
-//                     
-////                   stream.forEach(path->System.out.println(path));
-//                     parrale.forEach(path->{
-//                             Yaml reader =getReader();
+               Path path1 = Paths.get("/home/maanadev/cwlTools");
+               Path path2 = path1.normalize();
+
+               boolean pathExits = Files.exists(path2, new LinkOption[] { 
LinkOption.NOFOLLOW_LINKS });
+
+               File file = new File("/home/maanadev/cwlTools", 
"ucsc-liftOver.cwl");
+               
+               Yaml reader = getReader();
+               Map map = null ;
+               try {
+                       map= (Map) reader.load(new FileInputStream(file));
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+//                     stream.forEach(path -> {
+//                             Yaml reader = getReader();
 //                             try {
-//                                     Map map=(Map) reader.load(new 
FileInputStream(path.toFile()));
-//                                     System.out.println(map);
+//                                     Map map = (Map) reader.load(new 
FileInputStream(path.toFile()));
 //                             } catch (Exception e) {
 //                                     // TODO Auto-generated catch block
 //                                     e.printStackTrace();
 //                             }
-//                     }); 
-//
-//             } catch (IOException e) {
-//                     e.printStackTrace();
-//             }
-
-               String s=" 1 2 3 ";
-               System.out.println(s);
-               System.out.println(s.replaceAll("\\s", ""));
-               
-               s= " 1_2_3";
-               System.out.println(s);
-               System.out.println(s.replaceAll("_", ""));
-               
-               
-       }
-
+//                     });
+                       // parrale.forEach(path->{
+                       // Yaml reader =getReader();
+                       // try {
+                       // Map map=(Map) reader.load(new 
FileInputStream(path.toFile()));
+                       // System.out.println(map);
+                       // } catch (Exception e) {
+                       // // TODO Auto-generated catch block
+                       // e.printStackTrace();
+                       // }
+                       // });
+String finall="";
+String line="";
+                       
+               for(String s: 
map.get("description").toString().split("[\n|\r]")){
+                       
+                       while(s.length()>80){
+                               int lastSpaceIndex = s.lastIndexOf(" ",80);
+                               String firstHalf =s.substring(0, 
lastSpaceIndex)+"\n";
+                               s=s.substring(lastSpaceIndex+1);
+                               finall+=(firstHalf);
+                       }
+                       finall+=s+"\n";
+                       
+               }
+                       System.out.println(finall);     
+               }
+       
+       
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/9a0c7a8c/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/view/CwlContextualView.java
----------------------------------------------------------------------
diff --git 
a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/view/CwlContextualView.java
 
b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/view/CwlContextualView.java
index f4a7c6e..376b58a 100644
--- 
a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/view/CwlContextualView.java
+++ 
b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/view/CwlContextualView.java
@@ -51,6 +51,7 @@ public class CwlContextualView extends 
HTMLBasedActivityContextualView<CwlActivi
        private final CwlDumyActivity activity;
 
        private CWLUtil cwlutil;
+
        public CwlContextualView(CwlDumyActivity activity) {
                super((Activity) activity);
                this.activity = activity;
@@ -101,7 +102,7 @@ public class CwlContextualView extends 
HTMLBasedActivityContextualView<CwlActivi
        private String paragraphToHtml(String summery, String paragraph) {
 
                summery += "<tr><td colspan='2' align='left'>";
-
+               paragraph = formatParagraph(paragraph);
                for (String line : paragraph.split("[\n|\r]"))
                        summery += "<p>" + line + "</p>";
 
@@ -118,8 +119,8 @@ public class CwlContextualView extends 
HTMLBasedActivityContextualView<CwlActivi
                Map cwlFile = configurationBean.getCwlConfigurations();
                String description = "";
 
-               if (cwlFile.containsKey("description")) {
-                       description = (String) cwlFile.get("description");
+               if (cwlFile.containsKey(DESCRIPTION)) {
+                       description = (String) cwlFile.get(DESCRIPTION);
                        summery = paragraphToHtml(summery, description);
 
                }
@@ -131,31 +132,31 @@ public class CwlContextualView extends 
HTMLBasedActivityContextualView<CwlActivi
 
                HashMap<String, PortDetail> inputs = 
cwlutil.processInputDetails();
                HashMap<String, Integer> inputDepths = 
cwlutil.processInputDepths();
-               
-               if ((inputs != null && !inputs.isEmpty())&&(inputDepths != null 
&& !inputDepths.isEmpty()))
+
+               if ((inputs != null && !inputs.isEmpty()) && (inputDepths != 
null && !inputDepths.isEmpty()))
                        for (String id : inputs.keySet()) {
                                PortDetail detail = inputs.get(id);
-                               if(inputDepths.containsKey(id))
-                               summery = extractSummery(summery, id, 
detail,inputDepths.get(id));
+                               if (inputDepths.containsKey(id))
+                                       summery = extractSummery(summery, id, 
detail, inputDepths.get(id));
                        }
 
                summery += "<tr><th colspan='2' align='left'>Outputs</th></tr>";
 
                HashMap<String, PortDetail> outPuts = 
cwlutil.processOutputDetails();
                HashMap<String, Integer> outputDepths = 
cwlutil.processOutputDepths();
-               
-               if ((outPuts != null && !outPuts.isEmpty())&&(outputDepths != 
null && !outputDepths.isEmpty()))
+
+               if ((outPuts != null && !outPuts.isEmpty()) && (outputDepths != 
null && !outputDepths.isEmpty()))
                        for (String id : outPuts.keySet()) {
                                PortDetail detail = outPuts.get(id);
-                               if(outputDepths.containsKey(id))
-                                       summery = extractSummery(summery, id, 
detail,outputDepths.get(id));
+                               if (outputDepths.containsKey(id))
+                                       summery = extractSummery(summery, id, 
detail, outputDepths.get(id));
                        }
                summery += "</table>";
                return summery;
        }
 
-       private String extractSummery(String summery, String id, PortDetail 
detail,int depth) {
-               summery += "<tr align='left'><td> ID: " + id + " 
</td><td>Depth: " + depth+ "</td></tr>";
+       private String extractSummery(String summery, String id, PortDetail 
detail, int depth) {
+               summery += "<tr align='left'><td> ID: " + id + " 
</td><td>Depth: " + depth + "</td></tr>";
                if (detail.getLabel() != null) {
                        summery += "<tr><td  align ='left' colspan ='2'>Label: 
" + detail.getLabel() + "</td></tr>";
                }
@@ -183,4 +184,21 @@ public class CwlContextualView extends 
HTMLBasedActivityContextualView<CwlActivi
                summery += "<tr></tr>";
                return summery;
        }
+
+       private String formatParagraph(String paragraph) {
+               String result = "";
+               for (String line : paragraph.split("[\n|\r]")) {
+
+                       while (line.length() > 80) {
+                               int lastSpaceIndex = line.lastIndexOf(" ", 80);
+                               String firstHalf = line.substring(0, 
lastSpaceIndex) + "\n";
+                               line = line.substring(lastSpaceIndex + 1);
+                               result += (firstHalf);
+                       }
+                       result += (line + "\n");
+
+               }
+               return result;
+       }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/9a0c7a8c/taverna-cwl-utilities/src/test/java/org/apache/taverna/cwl/utilities/CWLUtilTest.java
----------------------------------------------------------------------
diff --git 
a/taverna-cwl-utilities/src/test/java/org/apache/taverna/cwl/utilities/CWLUtilTest.java
 
b/taverna-cwl-utilities/src/test/java/org/apache/taverna/cwl/utilities/CWLUtilTest.java
index 6f5a4ad..9f20110 100644
--- 
a/taverna-cwl-utilities/src/test/java/org/apache/taverna/cwl/utilities/CWLUtilTest.java
+++ 
b/taverna-cwl-utilities/src/test/java/org/apache/taverna/cwl/utilities/CWLUtilTest.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *     contributor license agreements.  See the NOTICE file distributed with
+ *     this work for additional information regarding copyright ownership.
+ *     The ASF licenses this file to You under the Apache License, Version 2.0
+ *     (the "License"); you may not use this file except in compliance with
+ *     the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ 
*******************************************************************************/
 package org.apache.taverna.cwl.utilities;
 
 import static org.junit.Assert.*;
@@ -6,11 +22,9 @@ import java.io.FileInputStream;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import java.util.stream.Stream;
 
 import org.junit.Before;
 import org.junit.Test;

Reply via email to