public CSSProfile findProfileFor(IStructuredModel model) { String baseLocation = null; if (model instanceof ICSSModel) { Object modelType = ((ICSSModel) model).getStyleSheetType(); if (modelType == ICSSModel.EXTERNAL) { baseLocation = model.getBaseLocation(); } else if (modelType == ICSSModel.EMBEDDED || modelType == ICSSModel.INLINE) { baseLocation = model.getBaseLocation(); // may be null } } else if (model != null) { baseLocation = model.getBaseLocation(); } return findProfileFor(baseLocation); }
/** * Returns the owner file name of the SSE model {@link IStructuredModel}. * * @param model * @return */ public static final String getFileName(IStructuredModel model) { String baselocation = model.getBaseLocation(); if (baselocation != null) { int index = baselocation.lastIndexOf('/'); if (index == -1) { index = baselocation.lastIndexOf('\\'); } if (index == -1) { return baselocation; } return baselocation.substring(index + 1, baselocation.length()); } return null; }
protected Action createAddSchemaInfoAction(Element element) { return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_SCHEMA_INFORMATION); }
protected Action createEditDoctypeAction(DocumentType doctype) { return new EditDoctypeAction(fModel, doctype, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_DOCTYPE); }
protected Action createEditSchemaInfoAction(Element element) { return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_NAMESPACES); }
/** * Returns the owner file name of the SSE model {@link IStructuredModel}. * * @param model * @return */ public static final String getFileName(IStructuredModel model) { String baselocation = model.getBaseLocation(); if (baselocation != null) { int index = baselocation.lastIndexOf('/'); if (index == -1) { index = baselocation.lastIndexOf('\\'); } if (index == -1) { return baselocation; } return baselocation.substring(index + 1, baselocation.length()); } return null; }
protected Action createAddDoctypeAction(Document document, int index) { return new EditDoctypeAction(fModel, document, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION); }
private IFile getFile(IStructuredModel model) { String location = model.getBaseLocation(); if (location != null) { IPath path = new Path(location); if (path.segmentCount() > 1) { return ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } return null; }
protected static IFile getFileFor(IStructuredModel model) { if (model == null) return null; String path = model.getBaseLocation(); if (path == null || path.length() == 0) { Object id = model.getId(); if (id == null) return null; path = id.toString(); } // TODO needs rework for linked resources IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile file = root.getFileForLocation(new Path(path)); return file; }
private IFile getFile(IStructuredModel model) { if (model != null) { String location = model.getBaseLocation(); if (location != null) { IPath path = new Path(location); if (!path.toFile().exists() && path.segmentCount() > 1) { return ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } } return null; }
private IFile getFile(IStructuredModel model) { IFile result = null; String location = model.getBaseLocation(); if (location != null) { IPath path = new Path(location); if (path.segmentCount() > 1) { result = ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } return result; }
/** * Returns the owner file of the SSE model {@link IStructuredModel}. * * @param node * the SSE model. * @return */ public static final IFile getFile(IStructuredModel model) { String baselocation = model.getBaseLocation(); if (baselocation != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath filePath = new Path(baselocation); if (filePath.segmentCount() > 1) { return root.getFile(filePath); } } return null; }
/** * Returns the owner file of the SSE model {@link IStructuredModel}. * * @param node * the SSE model. * @return */ public static final IFile getFile(IStructuredModel model) { String baselocation = model.getBaseLocation(); if (baselocation != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath filePath = new Path(baselocation); if (filePath.segmentCount() > 1) { return root.getFile(filePath); } } return null; }
/** * this method is copied from ModelManagerImpl of wtp. Because it is * internal. * * @param model * @return null if can't get file. */ // TODO: replace (or supplement) this is a "model info" association to the // IFile that created the model public static IFile getFileFor(IStructuredModel model) { if (model == null) return null; String path = model.getBaseLocation(); if (path == null || path.length() == 0) { Object id = model.getId(); if (id == null) return null; path = id.toString(); } // TODO needs rework for linked resources IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); try { IFile file = root.getFile(new Path(path)); // IFile file = root.getFileForLocation(new Path(path)); return file; } catch (Exception ex) { return null; } }
private void updateResolver(IStructuredModel model) { String baseLocation = model.getBaseLocation(); IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation())); if (baseFile != null) { if (baseFile.getLocation() != null) { baseLocation = baseFile.getLocation().toString(); } if (baseLocation == null && baseFile.getLocationURI() != null) { baseLocation = baseFile.getLocationURI().toString(); } if (baseLocation == null) { baseLocation = baseFile.getFullPath().toString(); } } else { baseLocation = model.getBaseLocation(); } modelQueryAdapter.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver())); }
protected void updateResolver(IStructuredModel model) { String baseLocation = model.getBaseLocation(); IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation())); if (baseFile != null) { if (baseFile.getLocation() != null) { baseLocation = baseFile.getLocation().toString(); } if (baseLocation == null && baseFile.getLocationURI() != null) { baseLocation = baseFile.getLocationURI().toString(); } if (baseLocation == null) { baseLocation = baseFile.getFullPath().toString(); } } else { baseLocation = model.getBaseLocation(); } modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver())); }
protected void updateResolver(IStructuredModel model) { String baseLocation = model.getBaseLocation(); IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation())); if (baseFile != null) { if (baseFile.getLocation() != null) { baseLocation = baseFile.getLocation().toString(); } if (baseLocation == null && baseFile.getLocationURI() != null) { baseLocation = baseFile.getLocationURI().toString(); } if (baseLocation == null) { baseLocation = baseFile.getFullPath().toString(); } } else { baseLocation = model.getBaseLocation(); } modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(baseLocation, model.getResolver())); }
private IPath getModelPath() { IPath path = null; IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(getStructuredDocument()); try { if (sModel != null) path = new Path(sModel.getBaseLocation()); } finally { if (sModel != null) sModel.releaseFromRead(); } return path; }
private IFile getFile() { IFile f = null; IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(getStructuredDocument()); try { if (sModel != null) f = FileBuffers.getWorkspaceFileAtLocation(new Path(sModel.getBaseLocation())); } finally { if (sModel != null) sModel.releaseFromRead(); } return f; }
sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); if (sModel != null) { result = sModel.getBaseLocation();