/** * adds a tableItem to the table. * * @param o the o * @param keyName the key name */ private void addFile(Object o, String keyName) { Import impItem = (Import) o; String fileName = impItem.getLocation(); if (null == fileName || (0 == fileName.length())) fileName = impItem.getName(); // create new TableItem TableItem item = new TableItem(filesTable, SWT.NONE); item.setImage(TAEConfiguratorPlugin.getImage(TAEConfiguratorPlugin.IMAGE_ANNOTATOR)); item.setText(0, fileName); item.setText(1, keyName); }
private static void setImportsByLocation(File dir, String descName) { FileOutputStream fos = null; try { File file = new File(dir, descName); AnalysisEngineDescription description = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(file)); Import[] imports = description.getAnalysisEngineMetaData().getTypeSystem().getImports(); for (Import each : imports) { String name = each.getName(); String[] split = name.split("[.]"); String location = split[split.length - 1] + ".xml"; each.setName(null); each.setLocation(location); } fos = new FileOutputStream(file); description.toXML(fos); } catch (InvalidXMLException | IOException | SAXException e) { RutaIdeUIPlugin.error(e); } finally { IOUtils.closeQuietly(fos); } }
/** * @param descriptor * @param cpeDescSaveFile */ private void updateImport(CpeComponentDescriptor descriptor, File cpeDescSaveFile) throws Exception { //don't touch import by name if (descriptor.getImport() != null && descriptor.getImport().getName() != null) return; //for include or import by location, get the absolute URL of the descriptor URL descUrl = descriptor.findAbsoluteUrl(defaultResourceManager); //don't touch URLs with protocol other than file: if ("file".equals(descUrl.getProtocol())) { File descFile = urlToFile(descUrl); //try to find relative path from cpeDescSaveFile to descFile String relPath = FileUtils.findRelativePath(descFile, cpeDescSaveFile.getParentFile()); if (relPath != null) { //update CPE descriptor descriptor.setInclude(null); Import newImport = UIMAFramework.getResourceSpecifierFactory().createImport(); newImport.setLocation(relPath); descriptor.setImport(newImport); } } }
fileName = fcdImport.getLocation(); if (null == fileName || (0 == fileName.length())) fileName = fcdImport.getName();
/** * Update import. * * @param descriptor the descriptor * @param cpeDescSaveFile the cpe desc save file * @throws Exception the exception */ private void updateImport(CpeComponentDescriptor descriptor, File cpeDescSaveFile) throws Exception { //don't touch import by name if (descriptor.getImport() != null && descriptor.getImport().getName() != null) return; //for include or import by location, get the absolute URL of the descriptor URL descUrl = descriptor.findAbsoluteUrl(defaultResourceManager); //don't touch URLs with protocol other than file: if ("file".equals(descUrl.getProtocol())) { File descFile = urlToFile(descUrl); //try to find relative path from cpeDescSaveFile to descFile String relPath = FileUtils.findRelativePath(descFile, cpeDescSaveFile.getParentFile()); if (relPath != null) { //update CPE descriptor descriptor.setInclude(null); Import newImport = UIMAFramework.getResourceSpecifierFactory().createImport(); newImport.setLocation(relPath); descriptor.setImport(newImport); } } }
@Override public void refresh() { super.refresh(); importTable.removeAll(); if (isAppropriate()) { Import[] importItems = getModelImportArray(); if (importItems != null) { for (int i = 0; i < importItems.length; i++) { if (importItems[i] != null) { TableItem tableItem = new TableItem(importTable, SWT.NONE); if (importItems[i].getLocation() != null) { tableItem.setText(0, TABLE_INDICATOR_BY_LOCATION); tableItem.setText(1, importItems[i].getLocation()); } else { tableItem.setText(0, TABLE_INDICATOR_BY_NAME); tableItem.setText(1, importItems[i].getName()); } } } packTable(importTable); } } enable(); }