private void updateLibs(XModelObject object) { if (WatcherLoader.isLocked(object.getModel())) { return; } IProject project = EclipseResourceUtil.getProject(object); if (project == null) return; XModelObject lib = validateLib(object); // if(lib == null) { // return; // } Libs libs = FileSystemsHelper.getLibs(object); if (libs != null) libs.update(); }
private static void _updateSrcs(XModelObject object) { IProject p = EclipseResourceUtil.getProject(object); if (p == null || !p.isAccessible()) return; String[] srcs = EclipseResourceUtil.getJavaProjectSrcLocations(p); Set<String> paths = new HashSet<String>(); for (int i = 0; i < srcs.length; i++) { String path = EclipseResourceUtil.getRelativeLocation(object.getModel(), srcs[i]); if (path == null) continue; paths.add(path); } XModelObject[] cs = object.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER); for (int i = 0; i < cs.length; i++) { if (cs[i] .getAttributeValue(XModelObjectConstants.ATTR_NAME) .startsWith("src")) { // $NON-NLS-1$ String loc = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION); if (!paths.contains(loc)) { object.removeChild(cs[i]); } else { paths.remove(loc); } } } for (String path : paths) { String n = getNextSrcName(object); Properties properties = new Properties(); properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, path); properties.setProperty(XModelObjectConstants.ATTR_NAME, n); FileSystemImpl s = (FileSystemImpl) object .getModel() .createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER, properties); object.addChild(s); } }
XFilteredTree createTree(String name, XModel model) { if (model == null || name == null) return null; String classname = model.getMetaData().getMapping("FilteredTrees").getValue(name); // $NON-NLS-1$ XFilteredTree result = null; try { result = (XFilteredTree) ModelFeatureFactory.getInstance().createFeatureInstance(classname); } catch (ClassCastException e) { ModelUIPlugin.getPluginLog().logError(e); return null; } result.setModel(model); if (result.getRoot() == null) { result = null; IProject p = EclipseResourceUtil.getProject(model.getRoot()); IModelNature nature = EclipseResourceUtil.getModelNature(p); if (nature != null) { ModelUIPlugin.getPluginLog() .logInfo( "Red Hat Project " + p.getName() + " is corrupted."); // $NON-NLS-1$ //$NON-NLS-2$ } } return result; }