public void testFlagNoRichEditor() throws Exception { if (!PlatformUiUtil.hasInternalBrowser()) { return; } TasksUiUtil.openUrl(null); assertEquals(1, activePage.getEditorReferences().length); IEditorPart editor = activePage.getEditorReferences()[0].getEditor(true); assertEquals(WebBrowserEditor.class, editor.getClass()); assertEquals(WebBrowserEditorInput.class, editor.getEditorInput().getClass()); assertEquals(null, ((WebBrowserEditorInput) editor.getEditorInput()).getURL()); WebBrowserEditorInput input = ((WebBrowserEditorInput) editor.getEditorInput()); Field f = input.getClass().getDeclaredField("style"); f.setAccessible(true); int style = (Integer) f.get(input); assertFalse((style & BrowserUtil.NO_RICH_EDITOR) == 0); TasksUiUtil.openUrl("http://eclipse.org/mylyn"); assertEquals(2, activePage.getEditorReferences().length); editor = activePage.getEditorReferences()[0].getEditor(true); assertEquals(WebBrowserEditor.class, editor.getClass()); assertEquals(WebBrowserEditorInput.class, editor.getEditorInput().getClass()); assertEquals(null, ((WebBrowserEditorInput) editor.getEditorInput()).getURL()); input = ((WebBrowserEditorInput) editor.getEditorInput()); f = input.getClass().getDeclaredField("style"); f.setAccessible(true); style = (Integer) f.get(input); assertFalse((style & BrowserUtil.NO_RICH_EDITOR) == 0); IEditorPart editor2 = activePage.getEditorReferences()[1].getEditor(true); assertEquals(WebBrowserEditor.class, editor2.getClass()); assertEquals(WebBrowserEditorInput.class, editor2.getEditorInput().getClass()); assertNotNull(((WebBrowserEditorInput) editor2.getEditorInput()).getURL()); assertEquals( "http://eclipse.org/mylyn", ((WebBrowserEditorInput) editor2.getEditorInput()).getURL().toString()); input = ((WebBrowserEditorInput) editor.getEditorInput()); f = input.getClass().getDeclaredField("style"); f.setAccessible(true); style = (Integer) f.get(input); assertFalse((style & BrowserUtil.NO_RICH_EDITOR) == 0); // open task should not set FLAG_NO_RICH_EDITOR TasksUiUtil.openTask("http://eclipse.org/mylyn/test"); assertEquals(3, activePage.getEditorReferences().length); editor = activePage.getEditorReferences()[2].getEditor(true); assertEquals(WebBrowserEditor.class, editor.getClass()); assertEquals(WebBrowserEditorInput.class, editor.getEditorInput().getClass()); assertEquals( "http://eclipse.org/mylyn/test", ((WebBrowserEditorInput) editor.getEditorInput()).getURL().toString()); input = ((WebBrowserEditorInput) editor.getEditorInput()); f = input.getClass().getDeclaredField("style"); f.setAccessible(true); style = (Integer) f.get(input); assertTrue((style & BrowserUtil.NO_RICH_EDITOR) == 0); }
private void openedByBrowser(Item item, URL url) { if (url == null || item == null) { return; } WebBrowserEditorInput input = new WebBrowserEditorInput(url); // add for bug TDI-21189 at 2012-6-8,that a document exist is only opened one time in studio try { IWorkbenchPage page = getActivePage(); IEditorReference[] iEditorReference = page.getEditorReferences(); for (IEditorReference editors : iEditorReference) { if (WebBrowserEditor.WEB_BROWSER_EDITOR_ID.equals(editors.getId())) { IEditorPart iEditorPart = editors.getEditor(true); if (iEditorPart != null && iEditorPart instanceof WebBrowserEditor) { WebBrowserEditorInput webBrowserEditorInput = (WebBrowserEditorInput) iEditorPart.getEditorInput(); if (webBrowserEditorInput != null && url.equals(webBrowserEditorInput.getURL())) { // page.activate(iEditorPart); iEditorPart.init(iEditorPart.getEditorSite(), webBrowserEditorInput); DocumentationUtil.setPartItemId( (WebBrowserEditor) iEditorPart, item.getProperty().getId(), ERepositoryObjectType.getItemType(item)); return; } } } } input.setName(item.getProperty().getLabel()); input.setToolTipText( item.getProperty().getLabel() + " " + item.getProperty().getVersion()); // $NON-NLS-1$ IEditorPart editorPart = page.openEditor(input, WebBrowserEditor.WEB_BROWSER_EDITOR_ID); if (editorPart != null && editorPart instanceof WebBrowserEditor) { DocumentationUtil.setPartItemId( (WebBrowserEditor) editorPart, item.getProperty().getId(), ERepositoryObjectType.getItemType(item)); } } catch (PartInitException e) { MessageBoxExceptionHandler.process(e); } }
public void testHashWithNullID() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, null); input.hashCode(); // Fails if exception thrown }
public void testHashWithNullURL() { WebBrowserEditorInput input = new WebBrowserEditorInput(null, 0, ID1); input.hashCode(); // Fails if exception thrown }
public void testCompareWithStatusbarVisible() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, ID1); WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), IWorkbenchBrowserSupport.STATUS, ID1); assertFalse(input.equals(input2)); }
public void testCompareWithDifferentStyle() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, ID1); WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), 1, ID1); assertTrue(input.equals(input2)); assertTrue(input.hashCode() == input2.hashCode()); }
public void testCompareWithDifferentId() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, ID1); WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), 0, ID2); assertFalse(input.equals(input2)); }
public void testCompareWithSelf() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, ID1); assertTrue(input.equals(input)); }
public void testCompareWithNull() throws MalformedURLException { WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), 0, ID1); assertFalse(input.equals(null)); }