Java Code Examples for gate.creole.ResourceInstantiationException#printStackTrace()
The following examples show how to use
gate.creole.ResourceInstantiationException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceParametersEditor.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { ParameterDisjunction pDisj = parameterDisjunctions.get(rowIndex); switch(columnIndex) { case 0: { if(aValue instanceof ParameterDisjunction){ //do nothing } else if (aValue instanceof Integer){ pDisj.setSelectedIndex((Integer) aValue); } break; } case 1: { break; } case 2: { break; } case 3: { Object oldValue = pDisj.getValue(); if (!Objects.equals(oldValue, aValue)) { pDisj.setValue(aValue); if (ResourceParametersEditor.this == null || ResourceParametersEditor.this.resource == null) break; try { ResourceParametersEditor.this.resource.setParameterValue(pDisj.getName(), pDisj.getValue()); } catch(ResourceInstantiationException e) { e.printStackTrace(); } } break; } default: { } } tableModel.fireTableCellUpdated(rowIndex, columnIndex); }
Example 2
Source File: NameBearerHandle.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { try { Corpus corpus = Factory.newCorpus("Corpus for " + target.getName()); corpus.add((Document)target); } catch(ResourceInstantiationException rie) { Err.println("Exception creating corpus"); rie.printStackTrace(Err.getPrintWriter()); } }
Example 3
Source File: CollectionPersistence.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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{ List<String> exceptionsOccurred = new ArrayList<String>(); //let's try to create a collection of the same type as the original Collection<Object> result = null; try{ result = (Collection<Object>)collectionType.newInstance(); }catch(Exception e){ // ignore - if we can't create a collection of the original type // for any reason, just create an ArrayList as a fallback. The // main use for this class is to persist parameter values for // GATE resources, and GATE can convert an ArrayList to any type // required by a resource parameter. } if(result == null) result = new ArrayList<Object>(localList.size()); //now we have the collection let's populate it for(Object local : localList) { try { result.add(PersistenceManager.getTransientRepresentation( local,containingControllerName,initParamOverrides)); } catch(PersistenceException pe) { exceptionsOccurred.add(pe.getMessage()); pe.printStackTrace(Err.getPrintWriter()); } catch(ResourceInstantiationException rie) { exceptionsOccurred.add(rie.getMessage()); rie.printStackTrace(Err.getPrintWriter()); } } if(exceptionsOccurred.size() > 0) { throw new PersistenceException("Some resources cannot be restored:\n" + Arrays.toString(exceptionsOccurred .toArray(new String[exceptionsOccurred.size()])) .replaceAll("[\\]\\[]", "").replaceAll(", ", "\n")); } return result; }
Example 4
Source File: SerialDatastoreViewer.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent e) { Runnable runner = new Runnable(){ @Override public void run(){ // load all selected resources TreePath[] selectedPaths = mainTree.getSelectionPaths(); if(ignoreSelection){ ignoreSelection = false; selectedPaths = null; } // if no selection -> load path under cursor if(selectedPaths == null && location != null) { selectedPaths = new TreePath[] {location}; location = null; } if(selectedPaths != null) { for(TreePath aPath : selectedPaths) { Object value = ((DefaultMutableTreeNode)aPath.getLastPathComponent()) .getUserObject(); if(value instanceof DSEntry) { DSEntry entry = (DSEntry)value; try { MainFrame.lockGUI("Loading " + entry.name); long start = System.currentTimeMillis(); fireStatusChanged("Loading " + entry.name); fireProgressChanged(0); FeatureMap params = Factory.newFeatureMap(); params.put(DataStore.DATASTORE_FEATURE_NAME, datastore); params.put(DataStore.LR_ID_FEATURE_NAME, entry.id); FeatureMap features = Factory.newFeatureMap(); Factory.createResource(entry.type, params, features, entry.name); // project.frame.resourcesTreeModel.treeChanged(); fireProgressChanged(0); fireProcessFinished(); long end = System.currentTimeMillis(); fireStatusChanged(entry.name + " loaded in " + NumberFormat.getInstance().format( (double)(end - start) / 1000) + " seconds"); } catch(ResourceInstantiationException rie) { MainFrame.unlockGUI(); JOptionPane.showMessageDialog(SerialDatastoreViewer.this, "Error!\n" + rie.toString(), "GATE", JOptionPane.ERROR_MESSAGE); rie.printStackTrace(Err.getPrintWriter()); fireProgressChanged(0); fireProcessFinished(); } finally { MainFrame.unlockGUI(); } } } } } }; Thread thread = new Thread(runner, SerialDatastoreViewer.this.getClass().getCanonicalName() + " DS Loader"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }