|
PRViewer |
|
1 /* 2 * Copyright (c) 1998-2001, The University of Sheffield. 3 * 4 * This file is part of GATE (see http://gate.ac.uk/), and is free 5 * software, licenced under the GNU Library General Public License, 6 * Version 2, June 1991 (in the distribution as file licence.html, 7 * and also available at http://gate.ac.uk/gate/licence.html). 8 * 9 * Valentin Tablan 27/02/2002 10 * 11 * $Id: PRViewer.java,v 1.2 2002/03/04 18:32:33 valyt Exp $ 12 * 13 */ 14 package gate.gui; 15 16 import javax.swing.*; 17 import java.awt.BorderLayout; 18 import java.awt.Component; 19 20 import gate.*; 21 import gate.util.*; 22 import gate.creole.*; 23 24 25 public class PRViewer extends AbstractVisualResource { 26 27 public PRViewer() { 28 initLocalData(); 29 initGuiComponents(); 30 initListeners(); 31 } 32 33 protected void initLocalData(){ 34 } 35 36 protected void initGuiComponents(){ 37 setLayout(new BorderLayout()); 38 editor = new ResourceParametersEditor(); 39 editor.setEditable(false); 40 JScrollPane scroller = new JScrollPane(editor); 41 scroller.setAlignmentX(Component.LEFT_ALIGNMENT); 42 scroller.setAlignmentY(Component.TOP_ALIGNMENT); 43 add(scroller, BorderLayout.CENTER); 44 } 45 46 protected void initListeners(){ 47 } 48 49 public void cleanup(){ 50 super.cleanup(); 51 editor.cleanup(); 52 } 53 54 public void setTarget(Object target){ 55 if(target == null) return; 56 if(!(target instanceof ProcessingResource)){ 57 throw new GateRuntimeException(this.getClass().getName() + 58 " can only be used to display " + 59 ProcessingResource.class.getName() + 60 "\n" + target.getClass().getName() + 61 " is not a " + 62 ProcessingResource.class.getName() + "!"); 63 } 64 if(target != null){ 65 ProcessingResource pr = (ProcessingResource)target; 66 ResourceData rData = (ResourceData)Gate.getCreoleRegister(). 67 get(pr.getClass().getName()); 68 if(rData != null){ 69 editor.init(null, rData.getParameterList().getInitimeParameters()); 70 }else{ 71 editor.init(null, null); 72 } 73 }else{ 74 editor.init(null, null); 75 } 76 } 77 78 ResourceParametersEditor editor; 79 }
|
PRViewer |
|