/** * Returns the file inspected by the given {@code PageModel}. * * @param page {@code PageModel} to retrieve the inspected file from. * @return {@code FileObject} that corresponds to the file inspected * by the given {@code PageModel} or {@code null} when such {@code FileObject} * cannot be found. */ static FileObject inspectedFileObject(PageModel page) { FileObject fob = null; Project project = page.getProject(); if (project != null) { String documentURL = page.getDocumentURL(); try { URL url = new URL(documentURL); fob = ServerURLMapping.fromServer(project, url); } catch (MalformedURLException ex) { } } return fob; }
/** * Updates css in browser using webKit. * @param snapshot */ synchronized void update(FileObject fileObject, String content) { assert webKit != null: "webKit not initialized"; // NOI18N Project owner = FileOwnerQuery.getOwner(fileObject); if (owner == null) { return; } URL serverUrl = ServerURLMapping.toServer(owner, fileObject); if (serverUrl == null) { return; } String mimeType = fileObject.getMIMEType(); if (mimeType.equals("text/html")) { // Should we be more strict, i.e., !mimeType.equals("text/css")? // NOI18N return; // Issue 225630 } StyleSheetHeader header = sheetsMap.get(serverUrl.toString()); if (header == null) { header = fobToSheetMap.get(fileObject); } if (header != null) { webKit.getCSS().setStyleSheetText(header.getStyleSheetId(), content); } }
private void browseFile(BrowserSupport bs, FileObject fo, String fragment) { URL url; if (FileUtil.isParentOf(project.getSiteRootFolder(), fo)) { url = ServerURLMapping.toServer(project, fo); if (fragment.length() > 0) { url = WebUtils.stringToUrl(WebUtils.urlToString(url)+fragment); } bs.load(url, fo); } else { url = fo.toURL(); WebBrowser wb = project.getProjectWebBrowser(); WebBrowserFeatures features = new WebBrowserFeatures(false, false, false, false, false, false); wb.createNewBrowserPane(features).showURL(url); } } }
/** * Start listening on CSS. Propagate changes to given webkit. * @param webKit */ synchronized void start(WebKitDebugging webKit, Project project) { assert webKit !=null : "webKit allready assigned"; // NOI18N this.webKit = webKit; for (StyleSheetHeader header : webKit.getCSS().getAllStyleSheets()) { try { //need to convert file:/// URL url = new URL(header.getSourceURL()); sheetsMap.put(url.toString(), header); if (project != null) { FileObject fob = ServerURLMapping.fromServer(project, url); if (fob != null) { fobToSheetMap.put(fob, header); } } //TODO: hack to workaround #221791 if (WebUtils.getLocalhostInetAddress().equals(InetAddress.getByName(url.getHost()))) { sheetsMap.put(new URL(url.toExternalForm().replace(url.getHost(), "localhost")).toString(), header); // NOI18N } } catch (IOException ex) { //ignore unknown sheets } } }
try { URL url = new URL(documentURL); final FileObject fob = ServerURLMapping.fromServer(project, url); if (fob != null) { EventQueue.invokeLater(new Runnable() {
if (project != null) { try { result = ServerURLMapping.fromServer(project, new URL(name)); synchronized (cache) { cache.put(ref, result);
String documentURL = pageModel.getDocumentURL(); url = new URL(documentURL); fob = ServerURLMapping.fromServer(project, url); if (fob != null) { dob = DataObject.find(fob);