use of gate.Controller in project gate-core by GateNLP.
the class NameBearerHandle method buildViews.
protected void buildViews() {
viewsBuilt = true;
fireStatusChanged("Building views...");
// build the large views
List<String> largeViewNames = Gate.getCreoleRegister().getLargeVRsForResource(target.getClass().getName());
if (largeViewNames != null && !largeViewNames.isEmpty()) {
largeView = new JTabbedPane(JTabbedPane.BOTTOM);
Iterator<String> classNameIter = largeViewNames.iterator();
while (classNameIter.hasNext()) {
try {
String className = classNameIter.next();
ResourceData rData = Gate.getCreoleRegister().get(className);
FeatureMap params = Factory.newFeatureMap();
FeatureMap features = Factory.newFeatureMap();
Gate.setHiddenAttribute(features, true);
VisualResource view = (VisualResource) Factory.createResource(className, params, features);
try {
view.setTarget(target);
} catch (IllegalArgumentException iae) {
// the view cannot display this particular target
Factory.deleteResource(view);
view = null;
}
if (view != null) {
view.setHandle(this);
((JTabbedPane) largeView).add((Component) view, rData.getName());
// publishers
if (view instanceof ActionsPublisher)
actionPublishers.add((ActionsPublisher) view);
}
} catch (ResourceInstantiationException rie) {
rie.printStackTrace(Err.getPrintWriter());
}
}
// select the first view by default
((JTabbedPane) largeView).setSelectedIndex(0);
}
// build the small views
List<String> smallViewNames = Gate.getCreoleRegister().getSmallVRsForResource(target.getClass().getName());
if (smallViewNames != null && !smallViewNames.isEmpty()) {
smallView = new JTabbedPane(JTabbedPane.BOTTOM);
Iterator<String> classNameIter = smallViewNames.iterator();
while (classNameIter.hasNext()) {
try {
String className = classNameIter.next();
ResourceData rData = Gate.getCreoleRegister().get(className);
FeatureMap params = Factory.newFeatureMap();
FeatureMap features = Factory.newFeatureMap();
Gate.setHiddenAttribute(features, true);
VisualResource view = (VisualResource) Factory.createResource(className, params, features);
try {
view.setTarget(target);
} catch (IllegalArgumentException iae) {
// the view cannot display this particular target
Factory.deleteResource(view);
view = null;
}
if (view != null) {
view.setHandle(this);
((JTabbedPane) smallView).add((Component) view, rData.getName());
if (view instanceof ActionsPublisher)
actionPublishers.add((ActionsPublisher) view);
}
} catch (ResourceInstantiationException rie) {
rie.printStackTrace(Err.getPrintWriter());
}
}
((JTabbedPane) smallView).setSelectedIndex(0);
}
fireStatusChanged("Views built!");
// Add the CTRL +F4 key & action combination to the resource
JComponent largeView = this.getLargeView();
if (largeView != null) {
largeView.getActionMap().put("Close resource", new CloseAction());
if (target instanceof Controller) {
largeView.getActionMap().put("Close recursively", new CloseRecursivelyAction());
}
/*if(target instanceof gate.TextualDocument) {
largeView.getActionMap().put("Save As XML", new SaveAsXmlAction());
}// End if*/
}
// End if
}
use of gate.Controller in project gate-core by GateNLP.
the class ControllerPersistence method createObject.
/**
* Creates a new object from the data contained. This new object is supposed
* to be a copy for the original object used as source for data extraction.
*/
@SuppressWarnings("unchecked")
@Override
public Object createObject() throws PersistenceException, ResourceInstantiationException {
Controller controller = (Controller) super.createObject();
if (controller.getPRs().isEmpty()) {
prList = PersistenceManager.getTransientRepresentation(prList, resourceName, initParamOverrides);
controller.setPRs((Collection<ProcessingResource>) prList);
}
return controller;
}
use of gate.Controller in project gate-core by GateNLP.
the class ControllerPersistence method extractDataFromSource.
/**
* Populates this Persistence with the data that needs to be stored from the
* original source object.
*/
@Override
public void extractDataFromSource(Object source) throws PersistenceException {
if (!(source instanceof Controller)) {
throw new UnsupportedOperationException(getClass().getName() + " can only be used for " + Controller.class.getName() + " objects!\n" + source.getClass().getName() + " is not a " + Controller.class.getName());
}
Controller controller = (Controller) source;
super.extractDataFromSource(source);
/*prList = new ArrayList(controller.getPRs().size());
Iterator prIter = controller.getPRs().iterator();
while(prIter.hasNext()){
((List)prList).add(prIter.next());
}*/
prList = new ArrayList<ProcessingResource>(controller.getPRs());
prList = PersistenceManager.getPersistentRepresentation(prList);
}
Aggregations