{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== '免费Z-image图片生成' && linkText !== '免费Z-image图片生成' ) { link.textContent = '免费Z-image图片生成'; link.href = 'https://zimage.run'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== 'Vibevoice' ) { link.textContent = 'Vibevoice'; link.href = 'https://vibevoice.info/'; replacedLinks.add(link); } // 替换Pricing链接 - 仅替换一次 else if ( (linkHref.includes('/pricing') || linkHref === '/pricing' || linkText === 'Pricing' || linkText.match(/^s*Pricings*$/i)) && linkText !== '免费去水印' ) { link.textContent = '免费去水印'; link.href = 'https://sora2watermarkremover.net/'; replacedLinks.add(link); } // 替换Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) && linkText !== 'LTX-2' ) { link.textContent = 'LTX-2'; link.href = 'https://ltx-2.run/'; replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, '免费Z-image图片生成'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \");\n\t}\n\t\n\tpublic static void startBulletList(StringBuffer buffer) {\n\t\tbuffer.append(\"
    \");\n\t}\n\t\n\tpublic static void endBulletList(StringBuffer buffer) {\n\t\tbuffer.append(\"
\");\n\t}\n\t\n\tpublic static void addBullet(StringBuffer buffer, String bullet) {\n\t\tif (bullet != null) {\n\t\t\tbuffer.append(\"
  • \");\n\t\t\tbuffer.append(bullet);\n\t\t\tbuffer.append(\"
  • \");\n\t\t}\n\t}\n\t\n\tpublic static void addSmallHeader(StringBuffer buffer, String header) {\n\t\tif (header != null) {\n\t\t\tbuffer.append(\"
    \");\n\t\t\tbuffer.append(header);\n\t\t\tbuffer.append(\"
    \");\n\t\t}\n\t}\n\t\n\tpublic static void addParagraph(StringBuffer buffer, String paragraph) {\n\t\tif (paragraph != null) {\n\t\t\tbuffer.append(\"

    \");\n\t\t\tbuffer.append(paragraph);\n\t\t\tbuffer.append(\"

    \");\n\t\t}\n\t}\n\t\n\tpublic static void addParagraph(StringBuffer buffer, Reader paragraphReader) {\n\t\tif (paragraphReader != null)\n\t\t\taddParagraph(buffer, read(paragraphReader));\n\t}\n}"}}},{"rowIdx":64,"cells":{"issue_id":{"kind":"number","value":5120,"string":"5,120"},"title":{"kind":"string","value":"Bug 5120 Empty popup doc in java editor"},"body":{"kind":"string","value":"1. Go to Java Perspective. 2. Double click on a java file. 3. Move the i-beam over the beginning prefixes of an import statement. For example, the \"org\" of \"import org.eclipse.swt.SWT\". An empty hover help box is displayed."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"34be391"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-22T14:39:24Z","string":"2001-10-22T14:39:24Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-19T19:33:20Z","string":"2001-10-19T19:33:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTypeHover.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.text.java.hover;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.ITextHover;\nimport org.eclipse.jface.text.ITextViewer;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorPart;\n\nimport org.eclipse.jdt.core.ICodeAssist;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput;\nimport org.eclipse.jdt.internal.ui.text.HTMLPrinter;\nimport org.eclipse.jdt.internal.ui.text.JavaWordFinder;\nimport org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAccess;\nimport org.eclipse.jdt.internal.ui.viewsupport.JavaTextLabelProvider;\n\n\npublic class JavaTypeHover implements ITextHover {\n\t\n\tprivate IEditorPart fEditor;\n\tprivate JavaTextLabelProvider fTextRenderer;\n\t\n\t\n\tpublic JavaTypeHover(IEditorPart editor) {\n\t\tfEditor= editor;\n\t\tfTextRenderer= new JavaTextLabelProvider(JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION | JavaElementLabelProvider.SHOW_PARAMETERS);\n\t}\n\t\n\tprivate ICodeAssist getCodeAssist() {\n\t\tif (fEditor != null) {\n\t\t\tIEditorInput input= fEditor.getEditorInput();\n\t\t\tif (input instanceof ClassFileEditorInput) {\n\t\t\t\tClassFileEditorInput cfeInput= (ClassFileEditorInput) input;\n\t\t\t\treturn cfeInput.getClassFile();\n\t\t\t}\n\t\t\t\n\t\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\t\t\t\t\n\t\t\treturn manager.getWorkingCopy(input);\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\tprivate String getInfoText(IMember member) {\n\t\tif (member.getElementType() != IJavaElement.TYPE) {\n\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\tbuffer.append(fTextRenderer.getTextLabel(member.getDeclaringType()));\n\t\t\tbuffer.append('.');\n\t\t\tbuffer.append(fTextRenderer.getTextLabel(member));\n\t\t\treturn buffer.toString();\n\t\t}\n\t\t\n\t\treturn fTextRenderer.getTextLabel(member);\n\t}\n\t\t\n\t/*\n\t * @see ITextHover#getHoverRegion(ITextViewer, int)\n\t */\n\tpublic IRegion getHoverRegion(ITextViewer textViewer, int offset) {\n\t\treturn JavaWordFinder.findWord(textViewer.getDocument(), offset);\n\t}\n\t\n\t/*\n\t * @see ITextHover#getHoverInfo(ITextViewer, IRegion)\n\t */\n\tpublic String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {\n\t\tICodeAssist resolve= getCodeAssist();\n\t\tif (resolve != null) {\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\tIJavaElement[] result= resolve.codeSelect(hoverRegion.getOffset(), hoverRegion.getLength());\n\t\t\t\t\n\t\t\t\tif (result == null)\n\t\t\t\t\treturn null;\n\t\t\t\t\n\t\t\t\tint nResults= result.length;\t\n\t\t\t\tif (nResults == 0)\n\t\t\t\t\treturn null;\n\t\t\t\t\t\n\t\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\t\tHTMLPrinter.addPageProlog(buffer);\n\t\t\t\t\n\t\t\t\tif (nResults > 1) {\n\t\t\t\t\t\n\t\t\t\t\tfor (int i= 0; i < result.length; i++) {\n\t\t\t\t\t\tHTMLPrinter.startBulletList(buffer);\n\t\t\t\t\t\tIJavaElement curr= result[i];\n\t\t\t\t\t\tif (curr instanceof IMember)\n\t\t\t\t\t\t\tHTMLPrinter.addBullet(buffer, getInfoText((IMember) curr));\n\t\t\t\t\t\tHTMLPrinter.endBulletList(buffer);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tIJavaElement curr= result[0];\n\t\t\t\t\tif (curr instanceof IMember) {\n\t\t\t\t\t\tIMember member= (IMember) curr;\n\t\t\t\t\t\tHTMLPrinter.addSmallHeader(buffer, getInfoText(member));\n\t\t\t\t\t\tHTMLPrinter.addParagraph(buffer, JavaDocAccess.getJavaDoc(member));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHTMLPrinter.addPageEpilog(buffer);\n\t\t\t\t\n\t\t\t\treturn buffer.toString();\n\t\t\t\t\n\t\t\t} catch (JavaModelException x) {\n\t\t\t\tJavaPlugin.log(x.getStatus());\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\t\n}"}}},{"rowIdx":65,"cells":{"issue_id":{"kind":"number","value":3666,"string":"3,666"},"title":{"kind":"string","value":"Bug 3666 CodeCompletion - Hungry code assist (1GDRYW5)"},"body":{"kind":"string","value":"jkca (5/15/2001 11:04:56 AM) jre-sdk 106 Under certain circumstances code assist eats too much code. Consider the enclosed class. As a programmer, I must add a parameter to the baz call in bar to make the program correct. Steps: 1. Change the baz call to baz(x.x.foo()) 2. Place the cursor after the first \"x.\" 3. Ctrl-Space to bring up code assist 4. Type \"f\" to filter the list. 5. Select, \"foo()\" 6. The code is changed to: baz(x.foo().foo()) I would rather it gave me baz(x.foo()x.foo()) public class X { void bar(X x) { baz(x.foo()); } int foo() { return 5; } void baz(int i, int j) { } } KUM (5/21/01 9:02:11 AM) The text to replace is computed by the code assist infrastructure. Moved to ITPJCORE. PM (9/4/2001 2:58:56 PM) Option was added. PM (9/25/2001 2:20:50 PM) Removing option. UI can decide whether it wants to use the codeassist end position (until the end of current identifier) or the cursor location it used to start with, so as to control the amount of source to replace. The choice amongst one or the other should be conditioned by a keystroke (enter=replace until end, insert=replace until cursor location). Moving to ITPJUI. Removing codeassist option."},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"2846b5d"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-22T15:21:02Z","string":"2001-10-22T15:21:02Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ResultCollector.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.text.java;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n \nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\n\nimport org.eclipse.swt.graphics.Image;\n\nimport org.eclipse.core.resources.IMarker;\n\nimport org.eclipse.jface.text.contentassist.ICompletionProposal;\n\nimport org.eclipse.jdt.core.Flags;\nimport org.eclipse.jdt.core.ICodeCompletionRequestor;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IImportDeclaration;\nimport org.eclipse.jdt.core.IJavaProject;\n\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\n\n/**\n * Bin to collect the proposal of the infrastructure on code assist in a java text.\n */\npublic class ResultCollector implements ICodeCompletionRequestor {\n\t\n\tprivate class ProposalComparator implements Comparator {\n\t\tpublic int compare(Object o1, Object o2) {\n\t\t\tICompletionProposal c1= (ICompletionProposal) o1;\n\t\t\tICompletionProposal c2= (ICompletionProposal) o2;\n\t\t\treturn c1.getDisplayString().compareTo(c2.getDisplayString());\n\t\t}\n\t}\n\n\tprivate final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-' };\n\tprivate final static char[] GENERAL_TRIGGERS= new char[] { ';', ',', '.', '\\t', '(', '{', '[' };\n\t\n\tprivate ArrayList fFields= new ArrayList(), fKeywords= new ArrayList(), \n\t\t\t\t\t\tfLabels= new ArrayList(), fMethods= new ArrayList(), \n\t\t\t\t\t\tfModifiers= new ArrayList(), fPackages= new ArrayList(),\n\t\t\t\t\t\tfTypes= new ArrayList(), fVariables= new ArrayList();\n\n\tprivate IMarker fLastProblem;\n\t\n\tprivate IJavaProject fJavaProject;\n\tprivate ICompilationUnit fCompilationUnit;\n\t\n\tprivate ArrayList[] fResults = new ArrayList[] {\n\t\tfVariables, fFields, fMethods, fTypes, fKeywords, fModifiers, fLabels, fPackages\n\t};\n\t\n\tprivate int fUserReplacementLength;\n\tprivate int fUserReplacementOffset;\n\t\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptClass\n\t */\t\n\tpublic void acceptClass(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) {\n\t\tProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);\n\t\tfTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_CLASS, new String(typeName), new String(packageName), info));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptError\n\t */\t\n\tpublic void acceptError(IMarker problemMarker) {\n\t\tfLastProblem= problemMarker;\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptField\n\t */\t\n\tpublic void acceptField(\n\t\tchar[] declaringTypePackageName, char[] declaringTypeName, char[] name,\n\t\tchar[] typePackageName, char[] typeName, char[] completionName,\n\t\tint modifiers, int start, int end) {\n\t\n\t\tString iconName= JavaPluginImages.IMG_MISC_DEFAULT;\n\t\tif (Flags.isPublic(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PUBLIC;\n\t\t} else if (Flags.isProtected(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PROTECTED;\n\t\t} else if (Flags.isPrivate(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PRIVATE;\n\t\t}\n\t\n\t\tStringBuffer nameBuffer= new StringBuffer();\n\t\tnameBuffer.append(name);\n\t\tif (typeName.length > 0) {\n\t\t\tnameBuffer.append(\" \"); //$NON-NLS-1$\n\t\t\tnameBuffer.append(typeName);\n\t\t}\n\t\tif (declaringTypeName != null && declaringTypeName.length > 0) {\n\t\t\tnameBuffer.append(\" - \"); //$NON-NLS-1$\n\t\t\tnameBuffer.append(declaringTypeName);\n\t\t}\t\n\t\t\n\t\tJavaCompletionProposal proposal= createCompletion(start, end, new String(completionName), iconName, nameBuffer.toString());\n\t\tproposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name));\n\t\t\n\t\tfFields.add(proposal);\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptInterface\n\t */\t\n\tpublic void acceptInterface(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) {\n\t\tProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);\n\t\tfTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_INTERFACE, new String(typeName), new String(packageName), info));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptKeyword\n\t */\t\n\tpublic void acceptKeyword(char[] keyword, int start, int end) {\n\t\tString kw= new String(keyword);\n\t\tfKeywords.add(createCompletion(start, end, kw, null, kw));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptLabel\n\t */\t\n\tpublic void acceptLabel(char[] labelName, int start, int end) {\n\t\tString ln= new String(labelName);\n\t\tfLabels.add(createCompletion(start, end, ln, null, ln));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptLocalVariable\n\t */\t\n\tpublic void acceptLocalVariable(char[] name, char[] typePackageName, char[] typeName, int modifiers, int start, int end) {\n\t\tStringBuffer buf= new StringBuffer();\n\t\tbuf.append(name);\n\t\tif (typeName != null) {\n\t\t\tbuf.append(\" \"); //$NON-NLS-1$\n\t\t\tbuf.append(typeName);\n\t\t}\t\n\t\tfVariables.add(createCompletion(start, end, new String(name), null, buf.toString()));\n\t}\n\t\n\tprivate String getParameterSignature(char[][] parameterTypeNames, char[][] parameterNames) {\n\t\tStringBuffer buf = new StringBuffer();\n\t\tif (parameterTypeNames != null) {\n\t\t\tfor (int i = 0; i < parameterTypeNames.length; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tbuf.append(',');\n\t\t\t\t\tbuf.append(' ');\n\t\t\t\t}\n\t\t\t\tbuf.append(parameterTypeNames[i]);\n\t\t\t\tif (parameterNames[i] != null) {\n\t\t\t\t\tbuf.append(' ');\n\t\t\t\t\tbuf.append(parameterNames[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn buf.toString();\n\t}\n\t\n\t/*\n\t * @see ICodeCompletionRequestor#acceptMethod(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int)\n\t */\n\tpublic void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] name,\n\t\tchar[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames,\n\t\tchar[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers,\n\t\tint start, int end) {\n\t\n\t\tJavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end);\n\t\tproposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name, parameterPackageNames, parameterTypeNames));\n\n\t\tboolean hasClosingBracket= completionName.length > 0 && completionName[completionName.length - 1] == ')';\n\t\n\t\tProposalContextInformation contextInformation= null;\n\t\tif (hasClosingBracket && parameterTypeNames.length > 0) {\n\t\t\tcontextInformation= new ProposalContextInformation();\n\t\t\tcontextInformation.setInformationDisplayString(getParameterSignature(parameterTypeNames, parameterNames));\t\t\n\t\t\tcontextInformation.setContextDisplayString(proposal.getDisplayString());\t\t\t\n\t\t\tproposal.setContextInformation(contextInformation);\n\t\t}\n\t\n\t\tboolean userMustCompleteParameters= (contextInformation != null && completionName.length > 0);\n\t\tchar[] triggers= userMustCompleteParameters ? METHOD_WITH_ARGUMENTS_TRIGGERS : GENERAL_TRIGGERS;\n\t\tproposal.setTriggerCharacters(triggers);\n\t\t\n\t\tif (userMustCompleteParameters) {\n\t\t\t// set the cursor before the closing bracket\n\t\t\tproposal.setCursorPosition(completionName.length - 1);\n\t\t}\n\t\t\n\t\tfMethods.add(proposal);\n\t}\n\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptModifier\n\t */\t\n\tpublic void acceptModifier(char[] modifier, int start, int end) {\n\t\tString mod= new String(modifier);\n\t\tfModifiers.add(createCompletion(start, end, mod, null, mod));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptPackage\n\t */\t\n\tpublic void acceptPackage(char[] packageName, char[] completionName, int start, int end) {\n\t\tfPackages.add(createCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_PACKAGE, new String(packageName)));\n\t}\n\t\n\t/*\n\t * @see ICompletionRequestor#acceptType\n\t */\t\n\tpublic void acceptType(char[] packageName, char[] typeName, char[] completionName, int start, int end) {\n\t\tProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);\n\t\tfTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_CLASS, new String(typeName), new String(packageName), info));\n\t}\n\t\n\t/*\n\t * @see ICodeCompletionRequestor#acceptMethodDeclaration(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int)\n\t */\n\tpublic void acceptMethodDeclaration(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {\n\t\t// XXX: To be revised\n\t\tJavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end);\n\t\tfMethods.add(proposal);\n\t}\n\t\n\t/*\n\t * @see ICodeCompletionRequestor#acceptVariableName(char[], char[], char[], char[], int, int)\n\t */\n\tpublic void acceptVariableName(char[] typePackageName, char[] typeName, char[] name, char[] completionName, int start, int end) {\n\t\t// XXX: To be revised\n\t\tStringBuffer buf= new StringBuffer();\n\t\tbuf.append(name);\n\t\tif (typeName != null && typeName.length > 0) {\n\t\t\tbuf.append(\" - \"); //$NON-NLS-1$\n\t\t\tbuf.append(typeName);\n\t\t}\t\n\t\tfVariables.add(createCompletion(start, end, new String(completionName), null, buf.toString()));\n\t}\t\n\t\n\tpublic String getErrorMessage() {\n\t\tif (fLastProblem != null)\n\t\t\treturn fLastProblem.getAttribute(IMarker.MESSAGE, JavaTextMessages.getString(\"ResultCollector.compile_error.message\")); //$NON-NLS-1$\n\t\treturn \"\"; //$NON-NLS-1$\n\t}\n\n\tpublic ICompletionProposal[] getResults() {\n\t\tArrayList result= new ArrayList();\n\t\tProposalComparator comperator= new ProposalComparator();\n\t\tfor (int i= 0; i < fResults.length; i++) {\n\t\t\tArrayList bucket = fResults[i];\n\t\t\tint size= bucket.size();\n\t\t\tif (size == 1) {\n\t\t\t\tresult.add(bucket.get(0));\n\t\t\t} else if (size > 1) {\n\t\t\t\tObject[] sortedBucket = new Object[size];\n\t\t\t\tbucket.toArray(sortedBucket);\n\t\t\t\tArrays.sort(sortedBucket, comperator);\n\t\t\t\tfor (int j= 0; j < sortedBucket.length; j++)\n\t\t\t\t\tresult.add(sortedBucket[j]);\n\t\t\t}\n\t\t}\t\t\n\t\treturn (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]);\n\t}\n\n\tprotected JavaCompletionProposal createMethodCompletion(char[] declaringTypeName, char[] name, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {\n\t\tString iconName= JavaPluginImages.IMG_MISC_DEFAULT;\n\t\tif (Flags.isPublic(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PUBLIC;\n\t\t} else if (Flags.isProtected(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PROTECTED;\n\t\t} else if (Flags.isPrivate(modifiers)) {\n\t\t\ticonName= JavaPluginImages.IMG_MISC_PRIVATE;\n\t\t}\n\n\t\tStringBuffer nameBuffer= new StringBuffer();\n\t\tnameBuffer.append(name);\n\t\tnameBuffer.append('(');\n\t\tif (parameterTypeNames.length > 0) {\n\t\t\tnameBuffer.append(getParameterSignature(parameterTypeNames, parameterNames));\n\t\t}\n\t\tnameBuffer.append(')'); \n\t\tif (returnTypeName.length > 0) {\n\t\t\tnameBuffer.append(\" \"); //$NON-NLS-1$\n\t\t\tnameBuffer.append(returnTypeName);\n\t\t}\n\t\tif (declaringTypeName.length > 0) {\n\t\t\tnameBuffer.append(\" - \"); //$NON-NLS-1$\n\t\t\tnameBuffer.append(declaringTypeName);\n\t\t}\n\t\treturn createCompletion(start, end, new String(completionName), iconName, nameBuffer.toString());\n\t}\n\n\t\n\tprotected JavaCompletionProposal createTypeCompletion(int start, int end, String completion, String iconName, String typeName, String containerName, ProposalInfo proposalInfo) {\n\t\tIImportDeclaration importDeclaration= null;\n\t\tif (containerName != null && fCompilationUnit != null) {\n\t\t\tif (completion.equals(JavaModelUtil.concatenateName(containerName, typeName))) {\n\t\t\t\timportDeclaration= fCompilationUnit.getImport(completion);\n\t\t\t\tcompletion= typeName;\n\t\t\t}\n\t\t}\n\t\tStringBuffer buf= new StringBuffer(typeName);\n\t\tif (containerName != null) {\n\t\t\tbuf.append(\" - \"); //$NON-NLS-1$\n\t\t\tbuf.append(containerName);\n\t\t}\n\t\tString name= buf.toString();\n\t\t\n\t\tJavaCompletionProposal proposal= createCompletion(start, end, completion, iconName, name);\n\t\tproposal.setImportDeclaration(importDeclaration);\n\t\tproposal.setProposalInfo(proposalInfo);\n\t\treturn proposal;\n\t}\n\t\n\tprotected JavaCompletionProposal createCompletion(int start, int end, String completion, String iconName, String name) {\n\t\tint length;\n\t\tif (fUserReplacementLength == -1) {\n\t\t\tlength= end - start;\n\t\t} else {\n\t\t\tlength= fUserReplacementLength;\n\t\t}\n\t\tif (fUserReplacementOffset != -1) {\n\t\t\tstart= fUserReplacementOffset;\n\t\t}\n\t\t\n\t\tImage icon= null;\n\t\tif (iconName != null)\n\t\t\ticon= JavaPluginImages.get(iconName);\t\t\n\n\t\treturn new JavaCompletionProposal(completion, start, length, icon, name);\n\t}\n\t\t\n\t/**\n\t * Specifies the context of the code assist operation.\n\t * @param jproject The Java project to which the underlying source belongs.\n\t * Needed to find types referred.\n\t * @param cu The compilation unit that is edited. Used to add import statements.\n\t * Can be null if no import statements should be added.\n\t */\n\tpublic void reset(IJavaProject jproject, ICompilationUnit cu) {\n\t\tfJavaProject= jproject;\n\t\tfCompilationUnit= cu;\n\t\t\n\t\tfUserReplacementLength= -1;\n\t\tfUserReplacementOffset= -1;\n\t\t\n\t\tfLastProblem= null;\n\t\t\n\t\tfor (int i= 0; i < fResults.length; i++)\n\t\t\tfResults[i].clear();\n\t}\n\t\n\t/**\n\t * If the replacement length is set, it overrides the length returned from\n\t * the content assist infrastructure.\n\t * Use this setting if code assist is called with a none empty selection.\n\t */\n\tpublic void setReplacementLength(int length) {\n\t\tfUserReplacementLength= length;\n\t}\n\n\t/**\n\t * If the replacement offset is set, it overrides the offset used for the content assist.\n\t * Use this setting if the code assist proposals generated will be applied on a document different than\n\t * the one used for evaluating the code assist.\n\t */\n\tpublic void setReplacementOffset(int offset) {\n\t\tfUserReplacementOffset= offset;\n\t}\n\n}\n"}}},{"rowIdx":66,"cells":{"issue_id":{"kind":"number","value":5144,"string":"5,144"},"title":{"kind":"string","value":"Bug 5144 Error when opening display view"},"body":{"kind":"string","value":"205 1. Put a breakpoint in VectorTest.testCapacity (anywhere) 2. Debug to the breakpoint (IBM JRE) 3. Close the display view. 4. Open the display view again (perspective -> show view) java.lang.NullPointerException Stack trace: java/lang/Throwable.()V java/lang/Throwable.(Ljava/lang/String;)V java/lang/NullPointerException.(Ljava/lang/String;)V org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.update()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.updateEvalActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.initializeActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.createPartControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane$2.run()V org/eclipse/core/internal/runtime/InternalPlatform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/core/runtime/Platform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/ui/internal/PartPane.createChildControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/ViewPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartTabFolder.createPartTab (Lorg/eclipse/ui/internal/LayoutPart;Ljava/lang/String;I) Lorg/eclipse/swt/custom/CTabItem; org/eclipse/ui/internal/PartTabFolder.replaceChild (Lorg/eclipse/ui/internal/PartPlaceholder;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PartTabFolder.replace (Lorg/eclipse/ui/internal/LayoutPart;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PerspectivePresentation.addPart (Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/Perspective.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.busyShowView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.access$4 (Lorg/eclipse/ui/internal/WorkbenchPage;Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage$7.run()V org/eclipse/swt/custom/BusyIndicator.showWhile (Lorg/eclipse/swt/widgets/Display;Ljava/lang/Runnable;)V org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/ShowViewMenu.showOther()V org/eclipse/ui/internal/ShowViewMenu.access$0 (Lorg/eclipse/ui/internal/ShowViewMenu;)V org/eclipse/ui/internal/ShowViewMenu$1.run()V org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.access$0 (Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event ;)V org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/swt/widgets/Widget.notifyListeners (ILorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Display.runDeferredEvents()Z org/eclipse/swt/widgets/Display.readAndDispatch()Z org/eclipse/ui/internal/Workbench.runEventLoop()V org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object; org/eclipse/core/internal/boot/InternalBootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; org/eclipse/core/boot/BootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; SlimLauncher.main([Ljava/lang/String;)V"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"d4387e6"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-22T20:33:59Z","string":"2001-10-22T20:33:59Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-22T17:00:00Z","string":"2001-10-22T17:00:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui"},"file_content":{"kind":"string","value":""}}},{"rowIdx":67,"cells":{"issue_id":{"kind":"number","value":5144,"string":"5,144"},"title":{"kind":"string","value":"Bug 5144 Error when opening display view"},"body":{"kind":"string","value":"205 1. Put a breakpoint in VectorTest.testCapacity (anywhere) 2. Debug to the breakpoint (IBM JRE) 3. Close the display view. 4. Open the display view again (perspective -> show view) java.lang.NullPointerException Stack trace: java/lang/Throwable.()V java/lang/Throwable.(Ljava/lang/String;)V java/lang/NullPointerException.(Ljava/lang/String;)V org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.update()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.updateEvalActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.initializeActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.createPartControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane$2.run()V org/eclipse/core/internal/runtime/InternalPlatform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/core/runtime/Platform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/ui/internal/PartPane.createChildControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/ViewPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartTabFolder.createPartTab (Lorg/eclipse/ui/internal/LayoutPart;Ljava/lang/String;I) Lorg/eclipse/swt/custom/CTabItem; org/eclipse/ui/internal/PartTabFolder.replaceChild (Lorg/eclipse/ui/internal/PartPlaceholder;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PartTabFolder.replace (Lorg/eclipse/ui/internal/LayoutPart;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PerspectivePresentation.addPart (Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/Perspective.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.busyShowView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.access$4 (Lorg/eclipse/ui/internal/WorkbenchPage;Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage$7.run()V org/eclipse/swt/custom/BusyIndicator.showWhile (Lorg/eclipse/swt/widgets/Display;Ljava/lang/Runnable;)V org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/ShowViewMenu.showOther()V org/eclipse/ui/internal/ShowViewMenu.access$0 (Lorg/eclipse/ui/internal/ShowViewMenu;)V org/eclipse/ui/internal/ShowViewMenu$1.run()V org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.access$0 (Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event ;)V org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/swt/widgets/Widget.notifyListeners (ILorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Display.runDeferredEvents()Z org/eclipse/swt/widgets/Display.readAndDispatch()Z org/eclipse/ui/internal/Workbench.runEventLoop()V org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object; org/eclipse/core/internal/boot/InternalBootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; org/eclipse/core/boot/BootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; SlimLauncher.main([Ljava/lang/String;)V"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"d4387e6"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-22T20:33:59Z","string":"2001-10-22T20:33:59Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-22T17:00:00Z","string":"2001-10-22T17:00:00Z"},"updated_file":{"kind":"string","value":"debug/org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.java"},"file_content":{"kind":"string","value":""}}},{"rowIdx":68,"cells":{"issue_id":{"kind":"number","value":5116,"string":"5,116"},"title":{"kind":"string","value":"Bug 5116 Showing methods in the Type Hierarchy View is redundant"},"body":{"kind":"string","value":"It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"0fa38ed"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-23T11:00:10Z","string":"2001-10-23T11:00:10Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-19T16:46:40Z","string":"2001-10-19T16:46:40Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/ToggleOrientationAction.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.typehierarchy;\n\nimport org.eclipse.jface.action.Action;\n\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\n\n/**\n * Toggles horizontaol / vertical layout of the type hierarchy\n */\npublic class ToggleOrientationAction extends Action {\n\n\tprivate TypeHierarchyViewPart fView;\t\n\t\n\tpublic ToggleOrientationAction(TypeHierarchyViewPart v, boolean initHorizontal) {\n\t\tsuper(TypeHierarchyMessages.getString(\"ToggleOrientationAction.label\")); //$NON-NLS-1$\n\t\tsetDescription(TypeHierarchyMessages.getString(\"ToggleOrientationAction.description\")); //$NON-NLS-1$\n\t\tsetToolTipText(TypeHierarchyMessages.getString(\"ToggleOrientationAction.tooltip\")); //$NON-NLS-1$\n\t\t\n\t\tJavaPluginImages.setLocalImageDescriptors(this, \"impl_co.gif\"); //$NON-NLS-1$\n\n\t\tfView= v;\n\t\tsetChecked(initHorizontal);\n\t}\n\n\t/*\n\t * @see Action#actionPerformed\n\t */\t\t\n\tpublic void run() {\n\t\tfView.setOrientation(isChecked()); // will toggle the checked state\n\t}\n\n\t/*\n\t * @see Action#setChecked\n\t */\t\t\n\tpublic void setChecked(boolean checked) {\n\t\tif (checked) {\n\t\t\tsetToolTipText(TypeHierarchyMessages.getString(\"ToggleOrientationAction.tooltip.checked\")); //$NON-NLS-1$\n\t\t} else {\n\t\t\tsetToolTipText(TypeHierarchyMessages.getString(\"ToggleOrientationAction.tooltip.unchecked\")); //$NON-NLS-1$\n\t\t}\n\t\tsuper.setChecked(checked);\n\t}\t\n\t\n}"}}},{"rowIdx":69,"cells":{"issue_id":{"kind":"number","value":5116,"string":"5,116"},"title":{"kind":"string","value":"Bug 5116 Showing methods in the Type Hierarchy View is redundant"},"body":{"kind":"string","value":"It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"0fa38ed"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-23T11:00:10Z","string":"2001-10-23T11:00:10Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-19T16:46:40Z","string":"2001-10-19T16:46:40Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/ToggleViewAction.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.typehierarchy;\n\nimport org.eclipse.jface.action.Action;\n\nimport org.eclipse.ui.help.WorkbenchHelp;\n\n/**\n * Action to switch between the different hierarchy views.\n */\npublic class ToggleViewAction extends Action {\n\t\n\tprivate TypeHierarchyViewPart fViewPart;\n\tprivate int fViewerIndex;\n\t\t\n\tpublic ToggleViewAction(TypeHierarchyViewPart v, int viewerIndex, String title, String contextHelpId, boolean isChecked) {\n\t\tsuper(title);\n\t\tfViewPart= v;\n\t\tfViewerIndex= viewerIndex;\n\t\tsetChecked(isChecked);\n\t\t\n\t\tWorkbenchHelp.setHelp(this,\tnew Object[] { contextHelpId });\n\t}\n\t\t\t\t\n\tpublic int getViewerIndex() {\n\t\treturn fViewerIndex;\n\t}\n\n\t/*\n\t * @see Action#actionPerformed\n\t */\t\n\tpublic void run() {\n\t\tfViewPart.setView(fViewerIndex);\n\t}\t\t\n}"}}},{"rowIdx":70,"cells":{"issue_id":{"kind":"number","value":5116,"string":"5,116"},"title":{"kind":"string","value":"Bug 5116 Showing methods in the Type Hierarchy View is redundant"},"body":{"kind":"string","value":"It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"0fa38ed"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-23T11:00:10Z","string":"2001-10-23T11:00:10Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-19T16:46:40Z","string":"2001-10-19T16:46:40Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.typehierarchy;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.BusyIndicator;\nimport org.eclipse.swt.custom.CLabel;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.custom.ViewForm;\nimport org.eclipse.swt.dnd.DND;\nimport org.eclipse.swt.dnd.DragSource;\nimport org.eclipse.swt.dnd.Transfer;\nimport org.eclipse.swt.events.KeyAdapter;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.KeyListener;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.ScrollBar;\nimport org.eclipse.swt.widgets.ToolBar;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\n\nimport org.eclipse.jface.action.IMenuListener;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.IStatusLineManager;\nimport org.eclipse.jface.action.IToolBarManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.action.Separator;\nimport org.eclipse.jface.action.ToolBarManager;\nimport org.eclipse.jface.dialogs.IDialogSettings;\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.jface.viewers.IBasicPropertyConstants;\nimport org.eclipse.jface.viewers.IInputSelectionProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.ISelectionProvider;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport org.eclipse.ui.IActionBars;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IMemento;\nimport org.eclipse.ui.IPartListener;\nimport org.eclipse.ui.IViewSite;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.actions.OpenWithMenu;\nimport org.eclipse.ui.help.ViewContextComputer;\nimport org.eclipse.ui.help.WorkbenchHelp;\nimport org.eclipse.ui.part.PageBook;\nimport org.eclipse.ui.part.ViewPart;\n\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.ISourceReference;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.ui.IContextMenuConstants;\nimport org.eclipse.jdt.ui.ITypeHierarchyViewPart;\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jdt.internal.ui.actions.AddMethodStubAction;\nimport org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;\nimport org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction;\nimport org.eclipse.jdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;\nimport org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer;\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;\nimport org.eclipse.jdt.internal.ui.packageview.BuildGroup;\nimport org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage;\nimport org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup;\nimport org.eclipse.jdt.internal.ui.reorg.ReorgGroup;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\nimport org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;\nimport org.eclipse.jdt.internal.ui.util.SelectionUtil;\nimport org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;\nimport org.eclipse.jdt.internal.ui.viewsupport.MarkerErrorTickProvider;\nimport org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;\n\n/**\n * view showing the supertypes/subtypes of its input.\n */\npublic class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart {\n\t\n\tpublic static final int VIEW_ID_TYPE= 2;\n\tpublic static final int VIEW_ID_SUPER= 0;\n\tpublic static final int VIEW_ID_SUB= 1;\n\t\n\tprivate static final String DIALOGSTORE_HIERARCHYVIEW= \"TypeHierarchyViewPart.hierarchyview\";\t //$NON-NLS-1$\n\tprivate static final String DIALOGSTORE_VIEWORIENTATION= \"TypeHierarchyViewPart.orientation\";\t //$NON-NLS-1$\n\n\n\tprivate static final String TAG_INPUT= \"input\"; //$NON-NLS-1$\n\tprivate static final String TAG_VIEW= \"view\"; //$NON-NLS-1$\n\tprivate static final String TAG_ORIENTATION= \"orientation\"; //$NON-NLS-1$\n\tprivate static final String TAG_RATIO= \"ratio\"; //$NON-NLS-1$\n\tprivate static final String TAG_SELECTION= \"selection\"; //$NON-NLS-1$\n\tprivate static final String TAG_VERTICAL_SCROLL= \"vertical_scroll\"; //$NON-NLS-1$\n\n\tprivate IType fInput;\n\t\n\tprivate IMemento fMemento;\n\t\n\tprivate ArrayList fInputHistory;\n\tprivate int fCurrHistoryIndex;\n\t\n\tprivate IProblemChangedListener fHierarchyProblemListener;\n\t\n\tprivate TypeHierarchyLifeCycle fHierarchyLifeCycle;\n\tprivate ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;\n\t\t\n\tprivate MethodsViewer fMethodsViewer;\n\t\t\t\n\tprivate int fCurrentViewerIndex;\n\tprivate TypeHierarchyViewer[] fAllViewers;\n\t\n\tprivate boolean fIsEnableMemberFilter;\n\t\n\tprivate SashForm fTypeMethodsSplitter;\n\tprivate PageBook fViewerbook;\n\tprivate PageBook fPagebook;\n\tprivate Label fNoHierarchyShownLabel;\n\tprivate Label fEmptyTypesViewer;\n\t\n\tprivate ViewForm fTypeViewerViewForm;\n\tprivate CLabel fMethodViewerPaneLabel;\n\tprivate JavaElementLabelProvider fPaneLabelProvider;\n\t\n\tprivate IDialogSettings fDialogSettings;\n\t\n\tprivate ToggleViewAction[] fViewActions;\n\t\n\tprivate HistoryDropDownAction fHistoryDropDownAction;\n\t\n\tprivate ToggleOrientationAction fToggleOrientationAction;\n\t\n\tprivate EnableMemberFilterAction fEnableMemberFilterAction;\n\tprivate AddMethodStubAction fAddStubAction;\n\tprivate FocusOnTypeAction fFocusOnTypeAction;\n\tprivate FocusOnSelectionAction fFocusOnSelectionAction;\n\t\n\tprivate IPartListener fPartListener;\n\t\n\tpublic TypeHierarchyViewPart() {\n\t\t\n\t\tfHierarchyLifeCycle= new TypeHierarchyLifeCycle();\n\t\tfTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {\n\t\t\tpublic void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {\n\t\t\t\tdoTypeHierarchyChanged(typeHierarchy, changedTypes);\n\t\t\t}\n\t\t};\n\t\tfHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);\n\t\t\n\t\tfHierarchyProblemListener= null;\n\t\t\n\t\tfIsEnableMemberFilter= false;\n\t\t\n\t\tfInputHistory= new ArrayList();\n\t\tfCurrHistoryIndex= -1;\n\t\tfAllViewers= null;\n\t\t\n\t\tString title= TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.supertypes.label\"); //$NON-NLS-1$\n\t\tString contextHelpId= IJavaHelpContextIds.SHOW_SUPERTYPES;\n\t\tToggleViewAction superViewAction= new ToggleViewAction(this, VIEW_ID_SUPER, title, contextHelpId, true);\n\t\tsuperViewAction.setDescription(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.supertypes.description\")); //$NON-NLS-1$\n\t\tsuperViewAction.setToolTipText(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.supertypes.tooltip\")); //$NON-NLS-1$\n\t\tJavaPluginImages.setLocalImageDescriptors(superViewAction, \"super_co.gif\"); //$NON-NLS-1$\n\n\t\ttitle= TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.subtypes.label\"); //$NON-NLS-1$\n\t\tcontextHelpId= IJavaHelpContextIds.SHOW_SUPERTYPES;\n\t\tToggleViewAction subViewAction= new ToggleViewAction(this, VIEW_ID_SUB, title, contextHelpId, false);\n\t\tsubViewAction.setDescription(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.subtypes.description\")); //$NON-NLS-1$\n\t\tsubViewAction.setToolTipText(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.subtypes.tooltip\")); //$NON-NLS-1$\n\t\tJavaPluginImages.setLocalImageDescriptors(subViewAction, \"sub_co.gif\"); //$NON-NLS-1$\n\n\t\ttitle= TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.vajhierarchy.label\"); //$NON-NLS-1$\n\t\tToggleViewAction vajViewAction= new ToggleViewAction(this, VIEW_ID_TYPE, title, contextHelpId, false);\n\t\tvajViewAction.setDescription(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.vajhierarchy.description\")); //$NON-NLS-1$\n\t\tvajViewAction.setToolTipText(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.toggleaction.vajhierarchy.tooltip\")); //$NON-NLS-1$\n\t\tJavaPluginImages.setLocalImageDescriptors(vajViewAction, \"hierarchy_co.gif\"); //$NON-NLS-2$\n\t\t\n\t\tfViewActions= new ToggleViewAction[] { vajViewAction, superViewAction, subViewAction };\n\t\t\n\t\tfDialogSettings= JavaPlugin.getDefault().getDialogSettings();\n\t\t\n\t\tfHistoryDropDownAction= new HistoryDropDownAction(this);\n\t\t\n\t\tfToggleOrientationAction= new ToggleOrientationAction(this, fDialogSettings.getBoolean(DIALOGSTORE_VIEWORIENTATION));\n\t\t\n\t\tfEnableMemberFilterAction= new EnableMemberFilterAction(this, false);\n\t\t\n\t\tfFocusOnTypeAction= new FocusOnTypeAction(this);\n\t\t\n\t\tfPaneLabelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS);\n\t\tfPaneLabelProvider.setErrorTickManager(new MarkerErrorTickProvider());\n\t\t\n\t\tfAddStubAction= new AddMethodStubAction();\n\t\tfFocusOnSelectionAction= new FocusOnSelectionAction(this);\t\n\t\n\t\tfPartListener= new IPartListener() {\n\t\t\tpublic void partActivated(IWorkbenchPart part) {\n\t\t\t\tif (part instanceof IEditorPart)\n\t\t\t\t\teditorActivated((IEditorPart) part);\n\t\t\t}\n\t\t\tpublic void partBroughtToTop(IWorkbenchPart part) {}\n\t\t\tpublic void partClosed(IWorkbenchPart part) {}\n\t\t\tpublic void partDeactivated(IWorkbenchPart part) {}\n\t\t\tpublic void partOpened(IWorkbenchPart part) {}\n\t\t};\t\n\t}\t\n\t\t\n\t/**\n\t * Selects an member in the methods list\n\t */\t\n\tpublic void selectMember(IMember member) {\n\t\tfMethodsViewer.setSelection(new StructuredSelection(member), true);\n\t}\t\n\n\n\t/**\n\t * Gets the current input (IType)\n\t */\t\n\tpublic IType getInput() {\n\t\treturn fInput;\n\t}\t\n\t\n\tprivate void addHistoryEntry(IType entry) {\n\t\tfCurrHistoryIndex= fInputHistory.size();\n\t\tfInputHistory.add(entry);\n\t}\n\t\n\t/**\n\t * Gets the entry at the given index.\n\t * @param index The index of the entry\n\t * @return The entry from the index or null if no entry available\n\t */\n\tpublic IType getHistoryEntry(int index) {\n\t\twhile (index >= 0 && index < fInputHistory.size()) {\n\t\t\tIType type= (IType) fInputHistory.get(index);\n\t\t\tif (type.exists()) {\n\t\t\t\treturn type;\n\t\t\t} else {\n\t\t\t\tfInputHistory.remove(index);\n\t\t\t\tif (fCurrHistoryIndex >= index && fCurrHistoryIndex > 0) {\n\t\t\t\t\tfCurrHistoryIndex--;\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Goes to the next or previous entry from the history\n\t */\t\n\tpublic void gotoHistoryEntry(int index) {\n\t\tIType elem= getHistoryEntry(index);\n\t\tif (elem != null) {\n\t\t\tupdateInput(elem);\n\t\t\tfCurrHistoryIndex= index;\n\t\t}\n\t}\n\t\n\tpublic int getCurrentHistoryIndex() {\n\t\treturn fCurrHistoryIndex;\n\t}\n\t\n\t/**\n\t * Sets the input to a new type\n\t */\n\tpublic void setInput(IType type) {\n\t\tif (type != null) {\n\t\t\tICompilationUnit cu= type.getCompilationUnit();\n\t\t\tif (cu != null && cu.isWorkingCopy()) {\n\t\t\t\ttype= (IType)cu.getOriginal(type);\n\t\t\t}\n\t\t} \n\t\t\n\t\tif (type != null && !type.equals(fInput)) {\n\t\t\taddHistoryEntry(type);\n\t\t}\n\t\t\t\n\t\tupdateInput(type);\n\t}\t\t\n\t\t\t\n\t/**\n\t * Changes the input to a new type\n\t */\n\tpublic void updateInput(IType type) {\n\t\tboolean typeChanged= (type != fInput);\n\t\t\n\t\tfInput= type;\n\t\tif (fInput == null) {\t\n\t\t\tclearInput();\n\t\t} else {\n\t\t\t// turn off member filtering\n\t\t\tenableMemberFilter(false);\t\t\t\n\t\t\t\n\t\t\ttry {\n\t\t\t\tfHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInput);\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tJavaPlugin.log(e.getStatus());\n\t\t\t\tclearInput();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\t\n\t\t\tfPagebook.showPage(fTypeMethodsSplitter);\t\t\t\t\t\t\n\t\t\t\n\t\t\tif (typeChanged) {\n\t\t\t\tupdateHierarchyViewer();\n\t\t\t}\n\t\t\t\n\t\t\tgetCurrentViewer().setSelection(new StructuredSelection(fInput));\n\t\t\t\n\t\t\tupdateMethodViewer(fInput);\n\t\t\tupdateTitle();\n\t\t}\n\t}\n\t\n\tprivate void clearInput() {\n\t\tfInput= null;\n\t\tfHierarchyLifeCycle.freeHierarchy();\n\t\t\n\t\tupdateHierarchyViewer();\n\t}\n\n\t/*\n\t * @see IWorbenchPart#setFocus\n\t */\t\n\tpublic void setFocus() {\n\t\tfPagebook.setFocus();\n\t}\n\n\t/*\n\t * @see IWorkbenchPart#dispose\n\t */\t\n\tpublic void dispose() {\n\t\tfHierarchyLifeCycle.freeHierarchy();\n\t\tfHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);\n\t\tfPaneLabelProvider.dispose();\n\t\tgetSite().getPage().removePartListener(fPartListener);\n\n\t\tif (fHierarchyProblemListener != null) {\n\t\t\tJavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);\n\t\t}\n\t\tif (fMethodsViewer != null) {\n\t\t\tJavaPlugin.getDefault().getProblemMarkerManager().removeListener(fMethodsViewer);\n\t\t}\n\t\tsuper.dispose();\n\t}\n\t\t\n\tprivate Control createTypeViewerControl(Composite parent) {\n\t\tfViewerbook= new PageBook(parent, SWT.NULL);\n\t\t\n\t\tISelectionChangedListener selectionChangedListener= new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\ttypeSelectionChanged(event.getSelection());\n\t\t\t}\n\t\t};\n\t\t\n\t\tKeyListener keyListener= new KeyAdapter() {\n\t\t\tpublic void keyPressed(KeyEvent event) {\n\t\t\t\tif (event.stateMask == SWT.NONE) {\n\t\t\t\t\tif (event.keyCode == SWT.F4) {\n\t\t\t\t\t\tObject elem= SelectionUtil.getSingleElement(getCurrentViewer().getSelection());\n\t\t\t\t\t\tif (elem instanceof IType) {\n\t\t\t\t\t\t\tIType[] arr= new IType[] { (IType) elem };\n\t\t\t\t\t\t\tOpenTypeHierarchyUtil.open(arr, getSite().getWorkbenchWindow());\t\t\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgetCurrentViewer().getControl().getDisplay().beep();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else if (event.keyCode == SWT.F5) {\n\t\t\t\t\t\tupdateHierarchyViewer();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tviewPartKeyShortcuts(event);\t\t\t\t\t\n\t\t\t}\n\t\t};\n\t\t\t\t\n\t\t// Create the viewers\n\t\tTypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);\n\t\tinitializeTypesViewer(superTypesViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);\n\t\t\n\t\tTypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);\n\t\tinitializeTypesViewer(subTypesViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);\n\t\t\n\t\tTypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);\n\t\tinitializeTypesViewer(vajViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);\n\n\t\tfAllViewers= new TypeHierarchyViewer[3];\n\t\tfAllViewers[VIEW_ID_SUPER]= superTypesViewer;\n\t\tfAllViewers[VIEW_ID_SUB]= subTypesViewer;\n\t\tfAllViewers[VIEW_ID_TYPE]= vajViewer;\n\t\t\n\t\tint currViewerIndex;\n\t\ttry {\n\t\t\tcurrViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);\n\t\t\tif (currViewerIndex < 0 || currViewerIndex > 2) {\n\t\t\t\tcurrViewerIndex= VIEW_ID_TYPE;\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\tcurrViewerIndex= VIEW_ID_TYPE;\n\t\t}\n\t\t\t\n\t\tfEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);\n\t\t\n\t\tfor (int i= 0; i < fAllViewers.length; i++) {\n\t\t\tfAllViewers[i].setInput(fAllViewers[i]);\n\t\t}\n\t\t\n\t\t// force the update\n\t\tfCurrentViewerIndex= -1;\n\t\tsetView(currViewerIndex);\n\t\t\t\t\n\t\treturn fViewerbook;\n\t}\n\n\tprivate void initializeTypesViewer(final TypeHierarchyViewer typesViewer, ISelectionChangedListener selectionChangedListener, KeyListener keyListener, String cotextHelpId) {\n\t\ttypesViewer.getControl().setVisible(false);\n\t\ttypesViewer.getControl().addKeyListener(keyListener);\n\t\ttypesViewer.initContextMenu(new IMenuListener() {\n\t\t\tpublic void menuAboutToShow(IMenuManager menu) {\n\t\t\t\tfillTypesViewerContextMenu(typesViewer, menu);\n\t\t\t}\n\t\t}, cotextHelpId,\tgetSite());\n\t\ttypesViewer.addSelectionChangedListener(selectionChangedListener);\n\t}\n\t\n\tprivate Control createMethodViewerControl(Composite parent) {\n\t\tfMethodsViewer= new MethodsViewer(parent, this);\n\t\tfMethodsViewer.initContextMenu(new IMenuListener() {\n\t\t\tpublic void menuAboutToShow(IMenuManager menu) {\n\t\t\t\tfillMethodsViewerContextMenu(menu);\n\t\t\t}\n\t\t}, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());\n\t\tfMethodsViewer.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tmethodSelectionChanged(event.getSelection());\n\t\t\t}\n\t\t});\n\t\tControl control= fMethodsViewer.getTable();\n\t\tcontrol.addKeyListener(new KeyAdapter() { \n\t\t\tpublic void keyPressed(KeyEvent event) {\n\t\t\t\tviewPartKeyShortcuts(event);\n\t\t\t}\n\t\t});\n\t\t\n\t\tJavaPlugin.getDefault().getProblemMarkerManager().addListener(fMethodsViewer);\n\t\treturn control;\n\t}\n\t\n\tprivate void initDragAndDrop() {\n\t\tTransfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };\n\t\tint ops= DND.DROP_COPY;\n\n\t\tDragSource source= new DragSource(fMethodsViewer.getControl(), ops);\n\t\tsource.setTransfer(transfers);\n\t\tsource.addDragListener(new BasicSelectionTransferDragAdapter(fMethodsViewer));\n\t\t\n\t\tfor (int i= 0; i < fAllViewers.length; i++) {\n\t\t\tTypeHierarchyViewer curr= fAllViewers[i];\n\t\t\tcurr.addDropSupport(ops, transfers, new TypeHierarchyTransferDropAdapter(curr));\n\t\t}\t\n\t}\n\t\n\t\n\tprivate void viewPartKeyShortcuts(KeyEvent event) {\n\t\tif (event.stateMask == SWT.CTRL) {\n\t\t\tif (event.character == '1') {\n\t\t\t\tsetView(VIEW_ID_TYPE);\n\t\t\t} else if (event.character == '2') {\n\t\t\t\tsetView(VIEW_ID_SUPER);\n\t\t\t} else if (event.character == '3') {\n\t\t\t\tsetView(VIEW_ID_SUB);\n\t\t\t}\n\t\t}\t\n\t}\n\t\n\t\t\n\t/**\n\t * Returns the inner component in a workbench part.\n\t * @see IWorkbenchPart#createPartControl\n\t */\n\tpublic void createPartControl(Composite container) {\n\t\t\t\t\t\t\n\t\tfPagebook= new PageBook(container, SWT.NONE);\n\t\t\t\t\t\t\n\t\t// page 1 of pagebook (viewers)\n\n\t\tfTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);\n\t\tfTypeMethodsSplitter.setVisible(false);\n\n\t\tfTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);\n\t\t\n\t\tControl typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);\n\t\tfTypeViewerViewForm.setContent(typeViewerControl);\n\t\t\t\t\n\t\tViewForm methodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);\n\t\tfTypeMethodsSplitter.setWeights(new int[] {35, 65});\n\t\t\n\t\tControl methodViewerPart= createMethodViewerControl(methodViewerViewForm);\n\t\tmethodViewerViewForm.setContent(methodViewerPart);\n\t\t\n\t\tfMethodViewerPaneLabel= new CLabel(methodViewerViewForm, SWT.NONE);\n\t\tmethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);\n\t\t\n\t\tinitDragAndDrop();\t\t\n\t\t\n\t\tToolBar methodViewerToolBar= new ToolBar(methodViewerViewForm, SWT.FLAT | SWT.WRAP);\n\t\tmethodViewerViewForm.setTopCenter(methodViewerToolBar);\n\t\t\n\t\t// page 2 of pagebook (no hierarchy label)\n\t\tfNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);\n\t\tfNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.empty\")); //$NON-NLS-1$\t\n\t\t\n\t\tMenuManager menu= new MenuManager();\n\t\tmenu.add(fFocusOnTypeAction);\n\t\tfNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));\n\t\t\n\t\tfPagebook.showPage(fNoHierarchyShownLabel);\n\t\t\n\t\t// will fill the main tool bar\n\t\tsetOrientation(fToggleOrientationAction.isChecked());\n\t\t\n\t\t// set the filter menu items\n\t\tIActionBars actionBars= getViewSite().getActionBars();\n\t\tIMenuManager viewMenu= actionBars.getMenuManager();\n\t\tviewMenu.add(fToggleOrientationAction);\t\n\t\n\t\t// fill the method viewer toolbar\n\t\tToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);\n\t\tlowertbmanager.add(fEnableMemberFilterAction);\t\t\t\n\t\tlowertbmanager.add(new Separator());\n\t\tfMethodsViewer.contributeToToolBar(lowertbmanager);\n\t\tlowertbmanager.update(true);\n\t\t\t\t\t\t\t\n\t\t// selection provider\n\t\tint nHierarchyViewers= fAllViewers.length; \n\t\tViewer[] trackedViewers= new Viewer[nHierarchyViewers + 1];\n\t\tfor (int i= 0; i < nHierarchyViewers; i++) {\n\t\t\ttrackedViewers[i]= fAllViewers[i];\n\t\t}\n\t\ttrackedViewers[nHierarchyViewers]= fMethodsViewer;\n\t\tISelectionProvider selProvider= new SelectionProviderMediator(trackedViewers);\n\t\tIStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();\n\t\tselProvider.addSelectionChangedListener(new StatusBarUpdater(slManager));\n\t\t\n\t\tgetSite().setSelectionProvider(selProvider);\n\t\tgetSite().getPage().addPartListener(fPartListener);\n\t\t\t\t\n\t\tIType input= determineInputElement();\n\t\tif (fMemento != null) {\n\t\t\trestoreState(fMemento, input);\n\t\t} else if (input != null) {\n\t\t\tsetInput(input);\n\t\t} else {\n\t\t\tsetViewerVisibility(false);\n\t\t}\n\t\t\n\t\t// fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing\n\t\tWorkbenchHelp.setHelp(fPagebook, new ViewContextComputer(this, IJavaHelpContextIds.TYPE_HIERARCHY_VIEW));\n\t}\n\n\n\t/**\n\t * called from ToggleOrientationAction\n\t */\t\n\tpublic void setOrientation(boolean horizontal) {\n\t\tif (fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {\n\t\t\tfTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);\n\t\t\tupdateMainToolbar(horizontal);\n\t\t}\n\t\tfToggleOrientationAction.setChecked(horizontal);\n\t\tfDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, horizontal);\n\t}\n\t\t\n\tprivate void updateMainToolbar(boolean horizontal) {\n\t\tIActionBars actionBars= getViewSite().getActionBars();\n\t\tIToolBarManager tbmanager= actionBars.getToolBarManager();\t\n\t\t\t\t\n\t\tif (horizontal) {\n\t\t\tclearMainToolBar(tbmanager);\n\t\t\tToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);\n\t\t\tfillMainToolBar(new ToolBarManager(typeViewerToolBar));\n\t\t\tfTypeViewerViewForm.setTopLeft(typeViewerToolBar);\n\t\t} else {\n\t\t\tfTypeViewerViewForm.setTopLeft(null);\n\t\t\tfillMainToolBar(tbmanager);\n\t\t}\n\t}\n\t\n\tprivate void fillMainToolBar(IToolBarManager tbmanager) {\n\t\ttbmanager.removeAll();\n\t\ttbmanager.add(fHistoryDropDownAction);\n\t\tfor (int i= 0; i < fViewActions.length; i++) {\n\t\t\ttbmanager.add(fViewActions[i]);\n\t\t}\n\t\ttbmanager.update(false);\t\n\t}\n\n\tprivate void clearMainToolBar(IToolBarManager tbmanager) {\n\t\ttbmanager.removeAll();\n\t\ttbmanager.update(false);\t\t\n\t}\t\n\t\n\t\n\t/**\n\t * Creates the context menu for the hierarchy viewers\n\t */\n\tprivate void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {\n\t\tJavaPlugin.createStandardGroups(menu);\n\t\t// viewer entries\n\t\tviewer.contributeToContextMenu(menu);\n\t\tIStructuredSelection selection= (IStructuredSelection)viewer.getSelection();\n\t\tif (JavaBasePreferencePage.openTypeHierarchyInPerspective()) {\n\t\t\taddOpenPerspectiveItem(menu, selection);\n\t\t}\n\t\taddOpenWithMenu(menu, selection);\n\t\t\n\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnTypeAction);\n\t\tif (fFocusOnSelectionAction.canActionBeAdded())\n\t\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnSelectionAction);\n\t\t\t\n\t\taddRefactoring(menu, viewer);\n\t\tContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, viewer);\n\t}\n\n\t/**\n\t * Creates the context menu for the method viewer\n\t */\t\n\tprivate void fillMethodsViewerContextMenu(IMenuManager menu) {\n\t\tJavaPlugin.createStandardGroups(menu);\n\t\t// viewer entries\n\t\tfMethodsViewer.contributeToContextMenu(menu);\n\t\tif (fAddStubAction.init(fInput, fMethodsViewer.getSelection())) {\n\t\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddStubAction);\n\t\t}\n\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fMethodsViewer));\t\n\t\taddOpenWithMenu(menu, (IStructuredSelection)fMethodsViewer.getSelection());\n\t\taddRefactoring(menu, fMethodsViewer);\n\t\tContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, fMethodsViewer);\n\t}\n\t\n\tprivate void addRefactoring(IMenuManager menu, IInputSelectionProvider viewer){\n\t\tMenuManager refactoring= new MenuManager(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.menu.refactor\")); //$NON-NLS-1$\n\t\tContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, viewer);\n\t\tif (!refactoring.isEmpty())\n\t\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring);\n\t}\n\t\n\tprivate void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {\n\t\t// If one file is selected get it.\n\t\t// Otherwise, do not show the \"open with\" menu.\n\t\tif (selection.size() != 1)\n\t\t\treturn;\n\n\t\tObject element= selection.getFirstElement();\n\t\tif (!(element instanceof IJavaElement))\n\t\t\treturn;\n\t\tIResource resource= null;\n\t\ttry {\n\t\t\tresource= ((IJavaElement)element).getUnderlyingResource();\t\n\t\t} catch(JavaModelException e) {\n\t\t\t// ignore\n\t\t}\n\t\tif (!(resource instanceof IFile))\n\t\t\treturn; \n\n\t\t// Create a menu flyout.\n\t\tMenuManager submenu= new MenuManager(TypeHierarchyMessages.getString(\"TypeHierarchyViewPart.menu.open\")); //$NON-NLS-1$\n\t\tsubmenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));\n\n\t\t// Add the submenu.\n\t\tmenu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);\n\t}\n\n\tprivate void addOpenPerspectiveItem(IMenuManager menu, IStructuredSelection selection) {\n\t\tOpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, selection);\n\t}\n\n\t/**\n\t * Toggles between the empty viewer page and the hierarchy\n\t */\n\tprivate void setViewerVisibility(boolean showHierarchy) {\n\t\tif (showHierarchy) {\n\t\t\tfViewerbook.showPage(getCurrentViewer().getControl());\n\t\t} else {\n\t\t\tfViewerbook.showPage(fEmptyTypesViewer);\n\t\t}\n\t}\n\t\n\t/**\n\t * Sets the member filter. null disables member filtering.\n\t */\t\n\tprivate void setMemberFilter(IMember[] memberFilter) {\n\t\tAssert.isNotNull(fAllViewers);\n\t\tfor (int i= 0; i < fAllViewers.length; i++) {\n\t\t\tfAllViewers[i].setMemberFilter(memberFilter);\n\t\t}\n\t\tupdateHierarchyViewer();\n\t\tupdateTitle();\n\t}\t\t\n\t\n\t/**\n\t * When the input changed or the hierarchy pane becomes visible,\n\t * updateHierarchyViewer brings up the correct view and refreshes\n\t * the current tree\n\t */\n\tprivate void updateHierarchyViewer() {\n\t\tif (fInput == null) {\n\t\t\tfPagebook.showPage(fNoHierarchyShownLabel);\n\t\t} else {\n\t\t\tif (getCurrentViewer().containsElements()) {\n\t\t\t\tRunnable runnable= new Runnable() {\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tgetCurrentViewer().updateContent();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tBusyIndicator.showWhile(getDisplay(), runnable);\n\t\t\t\tif (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {\n\t\t\t\t\tsetViewerVisibility(true);\n\t\t\t\t}\t\n\t\t\t} else {\t\t\t\t\t\t\t\n\t\t\t\tfEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString(\"TypeHierarchyViewPart.nodecl\", fInput.getElementName()));\t\t\t\t //$NON-NLS-1$\n\t\t\t\tsetViewerVisibility(false);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void updateMethodViewer(IType input) {\n\t\tif (input != fMethodsViewer.getInput()) {\n\t\t\tif (input != null) {\n\t\t\t\tfMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));\n\t\t\t\tfMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));\n\t\t\t} else {\n\t\t\t\tfMethodViewerPaneLabel.setText(\"\"); //$NON-NLS-1$\n\t\t\t\tfMethodViewerPaneLabel.setImage(null);\n\t\t\t}\n\t\t\tfMethodsViewer.setInput(input);\n\t\t}\n\t}\t\n\t\n\tprivate void methodSelectionChanged(ISelection sel) {\n\t\tif (sel instanceof IStructuredSelection) {\n\t\t\tList selected= ((IStructuredSelection)sel).toList();\n\t\t\tint nSelected= selected.size();\n\t\t\tif (fIsEnableMemberFilter) {\n\t\t\t\tIMember[] memberFilter= null;\n\t\t\t\tif (nSelected > 0) {\n\t\t\t\t\tmemberFilter= new IMember[nSelected];\n\t\t\t\t\tselected.toArray(memberFilter);\n\t\t\t\t}\n\t\t\t\tsetMemberFilter(memberFilter);\n\t\t\t}\n\t\t\tif (nSelected == 1) {\n\t\t\t\trevealElementInEditor(selected.get(0));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void typeSelectionChanged(ISelection sel) {\n\t\tif (sel instanceof IStructuredSelection) {\n\t\t\tList selected= ((IStructuredSelection)sel).toList();\n\t\t\tint nSelected= selected.size();\n\t\t\tif (nSelected != 0) {\n\t\t\t\tList types= new ArrayList(nSelected);\n\t\t\t\tfor (int i= nSelected-1; i >= 0; i--) {\n\t\t\t\t\tObject elem= selected.get(i);\n\t\t\t\t\tif (elem instanceof IType && !types.contains(elem)) {\n\t\t\t\t\t\ttypes.add(elem);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (types.size() == 1) {\n\t\t\t\t\tIType selectedType= (IType)types.get(0);\n\t\t\t\t\tif (!fIsEnableMemberFilter && !selectedType.equals(fMethodsViewer.getInput())) {\n\t\t\t\t\t\tupdateMethodViewer(selectedType);\n\t\t\t\t\t}\n\t\t\t\t} else if (types.size() == 0) {\n\t\t\t\t\t// method selected, no change\n\t\t\t\t}\n\t\t\t\tif (nSelected == 1) {\n\t\t\t\t\trevealElementInEditor(selected.get(0));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!fIsEnableMemberFilter && fMethodsViewer.getInput() != null) {\n\t\t\t\t\tupdateMethodViewer(null);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void revealElementInEditor(Object elem) {\n\t\t// only allow revealing when the type hierarchy is the active pagae\n\t\t// no revealing after selection events due to model changes\n\t\tif (getSite().getPage().getActivePart() != this) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tIEditorPart editorPart= EditorUtility.isOpenInEditor(elem);\n\t\tif (editorPart != null && (elem instanceof ISourceReference)) {\n\t\t\ttry {\n\t\t\t\tEditorUtility.openInEditor(elem, false);\n\t\t\t\tEditorUtility.revealInEditor(editorPart, (ISourceReference)elem);\n\t\t\t} catch (CoreException e) {\n\t\t\t\tJavaPlugin.log(e);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate Display getDisplay() {\n\t\tif (fPagebook != null && !fPagebook.isDisposed()) {\n\t\t\treturn fPagebook.getDisplay();\n\t\t}\n\t\treturn null;\n\t}\t\t\n\t\n\tprivate boolean isChildVisible(Composite pb, Control child) {\n\t\tControl[] children= pb.getChildren();\n\t\tfor (int i= 0; i < children.length; i++) {\n\t\t\tif (children[i] == child && children[i].isVisible())\n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate void updateTitle() {\n\t\tString title= getCurrentViewer().getTitle();\n\t\tsetTitle(getCurrentViewer().getTitle());\n\t\tString tooltip;\n\t\tif (fInput != null) {\n\t\t\tString[] args= new String[] { title, JavaModelUtil.getFullyQualifiedName(fInput) };\n\t\t\ttooltip= TypeHierarchyMessages.getFormattedString(\"TypeHierarchyViewPart.tooltip\", args); //$NON-NLS-1$\n\t\t} else {\n\t\t\ttooltip= title;\n\t\t}\n\t\tsetTitleToolTip(tooltip);\n\t}\n\t\t\n\t/**\n\t * Sets the current view (see view id)\n\t * called from ToggleViewAction. Must be called after creation of the viewpart.\n\t */\t\n\tpublic void setView(int viewerIndex) {\n\t\tAssert.isNotNull(fAllViewers);\n\t\tif (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {\t\t\t\n\t\t\tfCurrentViewerIndex= viewerIndex;\n\t\t\t\n\t\t\tupdateHierarchyViewer();\n\t\t\tif (fInput != null) {\n\t\t\t\tISelection currSelection= getCurrentViewer().getSelection();\n\t\t\t\tif (currSelection == null || currSelection.isEmpty()) {\n\t\t\t\t\tgetCurrentViewer().setSelection(new StructuredSelection(getInput()));\n\t\t\t\t}\n\t\t\t\tif (!fIsEnableMemberFilter) {\n\t\t\t\t\ttypeSelectionChanged(getCurrentViewer().getSelection());\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t\tupdateTitle();\n\t\t\t\n\t\t\tif (fHierarchyProblemListener != null) {\n\t\t\t\tJavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);\n\t\t\t}\n\t\t\tfHierarchyProblemListener= getCurrentViewer();\n\t\t\tJavaPlugin.getDefault().getProblemMarkerManager().addListener(fHierarchyProblemListener);\n\t\t\t\n\t\t\t\n\t\t\tfDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);\n\t\t\tgetCurrentViewer().getTree().setFocus();\n\t\t}\n\t\tfor (int i= 0; i < fViewActions.length; i++) {\n\t\t\tToggleViewAction action= fViewActions[i];\n\t\t\taction.setChecked(fCurrentViewerIndex == action.getViewerIndex());\n\t\t}\n\t}\n\n\t/**\n\t * Gets the curret active view index.\n\t */\t\t\n\tpublic int getViewIndex() {\n\t\treturn fCurrentViewerIndex;\n\t}\n\t\n\tprivate TypeHierarchyViewer getCurrentViewer() {\n\t\treturn fAllViewers[fCurrentViewerIndex];\n\t}\n\n\t/**\n\t * called from EnableMemberFilterAction.\n\t * Must be called after creation of the viewpart.\n\t */\t\n\tpublic void enableMemberFilter(boolean on) {\n\t\tif (on != fIsEnableMemberFilter) {\n\t\t\tfIsEnableMemberFilter= on;\n\t\t\tif (!on) {\n\t\t\t\tObject methodViewerInput= fMethodsViewer.getInput();\n\t\t\t\tIType input= getInput();\n\t\t\t\tsetMemberFilter(null);\n\t\t\t\tif (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {\n\t\t\t\t\t// avoid that the method view changes content by selecting the previous input\n\t\t\t\t\tgetCurrentViewer().setSelection(new StructuredSelection(methodViewerInput));\n\t\t\t\t} else if (input != null) {\n\t\t\t\t\t// choose a input that exists\n\t\t\t\t\tgetCurrentViewer().setSelection(new StructuredSelection(input));\n\t\t\t\t\tupdateMethodViewer(input);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmethodSelectionChanged(fMethodsViewer.getSelection());\n\t\t\t}\n\t\t}\n\t\tfEnableMemberFilterAction.setChecked(on);\n\t}\n\t\n\t/**\n\t * Called from ITypeHierarchyLifeCycleListener.\n\t * Can be called from any thread\n\t */\n\tprivate void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final IType[] changedTypes) {\n\t\tDisplay display= getDisplay();\n\t\tif (display != null) {\n\t\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tdoTypeHierarchyChangedOnViewers(changedTypes);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\t\n\tprivate void doTypeHierarchyChangedOnViewers(IType[] changedTypes) {\n\t\tif (changedTypes == null) {\n\t\t\t// hierarchy change\n\t\t\tif (!fHierarchyLifeCycle.getHierarchy().exists()) {\n\t\t\t\tclearInput();\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tfHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInput);\n\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\tJavaPlugin.log(e.getStatus());\n\t\t\t\t\tclearInput();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateHierarchyViewer();\n\t\t\t}\n\t\t} else {\n\t\t\t// elements in hierarchy modified\n\t\t\tif (getCurrentViewer().isMethodFiltering()) {\n\t\t\t\tif (changedTypes.length == 1) {\n\t\t\t\t\tgetCurrentViewer().refresh(changedTypes[0]);\n\t\t\t\t} else {\n\t\t\t\t\tupdateHierarchyViewer();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgetCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );\n\t\t\t}\n\t\t}\t\n\t}\t\n\t\n\n\t\n\t/**\n\t * Determines the input element to be used initially .\n\t */\t\n\tprivate IType determineInputElement() {\n\t\tObject input= getSite().getPage().getInput();\n\t\tif (input instanceof IType) { \n\t\t\treturn (IType)input;\n\t\t} \n\t\treturn null;\t\n\t}\n\t\n\t/*\n\t * @see IViewPart#init\n\t */\n\tpublic void init(IViewSite site, IMemento memento) throws PartInitException {\n\t\tsuper.init(site, memento);\n\t\tfMemento= memento;\n\t}\t\n\t\n\t/*\n\t * @see ViewPart#saveState(IMemento)\n\t */\n\tpublic void saveState(IMemento memento) {\n\t\tif (fPagebook == null) {\n\t\t\t// part has not been created\n\t\t\tif (fMemento != null) { //Keep the old state;\n\t\t\t\tmemento.putMemento(fMemento);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (fInput != null) {\n\t\t\tmemento.putString(TAG_INPUT, fInput.getHandleIdentifier());\n\t\t}\n\t\tmemento.putInteger(TAG_VIEW, getViewIndex());\n\t\tmemento.putInteger(TAG_ORIENTATION, fToggleOrientationAction.isChecked() ? 1 : 0);\t\n\t\tint weigths[]= fTypeMethodsSplitter.getWeights();\n\t\tint ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);\n\t\tmemento.putInteger(TAG_RATIO, ratio);\n\t\t\n\t\tScrollBar bar= getCurrentViewer().getTree().getVerticalBar();\n\t\tint position= bar != null ? bar.getSelection() : 0;\n\t\tmemento.putInteger(TAG_VERTICAL_SCROLL, position);\n\n\t\tIJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();\n\t\tif (selection != null) {\n\t\t\tmemento.putString(TAG_SELECTION, selection.getHandleIdentifier());\n\t\t}\n\t\t\t\n\t\tfMethodsViewer.saveState(memento);\n\t}\n\t\n\t/**\n\t * Restores the type hierarchy settings from a memento.\n\t */\n\tprivate void restoreState(IMemento memento, IType defaultInput) {\n\t\tIType input= defaultInput;\n\t\tString elementId= memento.getString(TAG_INPUT);\n\t\tif (elementId != null) {\n\t\t\tinput= (IType) JavaCore.create(elementId);\n\t\t\tif (!input.exists()) {\n\t\t\t\tinput= null;\n\t\t\t}\n\t\t}\n\t\tsetInput(input);\n\n\t\tInteger viewerIndex= memento.getInteger(TAG_VIEW);\n\t\tif (viewerIndex != null) {\n\t\t\tsetView(viewerIndex.intValue());\n\t\t}\n\t\tInteger orientation= memento.getInteger(TAG_ORIENTATION);\n\t\tif (orientation != null) {\n\t\t\tsetOrientation(orientation.intValue() == 1);\n\t\t}\n\t\tInteger ratio= memento.getInteger(TAG_RATIO);\n\t\tif (ratio != null) {\n\t\t\tfTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });\n\t\t}\n\t\tScrollBar bar= getCurrentViewer().getTree().getVerticalBar();\n\t\tif (bar != null) {\n\t\t\tInteger vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);\n\t\t\tif (vScroll != null) {\n\t\t\t\tbar.setSelection(vScroll.intValue());\n\t\t\t}\n\t\t}\n\t\t\n\t\tString selectionId= memento.getString(TAG_SELECTION);\n\t\tif (selectionId != null) {\n\t\t\tIJavaElement elem= JavaCore.create(selectionId);\n\t\t\tif (getCurrentViewer().isElementShown(elem)) {\n\t\t\t\tgetCurrentViewer().setSelection(new StructuredSelection(elem));\n\t\t\t}\n\t\t}\n\t\tfMethodsViewer.restoreState(memento);\n\t}\n\t\n\t/**\n\t * Link selection to active editor.\n\t */\n\tprivate void editorActivated(IEditorPart editor) {\n\t\tif (!JavaBasePreferencePage.linkTypeHierarchySelectionToEditor()) {\n\t\t\treturn;\n\t\t}\n\t\tif (fInput == null) {\n\t\t\t// no type hierarchy shown\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tIJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class);\n\t\ttry {\n\t\t\tTypeHierarchyViewer currentViewer= getCurrentViewer();\n\t\t\tif (elem instanceof IClassFile) {\n\t\t\t\tIType type= ((IClassFile)elem).getType();\n\t\t\t\tif (currentViewer.isElementShown(type)) {\n\t\t\t\t\tcurrentViewer.setSelection(new StructuredSelection(type));\n\t\t\t\t}\n\t\t\t} else if (elem instanceof ICompilationUnit) {\n\t\t\t\tIType[] allTypes= ((ICompilationUnit)elem).getAllTypes();\n\t\t\t\tfor (int i= 0; i < allTypes.length; i++) {\n\t\t\t\t\tif (currentViewer.isElementShown(allTypes[i])) {\n\t\t\t\t\t\tcurrentViewer.setSelection(new StructuredSelection(allTypes[i]));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\n\t\t} catch (JavaModelException e) {\n\t\t\tJavaPlugin.log(e.getStatus());\n\t\t}\n\t\t\n\t}\t\n\t\n\n}"}}},{"rowIdx":71,"cells":{"issue_id":{"kind":"number","value":5048,"string":"5,048"},"title":{"kind":"string","value":"Bug 5048 Too many declarations in hierarchy of (jdt)Parser.initialize()"},"body":{"kind":"string","value":"Build 204 In a self-hosting workspace, open type Parser (from JDT), and select its initialize() method in outliner. Request to search declarations in hierarchy, it incorrectly finds over 100 matches, as if it was not taking into account the accurate location of the Parser."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"f57e9cf"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-24T08:40:31Z","string":"2001-10-24T08:40:31Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-17T17:33:20Z","string":"2001-10-17T17:33:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindDeclarationsAction.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IImportDeclaration;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IPackageDeclaration;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.IJavaSearchConstants;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\n\npublic class FindDeclarationsAction extends ElementSearchAction {\n\n\tpublic FindDeclarationsAction() {\n\t\tthis(SearchMessages.getString(\"Search.FindDeclarationAction.label\"), new Class[] {IField.class, IMethod.class, IType.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class}); //$NON-NLS-1$\n\t\tsetToolTipText(SearchMessages.getString(\"Search.FindDeclarationAction.tooltip\")); //$NON-NLS-1$\n\t}\n\n\tpublic FindDeclarationsAction(String label, Class[] validTypes) {\n\t\tsuper(label, validTypes);\n\t\tsetImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);\n\t}\n\n\tprotected JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException {\n\t\tif (element.getElementType() == IJavaElement.TYPE) {\n\t\t\tIType type= (IType)element;\n\t\t\tint searchFor= IJavaSearchConstants.TYPE;\n\t\t\tString pattern= PrettySignature.getUnqualifiedTypeSignature(type);\n\t\t\treturn new JavaSearchOperation(JavaPlugin.getWorkspace(), pattern,\n\t\t\t\tsearchFor, getLimitTo(), getScope(type), getScopeDescription(type), getCollector());\n\t\t}\n\t\telse if (element.getElementType() == IJavaElement.METHOD) {\n\t\t\tIMethod method= (IMethod)element;\n\t\t\tint searchFor= IJavaSearchConstants.METHOD;\n\t\t\tif (method.isConstructor())\n\t\t\t\tsearchFor= IJavaSearchConstants.CONSTRUCTOR;\n\t\t\tIType type= method.getDeclaringType();\n\t\t\tString pattern= PrettySignature.getUnqualifiedMethodSignature(method);\n\t\t\treturn new JavaSearchOperation(JavaPlugin.getWorkspace(), pattern,\n\t\t\t\tsearchFor, getLimitTo(), getScope(type), getScopeDescription(type), getCollector());\n\t\t}\n\t\telse\n\t\t\treturn super.makeOperation(element);\n\t}\n\n\tprotected int getLimitTo() {\n\t\treturn IJavaSearchConstants.DECLARATIONS;\n\t}\n\n\tprotected boolean shouldUserBePrompted() {\n\t\treturn false;\n\t}\n\t\n\tprotected String getScopeDescription(IType type) {\n\t\treturn super.getScopeDescription(type);\n\t}\n}"}}},{"rowIdx":72,"cells":{"issue_id":{"kind":"number","value":5048,"string":"5,048"},"title":{"kind":"string","value":"Bug 5048 Too many declarations in hierarchy of (jdt)Parser.initialize()"},"body":{"kind":"string","value":"Build 204 In a self-hosting workspace, open type Parser (from JDT), and select its initialize() method in outliner. Request to search declarations in hierarchy, it incorrectly finds over 100 matches, as if it was not taking into account the accurate location of the Parser."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"f57e9cf"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-24T08:40:31Z","string":"2001-10-24T08:40:31Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-17T17:33:20Z","string":"2001-10-17T17:33:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindHierarchyDeclarationsAction.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\npublic class FindHierarchyDeclarationsAction extends FindDeclarationsAction {\n\n\tpublic FindHierarchyDeclarationsAction() {\n\t\tsuper(SearchMessages.getString(\"Search.FindHierarchyDeclarationsAction.label\"), new Class[] {IField.class, IMethod.class, IType.class} ); //$NON-NLS-1$\n\t\tsetToolTipText(SearchMessages.getString(\"Search.FindHierarchyDeclarationsAction.tooltip\")); //$NON-NLS-1$\n\t}\n\t\n\tprotected IJavaSearchScope getScope(IType type) throws JavaModelException {\n\t\tICompilationUnit cu= type.getCompilationUnit();\n\t\t\tif (cu != null && cu.isWorkingCopy()) {\n\t\t\t\ttype= (IType)cu.getOriginal(type);\n\t\t\t}\n\t\treturn SearchEngine.createHierarchyScope(type);\n\t}\n\t\n\tprotected boolean shouldUserBePrompted() {\n\t\treturn true;\n\t}\n\n\tprotected String getScopeDescription(IType type) {\n\t\treturn SearchMessages.getFormattedString(\"HierarchyScope\", new String[] {type.getElementName()}); //$NON-NLS-1$\n\t}\n}"}}},{"rowIdx":73,"cells":{"issue_id":{"kind":"number","value":4329,"string":"4,329"},"title":{"kind":"string","value":"Bug 4329 No results If searched via Package view selection and dialog (1GLDN1X)"},"body":{"kind":"string","value":"The package view initializes the Search dialog with the fully qualified name. This is not found when searching for declarations. Search via context menu in packages view works. ==> (Java) Search should first try to get the Java element and if that fails, display the the element name and not the fully qualified name. NOTES:"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"b975be2"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-24T17:13:09Z","string":"2001-10-24T17:13:09Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.StringReader;\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Combo;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.jface.dialogs.DialogPage;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IAdaptable;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.help.WorkbenchHelp;\nimport org.eclipse.ui.model.IWorkbenchAdapter;\n\nimport org.eclipse.search.internal.ui.SearchManager;\nimport org.eclipse.search.ui.ISearchPage;\nimport org.eclipse.search.ui.ISearchPageContainer;\nimport org.eclipse.search.ui.ISearchResultViewEntry;\n\nimport org.eclipse.search.ui.IWorkingSet;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICodeAssist;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IImportDeclaration;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.IJavaSearchConstants;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;\nimport org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\nimport org.eclipse.jdt.internal.ui.util.RowLayouter;\n\npublic class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants {\n\n\tpublic static final String EXTENSION_POINT_ID= \"org.eclipse.jdt.ui.JavaSearchPage\"; //$NON-NLS-1$\n\n\tprivate static List fgPreviousSearchPatterns= new ArrayList(20);\n\n\tprivate Combo fPattern;\n\tprivate String fInitialPattern;\n\tprivate boolean fFirstTime= true;\n\tprivate ISearchPageContainer fContainer;\n\t\n\tprivate Button[] fSearchFor;\n\tprivate String[] fSearchForText= {\n\t\tSearchMessages.getString(\"SearchPage.searchFor.type\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.method\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.package\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.constructor\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.field\") }; //$NON-NLS-1$\n\n\tprivate Button[] fLimitTo;\n\tprivate String[] fLimitToText= {\n\t\tSearchMessages.getString(\"SearchPage.limitTo.declarations\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.implementors\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.references\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.allOccurrences\")}; //$NON-NLS-1$\n\t\n\tprivate IJavaElement fJavaElement;\n\t\n\tprivate static class SearchPatternData {\n\n\t\tint\t\t\t\tsearchFor;\n\t\tint\t\t\t\tlimitTo;\n\t\tString\t\t\tpattern;\n\t\tIJavaElement\tjavaElement;\n\t\tint\t\t\t\tscope;\n\t\tIWorkingSet\t \tworkingSet;\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element) {\n\t\t\tthis(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null);\n\t\t}\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) {\n\t\t\tsearchFor= s;\n\t\t\tlimitTo= l;\n\t\t\tpattern= p;\n\t\t\tjavaElement= element;\n\t\t\tthis.scope= scope;\n\t\t\tthis.workingSet= workingSet;\n\t\t}\n\t}\n\n\t//---- Action Handling ------------------------------------------------\n\t\n\tpublic boolean performAction() {\n\t\tSearchPatternData data= getPatternData();\n\n\t\tIWorkspace workspace= JavaPlugin.getWorkspace();\n\n\t\t// Setup search scope\n\t\tIJavaSearchScope scope= null;\n\t\tString scopeDescription= \"\"; //$NON-NLS-1$\n\t\tswitch (getContainer().getSelectedScope()) {\n\t\t\tcase ISearchPageContainer.WORKSPACE_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"WorkspaceScope\"); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createWorkspaceScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.SELECTION_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"SelectionScope\"); //$NON-NLS-1$\n\t\t\t\tscope= getSelectedResourcesScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.WORKING_SET_SCOPE:\n\t\t\t\tIWorkingSet workingSet= getContainer().getSelectedWorkingSet();\n\t\t\t\tscopeDescription= SearchMessages.getFormattedString(\"WorkingSetScope\", new String[] {workingSet.getName()}); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources());\n\t\t}\t\t\n\t\t\n\t\tJavaSearchResultCollector collector= new JavaSearchResultCollector();\n\t\tJavaSearchOperation op= null;\n\t\tif (data.javaElement != null && getPattern().equals(fInitialPattern))\n\t\t\top= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector);\n\t\telse {\n\t\t\tdata.javaElement= null;\n\t\t\top= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector);\n\t\t}\n\t\tShell shell= getControl().getShell();\n\t\ttry {\n\t\t\tgetContainer().getRunnableContext().run(true, true, op);\n\t\t} catch (InvocationTargetException ex) {\n\t\t\tExceptionHandler.handle(ex, shell, SearchMessages.getString(\"Search.Error.search.title\"), SearchMessages.getString(\"Search.Error.search.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn false;\n\t\t} catch (InterruptedException ex) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate int getLimitTo() {\n\t\tfor (int i= 0; i < fLimitTo.length; i++) {\n\t\t\tif (fLimitTo[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\n\tprivate String[] getPreviousSearchPatterns() {\n\t\t// Search results are not persistent\n\t\tint patternCount= fgPreviousSearchPatterns.size();\n\t\tString [] patterns= new String[patternCount];\n\t\tfor (int i= 0; i < patternCount; i++)\n\t\t\tpatterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;\n\t\treturn patterns;\n\t}\n\t\n\tprivate int getSearchFor() {\n\t\tfor (int i= 0; i < fSearchFor.length; i++) {\n\t\t\tif (fSearchFor[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\t\n\tprivate String getPattern() {\n\t\treturn fPattern.getText();\n\t}\n\n\t/**\n\t * Return search pattern data and update previous searches.\n\t * An existing entry will be updated.\n\t */\n\tprivate SearchPatternData getPatternData() {\n\t\tString pattern= getPattern();\n\t\tSearchPatternData match= null;\n\t\tint i= 0;\n\t\tint size= fgPreviousSearchPatterns.size();\n\t\twhile (match == null && i < size) {\n\t\t\tmatch= (SearchPatternData) fgPreviousSearchPatterns.get(i);\n\t\t\ti++;\n\t\t\tif (!pattern.equals(match.pattern))\n\t\t\t\tmatch= null;\n\t\t};\n\t\tif (match == null) {\n\t\t\tmatch= new SearchPatternData(\n\t\t\t\t\t\t\tgetSearchFor(),\n\t\t\t\t\t\t\tgetLimitTo(),\n\t\t\t\t\t\t\tgetPattern(),\n\t\t\t\t\t\t\tfJavaElement,\n\t\t\t\t\t\t\tgetContainer().getSelectedScope(),\n\t\t\t\t\t\t\tgetContainer().getSelectedWorkingSet());\n\t\t\tfgPreviousSearchPatterns.add(match);\n\t\t}\n\t\telse {\n\t\t\tmatch.searchFor= getSearchFor();\n\t\t\tmatch.limitTo= getLimitTo();\n\t\t\tmatch.javaElement= fJavaElement;\n\t\t\tmatch.scope= getContainer().getSelectedScope();\n\t\t\tmatch.workingSet= getContainer().getSelectedWorkingSet();\n\t\t};\n\t\treturn match;\n\t}\n\n\t/*\n\t * Implements method from IDialogPage\n\t */\n\tpublic void setVisible(boolean visible) {\n\t\tif (visible && fPattern != null) {\n\t\t\tif (fFirstTime) {\n\t\t\t\tfFirstTime= false;\n\t\t\t\t// Set item and text here to prevent page from resizing\n\t\t\t\tfPattern.setItems(getPreviousSearchPatterns());\n\t\t\t\tinitSelections();\n\t\t\t}\n\t\t\tfPattern.setFocus();\n\t\t\tgetContainer().setPerformActionEnabled(fPattern.getText().length() > 0);\n\t\t}\n\t\tsuper.setVisible(visible);\n\t}\n\t\n\tpublic boolean isValid() {\n\t\treturn true;\n\t}\n\n\t//---- Widget creation ------------------------------------------------\n\n\t/**\n\t * Creates the page's content.\n\t */\n\tpublic void createControl(Composite parent) {\n\t\tGridData gd;\n\t\tComposite result= new Composite(parent, SWT.NONE);\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2; layout.makeColumnsEqualWidth= true;\n\t\tlayout.horizontalSpacing= 10;\n\t\tresult.setLayout(layout);\n\t\t\n\t\tRowLayouter layouter= new RowLayouter(layout.numColumns);\n\t\tgd= new GridData();\n\t\tgd.horizontalAlignment= gd.FILL;\n\t\tlayouter.setDefaultGridData(gd, 0);\n\t\tlayouter.setDefaultGridData(gd, 1);\n\t\tlayouter.setDefaultSpan();\n\t\t\n\t\tlayouter.perform(createExpression(result));\n\t\tlayouter.perform(createSearchFor(result), createLimitTo(result), -1);\n\t\t\n\t\tSelectionAdapter javaElementInitializer= new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tfJavaElement= null;\n\t\t\t}\n\t\t};\n\n\t\tfSearchFor[FIELD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[METHOD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[PACKAGE].addSelectionListener(javaElementInitializer);\n\t\t\n\t\tfSearchFor[TYPE].addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleSearchForSelected(((Button)e.widget).getSelection());\n\t\t\t}\n\t\t});\n\t\tsetControl(result);\n\t\t\n\t\tWorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE });\t\n\t}\n\n\tprivate Control createExpression(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.expression.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 1;\n\t\tresult.setLayout(layout);\n\t\t\n\t\t// Pattern combo\n\t\tfPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);\n\t\tfPattern.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandlePatternSelected();\n\t\t\t}\n\t\t});\n\t\tfPattern.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tgetContainer().setPerformActionEnabled(getPattern().length() > 0);\n\t\t\t}\n\t\t});\n\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.widthHint= convertWidthInCharsToPixels(30);\n\t\tfPattern.setLayoutData(gd);\n\t\t\n\t\t// Pattern info\n\t\tLabel label= new Label(result, SWT.LEFT);\n\t\tlabel.setText(SearchMessages.getString(\"SearchPage.expression.pattern\")); //$NON-NLS-1$\n\t\treturn result;\n\t}\n\n\tprivate void handlePatternSelected() {\n\t\tif (fPattern.getSelectionIndex() < 0)\n\t\t\treturn;\n\t\tint index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();\n\t\tSearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index);\n\t\tfor (int i= 0; i < fSearchFor.length; i++)\n\t\t\tfSearchFor[i].setSelection(false);\n\t\tfor (int i= 0; i < fLimitTo.length; i++)\n\t\t\tfLimitTo[i].setSelection(false);\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tfLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE));\n\t\tfLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE));\n\t\tfLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE));\t\t\t\t\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t\tfJavaElement= values.javaElement;\n\t\tif (values.workingSet != null)\n\t\t\tgetContainer().setSelectedWorkingSet(values.workingSet);\n\t\telse\n\t\t\tgetContainer().setSelectedScope(values.scope);\n\t}\n\n\tprivate void handleSearchForSelected(boolean state) {\n\t\tboolean implState= fLimitTo[IMPLEMENTORS].getSelection();\n\t\tif (!state && implState) {\n\t\t\tfLimitTo[IMPLEMENTORS].setSelection(false);\n\t\t\tfLimitTo[REFERENCES].setSelection(true);\n\t\t}\n\t\tfLimitTo[IMPLEMENTORS].setEnabled(state);\n\t\tfJavaElement= null;\n\t}\n\t\t\n\tprivate Control createSearchFor(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.searchFor.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 3;\n\t\tresult.setLayout(layout);\n\n\t\tfSearchFor= new Button[fSearchForText.length];\n\t\tfor (int i= 0; i < fSearchForText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fSearchForText[i]);\n\t\t\tfSearchFor[i]= button;\n\t\t}\n\t\t\n\t\treturn result;\t\t\n\t}\n\t\n\tprivate Control createLimitTo(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.limitTo.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\t\tresult.setLayout(layout);\n\n\t\tfLimitTo= new Button[fLimitToText.length];\n\t\tfor (int i= 0; i < fLimitToText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fLimitToText[i]);\n\t\t\tfLimitTo[i]= button;\n\t\t}\n\t\treturn result;\t\t\n\t}\t\n\t\n\tprivate void initSelections() {\n\t\tfJavaElement= null;\n\t\tISelection selection= getSelection();\n\t\tSearchPatternData values= null;\n\t\tvalues= tryTypedTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySimpleTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= getDefaultInitValues();\n\t\t\t\t\t\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tif (values.searchFor != TYPE)\n\t\t\tfLimitTo[IMPLEMENTORS].setEnabled(false);\n\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t}\n\n\tprivate SearchPatternData tryTypedTextSelection(ISelection selection) {\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tIEditorPart e= getEditorPart();\n\t\t\tif (e != null) {\n\t\t\t\tITextSelection ts= (ITextSelection)selection;\n\t\t\t\tICodeAssist assist= getCodeAssist(e);\n\t\t\t\tif (assist != null) {\n\t\t\t\t\tIJavaElement[] elements= null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\telements= assist.codeSelect(ts.getOffset(), ts.getLength());\n\t\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\t}\n\t\t\t\t\tif (elements != null && elements.length > 0) {\n\t\t\t\t\t\tif (elements.length == 1)\n\t\t\t\t\t\t\tfJavaElement= elements[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tfJavaElement= chooseFromList(elements);\n\t\t\t\t\t\tif (fJavaElement != null)\n\t\t\t\t\t\t\treturn determineInitValuesFrom(fJavaElement);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate ICodeAssist getCodeAssist(IEditorPart editorPart) {\n\t\tIEditorInput input= editorPart.getEditorInput();\n\t\tif (input instanceof ClassFileEditorInput)\n\t\t\treturn ((ClassFileEditorInput)input).getClassFile();\n\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\t\t\t\t\n\t\treturn manager.getWorkingCopy(input);\n\t}\n\n\tprivate SearchPatternData trySelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection == null)\n\t\t\treturn result;\n\t\tObject o= null;\n\t\tif (selection instanceof IStructuredSelection)\n\t\t\to= ((IStructuredSelection)selection).getFirstElement();\n\t\tif (o instanceof IJavaElement) {\n\t\t\tfJavaElement= (IJavaElement)o;\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof ISearchResultViewEntry) {\n\t\t\tfJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof IAdaptable) {\n\t\t\tIWorkbenchAdapter element= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);\n\t\t\tif (element != null)\n\t\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, element.getLabel(o), null);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate IJavaElement getJavaElement(IMarker marker) {\n\t\ttry {\n\t\t\treturn JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));\n\t\t} catch (CoreException ex) {\n\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate SearchPatternData determineInitValuesFrom(IJavaElement element) {\n\t\tif (element == null)\n\t\t\treturn null;\n\t\tint searchFor= UNKNOWN;\n\t\tint limitTo= UNKNOWN;\n\t\tString pattern= null; \n\t\tswitch (element.getElementType()) {\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT_ROOT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_DECLARATION:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.IMPORT_DECLARATION:\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tIImportDeclaration declaration= (IImportDeclaration)element;\n\t\t\t\tif (declaration.isOnDemand()) {\n\t\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\t\tint index= pattern.lastIndexOf('.');\n\t\t\t\t\tpattern= pattern.substring(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tsearchFor= TYPE;\n\t\t\t\t}\n\t\t\t\tlimitTo= DECLARATIONS;\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.TYPE:\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)element);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.COMPILATION_UNIT:\n\t\t\t\tICompilationUnit cu= (ICompilationUnit)element;\n\t\t\t\tString mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(\".\")); //$NON-NLS-1$\n\t\t\t\tIType mainType= cu.getType(mainTypeName);\n\t\t\t\tmainTypeName= JavaModelUtil.getTypeQualifiedName(mainType);\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName);\n\t\t\t\t\tif (mainType == null) {\n\t\t\t\t\t\t// fetch type which is declared first in the file\n\t\t\t\t\t\tIType[] types= cu.getTypes();\n\t\t\t\t\t\tif (types.length > 0)\n\t\t\t\t\t\t\tmainType= types[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.CLASS_FILE:\n\t\t\t\tIClassFile cf= (IClassFile)element;\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= cf.getType();\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (mainType == null)\n\t\t\t\t\tbreak;\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName(mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.FIELD:\n\t\t\t\tsearchFor= FIELD;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tIType type= ((IField)element).getDeclaringType();\n\t\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\t\tbuffer.append(JavaModelUtil.getFullyQualifiedName(type));\n\t\t\t\tbuffer.append('.');\n\t\t\t\tbuffer.append(element.getElementName());\n\t\t\t\tpattern= buffer.toString();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.METHOD:\n\t\t\t\tsearchFor= METHOD;\n\t\t\t\ttry {\n\t\t\t\t\tIMethod method= (IMethod)element;\n\t\t\t\t\tif (method.isConstructor())\n\t\t\t\t\t\tsearchFor= CONSTRUCTOR;\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\t\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= PrettySignature.getMethodSignature((IMethod)element);\n\t\t\t\tbreak;\n\t\t}\n\t\tif (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null)\n\t\t\treturn new SearchPatternData(searchFor, limitTo, pattern, element);\n\t\t\t\n\t\treturn null;\t\n\t}\n\t\n\tprivate SearchPatternData trySimpleTextSelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tBufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));\n\t\t\tString text;\n\t\t\ttry {\n\t\t\t\ttext= reader.readLine();\n\t\t\t\tif (text == null)\n\t\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t} catch (IOException ex) {\n\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t}\n\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, text, null);\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate SearchPatternData getDefaultInitValues() {\n\t\treturn new SearchPatternData(TYPE, REFERENCES, \"\", null); //$NON-NLS-1$\n\t}\t\n\n\tprivate IJavaElement chooseFromList(IJavaElement[] openChoices) {\n\t\tILabelProvider labelProvider= new JavaElementLabelProvider(\n\t\t\t JavaElementLabelProvider.SHOW_DEFAULT \n\t\t\t| JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION);\n\t\tElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);\n\t\tdialog.setTitle(SearchMessages.getString(\"SearchElementSelectionDialog.title\")); //$NON-NLS-1$\n\t\tdialog.setMessage(SearchMessages.getString(\"SearchElementSelectionDialog.message\")); //$NON-NLS-1$\n\t\tdialog.setElements(openChoices);\n\t\tif (dialog.open() == dialog.OK)\n\t\t\treturn (IJavaElement)dialog.getFirstResult();\n\t\treturn null;\n\t}\n\n\t/*\n\t * Implements method from ISearchPage\n\t */\n\tpublic void setContainer(ISearchPageContainer container) {\n\t\tfContainer= container;\n\t}\n\t\n\t/**\n\t * Returns the search page's container.\n\t */\n\tprivate ISearchPageContainer getContainer() {\n\t\treturn fContainer;\n\t}\n\t\n\t/**\n\t * Returns the current active selection.\n\t */\n\tprivate ISelection getSelection() {\n\t\treturn fContainer.getSelection();\n\t}\n\t\n\t/**\n\t * Returns the current active editor part.\n\t */\n\tprivate IEditorPart getEditorPart() {\n\t\tIWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();\n\t\tif (window != null) {\n\t\t\tIWorkbenchPage page= window.getActivePage();\n\t\t\tif (page != null)\n\t\t\t\treturn page.getActiveEditor();\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate IJavaSearchScope getSelectedResourcesScope() {\n\t\tArrayList resources= new ArrayList(10);\n\t\tif (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {\n\t\t\tIterator iter= ((IStructuredSelection)getSelection()).iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tObject selection= iter.next();\n\t\t\t\tif (selection instanceof IResource)\n\t\t\t\t\tresources.add(selection);\n\t\t\t\telse if (selection instanceof IAdaptable) {\n\t\t\t\t\tIResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class);\n\t\t\t\t\tif (resource != null)\n\t\t\t\t\t\tresources.add(resource);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()]));\n\t}\n}"}}},{"rowIdx":74,"cells":{"issue_id":{"kind":"number","value":4329,"string":"4,329"},"title":{"kind":"string","value":"Bug 4329 No results If searched via Package view selection and dialog (1GLDN1X)"},"body":{"kind":"string","value":"The package view initializes the Search dialog with the fully qualified name. This is not found when searching for declarations. Search via context menu in packages view works. ==> (Java) Search should first try to get the Java element and if that fails, display the the element name and not the fully qualified name. NOTES:"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"b975be2"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-24T17:13:09Z","string":"2001-10-24T17:13:09Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultCollector.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport java.text.MessageFormat;\nimport java.util.HashMap;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IProgressMonitor;\n\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.viewers.IInputSelectionProvider;\nimport org.eclipse.jface.viewers.ISelection;\n\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\n\nimport org.eclipse.search.ui.IContextMenuContributor;\nimport org.eclipse.search.ui.ISearchResultView;\nimport org.eclipse.search.ui.ISearchResultViewEntry;\nimport org.eclipse.search.ui.SearchUI;\n\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.search.IJavaSearchResultCollector;\n\nimport org.eclipse.jdt.ui.JavaUI;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\n\nimport org.eclipse.jdt.internal.ui.actions.GroupContext;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\nimport org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;\nimport org.eclipse.jdt.internal.ui.util.SelectionUtil;\n\n\npublic class JavaSearchResultCollector implements IJavaSearchResultCollector {\n\n\tprivate static final String MATCH= SearchMessages.getString(\"SearchResultCollector.match\"); //$NON-NLS-1$\n\tprivate static final String MATCHES= SearchMessages.getString(\"SearchResultCollector.matches\"); //$NON-NLS-1$\n\tprivate static final String DONE= SearchMessages.getString(\"SearchResultCollector.done\"); //$NON-NLS-1$\n\tprivate static final String SEARCHING= SearchMessages.getString(\"SearchResultCollector.searching\"); //$NON-NLS-1$\n\tprivate static final Integer POTENTIAL_MATCH_VALUE= new Integer(POTENTIAL_MATCH);\n\t\n\tprivate IProgressMonitor fMonitor;\n\tprivate IContextMenuContributor fContextMenu;\n\tprivate ISearchResultView fView;\n\tprivate JavaSearchOperation fOperation;\n\tprivate int fMatchCount= 0;\n\tprivate Integer[] fMessageFormatArgs= new Integer[1];\n\t\n\tprivate class ContextMenuContributor implements IContextMenuContributor {\n\n\t\tpublic void fill(IMenuManager menu, IInputSelectionProvider inputProvider) {\n\t\t\tJavaPlugin.createStandardGroups(menu);\n\t\t\tnew JavaSearchGroup().fill(menu, new GroupContext(inputProvider));\n\t\t\tOpenTypeHierarchyUtil.addToMenu(getWorbenchWindow(), menu, convertSelection(inputProvider.getSelection()));\n\t\t}\n\t\t\n\t\tprivate Object convertSelection(ISelection selection) {\n\t\t\tObject element= SelectionUtil.getSingleElement(selection);\n\t\t\tif (!(element instanceof ISearchResultViewEntry))\n\t\t\t\treturn null;\n\t\t\tIMarker marker= ((ISearchResultViewEntry)element).getSelectedMarker();\n\t\t\ttry {\n\t\t\t\treturn JavaCore.create((String) ((IMarker) marker).getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));\t\n\t\t\t} catch (CoreException ex) {\n\t\t\t\tExceptionHandler.log(ex, SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-1$\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic JavaSearchResultCollector() {\n\t\tfContextMenu= new ContextMenuContributor();\n\t}\n\n\t/**\n\t * @see IJavaSearchResultCollector#aboutToStart().\n\t */\n\tpublic void aboutToStart() {\n\t\tfView= SearchUI.getSearchResultView();\n\t\tfMatchCount= 0;\n\t\tif (fView != null) {\n\t\t\tfView.searchStarted(\n\t\t\t\tJavaSearchPage.EXTENSION_POINT_ID,\n\t\t\t\tfOperation.getDescription(),\n\t\t\t\tfOperation.getImageDescriptor(),\n\t\t\t\tfContextMenu,\n\t\t\t\tJavaSearchResultLabelProvider.INSTANCE,\n\t\t\t\tnew GotoMarkerAction(),\n\t\t\t\tnew GroupByKeyComputer(),\n\t\t\t\tfOperation);\n\t\t}\n\t\tif (!getProgressMonitor().isCanceled())\n\t\t\tgetProgressMonitor().subTask(SEARCHING);\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#accept\n\t */\n\tpublic void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException {\n\t\tIMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER);\n\t\tHashMap attributes;\n\t\tif (accuracy == POTENTIAL_MATCH) {\n\t\t\tattributes= new HashMap(6);\n\t\t\tattributes.put(IJavaSearchUIConstants.ATT_ACCURACY, POTENTIAL_MATCH_VALUE);\n\t\t} else\n\t\t\tattributes= new HashMap(5);\n\t\tJavaCore.addJavaElementMarkerAttributes(attributes, enclosingElement);\n\t\tattributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, enclosingElement.getHandleIdentifier());\n\t\tattributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0)));\n\t\tattributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0)));\n\t\tif (enclosingElement instanceof IMember && ((IMember)enclosingElement).isBinary())\n\t\t\tattributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR);\n\t\telse\n\t\t\tattributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CU_EDITOR);\n\t\tmarker.setAttributes(attributes);\n\n\t\tfView.addMatch(enclosingElement.getElementName(), enclosingElement, resource, marker);\n\n\t\tfMatchCount++;\n\t\tif (!getProgressMonitor().isCanceled())\n\t\t\tgetProgressMonitor().subTask(getFormattedMatchesString(fMatchCount));\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#done().\n\t */\n\tpublic void done() {\n\t\tif (!getProgressMonitor().isCanceled()) {\n\t\t\tString matchesString= getFormattedMatchesString(fMatchCount);\n\t\t\tgetProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString}));\n\t\t}\n\n\t\tif (fView != null)\n\t\t\tfView.searchFinished();\n\n\t\t// Cut no longer unused references because the collector might be re-used\n\t\tfView= null;\n\t\tfMonitor= null;\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#getProgressMonitor().\n\t */\n\tpublic IProgressMonitor getProgressMonitor() {\n\t\treturn fMonitor;\n\t};\n\t\n\tvoid setProgressMonitor(IProgressMonitor pm) {\n\t\tfMonitor= pm;\n\t}\t\n\t\n\tvoid setOperation(JavaSearchOperation operation) {\n\t\tfOperation= operation;\n\t}\n\t\n\tprivate String getFormattedMatchesString(int count) {\n\t\tif (fMatchCount == 1)\n\t\t\treturn MATCH;\n\t\tfMessageFormatArgs[0]= new Integer(count);\n\t\treturn MessageFormat.format(MATCHES, fMessageFormatArgs);\n\n\t}\n\n\tprivate IWorkbenchWindow getWorbenchWindow() {\n\t\tIWorkbenchWindow wbWindow= null;\n\t\tif (fView != null && fView.getSite() != null)\n\t\t\twbWindow= fView.getSite().getWorkbenchWindow();\n\t\tif (wbWindow == null)\n\t\t\twbWindow= JavaPlugin.getActiveWorkbenchWindow();\n\t\treturn wbWindow;\n\t}\n}"}}},{"rowIdx":75,"cells":{"issue_id":{"kind":"number","value":5232,"string":"5,232"},"title":{"kind":"string","value":"Bug 5232 Java Search page not initialized correctly from Navigator"},"body":{"kind":"string","value":"1. Open the Navigator 2. Select a .java file (that's on the classpath) 3. Open the Search dialog (Ctrl+H) 4. Press Search ==> Nothing found. It should give the same result(s) as if the .java file would be selected in the Packages view."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"431fffb"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-25T10:25:34Z","string":"2001-10-25T10:25:34Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.StringReader;\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Combo;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.jface.dialogs.DialogPage;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IAdaptable;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.help.WorkbenchHelp;\nimport org.eclipse.ui.model.IWorkbenchAdapter;\n\nimport org.eclipse.search.internal.ui.SearchManager;\nimport org.eclipse.search.ui.ISearchPage;\nimport org.eclipse.search.ui.ISearchPageContainer;\nimport org.eclipse.search.ui.ISearchResultViewEntry;\n\nimport org.eclipse.search.ui.IWorkingSet;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICodeAssist;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IImportDeclaration;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.IJavaSearchConstants;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;\nimport org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\nimport org.eclipse.jdt.internal.ui.util.RowLayouter;\n\npublic class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants {\n\n\tpublic static final String EXTENSION_POINT_ID= \"org.eclipse.jdt.ui.JavaSearchPage\"; //$NON-NLS-1$\n\n\tprivate static List fgPreviousSearchPatterns= new ArrayList(20);\n\n\tprivate Combo fPattern;\n\tprivate String fInitialPattern;\n\tprivate boolean fFirstTime= true;\n\tprivate ISearchPageContainer fContainer;\n\t\n\tprivate Button[] fSearchFor;\n\tprivate String[] fSearchForText= {\n\t\tSearchMessages.getString(\"SearchPage.searchFor.type\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.method\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.package\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.constructor\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.field\") }; //$NON-NLS-1$\n\n\tprivate Button[] fLimitTo;\n\tprivate String[] fLimitToText= {\n\t\tSearchMessages.getString(\"SearchPage.limitTo.declarations\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.implementors\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.references\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.allOccurrences\")}; //$NON-NLS-1$\n\t\n\tprivate IJavaElement fJavaElement;\n\t\n\tprivate static class SearchPatternData {\n\n\t\tint\t\t\t\tsearchFor;\n\t\tint\t\t\t\tlimitTo;\n\t\tString\t\t\tpattern;\n\t\tIJavaElement\tjavaElement;\n\t\tint\t\t\t\tscope;\n\t\tIWorkingSet\t \tworkingSet;\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element) {\n\t\t\tthis(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null);\n\t\t}\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) {\n\t\t\tsearchFor= s;\n\t\t\tlimitTo= l;\n\t\t\tpattern= p;\n\t\t\tjavaElement= element;\n\t\t\tthis.scope= scope;\n\t\t\tthis.workingSet= workingSet;\n\t\t}\n\t}\n\n\t//---- Action Handling ------------------------------------------------\n\t\n\tpublic boolean performAction() {\n\t\tSearchPatternData data= getPatternData();\n\n\t\tIWorkspace workspace= JavaPlugin.getWorkspace();\n\n\t\t// Setup search scope\n\t\tIJavaSearchScope scope= null;\n\t\tString scopeDescription= \"\"; //$NON-NLS-1$\n\t\tswitch (getContainer().getSelectedScope()) {\n\t\t\tcase ISearchPageContainer.WORKSPACE_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"WorkspaceScope\"); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createWorkspaceScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.SELECTION_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"SelectionScope\"); //$NON-NLS-1$\n\t\t\t\tscope= getSelectedResourcesScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.WORKING_SET_SCOPE:\n\t\t\t\tIWorkingSet workingSet= getContainer().getSelectedWorkingSet();\n\t\t\t\tscopeDescription= SearchMessages.getFormattedString(\"WorkingSetScope\", new String[] {workingSet.getName()}); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources());\n\t\t}\t\t\n\t\t\n\t\tJavaSearchResultCollector collector= new JavaSearchResultCollector();\n\t\tJavaSearchOperation op= null;\n\t\tif (data.javaElement != null && getPattern().equals(fInitialPattern))\n\t\t\top= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector);\n\t\telse {\n\t\t\tdata.javaElement= null;\n\t\t\top= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector);\n\t\t}\n\t\tShell shell= getControl().getShell();\n\t\ttry {\n\t\t\tgetContainer().getRunnableContext().run(true, true, op);\n\t\t} catch (InvocationTargetException ex) {\n\t\t\tExceptionHandler.handle(ex, shell, SearchMessages.getString(\"Search.Error.search.title\"), SearchMessages.getString(\"Search.Error.search.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn false;\n\t\t} catch (InterruptedException ex) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate int getLimitTo() {\n\t\tfor (int i= 0; i < fLimitTo.length; i++) {\n\t\t\tif (fLimitTo[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\n\tprivate String[] getPreviousSearchPatterns() {\n\t\t// Search results are not persistent\n\t\tint patternCount= fgPreviousSearchPatterns.size();\n\t\tString [] patterns= new String[patternCount];\n\t\tfor (int i= 0; i < patternCount; i++)\n\t\t\tpatterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;\n\t\treturn patterns;\n\t}\n\t\n\tprivate int getSearchFor() {\n\t\tfor (int i= 0; i < fSearchFor.length; i++) {\n\t\t\tif (fSearchFor[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\t\n\tprivate String getPattern() {\n\t\treturn fPattern.getText();\n\t}\n\n\t/**\n\t * Return search pattern data and update previous searches.\n\t * An existing entry will be updated.\n\t */\n\tprivate SearchPatternData getPatternData() {\n\t\tString pattern= getPattern();\n\t\tSearchPatternData match= null;\n\t\tint i= 0;\n\t\tint size= fgPreviousSearchPatterns.size();\n\t\twhile (match == null && i < size) {\n\t\t\tmatch= (SearchPatternData) fgPreviousSearchPatterns.get(i);\n\t\t\ti++;\n\t\t\tif (!pattern.equals(match.pattern))\n\t\t\t\tmatch= null;\n\t\t};\n\t\tif (match == null) {\n\t\t\tmatch= new SearchPatternData(\n\t\t\t\t\t\t\tgetSearchFor(),\n\t\t\t\t\t\t\tgetLimitTo(),\n\t\t\t\t\t\t\tgetPattern(),\n\t\t\t\t\t\t\tfJavaElement,\n\t\t\t\t\t\t\tgetContainer().getSelectedScope(),\n\t\t\t\t\t\t\tgetContainer().getSelectedWorkingSet());\n\t\t\tfgPreviousSearchPatterns.add(match);\n\t\t}\n\t\telse {\n\t\t\tmatch.searchFor= getSearchFor();\n\t\t\tmatch.limitTo= getLimitTo();\n\t\t\tmatch.javaElement= fJavaElement;\n\t\t\tmatch.scope= getContainer().getSelectedScope();\n\t\t\tmatch.workingSet= getContainer().getSelectedWorkingSet();\n\t\t};\n\t\treturn match;\n\t}\n\n\t/*\n\t * Implements method from IDialogPage\n\t */\n\tpublic void setVisible(boolean visible) {\n\t\tif (visible && fPattern != null) {\n\t\t\tif (fFirstTime) {\n\t\t\t\tfFirstTime= false;\n\t\t\t\t// Set item and text here to prevent page from resizing\n\t\t\t\tfPattern.setItems(getPreviousSearchPatterns());\n\t\t\t\tinitSelections();\n\t\t\t}\n\t\t\tfPattern.setFocus();\n\t\t\tgetContainer().setPerformActionEnabled(fPattern.getText().length() > 0);\n\t\t}\n\t\tsuper.setVisible(visible);\n\t}\n\t\n\tpublic boolean isValid() {\n\t\treturn true;\n\t}\n\n\t//---- Widget creation ------------------------------------------------\n\n\t/**\n\t * Creates the page's content.\n\t */\n\tpublic void createControl(Composite parent) {\n\t\tGridData gd;\n\t\tComposite result= new Composite(parent, SWT.NONE);\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2; layout.makeColumnsEqualWidth= true;\n\t\tlayout.horizontalSpacing= 10;\n\t\tresult.setLayout(layout);\n\t\t\n\t\tRowLayouter layouter= new RowLayouter(layout.numColumns);\n\t\tgd= new GridData();\n\t\tgd.horizontalAlignment= gd.FILL;\n\t\tlayouter.setDefaultGridData(gd, 0);\n\t\tlayouter.setDefaultGridData(gd, 1);\n\t\tlayouter.setDefaultSpan();\n\t\t\n\t\tlayouter.perform(createExpression(result));\n\t\tlayouter.perform(createSearchFor(result), createLimitTo(result), -1);\n\t\t\n\t\tSelectionAdapter javaElementInitializer= new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tfJavaElement= null;\n\t\t\t}\n\t\t};\n\n\t\tfSearchFor[FIELD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[METHOD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[PACKAGE].addSelectionListener(javaElementInitializer);\n\t\t\n\t\tfSearchFor[TYPE].addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleSearchForSelected(((Button)e.widget).getSelection());\n\t\t\t}\n\t\t});\n\t\tsetControl(result);\n\t\t\n\t\tWorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE });\t\n\t}\n\n\tprivate Control createExpression(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.expression.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 1;\n\t\tresult.setLayout(layout);\n\t\t\n\t\t// Pattern combo\n\t\tfPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);\n\t\tfPattern.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandlePatternSelected();\n\t\t\t}\n\t\t});\n\t\tfPattern.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tgetContainer().setPerformActionEnabled(getPattern().length() > 0);\n\t\t\t}\n\t\t});\n\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.widthHint= convertWidthInCharsToPixels(30);\n\t\tfPattern.setLayoutData(gd);\n\t\t\n\t\t// Pattern info\n\t\tLabel label= new Label(result, SWT.LEFT);\n\t\tlabel.setText(SearchMessages.getString(\"SearchPage.expression.pattern\")); //$NON-NLS-1$\n\t\treturn result;\n\t}\n\n\tprivate void handlePatternSelected() {\n\t\tif (fPattern.getSelectionIndex() < 0)\n\t\t\treturn;\n\t\tint index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();\n\t\tSearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index);\n\t\tfor (int i= 0; i < fSearchFor.length; i++)\n\t\t\tfSearchFor[i].setSelection(false);\n\t\tfor (int i= 0; i < fLimitTo.length; i++)\n\t\t\tfLimitTo[i].setSelection(false);\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tfLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE));\n\t\tfLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE));\n\t\tfLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE));\t\t\t\t\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t\tfJavaElement= values.javaElement;\n\t\tif (values.workingSet != null)\n\t\t\tgetContainer().setSelectedWorkingSet(values.workingSet);\n\t\telse\n\t\t\tgetContainer().setSelectedScope(values.scope);\n\t}\n\n\tprivate void handleSearchForSelected(boolean state) {\n\t\tboolean implState= fLimitTo[IMPLEMENTORS].getSelection();\n\t\tif (!state && implState) {\n\t\t\tfLimitTo[IMPLEMENTORS].setSelection(false);\n\t\t\tfLimitTo[REFERENCES].setSelection(true);\n\t\t}\n\t\tfLimitTo[IMPLEMENTORS].setEnabled(state);\n\t\tfJavaElement= null;\n\t}\n\t\t\n\tprivate Control createSearchFor(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.searchFor.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 3;\n\t\tresult.setLayout(layout);\n\n\t\tfSearchFor= new Button[fSearchForText.length];\n\t\tfor (int i= 0; i < fSearchForText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fSearchForText[i]);\n\t\t\tfSearchFor[i]= button;\n\t\t}\n\t\t\n\t\treturn result;\t\t\n\t}\n\t\n\tprivate Control createLimitTo(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.limitTo.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\t\tresult.setLayout(layout);\n\n\t\tfLimitTo= new Button[fLimitToText.length];\n\t\tfor (int i= 0; i < fLimitToText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fLimitToText[i]);\n\t\t\tfLimitTo[i]= button;\n\t\t}\n\t\treturn result;\t\t\n\t}\t\n\t\n\tprivate void initSelections() {\n\t\tfJavaElement= null;\n\t\tISelection selection= getSelection();\n\t\tSearchPatternData values= null;\n\t\tvalues= tryTypedTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySimpleTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= getDefaultInitValues();\n\t\t\t\t\t\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tif (values.searchFor != TYPE)\n\t\t\tfLimitTo[IMPLEMENTORS].setEnabled(false);\n\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t\tfJavaElement= values.javaElement;\n\t}\n\n\tprivate SearchPatternData tryTypedTextSelection(ISelection selection) {\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tIEditorPart e= getEditorPart();\n\t\t\tif (e != null) {\n\t\t\t\tITextSelection ts= (ITextSelection)selection;\n\t\t\t\tICodeAssist assist= getCodeAssist(e);\n\t\t\t\tif (assist != null) {\n\t\t\t\t\tIJavaElement[] elements= null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\telements= assist.codeSelect(ts.getOffset(), ts.getLength());\n\t\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\t}\n\t\t\t\t\tif (elements != null && elements.length > 0) {\n\t\t\t\t\t\tif (elements.length == 1)\n\t\t\t\t\t\t\tfJavaElement= elements[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tfJavaElement= chooseFromList(elements);\n\t\t\t\t\t\tif (fJavaElement != null)\n\t\t\t\t\t\t\treturn determineInitValuesFrom(fJavaElement);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate ICodeAssist getCodeAssist(IEditorPart editorPart) {\n\t\tIEditorInput input= editorPart.getEditorInput();\n\t\tif (input instanceof ClassFileEditorInput)\n\t\t\treturn ((ClassFileEditorInput)input).getClassFile();\n\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\t\t\t\t\n\t\treturn manager.getWorkingCopy(input);\n\t}\n\n\tprivate SearchPatternData trySelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection == null)\n\t\t\treturn result;\n\t\tObject o= null;\n\t\tif (selection instanceof IStructuredSelection)\n\t\t\to= ((IStructuredSelection)selection).getFirstElement();\n\t\tif (o instanceof IJavaElement) {\n\t\t\tfJavaElement= (IJavaElement)o;\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof ISearchResultViewEntry) {\n\t\t\tfJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof IAdaptable) {\n\t\t\tIWorkbenchAdapter element= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);\n\t\t\tif (element != null)\n\t\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, element.getLabel(o), null);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate IJavaElement getJavaElement(IMarker marker) {\n\t\ttry {\n\t\t\treturn JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));\n\t\t} catch (CoreException ex) {\n\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate SearchPatternData determineInitValuesFrom(IJavaElement element) {\n\t\tif (element == null)\n\t\t\treturn null;\n\t\tint searchFor= UNKNOWN;\n\t\tint limitTo= UNKNOWN;\n\t\tString pattern= null; \n\t\tswitch (element.getElementType()) {\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT_ROOT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_DECLARATION:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.IMPORT_DECLARATION:\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tIImportDeclaration declaration= (IImportDeclaration)element;\n\t\t\t\tif (declaration.isOnDemand()) {\n\t\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\t\tint index= pattern.lastIndexOf('.');\n\t\t\t\t\tpattern= pattern.substring(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tsearchFor= TYPE;\n\t\t\t\t}\n\t\t\t\tlimitTo= DECLARATIONS;\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.TYPE:\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)element);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.COMPILATION_UNIT:\n\t\t\t\tICompilationUnit cu= (ICompilationUnit)element;\n\t\t\t\tString mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(\".\")); //$NON-NLS-1$\n\t\t\t\tIType mainType= cu.getType(mainTypeName);\n\t\t\t\tmainTypeName= JavaModelUtil.getTypeQualifiedName(mainType);\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName);\n\t\t\t\t\tif (mainType == null) {\n\t\t\t\t\t\t// fetch type which is declared first in the file\n\t\t\t\t\t\tIType[] types= cu.getTypes();\n\t\t\t\t\t\tif (types.length > 0)\n\t\t\t\t\t\t\tmainType= types[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\telement= mainType;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.CLASS_FILE:\n\t\t\t\tIClassFile cf= (IClassFile)element;\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= cf.getType();\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (mainType == null)\n\t\t\t\t\tbreak;\n\t\t\t\telement= mainType;\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName(mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.FIELD:\n\t\t\t\tsearchFor= FIELD;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tIType type= ((IField)element).getDeclaringType();\n\t\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\t\tbuffer.append(JavaModelUtil.getFullyQualifiedName(type));\n\t\t\t\tbuffer.append('.');\n\t\t\t\tbuffer.append(element.getElementName());\n\t\t\t\tpattern= buffer.toString();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.METHOD:\n\t\t\t\tsearchFor= METHOD;\n\t\t\t\ttry {\n\t\t\t\t\tIMethod method= (IMethod)element;\n\t\t\t\t\tif (method.isConstructor())\n\t\t\t\t\t\tsearchFor= CONSTRUCTOR;\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\t\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= PrettySignature.getMethodSignature((IMethod)element);\n\t\t\t\tbreak;\n\t\t}\n\t\tif (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null)\n\t\t\treturn new SearchPatternData(searchFor, limitTo, pattern, element);\n\t\t\t\n\t\treturn null;\t\n\t}\n\t\n\tprivate SearchPatternData trySimpleTextSelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tBufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));\n\t\t\tString text;\n\t\t\ttry {\n\t\t\t\ttext= reader.readLine();\n\t\t\t\tif (text == null)\n\t\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t} catch (IOException ex) {\n\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t}\n\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, text, null);\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate SearchPatternData getDefaultInitValues() {\n\t\treturn new SearchPatternData(TYPE, REFERENCES, \"\", null); //$NON-NLS-1$\n\t}\t\n\n\tprivate IJavaElement chooseFromList(IJavaElement[] openChoices) {\n\t\tILabelProvider labelProvider= new JavaElementLabelProvider(\n\t\t\t JavaElementLabelProvider.SHOW_DEFAULT \n\t\t\t| JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION);\n\t\tElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);\n\t\tdialog.setTitle(SearchMessages.getString(\"SearchElementSelectionDialog.title\")); //$NON-NLS-1$\n\t\tdialog.setMessage(SearchMessages.getString(\"SearchElementSelectionDialog.message\")); //$NON-NLS-1$\n\t\tdialog.setElements(openChoices);\n\t\tif (dialog.open() == dialog.OK)\n\t\t\treturn (IJavaElement)dialog.getFirstResult();\n\t\treturn null;\n\t}\n\n\t/*\n\t * Implements method from ISearchPage\n\t */\n\tpublic void setContainer(ISearchPageContainer container) {\n\t\tfContainer= container;\n\t}\n\t\n\t/**\n\t * Returns the search page's container.\n\t */\n\tprivate ISearchPageContainer getContainer() {\n\t\treturn fContainer;\n\t}\n\t\n\t/**\n\t * Returns the current active selection.\n\t */\n\tprivate ISelection getSelection() {\n\t\treturn fContainer.getSelection();\n\t}\n\t\n\t/**\n\t * Returns the current active editor part.\n\t */\n\tprivate IEditorPart getEditorPart() {\n\t\tIWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();\n\t\tif (window != null) {\n\t\t\tIWorkbenchPage page= window.getActivePage();\n\t\t\tif (page != null)\n\t\t\t\treturn page.getActiveEditor();\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate IJavaSearchScope getSelectedResourcesScope() {\n\t\tArrayList resources= new ArrayList(10);\n\t\tif (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {\n\t\t\tIterator iter= ((IStructuredSelection)getSelection()).iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tObject selection= iter.next();\n\t\t\t\tif (selection instanceof IResource)\n\t\t\t\t\tresources.add(selection);\n\t\t\t\telse if (selection instanceof IAdaptable) {\n\t\t\t\t\tIResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class);\n\t\t\t\t\tif (resource != null)\n\t\t\t\t\t\tresources.add(resource);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()]));\n\t}\n}"}}},{"rowIdx":76,"cells":{"issue_id":{"kind":"number","value":5128,"string":"5,128"},"title":{"kind":"string","value":"Bug 5128 JavaUI.revealInEditor doesn't handle ICompilationUnits properly"},"body":{"kind":"string","value":"When calling JavaUI.revealInEditor with an ICompilationUnit, then the package declaration is revealed. This isn't useful, passing an ICompilationUnit should be treated as a no-op. Otherwise clients need to guard against revealing the package declaration in their code (see OpenResourceAction as an example)"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"5d2cbe7"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-25T15:07:33Z","string":"2001-10-25T15:07:33Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-20T15:00:00Z","string":"2001-10-20T15:00:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.javaeditor;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\nimport java.util.Iterator;\n\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.widgets.Composite;\n\nimport org.eclipse.core.runtime.CoreException;\n\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.IStatusLineManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.text.source.ISourceViewer;\nimport org.eclipse.jface.text.source.IVerticalRuler;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\n\nimport org.eclipse.ui.IEditorActionBarContributor;\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IPartService;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.part.EditorActionBarContributor;\nimport org.eclipse.ui.texteditor.AbstractTextEditor;\nimport org.eclipse.ui.texteditor.DefaultRangeIndicator;\nimport org.eclipse.ui.texteditor.ITextEditorActionConstants;\nimport org.eclipse.ui.texteditor.TextOperationAction;\nimport org.eclipse.ui.views.contentoutline.IContentOutlinePage;\n\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.ISourceRange;\nimport org.eclipse.jdt.core.ISourceReference;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.ui.IContextMenuConstants;\nimport org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;\nimport org.eclipse.jdt.ui.text.JavaTextTools;\n\nimport org.eclipse.jdt.internal.debug.ui.display.InspectAction;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.actions.AddMethodEntryBreakpointAction;\nimport org.eclipse.jdt.internal.ui.actions.AddWatchpointAction;\nimport org.eclipse.jdt.internal.ui.actions.OpenImportDeclarationAction;\nimport org.eclipse.jdt.internal.ui.actions.ShowInPackageViewAction;\nimport org.eclipse.jdt.internal.ui.search.JavaSearchGroup;\n\n\n\n/**\n * Java specific text editor.\n */\npublic abstract class JavaEditor extends AbstractTextEditor implements ISelectionChangedListener {\n\t\t\n\t/** The outline page */\n\tprotected JavaOutlinePage fOutlinePage;\n\t\n\t/** Outliner context menu Id */\n\tprotected String fOutlinerContextMenuId;\t\n\t\n\t/**\n\t * Returns the smallest ISourceReference also implementing IJavaElement\n\t * containing the given position.\n\t */\n\tabstract protected ISourceReference getJavaSourceReferenceAt(int position);\n\t\n\t/**\n\t * Sets the input of the editor's outline page.\n\t */\n\tabstract protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input);\n\t\n\t\n\t/**\n\t * Default constructor.\n\t */\n\tpublic JavaEditor() {\n\t\tsuper();\n\t\tJavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();\n\t\tsetSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools, this));\n\t\tsetRangeIndicator(new DefaultRangeIndicator());\n\t\tsetPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());\n\t}\n\t\n\t/**\n\t * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)\n\t * \n\t * This is the code that can be found in 1.0 fixing the bidi rendering of Java code.\n\t * Looking for something less vulernable in this stream.\n\t *\n\tprotected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {\n\t\tISourceViewer viewer= super.createSourceViewer(parent, ruler, styles);\n\t\tStyledText text= viewer.getTextWidget();\n\t\ttext.setBidiColoring(true);\n\t\treturn viewer;\n\t}\n\t */\n\t\n\t/**\n\t * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)\n\t */\n\tprotected boolean affectsTextPresentation(PropertyChangeEvent event) {\n\t\tJavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();\n\t\treturn textTools.affectsBehavior(event);\n\t}\n\t\t\n\t/**\n\t * Sets the outliner's context menu ID.\n\t */\n\tprotected void setOutlinerContextMenuId(String menuId) {\n\t\tfOutlinerContextMenuId= menuId;\n\t}\n\t\t\t\n\t/**\n\t * @see AbstractTextEditor#editorContextMenuAboutToShow\n\t */\n\tpublic void editorContextMenuAboutToShow(IMenuManager menu) {\n\t\tsuper.editorContextMenuAboutToShow(menu);\n\t\t\n\t\taddGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE);\n\t\taddGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);\n\t\taddGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW);\n\t\t\n\t\tMenuManager search= new JavaSearchGroup().getMenuManagerForGroup(isTextSelectionEmpty());\n\t\tmenu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, search);\n\t\taddAction(menu, ITextEditorActionConstants.GROUP_FIND, \"ShowJavaDoc\");\n\t\t\n\t\taddAction(menu, \"Inspect\"); //$NON-NLS-1$\n\t\taddAction(menu, \"Display\"); //$NON-NLS-1$\n\t\taddAction(menu, \"RunToLine\"); //$NON-NLS-1$\n\n\t}\t\t\t\n\t\n\t/**\n\t * Creates the outline page used with this editor.\n\t */\n\tprotected JavaOutlinePage createOutlinePage() {\n\t\t\n\t\tJavaOutlinePage page= new JavaOutlinePage(fOutlinerContextMenuId, this);\n\t\t\n\t\tpage.addSelectionChangedListener(this);\n\t\tsetOutlinePageInput(page, getEditorInput());\n\t\t\n\t\t// page.setAction(\"ShowTypeHierarchy\", new ShowTypeHierarchyAction(page));\t//$NON-NLS-1$\n\t\tpage.setAction(\"OpenImportDeclaration\", new OpenImportDeclarationAction(page)); //$NON-NLS-1$\n\t\tpage.setAction(\"ShowInPackageView\", new ShowInPackageViewAction(getSite(), page)); //$NON-NLS-1$\n\t\tpage.setAction(\"AddMethodEntryBreakpoint\", new AddMethodEntryBreakpointAction(page)); //$NON-NLS-1$\n\t\tpage.setAction(\"AddWatchpoint\", new AddWatchpointAction(page)); // $NON-NLS-1$\n\t\n\t\treturn page;\n\t}\n\t\n\t/**\n\t * Informs the editor that its outliner has been closed.\n\t */\n\tpublic void outlinePageClosed() {\n\t\tif (fOutlinePage != null) {\n\t\t\tfOutlinePage.removeSelectionChangedListener(this);\n\t\t\tfOutlinePage= null;\n\t\t\tresetHighlightRange();\n\t\t}\n\t}\n\t\n\t/*\n\t * Get the dektop's StatusLineManager\n\t */\n\tprotected IStatusLineManager getStatusLineManager() {\n\t\tIEditorActionBarContributor contributor= getEditorSite().getActionBarContributor();\n\t\tif (contributor instanceof EditorActionBarContributor) {\n\t\t\treturn ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();\n\t\t}\n\t\treturn null;\n\t}\t\n\t\n\t/**\n\t * @see AbstractTextEditor#getAdapter(Class)\n\t */\n\tpublic Object getAdapter(Class required) {\n\t\t\n\t\tif (IContentOutlinePage.class.equals(required)) {\n\t\t\tif (fOutlinePage == null)\n\t\t\t\tfOutlinePage= createOutlinePage();\n\t\t\treturn fOutlinePage;\n\t\t}\n\t\treturn super.getAdapter(required);\n\t}\n\t\n\tprotected void setSelection(ISourceReference reference, boolean moveCursor) {\n\t\t\n\t\tif (reference != null) {\n\t\t\t\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\tISourceRange range= reference.getSourceRange();\n\t\t\t\tint offset= range.getOffset();\n\t\t\t\tint length= range.getLength();\n\t\t\t\t\n\t\t\t\tsetHighlightRange(offset, length, moveCursor);\n\t\t\t\t\n\t\t\t\tif (moveCursor && (reference instanceof IMember)) {\n\t\t\t\t\trange= ((IMember) reference).getNameRange();\n\t\t\t\t\toffset= range.getOffset();\n\t\t\t\t\tlength= range.getLength();\n\t\t\t\t\tif (range != null && offset > -1 && length > 0) {\n\t\t\t\t\t\tif (getSourceViewer() != null) {\n\t\t\t\t\t\t\tgetSourceViewer().revealRange(offset, length);\n\t\t\t\t\t\t\tgetSourceViewer().setSelectedRange(offset, length);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn;\n\t\t\t\t\n\t\t\t} catch (JavaModelException x) {\n\t\t\t} catch (IllegalArgumentException x) {\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (moveCursor)\n\t\t\tresetHighlightRange();\n\t}\n\t\t\n\tpublic void setSelection(ISourceReference reference) {\n\t\t\n\t\tif (reference == null)\n\t\t\treturn;\n\t\t\n\t\ttry {\n\t\t\tISourceRange range= reference.getSourceRange();\n\t\t\tif (range == null) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// find this source reference in this editor's working copy\n\t\t\treference= getJavaSourceReferenceAt(range.getOffset());\n\t\t} catch (JavaModelException x) {\n\t\t\t// be tolerant, just go with what is there\n\t\t}\n\t\t\n\t\tif (reference == null)\n\t\t\treturn;\n\t\t\t\n\t\t// set hightlight range\n\t\tsetSelection(reference, true);\n\t\t\n\t\t// set outliner selection\n\t\tif (fOutlinePage != null) {\n\t\t\tfOutlinePage.removeSelectionChangedListener(this);\n\t\t\tfOutlinePage.select(reference);\n\t\t\tfOutlinePage.addSelectionChangedListener(this);\n\t\t}\n\t}\t\n\t\n\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\t\n\t\tISourceReference reference= null;\n\t\t\n\t\tISelection selection= event.getSelection();\n\t\tIterator iter= ((IStructuredSelection) selection).iterator();\n\t\twhile (iter.hasNext()) {\n\t\t\tObject o= iter.next();\n\t\t\tif (o instanceof ISourceReference) {\n\t\t\t\treference= (ISourceReference) o;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!isActivePart() && JavaPlugin.getActivePage() != null)\n\t\t\tJavaPlugin.getActivePage().bringToTop(this);\n\t\tsetSelection(reference, !isActivePart());\n\t}\n\t\t\t\n\t/**\n\t * @see AbstractTextEditor#adjustHighlightRange(int, int)\n\t */\n\tprotected void adjustHighlightRange(int offset, int length) {\n\t\t\n\t\ttry {\n\t\t\t\n\t\t\tISourceReference reference= getJavaSourceReferenceAt(offset);\n\t\t\twhile (reference != null) {\n\t\t\t\tISourceRange range= reference.getSourceRange();\n\t\t\t\tif (offset < range.getOffset() + range.getLength() && range.getOffset() < offset + length) {\n\t\t\t\t\tsetHighlightRange(range.getOffset(), range.getLength(), true);\n\t\t\t\t\tif (fOutlinePage != null) {\n\t\t\t\t\t\tfOutlinePage.removeSelectionChangedListener(this);\n\t\t\t\t\t\tfOutlinePage.select(reference);\n\t\t\t\t\t\tfOutlinePage.addSelectionChangedListener(this);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tIJavaElement parent= ((IJavaElement) reference).getParent();\n\t\t\t\tif (parent instanceof ISourceReference)\n\t\t\t\t\treference= (ISourceReference) parent;\n\t\t\t\telse\n\t\t\t\t\treference= null;\n\t\t\t}\n\t\t\t\n\t\t} catch (JavaModelException x) {\n\t\t}\n\t\t\n\t\tresetHighlightRange();\n\t}\n\t\t\t\n\tprotected boolean isActivePart() {\n\t\tIWorkbenchWindow window= getSite().getWorkbenchWindow();\n\t\tIPartService service= window.getPartService();\n\t\treturn (this == service.getActivePart());\n\t}\n\t\n\t/**\n\t * @see AbstractTextEditor#doSetInput\n\t */\n\tprotected void doSetInput(IEditorInput input) throws CoreException {\n\t\tsuper.doSetInput(input);\n\t\tsetOutlinePageInput(fOutlinePage, input);\n\t}\n\t\n\tprotected void createActions() {\n\t\tsuper.createActions();\n\t\t\n\t\tsetAction(\"ShowJavaDoc\", new TextOperationAction(JavaEditorMessages.getResourceBundle(), \"ShowJavaDoc.\", this, ISourceViewer.INFORMATION));\n\t\t\n\t\tsetAction(\"Display\", new EditorDisplayAction(this, true)); //$NON-NLS-1$\n\t\tsetAction(\"RunToLine\", new RunToLineAction(this)); //$NON-NLS-1$\n\t\tsetAction(\"Inspect\", new InspectAction(this, true)); //$NON-NLS-1$\n\t}\n\t\n\tprivate boolean isTextSelectionEmpty() {\n\t\tISelection selection= getSelectionProvider().getSelection();\n\t\tif (!(selection instanceof ITextSelection))\n\t\t\treturn true;\n\t\treturn ((ITextSelection)selection).getLength() == 0;\t\n\t}\n\t\n\tpublic void updatedTitleImage(Image image) {\n\t\tsetTitleImage(image);\n\t}\n}"}}},{"rowIdx":77,"cells":{"issue_id":{"kind":"number","value":5233,"string":"5,233"},"title":{"kind":"string","value":"Bug 5233 Internal Error during code assist"},"body":{"kind":"string","value":"Start code assist after item.set (assuming SWT & CTabItem are imported): final CTabItem item= new CTabItem(folder, SWT.NONE); item.set ==> a lot of internal error dialogs are opened. The log is not helpful due to bug in SWT: Log: Thu Oct 25 11:56:08 GMT+02:00 2001 4 org.eclipse.core.runtime 0 Failed to execute runnable (String index out of range: 1) org.eclipse.swt.SWTException: Failed to execute runnable (String index out of range: 1) at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:318) at org.eclipse.ui.internal.Workbench.handleExceptionInEventLoop(Workbench.java:362) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:82 0) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"b0f6f4a"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-25T15:08:11Z","string":"2001-10-25T15:08:11Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/HTMLTextPresenter.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.text;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\n\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.io.StringReader;\n\nimport java.util.Iterator;\nimport org.eclipse.swt.custom.StyleRange;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.widgets.Display;\n\nimport org.eclipse.jface.text.DefaultInformationControl;\nimport org.eclipse.jface.text.Region;\nimport org.eclipse.jface.text.TextPresentation;\n\nimport org.eclipse.jdt.internal.core.util.CharArrayBuffer;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\n\n\n\npublic class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {\n\t\n\tprivate static final String LINE_DELIM= System.getProperty(\"line.separator\", \"\\n\");\n\t\n\tprivate int fCounter;\n\tprivate boolean fEnforceUpperLineLimit;\n\t\n\tpublic HTMLTextPresenter(boolean enforceUpperLineLimit) {\n\t\tsuper();\n\t\tfEnforceUpperLineLimit= enforceUpperLineLimit;\n\t}\n\t\n\tpublic HTMLTextPresenter() {\n\t\tthis(true);\n\t}\n\t\n\tprotected Reader createReader(String hoverInfo, TextPresentation presentation) {\n\t\treturn new HTML2TextReader(new StringReader(hoverInfo), presentation);\n\t}\n\t\n\tprotected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {\n\t\t\t\t\n\t\tint yoursStart= offset;\n\t\tint yoursEnd= offset + insertLength -1;\n\t\tyoursEnd= Math.max(yoursStart, yoursEnd);\n\t\t\n\t\tIterator e= presentation.getAllStyleRangeIterator();\n\t\twhile (e.hasNext()) {\n\t\t\t\n\t\t\tStyleRange range= (StyleRange) e.next();\n\t\t\n\t\t\tint myStart= range.start;\n\t\t\tint myEnd= range.start + range.length -1;\n\t\t\tmyEnd= Math.max(myStart, myEnd);\n\t\t\t\n\t\t\tif (myEnd < yoursStart)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (myStart < yoursStart)\n\t\t\t\trange.length += insertLength;\n\t\t\telse\n\t\t\t\trange.start += insertLength;\n\t\t}\n\t}\n\t\n\tprivate void append(StringBuffer buffer, String string, TextPresentation presentation) {\n\t\t\n\t\tint length= string.length();\n\t\tbuffer.append(string);\n\t\t\n\t\tif (presentation != null)\n\t\t\tadaptTextPresentation(presentation, fCounter, length);\n\t\t\t\n\t\tfCounter += length;\n\t}\n\t\n\tprivate String getIndent(String line) {\n\t\tint i= 0;\n\t\twhile (Character.isWhitespace(line.charAt(i))) ++ i;\n\t\treturn (line.substring(0, i) + \" \");\n\t}\n\t\n\t/*\n\t * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int)\n\t */\n\tpublic String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {\n\t\t\n\t\tif (hoverInfo == null)\n\t\t\treturn null;\n\t\t\t\n\t\tGC gc= new GC(display);\n\t\ttry {\n\t\t\t\n\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\tint maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight());\n\t\t\t\n\t\t\tfCounter= 0;\n\t\t\tLineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);\n\t\t\t\n\t\t\tboolean lastLineFormatted= false;\n\t\t\tString lastLineIndent= null;\n\t\t\t\n\t\t\tString line=reader.readLine();\n\t\t\tboolean lineFormatted= reader.isFormattedLine();\n\t\t\t\n\t\t\twhile (line != null) {\n\t\t\t\t\n\t\t\t\tif (fEnforceUpperLineLimit && maxNumberOfLines <= 0)\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tif (buffer.length() > 0) {\n\t\t\t\t\tif (!lastLineFormatted)\n\t\t\t\t\t\tappend(buffer, LINE_DELIM, null);\n\t\t\t\t\telse {\n\t\t\t\t\t\tappend(buffer, LINE_DELIM, presentation);\n\t\t\t\t\t\tif (lastLineIndent != null)\n\t\t\t\t\t\t\tappend(buffer, lastLineIndent, presentation);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tappend(buffer, line, null);\n\t\t\t\t\n\t\t\t\tlastLineFormatted= lineFormatted;\n\t\t\t\tif (!lineFormatted)\n\t\t\t\t\tlastLineIndent= null;\n\t\t\t\telse if (lastLineIndent == null)\n\t\t\t\t\tlastLineIndent= getIndent(line);\n\t\t\t\t\t\n\t\t\t\tline= reader.readLine();\n\t\t\t\tlineFormatted= reader.isFormattedLine();\n\t\t\t\t\n\t\t\t\tmaxNumberOfLines--;\n\t\t\t}\n\t\t\t\n\t\t\tif (line != null) {\n\t\t\t\tappend(buffer, LINE_DELIM, lineFormatted ? presentation : null);\n\t\t\t\tappend(buffer, \"...\", presentation);\n\t\t\t}\n\t\t\t\n\t\t\treturn trim(buffer, presentation);\n\t\t\t\n\t\t} catch (IOException e) {\n\t\t\t\n\t\t\tJavaPlugin.log(e);\n\t\t\treturn null;\n\t\t\t\n\t\t} finally {\n\t\t\tgc.dispose();\n\t\t}\n\t}\n\t\n\tprivate String trim(StringBuffer buffer, TextPresentation presentation) {\n\t\t\n\t\tint length= buffer.length();\n\t\t\t\t\n\t\tint end= length -1;\n\t\twhile (end >= 0 && Character.isWhitespace(buffer.charAt(end)))\n\t\t\t-- end;\n\t\t\n\t\tif (end == -1)\n\t\t\treturn \"\";\n\t\t\t\n\t\tif (end < length -1)\n\t\t\tbuffer.delete(end + 1, length);\n\t\telse\n\t\t\tend= length;\n\t\t\t\n\t\tint start= 0;\n\t\twhile (start < end && Character.isWhitespace(buffer.charAt(start)))\n\t\t\t++ start;\n\t\t\t\n\t\tbuffer.delete(0, start);\n\t\tpresentation.setResultWindow(new Region(start, buffer.length()));\n\t\treturn buffer.toString();\n\t}\n}\n\n"}}},{"rowIdx":78,"cells":{"issue_id":{"kind":"number","value":5161,"string":"5,161"},"title":{"kind":"string","value":"Bug 5161 More info in Console open on type dialog"},"body":{"kind":"string","value":"When open on type gets multiple hits in the same package you cannot determine which file you are opening. For example, if I have one version of a class in source, and one in a jar, then I have no idea which one I'm opening."},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"7d5a2b1"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-25T18:19:19Z","string":"2001-10-25T18:19:19Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-22T22:33:20Z","string":"2001-10-22T22:33:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui"},"file_content":{"kind":"string","value":""}}},{"rowIdx":79,"cells":{"issue_id":{"kind":"number","value":5161,"string":"5,161"},"title":{"kind":"string","value":"Bug 5161 More info in Console open on type dialog"},"body":{"kind":"string","value":"When open on type gets multiple hits in the same package you cannot determine which file you are opening. For example, if I have one version of a class in source, and one in a jar, then I have no idea which one I'm opening."},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"7d5a2b1"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-25T18:19:19Z","string":"2001-10-25T18:19:19Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-22T22:33:20Z","string":"2001-10-22T22:33:20Z"},"updated_file":{"kind":"string","value":"debug/org/eclipse/jdt/internal/debug/ui/OpenOnConsoleTypeAction.java"},"file_content":{"kind":"string","value":""}}},{"rowIdx":80,"cells":{"issue_id":{"kind":"number","value":5231,"string":"5,231"},"title":{"kind":"string","value":"Bug 5231 Add search for field read and write references"},"body":{"kind":"string","value":"The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"5c5661b"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T13:56:25Z","string":"2001-10-26T13:56:25Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchGroup.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport org.eclipse.jface.action.GroupMarker;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.MenuManager;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;\nimport org.eclipse.jdt.internal.ui.actions.GroupContext;\nimport org.eclipse.jdt.ui.IContextMenuConstants;\n\n/**\n * Contribute Java search specific menu elements.\n */\npublic class JavaSearchGroup extends ContextMenuGroup {\n\n\tprivate ElementSearchAction[] fActions;\n\n\tpublic static final String GROUP_NAME= IContextMenuConstants.GROUP_SEARCH;\n\n\tpublic JavaSearchGroup() {\n\t\tfActions= new ElementSearchAction[] {\n\t\t\tnew FindReferencesAction(),\n\t\t\tnew FindDeclarationsAction(),\n\t\t\tnew FindHierarchyReferencesAction(),\n\t\t\tnew FindHierarchyDeclarationsAction(),\n\t\t\tnew FindImplementorsAction()\n\t\t};\n\t}\n\n\tpublic void fill(IMenuManager manager, GroupContext context) {\n\t\tMenuManager javaSearchMM= new MenuManager(SearchMessages.getString(GROUP_NAME), GROUP_NAME); //$NON-NLS-1$\n\t\t\n\t\tfor (int i= 0; i < fActions.length; i++) {\n\t\t\tElementSearchAction action= fActions[i];\n\t\t\tif (action.canOperateOn(context.getSelection()))\n\t\t\t\tjavaSearchMM.add(action);\n\t\t}\n\t\t\n\t\tif (!javaSearchMM.isEmpty())\n\t\t\tmanager.appendToGroup(GROUP_NAME, javaSearchMM);\n\t}\n\n\tpublic String getGroupName() {\n\t\treturn GROUP_NAME;\n\t}\n\t\n\tpublic MenuManager getMenuManagerForGroup(boolean isTextSelectionEmpty) {\n\t\tMenuManager javaSearchMM= new MenuManager(SearchMessages.getString(GROUP_NAME), GROUP_NAME); //$NON-NLS-1$\n\t\tif (!isTextSelectionEmpty) {\n\t\t\tjavaSearchMM.add(new GroupMarker(GROUP_NAME));\n\t\t\tfor (int i= 0; i < fActions.length; i++)\n\t\t\t\tjavaSearchMM.appendToGroup(GROUP_NAME, fActions[i]);\n\t\t}\n\t\treturn javaSearchMM;\n\t}\n}\n\n"}}},{"rowIdx":81,"cells":{"issue_id":{"kind":"number","value":5231,"string":"5,231"},"title":{"kind":"string","value":"Bug 5231 Add search for field read and write references"},"body":{"kind":"string","value":"The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"5c5661b"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T13:56:25Z","string":"2001-10-26T13:56:25Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchOperation.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IProgressMonitor;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\n\nimport org.eclipse.ui.actions.WorkspaceModifyOperation;\n\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.search.IJavaSearchConstants;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\n\npublic class JavaSearchOperation extends WorkspaceModifyOperation {\n\t\n\tprivate IWorkspace fWorkspace;\n\tprivate IJavaElement fElementPattern;\n\tprivate int fLimitTo;\n\tprivate String fStringPattern;\n\tprivate int fSearchFor;\n\tprivate IJavaSearchScope fScope;\n\tprivate String fScopeDescription;\n\tprivate JavaSearchResultCollector fCollector;\n\t\n\tprotected JavaSearchOperation(\n\t\t\t\tIWorkspace workspace,\n\t\t\t\tint limitTo,\n\t\t\t\tIJavaSearchScope scope,\n\t\t\t\tString scopeDescription,\n\t\t\t\tJavaSearchResultCollector collector) {\n\t\tfWorkspace= workspace;\n\t\tfLimitTo= limitTo;\n\t\tfScope= scope;\n\t\tfScopeDescription= scopeDescription;\n\t\tfCollector= collector;\n\t\tfCollector.setOperation(this);\n\t}\n\t\n\tpublic JavaSearchOperation(\n\t\t\t\tIWorkspace workspace,\n\t\t\t\tIJavaElement pattern,\n\t\t\t\tint limitTo,\n\t\t\t\tIJavaSearchScope scope,\n\t\t\t\tString scopeDescription,\n\t\t\t\tJavaSearchResultCollector collector) {\n\t\tthis(workspace, limitTo, scope, scopeDescription, collector);\n\t\tfElementPattern= pattern;\n\t}\n\t\n\tpublic JavaSearchOperation(\n\t\t\t\tIWorkspace workspace,\n\t\t\t\tString pattern,\n\t\t\t\tint searchFor, \n\t\t\t\tint limitTo,\n\t\t\t\tIJavaSearchScope scope,\n\t\t\t\tString scopeDescription,\n\t\t\t\tJavaSearchResultCollector collector) {\n\t\tthis(workspace, limitTo, scope, scopeDescription, collector);\n\t\tfStringPattern= pattern;\n\t\tfSearchFor= searchFor;\n\t}\n\t\n\tprotected void execute(IProgressMonitor monitor) throws CoreException {\n\t\tfCollector.setProgressMonitor(monitor);\n\t\tSearchEngine engine= new SearchEngine();\n\t\tif (fElementPattern != null)\n\t\t\tengine.search(fWorkspace, fElementPattern, fLimitTo, fScope, fCollector);\n\t\telse\n\t\t\tengine.search(fWorkspace, fStringPattern, fSearchFor, fLimitTo, fScope, fCollector);\n\t}\n\n\tString getDescription() {\n\t\tString desc= null;\n\t\tif (fElementPattern != null) {\n\t\t\tif (fLimitTo == IJavaSearchConstants.REFERENCES\n\t\t\t&& fElementPattern.getElementType() == IJavaElement.METHOD)\n\t\t\t\tdesc= PrettySignature.getUnqualifiedMethodSignature((IMethod)fElementPattern);\n\t\t\telse\n\t\t\t\tdesc= fElementPattern.getElementName();\n\t\t\tif (\"\".equals(desc) && fElementPattern.getElementType() == IJavaElement.PACKAGE_FRAGMENT) //$NON-NLS-1$\n\t\t\t\tdesc= SearchMessages.getString(\"JavaSearchOperation.default_package\"); //$NON-NLS-1$\n\t\t}\n\t\telse\n\t\t\tdesc= fStringPattern;\n\n\t\tString[] args= new String[] {desc, \"{0}\", fScopeDescription}; //$NON-NLS-1$\n\t\tswitch (fLimitTo) {\n\t\t\tcase IJavaSearchConstants.IMPLEMENTORS:\n\t\t\t\treturn SearchMessages.getFormattedString(\"JavaSearchOperation.implementorsPostfix\", args); //$NON-NLS-1$\n\t\t\tcase IJavaSearchConstants.DECLARATIONS:\n\t\t\t\treturn SearchMessages.getFormattedString(\"JavaSearchOperation.declarationsPostfix\", args); //$NON-NLS-1$\n\t\t\tcase IJavaSearchConstants.REFERENCES:\n\t\t\t\treturn SearchMessages.getFormattedString(\"JavaSearchOperation.referencesPostfix\", args); //$NON-NLS-1$\n\t\t\tcase IJavaSearchConstants.ALL_OCCURRENCES:\n\t\t\t\treturn SearchMessages.getFormattedString(\"JavaSearchOperation.occurrencesPostfix\", args); //$NON-NLS-1$\n\t\t\tdefault:\n\t\t\t\treturn SearchMessages.getFormattedString(\"JavaSearchOperation.occurrencesPostfix\", args); //$NON-NLS-1$;\n\t\t}\n\t}\n\t\n\tImageDescriptor getImageDescriptor() {\n\t\tif (fLimitTo == IJavaSearchConstants.IMPLEMENTORS || fLimitTo == IJavaSearchConstants.DECLARATIONS)\n\t\t\treturn JavaPluginImages.DESC_OBJS_SEARCH_DECL;\n\t\telse\n\t\t\treturn JavaPluginImages.DESC_OBJS_SEARCH_REF;\n\t}\n}"}}},{"rowIdx":82,"cells":{"issue_id":{"kind":"number","value":5231,"string":"5,231"},"title":{"kind":"string","value":"Bug 5231 Add search for field read and write references"},"body":{"kind":"string","value":"The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"5c5661b"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T13:56:25Z","string":"2001-10-26T13:56:25Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.StringReader;\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Combo;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.jface.dialogs.DialogPage;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IAdaptable;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.help.WorkbenchHelp;\nimport org.eclipse.ui.model.IWorkbenchAdapter;\n\nimport org.eclipse.search.internal.ui.SearchManager;\nimport org.eclipse.search.ui.ISearchPage;\nimport org.eclipse.search.ui.ISearchPageContainer;\nimport org.eclipse.search.ui.ISearchResultViewEntry;\n\nimport org.eclipse.search.ui.IWorkingSet;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICodeAssist;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IImportDeclaration;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.IJavaSearchConstants;\nimport org.eclipse.jdt.core.search.IJavaSearchScope;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;\nimport org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\nimport org.eclipse.jdt.internal.ui.util.RowLayouter;\n\npublic class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants {\n\n\tpublic static final String EXTENSION_POINT_ID= \"org.eclipse.jdt.ui.JavaSearchPage\"; //$NON-NLS-1$\n\n\tprivate static List fgPreviousSearchPatterns= new ArrayList(20);\n\n\tprivate Combo fPattern;\n\tprivate String fInitialPattern;\n\tprivate boolean fFirstTime= true;\n\tprivate ISearchPageContainer fContainer;\n\t\n\tprivate Button[] fSearchFor;\n\tprivate String[] fSearchForText= {\n\t\tSearchMessages.getString(\"SearchPage.searchFor.type\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.method\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.package\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.constructor\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.searchFor.field\") }; //$NON-NLS-1$\n\n\tprivate Button[] fLimitTo;\n\tprivate String[] fLimitToText= {\n\t\tSearchMessages.getString(\"SearchPage.limitTo.declarations\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.implementors\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.references\"), //$NON-NLS-1$\n\t\tSearchMessages.getString(\"SearchPage.limitTo.allOccurrences\")}; //$NON-NLS-1$\n\t\n\tprivate IJavaElement fJavaElement;\n\t\n\tprivate static class SearchPatternData {\n\n\t\tint\t\t\t\tsearchFor;\n\t\tint\t\t\t\tlimitTo;\n\t\tString\t\t\tpattern;\n\t\tIJavaElement\tjavaElement;\n\t\tint\t\t\t\tscope;\n\t\tIWorkingSet\t \tworkingSet;\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element) {\n\t\t\tthis(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null);\n\t\t}\n\t\t\n\t\tpublic SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) {\n\t\t\tsearchFor= s;\n\t\t\tlimitTo= l;\n\t\t\tpattern= p;\n\t\t\tjavaElement= element;\n\t\t\tthis.scope= scope;\n\t\t\tthis.workingSet= workingSet;\n\t\t}\n\t}\n\n\t//---- Action Handling ------------------------------------------------\n\t\n\tpublic boolean performAction() {\n\t\tSearchPatternData data= getPatternData();\n\n\t\tIWorkspace workspace= JavaPlugin.getWorkspace();\n\n\t\t// Setup search scope\n\t\tIJavaSearchScope scope= null;\n\t\tString scopeDescription= \"\"; //$NON-NLS-1$\n\t\tswitch (getContainer().getSelectedScope()) {\n\t\t\tcase ISearchPageContainer.WORKSPACE_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"WorkspaceScope\"); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createWorkspaceScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.SELECTION_SCOPE:\n\t\t\t\tscopeDescription= SearchMessages.getString(\"SelectionScope\"); //$NON-NLS-1$\n\t\t\t\tscope= getSelectedResourcesScope();\n\t\t\t\tbreak;\n\t\t\tcase ISearchPageContainer.WORKING_SET_SCOPE:\n\t\t\t\tIWorkingSet workingSet= getContainer().getSelectedWorkingSet();\n\t\t\t\tscopeDescription= SearchMessages.getFormattedString(\"WorkingSetScope\", new String[] {workingSet.getName()}); //$NON-NLS-1$\n\t\t\t\tscope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources());\n\t\t}\t\t\n\t\t\n\t\tJavaSearchResultCollector collector= new JavaSearchResultCollector();\n\t\tJavaSearchOperation op= null;\n\t\tif (data.javaElement != null && getPattern().equals(fInitialPattern))\n\t\t\top= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector);\n\t\telse {\n\t\t\tdata.javaElement= null;\n\t\t\top= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector);\n\t\t}\n\t\tShell shell= getControl().getShell();\n\t\ttry {\n\t\t\tgetContainer().getRunnableContext().run(true, true, op);\n\t\t} catch (InvocationTargetException ex) {\n\t\t\tExceptionHandler.handle(ex, shell, SearchMessages.getString(\"Search.Error.search.title\"), SearchMessages.getString(\"Search.Error.search.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn false;\n\t\t} catch (InterruptedException ex) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate int getLimitTo() {\n\t\tfor (int i= 0; i < fLimitTo.length; i++) {\n\t\t\tif (fLimitTo[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\n\tprivate String[] getPreviousSearchPatterns() {\n\t\t// Search results are not persistent\n\t\tint patternCount= fgPreviousSearchPatterns.size();\n\t\tString [] patterns= new String[patternCount];\n\t\tfor (int i= 0; i < patternCount; i++)\n\t\t\tpatterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;\n\t\treturn patterns;\n\t}\n\t\n\tprivate int getSearchFor() {\n\t\tfor (int i= 0; i < fSearchFor.length; i++) {\n\t\t\tif (fSearchFor[i].getSelection())\n\t\t\t\treturn i;\n\t\t}\n\t\tAssert.isTrue(false, SearchMessages.getString(\"SearchPage.shouldNeverHappen\")); //$NON-NLS-1$\n\t\treturn -1;\n\t}\n\t\n\tprivate String getPattern() {\n\t\treturn fPattern.getText();\n\t}\n\n\t/**\n\t * Return search pattern data and update previous searches.\n\t * An existing entry will be updated.\n\t */\n\tprivate SearchPatternData getPatternData() {\n\t\tString pattern= getPattern();\n\t\tSearchPatternData match= null;\n\t\tint i= 0;\n\t\tint size= fgPreviousSearchPatterns.size();\n\t\twhile (match == null && i < size) {\n\t\t\tmatch= (SearchPatternData) fgPreviousSearchPatterns.get(i);\n\t\t\ti++;\n\t\t\tif (!pattern.equals(match.pattern))\n\t\t\t\tmatch= null;\n\t\t};\n\t\tif (match == null) {\n\t\t\tmatch= new SearchPatternData(\n\t\t\t\t\t\t\tgetSearchFor(),\n\t\t\t\t\t\t\tgetLimitTo(),\n\t\t\t\t\t\t\tgetPattern(),\n\t\t\t\t\t\t\tfJavaElement,\n\t\t\t\t\t\t\tgetContainer().getSelectedScope(),\n\t\t\t\t\t\t\tgetContainer().getSelectedWorkingSet());\n\t\t\tfgPreviousSearchPatterns.add(match);\n\t\t}\n\t\telse {\n\t\t\tmatch.searchFor= getSearchFor();\n\t\t\tmatch.limitTo= getLimitTo();\n\t\t\tmatch.javaElement= fJavaElement;\n\t\t\tmatch.scope= getContainer().getSelectedScope();\n\t\t\tmatch.workingSet= getContainer().getSelectedWorkingSet();\n\t\t};\n\t\treturn match;\n\t}\n\n\t/*\n\t * Implements method from IDialogPage\n\t */\n\tpublic void setVisible(boolean visible) {\n\t\tif (visible && fPattern != null) {\n\t\t\tif (fFirstTime) {\n\t\t\t\tfFirstTime= false;\n\t\t\t\t// Set item and text here to prevent page from resizing\n\t\t\t\tfPattern.setItems(getPreviousSearchPatterns());\n\t\t\t\tinitSelections();\n\t\t\t}\n\t\t\tfPattern.setFocus();\n\t\t\tgetContainer().setPerformActionEnabled(fPattern.getText().length() > 0);\n\t\t}\n\t\tsuper.setVisible(visible);\n\t}\n\t\n\tpublic boolean isValid() {\n\t\treturn true;\n\t}\n\n\t//---- Widget creation ------------------------------------------------\n\n\t/**\n\t * Creates the page's content.\n\t */\n\tpublic void createControl(Composite parent) {\n\t\tGridData gd;\n\t\tComposite result= new Composite(parent, SWT.NONE);\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2; layout.makeColumnsEqualWidth= true;\n\t\tlayout.horizontalSpacing= 10;\n\t\tresult.setLayout(layout);\n\t\t\n\t\tRowLayouter layouter= new RowLayouter(layout.numColumns);\n\t\tgd= new GridData();\n\t\tgd.horizontalAlignment= gd.FILL;\n\t\tlayouter.setDefaultGridData(gd, 0);\n\t\tlayouter.setDefaultGridData(gd, 1);\n\t\tlayouter.setDefaultSpan();\n\t\t\n\t\tlayouter.perform(createExpression(result));\n\t\tlayouter.perform(createSearchFor(result), createLimitTo(result), -1);\n\t\t\n\t\tSelectionAdapter javaElementInitializer= new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tfJavaElement= null;\n\t\t\t}\n\t\t};\n\n\t\tfSearchFor[FIELD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[METHOD].addSelectionListener(javaElementInitializer);\n\t\tfSearchFor[PACKAGE].addSelectionListener(javaElementInitializer);\n\t\t\n\t\tfSearchFor[TYPE].addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleSearchForSelected(((Button)e.widget).getSelection());\n\t\t\t}\n\t\t});\n\t\tsetControl(result);\n\t\t\n\t\tWorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE });\t\n\t}\n\n\tprivate Control createExpression(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.expression.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 1;\n\t\tresult.setLayout(layout);\n\t\t\n\t\t// Pattern combo\n\t\tfPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);\n\t\tfPattern.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandlePatternSelected();\n\t\t\t}\n\t\t});\n\t\tfPattern.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tgetContainer().setPerformActionEnabled(getPattern().length() > 0);\n\t\t\t}\n\t\t});\n\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.widthHint= convertWidthInCharsToPixels(30);\n\t\tfPattern.setLayoutData(gd);\n\t\t\n\t\t// Pattern info\n\t\tLabel label= new Label(result, SWT.LEFT);\n\t\tlabel.setText(SearchMessages.getString(\"SearchPage.expression.pattern\")); //$NON-NLS-1$\n\t\treturn result;\n\t}\n\n\tprivate void handlePatternSelected() {\n\t\tif (fPattern.getSelectionIndex() < 0)\n\t\t\treturn;\n\t\tint index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();\n\t\tSearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index);\n\t\tfor (int i= 0; i < fSearchFor.length; i++)\n\t\t\tfSearchFor[i].setSelection(false);\n\t\tfor (int i= 0; i < fLimitTo.length; i++)\n\t\t\tfLimitTo[i].setSelection(false);\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tfLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE));\n\t\tfLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE));\n\t\tfLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE));\t\t\t\t\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t\tfJavaElement= values.javaElement;\n\t\tif (values.workingSet != null)\n\t\t\tgetContainer().setSelectedWorkingSet(values.workingSet);\n\t\telse\n\t\t\tgetContainer().setSelectedScope(values.scope);\n\t}\n\n\tprivate void handleSearchForSelected(boolean state) {\n\t\tboolean implState= fLimitTo[IMPLEMENTORS].getSelection();\n\t\tif (!state && implState) {\n\t\t\tfLimitTo[IMPLEMENTORS].setSelection(false);\n\t\t\tfLimitTo[REFERENCES].setSelection(true);\n\t\t}\n\t\tfLimitTo[IMPLEMENTORS].setEnabled(state);\n\t\tfJavaElement= null;\n\t}\n\t\t\n\tprivate Control createSearchFor(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.searchFor.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 3;\n\t\tresult.setLayout(layout);\n\n\t\tfSearchFor= new Button[fSearchForText.length];\n\t\tfor (int i= 0; i < fSearchForText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fSearchForText[i]);\n\t\t\tfSearchFor[i]= button;\n\t\t}\n\t\t\n\t\treturn result;\t\t\n\t}\n\t\n\tprivate Control createLimitTo(Composite parent) {\n\t\tGroup result= new Group(parent, SWT.NONE);\n\t\tresult.setText(SearchMessages.getString(\"SearchPage.limitTo.label\")); //$NON-NLS-1$\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\t\tresult.setLayout(layout);\n\n\t\tfLimitTo= new Button[fLimitToText.length];\n\t\tfor (int i= 0; i < fLimitToText.length; i++) {\n\t\t\tButton button= new Button(result, SWT.RADIO);\n\t\t\tbutton.setText(fLimitToText[i]);\n\t\t\tfLimitTo[i]= button;\n\t\t}\n\t\treturn result;\t\t\n\t}\t\n\t\n\tprivate void initSelections() {\n\t\tfJavaElement= null;\n\t\tISelection selection= getSelection();\n\t\tSearchPatternData values= null;\n\t\tvalues= tryTypedTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= trySimpleTextSelection(selection);\n\t\tif (values == null)\n\t\t\tvalues= getDefaultInitValues();\n\t\t\t\t\t\n\t\tfSearchFor[values.searchFor].setSelection(true);\n\t\tfLimitTo[values.limitTo].setSelection(true);\n\t\tif (values.searchFor != TYPE)\n\t\t\tfLimitTo[IMPLEMENTORS].setEnabled(false);\n\n\t\tfInitialPattern= values.pattern;\n\t\tfPattern.setText(fInitialPattern);\n\t\tfJavaElement= values.javaElement;\n\t}\n\n\tprivate SearchPatternData tryTypedTextSelection(ISelection selection) {\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tIEditorPart e= getEditorPart();\n\t\t\tif (e != null) {\n\t\t\t\tITextSelection ts= (ITextSelection)selection;\n\t\t\t\tICodeAssist assist= getCodeAssist(e);\n\t\t\t\tif (assist != null) {\n\t\t\t\t\tIJavaElement[] elements= null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\telements= assist.codeSelect(ts.getOffset(), ts.getLength());\n\t\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\t}\n\t\t\t\t\tif (elements != null && elements.length > 0) {\n\t\t\t\t\t\tif (elements.length == 1)\n\t\t\t\t\t\t\tfJavaElement= elements[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tfJavaElement= chooseFromList(elements);\n\t\t\t\t\t\tif (fJavaElement != null)\n\t\t\t\t\t\t\treturn determineInitValuesFrom(fJavaElement);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate ICodeAssist getCodeAssist(IEditorPart editorPart) {\n\t\tIEditorInput input= editorPart.getEditorInput();\n\t\tif (input instanceof ClassFileEditorInput)\n\t\t\treturn ((ClassFileEditorInput)input).getClassFile();\n\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\t\t\t\t\n\t\treturn manager.getWorkingCopy(input);\n\t}\n\n\tprivate SearchPatternData trySelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection == null)\n\t\t\treturn result;\n\t\tObject o= null;\n\t\tif (selection instanceof IStructuredSelection)\n\t\t\to= ((IStructuredSelection)selection).getFirstElement();\n\t\tif (o instanceof IJavaElement) {\n\t\t\tfJavaElement= (IJavaElement)o;\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof ISearchResultViewEntry) {\n\t\t\tfJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());\n\t\t\tresult= determineInitValuesFrom(fJavaElement);\n\t\t} else if (o instanceof IAdaptable) {\n\t\t\tIJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class);\n\t\t\tif (element != null) {\n\t\t\t\tresult= determineInitValuesFrom(element);\n\t\t\t} else {\n\t\t\t\tIWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);\n\t\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, adapter.getLabel(o), null);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate IJavaElement getJavaElement(IMarker marker) {\n\t\ttry {\n\t\t\treturn JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));\n\t\t} catch (CoreException ex) {\n\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.createJavaElement.title\"), SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate SearchPatternData determineInitValuesFrom(IJavaElement element) {\n\t\tif (element == null)\n\t\t\treturn null;\n\t\tint searchFor= UNKNOWN;\n\t\tint limitTo= UNKNOWN;\n\t\tString pattern= null; \n\t\tswitch (element.getElementType()) {\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT_ROOT:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.PACKAGE_DECLARATION:\n\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.IMPORT_DECLARATION:\n\t\t\t\tpattern= element.getElementName();\n\t\t\t\tIImportDeclaration declaration= (IImportDeclaration)element;\n\t\t\t\tif (declaration.isOnDemand()) {\n\t\t\t\t\tsearchFor= PACKAGE;\n\t\t\t\t\tint index= pattern.lastIndexOf('.');\n\t\t\t\t\tpattern= pattern.substring(0, index);\n\t\t\t\t} else {\n\t\t\t\t\tsearchFor= TYPE;\n\t\t\t\t}\n\t\t\t\tlimitTo= DECLARATIONS;\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.TYPE:\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)element);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.COMPILATION_UNIT:\n\t\t\t\tICompilationUnit cu= (ICompilationUnit)element;\n\t\t\t\tString mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(\".\")); //$NON-NLS-1$\n\t\t\t\tIType mainType= cu.getType(mainTypeName);\n\t\t\t\tmainTypeName= JavaModelUtil.getTypeQualifiedName(mainType);\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName);\n\t\t\t\t\tif (mainType == null) {\n\t\t\t\t\t\t// fetch type which is declared first in the file\n\t\t\t\t\t\tIType[] types= cu.getTypes();\n\t\t\t\t\t\tif (types.length > 0)\n\t\t\t\t\t\t\tmainType= types[0];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\telement= mainType;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName((IType)mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.CLASS_FILE:\n\t\t\t\tIClassFile cf= (IClassFile)element;\n\t\t\t\ttry {\t\t\t\t\t\n\t\t\t\t\tmainType= cf.getType();\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (mainType == null)\n\t\t\t\t\tbreak;\n\t\t\t\telement= mainType;\n\t\t\t\tsearchFor= TYPE;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= JavaModelUtil.getFullyQualifiedName(mainType);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.FIELD:\n\t\t\t\tsearchFor= FIELD;\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tIType type= ((IField)element).getDeclaringType();\n\t\t\t\tStringBuffer buffer= new StringBuffer();\n\t\t\t\tbuffer.append(JavaModelUtil.getFullyQualifiedName(type));\n\t\t\t\tbuffer.append('.');\n\t\t\t\tbuffer.append(element.getElementName());\n\t\t\t\tpattern= buffer.toString();\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.METHOD:\n\t\t\t\tsearchFor= METHOD;\n\t\t\t\ttry {\n\t\t\t\t\tIMethod method= (IMethod)element;\n\t\t\t\t\tif (method.isConstructor())\n\t\t\t\t\t\tsearchFor= CONSTRUCTOR;\n\t\t\t\t} catch (JavaModelException ex) {\n\t\t\t\t\tExceptionHandler.handle(ex, SearchMessages.getString(\"Search.Error.javaElementAccess.title\"), SearchMessages.getString(\"Search.Error.javaElementAccess.message\")); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\t\n\t\t\t\tlimitTo= REFERENCES;\n\t\t\t\tpattern= PrettySignature.getMethodSignature((IMethod)element);\n\t\t\t\tbreak;\n\t\t}\n\t\tif (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null)\n\t\t\treturn new SearchPatternData(searchFor, limitTo, pattern, element);\n\t\t\t\n\t\treturn null;\t\n\t}\n\t\n\tprivate SearchPatternData trySimpleTextSelection(ISelection selection) {\n\t\tSearchPatternData result= null;\n\t\tif (selection instanceof ITextSelection) {\n\t\t\tBufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));\n\t\t\tString text;\n\t\t\ttry {\n\t\t\t\ttext= reader.readLine();\n\t\t\t\tif (text == null)\n\t\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t} catch (IOException ex) {\n\t\t\t\ttext= \"\"; //$NON-NLS-1$\n\t\t\t}\n\t\t\tresult= new SearchPatternData(TYPE, REFERENCES, text, null);\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tprivate SearchPatternData getDefaultInitValues() {\n\t\treturn new SearchPatternData(TYPE, REFERENCES, \"\", null); //$NON-NLS-1$\n\t}\t\n\n\tprivate IJavaElement chooseFromList(IJavaElement[] openChoices) {\n\t\tILabelProvider labelProvider= new JavaElementLabelProvider(\n\t\t\t JavaElementLabelProvider.SHOW_DEFAULT \n\t\t\t| JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION);\n\t\tElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);\n\t\tdialog.setTitle(SearchMessages.getString(\"SearchElementSelectionDialog.title\")); //$NON-NLS-1$\n\t\tdialog.setMessage(SearchMessages.getString(\"SearchElementSelectionDialog.message\")); //$NON-NLS-1$\n\t\tdialog.setElements(openChoices);\n\t\tif (dialog.open() == dialog.OK)\n\t\t\treturn (IJavaElement)dialog.getFirstResult();\n\t\treturn null;\n\t}\n\n\t/*\n\t * Implements method from ISearchPage\n\t */\n\tpublic void setContainer(ISearchPageContainer container) {\n\t\tfContainer= container;\n\t}\n\t\n\t/**\n\t * Returns the search page's container.\n\t */\n\tprivate ISearchPageContainer getContainer() {\n\t\treturn fContainer;\n\t}\n\t\n\t/**\n\t * Returns the current active selection.\n\t */\n\tprivate ISelection getSelection() {\n\t\treturn fContainer.getSelection();\n\t}\n\t\n\t/**\n\t * Returns the current active editor part.\n\t */\n\tprivate IEditorPart getEditorPart() {\n\t\tIWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();\n\t\tif (window != null) {\n\t\t\tIWorkbenchPage page= window.getActivePage();\n\t\t\tif (page != null)\n\t\t\t\treturn page.getActiveEditor();\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate IJavaSearchScope getSelectedResourcesScope() {\n\t\tArrayList resources= new ArrayList(10);\n\t\tif (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {\n\t\t\tIterator iter= ((IStructuredSelection)getSelection()).iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tObject selection= iter.next();\n\t\t\t\tif (selection instanceof IResource)\n\t\t\t\t\tresources.add(selection);\n\t\t\t\telse if (selection instanceof IAdaptable) {\n\t\t\t\t\tIResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class);\n\t\t\t\t\tif (resource != null)\n\t\t\t\t\t\tresources.add(resource);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()]));\n\t}\n}"}}},{"rowIdx":83,"cells":{"issue_id":{"kind":"number","value":5231,"string":"5,231"},"title":{"kind":"string","value":"Bug 5231 Add search for field read and write references"},"body":{"kind":"string","value":"The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"5c5661b"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T13:56:25Z","string":"2001-10-26T13:56:25Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-25T08:53:20Z","string":"2001-10-25T08:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultCollector.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.search;\n\nimport java.text.MessageFormat;\nimport java.util.HashMap;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IProgressMonitor;\n\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.viewers.IInputSelectionProvider;\nimport org.eclipse.jface.viewers.ISelection;\n\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\n\nimport org.eclipse.search.ui.IContextMenuContributor;\nimport org.eclipse.search.ui.ISearchResultView;\nimport org.eclipse.search.ui.ISearchResultViewEntry;\nimport org.eclipse.search.ui.SearchUI;\n\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.search.IJavaSearchResultCollector;\n\nimport org.eclipse.jdt.ui.JavaUI;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\n\nimport org.eclipse.jdt.internal.ui.actions.GroupContext;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\nimport org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;\nimport org.eclipse.jdt.internal.ui.util.SelectionUtil;\n\n\npublic class JavaSearchResultCollector implements IJavaSearchResultCollector {\n\n\tprivate static final String MATCH= SearchMessages.getString(\"SearchResultCollector.match\"); //$NON-NLS-1$\n\tprivate static final String MATCHES= SearchMessages.getString(\"SearchResultCollector.matches\"); //$NON-NLS-1$\n\tprivate static final String DONE= SearchMessages.getString(\"SearchResultCollector.done\"); //$NON-NLS-1$\n\tprivate static final String SEARCHING= SearchMessages.getString(\"SearchResultCollector.searching\"); //$NON-NLS-1$\n\tprivate static final Integer POTENTIAL_MATCH_VALUE= new Integer(POTENTIAL_MATCH);\n\t\n\tprivate IProgressMonitor fMonitor;\n\tprivate IContextMenuContributor fContextMenu;\n\tprivate ISearchResultView fView;\n\tprivate JavaSearchOperation fOperation;\n\tprivate int fMatchCount= 0;\n\tprivate Integer[] fMessageFormatArgs= new Integer[1];\n\t\n\tprivate class ContextMenuContributor implements IContextMenuContributor {\n\n\t\tpublic void fill(IMenuManager menu, IInputSelectionProvider inputProvider) {\n\t\t\tJavaPlugin.createStandardGroups(menu);\n\t\t\tnew JavaSearchGroup().fill(menu, new GroupContext(inputProvider));\n\t\t\tOpenTypeHierarchyUtil.addToMenu(getWorbenchWindow(), menu, convertSelection(inputProvider.getSelection()));\n\t\t}\n\t\t\n\t\tprivate Object convertSelection(ISelection selection) {\n\t\t\tObject element= SelectionUtil.getSingleElement(selection);\n\t\t\tif (!(element instanceof ISearchResultViewEntry))\n\t\t\t\treturn null;\n\t\t\tIMarker marker= ((ISearchResultViewEntry)element).getSelectedMarker();\n\t\t\ttry {\n\t\t\t\treturn JavaCore.create((String) ((IMarker) marker).getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));\t\n\t\t\t} catch (CoreException ex) {\n\t\t\t\tExceptionHandler.log(ex, SearchMessages.getString(\"Search.Error.createJavaElement.message\")); //$NON-NLS-1$\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic JavaSearchResultCollector() {\n\t\tfContextMenu= new ContextMenuContributor();\n\t}\n\n\t/**\n\t * @see IJavaSearchResultCollector#aboutToStart().\n\t */\n\tpublic void aboutToStart() {\n\t\tfView= SearchUI.getSearchResultView();\n\t\tfMatchCount= 0;\n\t\tif (fView != null) {\n\t\t\tfView.searchStarted(\n\t\t\t\tJavaSearchPage.EXTENSION_POINT_ID,\n\t\t\t\tfOperation.getDescription(),\n\t\t\t\tfOperation.getImageDescriptor(),\n\t\t\t\tfContextMenu,\n\t\t\t\tJavaSearchResultLabelProvider.INSTANCE,\n\t\t\t\tnew GotoMarkerAction(),\n\t\t\t\tnew GroupByKeyComputer(),\n\t\t\t\tfOperation);\n\t\t}\n\t\tif (!getProgressMonitor().isCanceled())\n\t\t\tgetProgressMonitor().subTask(SEARCHING);\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#accept\n\t */\n\tpublic void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException {\n\t\tIMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER);\n\t\tHashMap attributes;\n\t\tObject groupKey= enclosingElement;\n\t\tif (accuracy == POTENTIAL_MATCH) {\n\t\t\tattributes= new HashMap(6);\n\t\t\tattributes.put(IJavaSearchUIConstants.ATT_ACCURACY, POTENTIAL_MATCH_VALUE);\n\t\t\tif (groupKey == null)\n\t\t\t\tgroupKey= \"?:null\";\n\t\t\telse\n\t\t\t\tgroupKey= \"?:\" + enclosingElement.getHandleIdentifier();\n\t\t} else\n\t\t\tattributes= new HashMap(5);\n\t\tJavaCore.addJavaElementMarkerAttributes(attributes, enclosingElement);\n\t\tattributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, enclosingElement.getHandleIdentifier());\n\t\tattributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0)));\n\t\tattributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0)));\n\t\tif (enclosingElement instanceof IMember && ((IMember)enclosingElement).isBinary())\n\t\t\tattributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR);\n\t\telse\n\t\t\tattributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CU_EDITOR);\n\t\tmarker.setAttributes(attributes);\n\n\t\tfView.addMatch(enclosingElement.getElementName(), groupKey, resource, marker);\n\t\tfMatchCount++;\n\t\tif (!getProgressMonitor().isCanceled())\n\t\t\tgetProgressMonitor().subTask(getFormattedMatchesString(fMatchCount));\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#done().\n\t */\n\tpublic void done() {\n\t\tif (!getProgressMonitor().isCanceled()) {\n\t\t\tString matchesString= getFormattedMatchesString(fMatchCount);\n\t\t\tgetProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString}));\n\t\t}\n\n\t\tif (fView != null)\n\t\t\tfView.searchFinished();\n\n\t\t// Cut no longer unused references because the collector might be re-used\n\t\tfView= null;\n\t\tfMonitor= null;\n\t}\n\t\n\t/**\n\t * @see IJavaSearchResultCollector#getProgressMonitor().\n\t */\n\tpublic IProgressMonitor getProgressMonitor() {\n\t\treturn fMonitor;\n\t};\n\t\n\tvoid setProgressMonitor(IProgressMonitor pm) {\n\t\tfMonitor= pm;\n\t}\t\n\t\n\tvoid setOperation(JavaSearchOperation operation) {\n\t\tfOperation= operation;\n\t}\n\t\n\tprivate String getFormattedMatchesString(int count) {\n\t\tif (fMatchCount == 1)\n\t\t\treturn MATCH;\n\t\tfMessageFormatArgs[0]= new Integer(count);\n\t\treturn MessageFormat.format(MATCHES, fMessageFormatArgs);\n\n\t}\n\n\tprivate IWorkbenchWindow getWorbenchWindow() {\n\t\tIWorkbenchWindow wbWindow= null;\n\t\tif (fView != null && fView.getSite() != null)\n\t\t\twbWindow= fView.getSite().getWorkbenchWindow();\n\t\tif (wbWindow == null)\n\t\t\twbWindow= JavaPlugin.getActiveWorkbenchWindow();\n\t\treturn wbWindow;\n\t}\n}"}}},{"rowIdx":84,"cells":{"issue_id":{"kind":"number","value":4971,"string":"4,971"},"title":{"kind":"string","value":"Bug 4971 Strange 'copy package'"},"body":{"kind":"string","value":"203 1. Create a new project xxx 2. Package viewer: Select a package in project A e.g. org.eclipse.jdt.internal.ui in jdt.ui 3. From the context menu choose copy 4. Select xxx as destination 5. As result, xx contains a package 'ui'. Should be 'org.eclipse.jdt.internal.ui'"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"424380a"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T16:03:39Z","string":"2001-10-26T16:03:39Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-15T10:00:00Z","string":"2001-10-15T10:00:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/core"},"file_content":{"kind":"string","value":""}}},{"rowIdx":85,"cells":{"issue_id":{"kind":"number","value":4971,"string":"4,971"},"title":{"kind":"string","value":"Bug 4971 Strange 'copy package'"},"body":{"kind":"string","value":"203 1. Create a new project xxx 2. Package viewer: Select a package in project A e.g. org.eclipse.jdt.internal.ui in jdt.ui 3. From the context menu choose copy 4. Select xxx as destination 5. As result, xx contains a package 'ui'. Should be 'org.eclipse.jdt.internal.ui'"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"424380a"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-26T16:03:39Z","string":"2001-10-26T16:03:39Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-15T10:00:00Z","string":"2001-10-15T10:00:00Z"},"updated_file":{"kind":"string","value":"refactoring/org/eclipse/jdt/internal/core/refactoring/reorg/CopyRefactoring.java"},"file_content":{"kind":"string","value":""}}},{"rowIdx":86,"cells":{"issue_id":{"kind":"number","value":3348,"string":"3,348"},"title":{"kind":"string","value":"Bug 3348 DCR: Code formatter enhancement (1GIYHQR)"},"body":{"kind":"null"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"d723bdd"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T16:49:01Z","string":"2001-10-31T16:49:01Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeFormatterPreferencePage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.preferences;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.Hashtable;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.Text;\n\nimport org.eclipse.core.runtime.IStatus;\n\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.preference.PreferencePage;\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.source.SourceViewer;\n\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\nimport org.eclipse.ui.help.DialogPageContextComputer;\nimport org.eclipse.ui.help.WorkbenchHelp;\n\nimport org.eclipse.jdt.core.JavaCore;\n\nimport org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;\nimport org.eclipse.jdt.ui.text.JavaTextTools;\n\nimport org.eclipse.jdt.internal.formatter.CodeFormatter;\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jdt.internal.ui.JavaUIMessages;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusInfo;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusUtil;\nimport org.eclipse.jdt.internal.ui.util.TabFolderLayout;\n\n/*\n * The page for setting code formatter options\n */\npublic class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {\n\n\t// Preference store keys, see JavaCore.getOptions\n\tprivate static final String PREF_NEWLINE_OPENING_BRACES= \"org.eclipse.jdt.core.formatter.newline.openingBrace\";\n\tprivate static final String PREF_NEWLINE_CONTROL_STATEMENT= \"org.eclipse.jdt.core.formatter.newline.controlStatement\";\n\tprivate static final String PREF_NEWLINE_CLEAR_ALL= \"org.eclipse.jdt.core.formatter.newline.clearAll\";\n\tprivate static final String PREF_NEWLINE_ELSE_IF= \"org.eclipse.jdt.core.formatter.newline.elseIf\";\n\tprivate static final String PREF_NEWLINE_EMPTY_BLOCK= \"org.eclipse.jdt.core.formatter.newline.emptyBlock\";\n\tprivate static final String PREF_LINE_SPLIT= \"org.eclipse.jdt.core.formatter.lineSplit\";\t\n\tprivate static final String PREF_STYLE_COMPACT_ASSIGNEMENT= \"org.eclipse.jdt.core.formatter.style.assignment\";\t\n\tprivate static final String PREF_TAB_CHAR= \"org.eclipse.jdt.core.formatter.tabulation.char\";\t\n\tprivate static final String PREF_TAB_SIZE= \"org.eclipse.jdt.core.formatter.tabulation.size\";\n\n\t// values\n\tprivate static final String INSERT= \"insert\";\n\tprivate static final String DO_NOT_INSERT= \"do not insert\";\n\t\n\tprivate static final String COMPACT= \"compact\";\n\tprivate static final String NORMAL= \"normal\";\n\t\n\tprivate static final String TAB= \"tab\";\n\tprivate static final String SPACE= \"space\";\n\t\n\tprivate static final String CLEAR_ALL= \"clear all\";\n\tprivate static final String PRESERVE_ONE= \"preserve one\";\n\t\n\n\tprivate static String[] getAllKeys() {\n\t\treturn new String[] {\n\t\t\tPREF_NEWLINE_OPENING_BRACES, PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL,\n\t\t\tPREF_NEWLINE_ELSE_IF, PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT,\n\t\t\tPREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE\n\t\t};\t\n\t}\n\t\n\t/**\n\t * Gets the currently configured tab size\n\t */\n\tpublic static int getTabSize() {\n\t\tString string= (String) JavaCore.getOptions().get(PREF_TAB_SIZE);\n\t\treturn getIntValue(string, 4);\n\t}\n\t\n\t/**\n\t * Gets the current compating assignement configuration\n\t */\t\n\tpublic static boolean isCompactingAssignment() {\n\t\treturn COMPACT.equals(JavaCore.getOptions().get(PREF_STYLE_COMPACT_ASSIGNEMENT));\n\t}\n\t\n\t\n\tprivate static int getIntValue(String string, int dflt) {\n\t\ttry {\n\t\t\treturn Integer.parseInt(string);\n\t\t} catch (NumberFormatException e) {\n\t\t}\n\t\treturn dflt;\n\t}\t\n\t\t\n\t\n\t/**\n\t * Initializes the current options (read from preference store)\n\t */\n\tpublic static void initDefaults(IPreferenceStore store) {\n\t\tHashtable hashtable= JavaCore.getDefaultOptions();\n\t\tHashtable currOptions= JavaCore.getOptions();\n\t\tString[] allKeys= getAllKeys();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString defValue= (String) hashtable.get(key);\n\t\t\tif (defValue != null) {\n\t\t\t\tstore.setDefault(key, defValue);\n\t\t\t} else {\n\t\t\t\tJavaPlugin.logErrorMessage(\"CodeFormatterPreferencePage: value is null: \" + key);\n\t\t\t}\n\t\t\t// update the JavaCore options from the pref store\n\t\t\tString val= store.getString(key);\n\t\t\tif (val != null) {\n\t\t\t\tcurrOptions.put(key, val);\n\t\t\t}\t\t\t\n\t\t}\n\t\tJavaCore.setOptions(currOptions);\n\t}\n\n\tprivate static class ControlData {\n\t\tprivate String fKey;\n\t\tprivate String[] fValues;\n\t\t\n\t\tpublic ControlData(String key, String[] values) {\n\t\t\tfKey= key;\n\t\t\tfValues= values;\n\t\t}\n\t\t\n\t\tpublic String getKey() {\n\t\t\treturn fKey;\n\t\t}\n\t\t\n\t\tpublic String getValue(boolean selection) {\n\t\t\tint index= selection ? 0 : 1;\n\t\t\treturn fValues[index];\n\t\t}\n\t\t\n\t\tpublic String getValue(int index) {\n\t\t\treturn fValues[index];\n\t\t}\t\t\n\t\t\n\t\tpublic int getSelection(String value) {\n\t\t\tfor (int i= 0; i < fValues.length; i++) {\n\t\t\t\tif (value.equals(fValues[i])) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t}\n\t\n\tprivate Hashtable fWorkingValues;\n\n\tprivate ArrayList fCheckBoxes;\n\tprivate ArrayList fTextBoxes;\n\t\n\tprivate SelectionListener fButtonSelectionListener;\n\tprivate ModifyListener fTextModifyListener;\n\t\n\tprivate String fPreviewText;\n\tprivate IDocument fPreviewDocument;\n\t\n\tprivate Text fTabSizeTextBox;\n\t\n\n\tpublic CodeFormatterPreferencePage() {\n\t\tsetPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());\n\t\tsetDescription(JavaUIMessages.getString(\"CodeFormatterPreferencePage.description\")); //$NON-NLS-1$\n\t\n\t\tfWorkingValues= JavaCore.getOptions();\n\t\tfCheckBoxes= new ArrayList();\n\t\tfTextBoxes= new ArrayList();\n\t\t\n\t\tfButtonSelectionListener= new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {}\n\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (!e.widget.isDisposed()) {\n\t\t\t\t\tcontrolChanged((Button) e.widget);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\tfTextModifyListener= new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (!e.widget.isDisposed()) {\n\t\t\t\t\ttextChanged((Text) e.widget);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\tfPreviewDocument= new Document();\n\t\tfPreviewText= loadPreviewFile(\"CodeFormatterPreviewCode.txt\");\t//$NON-NLS-1$\t\n\t}\n\n\t/*\n\t * @see IWorkbenchPreferencePage#init()\n\t */\t\n\tpublic void init(IWorkbench workbench) {\n\t}\n\n\t/*\n\t * @see PreferencePage#createControl(Composite)\n\t */\n\tpublic void createControl(Composite parent) {\n\t\tsuper.createControl(parent);\n\t\tWorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE));\n\t}\t\n\n\t/*\n\t * @see PreferencePage#createContents(Composite)\n\t */\n\tprotected Control createContents(Composite parent) {\n\t\t\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.marginHeight= 0;\n\t\tlayout.marginWidth= 0;\n\t\t\n\t\tComposite composite= new Composite(parent, SWT.NONE);\n\t\tcomposite.setLayout(layout);\n\t\t\t\t\n\t\t\t\n\t\tTabFolder folder= new TabFolder(composite, SWT.NONE);\n\t\tfolder.setLayout(new TabFolderLayout());\t\n\t\tfolder.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tString[] insertNotInsert= new String[] { INSERT, DO_NOT_INSERT };\n\t\t\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\t\t\n\t\tComposite newlineComposite= new Composite(folder, SWT.NULL);\n\t\tnewlineComposite.setLayout(layout);\n\n\t\tString label= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_opening_braces.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_OPENING_BRACES, insertNotInsert);\t\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_control_statement.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_CONTROL_STATEMENT, insertNotInsert);\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_clear_lines\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_CLEAR_ALL, new String[] { CLEAR_ALL, PRESERVE_ONE } );\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_else_if.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert);\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_empty_block.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_EMPTY_BLOCK, insertNotInsert);\t\n\t\t\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\t\n\t\t\n\t\tComposite lineSplittingComposite= new Composite(folder, SWT.NULL);\n\t\tlineSplittingComposite.setLayout(layout);\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.split_line.label\"); //$NON-NLS-1$\n\t\taddTextField(lineSplittingComposite, label, PREF_LINE_SPLIT);\n\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\t\n\t\t\n\t\tComposite styleComposite= new Composite(folder, SWT.NULL);\n\t\tstyleComposite.setLayout(layout);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.style_compact_assignement.label\"); //$NON-NLS-1$\n\t\taddCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ASSIGNEMENT, new String[] { COMPACT, NORMAL } );\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab_char.label\"); //$NON-NLS-1$\n\t\taddCheckBox(styleComposite, label, PREF_TAB_CHAR, new String[] { TAB, SPACE } );\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab_size.label\"); //$NON-NLS-1$\n\t\tfTabSizeTextBox= addTextField(styleComposite, label, PREF_TAB_SIZE);\t\t\n\t\tfTabSizeTextBox.setEnabled(!usesTabs());\n\n\t\tTabItem item= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.newline.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL));\n\t\titem.setControl(newlineComposite);\n\n\t\titem= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.linesplit.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));\n\t\titem.setControl(lineSplittingComposite);\n\t\t\n\t\titem= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.style.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_REF));\n\t\titem.setControl(styleComposite);\t\t\n\t\t\n\t\tcreatePreview(parent);\n\t\t\t\n\t\tupdatePreview();\n\t\t\t\t\t\n\t\treturn composite;\n\t}\n\t\n\tprivate Control createPreview(Composite parent) {\n\t\tSourceViewer previewViewer= new SourceViewer(parent, null, SWT.V_SCROLL);\n\t\tJavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();\n\t\tpreviewViewer.configure(new JavaSourceViewerConfiguration(tools, null));\n\t\tpreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));\n\t\tpreviewViewer.setEditable(false);\n\t\tpreviewViewer.setDocument(fPreviewDocument);\n\t\tControl control= previewViewer.getControl();\n\t\tcontrol.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\treturn control;\n\t}\n\n\t\n\tprivate Button addCheckBox(Composite parent, String label, String key, String[] values) {\n\t\tControlData data= new ControlData(key, values);\n\t\t\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan= 2;\n\t\t\n\t\tButton checkBox= new Button(parent, SWT.CHECK);\n\t\tcheckBox.setText(label);\n\t\tcheckBox.setData(data);\n\t\tcheckBox.setLayoutData(gd);\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\tcheckBox.setSelection(data.getSelection(currValue) == 0);\n\t\tcheckBox.addSelectionListener(fButtonSelectionListener);\n\t\t\n\t\tfCheckBoxes.add(checkBox);\n\t\treturn checkBox;\n\t}\n\t\n\tprivate Text addTextField(Composite parent, String label, String key) {\t\n\t\tLabel labelControl= new Label(parent, SWT.NONE);\n\t\tlabelControl.setText(label);\n\t\tlabelControl.setLayoutData(new GridData());\n\t\t\t\t\n\t\tText textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);\n\t\ttextBox.setData(key);\n\t\ttextBox.setLayoutData(new GridData());\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\ttextBox.setText(String.valueOf(getIntValue(currValue, 1)));\n\t\ttextBox.setTextLimit(3);\n\t\ttextBox.addModifyListener(fTextModifyListener);\n\n\t\tGridData gd= new GridData();\n\t\tgd.widthHint= convertWidthInCharsToPixels(5);\n\t\ttextBox.setLayoutData(gd);\n\n\t\tfTextBoxes.add(textBox);\n\t\treturn textBox;\n\t}\t\n\t\n\tprivate void controlChanged(Button button) {\n\t\tControlData data= (ControlData) button.getData();\n\t\tboolean selection= button.getSelection();\n\t\tString newValue= data.getValue(selection);\t\n\t\tfWorkingValues.put(data.getKey(), newValue);\n\t\tupdatePreview();\n\t\t\n\t\tif (PREF_TAB_CHAR.equals(data.getKey())) {\n\t\t\tfTabSizeTextBox.setEnabled(!selection);\n\t\t\tupdateStatus(new StatusInfo());\n\t\t\tif (selection) {\n\t\t\t\tfTabSizeTextBox.setText((String)fWorkingValues.get(PREF_TAB_SIZE));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void textChanged(Text textControl) {\n\t\tString key= (String) textControl.getData();\n\t\tString number= textControl.getText();\n\t\tIStatus status= validatePositiveNumber(number);\n\t\tif (!status.matches(IStatus.ERROR)) {\n\t\t\tfWorkingValues.put(key, number);\n\t\t}\n\t\tupdateStatus(status);\n\t\tupdatePreview();\n\t}\n\t\t\n\t\n\t/*\n\t * @see IPreferencePage#performOk()\n\t */\n\tpublic boolean performOk() {\n\t\tString[] allKeys= getAllKeys();\n\t\t// preserve other options\n\t\t// store in JCore and the preferences\n\t\tHashtable actualOptions= JavaCore.getOptions();\n\t\tIPreferenceStore store= getPreferenceStore();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString val= (String) fWorkingValues.get(key);\n\t\t\tactualOptions.put(key, val);\n\t\t\tstore.putValue(key, val);\n\t\t}\n\t\tJavaCore.setOptions(actualOptions);\n\t\treturn super.performOk();\n\t}\t\n\t\n\t/*\n\t * @see PreferencePage#performDefaults()\n\t */\n\tprotected void performDefaults() {\n\t\tfWorkingValues= JavaCore.getDefaultOptions();\n\t\tupdateControls();\n\t\tsuper.performDefaults();\n\t}\n\n\tprivate String loadPreviewFile(String filename) {\n\t\tString separator= System.getProperty(\"line.separator\"); //$NON-NLS-1$\n\t\tStringBuffer btxt= new StringBuffer(512);\n\t\tBufferedReader rin= null;\n\t\ttry {\n\t\t\trin= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));\n\t\t\tString line;\n\t\t\twhile ((line= rin.readLine()) != null) {\n\t\t\t\tbtxt.append(line);\n\t\t\t\tbtxt.append(separator);\n\t\t\t}\n\t\t} catch (IOException io) {\n\t\t\tJavaPlugin.log(io);\n\t\t} finally {\n\t\t\tif (rin != null) {\n\t\t\t\ttry { rin.close(); } catch (IOException e) {}\n\t\t\t}\n\t\t}\n\t\treturn btxt.toString();\n\t}\n\n\n\tprivate void updatePreview() {\n\t\tfPreviewDocument.set(CodeFormatter.format(fPreviewText, 0, fWorkingValues));\n\t}\t\n\t\n\tprivate void updateControls() {\n\t\t// update the UI\n\t\tfor (int i= fCheckBoxes.size() - 1; i >= 0; i--) {\n\t\t\tButton curr= (Button) fCheckBoxes.get(i);\n\t\t\tControlData data= (ControlData) curr.getData();\n\t\t\t\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(data.getKey());\t\n\t\t\tcurr.setSelection(data.getSelection(currValue) == 0);\t\t\t\n\t\t}\n\t\tfor (int i= fTextBoxes.size() - 1; i >= 0; i--) {\n\t\t\tText curr= (Text) fTextBoxes.get(i);\n\t\t\tString key= (String) curr.getData();\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(key);\n\t\t\tcurr.setText(currValue);\n\t\t}\n\t\tfTabSizeTextBox.setEnabled(!usesTabs());\t\n\t}\n\t\n\tprivate IStatus validatePositiveNumber(String number) {\n\t\tStatusInfo status= new StatusInfo();\n\t\tif (number.length() == 0) {\n\t\t\tstatus.setError(JavaUIMessages.getString(\"CodeFormatterPreferencePage.empty_input\"));\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tint value= Integer.parseInt(number);\n\t\t\t\tif (value < 0) {\n\t\t\t\t\tstatus.setError(JavaUIMessages.getFormattedString(\"CodeFormatterPreferencePage.invalid_input\", number));\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tstatus.setError(JavaUIMessages.getFormattedString(\"CodeFormatterPreferencePage.invalid_input\", number));\n\t\t\t}\n\t\t}\n\t\treturn status;\n\t}\n\t\t\t\n\t\n\tprivate void updateStatus(IStatus status) {\n\t\tif (!status.matches(IStatus.ERROR)) {\n\t\t\t// look if there are more severe errors\n\t\t\tfor (int i= 0; i < fTextBoxes.size(); i++) {\n\t\t\t\tText curr= (Text) fTextBoxes.get(i);\n\t\t\t\tif (!(curr == fTabSizeTextBox && usesTabs())) {\n\t\t\t\t\tIStatus currStatus= validatePositiveNumber(curr.getText());\n\t\t\t\t\tstatus= StatusUtil.getMoreSevere(currStatus, status);\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\tsetValid(!status.matches(IStatus.ERROR));\n\t\tStatusUtil.applyToStatusLine(this, status);\n\t}\n\t\n\tprivate boolean usesTabs() {\n\t\treturn TAB.equals(fWorkingValues.get(PREF_TAB_CHAR));\n\t}\n\t\t\n\n}\n\n\n"}}},{"rowIdx":87,"cells":{"issue_id":{"kind":"number","value":3348,"string":"3,348"},"title":{"kind":"string","value":"Bug 3348 DCR: Code formatter enhancement (1GIYHQR)"},"body":{"kind":"null"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"d723bdd"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T16:49:01Z","string":"2001-10-31T16:49:01Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.text.java;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.DefaultAutoIndentStrategy;\nimport org.eclipse.jface.text.DocumentCommand;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IDocumentPartitioner;\nimport org.eclipse.jface.text.ITypedRegion;\n\nimport org.eclipse.jdt.internal.ui.text.JavaPartitionScanner;\n\n/**\n * Auto indent strategy sensitive to brackets.\n */\npublic class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy {\n\n\tpublic JavaAutoIndentStrategy() {\n\t}\n\n\t// evaluate the line with the opening bracket that matches the closing bracket on the given line\n\tprotected int findMatchingOpenBracket(IDocument d, int line, int end, int closingBracketIncrease) throws BadLocationException {\n\n\t\tint start= d.getLineOffset(line);\n\t\tint brackcount= getBracketCount(d, start, end, false) - closingBracketIncrease;\n\n\t\t// sum up the brackets counts of each line (closing brackets count negative, \n\t\t// opening positive) until we find a line the brings the count to zero\n\t\twhile (brackcount < 0) {\n\t\t\tline--;\n\t\t\tif (line < 0) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tstart= d.getLineOffset(line);\n\t\t\tend= start + d.getLineLength(line) - 1;\n\t\t\tbrackcount += getBracketCount(d, start, end, false);\n\t\t}\n\t\treturn line;\n\t}\n\n\tprivate int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {\n\n\t\tint bracketcount= 0;\n\t\twhile (start < end) {\n\t\t\tchar curr= d.getChar(start);\n\t\t\tstart++;\n\t\t\tswitch (curr) {\n\t\t\t\tcase '/' :\n\t\t\t\t\tif (start < end) {\n\t\t\t\t\t\tchar next= d.getChar(start);\n\t\t\t\t\t\tif (next == '*') {\n\t\t\t\t\t\t\t// a comment starts, advance to the comment end\n\t\t\t\t\t\t\tstart= getCommentEnd(d, start + 1, end);\n\t\t\t\t\t\t} else if (next == '/') {\n\t\t\t\t\t\t\t// '//'-comment: nothing to do anymore on this line \n\t\t\t\t\t\t\tstart= end;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '*' :\n\t\t\t\t\tif (start < end) {\n\t\t\t\t\t\tchar next= d.getChar(start);\n\t\t\t\t\t\tif (next == '/') {\n\t\t\t\t\t\t\t// we have been in a comment: forget what we read before\n\t\t\t\t\t\t\tbracketcount= 0;\n\t\t\t\t\t\t\tstart++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '{' :\n\t\t\t\t\tbracketcount++;\n\t\t\t\t\tignoreCloseBrackets= false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '}' :\n\t\t\t\t\tif (!ignoreCloseBrackets) {\n\t\t\t\t\t\tbracketcount--;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '\"' :\n\t\t\t\tcase '\\'' :\n\t\t\t\t\tstart= getStringEnd(d, start, end, curr);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault :\n\t\t\t\t\t}\n\t\t}\n\t\treturn bracketcount;\n\t}\n\n\t// ----------- bracket counting ------------------------------------------------------\n\n\tprivate int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {\n\t\twhile (pos < end) {\n\t\t\tchar curr= d.getChar(pos);\n\t\t\tpos++;\n\t\t\tif (curr == '*') {\n\t\t\t\tif (pos < end && d.getChar(pos) == '/') {\n\t\t\t\t\treturn pos + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn end;\n\t}\n\n\tprotected String getIndentOfLine(IDocument d, int line) throws BadLocationException {\n\t\tif (line > -1) {\n\t\t\tint start= d.getLineOffset(line);\n\t\t\tint end= start + d.getLineLength(line) - 1;\n\t\t\tint whiteend= findEndOfWhiteSpace(d, start, end);\n\t\t\treturn d.get(start, whiteend - start);\n\t\t} else {\n\t\t\treturn \"\"; //$NON-NLS-1$\n\t\t}\n\t}\n\n\tprivate int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {\n\t\twhile (pos < end) {\n\t\t\tchar curr= d.getChar(pos);\n\t\t\tpos++;\n\t\t\tif (curr == '\\\\') {\n\t\t\t\t// ignore escaped characters\n\t\t\t\tpos++;\n\t\t\t} else if (curr == ch) {\n\t\t\t\treturn pos;\n\t\t\t}\n\t\t}\n\t\treturn end;\n\t}\n\n\tprotected void smartInsertAfterBracket(IDocument d, DocumentCommand c) {\n\t\tif (c.offset == -1 || d.getLength() == 0)\n\t\t\treturn;\n\n\t\ttry {\n\t\t\tint p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);\n\t\t\tint line= d.getLineOfOffset(p);\n\t\t\tint start= d.getLineOffset(line);\n\t\t\tint whiteend= findEndOfWhiteSpace(d, start, c.offset);\n\n\t\t\t// shift only when line does not contain any text up to the closing bracket\n\t\t\tif (whiteend == c.offset) {\n\t\t\t\t// evaluate the line with the opening bracket that matches out closing bracket\n\t\t\t\tint indLine= findMatchingOpenBracket(d, line, c.offset, 1);\n\t\t\t\tif (indLine != -1 && indLine != line) {\n\t\t\t\t\t// take the indent of the found line\n\t\t\t\t\tStringBuffer replaceText= new StringBuffer(getIndentOfLine(d, indLine));\n\t\t\t\t\t// add the rest of the current line including the just added close bracket\n\t\t\t\t\treplaceText.append(d.get(whiteend, c.offset - whiteend));\n\t\t\t\t\treplaceText.append(c.text);\n\t\t\t\t\t// modify document command\n\t\t\t\t\tc.length += c.offset - start;\n\t\t\t\t\tc.offset= start;\n\t\t\t\t\tc.text= replaceText.toString();\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (BadLocationException excp) {\n\t\t\tSystem.out.println(JavaTextMessages.getString(\"AutoIndent.error.bad_location.message1\")); //$NON-NLS-1$\n\t\t}\n\t}\n\n\tprotected void smartIndentAfterNewLine(IDocument d, DocumentCommand c) {\n\n\t\tint docLength= d.getLength();\n\t\tif (c.offset == -1 || docLength == 0)\n\t\t\treturn;\n\n\t\ttry {\n\t\t\tint p= (c.offset == docLength ? c.offset - 1 : c.offset);\n\t\t\tint line= d.getLineOfOffset(p);\n\n\t\t\tStringBuffer buf= new StringBuffer(c.text);\n\t\t\tif (c.offset < docLength && d.getChar(c.offset) == '}') {\n\t\t\t\tint indLine= findMatchingOpenBracket(d, line, c.offset, 0);\n\t\t\t\tif (indLine == -1) {\n\t\t\t\t\tindLine= line;\n\t\t\t\t}\n\t\t\t\tbuf.append(getIndentOfLine(d, indLine));\n\t\t\t} else {\n\t\t\t\tint start= d.getLineOffset(line);\n\t\t\t\t// if line just ended a javadoc comment, take the indent from the comment's begin line\n\t\t\t\tIDocumentPartitioner partitioner= d.getDocumentPartitioner();\n\t\t\t\tif (partitioner != null) {\n\t\t\t\t\tITypedRegion region= partitioner.getPartition(start);\n\t\t\t\t\tif (JavaPartitionScanner.JAVA_DOC.equals(region.getType()))\n\t\t\t\t\t\tstart= d.getLineInformationOfOffset(region.getOffset()).getOffset();\n\t\t\t\t}\t\t\t\t\n\t\t\t\tint whiteend= findEndOfWhiteSpace(d, start, c.offset);\n\t\t\t\tbuf.append(d.get(start, whiteend - start));\n\t\t\t\tif (getBracketCount(d, start, c.offset, true) > 0) {\n\t\t\t\t\tbuf.append('\\t');\n\t\t\t\t}\n\t\t\t}\n\t\t\tc.text= buf.toString();\n\n\t\t} catch (BadLocationException excp) {\n\t\t\tSystem.out.println(JavaTextMessages.getString(\"AutoIndent.error.bad_location.message2\")); //$NON-NLS-1$\n\t\t}\n\t}\n\t\n\t/**\n\t * Returns whether the text ends with one of the given search strings.\n\t */\n\tprivate boolean endsWithDelimiter(IDocument d, String txt) {\n\t\t\n\t\tString[] delimiters= d.getLegalLineDelimiters();\n\t\t\n\t\tfor (int i= 0; i < delimiters.length; i++) {\n\t\t\tif (txt.endsWith(delimiters[i]))\n\t\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\t\n\n\t/**\n\t * @see IAutoIndentStrategy#customizeDocumentCommand\n\t */\n\tpublic void customizeDocumentCommand(IDocument d, DocumentCommand c) {\n\t\tif (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text))\n\t\t\tsmartIndentAfterNewLine(d, c);\n\t\telse if (\"}\".equals(c.text)) { //$NON-NLS-1$\n\t\t\tsmartInsertAfterBracket(d, c);\n\t\t}\n\t}\n}\n"}}},{"rowIdx":88,"cells":{"issue_id":{"kind":"number","value":5340,"string":"5,340"},"title":{"kind":"string","value":"Bug 5340 Cancelling add exception breakpoint has no effect"},"body":{"kind":"string","value":"1) Go to the breakpoints pane in the debug perspective 2) Click the J! button to add an exception 3) In the progress dialog, click cancel. The progress dialog closes immediately 4) Eventually the exception list comes up, it ignored the cancelation request. It should either honour the cancellation request or diable the cancel button (when calling ProgressMonitorDialog.run pass false for the canceleable parameter)."},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"8cf182b"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T17:03:12Z","string":"2001-10-31T17:03:12Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-29T21:13:20Z","string":"2001-10-29T21:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/launcher/AddExceptionDialog.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.launcher;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.List;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.swt.widgets.Text;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.IStatus;\nimport org.eclipse.core.runtime.Status;\n\nimport org.eclipse.jface.dialogs.IDialogSettings;\nimport org.eclipse.jface.dialogs.ProgressMonitorDialog;\nimport org.eclipse.jface.operation.IRunnableWithProgress;\n\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.ITypeHierarchy;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.search.SearchEngine;\n\nimport org.eclipse.jdt.ui.IJavaElementSearchConstants;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.dialogs.FilteredList;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusDialog;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusInfo;\nimport org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine;\nimport org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\nimport org.eclipse.jdt.internal.ui.util.TypeInfo;\nimport org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;\n\n/**\n * Lots of stuff commented out because pending API change in \n * Debugger\n */\npublic class AddExceptionDialog extends StatusDialog {\n\t\n\tprivate static final String DIALOG_SETTINGS= \"AddExceptionDialog\"; //$NON-NLS-1$\n\tprivate static final String SETTING_CAUGHT_CHECKED= \"caughtChecked\"; //$NON-NLS-1$\n\tprivate static final String SETTING_UNCAUGHT_CHECKED= \"uncaughtChecked\"; //$NON-NLS-1$\n\n\tprivate Text fFilterText;\n\tprivate FilteredList fTypeList;\n\tprivate boolean fTypeListInitialized= false;\n\t\n\tprivate Button fCaughtBox;\n\tprivate Button fUncaughtBox;\n\t\n\tpublic static final int CHECKED_EXCEPTION= 0;\n\tpublic static final int UNCHECKED_EXCEPTION= 1;\n\tpublic static final int NO_EXCEPTION= -1;\n\t\n\tprivate SelectionListener fListListener= new SelectionAdapter() {\n\t\tpublic void widgetSelected(SelectionEvent evt) {\n\t\t\tvalidateListSelection();\n\t\t}\n\t\t\n\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\tvalidateListSelection();\n\t\t\tif (getStatus().isOK())\n\t\t\t\tokPressed();\n\t\t}\n\t};\n\t\t\n\tprivate Object fResult;\n\tprivate int fExceptionType= NO_EXCEPTION;\n\tprivate boolean fIsCaughtSelected= true;\n\tprivate boolean fIsUncaughtSelected= true;\n\t/**\n\t * Constructor for AddExceptionDialog\n\t */\n\tpublic AddExceptionDialog(Shell parentShell) {\n\t\tsuper(parentShell);\n\t\tsetTitle(LauncherMessages.getString(\"AddExceptionDialog.title\")); //$NON-NLS-1$\n\t}\n\t\n\tprotected Control createDialogArea(Composite ancestor) {\n\t\tinitFromDialogSettings();\n\n\t\tComposite parent= new Composite(ancestor, SWT.NULL);\n\t\tGridLayout layout= new GridLayout();\n\t\tparent.setLayout(layout);\n\t\t\n\t\tLabel l= new Label(parent, SWT.NULL);\n\t\tl.setLayoutData(new GridData());\n\t\tl.setText(LauncherMessages.getString(\"AddExceptionDialog.message\")); //$NON-NLS-1$\n\n\t\tfFilterText = new Text(parent, SWT.BORDER);\t\t\n\n\t\tGridData data= new GridData();\n\t\tdata.grabExcessVerticalSpace= false;\n\t\tdata.grabExcessHorizontalSpace= true;\n\t\tdata.horizontalAlignment= GridData.FILL;\n\t\tdata.verticalAlignment= GridData.BEGINNING;\n\t\tfFilterText.setLayoutData(data);\n\t\t\t\t\n\t\tListener listener= new Listener() {\n\t\t\tpublic void handleEvent(Event e) {\n\t\t\t\tfTypeList.setFilter(fFilterText.getText());\n\t\t\t}\n\t\t};\t\t\n\t\tfFilterText.addListener(SWT.Modify, listener);\t\t\t\t\t\t\t\t\n\t\t\n\t\tfTypeList= new FilteredList(parent, SWT.BORDER | SWT.SINGLE, \n\t\t\t\tnew TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_PACKAGE_POSTFIX),\n\t\t\t\ttrue, true, true);\n\n\t\tGridData gd= new GridData(GridData.FILL_BOTH);\n\t\t//gd.horizontalIndent= convertWidthInCharsToPixels(4);\n\t\tgd.widthHint= convertWidthInCharsToPixels(65);\n\t\tgd.heightHint= convertHeightInCharsToPixels(20);\n\t\tfTypeList.setLayoutData(gd);\t\t\t\t\n\t\t\n\t\tfCaughtBox= new Button(parent, SWT.CHECK);\n\t\tfCaughtBox.setLayoutData(new GridData());\n\t\tfCaughtBox.setText(LauncherMessages.getString(\"AddExceptionDialog.caught\")); //$NON-NLS-1$\n\t\tfCaughtBox.setSelection(fIsCaughtSelected);\n\t\t\n\t\tfUncaughtBox= new Button(parent, SWT.CHECK);\n\t\tfUncaughtBox.setLayoutData(new GridData());\n\t\t// fix: 1GEUWCI: ITPDUI:Linux - Add Exception box has confusing checkbox\n\t\tfUncaughtBox.setText(LauncherMessages.getString(\"AddExceptionDialog.uncaught\")); //$NON-NLS-1$\n\t\t// end fix.\n\t\tfUncaughtBox.setSelection(fIsUncaughtSelected);\n\t\t\n\t\taddFromListSelected(true);\n\t\treturn parent;\n\t}\n\t\t\n\tpublic void addFromListSelected(boolean selected) {\n\t\tfTypeList.setEnabled(selected);\n\t\tif (selected) {\n\t\t\tif (!fTypeListInitialized) {\n\t\t\t\tinitializeTypeList();\n\t\t\t}\n\t\t\tfTypeList.addSelectionListener(fListListener);\n\t\t\tvalidateListSelection();\n\t\t} else\n\t\t\tfTypeList.removeSelectionListener(fListListener);\n\t}\n\t\n\tprotected void okPressed() {\n\t\tTypeInfo typeRef= (TypeInfo)fTypeList.getSelection()[0];\n\t\tIType resolvedType= null;\n\t\ttry {\n\t\t\tresolvedType= typeRef.resolveType(SearchEngine.createWorkspaceScope());\n\t\t} catch (JavaModelException e) {\n\t\t\tupdateStatus(e.getStatus());\n\t\t\treturn;\n\t\t}\n\t\tfExceptionType= getExceptionType(resolvedType);\n\t\tif (fExceptionType == NO_EXCEPTION) {\n\t\t\tStatusInfo status= new StatusInfo();\n\t\t\tstatus.setError(LauncherMessages.getString(\"AddExceptionDialog.error.notThrowable\")); //$NON-NLS-1$\n\t\t\tupdateStatus(status);\n\t\t\treturn;\n\t\t}\n\t\tfIsCaughtSelected= fCaughtBox.getSelection();\n\t\tfIsUncaughtSelected= fUncaughtBox.getSelection();\n\t\tfResult= resolvedType;\n\t\t\n\t\tsaveDialogSettings();\n\t\t\n\t\tsuper.okPressed();\n\t}\n\t\n\tprivate int getExceptionType(final IType type) {\n\t\tfinal int[] result= new int[] { NO_EXCEPTION };\n\t\n\t\tBusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();\n\t\tIRunnableWithProgress runnable= new IRunnableWithProgress() {\n\t\t\tpublic void run(IProgressMonitor pm) {\n\t\t\t\ttry {\n\t\t\t\t\tITypeHierarchy hierarchy= type.newSupertypeHierarchy(pm);\n\t\t\t\t\tIType curr= type;\n\t\t\t\t\twhile (curr != null) {\n\t\t\t\t\t\tString name= JavaModelUtil.getFullyQualifiedName(curr);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (\"java.lang.Throwable\".equals(name)) { //$NON-NLS-1$\n\t\t\t\t\t\t\tresult[0]= CHECKED_EXCEPTION;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\"java.lang.RuntimeException\".equals(name) || \"java.lang.Error\".equals(name)) { //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\t\t\tresult[0]= UNCHECKED_EXCEPTION;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurr= hierarchy.getSuperclass(curr);\n\t\t\t\t\t}\n\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\tJavaPlugin.log(e);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\ttry {\t\t\n\t\t\tcontext.run(false, false, runnable);\n\t\t} catch (InterruptedException e) {\n\t\t} catch (InvocationTargetException e) {\n\t\t\tJavaPlugin.log(e);\n\t\t}\n\n\t\treturn result[0];\n\t}\n\t\n\tpublic Object getResult() {\n\t\treturn fResult;\n\t}\n\t\n\tpublic int getExceptionType() {\n\t\treturn fExceptionType;\n\t}\n\t\n\tpublic boolean isCaughtSelected() {\n\t\treturn fIsCaughtSelected;\n\t}\n\t\n\tpublic boolean isUncaughtSelected() {\n\t\treturn fIsUncaughtSelected;\n\t}\n\t\n\tpublic void initializeTypeList() {\n\t\tAllTypesSearchEngine searchEngine= new AllTypesSearchEngine(JavaPlugin.getWorkspace());\n\t\tint flags= IJavaElementSearchConstants.CONSIDER_BINARIES |\n\t\t\t\t\tIJavaElementSearchConstants.CONSIDER_CLASSES |\n\t\t\t\t\tIJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS;\n\t\tList result= searchEngine.searchTypes(new ProgressMonitorDialog(getShell()), SearchEngine.createWorkspaceScope(), flags);\n\t\tfFilterText.setText(\"*Exception*\"); //$NON-NLS-1$\n\t\tfTypeList.setElements(result.toArray()); // XXX inefficient\n\t\tfTypeListInitialized= true;\n\t}\n\t\n\tprivate void validateListSelection() {\n\t\tStatusInfo status= new StatusInfo();\n\t\tif (fTypeList.getSelection().length != 1) {\n\t\t\tstatus.setError(LauncherMessages.getString(\"AddExceptionDialog.error.noSelection\")); //$NON-NLS-1$\n\t\t}\n\t\tupdateStatus(status);\n\t}\n\t\n\tprivate void initFromDialogSettings() {\n\t\tIDialogSettings allSetttings= JavaPlugin.getDefault().getDialogSettings();\n\t\tIDialogSettings section= allSetttings.getSection(DIALOG_SETTINGS);\n\t\tif (section == null) {\n\t\t\tsection= allSetttings.addNewSection(DIALOG_SETTINGS);\n\t\t\tsection.put(SETTING_CAUGHT_CHECKED, true);\n\t\t\tsection.put(SETTING_UNCAUGHT_CHECKED, true);\n\t\t}\n\t\tfIsCaughtSelected= section.getBoolean(SETTING_CAUGHT_CHECKED);\n\t\tfIsUncaughtSelected= section.getBoolean(SETTING_UNCAUGHT_CHECKED);\n\t}\n\t\n\tprivate void saveDialogSettings() {\n\t\tIDialogSettings allSetttings= JavaPlugin.getDefault().getDialogSettings();\n\t\tIDialogSettings section= allSetttings.getSection(DIALOG_SETTINGS);\n\t\t// won't be null since we initialize it in the method above.\n\t\tsection.put(SETTING_CAUGHT_CHECKED, fIsCaughtSelected);\n\t\tsection.put(SETTING_UNCAUGHT_CHECKED, fIsUncaughtSelected);\n\t}\n\t\n\tpublic void create() {\n\t\tsuper.create();\n\t\tfFilterText.selectAll();\n\t\tfFilterText.setFocus();\n\t}\n}\n"}}},{"rowIdx":89,"cells":{"issue_id":{"kind":"number","value":5165,"string":"5,165"},"title":{"kind":"string","value":"Bug 5165 package viewer project sorting"},"body":{"kind":"string","value":"i have a (library) project Refactoring Tests Resources and other projects org.eclipse.... before 205 they used to be sorted alphabetically now they're not. is that intentional?"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"21646f3"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T17:03:20Z","string":"2001-10-31T17:03:20Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-23T09:40:00Z","string":"2001-10-23T09:40:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementSorter.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.viewsupport;\n\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerSorter;\n\nimport org.eclipse.core.resources.IContainer;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.IStorage;\nimport org.eclipse.jdt.core.Flags;\nimport org.eclipse.jdt.core.IClasspathEntry;\nimport org.eclipse.jdt.core.IField;\nimport org.eclipse.jdt.core.IInitializer;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\n\n/**\n * Sorts Java elements:\n * Package fragment roots are sorted as ordered in the classpath.\n */\npublic class JavaElementSorter extends ViewerSorter {\n\t\n\tprivate static final int CU_MEMBERS=\t0;\n\tprivate static final int INNER_TYPES=\t1;\n\tprivate static final int CONSTRUCTORS=\t2;\n\tprivate static final int STATIC_INIT= 3;\n\tprivate static final int STATIC_METHODS= 4;\n\tprivate static final int INIT= 5;\n\tprivate static final int METHODS= 6;\n\tprivate static final int STATIC_FIELDS= 7;\n\tprivate static final int FIELDS= 8;\n\tprivate static final int JAVAELEMENTS= 9;\n\tprivate static final int PACKAGEFRAGMENTROOT= 10;\n\tprivate static final int RESOURCEPACKAGES= 11;\n\tprivate static final int RESOURCEFOLDERS= 12;\n\tprivate static final int RESOURCES= 13;\n\tprivate static final int STORAGE= 14;\n\t\n\tprivate static final int OTHERS= 20;\t\n\n\tprivate IClasspathEntry[] fClassPath;\n\n\t/*\n\t * @see ViewerSorter#sort\n\t */\n\tpublic void sort(Viewer v, Object[] property) {\n\t\tfClassPath= null;\n\t\ttry {\n\t\t\tsuper.sort(v, property);\n\t\t} finally {\n\t\t\tfClassPath= null;\n\t\t}\n\t}\n\t\n\t/*\n\t * @see ViewerSorter#isSorterProperty\n\t */\t\t\n\tpublic boolean isSorterProperty(Object element, Object property) {\n\t\treturn true;\n\t}\n\n\t/*\n\t * @see ViewerSorter#category\n\t */\t\n\tpublic int category(Object element) {\n\t\tif (element instanceof IJavaElement) {\n\t\t\ttry {\n\t\t\t\tIJavaElement je= (IJavaElement) element;\n\t\t\t\t\n\t\t\t\tswitch (je.getElementType()) {\n\t\t\t\t\tcase IJavaElement.METHOD: {\n\t\t\t\t\t\tIMethod method= (IMethod) je;\n\t\t\t\t\t\tif (method.isConstructor())\n\t\t\t\t\t\t\treturn CONSTRUCTORS;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tint flags= method.getFlags();\n\t\t\t\t\t\treturn Flags.isStatic(flags) ? STATIC_METHODS : METHODS;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase IJavaElement.FIELD: {\n\t\t\t\t\t\tint flags= ((IField) je).getFlags();\n\t\t\t\t\t\treturn Flags.isStatic(flags) ? STATIC_FIELDS : FIELDS;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase IJavaElement.INITIALIZER: {\n\t\t\t\t\t\tint flags= ((IInitializer) je).getFlags();\n\t\t\t\t\t\treturn Flags.isStatic(flags) ? STATIC_INIT : INIT;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase IJavaElement.TYPE: {\n\t\t\t\t\t\tif (((IType)element).getDeclaringType() != null) {\n\t\t\t\t\t\t\treturn INNER_TYPES;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn CU_MEMBERS;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcase IJavaElement.PACKAGE_DECLARATION:\n\t\t\t\t\t\treturn CU_MEMBERS;\n\t\t\t\t\tcase IJavaElement.IMPORT_CONTAINER:\n\t\t\t\t\t\treturn CU_MEMBERS;\n\t\t\t\t\tcase IJavaElement.PACKAGE_FRAGMENT:\n\t\t\t\t\t\tIPackageFragment pack= (IPackageFragment) je;\n\t\t\t\t\t\tif (!pack.hasChildren() && pack.getNonJavaResources().length > 0) {\n\t\t\t\t\t\t\treturn RESOURCEPACKAGES;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (pack.getParent().getUnderlyingResource() instanceof IProject) {\n\t\t\t\t\t\t\treturn PACKAGEFRAGMENTROOT;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase IJavaElement.PACKAGE_FRAGMENT_ROOT:\n\t\t\t\t\t\treturn PACKAGEFRAGMENTROOT;\n\t\t\t\t}\n\t\t\t\n\t\t\t} catch (JavaModelException x) {\n\t\t\t\tJavaPlugin.log(x);\n\t\t\t}\n\t\t\treturn JAVAELEMENTS;\n\t\t} else if (element instanceof IFile) {\n\t\t\treturn RESOURCES;\n\t\t} else if (element instanceof IContainer) {\n\t\t\treturn RESOURCEFOLDERS;\t\n\t\t} else if (element instanceof IStorage) {\n\t\t\treturn STORAGE;\n\t\t}\t\t\t\n\t\treturn OTHERS;\n\t}\n\t\n\t/*\n\t * @see ViewerSorter#compare\n\t */\n\tpublic int compare(Viewer viewer, Object e1, Object e2) {\n\t\tint cat1= category(e1);\n\t\tint cat2= category(e2);\n\n\t\tif (cat1 != cat2)\n\t\t\treturn cat1 - cat2;\t\n\t\t\n\t\tswitch (cat1) {\n\t\t\tcase OTHERS:\n\t\t\t\t// unknown\n\t\t\t\treturn 0;\n\t\t\tcase CU_MEMBERS:\n\t\t\t\t// do not sort elements in CU or ClassFiles\n\t\t\t\treturn 0;\n\t\t\tcase PACKAGEFRAGMENTROOT:\n\t\t\t\tint p1= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e1));\n\t\t\t\tint p2= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e2));\n\t\t\t\treturn p1 - p2;\n\t\t\tcase STORAGE:\n\t\t\t\treturn ((IStorage)e1).getName().compareToIgnoreCase(((IStorage)e2).getName());\n\t\t\tcase RESOURCES:\n\t\t\tcase RESOURCEFOLDERS:\n\t\t\t\treturn ((IResource)e1).getName().compareToIgnoreCase(((IResource)e2).getName());\n\t\t\tcase RESOURCEPACKAGES:\t\n\t\t\t\treturn ((IJavaElement)e1).getElementName().compareToIgnoreCase(((IJavaElement)e2).getElementName());\n\t\t\tdefault:\n\t\t\t\treturn ((IJavaElement)e1).getElementName().compareTo(((IJavaElement)e2).getElementName());\n\t\t}\n\t}\n\t\t\t\n\tprivate int getClassPathIndex(IPackageFragmentRoot root) {\n\t\ttry {\n\t\t\tif (fClassPath == null)\n\t\t\t\tfClassPath= root.getJavaProject().getResolvedClasspath(true);\n\t\t} catch (JavaModelException e) {\n\t\t\treturn 0;\n\t\t}\n\t\tfor (int i= 0; i < fClassPath.length; i++) {\n\t\t\tif (fClassPath[i].getPath().equals(root.getPath()))\n\t\t\t\treturn i;\n\t\t}\n\t\treturn 0;\n\t}\t\n\t\n\t\n};"}}},{"rowIdx":90,"cells":{"issue_id":{"kind":"number","value":5367,"string":"5,367"},"title":{"kind":"string","value":"Bug 5367 Meaningless brackets presented with primitive display options"},"body":{"kind":"string","value":"With the primitive display options all turned on, booleans are rendered: enableCancelButton= false [] doubles have the same problem"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"add38a7"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T18:11:54Z","string":"2001-10-31T18:11:54Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-30T22:13:20Z","string":"2001-10-30T22:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui"},"file_content":{"kind":"string","value":""}}},{"rowIdx":91,"cells":{"issue_id":{"kind":"number","value":5367,"string":"5,367"},"title":{"kind":"string","value":"Bug 5367 Meaningless brackets presented with primitive display options"},"body":{"kind":"string","value":"With the primitive display options all turned on, booleans are rendered: enableCancelButton= false [] doubles have the same problem"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"add38a7"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T18:11:54Z","string":"2001-10-31T18:11:54Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-30T22:13:20Z","string":"2001-10-30T22:13:20Z"},"updated_file":{"kind":"string","value":"debug/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java"},"file_content":{"kind":"string","value":""}}},{"rowIdx":92,"cells":{"issue_id":{"kind":"number","value":5328,"string":"5,328"},"title":{"kind":"string","value":"Bug 5328 NPE in Open Super Method action"},"body":{"kind":"string","value":"1) make an empty selection in the text editor outside of a type's range, e.g, in the import 2) execute Show in Packages View ->NPE Notice: I've changed the Show in Packages View action and it might be the culprit. Issue: unclear why this code is executed when running the other action. org.eclipse.jface.util.Assert$AssertionFailedException: null argument; at org.eclipse.jface.util.Assert.isNotNull(Assert.java:133) at org.eclipse.jface.util.Assert.isNotNull(Assert.java(Compiled Code)) at org.eclipse.jface.viewers.StructuredSelection. (StructuredSelection.java:54) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$Adapter.asStruct uredSelection(StructuredSelectionProvider.java:75) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$Adapter.asStruct uredSelection(StructuredSelectionProvider.java:48) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$SelectionService Adapter.getSelection(StructuredSelectionProvider.java:138) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.getMethod (OpenSuperImplementationAction.java:69) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.canOperateOn (OpenSuperImplementationAction.java:61) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.update (OpenSuperImplementationAction.java:57) at org.eclipse.ui.texteditor.AbstractTextEditor.addAction (AbstractTextEditor.java:1693) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.editorContextMenuAboutToShow (JavaEditor.java:138) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.editorContextMenuAb outToShow(CompilationUnitEditor.java:298) at org.eclipse.ui.texteditor.AbstractTextEditor$2.menuAboutToShow (AbstractTextEditor.java:659) at org.eclipse.jface.action.MenuManager.fireAboutToShow (MenuManager.java:220) at org.eclipse.jface.action.MenuManager.handleAboutToShow (MenuManager.java:253) at org.eclipse.jface.action.MenuManager.access$0(MenuManager.java:250) at org.eclipse.jface.action.MenuManager$1.menuShown (MenuManager.java:280) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:112) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:828) at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:2787) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:983) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method) at org.eclipse.swt.widgets.Menu.setVisible(Menu.java:740) at org.eclipse.swt.widgets.Control.WM_CONTEXTMENU(Control.java:2612) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java (Compiled Code)) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java (Compiled Code)) at org.eclipse.swt.widgets.Control.WM_RBUTTONUP(Control.java:3446) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1136) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1165) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:675) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at SlimLauncher.main(SlimLauncher.java:14)"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"b6c438e"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T18:17:00Z","string":"2001-10-31T18:17:00Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-29T15:40:00Z","string":"2001-10-29T15:40:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/StructuredSelectionProvider.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.actions;\n\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionProvider;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.StructuredSelection;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.ISelectionService;\n\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICodeAssist;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;\nimport org.eclipse.jdt.internal.ui.util.ExceptionHandler;\n\n/**\n */\npublic abstract class StructuredSelectionProvider {\n\t\n\tpublic static int FLAGS_DO_CODERESOLVE= 1;\n\tpublic static int FLAGS_DO_ELEMENT_AT_OFFSET= 2;\n\n\tprivate static abstract class Adapter extends StructuredSelectionProvider {\n\t\tprivate ITextSelection fLastTextSelection;\n\t\tprivate IStructuredSelection fLastStructuredSelection;\n\t\t\n\t\tprivate Adapter() {\n\t\t}\n\t\t\n\t\tprotected IStructuredSelection asStructuredSelection(ITextSelection selection, int flags) {\n\t\t\tIEditorPart editor= JavaPlugin.getActivePage().getActiveEditor();\n\t\t\tif (editor == null)\n\t\t\t\treturn null;\n\t\t\treturn asStructuredSelection(selection, editor, flags);\t\t\t\t\n\t\t}\n\t\t\n\t\tprotected IStructuredSelection asStructuredSelection(ITextSelection selection, IEditorPart editor, int flags) {\n\t\t\tif ((flags & FLAGS_DO_CODERESOLVE) != 0) {\n\t\t\t\tif (selection.getLength() == 0)\n\t\t\t\t\treturn StructuredSelection.EMPTY;\t\t\t\t\n\t\t\t\tIStructuredSelection result= considerCache(selection);\n\t\t\t\tif (result != null)\n\t\t\t\t\treturn result;\n\t\t\t\t\t\n\t\t\t\tIJavaElement assist= getEditorInput(editor);\n\t\t\t\tif (assist instanceof ICodeAssist) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tIJavaElement[] elements= ((ICodeAssist)assist).codeSelect(selection.getOffset(), selection.getLength());\n\t\t\t\t\t\tresult= new StructuredSelection(elements);\n\t\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\t\tExceptionHandler.handle(e, \"Selection Converter\", \"Unexpected exception while converting text selection.\");\n\t\t\t\t\t}\n\t\t\t\t\tcacheResult(selection, result);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else if ((flags & FLAGS_DO_ELEMENT_AT_OFFSET) != 0) {\n\t\t\t\ttry {\n\t\t\t\t\tIJavaElement assist= getEditorInput(editor);\n\t\t\t\t\tif (assist instanceof ICompilationUnit) {\n\t\t\t\t\t\tIJavaElement ref= ((ICompilationUnit)assist).getElementAt(selection.getOffset());\n\t\t\t\t\t\treturn new StructuredSelection(ref);\t\n\t\t\t\t\t} else if (assist instanceof IClassFile) {\n\t\t\t\t\t\tIJavaElement ref= ((IClassFile)assist).getElementAt(selection.getOffset());\n\t\t\t\t\t\treturn new StructuredSelection(ref);\n\t\t\t\t\t}\n\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\tExceptionHandler.handle(e, \"Selection Converter\", \"Unexpected exception while converting text selection.\");\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn StructuredSelection.EMPTY;\n\t\t}\n\t\t\n\t\tprivate IStructuredSelection considerCache(ITextSelection selection) {\n\t\t\tif (selection != fLastTextSelection) {\n\t\t\t\tfLastTextSelection= null;\n\t\t\t\tfLastStructuredSelection= null;\n\t\t\t}\n\t\t\treturn fLastStructuredSelection;\n\t\t}\n\t\t\n\t\tprivate void cacheResult(ITextSelection selection, IStructuredSelection result) {\n\t\t\tfLastTextSelection= selection;\n\t\t\tfLastStructuredSelection= result;\n\t\t}\n\t\t\n\t\tprivate IJavaElement getEditorInput(IEditorPart editorPart) {\n\t\t\tIEditorInput input= editorPart.getEditorInput();\n\t\t\tif (input instanceof IClassFileEditorInput)\n\t\t\t\treturn ((IClassFileEditorInput)input).getClassFile();\n\t\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\t\t\t\t\n\t\t\treturn manager.getWorkingCopy(input);\n\t\t}\n\t}\n\n\tprivate static class SelectionProviderAdapter extends Adapter {\n\t\tprivate ISelectionProvider fProvider; \n\t\tpublic SelectionProviderAdapter(ISelectionProvider provider) {\n\t\t\tsuper();\n\t\t\tfProvider= provider;\n\t\t\tAssert.isNotNull(fProvider);\n\t\t}\n\t\tpublic IStructuredSelection getSelection(int flags) {\n\t\t\tISelection result= fProvider.getSelection();\n\t\t\tif (result instanceof IStructuredSelection)\n\t\t\t\treturn (IStructuredSelection)result;\n\t\t\tif (result instanceof ITextSelection && fProvider instanceof IEditorPart)\n\t\t\t\treturn asStructuredSelection((ITextSelection)result, (IEditorPart)fProvider, flags);\n\t\t\treturn StructuredSelection.EMPTY;\n\t\t}\n\t}\n\t\n\tprivate static class SelectionServiceAdapter extends Adapter {\n\t\tprivate ISelectionService fService; \n\t\tpublic SelectionServiceAdapter(ISelectionService service) {\n\t\t\tsuper();\n\t\t\tfService= service;\n\t\t\tAssert.isNotNull(fService);\n\t\t}\n\t\tpublic IStructuredSelection getSelection(int flags) {\n\t\t\tISelection result= fService.getSelection();\n\t\t\tif (result instanceof IStructuredSelection)\n\t\t\t\treturn (IStructuredSelection)result;\n\t\t\tif (result instanceof ITextSelection)\n\t\t\t\treturn asStructuredSelection((ITextSelection)result, flags);\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tpublic IStructuredSelection getSelection() {\n\t\treturn getSelection(FLAGS_DO_CODERESOLVE);\n\t}\n\t\n\tpublic abstract IStructuredSelection getSelection(int flags);\n\n\tprivate StructuredSelectionProvider() {\n\t\t// prevent instantiation.\n\t}\n\n\tpublic static StructuredSelectionProvider createFrom(ISelectionProvider provider) {\n\t\treturn new SelectionProviderAdapter(provider);\n\t}\n\t\n\tpublic static StructuredSelectionProvider createFrom(ISelectionService service) {\n\t\treturn new SelectionServiceAdapter(service);\n\t}\n\t\t\n}\n\n"}}},{"rowIdx":93,"cells":{"issue_id":{"kind":"number","value":5358,"string":"5,358"},"title":{"kind":"string","value":"Bug 5358 Suspicious usage of IJavaElementDelta.getFlags()"},"body":{"kind":"string","value":"Build 20011025 Searching for references to IJavaElement.getFlags(), I found suspicious usage in JDT UI code. There are pattern of code like this one: delta.getFlags() == IJavaElementDelta.F_CONTENT where it should be: (delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"10e602c"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T18:22:06Z","string":"2001-10-31T18:22:06Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-30T16:40:00Z","string":"2001-10-30T16:40:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.typehierarchy;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.IStatus;\n\nimport org.eclipse.jface.operation.IRunnableWithProgress;\n\nimport org.eclipse.jdt.core.ElementChangedEvent;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IElementChangedListener;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IJavaElementDelta;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IRegion;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.ITypeHierarchy;\nimport org.eclipse.jdt.core.ITypeHierarchyChangedListener;\nimport org.eclipse.jdt.core.IWorkingCopy;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;\nimport org.eclipse.jdt.internal.ui.util.JavaModelUtil;\n\n/**\n * Manages a type hierarchy, to keep it refreshed, and to allow it to be shared.\n */\npublic class TypeHierarchyLifeCycle implements ITypeHierarchyChangedListener, IElementChangedListener {\n\t\n\tprivate boolean fHierarchyRefreshNeeded;\n\tprivate ITypeHierarchy fHierarchy;\n\tprivate IJavaElement fInputElement;\n\tprivate boolean fIsSuperTypesOnly;\n\t\n\tprivate List fChangeListeners;\n\t\n\tpublic TypeHierarchyLifeCycle() {\n\t\tthis(false);\n\t}\t\n\t\n\tpublic TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {\n\t\tfHierarchy= null;\n\t\tfInputElement= null;\n\t\tfIsSuperTypesOnly= isSuperTypesOnly;\n\t\tfChangeListeners= new ArrayList(2);\n\t}\n\t\n\tpublic ITypeHierarchy getHierarchy() {\n\t\treturn fHierarchy;\n\t}\n\t\n\tpublic IJavaElement getInputElement() {\n\t\treturn fInputElement;\n\t}\n\t\n\t\n\tpublic void freeHierarchy() {\n\t\tif (fHierarchy != null) {\n\t\t\tfHierarchy.removeTypeHierarchyChangedListener(this);\n\t\t\tJavaCore.removeElementChangedListener(this);\n\t\t\tfHierarchy= null;\n\t\t\tfInputElement= null;\n\t\t}\n\t}\n\t\n\tpublic void removeChangedListener(ITypeHierarchyLifeCycleListener listener) {\n\t\tfChangeListeners.remove(listener);\n\t}\n\t\n\tpublic void addChangedListener(ITypeHierarchyLifeCycleListener listener) {\n\t\tif (!fChangeListeners.contains(listener)) {\n\t\t\tfChangeListeners.add(listener);\n\t\t}\n\t}\n\t\n\tprivate void fireChange(IType[] changedTypes) {\n\t\tfor (int i= fChangeListeners.size()-1; i>=0; i--) {\n\t\t\tITypeHierarchyLifeCycleListener curr= (ITypeHierarchyLifeCycleListener) fChangeListeners.get(i);\n\t\t\tcurr.typeHierarchyChanged(this, changedTypes);\n\t\t}\n\t}\n\t\n\tpublic void ensureRefreshedTypeHierarchy() throws JavaModelException {\n\t\tif (fHierarchy != null) {\n\t\t\tensureRefreshedTypeHierarchy(fInputElement);\n\t\t}\n\t}\n\t\n\tpublic void ensureRefreshedTypeHierarchy(final IJavaElement element) throws JavaModelException {\n\t\tif (element == null) {\n\t\t\tfreeHierarchy();\n\t\t\treturn;\n\t\t}\n\t\tboolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));\n\t\t\n\t\tif (hierachyCreationNeeded || fHierarchyRefreshNeeded) {\n\t\t\tIRunnableWithProgress op= new IRunnableWithProgress() {\n\t\t\t\tpublic void run(IProgressMonitor pm) throws InvocationTargetException {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdoHierarchyRefresh(element, pm);\n\t\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\t\tthrow new InvocationTargetException(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\t\n\t\t\ttry {\n\t\t\t\tnew BusyIndicatorRunnableContext().run(true, false, op);\n\t\t\t} catch (InvocationTargetException e) {\n\t\t\t\tThrowable th= e.getTargetException();\n\t\t\t\tif (th instanceof JavaModelException) {\n\t\t\t\t\tthrow (JavaModelException)th;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new JavaModelException(th, IStatus.ERROR);\n\t\t\t\t}\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\t// Not cancelable.\n\t\t\t}\n\t\t\t\n\t\t\tfHierarchyRefreshNeeded= false;\n\t\t}\n\t}\n\t\n\tprivate void doHierarchyRefresh(IJavaElement element, IProgressMonitor pm) throws JavaModelException {\n\t\tboolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));\n\t\tif (hierachyCreationNeeded) {\n\t\t\tif (fHierarchy != null) {\n\t\t\t\tfHierarchy.removeTypeHierarchyChangedListener(this);\n\t\t\t\tJavaCore.removeElementChangedListener(this);\n\t\t\t}\n\t\t\tfInputElement= element;\n\t\t\tif (element.getElementType() == IJavaElement.TYPE) {\n\t\t\t\tIType type= (IType) element;\n\t\t\t\tif (fIsSuperTypesOnly) {\n\t\t\t\t\tfHierarchy= type.newSupertypeHierarchy(pm);\n\t\t\t\t} else {\n\t\t\t\t\tfHierarchy= type.newTypeHierarchy(pm);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tIJavaProject jproject= element.getJavaProject();\n\t\t\t\tIRegion region= JavaCore.newRegion();\n\t\t\t\tregion.add(element);\n\t\t\t\tfHierarchy= jproject.newTypeHierarchy(region, pm);\t\t\t\t\n\t\t\t}\n\t\t\tfHierarchy.addTypeHierarchyChangedListener(this);\n\t\t\tJavaCore.addElementChangedListener(this);\n\t\t} else {\n\t\t\tfHierarchy.refresh(pm);\n\t\t}\n\t}\t\t\n\t\n\t/*\n\t * @see ITypeHierarchyChangedListener#typeHierarchyChanged\n\t */\n\tpublic void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {\n\t \tfHierarchyRefreshNeeded= true;\n\n\t}\t\t\n\n\t/*\n\t * @see IElementChangedListener#elementChanged(ElementChangedEvent)\n\t */\n\tpublic void elementChanged(ElementChangedEvent event) {\n\t\tIJavaElement elem= event.getDelta().getElement();\n\t\tif (elem instanceof IWorkingCopy && ((IWorkingCopy)elem).isWorkingCopy()) {\n\t\t\treturn;\n\t\t}\n\t\tif (fHierarchyRefreshNeeded) {\n\t\t\tfireChange(null);\n\t\t} else {\n\t\t\tArrayList changedTypes= new ArrayList();\n\t\t\tprocessDelta(event.getDelta(), changedTypes);\n\t\t\tfireChange((IType[]) changedTypes.toArray(new IType[changedTypes.size()]));\n\t\t}\n\t}\n\t\n\t/*\n\t * Assume that the hierarchy is intact (no refresh needed)\n\t */\t\t\t\t\t\n\tprivate void processDelta(IJavaElementDelta delta, ArrayList changedTypes) {\n\t\tIJavaElement element= delta.getElement();\n\t\tswitch (element.getElementType()) {\n\t\t\tcase IJavaElement.TYPE:\n\t\t\t\tprocessTypeDelta((IType) element, changedTypes);\n\t\t\t\tprocessChildrenDelta(delta, changedTypes); // (inner types)\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.JAVA_MODEL:\n\t\t\tcase IJavaElement.JAVA_PROJECT:\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT_ROOT:\n\t\t\tcase IJavaElement.PACKAGE_FRAGMENT:\n\t\t\t\tprocessChildrenDelta(delta, changedTypes);\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.COMPILATION_UNIT:\n\t\t\t\tif (delta.getKind() == IJavaElementDelta.CHANGED && delta.getFlags() == IJavaElementDelta.F_CONTENT) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tIType[] types= ((ICompilationUnit) element).getAllTypes();\n\t\t\t\t\t\tfor (int i= 0; i < types.length; i++) {\n\t\t\t\t\t\t\tprocessTypeDelta(types[i], changedTypes);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\t\tJavaPlugin.log(e);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tprocessChildrenDelta(delta, changedTypes);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase IJavaElement.CLASS_FILE:\t\n\t\t\t\tif (delta.getKind() == IJavaElementDelta.CHANGED && delta.getFlags() == IJavaElementDelta.F_CONTENT) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tIType type= ((IClassFile) element).getType();\n\t\t\t\t\t\tprocessTypeDelta(type, changedTypes);\n\t\t\t\t\t} catch (JavaModelException e) {\n\t\t\t\t\t\tJavaPlugin.log(e);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tprocessChildrenDelta(delta, changedTypes);\n\t\t\t\t}\n\t\t\t\tbreak;\t\t\t\t\n\t\t}\n\t}\n\t\n\tprivate void processTypeDelta(IType type, ArrayList changedTypes) {\n\t\tif (getHierarchy().contains(type)) {\n\t\t\tchangedTypes.add(type);\n\t\t}\n\t}\n\t\n\tprivate void processChildrenDelta(IJavaElementDelta delta, ArrayList changedTypes) {\n\t\tIJavaElementDelta[] children= delta.getAffectedChildren();\n\t\tfor (int i= 0; i < children.length; i++) {\n\t\t\tprocessDelta(children[i], changedTypes); // recursive\n\t\t}\n\t}\n\t\n}"}}},{"rowIdx":94,"cells":{"issue_id":{"kind":"number","value":5361,"string":"5,361"},"title":{"kind":"string","value":"Bug 5361 No error tick on imports in Packages view"},"body":{"kind":"string","value":"Add an import that causes an error (e.g. dani.is.bad) and save. ==> The Outline view shows the error ticks on the imports but the package view doesn't"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"491a8fb"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-10-31T18:31:06Z","string":"2001-10-31T18:31:06Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-30T16:40:00Z","string":"2001-10-30T16:40:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/MarkerErrorTickProvider.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.viewsupport;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\n\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IJavaModelMarker;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.core.ISourceRange;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\n\n/**\n * Used by the JavaElementLabelProvider to evaluate the error tick state of\n * an element.\n */\npublic class MarkerErrorTickProvider implements IErrorTickProvider {\n\t\n\t/*\n\t * @see IErrorTickProvider#getErrorInfo\n\t */\n\tpublic int getErrorInfo(IJavaElement element) {\n\t\tint info= 0;\n\t\ttry {\n\t\t\tIResource res= null;\n\t\t\tISourceRange range= null;\n\t\t\tint depth= IResource.DEPTH_INFINITE;\n\t\t\t\n\t\t\tint type= element.getElementType();\n\t\t\t\n\t\t\tif (type == IJavaElement.JAVA_PROJECT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT\n\t\t\t\t|| type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.CLASS_FILE || type == IJavaElement.COMPILATION_UNIT) {\n\t\t\t\tres= element.getCorrespondingResource();\n\t\t\t\tif (type == IJavaElement.PACKAGE_FRAGMENT) {\n\t\t\t\t\tdepth= IResource.DEPTH_ONE;\n\t\t\t\t} else if (type == IJavaElement.JAVA_PROJECT) {\n\t\t\t\t\tIMarker[] bpMarkers= res.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, true, IResource.DEPTH_ONE);\n\t\t\t\t\tinfo= accumulateProblems(bpMarkers, info, null);\n\t\t\t\t}\n\t\t\t} else if (type == IJavaElement.TYPE || type == IJavaElement.METHOD || type == IJavaElement.INITIALIZER) {\n\t\t\t\t// I assume that only source elements can have markers\n\t\t\t\tICompilationUnit cu= ((IMember)element).getCompilationUnit();\n\t\t\t\tif (cu != null) {\n\t\t\t\t\tres= element.getUnderlyingResource();\n\t\t\t\t\trange= ((IMember)element).getSourceRange();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (res != null) {\n\t\t\t\tIMarker[] markers= res.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, depth);\n\t\t\t\tif (markers != null) {\n\t\t\t\t\tinfo= accumulateProblems(markers, info, range);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (CoreException e) {\n\t\t\tJavaPlugin.log(e.getStatus());\n\t\t}\n\t\treturn info;\n\t}\n\t\n\tprivate int accumulateProblems(IMarker[] markers, int info, ISourceRange range) {\n\t\tif (markers != null) {\t\n\t\t\tfor (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {\n\t\t\t\tIMarker curr= markers[i];\n\t\t\t\tif (range == null || isInRange(curr, range)) {\n\t\t\t\t\tint priority= curr.getAttribute(IMarker.SEVERITY, -1);\n\t\t\t\t\tif (priority == IMarker.SEVERITY_WARNING) {\n\t\t\t\t\t\tinfo= ERRORTICK_WARNING;\n\t\t\t\t\t} else if (priority == IMarker.SEVERITY_ERROR) {\n\t\t\t\t\t\tinfo= ERRORTICK_ERROR;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn info;\n\t}\n\t\n\tprivate boolean isInRange(IMarker marker, ISourceRange range) {\n\t\tint pos= marker.getAttribute(IMarker.CHAR_START, -1);\n\t\tint offset= range.getOffset();\n\t\treturn (offset <= pos && offset + range.getLength() > pos);\n\t}\t\n\n}\n\n"}}},{"rowIdx":95,"cells":{"issue_id":{"kind":"number","value":5392,"string":"5,392"},"title":{"kind":"string","value":"Bug 5392 Eclipse dies without warning"},"body":{"kind":"string","value":"build 205 on Win98. This happened 3 times. 1). I was looking at Java code and selected something in the Outline view and Eclipse died without any warning. No log messages or dialogs. 2). I restarted, opened up the Java class again, clicked around in the Outline and it was ok. Then I clicked on a method in the outline, did a search, then double-clicked on the single search result and Eclipse died without warning again. Again without a log or dialog. 3). Restarted again. Pressed the Open to Type button, typed in the class name and hit ok. Eclipse died, got 3 dialogs saying that an error has occurred, and got the following in my log file. Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306)"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"02264f5"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-11-01T08:39:47Z","string":"2001-11-01T08:39:47Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-31T17:40:00Z","string":"2001-10-31T17:40:00Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.javaeditor;\n\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.jface.text.source.IAnnotationModel;\nimport org.eclipse.jface.text.source.IAnnotationModelListener;\n\nimport org.eclipse.jface.util.Assert;\nimport org.eclipse.ui.IEditorInput;\n\nimport org.eclipse.jdt.core.IJavaElement;\n\nimport org.eclipse.jdt.ui.JavaElementLabelProvider;\n\n/**\n * The JavaEditorErrorTickUpdater will register as a AnnotationModelListener\n * on the annotation model of a Java Editor and update the title images when the annotation\n * model changed.\n */\npublic class JavaEditorErrorTickUpdater implements IAnnotationModelListener {\n\n\tprivate JavaEditor fJavaEditor;\n\tprivate IAnnotationModel fAnnotationModel;\n\tprivate JavaElementLabelProvider fLabelProvider;\n\n\tpublic JavaEditorErrorTickUpdater(JavaEditor editor) {\n\t\tfJavaEditor= editor;\n\t\tAssert.isNotNull(editor);\n\t}\n\n\t/**\n\t * Defines the annotation model to listen to. To be called when the\n\t * annotation model changes.\n\t * @param model The new annotation model or null\n\t * to uninstall.\n\t */\n\tpublic void setAnnotationModel(IAnnotationModel model) {\n\t\tif (fAnnotationModel != null) {\n\t\t\tfAnnotationModel.removeAnnotationModelListener(this);\n\t\t}\n\t\t\t\t\n\t\tif (model != null) {\n\t\t\tfAnnotationModel=model;\n\t\t\tfAnnotationModel.addAnnotationModelListener(this);\n\t\t\t\n\t\t\tif (fLabelProvider == null) {\n\t\t\t\tfLabelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS);\n\t\t\t}\n\t\t\tfLabelProvider.setErrorTickManager(new AnnotationErrorTickProvider(fAnnotationModel));\n\t\t\tmodelChanged(fAnnotationModel);\n\t\t} else {\n\t\t\tfAnnotationModel= null;\n\t\t\tif (fLabelProvider != null) {\n\t\t\t\tfLabelProvider.dispose();\n\t\t\t\tfLabelProvider= null;\n\t\t\t}\n\t\t}\t\n\t}\n\t\t\t\n\t/**\n\t * @see IAnnotationModelListener#modelChanged(IAnnotationModel)\n\t */\n\tpublic void modelChanged(IAnnotationModel model) {\n\t\tif (fJavaEditor.getTitleImage() == null) {\n\t\t\treturn;\n\t\t}\n\t\tShell shell= fJavaEditor.getEditorSite().getShell();\n\t\tif (shell != null && !shell.isDisposed()) {\n\t\t\tshell.getDisplay().asyncExec(new Runnable() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tdoUpdateErrorTicks();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\t\n\tprivate void doUpdateErrorTicks() {\n\t\tIEditorInput input= fJavaEditor.getEditorInput();\n\t\tif (fLabelProvider != null && input != null) { // running async, tests needed\n\t\t\tIJavaElement jelement= (IJavaElement) input.getAdapter(IJavaElement.class);\n\t\t\tif (jelement != null) {\n\t\t\t\tfJavaEditor.updatedTitleImage(fLabelProvider.getImage(jelement));\n\t\t\t}\n\t\t}\n\t}\t\n\n}\n\n\n"}}},{"rowIdx":96,"cells":{"issue_id":{"kind":"number","value":4273,"string":"4,273"},"title":{"kind":"string","value":"Bug 4273 Compiler option changes not handled correctly (1GKWRI3)"},"body":{"kind":"string","value":"Nothing happens if auto-build is on and (some) compiler options are changed . If something was reported as error and now I choose that to be reported as warning and if autobuild is on I expect a rebuild. Same if I switch from 1.2 to 1.3 compatibilty. NOTES: EG (01.10.2001 14:57:06) we should prompt the user for a rebuild whenever an option changes. MA (01.10.2001 15:16:25) The description in the pages says everything. EG (02.10.2001 18:16:59) yes, but this is isn't sufficient. We should show a dialog with the option to rebuild the workspace after apply."},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"2c430ec"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-11-01T10:02:10Z","string":"2001-11-01T10:02:10Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerPreferencePage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.preferences;\n\nimport java.util.ArrayList;\nimport java.util.Hashtable;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Combo;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.Widget;\n\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.preference.PreferencePage;\n\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\nimport org.eclipse.ui.help.DialogPageContextComputer;\nimport org.eclipse.ui.help.WorkbenchHelp;\n\nimport org.eclipse.jdt.core.JavaCore;\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jdt.internal.ui.JavaUIMessages;\nimport org.eclipse.jdt.internal.ui.util.TabFolderLayout;\n\n/*\n * The page for setting the compiler options.\n */\npublic class CompilerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {\n\n\t// Preference store keys, see JavaCore.getOptions\n\tprivate static final String PREF_LOCAL_VARIABLE_ATTR= \"org.eclipse.jdt.core.compiler.debug.localVariable\";\n\tprivate static final String PREF_LINE_NUMBER_ATTR= \"org.eclipse.jdt.core.compiler.debug.lineNumber\";\n\tprivate static final String PREF_SOURCE_FILE_ATTR= \"org.eclipse.jdt.core.compiler.debug.sourceFile\";\n\tprivate static final String PREF_CODEGEN_UNUSED_LOCAL= \"org.eclipse.jdt.core.compiler.codegen.unusedLocal\";\n\tprivate static final String PREF_CODEGEN_TARGET_PLATFORM= \"org.eclipse.jdt.core.compiler.codegen.targetPlatform\";\n\tprivate static final String PREF_PB_UNREACHABLE_CODE= \"org.eclipse.jdt.core.compiler.problem.unreachableCode\";\t\n\tprivate static final String PREF_PB_INVALID_IMPORT= \"org.eclipse.jdt.core.compiler.problem.invalidImport\";\t\n\tprivate static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= \"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\";\t\n\tprivate static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= \"org.eclipse.jdt.core.compiler.problem.methodWithConstructorName\";\n\tprivate static final String PREF_PB_DEPRECATION= \"org.eclipse.jdt.core.compiler.problem.deprecation\";\n\tprivate static final String PREF_PB_HIDDEN_CATCH_BLOCK= \"org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock\";\n\tprivate static final String PREF_PB_UNUSED_LOCAL= \"org.eclipse.jdt.core.compiler.problem.unusedLocal\";\t\n\tprivate static final String PREF_PB_UNUSED_PARAMETER= \"org.eclipse.jdt.core.compiler.problem.unusedParameter\";\n\tprivate static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= \"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\";\n\tprivate static final String PREF_PB_NON_EXTERNALIZED_STRINGS= \"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\";\n\tprivate static final String PREF_PB_ASSERT_AS_IDENTIFIER= \"org.eclipse.jdt.core.compiler.problem.assertIdentifier\";\n\tprivate static final String PREF_SOURCE_COMPATIBILITY= \"org.eclipse.jdt.core.compiler.source\";\n\n\t// values\n\tprivate static final String GENERATE= \"generate\";\n\tprivate static final String DO_NOT_GENERATE= \"do not generate\";\n\t\n\tprivate static final String PRESERVE= \"preserve\";\n\tprivate static final String OPTIMIZE_OUT= \"optimize out\";\n\t\n\tprivate static final String VERSION_1_1= \"1.1\";\n\tprivate static final String VERSION_1_2= \"1.2\";\n\tprivate static final String VERSION_1_3= \"1.3\";\n\tprivate static final String VERSION_1_4= \"1.4\";\n\t\n\tprivate static final String ERROR= \"error\";\n\tprivate static final String WARNING= \"warning\";\n\tprivate static final String IGNORE= \"ignore\";\t\n\n\tprivate static String[] getAllKeys() {\n\t\treturn new String[] {\n\t\t\tPREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,\n\t\t\tPREF_CODEGEN_TARGET_PLATFORM, PREF_PB_UNREACHABLE_CODE, PREF_PB_INVALID_IMPORT, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,\n\t\t\tPREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,\n\t\t\tPREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS,\n\t\t\tPREF_PB_ASSERT_AS_IDENTIFIER, PREF_SOURCE_COMPATIBILITY\n\t\t};\t\n\t}\n\n\t/**\n\t * Initializes the current options (read from preference store)\n\t */\n\tpublic static void initDefaults(IPreferenceStore store) {\n\t\tHashtable hashtable= JavaCore.getDefaultOptions();\n\t\tHashtable currOptions= JavaCore.getOptions();\n\t\tString[] allKeys= getAllKeys();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString defValue= (String) hashtable.get(key);\n\t\t\tif (defValue != null) {\n\t\t\t\tstore.setDefault(key, defValue);\n\t\t\t} else {\n\t\t\t\tJavaPlugin.logErrorMessage(\"CompilerPreferencePage: value is null: \" + key);\n\t\t\t}\n\t\t\t// update the JavaCore options from the pref store\n\t\t\tString val= store.getString(key);\n\t\t\tif (val != null) {\n\t\t\t\tcurrOptions.put(key, val);\n\t\t\t}\t\t\t\n\t\t}\n\t\tJavaCore.setOptions(currOptions);\n\t}\n\n\tprivate static class ControlData {\n\t\tprivate String fKey;\n\t\tprivate String[] fValues;\n\t\t\n\t\tpublic ControlData(String key, String[] values) {\n\t\t\tfKey= key;\n\t\t\tfValues= values;\n\t\t}\n\t\t\n\t\tpublic String getKey() {\n\t\t\treturn fKey;\n\t\t}\n\t\t\n\t\tpublic String getValue(boolean selection) {\n\t\t\tint index= selection ? 0 : 1;\n\t\t\treturn fValues[index];\n\t\t}\n\t\t\n\t\tpublic String getValue(int index) {\n\t\t\treturn fValues[index];\n\t\t}\t\t\n\t\t\n\t\tpublic int getSelection(String value) {\n\t\t\tfor (int i= 0; i < fValues.length; i++) {\n\t\t\t\tif (value.equals(fValues[i])) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t}\n\t\n\tprivate Hashtable fWorkingValues;\n\n\tprivate ArrayList fCheckBoxes;\n\tprivate ArrayList fComboBoxes;\n\t\n\tprivate SelectionListener fSelectionListener;\n\n\tpublic CompilerPreferencePage() {\n\t\tsetPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());\n\t\tsetDescription(JavaUIMessages.getString(\"CompilerPreferencePage.description\")); //$NON-NLS-1$\n\t\n\t\tfWorkingValues= JavaCore.getOptions();\n\t\tfCheckBoxes= new ArrayList();\n\t\tfComboBoxes= new ArrayList();\n\t\t\n\t\tfSelectionListener= new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {}\n\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tcontrolChanged(e.widget);\n\t\t\t}\n\t\t};\n\t\t\n\t}\n\n\t/**\n\t * @see IWorkbenchPreferencePage#init()\n\t */\t\n\tpublic void init(IWorkbench workbench) {\n\t}\n\n\t/**\n\t * @see PreferencePage#createControl(Composite)\n\t */\n\tpublic void createControl(Composite parent) {\n\t\t// added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages\n\t\tsuper.createControl(parent);\n\t\tWorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE));\n\t}\t\n\n\t/**\n\t * @see PreferencePage#createContents(Composite)\n\t */\n\tprotected Control createContents(Composite parent) {\n\t\tTabFolder folder= new TabFolder(parent, SWT.NONE);\n\t\tfolder.setLayout(new TabFolderLayout());\t\n\t\tfolder.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tString[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };\n\t\t\n\t\tString[] errorWarningIgnoreLabels= new String[] {\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.error\"), \n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.warning\"),\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.ignore\")\n\t\t};\n\t\t\t\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\n\t\tComposite warningsComposite= new Composite(folder, SWT.NULL);\n\t\twarningsComposite.setLayout(layout);\n\n\t\tString label= JavaUIMessages.getString(\"CompilerPreferencePage.pb_unreachable_code.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_UNREACHABLE_CODE, errorWarningIgnore, errorWarningIgnoreLabels);\t\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_invalid_import.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_INVALID_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels);\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_overriding_pkg_dflt.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels);\t\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_method_naming.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels);\t\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_deprecation.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_hidden_catchblock.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_unused_local.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_unused_parameter.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_synth_access_emul.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels);\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_non_externalized_strings.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.pb_assert_as_identifier.label\"); //$NON-NLS-1$\n\t\taddComboBox(warningsComposite, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels);\t\t\n\n\t\tString[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE };\n\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\n\t\tComposite codeGenComposite= new Composite(folder, SWT.NULL);\n\t\tcodeGenComposite.setLayout(layout);\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.variable_attr.label\"); //$NON-NLS-1$\n\t\taddCheckBox(codeGenComposite, label, PREF_LOCAL_VARIABLE_ATTR, generateValues);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.line_number_attr.label\"); //$NON-NLS-1$\n\t\taddCheckBox(codeGenComposite, label, PREF_LINE_NUMBER_ATTR, generateValues);\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.source_file_attr.label\"); //$NON-NLS-1$\n\t\taddCheckBox(codeGenComposite, label, PREF_SOURCE_FILE_ATTR, generateValues);\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.codegen_unused_local.label\"); //$NON-NLS-1$\n\t\taddCheckBox(codeGenComposite, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT });\t\n\n\t\tString[] values= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 };\n\t\tString[] valuesLabels= new String[] {\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.jvm11\"), \n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.jvm12\"),\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.jvm13\"),\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.jvm14\")\n\t\t};\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.codegen_targetplatform.label\"); //$NON-NLS-1$\n\t\taddComboBox(codeGenComposite, label, PREF_CODEGEN_TARGET_PLATFORM, values, valuesLabels);\t\n\n\t\tvalues= new String[] { VERSION_1_3, VERSION_1_4 };\n\t\tvaluesLabels= new String[] {\n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.version13\"), \n\t\t\tJavaUIMessages.getString(\"CompilerPreferencePage.version14\")\n\t\t};\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CompilerPreferencePage.source_compatibility.label\"); //$NON-NLS-1$\n\t\taddComboBox(codeGenComposite, label, PREF_SOURCE_COMPATIBILITY, values, valuesLabels);\t\n\n\n\t\tTabItem item= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CompilerPreferencePage.warnings.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING));\n\t\titem.setControl(warningsComposite);\n\n\t\n\t\titem= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CompilerPreferencePage.generation.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));\n\t\titem.setControl(codeGenComposite);\n\t\t\n\t\t\t\t\n\t\treturn folder;\n\t}\n\t\n\tprivate void addCheckBox(Composite parent, String label, String key, String[] values) {\n\t\tControlData data= new ControlData(key, values);\n\t\t\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan= 2;\n\t\t\n\t\tButton checkBox= new Button(parent, SWT.CHECK);\n\t\tcheckBox.setText(label);\n\t\tcheckBox.setData(data);\n\t\tcheckBox.setLayoutData(gd);\n\t\tcheckBox.addSelectionListener(fSelectionListener);\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\tcheckBox.setSelection(data.getSelection(currValue) == 0);\n\t\t\n\t\tfCheckBoxes.add(checkBox);\n\t}\n\t\n\tprivate void addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels) {\n\t\tControlData data= new ControlData(key, values);\n\t\t\n\t\tLabel labelControl= new Label(parent, SWT.NONE);\n\t\tlabelControl.setText(label);\n\t\tlabelControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\t\n\t\tGridData gd= new GridData();\n\t\tgd.horizontalAlignment= GridData.END;\n\t\t\n\t\tCombo comboBox= new Combo(parent, SWT.READ_ONLY);\n\t\tcomboBox.setItems(valueLabels);\n\t\tcomboBox.setData(data);\n\t\tcomboBox.setLayoutData(gd);\n\t\tcomboBox.addSelectionListener(fSelectionListener);\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\tcomboBox.select(data.getSelection(currValue));\n\t\t\n\t\tfComboBoxes.add(comboBox);\n\t}\t\n\t\n\tprivate void controlChanged(Widget widget) {\n\t\tControlData data= (ControlData) widget.getData();\n\t\tString newValue= null;\n\t\tif (widget instanceof Button) {\n\t\t\tnewValue= data.getValue(((Button)widget).getSelection());\t\t\t\n\t\t} else if (widget instanceof Combo) {\n\t\t\tnewValue= data.getValue(((Combo)widget).getSelectionIndex());\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\tfWorkingValues.put(data.getKey(), newValue);\n\t}\n\t\n\t/*\n\t * @see IPreferencePage#performOk()\n\t */\n\tpublic boolean performOk() {\n\t\tString[] allKeys= getAllKeys();\n\t\t// preserve other options\n\t\t// store in JCore and the preferences\n\t\tHashtable actualOptions= JavaCore.getOptions();\n\t\tIPreferenceStore store= getPreferenceStore();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString val= (String) fWorkingValues.get(key);\n\t\t\tactualOptions.put(key, val);\n\t\t\tstore.putValue(key, val);\n\t\t}\n\t\tJavaCore.setOptions(actualOptions);\n\t\treturn super.performOk();\n\t}\t\t\n\t\n\t/*\n\t * @see PreferencePage#performDefaults()\n\t */\n\tprotected void performDefaults() {\n\t\tfWorkingValues= JavaCore.getDefaultOptions();\n\t\tupdateControls();\n\t\tsuper.performDefaults();\n\t}\n\t\n\tprivate void updateControls() {\n\t\t// update the UI\n\t\tfor (int i= fCheckBoxes.size() - 1; i >= 0; i--) {\n\t\t\tButton curr= (Button) fCheckBoxes.get(i);\n\t\t\tControlData data= (ControlData) curr.getData();\n\t\t\t\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(data.getKey());\t\n\t\t\tcurr.setSelection(data.getSelection(currValue) == 0);\t\t\t\n\t\t}\n\t\tfor (int i= fComboBoxes.size() - 1; i >= 0; i--) {\n\t\t\tCombo curr= (Combo) fComboBoxes.get(i);\n\t\t\tControlData data= (ControlData) curr.getData();\n\t\t\t\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(data.getKey());\t\n\t\t\tcurr.select(data.getSelection(currValue));\t\t\t\n\t\t}\t\t\n\t\t\n\t}\n\n}\n\n\n"}}},{"rowIdx":97,"cells":{"issue_id":{"kind":"number","value":4171,"string":"4,171"},"title":{"kind":"string","value":"Bug 4171 Accessibility: Code Formatter Page too large with a large text font (1GJL58E)"},"body":{"kind":"string","value":"If the Text font is set to be very large (say 36 point) the CodeFormatter preference page is created so large that it ends up bigger than the display. The text in the preference page should be scrollable. It also does not pick up changes to the font size so if the user changes the size of the text font they will have to reopen the preference dialog to get the change picked up. STEPS 1) Set the Text Font in the font preference page to be 36 point 2) Close the preference dialog 3) Reopen the preference dialog and select the code formatter page NOTES:"},"status":{"kind":"string","value":"verified fixed"},"after_fix_sha":{"kind":"string","value":"c9d4729"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-11-01T10:08:06Z","string":"2001-11-01T10:08:06Z"},"report_datetime":{"kind":"timestamp","value":"2001-10-11T03:13:20Z","string":"2001-10-11T03:13:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeFormatterPreferencePage.java"},"file_content":{"kind":"string","value":"/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\npackage org.eclipse.jdt.internal.ui.preferences;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.Hashtable;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.Text;\n\nimport org.eclipse.core.runtime.IStatus;\n\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.preference.PreferencePage;\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.source.SourceViewer;\n\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\nimport org.eclipse.ui.help.DialogPageContextComputer;\nimport org.eclipse.ui.help.WorkbenchHelp;\n\nimport org.eclipse.jdt.core.JavaCore;\n\nimport org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;\nimport org.eclipse.jdt.ui.text.JavaTextTools;\n\nimport org.eclipse.jdt.internal.formatter.CodeFormatter;\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds;\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jdt.internal.ui.JavaUIMessages;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusInfo;\nimport org.eclipse.jdt.internal.ui.dialogs.StatusUtil;\nimport org.eclipse.jdt.internal.ui.util.TabFolderLayout;\n\n/*\n * The page for setting code formatter options\n */\npublic class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {\n\n\t// Preference store keys, see JavaCore.getOptions\n\tprivate static final String PREF_NEWLINE_OPENING_BRACES= \"org.eclipse.jdt.core.formatter.newline.openingBrace\";\n\tprivate static final String PREF_NEWLINE_CONTROL_STATEMENT= \"org.eclipse.jdt.core.formatter.newline.controlStatement\";\n\tprivate static final String PREF_NEWLINE_CLEAR_ALL= \"org.eclipse.jdt.core.formatter.newline.clearAll\";\n\tprivate static final String PREF_NEWLINE_ELSE_IF= \"org.eclipse.jdt.core.formatter.newline.elseIf\";\n\tprivate static final String PREF_NEWLINE_EMPTY_BLOCK= \"org.eclipse.jdt.core.formatter.newline.emptyBlock\";\n\tprivate static final String PREF_LINE_SPLIT= \"org.eclipse.jdt.core.formatter.lineSplit\";\t\n\tprivate static final String PREF_STYLE_COMPACT_ASSIGNEMENT= \"org.eclipse.jdt.core.formatter.style.assignment\";\t\n\tprivate static final String PREF_TAB_CHAR= \"org.eclipse.jdt.core.formatter.tabulation.char\";\t\n\tprivate static final String PREF_TAB_SIZE= \"org.eclipse.jdt.core.formatter.tabulation.size\";\n\n\t// values\n\tprivate static final String INSERT= \"insert\";\n\tprivate static final String DO_NOT_INSERT= \"do not insert\";\n\t\n\tprivate static final String COMPACT= \"compact\";\n\tprivate static final String NORMAL= \"normal\";\n\t\n\tprivate static final String TAB= \"tab\";\n\tprivate static final String SPACE= \"space\";\n\t\n\tprivate static final String CLEAR_ALL= \"clear all\";\n\tprivate static final String PRESERVE_ONE= \"preserve one\";\n\t\n\n\tprivate static String[] getAllKeys() {\n\t\treturn new String[] {\n\t\t\tPREF_NEWLINE_OPENING_BRACES, PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL,\n\t\t\tPREF_NEWLINE_ELSE_IF, PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT,\n\t\t\tPREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE\n\t\t};\t\n\t}\n\t\n\t/**\n\t * Gets the currently configured tab size\n\t */\n\tpublic static int getTabSize() {\n\t\tString string= (String) JavaCore.getOptions().get(PREF_TAB_SIZE);\n\t\treturn getIntValue(string, 4);\n\t}\n\t\n\t/**\n\t * Gets the current compating assignement configuration\n\t */\t\n\tpublic static boolean isCompactingAssignment() {\n\t\treturn COMPACT.equals(JavaCore.getOptions().get(PREF_STYLE_COMPACT_ASSIGNEMENT));\n\t}\n\t\n\t/**\n\t * Gets the current compating assignement configuration\n\t */\t\n\tpublic static boolean useSpaces() {\n\t\treturn SPACE.equals(JavaCore.getOptions().get(PREF_TAB_CHAR));\n\t}\t\n\t\n\t\n\tprivate static int getIntValue(String string, int dflt) {\n\t\ttry {\n\t\t\treturn Integer.parseInt(string);\n\t\t} catch (NumberFormatException e) {\n\t\t}\n\t\treturn dflt;\n\t}\t\n\t\t\n\t\n\t/**\n\t * Initializes the current options (read from preference store)\n\t */\n\tpublic static void initDefaults(IPreferenceStore store) {\n\t\tHashtable hashtable= JavaCore.getDefaultOptions();\n\t\tHashtable currOptions= JavaCore.getOptions();\n\t\tString[] allKeys= getAllKeys();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString defValue= (String) hashtable.get(key);\n\t\t\tif (defValue != null) {\n\t\t\t\tstore.setDefault(key, defValue);\n\t\t\t} else {\n\t\t\t\tJavaPlugin.logErrorMessage(\"CodeFormatterPreferencePage: value is null: \" + key);\n\t\t\t}\n\t\t\t// update the JavaCore options from the pref store\n\t\t\tString val= store.getString(key);\n\t\t\tif (val != null) {\n\t\t\t\tcurrOptions.put(key, val);\n\t\t\t}\t\t\t\n\t\t}\n\t\tJavaCore.setOptions(currOptions);\n\t}\n\n\tprivate static class ControlData {\n\t\tprivate String fKey;\n\t\tprivate String[] fValues;\n\t\t\n\t\tpublic ControlData(String key, String[] values) {\n\t\t\tfKey= key;\n\t\t\tfValues= values;\n\t\t}\n\t\t\n\t\tpublic String getKey() {\n\t\t\treturn fKey;\n\t\t}\n\t\t\n\t\tpublic String getValue(boolean selection) {\n\t\t\tint index= selection ? 0 : 1;\n\t\t\treturn fValues[index];\n\t\t}\n\t\t\n\t\tpublic String getValue(int index) {\n\t\t\treturn fValues[index];\n\t\t}\t\t\n\t\t\n\t\tpublic int getSelection(String value) {\n\t\t\tfor (int i= 0; i < fValues.length; i++) {\n\t\t\t\tif (value.equals(fValues[i])) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t}\n\t\n\tprivate Hashtable fWorkingValues;\n\n\tprivate ArrayList fCheckBoxes;\n\tprivate ArrayList fTextBoxes;\n\t\n\tprivate SelectionListener fButtonSelectionListener;\n\tprivate ModifyListener fTextModifyListener;\n\t\n\tprivate String fPreviewText;\n\tprivate IDocument fPreviewDocument;\n\t\n\tprivate Text fTabSizeTextBox;\n\t\n\n\tpublic CodeFormatterPreferencePage() {\n\t\tsetPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());\n\t\tsetDescription(JavaUIMessages.getString(\"CodeFormatterPreferencePage.description\")); //$NON-NLS-1$\n\t\n\t\tfWorkingValues= JavaCore.getOptions();\n\t\tfCheckBoxes= new ArrayList();\n\t\tfTextBoxes= new ArrayList();\n\t\t\n\t\tfButtonSelectionListener= new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {}\n\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (!e.widget.isDisposed()) {\n\t\t\t\t\tcontrolChanged((Button) e.widget);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\tfTextModifyListener= new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (!e.widget.isDisposed()) {\n\t\t\t\t\ttextChanged((Text) e.widget);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\tfPreviewDocument= new Document();\n\t\tfPreviewText= loadPreviewFile(\"CodeFormatterPreviewCode.txt\");\t//$NON-NLS-1$\t\n\t}\n\n\t/*\n\t * @see IWorkbenchPreferencePage#init()\n\t */\t\n\tpublic void init(IWorkbench workbench) {\n\t}\n\n\t/*\n\t * @see PreferencePage#createControl(Composite)\n\t */\n\tpublic void createControl(Composite parent) {\n\t\tsuper.createControl(parent);\n\t\tWorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE));\n\t}\t\n\n\t/*\n\t * @see PreferencePage#createContents(Composite)\n\t */\n\tprotected Control createContents(Composite parent) {\n\t\t\n\t\tGridLayout layout= new GridLayout();\n\t\tlayout.marginHeight= 0;\n\t\tlayout.marginWidth= 0;\n\t\t\n\t\tComposite composite= new Composite(parent, SWT.NONE);\n\t\tcomposite.setLayout(layout);\n\t\t\t\t\n\t\t\t\n\t\tTabFolder folder= new TabFolder(composite, SWT.NONE);\n\t\tfolder.setLayout(new TabFolderLayout());\t\n\t\tfolder.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tString[] insertNotInsert= new String[] { INSERT, DO_NOT_INSERT };\n\t\t\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\n\t\t\n\t\tComposite newlineComposite= new Composite(folder, SWT.NULL);\n\t\tnewlineComposite.setLayout(layout);\n\n\t\tString label= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_opening_braces.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_OPENING_BRACES, insertNotInsert);\t\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_control_statement.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_CONTROL_STATEMENT, insertNotInsert);\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_clear_lines\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_CLEAR_ALL, new String[] { CLEAR_ALL, PRESERVE_ONE } );\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_else_if.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert);\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.newline_empty_block.label\"); //$NON-NLS-1$\n\t\taddCheckBox(newlineComposite, label, PREF_NEWLINE_EMPTY_BLOCK, insertNotInsert);\t\n\t\t\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\t\n\t\t\n\t\tComposite lineSplittingComposite= new Composite(folder, SWT.NULL);\n\t\tlineSplittingComposite.setLayout(layout);\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.split_line.label\"); //$NON-NLS-1$\n\t\taddTextField(lineSplittingComposite, label, PREF_LINE_SPLIT);\n\n\t\tlayout= new GridLayout();\n\t\tlayout.numColumns= 2;\t\n\t\t\n\t\tComposite styleComposite= new Composite(folder, SWT.NULL);\n\t\tstyleComposite.setLayout(layout);\n\t\t\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.style_compact_assignement.label\"); //$NON-NLS-1$\n\t\taddCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ASSIGNEMENT, new String[] { COMPACT, NORMAL } );\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab_char.label\"); //$NON-NLS-1$\n\t\taddCheckBox(styleComposite, label, PREF_TAB_CHAR, new String[] { TAB, SPACE } );\t\t\n\n\t\tlabel= JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab_size.label\"); //$NON-NLS-1$\n\t\tfTabSizeTextBox= addTextField(styleComposite, label, PREF_TAB_SIZE);\t\t\n\t\tfTabSizeTextBox.setEnabled(!usesTabs());\n\n\t\tTabItem item= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.newline.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL));\n\t\titem.setControl(newlineComposite);\n\n\t\titem= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.linesplit.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));\n\t\titem.setControl(lineSplittingComposite);\n\t\t\n\t\titem= new TabItem(folder, SWT.NONE);\n\t\titem.setText(JavaUIMessages.getString(\"CodeFormatterPreferencePage.tab.style.tabtitle\")); //$NON-NLS-1$\n\t\titem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_REF));\n\t\titem.setControl(styleComposite);\t\t\n\t\t\n\t\tcreatePreview(parent);\n\t\t\t\n\t\tupdatePreview();\n\t\t\t\t\t\n\t\treturn composite;\n\t}\n\t\n\tprivate Control createPreview(Composite parent) {\n\t\tSourceViewer previewViewer= new SourceViewer(parent, null, SWT.V_SCROLL);\n\t\tJavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();\n\t\tpreviewViewer.configure(new JavaSourceViewerConfiguration(tools, null));\n\t\tpreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));\n\t\tpreviewViewer.setEditable(false);\n\t\tpreviewViewer.setDocument(fPreviewDocument);\n\t\tControl control= previewViewer.getControl();\n\t\tcontrol.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\treturn control;\n\t}\n\n\t\n\tprivate Button addCheckBox(Composite parent, String label, String key, String[] values) {\n\t\tControlData data= new ControlData(key, values);\n\t\t\n\t\tGridData gd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan= 2;\n\t\t\n\t\tButton checkBox= new Button(parent, SWT.CHECK);\n\t\tcheckBox.setText(label);\n\t\tcheckBox.setData(data);\n\t\tcheckBox.setLayoutData(gd);\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\tcheckBox.setSelection(data.getSelection(currValue) == 0);\n\t\tcheckBox.addSelectionListener(fButtonSelectionListener);\n\t\t\n\t\tfCheckBoxes.add(checkBox);\n\t\treturn checkBox;\n\t}\n\t\n\tprivate Text addTextField(Composite parent, String label, String key) {\t\n\t\tLabel labelControl= new Label(parent, SWT.NONE);\n\t\tlabelControl.setText(label);\n\t\tlabelControl.setLayoutData(new GridData());\n\t\t\t\t\n\t\tText textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);\n\t\ttextBox.setData(key);\n\t\ttextBox.setLayoutData(new GridData());\n\t\t\n\t\tString currValue= (String)fWorkingValues.get(key);\t\n\t\ttextBox.setText(String.valueOf(getIntValue(currValue, 1)));\n\t\ttextBox.setTextLimit(3);\n\t\ttextBox.addModifyListener(fTextModifyListener);\n\n\t\tGridData gd= new GridData();\n\t\tgd.widthHint= convertWidthInCharsToPixels(5);\n\t\ttextBox.setLayoutData(gd);\n\n\t\tfTextBoxes.add(textBox);\n\t\treturn textBox;\n\t}\t\n\t\n\tprivate void controlChanged(Button button) {\n\t\tControlData data= (ControlData) button.getData();\n\t\tboolean selection= button.getSelection();\n\t\tString newValue= data.getValue(selection);\t\n\t\tfWorkingValues.put(data.getKey(), newValue);\n\t\tupdatePreview();\n\t\t\n\t\tif (PREF_TAB_CHAR.equals(data.getKey())) {\n\t\t\tfTabSizeTextBox.setEnabled(!selection);\n\t\t\tupdateStatus(new StatusInfo());\n\t\t\tif (selection) {\n\t\t\t\tfTabSizeTextBox.setText((String)fWorkingValues.get(PREF_TAB_SIZE));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void textChanged(Text textControl) {\n\t\tString key= (String) textControl.getData();\n\t\tString number= textControl.getText();\n\t\tIStatus status= validatePositiveNumber(number);\n\t\tif (!status.matches(IStatus.ERROR)) {\n\t\t\tfWorkingValues.put(key, number);\n\t\t}\n\t\tupdateStatus(status);\n\t\tupdatePreview();\n\t}\n\t\t\n\t\n\t/*\n\t * @see IPreferencePage#performOk()\n\t */\n\tpublic boolean performOk() {\n\t\tString[] allKeys= getAllKeys();\n\t\t// preserve other options\n\t\t// store in JCore and the preferences\n\t\tHashtable actualOptions= JavaCore.getOptions();\n\t\tIPreferenceStore store= getPreferenceStore();\n\t\tfor (int i= 0; i < allKeys.length; i++) {\n\t\t\tString key= allKeys[i];\n\t\t\tString val= (String) fWorkingValues.get(key);\n\t\t\tactualOptions.put(key, val);\n\t\t\tstore.putValue(key, val);\n\t\t}\n\t\tJavaCore.setOptions(actualOptions);\n\t\treturn super.performOk();\n\t}\t\n\t\n\t/*\n\t * @see PreferencePage#performDefaults()\n\t */\n\tprotected void performDefaults() {\n\t\tfWorkingValues= JavaCore.getDefaultOptions();\n\t\tupdateControls();\n\t\tsuper.performDefaults();\n\t}\n\n\tprivate String loadPreviewFile(String filename) {\n\t\tString separator= System.getProperty(\"line.separator\"); //$NON-NLS-1$\n\t\tStringBuffer btxt= new StringBuffer(512);\n\t\tBufferedReader rin= null;\n\t\ttry {\n\t\t\trin= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));\n\t\t\tString line;\n\t\t\twhile ((line= rin.readLine()) != null) {\n\t\t\t\tbtxt.append(line);\n\t\t\t\tbtxt.append(separator);\n\t\t\t}\n\t\t} catch (IOException io) {\n\t\t\tJavaPlugin.log(io);\n\t\t} finally {\n\t\t\tif (rin != null) {\n\t\t\t\ttry { rin.close(); } catch (IOException e) {}\n\t\t\t}\n\t\t}\n\t\treturn btxt.toString();\n\t}\n\n\n\tprivate void updatePreview() {\n\t\tfPreviewDocument.set(CodeFormatter.format(fPreviewText, 0, fWorkingValues));\n\t}\t\n\t\n\tprivate void updateControls() {\n\t\t// update the UI\n\t\tfor (int i= fCheckBoxes.size() - 1; i >= 0; i--) {\n\t\t\tButton curr= (Button) fCheckBoxes.get(i);\n\t\t\tControlData data= (ControlData) curr.getData();\n\t\t\t\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(data.getKey());\t\n\t\t\tcurr.setSelection(data.getSelection(currValue) == 0);\t\t\t\n\t\t}\n\t\tfor (int i= fTextBoxes.size() - 1; i >= 0; i--) {\n\t\t\tText curr= (Text) fTextBoxes.get(i);\n\t\t\tString key= (String) curr.getData();\t\t\n\t\t\tString currValue= (String) fWorkingValues.get(key);\n\t\t\tcurr.setText(currValue);\n\t\t}\n\t\tfTabSizeTextBox.setEnabled(!usesTabs());\t\n\t}\n\t\n\tprivate IStatus validatePositiveNumber(String number) {\n\t\tStatusInfo status= new StatusInfo();\n\t\tif (number.length() == 0) {\n\t\t\tstatus.setError(JavaUIMessages.getString(\"CodeFormatterPreferencePage.empty_input\"));\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tint value= Integer.parseInt(number);\n\t\t\t\tif (value < 0) {\n\t\t\t\t\tstatus.setError(JavaUIMessages.getFormattedString(\"CodeFormatterPreferencePage.invalid_input\", number));\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tstatus.setError(JavaUIMessages.getFormattedString(\"CodeFormatterPreferencePage.invalid_input\", number));\n\t\t\t}\n\t\t}\n\t\treturn status;\n\t}\n\t\t\t\n\t\n\tprivate void updateStatus(IStatus status) {\n\t\tif (!status.matches(IStatus.ERROR)) {\n\t\t\t// look if there are more severe errors\n\t\t\tfor (int i= 0; i < fTextBoxes.size(); i++) {\n\t\t\t\tText curr= (Text) fTextBoxes.get(i);\n\t\t\t\tif (!(curr == fTabSizeTextBox && usesTabs())) {\n\t\t\t\t\tIStatus currStatus= validatePositiveNumber(curr.getText());\n\t\t\t\t\tstatus= StatusUtil.getMoreSevere(currStatus, status);\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\tsetValid(!status.matches(IStatus.ERROR));\n\t\tStatusUtil.applyToStatusLine(this, status);\n\t}\n\t\n\tprivate boolean usesTabs() {\n\t\treturn TAB.equals(fWorkingValues.get(PREF_TAB_CHAR));\n\t}\n\t\t\n\n}\n\n\n"}}},{"rowIdx":98,"cells":{"issue_id":{"kind":"number","value":5418,"string":"5,418"},"title":{"kind":"string","value":"Bug 5418 bracket marker stays in editor"},"body":{"kind":"string","value":"private void showDebugSourcePage(String typeName) { if (dialog.open() == dialog.OK) { } 1. set the cursor after the opening bracket (after dialog.OK) 2. press enter 3. The bracket box includes all characters insterted by the auto indenter"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"d287924"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-11-01T19:13:57Z","string":"2001-11-01T19:13:57Z"},"report_datetime":{"kind":"timestamp","value":"2001-11-01T15:53:20Z","string":"2001-11-01T15:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.javaeditor;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.Iterator;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StyleRange;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.KeyListener;\nimport org.eclipse.swt.events.MouseEvent;\nimport org.eclipse.swt.events.MouseListener;\nimport org.eclipse.swt.events.PaintEvent;\nimport org.eclipse.swt.events.PaintListener;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Shell;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IFolder;\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.IWorkspaceRoot;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.Path;\n\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.ErrorDialog;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.dialogs.ProgressMonitorDialog;\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.BadPositionCategoryException;\nimport org.eclipse.jface.text.DefaultPositionUpdater;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IPositionUpdater;\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.ITextInputListener;\nimport org.eclipse.jface.text.ITextOperationTarget;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.TextPresentation;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.jface.text.source.IAnnotationModel;\nimport org.eclipse.jface.text.source.ISourceViewer;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.ISelectionProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\n\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IViewPart;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.actions.WorkspaceModifyOperation;\nimport org.eclipse.ui.dialogs.SaveAsDialog;\nimport org.eclipse.ui.part.FileEditorInput;\nimport org.eclipse.ui.texteditor.IDocumentProvider;\nimport org.eclipse.ui.texteditor.ITextEditorActionConstants;\nimport org.eclipse.ui.texteditor.MarkerAnnotation;\nimport org.eclipse.ui.texteditor.MarkerUtilities;\nimport org.eclipse.ui.texteditor.TextOperationAction;\nimport org.eclipse.ui.views.tasklist.TaskList;\n\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jdt.core.ISourceReference;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\n\nimport org.eclipse.jdt.ui.IContextMenuConstants;\nimport org.eclipse.jdt.ui.IWorkingCopyManager;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory;\nimport org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction;\nimport org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.BracketHighlighter.BracketPositionManager;\nimport org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.BracketHighlighter.HighlightBrackets;\nimport org.eclipse.jdt.internal.ui.text.JavaPairMatcher;\n\n\n/**\n * Java specific text editor.\n */\npublic class CompilationUnitEditor extends JavaEditor {\n\t\n\t\n\t/**\n\t * Responsible for highlighting matching pairs of brackets.\n\t */\n\tclass BracketHighlighter implements KeyListener, MouseListener {\t\t\n\t\t\n\t\t/**\n\t\t * Highlights the brackets.\n\t\t */\n\t\tclass HighlightBrackets implements PaintListener {\n\t\t\t\t\t\t\n\t\t\tprivate boolean fHooked= false;\n\t\t\tprivate JavaPairMatcher fMatcher= new JavaPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' });\n\t\t\tprivate StyledText fTextWidget;\n\t\t\tprivate Color fColor;\n\t\t\t\n\t\t\tpublic HighlightBrackets() {\n\t\t\t\tfTextWidget= fSourceViewer.getTextWidget();\n\t\t\t\tfColor= fTextWidget.getDisplay().getSystemColor(SWT.COLOR_MAGENTA);\n\t\t\t}\n\t\t\t\n\t\t\tpublic void dispose() {\n\t\t\t\tif (fMatcher != null) {\n\t\t\t\t\tfMatcher.dispose();\n\t\t\t\t\tfMatcher= null;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfTextWidget= null;\n\t\t\t\tfColor= null;\n\t\t\t}\n\t\t\t\n\t\t\tpublic void run() {\n\t\t\t\t\n\t\t\t\tint offset= fSourceViewer.getSelectedRange().x;\n\t\t\t\tIRegion pair= fMatcher.match(fSourceViewer.getDocument(), offset);\n\t\t\t\t\n\t\t\t\tif (pair == null) {\n\t\t\t\t\tremoveStyles();\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tif (pair.getOffset() != fBracketPosition.getOffset() || pair.getLength() != fBracketPosition.getLength())\n\t\t\t\t\t\tremoveStyles();\n\t\t\t\t\t\t\n\t\t\t\t\tfBracketPosition.offset= pair.getOffset();\n\t\t\t\t\tfBracketPosition.length= pair.getLength();\n\t\t\t\t\tfBracketPosition.isDeleted= false;\n\t\t\t\t\t\n\t\t\t\t\tapplyStyles();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tpublic void paintControl(PaintEvent event) {\n\t\t\t\thandleDrawRequest(event.gc);\n\t\t\t}\n\t\t\t\n\t\t\tprivate void handleDrawRequest(GC gc) {\n\t\t\t\tIRegion region= fSourceViewer.getVisibleRegion();\n\t\t\t\tint offset= fBracketPosition.getOffset();\n\t\t\t\tint length= fBracketPosition.getLength();\n\t\t\t\t\n\t\t\t\tif (region.getOffset() <= offset && region.getOffset() + region.getLength() >= offset + length) {\n\t\t\t\t\toffset -= region.getOffset();\t\t\t\t\t\t\n\t\t\t\t\tif (length == 2) {\n\t\t\t\t\t\tdraw(gc, offset, length);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdraw(gc, offset, 1);\n\t\t\t\t\t\tdraw(gc, offset + length -1, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tprivate void draw(GC gc, int offset, int length) {\n\t\t\t\tif (gc != null) {\n\t\t\t\t\tPoint left= fTextWidget.getLocationAtOffset(offset);\n\t\t\t\t\tPoint right= fTextWidget.getLocationAtOffset(offset + length);\n\t\t\t\t\tgc.setForeground(fColor);\n\t\t\t\t\tgc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);\n\t\t\t\t} else {\n\t\t\t\t\tfTextWidget.redrawRange(offset, length, true);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\tprivate void removeStyles() {\n\t\t\t\tfHooked= false;\n\t\t\t\tfTextWidget.removePaintListener(this);\n\t\t\t\thandleDrawRequest(null);\n\t\t\t}\n\t\t\t\n\t\t\tprivate void applyStyles() {\n\t\t\t\tif (!fHooked) {\n\t\t\t\t\tfHooked= true;\n\t\t\t\t\tfTextWidget.addPaintListener(this);\n\t\t\t\t}\n\t\t\t\thandleDrawRequest(null);\n\t\t\t}\n\t\t};\n\t\t\n\t\t/**\n\t\t * Monitors the input document of the source viewer.\n\t\t */\n\t\tclass BracketPositionManager implements ITextInputListener {\n\t\t\t\n\t\t\tprivate IDocument fDocument;\n\t\t\tprivate IPositionUpdater fPositionUpdater;\n\t\t\tprivate String fCategory;\n\t\t\t\n\t\t\tpublic BracketPositionManager() {\n\t\t\t\tfCategory= getClass().getName() + hashCode();\n\t\t\t\tfPositionUpdater= new DefaultPositionUpdater(fCategory);\n\t\t\t}\n\t\t\t\n\t\t\tpublic void install() {\n\t\t\t\tfSourceViewer.addTextInputListener(this);\n\t\t\t\tstart(fSourceViewer.getDocument());\n\t\t\t}\n\t\t\t\n\t\t\tpublic void dispose() {\n\t\t\t\tfSourceViewer.removeTextInputListener(this);\n\t\t\t\tif (fDocument != null) {\n\t\t\t\t\tstop(fDocument);\n\t\t\t\t\tfDocument= null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tprivate void start(IDocument document) {\n\t\t\t\tfDocument= document;\n\t\t\t\tfDocument.addPositionCategory(fCategory);\n\t\t\t\tfDocument.addPositionUpdater(fPositionUpdater);\n\t\t\t\ttry {\n\t\t\t\t\tfDocument.addPosition(fCategory, fBracketPosition);\n\t\t\t\t} catch (BadPositionCategoryException x) {\n\t\t\t\t\t// should not happen\n\t\t\t\t} catch (BadLocationException x) {\n\t\t\t\t\t// should not happen\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tprivate void stop(IDocument document) {\n\t\t\t\tif (document == fDocument) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdocument.removePositionUpdater(fPositionUpdater);\n\t\t\t\t\t\tdocument.removePositionCategory(fCategory);\t\t\t\n\t\t\t\t\t} catch (BadPositionCategoryException x) {\n\t\t\t\t\t\t// should not happen\n\t\t\t\t\t}\n\t\t\t\t\tfDocument= null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t/*\n\t\t\t * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)\n\t\t\t */\n\t\t\tpublic void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {\n\t\t\t\tif (oldInput != null)\n\t\t\t\t\tstop(oldInput);\n\t\t\t}\n\t\t\t\n\t\t\t/*\n\t\t\t * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)\n\t\t\t */\n\t\t\tpublic void inputDocumentChanged(IDocument oldInput, IDocument newInput) {\n\t\t\t\tif (newInput != null)\n\t\t\t\t\tstart(newInput);\n\t\t\t}\n\t\t};\n\t\t\n\t\tprivate Position fBracketPosition= new Position(0, 0);\n\t\tprivate BracketPositionManager fManager= new BracketPositionManager();\n\t\t\n\t\tprivate ISourceViewer fSourceViewer;\n\t\tprivate HighlightBrackets fHighlightBrackets;\n\n\t\tpublic BracketHighlighter(ISourceViewer sourceViewer) {\n\t\t\tfSourceViewer= sourceViewer;\n\t\t\tfHighlightBrackets= new HighlightBrackets();\n\t\t}\n\t\t\n\t\tpublic void install() {\n\t\t\t\n\t\t\tfManager.install();\n\t\t\t\n\t\t\tStyledText text= fSourceViewer.getTextWidget();\n\t\t\ttext.addKeyListener(this);\n\t\t\ttext.addMouseListener(this);\n\t\t}\n\t\t\n\t\tpublic void dispose() {\n\t\t\t\n\t\t\tif (fManager != null) {\n\t\t\t\tfManager.dispose();\n\t\t\t\tfManager= null;\n\t\t\t}\n\t\t\t\n\t\t\tif (fHighlightBrackets != null) {\n\t\t\t\tfHighlightBrackets.dispose();\n\t\t\t\tfHighlightBrackets= null;\n\t\t\t}\n\t\t\t\n\t\t\tif (fSourceViewer != null && fBracketHighlighter != null) {\n\t\t\t\t\n\t\t\t\tStyledText text= fSourceViewer.getTextWidget();\n\t\t\t\tif (text != null && !text.isDisposed()) {\n\t\t\t\t\ttext.removeKeyListener(fBracketHighlighter);\n\t\t\t\t\ttext.removeMouseListener(fBracketHighlighter);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfSourceViewer= null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/*\n\t\t * @see KeyListener#keyPressed(KeyEvent)\n\t\t */\n\t\tpublic void keyPressed(KeyEvent e) {\n\t\t}\n\n\t\t/*\n\t\t * @see KeyListener#keyReleased(KeyEvent)\n\t\t */\n\t\tpublic void keyReleased(KeyEvent e) {\n\t\t\tfHighlightBrackets.run();\n\t\t}\n\n\t\t/*\n\t\t * @see MouseListener#mouseDoubleClick(MouseEvent)\n\t\t */\n\t\tpublic void mouseDoubleClick(MouseEvent e) {\n\t\t}\n\n\t\t/*\n\t\t * @see MouseListener#mouseDown(MouseEvent)\n\t\t */\n\t\tpublic void mouseDown(MouseEvent e) {\n\t\t}\n\n\t\t/*\n\t\t * @see MouseListener#mouseUp(MouseEvent)\n\t\t */\n\t\tpublic void mouseUp(MouseEvent e) {\n\t\t\tfHighlightBrackets.run();\n\t\t}\n\t};\n\t\n\t\n\t/** The status line clearer */\n\tprotected ISelectionChangedListener fStatusLineClearer;\n\t/** The editor's save policy */\n\tprotected ISavePolicy fSavePolicy;\n\t/** Listener to annotation model changes that updates the error tick in the tab image */\n\tprivate JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;\n\t/** The editor's bracket highlighter */\n\tprivate BracketHighlighter fBracketHighlighter;\n\t\n\t\n\t/**\n\t * Creates a new compilation unit editor.\n\t */\n\tpublic CompilationUnitEditor() {\n\t\tsuper();\n\t\tsetDocumentProvider(JavaPlugin.getDefault().getCompilationUnitDocumentProvider());\n\t\tsetEditorContextMenuId(\"#CompilationUnitEditorContext\"); //$NON-NLS-1$\n\t\tsetRulerContextMenuId(\"#CompilationUnitRulerContext\"); //$NON-NLS-1$\n\t\tsetOutlinerContextMenuId(\"#CompilationUnitOutlinerContext\"); //$NON-NLS-1$\n\t\tfSavePolicy= null;\n\t\t\t\n\t\tfJavaEditorErrorTickUpdater= new JavaEditorErrorTickUpdater(this);\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#createActions\n\t */\n\tprotected void createActions() {\n\t\t\n\t\tsuper.createActions();\n\t\t\n\t\tsetAction(\"ContentAssistProposal\", new TextOperationAction(JavaEditorMessages.getResourceBundle(), \"ContentAssistProposal.\", this, ISourceViewer.CONTENTASSIST_PROPOSALS));\t\t\t //$NON-NLS-1$ //$NON-NLS-2$\n\t\tsetAction(\"AddImportOnSelection\", new AddImportOnSelectionAction(this));\t\t //$NON-NLS-1$\n\t\tsetAction(\"OrganizeImports\", new OrganizeImportsAction(this)); //$NON-NLS-1$\n\t\t\n\t\tsetAction(\"Comment\", new TextOperationAction(JavaEditorMessages.getResourceBundle(), \"Comment.\", this, ITextOperationTarget.PREFIX)); //$NON-NLS-1$ //$NON-NLS-2$\n\t\tsetAction(\"Uncomment\", new TextOperationAction(JavaEditorMessages.getResourceBundle(), \"Uncomment.\", this, ITextOperationTarget.STRIP_PREFIX)); //$NON-NLS-1$ //$NON-NLS-2$\n\t\tsetAction(\"Format\", new TextOperationAction(JavaEditorMessages.getResourceBundle(), \"Format.\", this, ISourceViewer.FORMAT)); //$NON-NLS-1$ //$NON-NLS-2$\n\t\t\n\t\tsetAction(\"AddBreakpoint\", new AddBreakpointAction(this)); //$NON-NLS-1$\n\t\tsetAction(\"ManageBreakpoints\", new BreakpointRulerAction(getVerticalRuler(), this)); //$NON-NLS-1$\n\t\t\n\t\tsetAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, getAction(\"ManageBreakpoints\"));\t\t //$NON-NLS-1$\n\t}\n\t\n\t/*\n\t * @see JavaEditor#getJavaSourceReferenceAt\n\t */\n\tprotected ISourceReference getJavaSourceReferenceAt(int position) {\n\t\t\n\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\n\t\tICompilationUnit unit= manager.getWorkingCopy(getEditorInput());\n\t\t\n\t\tif (unit != null) {\n\t\t\tsynchronized (unit) {\n\t\t\t\ttry {\n\t\t\t\t\tunit.reconcile();\n\t\t\t\t\tIJavaElement element= unit.getElementAt(position);\n\t\t\t\t\tif (element instanceof ISourceReference)\n\t\t\t\t\t\treturn (ISourceReference) element;\n\t\t\t\t} catch (JavaModelException x) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\t/*\n\t * @see AbstractEditor#editorContextMenuAboutToChange\n\t */\n\tpublic void editorContextMenuAboutToShow(IMenuManager menu) {\n\t\tsuper.editorContextMenuAboutToShow(menu);\n\t\t\n\t\taddAction(menu, IContextMenuConstants.GROUP_GENERATE, \"ContentAssistProposal\"); //$NON-NLS-1$\n\t\taddAction(menu, IContextMenuConstants.GROUP_GENERATE, \"AddImportOnSelection\"); //$NON-NLS-1$\n\t\taddAction(menu, IContextMenuConstants.GROUP_GENERATE, \"OrganizeImports\"); //$NON-NLS-1$\n\t\taddAction(menu, ITextEditorActionConstants.GROUP_ADD, \"AddBreakpoint\"); //$NON-NLS-1$\n\t\taddAction(menu, ITextEditorActionConstants.GROUP_EDIT, \"Comment\"); //$NON-NLS-1$\n\t\taddAction(menu, ITextEditorActionConstants.GROUP_EDIT, \"Uncomment\"); //$NON-NLS-1$\n\t\taddAction(menu, ITextEditorActionConstants.GROUP_EDIT, \"Format\"); //$NON-NLS-1$\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#rulerContextMenuAboutToShow\n\t */\n\tprotected void rulerContextMenuAboutToShow(IMenuManager menu) {\n\t\tsuper.rulerContextMenuAboutToShow(menu);\n\t\taddAction(menu, \"ManageBreakpoints\"); //$NON-NLS-1$\n\t}\n\t\n\t/*\n\t * @see JavaEditor#createOutlinePage\n\t */\n\tprotected JavaOutlinePage createOutlinePage() {\n\t\tJavaOutlinePage page= super.createOutlinePage();\n\t\t\n\t\tpage.setAction(\"OrganizeImports\", new OrganizeImportsAction(this)); //$NON-NLS-1$\n\t\tpage.setAction(\"ReplaceWithEdition\", new JavaReplaceWithEditionAction(page)); //$NON-NLS-1$\n\t\tpage.setAction(\"AddEdition\", new JavaAddElementFromHistory(this, page)); //$NON-NLS-1$\n\t\t\n\t\tDeleteISourceManipulationsAction deleteElement= new DeleteISourceManipulationsAction(page);\n\t\tpage.setAction(\"DeleteElement\", deleteElement); //$NON-NLS-1$\n\t\tpage.addSelectionChangedListener(deleteElement);\n\t\t\n\t\treturn page;\n\t}\n\n\t/*\n\t * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)\n\t */\n\tprotected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {\n\t\tif (page != null) {\n\t\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\n\t\t\tpage.setInput(manager.getWorkingCopy(input));\n\t\t}\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor)\n\t */\n\tprotected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) {\n\t\tIDocumentProvider p= getDocumentProvider();\n\t\tif (p instanceof CompilationUnitDocumentProvider) {\n\t\t\tCompilationUnitDocumentProvider cp= (CompilationUnitDocumentProvider) p;\n\t\t\tcp.setSavePolicy(fSavePolicy);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tsuper.performSaveOperation(operation, progressMonitor);\n\t\t} finally {\n\t\t\tif (p instanceof CompilationUnitDocumentProvider) {\n\t\t\t\tCompilationUnitDocumentProvider cp= (CompilationUnitDocumentProvider) p;\n\t\t\t\tcp.setSavePolicy(null);\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#doSave(IProgressMonitor)\n\t */\n\tpublic void doSave(IProgressMonitor progressMonitor) {\n\t\t\n\t\tIDocumentProvider p= getDocumentProvider();\n\t\tif (p == null)\n\t\t\treturn;\n\t\t\t\n\t\tif (p.isDeleted(getEditorInput())) {\n\t\t\t\n\t\t\tif (isSaveAsAllowed()) {\n\t\t\t\t\n\t\t\t\t/*\n\t\t\t\t * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.\n\t\t\t\t * Changed Behavior to make sure that if called inside a regular save (because\n\t\t\t\t * of deletion of input element) there is a way to report back to the caller.\n\t\t\t\t */\n\t\t\t\t performSaveAs(progressMonitor);\n\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\t/* \n\t\t\t\t * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there\n\t\t\t\t * Missing resources.\n\t\t\t\t */\n\t\t\t\tShell shell= getSite().getShell();\n\t\t\t\tMessageDialog.openError(shell, JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.title1\"), JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.message1\")); //$NON-NLS-1$ //$NON-NLS-2$\n\t\t\t}\n\t\t\t\n\t\t} else {\t\n\t\t\t\n\t\t\tgetStatusLineManager().setErrorMessage(\"\"); //$NON-NLS-1$\n\t\t\t\n\t\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\n\t\t\tICompilationUnit unit= manager.getWorkingCopy(getEditorInput());\n\t\t\t\n\t\t\tif (unit != null) {\n\t\t\t\tsynchronized (unit) { \n\t\t\t\t\tperformSaveOperation(createSaveOperation(false), progressMonitor); \n\t\t\t\t}\n\t\t\t} else \n\t\t\t\tperformSaveOperation(createSaveOperation(false), progressMonitor);\n\t\t}\n\t}\n\t\n\t/**\n\t * Jumps to the error next according to the given direction.\n\t */\n\tpublic void gotoError(boolean forward) {\n\t\t\n\t\tISelectionProvider provider= getSelectionProvider();\n\t\t\n\t\tif (fStatusLineClearer != null) {\n\t\t\tprovider.removeSelectionChangedListener(fStatusLineClearer);\n\t\t\tfStatusLineClearer= null;\n\t\t}\n\t\t\n\t\tITextSelection s= (ITextSelection) provider.getSelection();\n\t\tIMarker nextError= getNextError(s.getOffset(), forward);\n\t\t\n\t\tif (nextError != null) {\n\t\t\t\n\t\t\tgotoMarker(nextError);\n\t\t\t\n\t\t\tIWorkbenchPage page= getSite().getPage();\n\t\t\t\n\t\t\tIViewPart view= view= page.findView(\"org.eclipse.ui.views.TaskList\"); //$NON-NLS-1$\n\t\t\tif (view instanceof TaskList) {\n\t\t\t\tStructuredSelection ss= new StructuredSelection(nextError);\n\t\t\t\t((TaskList) view).setSelection(ss, true);\n\t\t\t}\n\t\t\t\n\t\t\tgetStatusLineManager().setErrorMessage(nextError.getAttribute(IMarker.MESSAGE, \"\")); //$NON-NLS-1$\n\t\t\tfStatusLineClearer= new ISelectionChangedListener() {\n\t\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\t\tgetSelectionProvider().removeSelectionChangedListener(fStatusLineClearer);\n\t\t\t\t\tfStatusLineClearer= null;\n\t\t\t\t\tgetStatusLineManager().setErrorMessage(\"\"); //$NON-NLS-1$\n\t\t\t\t}\n\t\t\t};\n\t\t\tprovider.addSelectionChangedListener(fStatusLineClearer);\n\t\t\t\n\t\t} else {\n\t\t\t\n\t\t\tgetStatusLineManager().setErrorMessage(\"\"); //$NON-NLS-1$\n\t\t\t\n\t\t}\n\t}\n\n\tprivate IMarker getNextError(int offset, boolean forward) {\n\t\t\n\t\tIMarker nextError= null;\n\t\t\n\t\tIDocument document= getDocumentProvider().getDocument(getEditorInput());\n\t\tint endOfDocument= document.getLength(); \n\t\tint distance= 0;\n\t\t\n\t\tIAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());\n\t\tIterator e= model.getAnnotationIterator();\n\t\twhile (e.hasNext()) {\n\t\t\tAnnotation a= (Annotation) e.next();\n\t\t\tif (a instanceof MarkerAnnotation) {\n\t\t\t\tMarkerAnnotation ma= (MarkerAnnotation) a;\n\t\t\t\tIMarker marker= ma.getMarker();\n\t\t\n\t\t\t\tif (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {\n\t\t\t\t\tPosition p= model.getPosition(a);\n\t\t\t\t\tif (!p.includes(offset)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tint currentDistance= 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (forward) {\n\t\t\t\t\t\t\tcurrentDistance= p.getOffset() - offset;\n\t\t\t\t\t\t\tif (currentDistance < 0)\n\t\t\t\t\t\t\t\tcurrentDistance= endOfDocument - offset + p.getOffset();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcurrentDistance= offset - p.getOffset();\n\t\t\t\t\t\t\tif (currentDistance < 0)\n\t\t\t\t\t\t\t\tcurrentDistance= offset + endOfDocument - p.getOffset();\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (nextError == null || currentDistance < distance) {\n\t\t\t\t\t\t\tdistance= currentDistance;\n\t\t\t\t\t\t\tnextError= marker;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn nextError;\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#isSaveAsAllowed() \n\t */\n\tpublic boolean isSaveAsAllowed() {\n\t\treturn true;\n\t}\n\t\n\t/*\n\t * 1GF7WG9: ITPJUI:ALL - EXCEPTION: \"Save As...\" always fails\n\t */\n\tprotected IPackageFragment getPackage(IWorkspaceRoot root, IPath path) {\n\t\t\t\t\n\t\tif (path.segmentCount() == 1) {\n\t\t\t\n\t\t\tIProject project= root.getProject(path.toString());\n\t\t\tif (project != null) {\n\t\t\t\tIJavaProject jProject= JavaCore.create(project);\n\t\t\t\tif (jProject != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tIJavaElement element= jProject.findElement(new Path(\"\")); //$NON-NLS-1$\n\t\t\t\t\t\tif (element instanceof IPackageFragment) {\n\t\t\t\t\t\t\tIPackageFragment fragment= (IPackageFragment) element;\n\t\t\t\t\t\t\tIJavaElement parent= fragment.getParent();\n\t\t\t\t\t\t\tif (parent instanceof IPackageFragmentRoot) {\n\t\t\t\t\t\t\t\tIPackageFragmentRoot pRoot= (IPackageFragmentRoot) parent;\n\t\t\t\t\t\t\t\tif ( !pRoot.isArchive() && !pRoot.isExternal() && path.equals(pRoot.getPath()))\n\t\t\t\t\t\t\t\t\treturn fragment;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (JavaModelException x) {\n\t\t\t\t\t\t// ignore\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn null;\n\t\t\t\n\t\t} else if (path.segmentCount() > 1) {\n\t\t\n\t\t\tIFolder folder= root.getFolder(path);\n\t\t\tIJavaElement element= JavaCore.create(folder);\n\t\t\tif (element instanceof IPackageFragment)\n\t\t\t\treturn (IPackageFragment) element;\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\t/*\n\t * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.\n\t * Changed behavior to make sure that if called inside a regular save (because\n\t * of deletion of input element) there is a way to report back to the caller.\n\t */\t\n\tprotected void performSaveAs(IProgressMonitor progressMonitor) {\n\t\t\n\t\tShell shell= getSite().getShell();\n\t\t\n\t\tSaveAsDialog dialog= new SaveAsDialog(shell);\n\t\tif (dialog.open() == Dialog.CANCEL) {\n\t\t\tif (progressMonitor != null)\n\t\t\t\tprogressMonitor.setCanceled(true);\n\t\t\treturn;\n\t\t}\n\t\t\t\n\t\tIPath filePath= dialog.getResult();\n\t\tif (filePath == null) {\n\t\t\tif (progressMonitor != null)\n\t\t\t\tprogressMonitor.setCanceled(true);\n\t\t\treturn;\n\t\t}\n\t\t\t\n\t\tfilePath= filePath.removeTrailingSeparator();\n\t\tfinal String fileName= filePath.lastSegment();\n\t\tIPath folderPath= filePath.removeLastSegments(1);\n\t\tif (folderPath == null) {\n\t\t\tif (progressMonitor != null)\n\t\t\t\tprogressMonitor.setCanceled(true);\t\t\t\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tIWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();\n\t\t\n\t\t/*\n\t\t * 1GF7WG9: ITPJUI:ALL - EXCEPTION: \"Save As...\" always fails\n\t\t */\n\t\tfinal IPackageFragment fragment= getPackage(root, folderPath);\n\t\t\n\t\tIFile file= root.getFile(filePath);\n\t\tfinal FileEditorInput newInput= new FileEditorInput(file);\n\t\t\n\t\tWorkspaceModifyOperation op= new WorkspaceModifyOperation() {\n\t\t\tpublic void execute(final IProgressMonitor monitor) throws CoreException {\n\t\t\t\t\n\t\t\t\tif (fragment != null) {\n\t\t\t\t\ttry {\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t// copy to another package\n\t\t\t\t\t\tIWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();\n\t\t\t\t\t\tICompilationUnit unit= manager.getWorkingCopy(getEditorInput());\n\t\t\t\t\t\t\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * 1GJXY0L: ITPJUI:WINNT - NPE during save As in Java editor\n\t\t\t\t\t\t * Introduced null check, just go on in the null case\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (unit != null) {\n\t\t\t\t\t\t\t/* \n\t\t\t\t\t\t\t * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there\n\t\t\t\t\t\t\t * Changed false to true.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tunit.copy(fragment, null, fileName, true, monitor);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t} catch (JavaModelException x) {\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// if (fragment == null) then copy to a directory which is not a package\n\t\t\t\t// if (unit == null) copy the file that is not a compilation unit\n\t\t\t\t\n\t\t\t\t/* \n\t\t\t\t * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there\n\t\t\t\t * Changed false to true.\n\t\t\t\t */\n\t\t\t\tgetDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);\n\t\t\t}\n\t\t};\n\t\t\n\t\tboolean success= false;\n\t\ttry {\n\t\t\t\n\t\t\tif (fragment == null)\n\t\t\t\tgetDocumentProvider().aboutToChange(newInput);\n\t\t\t\n\t\t\tnew ProgressMonitorDialog(shell).run(false, true, op);\n\t\t\tsetInput(newInput);\n\t\t\tsuccess= true;\n\t\t\t\n\t\t} catch (InterruptedException x) {\n\t\t} catch (InvocationTargetException x) {\n\t\t\t\n\t\t\t/* \n\t\t\t * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there\n\t\t\t * Missing resources.\n\t\t\t */\t\t\t\t\t\t\n\t\t\tThrowable t= x.getTargetException();\n\t\t\tif (t instanceof CoreException) {\n\t\t\t\tCoreException cx= (CoreException) t;\n\t\t\t\tErrorDialog.openError(shell, JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.title2\"), JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.message2\"), cx.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$\n\t\t\t} else {\n\t\t\t\tMessageDialog.openError(shell, JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.title3\"), JavaEditorMessages.getString(\"CompilationUnitEditor.error.saving.message3\") + t.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$\n\t\t\t}\n\t\t\t\n\t\t} finally {\n\t\t\t\n\t\t\tif (fragment == null)\n\t\t\t\tgetDocumentProvider().changed(newInput);\n\t\t\t\t\n\t\t\tif (progressMonitor != null)\n\t\t\t\tprogressMonitor.setCanceled(!success);\n\t\t}\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#doSetInput(IEditorInput)\n\t */\n\tprotected void doSetInput(IEditorInput input) throws CoreException {\n\t\tsuper.doSetInput(input);\n\t\tfJavaEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input));\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#dispose()\n\t */\n\tpublic void dispose() {\n\t\tif (fJavaEditorErrorTickUpdater != null) {\n\t\t\tfJavaEditorErrorTickUpdater.setAnnotationModel(null);\n\t\t\tfJavaEditorErrorTickUpdater= null;\n\t\t}\n\t\t\n\t\tif (fBracketHighlighter != null) {\n\t\t\tfBracketHighlighter.dispose();\n\t\t\tfBracketHighlighter= null;\n\t\t}\n\t\t\n\t\tsuper.dispose();\n\t}\n\t\n\t/*\n\t * @see AbstractTextEditor#createPartControl(Composite)\n\t */\n\tpublic void createPartControl(Composite parent) {\n\t\tsuper.createPartControl(parent);\n\t\t\n\t\t// create and install bracket highlighter\n\t\tISourceViewer sourceViewer= getSourceViewer();\n\t\tfBracketHighlighter= new BracketHighlighter(sourceViewer);\n\t\tfBracketHighlighter.install();\n\t}\n}"}}},{"rowIdx":99,"cells":{"issue_id":{"kind":"number","value":5418,"string":"5,418"},"title":{"kind":"string","value":"Bug 5418 bracket marker stays in editor"},"body":{"kind":"string","value":"private void showDebugSourcePage(String typeName) { if (dialog.open() == dialog.OK) { } 1. set the cursor after the opening bracket (after dialog.OK) 2. press enter 3. The bracket box includes all characters insterted by the auto indenter"},"status":{"kind":"string","value":"resolved fixed"},"after_fix_sha":{"kind":"string","value":"d287924"},"project_name":{"kind":"string","value":"JDT"},"repo_url":{"kind":"string","value":"https://github.com/eclipse-jdt/eclipse.jdt.ui"},"repo_name":{"kind":"string","value":"eclipse-jdt/eclipse.jdt.ui"},"language":{"kind":"string","value":"java"},"issue_url":{"kind":"null"},"before_fix_sha":{"kind":"null"},"pull_url":{"kind":"null"},"commit_datetime":{"kind":"timestamp","value":"2001-11-01T19:13:57Z","string":"2001-11-01T19:13:57Z"},"report_datetime":{"kind":"timestamp","value":"2001-11-01T15:53:20Z","string":"2001-11-01T15:53:20Z"},"updated_file":{"kind":"string","value":"org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java"},"file_content":{"kind":"string","value":"package org.eclipse.jdt.internal.ui.text.java;\n\n/*\n * (c) Copyright IBM Corp. 2000, 2001.\n * All Rights Reserved.\n */\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.text.TextAttribute;\nimport org.eclipse.jface.text.rules.EndOfLineRule;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.RuleBasedScanner;\nimport org.eclipse.jface.text.rules.SingleLineRule;\nimport org.eclipse.jface.text.rules.Token;\nimport org.eclipse.jface.text.rules.WhitespaceRule;\nimport org.eclipse.jface.text.rules.WordRule;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.jdt.ui.text.IColorManager;\nimport org.eclipse.jdt.ui.text.IJavaColorConstants;\n\nimport org.eclipse.jdt.internal.ui.text.JavaWhitespaceDetector;\nimport org.eclipse.jdt.internal.ui.text.JavaWordDetector;\n\n\n/**\n * A Java code scanner.\n */\npublic class JavaCodeScanner extends RuleBasedScanner {\n\t\n\t\n\tprivate static String[] fgKeywords= { \n\t\t\"abstract\", //$NON-NLS-1$\n\t\t\"break\", //$NON-NLS-1$\n\t\t\"case\", \"catch\", \"class\", \"const\", \"continue\", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"default\", \"do\", //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"else\", \"extends\", //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"final\", \"finally\", \"for\", //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"goto\", //$NON-NLS-1$\n\t\t\"if\", \"implements\", \"import\", \"instanceof\", \"interface\", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"native\", \"new\", //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"package\", \"private\", \"protected\", \"public\", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"return\", //$NON-NLS-1$\n\t\t\"static\", \"super\", \"switch\", \"synchronized\", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"this\", \"throw\", \"throws\", \"transient\", \"try\", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\"volatile\", //$NON-NLS-1$\n\t\t\"while\" //$NON-NLS-1$\n\t};\n\t\n\tprivate static String[] fgTypes= { \"void\", \"boolean\", \"char\", \"byte\", \"short\", \"strictfp\", \"int\", \"long\", \"float\", \"double\" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$\n\t\n\tprivate static String[] fgConstants= { \"false\", \"null\", \"true\" }; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$\n\n\t\n\tprivate Token fKeyword;\n\tprivate Token fType;\n\tprivate Token fString;\n\tprivate Token fComment;\n\t\n\tprivate IColorManager fColorManager;\n\t\t\n\t/**\n\t * Creates a Java code scanner\n\t */\n\tpublic JavaCodeScanner(IColorManager manager) {\n\t\tsuper();\n\t\t\n\t\tsetDefaultReturnToken(new Token(new TextAttribute(manager.getColor(IJavaColorConstants.JAVA_DEFAULT))));\n\t\t\n\t\tfColorManager= manager;\n\t\t\n\t\tfKeyword= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_KEYWORD), null, SWT.BOLD));\n\t\tfType= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_TYPE), null, SWT.BOLD));\n\t\tfString= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_STRING)));\n\t\tfComment= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT)));\n\t\t\n\t\tinitializeRules();\n\t\t\n\t}\n\t\n\tprivate void initializeRules() {\n\t\tList rules= new ArrayList();\n\t\t\n\t\t// Add rule for single line comments.\n\t\trules.add(new EndOfLineRule(\"//\", fComment)); //$NON-NLS-1$\n\t\t\n\t\t// Add rule for strings and character constants.\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", fString, '\\\\')); //$NON-NLS-2$ //$NON-NLS-1$\n\t\trules.add(new SingleLineRule(\"'\", \"'\", fString, '\\\\')); //$NON-NLS-2$ //$NON-NLS-1$\n\t\t\t\t\n\t\t// Add generic whitespace rule.\n\t\trules.add(new WhitespaceRule(new JavaWhitespaceDetector()));\n\t\t\n\t\t// Add word rule for keywords, types, and constants.\n\t\tWordRule wordRule= new WordRule(new JavaWordDetector(), getDefaultReturnToken());\n\t\tfor (int i=0; i
    issue_id
    int64
    2.03k
    426k
    title
    stringlengths
    9
    251
    body
    stringlengths
    1
    32.8k
    status
    stringclasses
    6 values
    after_fix_sha
    stringlengths
    7
    7
    project_name
    stringclasses
    6 values
    repo_url
    stringclasses
    6 values
    repo_name
    stringclasses
    6 values
    language
    stringclasses
    1 value
    issue_url
    null
    before_fix_sha
    null
    pull_url
    null
    commit_datetime
    timestamp[us, tz=UTC]
    report_datetime
    timestamp[us, tz=UTC]
    updated_file
    stringlengths
    2
    187
    file_content
    stringlengths
    0
    368k
    4,086
    Bug 4086 Format problem in single element mode (1GKPJI8)
    EG (27.09.2001 12:32:36) from WSAD newsgoup If you select Format (from the popup menu when you right click on .java file) while in "View selected element only" mode (ie - looking at only one method) the auot format adds a large amount of whitespace to the begining of each line. Repeated "Formats" just add more space. You then have to go to the "whole document" view and reformat the entire document to fix this (well, I guess I could manual remove the whitespace, but then what's the point of autoformat?). NOTES: EG (10.10.2001 22:38:03) pls investigate whether this is the formatting strategy or the Java editor
    verified fixed
    44b869a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T11:58:37Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/codemanipulation/AddGetterSetterOperation.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.codemanipulation; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * For given fields, method stubs for getters and setters are created. */ public class AddGetterSetterOperation implements IWorkspaceRunnable { private IField[] fFields; private List fCreatedAccessors; private IRequestQuery fSkipExistingQuery; private IRequestQuery fSkipFinalSettersQuery; private boolean fSkipAllFinalSetters; private boolean fSkipAllExisting; /** * Creates the operation. * @param fields The fields to create setter/getters for. * @param skipFinalSettersQuery Callback to ask if the setter can be skipped for a final field. * Argument of the query is the final field. * @param skipExistingQuery Callback to ask if setter / getters that already exist can be skipped. * Argument of the query is the existing method. */ public AddGetterSetterOperation(IField[] fields, IRequestQuery skipFinalSettersQuery, IRequestQuery skipExistingQuery) { super(); fFields= fields; fSkipExistingQuery= skipExistingQuery; fSkipFinalSettersQuery= skipFinalSettersQuery; fCreatedAccessors= new ArrayList(); } /** * The policy to evaluate the base name (no 'set'/'get' of the accessor. */ private String evalAccessorName(String fieldname) { if (fieldname.length() > 0) { char firstLetter= fieldname.charAt(0); if (!Character.isUpperCase(firstLetter)) { if (fieldname.length() > 1) { char secondLetter= fieldname.charAt(1); if (Character.isUpperCase(secondLetter)) { return fieldname.substring(1); } if (firstLetter == '_') { return String.valueOf(Character.toUpperCase(secondLetter)) + fieldname.substring(2); } } return String.valueOf(Character.toUpperCase(firstLetter)) + fieldname.substring(1); } } return fieldname; } /** * Creates the name of the parameter from an accessor name. */ private String getArgumentName(String accessorName) { if (accessorName.length() > 0) { char firstLetter= accessorName.charAt(0); if (!Character.isLowerCase(firstLetter)) { return "" + Character.toLowerCase(firstLetter) + accessorName.substring(1); //$NON-NLS-1$ } } return accessorName; } /** * Runs the operation. * @throws OperationCanceledException Runtime error thrown when operation is cancelled. */ public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { if (monitor == null) { monitor= new NullProgressMonitor(); } try { int nFields= fFields.length; monitor.beginTask(CodeManipulationMessages.getString("AddGetterSetterOperation.description"), nFields); //$NON-NLS-1$ for (int i= 0; i < nFields; i++) { generateStubs(fFields[i], new SubProgressMonitor(monitor, 1)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } } } finally { monitor.done(); } } private boolean querySkipFinalSetters(IField field) throws OperationCanceledException { if (!fSkipAllFinalSetters) { switch (fSkipFinalSettersQuery.doQuery(field)) { case IRequestQuery.CANCEL: throw new OperationCanceledException(); case IRequestQuery.NO: return false; case IRequestQuery.YES_ALL: fSkipAllFinalSetters= true; } } return true; } private boolean querySkipExistingMethods(IMethod method) throws OperationCanceledException { if (!fSkipAllExisting) { switch (fSkipExistingQuery.doQuery(method)) { case IRequestQuery.CANCEL: throw new OperationCanceledException(); case IRequestQuery.NO: return false; case IRequestQuery.YES_ALL: fSkipAllExisting= true; } } return true; } /** * Creates setter and getter for a given field. */ private void generateStubs(IField field, IProgressMonitor monitor) throws JavaModelException, OperationCanceledException { try { monitor.beginTask(CodeManipulationMessages.getFormattedString("AddGetterSetterOperation.processField", field.getElementName()), 2); //$NON-NLS-1$ fSkipAllFinalSetters= false; fSkipAllExisting= false; String fieldName= field.getElementName(); String accessorName= evalAccessorName(fieldName); String argname= getArgumentName(accessorName); boolean isStatic= Flags.isStatic(field.getFlags()); String typeName= Signature.toString(field.getTypeSignature()); IType parentType= field.getDeclaringType(); String lineDelim= StubUtility.getLineDelimiterUsed(parentType); int indent= StubUtility.getIndentUsed(parentType) + 1; // test if the getter already exists String getterName= "get" + accessorName; //$NON-NLS-1$ IMethod existing= JavaModelUtil.findMethod(getterName, new String[0], false, parentType); if (!(existing != null && querySkipExistingMethods(existing))) { // create the getter stub StringBuffer buf= new StringBuffer(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" * Gets the "); buf.append(argname); buf.append(".\n"); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" * @return Returns a "); buf.append(typeName); buf.append('\n'); //$NON-NLS-1$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public "); //$NON-NLS-1$ if (isStatic) { buf.append("static "); //$NON-NLS-1$ } buf.append(typeName); buf.append(' '); buf.append(getterName); buf.append("() {\nreturn "); buf.append(fieldName); buf.append(";\n}\n"); //$NON-NLS-2$ //$NON-NLS-1$ IJavaElement sibling= null; if (existing != null) { sibling= StubUtility.findSibling(existing); existing.delete(false, null); } String formattedContent= StubUtility.codeFormat(buf.toString(), indent, lineDelim) + lineDelim; fCreatedAccessors.add(parentType.createMethod(formattedContent, sibling, true, null)); } monitor.worked(1); String setterName= "set" + accessorName; //$NON-NLS-1$ String[] args= new String[] { field.getTypeSignature() }; // test if the setter already exists or field is final boolean isFinal= Flags.isFinal(field.getFlags()); existing= JavaModelUtil.findMethod(setterName, args, false, parentType); if (!(isFinal && querySkipFinalSetters(field)) && !(existing != null && querySkipExistingMethods(existing))) { // create the setter stub StringBuffer buf= new StringBuffer(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" * Sets the "); buf.append(argname); buf.append(".\n"); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" * @param "); buf.append(argname); buf.append(" The "); buf.append(argname); buf.append(" to set\n"); //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public "); //$NON-NLS-1$ if (isStatic) { buf.append("static "); //$NON-NLS-1$ } buf.append("void "); buf.append(setterName); //$NON-NLS-1$ buf.append('('); buf.append(typeName); buf.append(' '); buf.append(argname); buf.append(") {\n"); //$NON-NLS-1$ if (argname.equals(fieldName)) { if (isStatic) { buf.append(parentType.getElementName()); buf.append('.'); } else { buf.append("this."); //$NON-NLS-1$ } } buf.append(fieldName); buf.append("= "); buf.append(argname); buf.append(";\n}\n"); //$NON-NLS-1$ //$NON-NLS-2$ IJavaElement sibling= null; if (existing != null) { sibling= StubUtility.findSibling(existing); existing.delete(false, null); } String formattedContent= StubUtility.codeFormat(buf.toString(), indent, lineDelim) + lineDelim; fCreatedAccessors.add(parentType.createMethod(formattedContent, sibling, true, null)); } } finally { monitor.done(); } } /** * Returns the created accessors. To be called after a sucessful run. */ public IMethod[] getCreatedAccessors() { return (IMethod[]) fCreatedAccessors.toArray(new IMethod[fCreatedAccessors.size()]); } }
    4,086
    Bug 4086 Format problem in single element mode (1GKPJI8)
    EG (27.09.2001 12:32:36) from WSAD newsgoup If you select Format (from the popup menu when you right click on .java file) while in "View selected element only" mode (ie - looking at only one method) the auot format adds a large amount of whitespace to the begining of each line. Repeated "Formats" just add more space. You then have to go to the "whole document" view and reformat the entire document to fix this (well, I guess I could manual remove the whitespace, but then what's the point of autoformat?). NOTES: EG (10.10.2001 22:38:03) pls investigate whether this is the formatting strategy or the Java editor
    verified fixed
    44b869a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T11:58:37Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/codemanipulation/StubUtility.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.codemanipulation; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IBuffer; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.ITypeNameRequestor; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.TypeInfo; import org.eclipse.jdt.internal.ui.util.TypeInfoRequestor; public class StubUtility { /** * Generates a stub. Given a template method, a stub with the same signature * will be constructed so it can be added to a type. * The method is asumed to be from a supertype, as a super call will be generated in * the method body. * @param parenttype The type to which the method will be added to * @param method A method template (method belongs to different type than the parent) * @param imports Imports required by the sub are added to the imports structure * @throws JavaModelException */ public static String genStub(IType parenttype, IMethod method, IImportsStructure imports) throws JavaModelException { boolean callSuper= !Flags.isAbstract(method.getFlags()) && !Flags.isStatic(method.getFlags()) && method.getDeclaringType().isClass(); return genStub(parenttype, method, callSuper, true, imports); } /** * Generates a stub. Given a template method, a stub with the same signature * will be constructed so it can be added to a type. * @param parenttype The type to which the method will be added to * @param method A method template (method belongs to different type than the parent) * @param callSuper If set a super call will be added to the method body * @param imports Imports required by the sub are added to the imports structure * @throws JavaModelException */ public static String genStub(IType parenttype, IMethod method, boolean callSuper, boolean addSeeTag, IImportsStructure imports) throws JavaModelException { IType declaringtype= method.getDeclaringType(); StringBuffer buf= new StringBuffer(); String[] paramTypes= method.getParameterTypes(); String[] paramNames= method.getParameterNames(); String[] excTypes= method.getExceptionTypes(); String retTypeSig= method.getReturnType(); int lastParam= paramTypes.length -1; if (!method.isConstructor()) { // java doc if (addSeeTag) { genJavaDocSeeTag(declaringtype.getElementName(), method.getElementName(), paramTypes, buf); } else { // generate a default java doc comment String desc= "Method " + method.getElementName(); //$NON-NLS-1$ genJavaDocStub(desc, paramNames, retTypeSig, excTypes, buf); } } else { String desc= "Constructor for " + parenttype.getElementName(); //$NON-NLS-1$ genJavaDocStub(desc, paramNames, Signature.SIG_VOID, excTypes, buf); } int flags= method.getFlags(); if (Flags.isPublic(flags) || (declaringtype.isInterface() && parenttype.isClass())) { buf.append("public "); //$NON-NLS-1$ } else if (Flags.isProtected(flags)) { buf.append("protected "); //$NON-NLS-1$ } else if (Flags.isPrivate(flags)) { buf.append("private "); //$NON-NLS-1$ } if (Flags.isSynchronized(flags)) { buf.append("synchronized "); //$NON-NLS-1$ } if (Flags.isVolatile(flags)) { buf.append("volatile "); //$NON-NLS-1$ } if (Flags.isStrictfp(flags)) { buf.append("strictfp "); //$NON-NLS-1$ } if (Flags.isStatic(flags)) { buf.append("static "); //$NON-NLS-1$ } if (!method.isConstructor()) { String retTypeFrm= Signature.toString(retTypeSig); if (!isBuiltInType(retTypeSig)) { resolveAndAdd(retTypeSig, declaringtype, imports); } buf.append(Signature.getSimpleName(retTypeFrm)); buf.append(' '); buf.append(method.getElementName()); } else { buf.append(parenttype.getElementName()); } buf.append('('); for (int i= 0; i <= lastParam; i++) { String paramTypeSig= paramTypes[i]; String paramTypeFrm= Signature.toString(paramTypeSig); if (!isBuiltInType(paramTypeSig)) { resolveAndAdd(paramTypeSig, declaringtype, imports); } buf.append(Signature.getSimpleName(paramTypeFrm)); buf.append(' '); buf.append(paramNames[i]); if (i < lastParam) { buf.append(", "); //$NON-NLS-1$ } } buf.append(')'); int lastExc= excTypes.length - 1; if (lastExc >= 0) { buf.append(" throws "); //$NON-NLS-1$ for (int i= 0; i <= lastExc; i++) { String excTypeSig= excTypes[i]; String excTypeFrm= Signature.toString(excTypeSig); resolveAndAdd(excTypeSig, declaringtype, imports); buf.append(Signature.getSimpleName(excTypeFrm)); if (i < lastExc) { buf.append(", "); //$NON-NLS-1$ } } } if (parenttype.isInterface()) { buf.append(";\n\n"); //$NON-NLS-1$ } else { buf.append(" {\n\t"); //$NON-NLS-1$ if (!callSuper) { if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) { buf.append('\t'); if (!isBuiltInType(retTypeSig) || Signature.getArrayCount(retTypeSig) > 0) { buf.append("return null;\n\t"); //$NON-NLS-1$ } else if (retTypeSig.equals(Signature.SIG_BOOLEAN)) { buf.append("return false;\n\t"); //$NON-NLS-1$ } else { buf.append("return 0;\n\t"); //$NON-NLS-1$ } } } else { buf.append('\t'); if (!method.isConstructor()) { if (!Signature.SIG_VOID.equals(retTypeSig)) { buf.append("return "); //$NON-NLS-1$ } buf.append("super."); //$NON-NLS-1$ buf.append(method.getElementName()); } else { buf.append("super"); //$NON-NLS-1$ } buf.append('('); for (int i= 0; i <= lastParam; i++) { buf.append(paramNames[i]); if (i < lastParam) { buf.append(", "); //$NON-NLS-1$ } } buf.append(");\n\t"); //$NON-NLS-1$ } buf.append("}\n\n"); //$NON-NLS-1$ } return buf.toString(); } private static boolean isBuiltInType(String typeName) { char first= Signature.getElementType(typeName).charAt(0); return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED); } private static void resolveAndAdd(String refTypeSig, IType declaringType, IImportsStructure imports) throws JavaModelException { String resolvedTypeName= JavaModelUtil.getResolvedTypeName(refTypeSig, declaringType); if (resolvedTypeName != null) { imports.addImport(resolvedTypeName); } } /** * Generates a default JavaDoc comment stub for a method. */ public static void genJavaDocStub(String descr, String[] paramNames, String retTypeSig, String[] excTypeSigs, StringBuffer buf) { buf.append("/**\n"); //$NON-NLS-1$ buf.append(" * "); buf.append(descr); buf.append(".\n"); //$NON-NLS-2$ //$NON-NLS-1$ for (int i= 0; i < paramNames.length; i++) { buf.append(" * @param "); buf.append(paramNames[i]); buf.append('\n'); //$NON-NLS-1$ } if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) { String simpleName= Signature.getSimpleName(Signature.toString(retTypeSig)); buf.append(" * @return "); buf.append(simpleName); buf.append('\n'); //$NON-NLS-1$ } for (int i= 0; i < excTypeSigs.length; i++) { String simpleName= Signature.getSimpleName(Signature.toString(excTypeSigs[i])); buf.append(" * @throws "); buf.append(simpleName); buf.append('\n'); //$NON-NLS-1$ } buf.append(" */\n"); //$NON-NLS-1$ } /** * Generates a '@see' tag to the defined method. */ public static void genJavaDocSeeTag(String declaringTypeName, String methodName, String[] paramTypes, StringBuffer buf) { // create a @see link buf.append("/*\n"); //$NON-NLS-1$ buf.append(" * @see "); //$NON-NLS-1$ buf.append(declaringTypeName); buf.append('#'); buf.append(methodName); buf.append('('); for (int i= 0; i < paramTypes.length; i++) { if (i > 0) { buf.append(", "); //$NON-NLS-1$ } buf.append(Signature.getSimpleName(Signature.toString(paramTypes[i]))); } buf.append(")\n"); //$NON-NLS-1$ buf.append(" */\n"); //$NON-NLS-1$ } /** * Finds a method in a list of methods. * @return The found method or null, if nothing found */ private static IMethod findMethod(IMethod method, List allMethods) throws JavaModelException { String name= method.getElementName(); String[] paramTypes= method.getParameterTypes(); boolean isConstructor= method.isConstructor(); for (int i= allMethods.size() - 1; i >= 0; i--) { IMethod curr= (IMethod) allMethods.get(i); if (JavaModelUtil.isSameMethodSignature(name, paramTypes, isConstructor, curr)) { return curr; } } return null; } /** * Creates needed constructors for a type. * @param type The type to create constructors for * @param supertype The type's super type * @param newMethods The resulting source for the created constructors (List of String) * @param imports Type names for input declarations required (for example 'java.util.Vector') */ public static void evalConstructors(IType type, IType supertype, List newMethods, IImportsStructure imports) throws JavaModelException { IMethod[] methods= supertype.getMethods(); for (int i= 0; i < methods.length; i++) { IMethod curr= methods[i]; if (curr.isConstructor() && JavaModelUtil.isVisible(curr, type.getPackageFragment())) { String newStub= genStub(type, methods[i], imports); newMethods.add(newStub); } } } /** * Searches for unimplemented methods of a type. * @param newMethods The source for the created methods (Vector of String) * @param imports Type names for input declarations required (for example 'java.util.Vector') */ public static void evalUnimplementedMethods(IType type, ITypeHierarchy hierarchy, List newMethods, IImportsStructure imports) throws JavaModelException { List allMethods= new ArrayList(); IMethod[] typeMethods= type.getMethods(); for (int i= 0; i < typeMethods.length; i++) { IMethod curr= typeMethods[i]; if (!curr.isConstructor() && !Flags.isStatic(curr.getFlags())) { allMethods.add(curr); } } IType[] superTypes= hierarchy.getAllSuperclasses(type); for (int i= 0; i < superTypes.length; i++) { IMethod[] methods= superTypes[i].getMethods(); for (int k= 0; k < methods.length; k++) { IMethod curr= methods[k]; if (!curr.isConstructor() && !Flags.isStatic(curr.getFlags())) { if (findMethod(curr, allMethods) == null) { allMethods.add(curr); } } } } for (int i= allMethods.size() - 1; i >= 0; i--) { IMethod curr= (IMethod) allMethods.get(i); if (Flags.isAbstract(curr.getFlags()) && !type.equals(curr.getDeclaringType())) { // implement all abstract methods String newStub= genStub(type, curr, false, true, imports); newMethods.add(newStub); } } IType[] superInterfaces= hierarchy.getAllSuperInterfaces(type); for (int i= 0; i < superInterfaces.length; i++) { IMethod[] methods= superInterfaces[i].getMethods(); for (int k= 0; k < methods.length; k++) { IMethod curr= methods[k]; // binary interfaces can contain static initializers (variable intializations) // 1G4CKUS if (!Flags.isStatic(curr.getFlags())) { IMethod impl= findMethod(curr, allMethods); if (impl == null || curr.getExceptionTypes().length < impl.getExceptionTypes().length) { // implement an interface method when it does not exist in the hierarchy // or when it throws less exceptions that the implemented String newStub= genStub(type, curr, false, true, imports); newMethods.add(newStub); allMethods.add(curr); } } } } } /** * Examines a string and returns the first line delimiter found. */ public static String getLineDelimiterUsed(IJavaElement elem) throws JavaModelException { ICompilationUnit cu= (ICompilationUnit) JavaModelUtil.findElementOfKind(elem, IJavaElement.COMPILATION_UNIT); if (cu != null && cu.exists()) { IBuffer buf= cu.getBuffer(); int length= buf.getLength(); for (int i= 0; i < length; i++) { char ch= buf.getChar(i); if (ch == SWT.CR) { if (i + 1 < length) { if (buf.getChar(i + 1) == SWT.LF) { return "\r\n"; //$NON-NLS-1$ } } return "\r"; //$NON-NLS-1$ } else if (ch == SWT.LF) { return "\n"; //$NON-NLS-1$ } } } return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Embodies the policy which line delimiter to use when inserting into * a document. */ public static String getLineDelimiterFor(IDocument doc) { // new for: 1GF5UU0: ITPJUI:WIN2000 - "Organize Imports" in java editor inserts lines in wrong format String lineDelim= null; try { lineDelim= doc.getLineDelimiter(0); } catch (BadLocationException e) { } if (lineDelim == null) { String systemDelimiter= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ String[] lineDelims= doc.getLegalLineDelimiters(); for (int i= 0; i < lineDelims.length; i++) { if (lineDelims[i].equals(systemDelimiter)) { lineDelim= systemDelimiter; break; } } if (lineDelim == null) { lineDelim= lineDelims.length > 0 ? lineDelims[0] : systemDelimiter; } } return lineDelim; } /** * Evaluates the indention used by a Java element. (in tabulators) */ public static int getIndentUsed(IJavaElement elem) throws JavaModelException { if (elem instanceof ISourceReference) { int tabWidth= CodeFormatterPreferencePage.getTabSize(); ICompilationUnit cu= (ICompilationUnit)JavaModelUtil.findElementOfKind(elem, IJavaElement.COMPILATION_UNIT); if (cu != null) { IBuffer buf= cu.getBuffer(); int i= ((ISourceReference)elem).getSourceRange().getOffset(); int result= 0; int blanks= 0; while (i > 0) { i--; char ch= buf.getChar(i); switch (ch) { case '\t': result++; blanks= 0; break; case ' ': blanks++; if (blanks == tabWidth) { result++; blanks= 0; } break; default: return result; } } } } return 0; } public static String codeFormat(String sourceString, int initialIndentationLevel, String lineDelim) { // code formatter does not offer all options we need CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions()); formatter.options.setLineSeparator(lineDelim); formatter.setInitialIndentationLevel(initialIndentationLevel); return formatter.formatSourceString(sourceString) + lineDelim; } /** * Returns the element after the give element. */ public static IJavaElement findSibling(IJavaElement member) throws JavaModelException { IJavaElement parent= member.getParent(); if (parent instanceof IParent) { IJavaElement[] elements= ((IParent)parent).getChildren(); for (int i= elements.length - 2; i >= 0 ; i--) { if (member.equals(elements[i])) { return elements[i+1]; } } } return null; } }
    4,086
    Bug 4086 Format problem in single element mode (1GKPJI8)
    EG (27.09.2001 12:32:36) from WSAD newsgoup If you select Format (from the popup menu when you right click on .java file) while in "View selected element only" mode (ie - looking at only one method) the auot format adds a large amount of whitespace to the begining of each line. Repeated "Formats" just add more space. You then have to go to the "whole document" view and reformat the entire document to fix this (well, I guess I could manual remove the whitespace, but then what's the point of autoformat?). NOTES: EG (10.10.2001 22:38:03) pls investigate whether this is the formatting strategy or the Java editor
    verified fixed
    44b869a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T11:58:37Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaFormattingStrategy.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.formatter.IFormattingStrategy; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.codemanipulation.StubUtility; public class JavaFormattingStrategy implements IFormattingStrategy { private String fInitialIndentation; private ISourceViewer fViewer; public JavaFormattingStrategy(ISourceViewer viewer) { fViewer = viewer; } /** * @see IFormattingStrategy#formatterStarts(String) */ public void formatterStarts(String initialIndentation) { fInitialIndentation= initialIndentation; } /** * @see IFormattingStrategy#formatterStops() */ public void formatterStops() { } /** * @see IFormattingStrategy#format(String, boolean, String, int[]) */ public String format(String content, boolean isLineStart, String indentation, int[] positions) { CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions()); IDocument doc= fViewer.getDocument(); String lineDelimiter= StubUtility.getLineDelimiterFor(doc); formatter.options.setLineSeparator(lineDelimiter); formatter.setPositionsToMap(positions); formatter.setInitialIndentationLevel(fInitialIndentation == null ? 0 : fInitialIndentation.length()); return formatter.formatSourceString(content); } }
    4,283
    Bug 4283 assertion failed on opening rename parameters (1GKYY5N)
    ak (10/2/2001 2:27:26 PM) during file editing i selected 'Rename parameters..' from the global 'Refactor' menu 4 org.eclipse.ui 0 null argument; org.eclipse.jface.util.Assert$AssertionFailedException: null argument; at org.eclipse.jface.util.Assert.isNotNull(Assert.java:133) at org.eclipse.jface.util.Assert.isNotNull(Assert.java(Compiled Code)) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.<init>(RefactoringWizard.java:47) at org.eclipse.jdt.internal.ui.refactoring.RenameParametersWizard.<init>(RenameParametersWizard.java:14) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup$1.createWizard(RefactoringGroup.java:77) at org.eclipse.jdt.internal.ui.refactoring.actions.OpenRefactoringWizardAction.run(OpenRefactoringWizardAction.java:49) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActionDelegate.run(RefactoringActionDelegate.java:47) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) NOTES:
    resolved fixed
    fb1f1e3
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T13:50:36Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui
    4,283
    Bug 4283 assertion failed on opening rename parameters (1GKYY5N)
    ak (10/2/2001 2:27:26 PM) during file editing i selected 'Rename parameters..' from the global 'Refactor' menu 4 org.eclipse.ui 0 null argument; org.eclipse.jface.util.Assert$AssertionFailedException: null argument; at org.eclipse.jface.util.Assert.isNotNull(Assert.java:133) at org.eclipse.jface.util.Assert.isNotNull(Assert.java(Compiled Code)) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.<init>(RefactoringWizard.java:47) at org.eclipse.jdt.internal.ui.refactoring.RenameParametersWizard.<init>(RenameParametersWizard.java:14) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup$1.createWizard(RefactoringGroup.java:77) at org.eclipse.jdt.internal.ui.refactoring.actions.OpenRefactoringWizardAction.run(OpenRefactoringWizardAction.java:49) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringActionDelegate.run(RefactoringActionDelegate.java:47) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) NOTES:
    resolved fixed
    fb1f1e3
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T13:50:36Z
    2001-10-11T03:13:20Z
    refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/OpenRefactoringWizardAction.java
    4,376
    Bug 4376 refactoring CCE
    1. create a non java project abc 2. create junit 3. rename Assert.java java.lang.reflect.InvocationTargetException: java.lang.ClassCastException: org.eclipse.jdt.internal.core.JavaProject at org.eclipse.jdt.internal.core.refactoring.Checks.excludeCompilationUnits (Checks.java:413) at org.eclipse.jdt.internal.core.refactoring.rename.RenameTypeRefactoring.analyzeAf fectedCompilationUnits(RenameTypeRefactoring.java:459) at org.eclipse.jdt.internal.core.refactoring.rename.RenameTypeRefactoring.checkInpu t(RenameTypeRefactoring.java:231) at org.eclipse.jdt.internal.core.refactoring.rename.RenameCompilationUnitRefactorin g.checkInput(RenameCompilationUnitRefactoring.java:177) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:58) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:93) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:98)
    resolved fixed
    85dcbd0
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T14:33:26Z
    2001-10-11T14:20:00Z
    org.eclipse.jdt.ui/core
    4,376
    Bug 4376 refactoring CCE
    1. create a non java project abc 2. create junit 3. rename Assert.java java.lang.reflect.InvocationTargetException: java.lang.ClassCastException: org.eclipse.jdt.internal.core.JavaProject at org.eclipse.jdt.internal.core.refactoring.Checks.excludeCompilationUnits (Checks.java:413) at org.eclipse.jdt.internal.core.refactoring.rename.RenameTypeRefactoring.analyzeAf fectedCompilationUnits(RenameTypeRefactoring.java:459) at org.eclipse.jdt.internal.core.refactoring.rename.RenameTypeRefactoring.checkInpu t(RenameTypeRefactoring.java:231) at org.eclipse.jdt.internal.core.refactoring.rename.RenameCompilationUnitRefactorin g.checkInput(RenameCompilationUnitRefactoring.java:177) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:58) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:93) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:98)
    resolved fixed
    85dcbd0
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T14:33:26Z
    2001-10-11T14:20:00Z
    refactoring/org/eclipse/jdt/internal/core/refactoring/Checks.java
    4,373
    Bug 4373 Packages View - double clich doesn't expand two hiearchy levels
    - enable: Show CU children in packages view - double click on CU observe: only one level gets expanded - now expand a node by clicking on the + observe: two levels get expanded
    resolved fixed
    d00ad36
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T14:57:29Z
    2001-10-11T14:20:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.packageview; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory; import org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction; import org.eclipse.jdt.internal.ui.dnd.DelegatingDragAdapter; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer; import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener; import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput; import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage; import org.eclipse.jdt.internal.ui.IPreferencesConstants; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup; import org.eclipse.jdt.internal.ui.refactoring.actions.StructuredSelectionProvider; import org.eclipse.jdt.internal.ui.reorg.DeleteAction; import org.eclipse.jdt.internal.ui.reorg.ReorgGroup; import org.eclipse.jdt.internal.ui.search.JavaSearchGroup; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.viewsupport.MarkerErrorTickProvider; import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.ui.wizards.NewGroup; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.IPackagesViewPart; import org.eclipse.jdt.ui.JavaElementContentProvider; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeViewerListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSource; import org.eclipse.swt.dnd.FileTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.OpenPerspectiveMenu; import org.eclipse.ui.actions.OpenWithMenu; import org.eclipse.ui.actions.RefreshAction; import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.help.ViewContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.ISetSelectionTarget; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.views.internal.framelist.BackAction; import org.eclipse.ui.views.internal.framelist.ForwardAction; import org.eclipse.ui.views.internal.framelist.FrameList; import org.eclipse.ui.views.internal.framelist.GoIntoAction; import org.eclipse.ui.views.internal.framelist.UpAction; /** * The ViewPart for the ProjectExplorer. It listens to part activation events. * When selection linking with the editor is enabled the view selection tracks * the active editor page. Similarly when a resource is selected in the packages * view the corresponding editor is activated. */ public class PackageExplorerPart extends ViewPart implements ISetSelectionTarget, IMenuListener, IPackagesViewPart, IPropertyChangeListener { public final static String VIEW_ID= JavaUI.ID_PACKAGES; // Persistance tags. static final String TAG_SELECTION= "selection"; //$NON-NLS-1$ static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$ static final String TAG_ELEMENT= "element"; //$NON-NLS-1$ static final String TAG_PATH= "path"; //$NON-NLS-1$ static final String TAG_VERTICAL_POSITION= "verticalPosition"; //$NON-NLS-1$ static final String TAG_HORIZONTAL_POSITION= "horizontalPosition"; //$NON-NLS-1$ static final String TAG_FILTERS = "filters"; //$NON-NLS-1$ static final String TAG_FILTER = "filter"; //$NON-NLS-1$ static final String TAG_SHOWLIBRARIES = "showLibraries"; //$NON-NLS-1$ static final String TAG_SHOWBINARIES = "showBinaries"; //$NON-NLS-1$ private JavaElementPatternFilter fPatternFilter= new JavaElementPatternFilter(); private LibraryFilter fLibraryFilter= new LibraryFilter(); private BinaryProjectFilter fBinaryFilter= new BinaryProjectFilter(); private ProblemTreeViewer fViewer; private PackagesFrameSource fFrameSource; private FrameList fFrameList; private ContextMenuGroup[] fStandardGroups; private Menu fContextMenu; private OpenResourceAction fOpenCUAction; private Action fOpenToAction; private Action fShowTypeHierarchyAction; private Action fShowNavigatorAction; private Action fPropertyDialogAction; private Action fDeleteAction; private RefreshAction fRefreshAction; private BackAction fBackAction; private ForwardAction fForwardAction; private GoIntoAction fZoomInAction; private UpAction fUpAction; private GotoTypeAction fGotoTypeAction; private GotoPackageAction fGotoPackageAction; private AddBookmarkAction fAddBookmarkAction; private FilterSelectionAction fFilterAction; private ShowLibrariesAction fShowLibrariesAction; private ShowBinariesAction fShowBinariesAction; private IMemento fMemento; private IPartListener fPartListener= new IPartListener() { public void partActivated(IWorkbenchPart part) { if (part instanceof IEditorPart) editorActivated((IEditorPart) part); } public void partBroughtToTop(IWorkbenchPart part) { } public void partClosed(IWorkbenchPart part) { } public void partDeactivated(IWorkbenchPart part) { } public void partOpened(IWorkbenchPart part) { } }; private ITreeViewerListener fExpansionListener= new ITreeViewerListener() { public void treeCollapsed(TreeExpansionEvent event) { } public void treeExpanded(TreeExpansionEvent event) { Object element= event.getElement(); if (element instanceof ICompilationUnit || element instanceof IClassFile) expandMainType(element); } }; public PackageExplorerPart() { } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento= memento; } /** * Initializes the default preferences */ public static void initDefaults(IPreferenceStore store) { store.setDefault(TAG_SHOWLIBRARIES, true); store.setDefault(TAG_SHOWBINARIES, true); } /** * Returns the package explorer part of the active perspective. If * there isn't any package explorer part <code>null</code> is returned. */ public static PackageExplorerPart getFromActivePerspective() { IViewPart view= JavaPlugin.getActivePage().findView(VIEW_ID); if (view instanceof PackageExplorerPart) return (PackageExplorerPart)view; return null; } /** * Makes the package explorer part visible in the active perspective. If there * isn't a package explorer part registered <code>null</code> is returned. * Otherwise the opened view part is returned. */ public static PackageExplorerPart openInActivePerspective() { try { return (PackageExplorerPart)JavaPlugin.getActivePage().showView(VIEW_ID); } catch(PartInitException pe) { return null; } } public void dispose() { if (fViewer != null) JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fViewer); if (fContextMenu != null && !fContextMenu.isDisposed()) fContextMenu.dispose(); getSite().getPage().removePartListener(fPartListener); JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); if (fViewer != null) fViewer.removeTreeListener(fExpansionListener); super.dispose(); } /** * Implementation of IWorkbenchPart.createPartControl(Composite) */ public void createPartControl(Composite parent) { fViewer= new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); boolean showCUChildren= JavaBasePreferencePage.showCompilationUnitChildren(); fViewer.setContentProvider(new JavaElementContentProvider(showCUChildren)); JavaPlugin.getDefault().getProblemMarkerManager().addListener(fViewer); JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_VARIABLE | JavaElementLabelProvider.SHOW_PARAMETERS; JavaElementLabelProvider labelProvider = new JavaElementLabelProvider(labelFlags); labelProvider.setErrorTickManager(new MarkerErrorTickProvider()); fViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, null)); fViewer.setSorter(new PackageViewerSorter()); fViewer.addFilter(new EmptyInnerPackageFilter()); fViewer.setUseHashlookup(true); fViewer.addFilter(fPatternFilter); fViewer.addFilter(fLibraryFilter); fViewer.addFilter(fBinaryFilter); if(fMemento != null) restoreFilters(); else initFilterFromPreferences(); // Set input after filter and sorter has been set. This avoids resorting // and refiltering. fViewer.setInput(findInputElement()); initDragAndDrop(); initFrameList(); initRefreshKey(); updateTitle(); MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(this); fContextMenu= menuMgr.createContextMenu(fViewer.getTree()); fViewer.getTree().setMenu(fContextMenu); getSite().registerContextMenu(menuMgr, fViewer); makeActions(); // call before registering for selection changes fViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged(event); } }); fViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { handleDoubleClick(event); } }); fViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleKeyPressed(e); } }); getSite().setSelectionProvider(fViewer); getSite().getPage().addPartListener(fPartListener); IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager(); fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager)); fViewer.addTreeListener(fExpansionListener); if (fMemento != null) restoreState(fMemento); fMemento= null; // Set help for the view // fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing WorkbenchHelp.setHelp(fViewer.getControl(), new ViewContextComputer(this, IJavaHelpContextIds.PACKAGE_VIEW)); fillActionBars(); } private void fillActionBars() { IActionBars actionBars= getViewSite().getActionBars(); IToolBarManager toolBar= actionBars.getToolBarManager(); toolBar.add(fBackAction); toolBar.add(fForwardAction); toolBar.add(fUpAction); actionBars.updateActionBars(); IMenuManager menu = actionBars.getMenuManager(); menu.add(fFilterAction); menu.add(fShowLibrariesAction); menu.add(fShowBinariesAction); } private Object findInputElement() { Object input= getSite().getPage().getInput(); if (input instanceof IWorkspace) { return JavaCore.create(((IWorkspace)input).getRoot()); } else if (input instanceof IContainer) { return JavaCore.create((IContainer)input); } //1GERPRT: ITPJUI:ALL - Packages View is empty when shown in Type Hierarchy Perspective // we can't handle the input // fall back to show the workspace return JavaCore.create(JavaPlugin.getWorkspace().getRoot()); } /** * Answer the property defined by key. */ public Object getAdapter(Class key) { if (key.equals(ISelectionProvider.class)) return fViewer; return super.getAdapter(key); } /** * Returns the tool tip text for the given element. */ String getToolTipText(Object element) { if (!(element instanceof IResource)) return ((ILabelProvider) getViewer().getLabelProvider()).getText(element); IPath path= ((IResource) element).getFullPath(); if (path.isRoot()) { return PackagesMessages.getString("PackageExplorer.title"); //$NON-NLS-1$ } else { return path.makeRelative().toString(); } } /** * @see IWorkbenchPart#setFocus() */ public void setFocus() { fViewer.getTree().setFocus(); } /** * Returns the shell to use for opening dialogs. * Used in this class, and in the actions. */ private Shell getShell() { return fViewer.getTree().getShell(); } /** * Returns the selection provider. */ private ISelectionProvider getSelectionProvider() { return fViewer; } /** * Returns the current selection. */ private ISelection getSelection() { return fViewer.getSelection(); } //---- Action handling ---------------------------------------------------------- /** * Called when the context menu is about to open. * Override to add your own context dependent menu contributions. */ public void menuAboutToShow(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection(); boolean selectionHasElements= !selection.isEmpty(); Object element= selection.getFirstElement(); // updateActions(selection); if (selection.size() == 1 && fViewer.isExpandable(element)) menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction); addGotoMenu(menu); fOpenCUAction.update(); if (fOpenCUAction.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenCUAction); addOpenWithMenu(menu, selection); addOpenToMenu(menu, selection); addRefactoring(menu); if (selection.size() == 1) { menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fViewer)); menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaAddElementFromHistory(null, fViewer)); } ContextMenuGroup.add(menu, fStandardGroups, fViewer); if (fAddBookmarkAction.canOperateOnSelection()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddBookmarkAction); menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fRefreshAction); fRefreshAction.selectionChanged(selection); if (selectionHasElements) { // update the action to use the right selection since the refresh // action doesn't listen to selection changes. menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fPropertyDialogAction); } } void addGotoMenu(IMenuManager menu) { MenuManager gotoMenu= new MenuManager(PackagesMessages.getString("PackageExplorer.gotoTitle")); //$NON-NLS-1$ menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, gotoMenu); gotoMenu.add(fBackAction); gotoMenu.add(fForwardAction); gotoMenu.add(fUpAction); gotoMenu.add(fGotoTypeAction); gotoMenu.add(fGotoPackageAction); } private void makeActions() { ISelectionProvider provider= getSelectionProvider(); fOpenCUAction= new OpenResourceAction(provider); fPropertyDialogAction= new PropertyDialogAction(getShell(), provider); // fShowTypeHierarchyAction= new ShowTypeHierarchyAction(provider); fShowNavigatorAction= new ShowInNavigatorAction(provider); fAddBookmarkAction= new AddBookmarkAction(provider); fStandardGroups= new ContextMenuGroup[] { new NewGroup(), new BuildGroup(), new ReorgGroup(), new JavaSearchGroup() }; fDeleteAction= new DeleteAction(StructuredSelectionProvider.createFrom(provider)); fRefreshAction= new RefreshAction(getShell()); fFilterAction = new FilterSelectionAction(getShell(), this, PackagesMessages.getString("PackageExplorer.filters")); //$NON-NLS-1$ fShowLibrariesAction = new ShowLibrariesAction(this, PackagesMessages.getString("PackageExplorer.referencedLibs")); //$NON-NLS-1$ fShowBinariesAction = new ShowBinariesAction(getShell(), this, PackagesMessages.getString("PackageExplorer.binaryProjects")); //$NON-NLS-1$ fBackAction= new BackAction(fFrameList); fForwardAction= new ForwardAction(fFrameList); fZoomInAction= new GoIntoAction(fFrameList); fUpAction= new UpAction(fFrameList); fGotoTypeAction= new GotoTypeAction(this); fGotoPackageAction= new GotoPackageAction(this); IActionBars actionService= getViewSite().getActionBars(); actionService.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, fDeleteAction); } private void addRefactoring(IMenuManager menu){ MenuManager refactoring= new MenuManager(PackagesMessages.getString("PackageExplorer.refactoringTitle")); //$NON-NLS-1$ ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, fViewer); if (!refactoring.isEmpty()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring); } private void addOpenToMenu(IMenuManager menu, IStructuredSelection selection) { if (selection.size() != 1) return; IAdaptable element= (IAdaptable) selection.getFirstElement(); IResource resource= (IResource)element.getAdapter(IResource.class); if ((resource instanceof IContainer)) { // Create a menu flyout. MenuManager submenu = new MenuManager(PackagesMessages.getString("PackageExplorer.openPerspective")); //$NON-NLS-1$ submenu.add(new OpenPerspectiveMenu(getSite().getWorkbenchWindow(), resource)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, element); } private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { // If one file is selected get it. // Otherwise, do not show the "open with" menu. if (selection.size() != 1) return; IAdaptable element= (IAdaptable)selection.getFirstElement(); Object resource= element.getAdapter(IResource.class); if (!(resource instanceof IFile)) return; // Create a menu flyout. MenuManager submenu= new MenuManager(PackagesMessages.getString("PackageExplorer.openWith")); //$NON-NLS-1$ submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } private boolean isSelectionOfType(ISelection s, Class clazz, boolean considerUnderlyingResource) { if (! (s instanceof IStructuredSelection) || s.isEmpty()) return false; IStructuredSelection selection= (IStructuredSelection)s; Iterator iter= selection.iterator(); while (iter.hasNext()) { Object o= iter.next(); if (clazz.isInstance(o)) return true; if (considerUnderlyingResource) { if (! (o instanceof IJavaElement)) return false; IJavaElement element= (IJavaElement)o; Object resource= element.getAdapter(IResource.class); if (! clazz.isInstance(resource)) return false; } } return true; } //---- Event handling ---------------------------------------------------------- private void initDragAndDrop() { int ops= DND.DROP_COPY | DND.DROP_MOVE; final LocalSelectionTransfer lt= LocalSelectionTransfer.getInstance(); Transfer[] transfers= new Transfer[] {lt, FileTransfer.getInstance()}; // Drop Adapter TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new SelectionTransferDropAdapter(fViewer), new FileTransferDropAdapter(fViewer) }; fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); // Drag Adapter Control control= fViewer.getControl(); TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(fViewer), new FileTransferDragAdapter(fViewer) }; DragSource source= new DragSource(control, ops); // Note, that the transfer agents are set by the delegating drag adapter itself. source.addDragListener(new DelegatingDragAdapter(dragListeners)); } /** * Handles key events in viewer. */ void handleKeyPressed(KeyEvent event) { if (event.character == SWT.DEL && event.stateMask == 0 && fDeleteAction.isEnabled()) fDeleteAction.run(); } /** * Handles double clicks in viewer. * Opens editor if file double-clicked. */ private void handleDoubleClick(DoubleClickEvent event) { IStructuredSelection s= (IStructuredSelection) event.getSelection(); Object element= s.getFirstElement(); // if the resource is already open then always open it if (EditorUtility.isOpenInEditor(element) == null) { if (fOpenCUAction.isEnabled()) { fOpenCUAction.run(); return; } } if (fViewer.isExpandable(element)) { if (JavaBasePreferencePage.doubleClockGoesInto()) fZoomInAction.run(); else fViewer.setExpandedState(element, !fViewer.getExpandedState(element)); } } /** * Handles selection changed in viewer. * Updates global actions. * Links to editor (if option enabled) */ private void handleSelectionChanged(SelectionChangedEvent event) { IStructuredSelection sel= (IStructuredSelection) event.getSelection(); //updateGlobalActions(sel); fZoomInAction.update(); linkToEditor(sel); } public void selectReveal(ISelection selection) { ISelection javaSelection= convertSelection(selection); fViewer.setSelection(javaSelection, true); } private ISelection convertSelection(ISelection s) { List converted= new ArrayList(); if (s instanceof StructuredSelection) { Object[] elements= ((StructuredSelection)s).toArray(); for (int i= 0; i < elements.length; i++) { Object e= elements[i]; if (e instanceof IJavaElement) converted.add(e); else if (e instanceof IResource) { IJavaElement element= JavaCore.create((IResource)e); if (element != null) converted.add(element); else converted.add(e); } } } return new StructuredSelection(converted.toArray()); } public void selectAndReveal(Object element) { selectReveal(new StructuredSelection(element)); } /** * Returns whether the preference to link selection to active editor is enabled. */ boolean isLinkingEnabled() { return JavaBasePreferencePage.linkPackageSelectionToEditor(); } /** * Links to editor (if option enabled) */ private void linkToEditor(IStructuredSelection selection) { //if (!isLinkingEnabled()) // return; Object obj= selection.getFirstElement(); Object element= null; if (selection.size() == 1) { if (obj instanceof IJavaElement) { IJavaElement cu= JavaModelUtil.findParentOfKind((IJavaElement)obj, IJavaElement.COMPILATION_UNIT); if (cu != null) element= getResourceFor(cu); if (element == null) element= JavaModelUtil.findParentOfKind((IJavaElement)obj, IJavaElement.CLASS_FILE); } else if (obj instanceof IFile) element= obj; if (element == null) return; IWorkbenchPage page= getSite().getPage(); IEditorPart editorArray[]= page.getEditors(); for (int i= 0; i < editorArray.length; ++i) { IEditorPart editor= editorArray[i]; Object input= getElementOfInput(editor.getEditorInput()); if (input != null && input.equals(element)) { page.bringToTop(editor); if (obj instanceof ISourceReference) EditorUtility.revealInEditor(editor, (ISourceReference)obj); return; } } } } private IResource getResourceFor(Object element) { if (element instanceof IJavaElement) { try { element= ((IJavaElement)element).getUnderlyingResource(); } catch (JavaModelException e) { return null; } } if (!(element instanceof IResource) || ((IResource)element).isPhantom()) { return null; } return (IResource)element; } public void saveState(IMemento memento) { if (fViewer == null) { // part has not been created if (fMemento != null) //Keep the old state; memento.putMemento(fMemento); return; } saveExpansionState(memento); saveSelectionState(memento); saveScrollState(memento, fViewer.getTree()); savePatternFilterState(memento); saveFilterState(memento); } protected void saveFilterState(IMemento memento) { boolean showLibraries= getLibraryFilter().getShowLibraries(); String show= "true"; //$NON-NLS-1$ if (!showLibraries) show= "false"; //$NON-NLS-1$ memento.putString(TAG_SHOWLIBRARIES, show); //save binary filter boolean showBinaries= getBinaryFilter().getShowBinaries(); String showBinString= "true"; //$NON-NLS-1$ if (!showBinaries) showBinString= "false"; //$NON-NLS-1$ memento.putString(TAG_SHOWBINARIES, showBinString); } protected void savePatternFilterState(IMemento memento) { String filters[] = getPatternFilter().getPatterns(); if(filters.length > 0) { IMemento filtersMem = memento.createChild(TAG_FILTERS); for (int i = 0; i < filters.length; i++){ IMemento child = filtersMem.createChild(TAG_FILTER); child.putString(TAG_ELEMENT,filters[i]); } } } protected void saveScrollState(IMemento memento, Tree tree) { ScrollBar bar= tree.getVerticalBar(); int position= bar != null ? bar.getSelection() : 0; memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position)); //save horizontal position bar= tree.getHorizontalBar(); position= bar != null ? bar.getSelection() : 0; memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position)); } protected void saveSelectionState(IMemento memento) { Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray(); if (elements.length > 0) { IMemento selectionMem= memento.createChild(TAG_SELECTION); for (int i= 0; i < elements.length; i++) { IMemento elementMem= selectionMem.createChild(TAG_ELEMENT); // we can only persist JavaElements for now Object o= elements[i]; if (o instanceof IJavaElement) elementMem.putString(TAG_PATH, ((IJavaElement) elements[i]).getHandleIdentifier()); } } } protected void saveExpansionState(IMemento memento) { Object expandedElements[]= fViewer.getExpandedElements(); if (expandedElements.length > 0) { IMemento expandedMem= memento.createChild(TAG_EXPANDED); for (int i= 0; i < expandedElements.length; i++) { IMemento elementMem= expandedMem.createChild(TAG_ELEMENT); // we can only persist JavaElements for now Object o= expandedElements[i]; if (o instanceof IJavaElement) elementMem.putString(TAG_PATH, ((IJavaElement) expandedElements[i]).getHandleIdentifier()); } } } void restoreState(IMemento memento) { restoreExpansionState(memento); restoreSelectionState(memento); restoreScrollState(memento, fViewer.getTree()); } protected void restoreScrollState(IMemento memento, Tree tree) { ScrollBar bar= tree.getVerticalBar(); if (bar != null) { try { String posStr= memento.getString(TAG_VERTICAL_POSITION); int position; position= new Integer(posStr).intValue(); bar.setSelection(position); } catch (NumberFormatException e) { // ignore, don't set scrollposition } } bar= tree.getHorizontalBar(); if (bar != null) { try { String posStr= memento.getString(TAG_HORIZONTAL_POSITION); int position; position= new Integer(posStr).intValue(); bar.setSelection(position); } catch (NumberFormatException e) { // ignore don't set scroll position } } } protected void restoreSelectionState(IMemento memento) { IMemento childMem; childMem= memento.getChild(TAG_SELECTION); if (childMem != null) { ArrayList list= new ArrayList(); IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT); for (int i= 0; i < elementMem.length; i++) { Object element= JavaCore.create(elementMem[i].getString(TAG_PATH)); list.add(element); } fViewer.setSelection(new StructuredSelection(list)); } } protected void restoreExpansionState(IMemento memento) { IMemento childMem= memento.getChild(TAG_EXPANDED); if (childMem != null) { ArrayList elements= new ArrayList(); IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT); for (int i= 0; i < elementMem.length; i++) { Object element= JavaCore.create(elementMem[i].getString(TAG_PATH)); elements.add(element); } fViewer.setExpandedElements(elements.toArray()); } } /** * Create the KeyListener for doing the refresh on the viewer. */ private void initRefreshKey() { fViewer.getControl().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { if (event.keyCode == SWT.F5) { fRefreshAction.selectionChanged( (IStructuredSelection) fViewer.getSelection()); if (fRefreshAction.isEnabled()) fRefreshAction.run(); } } }); } void initFrameList() { fFrameSource= new PackagesFrameSource(this); fFrameList= new FrameList(fFrameSource); fFrameSource.connectTo(fFrameList); } /** * An editor has been activated. Set the selection in this Packages Viewer * to be the editor's input, if linking is enabled. */ void editorActivated(IEditorPart editor) { if (!isLinkingEnabled()) return; Object input= getElementOfInput(editor.getEditorInput()); Object element= null; if (input instanceof IFile) element= JavaCore.create((IFile)input); if (element == null) // try a non Java resource element= input; if (element != null) { // if the current selection is a child of the new // selection then ignore it. IStructuredSelection oldSelection= (IStructuredSelection)getSelection(); if (oldSelection.size() == 1) { Object o= oldSelection.getFirstElement(); if (o instanceof IMember) { IMember m= (IMember)o; if (element.equals(m.getCompilationUnit())) return; if (element.equals(m.getClassFile())) return; } } ISelection newSelection= new StructuredSelection(element); if (!fViewer.getSelection().equals(newSelection)) { fViewer.setSelection(newSelection); } } } /** * A compilation unit or class was expanded, expand * the main type. */ void expandMainType(Object element) { try { IType type= null; if (element instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit)element; IType[] types= cu.getTypes(); if (types.length > 0) type= types[0]; } else if (element instanceof IClassFile) { IClassFile cf= (IClassFile)element; type= cf.getType(); } if (type != null) { final IType type2= type; Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().asyncExec(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.expandToLevel(type2, 1); } }); } } } catch(JavaModelException e) { // no reveal } } /** * Returns the element contained in the EditorInput */ Object getElementOfInput(IEditorInput input) { if (input instanceof IFileEditorInput) return ((IFileEditorInput)input).getFile(); else if (input instanceof ClassFileEditorInput) return ((ClassFileEditorInput)input).getClassFile(); else if (input instanceof JarEntryEditorInput) return ((JarEntryEditorInput)input).getStorage(); return null; } /** * Returns the Viewer. */ TreeViewer getViewer() { return fViewer; } /** * Returns the pattern filter for this view. * @return the pattern filter */ JavaElementPatternFilter getPatternFilter() { return fPatternFilter; } /** * Returns the library filter for this view. * @return the library filter */ LibraryFilter getLibraryFilter() { return fLibraryFilter; } /** * Returns the Binary filter for this view. * @return the binary filter */ BinaryProjectFilter getBinaryFilter() { return fBinaryFilter; } void restoreFilters() { IMemento filtersMem= fMemento.getChild(TAG_FILTERS); if(filtersMem != null) { IMemento children[]= filtersMem.getChildren(TAG_FILTER); String filters[]= new String[children.length]; for (int i = 0; i < children.length; i++) { filters[i]= children[i].getString(TAG_ELEMENT); } getPatternFilter().setPatterns(filters); } else { getPatternFilter().setPatterns(new String[0]); } //restore library String show= fMemento.getString(TAG_SHOWLIBRARIES); if (show != null) getLibraryFilter().setShowLibraries(show.equals("true")); //$NON-NLS-1$ else initLibraryFilterFromPreferences(); //restore binary fileter String showbin= fMemento.getString(TAG_SHOWBINARIES); if (showbin != null) getBinaryFilter().setShowBinaries(show.equals("true")); //$NON-NLS-1$ else initBinaryFilterFromPreferences(); } void initFilterFromPreferences() { initBinaryFilterFromPreferences(); initLibraryFilterFromPreferences(); } void initLibraryFilterFromPreferences() { JavaPlugin plugin= JavaPlugin.getDefault(); boolean show= plugin.getPreferenceStore().getBoolean(TAG_SHOWLIBRARIES); getLibraryFilter().setShowLibraries(show); } void initBinaryFilterFromPreferences() { JavaPlugin plugin= JavaPlugin.getDefault(); boolean showbin= plugin.getPreferenceStore().getBoolean(TAG_SHOWBINARIES); getBinaryFilter().setShowBinaries(showbin); } /** * Updates the title text and title tool tip. * Called whenever the input of the viewer changes. */ void updateTitle() { Object input= getViewer().getInput(); String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ if (input == null || (input instanceof IJavaModel)) { setTitle(viewName); setTitleToolTip(""); //$NON-NLS-1$ } else { ILabelProvider labelProvider = (ILabelProvider) getViewer().getLabelProvider(); String inputText= labelProvider.getText(input); String title= PackagesMessages.getFormattedString("PackageExplorer.argTitle", new String[] { viewName, inputText }); //$NON-NLS-1$ setTitle(title); setTitleToolTip(getToolTipText(input)); } } /** * Sets the decorator for the package explorer. * * @param decorator a label decorator or <code>null</code> for no decorations. */ public void setLabelDecorator(ILabelDecorator decorator) { int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_VARIABLE; JavaElementLabelProvider javaProvider= new JavaElementLabelProvider(labelFlags); javaProvider.setErrorTickManager(new MarkerErrorTickProvider()); if (decorator == null) { fViewer.setLabelProvider(javaProvider); } else { fViewer.setLabelProvider(new DecoratingLabelProvider(javaProvider, decorator)); } } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty() != IPreferencesConstants.SHOW_CU_CHILDREN) return; if (fViewer != null) { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); boolean b= store.getBoolean(IPreferencesConstants.SHOW_CU_CHILDREN); ((JavaElementContentProvider)fViewer.getContentProvider()).setProvideMembers(b); fViewer.refresh(); } } }
    3,811
    Bug 3811 Setter / Getter generates setter for final fields (1GEUMGT)
    - private final String fName; - generate Setter and Getter - you get public void setName(String name) { fName= name; } which produces a compile error. NOTES: EG (6/5/2001 3:41:01 AM) not critical, can be documented. MA (02.08.2001 16:49:08) fixed in 200
    verified fixed
    2c52566
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T14:57:53Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/codemanipulation/AddGetterSetterOperation.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.codemanipulation; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * For given fields, method stubs for getters and setters are created. */ public class AddGetterSetterOperation implements IWorkspaceRunnable { private IField[] fFields; private List fCreatedAccessors; private IRequestQuery fSkipExistingQuery; private IRequestQuery fSkipFinalSettersQuery; private boolean fSkipAllFinalSetters; private boolean fSkipAllExisting; /** * Creates the operation. * @param fields The fields to create setter/getters for. * @param skipFinalSettersQuery Callback to ask if the setter can be skipped for a final field. * Argument of the query is the final field. * @param skipExistingQuery Callback to ask if setter / getters that already exist can be skipped. * Argument of the query is the existing method. */ public AddGetterSetterOperation(IField[] fields, IRequestQuery skipFinalSettersQuery, IRequestQuery skipExistingQuery) { super(); fFields= fields; fSkipExistingQuery= skipExistingQuery; fSkipFinalSettersQuery= skipFinalSettersQuery; fCreatedAccessors= new ArrayList(); } /** * The policy to evaluate the base name (no 'set'/'get' of the accessor. */ private String evalAccessorName(String fieldname) { if (fieldname.length() > 0) { char firstLetter= fieldname.charAt(0); if (!Character.isUpperCase(firstLetter)) { if (fieldname.length() > 1) { char secondLetter= fieldname.charAt(1); if (Character.isUpperCase(secondLetter)) { return fieldname.substring(1); } if (firstLetter == '_') { return String.valueOf(Character.toUpperCase(secondLetter)) + fieldname.substring(2); } } return String.valueOf(Character.toUpperCase(firstLetter)) + fieldname.substring(1); } } return fieldname; } /** * Creates the name of the parameter from an accessor name. */ private String getArgumentName(String accessorName) { if (accessorName.length() > 0) { char firstLetter= accessorName.charAt(0); if (!Character.isLowerCase(firstLetter)) { return "" + Character.toLowerCase(firstLetter) + accessorName.substring(1); //$NON-NLS-1$ } } return accessorName; } /** * Runs the operation. * @throws OperationCanceledException Runtime error thrown when operation is cancelled. */ public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { if (monitor == null) { monitor= new NullProgressMonitor(); } try { int nFields= fFields.length; monitor.beginTask(CodeManipulationMessages.getString("AddGetterSetterOperation.description"), nFields); //$NON-NLS-1$ for (int i= 0; i < nFields; i++) { generateStubs(fFields[i], new SubProgressMonitor(monitor, 1)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } } } finally { monitor.done(); } } private boolean querySkipFinalSetters(IField field) throws OperationCanceledException { if (!fSkipAllFinalSetters) { switch (fSkipFinalSettersQuery.doQuery(field)) { case IRequestQuery.CANCEL: throw new OperationCanceledException(); case IRequestQuery.NO: return false; case IRequestQuery.YES_ALL: fSkipAllFinalSetters= true; } } return true; } private boolean querySkipExistingMethods(IMethod method) throws OperationCanceledException { if (!fSkipAllExisting) { switch (fSkipExistingQuery.doQuery(method)) { case IRequestQuery.CANCEL: throw new OperationCanceledException(); case IRequestQuery.NO: return false; case IRequestQuery.YES_ALL: fSkipAllExisting= true; } } return true; } /** * Creates setter and getter for a given field. */ private void generateStubs(IField field, IProgressMonitor monitor) throws JavaModelException, OperationCanceledException { try { monitor.beginTask(CodeManipulationMessages.getFormattedString("AddGetterSetterOperation.processField", field.getElementName()), 2); //$NON-NLS-1$ fSkipAllFinalSetters= false; fSkipAllExisting= false; String fieldName= field.getElementName(); String accessorName= evalAccessorName(fieldName); String argname= getArgumentName(accessorName); boolean isStatic= Flags.isStatic(field.getFlags()); String typeName= Signature.toString(field.getTypeSignature()); IType parentType= field.getDeclaringType(); String lineDelim= StubUtility.getLineDelimiterUsed(parentType); int indent= StubUtility.getIndentUsed(field); // test if the getter already exists String getterName= "get" + accessorName; //$NON-NLS-1$ IMethod existing= JavaModelUtil.findMethod(getterName, new String[0], false, parentType); if (!(existing != null && querySkipExistingMethods(existing))) { // create the getter stub StringBuffer buf= new StringBuffer(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" * Gets the "); buf.append(argname); buf.append(".\n"); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" * @return Returns a "); buf.append(typeName); buf.append('\n'); //$NON-NLS-1$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public "); //$NON-NLS-1$ if (isStatic) { buf.append("static "); //$NON-NLS-1$ } buf.append(typeName); buf.append(' '); buf.append(getterName); buf.append("() {\nreturn "); buf.append(fieldName); buf.append(";\n}\n"); //$NON-NLS-2$ //$NON-NLS-1$ IJavaElement sibling= null; if (existing != null) { sibling= StubUtility.findSibling(existing); existing.delete(false, null); } String formattedContent= StubUtility.codeFormat(buf.toString(), indent, lineDelim) + lineDelim; fCreatedAccessors.add(parentType.createMethod(formattedContent, sibling, true, null)); } monitor.worked(1); String setterName= "set" + accessorName; //$NON-NLS-1$ String[] args= new String[] { field.getTypeSignature() }; // test if the setter already exists or field is final boolean isFinal= Flags.isFinal(field.getFlags()); existing= JavaModelUtil.findMethod(setterName, args, false, parentType); if (!(isFinal && querySkipFinalSetters(field)) && !(existing != null && querySkipExistingMethods(existing))) { // create the setter stub StringBuffer buf= new StringBuffer(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" * Sets the "); buf.append(argname); buf.append(".\n"); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" * @param "); buf.append(argname); buf.append(" The "); buf.append(argname); buf.append(" to set\n"); //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-2$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public "); //$NON-NLS-1$ if (isStatic) { buf.append("static "); //$NON-NLS-1$ } buf.append("void "); buf.append(setterName); //$NON-NLS-1$ buf.append('('); buf.append(typeName); buf.append(' '); buf.append(argname); buf.append(") {\n"); //$NON-NLS-1$ if (argname.equals(fieldName)) { if (isStatic) { buf.append(parentType.getElementName()); buf.append('.'); } else { buf.append("this."); //$NON-NLS-1$ } } buf.append(fieldName); buf.append("= "); buf.append(argname); buf.append(";\n}\n"); //$NON-NLS-1$ //$NON-NLS-2$ IJavaElement sibling= null; if (existing != null) { sibling= StubUtility.findSibling(existing); existing.delete(false, null); } String formattedContent= StubUtility.codeFormat(buf.toString(), indent, lineDelim) + lineDelim; fCreatedAccessors.add(parentType.createMethod(formattedContent, sibling, true, null)); } } finally { monitor.done(); } } /** * Returns the created accessors. To be called after a sucessful run. */ public IMethod[] getCreatedAccessors() { return (IMethod[]) fCreatedAccessors.toArray(new IMethod[fCreatedAccessors.size()]); } }
    3,811
    Bug 3811 Setter / Getter generates setter for final fields (1GEUMGT)
    - private final String fName; - generate Setter and Getter - you get public void setName(String name) { fName= name; } which produces a compile error. NOTES: EG (6/5/2001 3:41:01 AM) not critical, can be documented. MA (02.08.2001 16:49:08) fixed in 200
    verified fixed
    2c52566
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T14:57:53Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/codemanipulation/ImportsStructure.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.codemanipulation; import java.util.ArrayList; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IImportContainer; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IPackageDeclaration; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.DocumentManager; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; public class ImportsStructure implements IImportsStructure { private ICompilationUnit fCompilationUnit; private ArrayList fPackageEntries; private int fImportOnDemandThreshold; private boolean fReplaceExistingImports; /** * Creates an ImportsStructure for a compilation unit with existing * imports. New imports are added next to the existing import that * has the best match. */ public ImportsStructure(ICompilationUnit cu) throws JavaModelException { fCompilationUnit= cu; IImportDeclaration[] decls= cu.getImports(); fPackageEntries= new ArrayList(decls.length + 5); PackageEntry curr= null; for (int i= 0; i < decls.length; i++) { String packName= Signature.getQualifier(decls[i].getElementName()); if (curr == null || !packName.equals(curr.getName())) { curr= new PackageEntry(packName, -1); fPackageEntries.add(curr); } curr.add(decls[i]); } fImportOnDemandThreshold= Integer.MAX_VALUE; fReplaceExistingImports= false; } /** * Creates an ImportsStructure for a compilation unit where exiting imports should be * completly ignored. Create will replace all existing imports * @param preferenceOrder Defines the prefered order of imports. * @param importThreshold Defines the number of imports in a package needed to introduce a * import on demand instead (e.g. java.util.*) */ public ImportsStructure(ICompilationUnit cu, String[] preferenceOrder, int importThreshold) { fCompilationUnit= cu; int nEntries= preferenceOrder.length; fPackageEntries= new ArrayList(20 + nEntries); for (int i= 0; i < nEntries; i++) { PackageEntry entry= new PackageEntry(preferenceOrder[i], i); fPackageEntries.add(entry); } fImportOnDemandThreshold= importThreshold; fReplaceExistingImports= true; } public ICompilationUnit getCompilationUnit() { return fCompilationUnit; } private static boolean sameMatchLenTest(String newName, String bestName, String currName, int matchLen) { // known: bestName and currName differ from newName at position 'matchLen' // currName and bestName dont have to differ at position 'matchLen' // determine the order and return true if currName is closer to newName char newChar= getCharAt(newName, matchLen); char currChar= getCharAt(currName, matchLen); char bestChar= getCharAt(bestName, matchLen); if (newChar < currChar) { if (bestChar < newChar) { // b < n < c return (currChar - newChar) < (newChar - bestChar); // -> (c - n) < (n - b) } else { // n < b && n < c return currName.compareTo(bestName) < 0; // -> (c < b) } } else { if (bestChar > newChar) { // c < n < b return (newChar - currChar) < (bestChar - newChar); // -> (n - c) < (b - n) } else { // n > b && n > c return bestName.compareTo(currName) < 0; // -> (c > b) } } } private PackageEntry findBestMatch(String newName) { int bestMatchLen= -1; PackageEntry bestMatch= null; String bestName= ""; //$NON-NLS-1$ for (int i= 0; i < fPackageEntries.size(); i++) { boolean isBetterMatch; PackageEntry curr= (PackageEntry) fPackageEntries.get(i); String currName= curr.getName(); int currMatchLen= getMatchLen(currName, newName); if (currMatchLen > bestMatchLen) { isBetterMatch= true; } else if (currMatchLen == bestMatchLen) { if (currMatchLen == newName.length() && currMatchLen == currName.length() && currMatchLen == bestName.length()) { // dulicate entry and complete match isBetterMatch= curr.getNumberOfImports() > bestMatch.getNumberOfImports(); } else { isBetterMatch= sameMatchLenTest(newName, bestName, currName, currMatchLen); } } else { isBetterMatch= false; } if (isBetterMatch) { bestMatchLen= currMatchLen; bestMatch= curr; bestName= currName; } } return bestMatch; } /** * Adds a new import declaration that is sorted in the structure using * the best match algorithm. If an import already exists, the import is * not added. * @param qualifiedTypeName The fully qualified name of the type to import */ public void addImport(String qualifiedTypeName) { String packName= Signature.getQualifier(qualifiedTypeName); String typeName= Signature.getSimpleName(qualifiedTypeName); addImport(packName, typeName); } /** * Adds a new import declaration that is sorted in the structure using * the best match algorithm. If an import already exists, the import is * not added. * @param packageName The package name of the type to import * @param typeName The type name of the type to import (can be '*' for imports-on-demand) */ public void addImport(String packageName, String typeName) { String fullTypeName= JavaModelUtil.concatenateName(packageName, typeName); IImportDeclaration decl= fCompilationUnit.getImport(fullTypeName); PackageEntry bestMatch= findBestMatch(packageName); if (bestMatch == null) { PackageEntry packEntry= new PackageEntry(packageName, -1); packEntry.add(decl); fPackageEntries.add(packEntry); } else { int cmp= packageName.compareTo(bestMatch.getName()); if (cmp == 0) { bestMatch.sortIn(decl); } else { // create a new packageentry PackageEntry packEntry= new PackageEntry(packageName, bestMatch.getCategory()); packEntry.add(decl); int index= fPackageEntries.indexOf(bestMatch); if (cmp < 0) { // sort in ahead of best match fPackageEntries.add(index, packEntry); } else { // sort in after best match fPackageEntries.add(index + 1, packEntry); } } } } /** * Adds a new import declaration that is sorted in the structure using * the best match algorithm. If an import already exists, the import is * not added. * @param packageName The package name of the type to import * @param enclosingTypeName Name of the enclosing type (dor-separated) * @param typeName The type name of the type to import (can be '*' for imports-on-demand) */ public void addImport(String packageName, String enclosingTypeName, String typeName) { addImport(JavaModelUtil.concatenateName(packageName, enclosingTypeName), typeName); } private static int getMatchLen(String s, String t) { int len= Math.min(s.length(), t.length()); for (int i= 0; i < len; i++) { if (s.charAt(i) != t.charAt(i)) { return i; } } return len; } private static char getCharAt(String str, int index) { if (str.length() > index) { return str.charAt(index); } return 0; } /** * Creates all new elements in the import structure. * Returns all created IImportDeclaration. Does not return null */ public IImportDeclaration[] create(boolean save, IProgressMonitor monitor) throws CoreException { DocumentManager docManager= new DocumentManager(fCompilationUnit); docManager.connect(); try { IImportDeclaration[] res= create(docManager.getDocument(), monitor); if (save) { docManager.save(null); } return res; } finally { docManager.disconnect(); } } /** * Creates all new elements in the import structure. * Returns all created IImportDeclaration. Does not return null */ public IImportDeclaration[] create(IDocument doc, IProgressMonitor monitor) throws CoreException { ArrayList created= new ArrayList(); try { performCreate(created, doc); } finally { if (monitor != null) { monitor.done(); } } return (IImportDeclaration[]) created.toArray(new IImportDeclaration[created.size()]); } private int getPackageStatementEndPos() throws JavaModelException { IPackageDeclaration[] packDecls= fCompilationUnit.getPackageDeclarations(); if (packDecls != null && packDecls.length > 0) { ISourceRange range= packDecls[0].getSourceRange(); return range.getOffset() + range.getLength(); // semicolon is included } return 0; } private void performCreate(ArrayList created, IDocument doc) throws JavaModelException { int importsStart, importsLen; // 1GF5UU0: ITPJUI:WIN2000 - "Organize Imports" in java editor inserts lines in wrong format String lineDelim= StubUtility.getLineDelimiterFor(doc); int lastPos; StringBuffer buf= new StringBuffer(); IImportContainer container= fCompilationUnit.getImportContainer(); if (container.exists()) { ISourceRange importSourceRange= container.getSourceRange(); importsStart= importSourceRange.getOffset(); importsLen= importSourceRange.getLength(); if (!fReplaceExistingImports) { buf.append(container.getSource()); } lastPos= buf.length(); } else { importsStart= getPackageStatementEndPos(); importsLen= 0; lastPos= 0; } // all (top level) types in this cu IType[] topLevelTypes= fCompilationUnit.getTypes(); int lastCategory= -1; // create from last to first to not invalidate positions for (int i= fPackageEntries.size() -1; i >= 0; i--) { PackageEntry pack= (PackageEntry) fPackageEntries.get(i); int nImports= pack.getNumberOfImports(); if (nImports > 0) { String packName= pack.getName(); if (isImportNeeded(packName, topLevelTypes)) { // add empty line if (pack.getCategory() != lastCategory) { if (lastCategory != -1) { buf.insert(lastPos, lineDelim); } lastCategory= pack.getCategory(); } if (nImports >= fImportOnDemandThreshold) { // assume no existing imports String starimport= packName + ".*"; //$NON-NLS-1$ lastPos= insertImport(buf, lastPos, starimport, lineDelim); created.add(fCompilationUnit.getImport(starimport)); } else { for (int j= nImports - 1; j >= 0; j--) { IImportDeclaration currDecl= pack.getImportAt(j); if (fReplaceExistingImports || !currDecl.exists()) { lastPos= insertImport(buf, lastPos, currDecl.getElementName(), lineDelim); created.add(currDecl); } else { lastPos= currDecl.getSourceRange().getOffset() - importsStart; } } } } } } try { if (!container.exists() && created.size() > 0) { buf.append(lineDelim); // nl after import (<nl+>) if (importsStart > 0) { // package statement buf.insert(0, lineDelim); buf.insert(0, lineDelim); //<pack><nl*><nl*><import><nl+><nl-pack><cl> } else { buf.append(lineDelim); } } String newContent= buf.toString(); if (hasChanged(doc, importsStart, importsLen, newContent)) { doc.replace(importsStart, importsLen, newContent); } } catch (BadLocationException e) { // can not happen JavaPlugin.log(e); } } private boolean hasChanged(IDocument doc, int offset, int length, String content) throws BadLocationException { if (content.length() != length) { return true; } for (int i= 0; i < length; i++) { if (content.charAt(i) != doc.getChar(offset + i)) { return true; } } return false; } private boolean isImportNeeded(String packName, IType[] cuTypes) { if (packName.length() == 0 || "java.lang".equals(packName)) { //$NON-NLS-1$ return false; } if (cuTypes.length > 0) { if (packName.equals(cuTypes[0].getPackageFragment().getElementName())) { return false; } for (int i= 0; i < cuTypes.length; i++) { if (packName.equals(JavaModelUtil.getFullyQualifiedName(cuTypes[i]))) { return false; } } } return true; } private int insertImport(StringBuffer buf, int pos, String importName, String lineDelim) { StringBuffer name= new StringBuffer(); if (pos > 0 && pos == buf.length()) { buf.append(lineDelim); pos= buf.length(); } name.append("import "); //$NON-NLS-1$ name.append(importName); name.append(';'); if (pos < buf.length()) { name.append(lineDelim); } buf.insert(pos, name.toString()); return pos; } /* * Internal element for the import structure: A container for imports * of all types from the same package */ private static class PackageEntry { private String fName; private ArrayList fImportEntries; private int fCategory; public PackageEntry(String name, int category) { fName= name; fImportEntries= new ArrayList(5); fCategory= category; } public int findInsertPosition(String fullImportName) { int nInports= fImportEntries.size(); for (int i= 0; i < nInports; i++) { IImportDeclaration curr= getImportAt(i); if (fullImportName.compareTo(curr.getElementName()) <= 0) { return i; } } return nInports; } public void sortIn(IImportDeclaration imp) { String fullImportName= imp.getElementName(); int insertPosition= -1; int nInports= fImportEntries.size(); for (int i= 0; i < nInports; i++) { int cmp= fullImportName.compareTo(getImportAt(i).getElementName()); if (cmp == 0) { return; // exists already } else if (cmp < 0 && insertPosition == -1) { insertPosition= i; } } if (insertPosition == -1) { fImportEntries.add(imp); } else { fImportEntries.add(insertPosition, imp); } } public void add(IImportDeclaration imp) { fImportEntries.add(imp); } /*public IImportDeclaration findTypeName(String typeName) { int nInports= fImportEntries.size(); if (nInports > 0) { String fullName= StubUtility.getFullTypeName(fName, typeName); for (int i= 0; i < nInports; i++) { IImportDeclaration curr= getImportAt(i); if (!curr.isOnDemand()) { if (fullName.equals(curr.getElementName())) { return curr; } } } } return null; }*/ public final IImportDeclaration getImportAt(int index) { return (IImportDeclaration)fImportEntries.get(index); } public int getNumberOfImports() { return fImportEntries.size(); } public String getName() { return fName; } public int getCategory() { return fCategory; } } }
    4,365
    Bug 4365 Deadlock on save
    D:\devel\sdk203>.\jre\bin\java -verify -cp startup.jar org.eclipse.core.launcher .UIMain -application org.eclipse.ui.workbench -ws win32 -platform d:\workspaces\ eclipse-sh1\plugins Full thread dump Classic VM (J2RE 1.3.0 IBM build cn130-20010502, native threads ): "org.eclipse.jface.text.reconciler.MonoReconciler" (TID:0x2c8bee8, sys_threa d_t:0x13d10ab0, state:CW, native ID:0x424) prio=1 at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:421) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:138) at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:1 8) at org.eclipse.swt.widgets.Display.syncExec(Display.java:1572) at org.eclipse.jdt.ui.JavaElementContentProvider.postRunnable(JavaElemen tContentProvider.java:277) at org.eclipse.jdt.ui.JavaElementContentProvider.postRefresh(JavaElement ContentProvider.java:242) at org.eclipse.jdt.ui.JavaElementContentProvider.processDelta(JavaElemen tContentProvider.java:143) at org.eclipse.jdt.ui.JavaElementContentProvider.elementChanged(JavaElem entContentProvider.java:82) at org.eclipse.jdt.internal.core.JavaModelManager.fire(JavaModelManager. java:255) at org.eclipse.jdt.internal.core.WorkingCopy.reconcile(WorkingCopy.java: 250) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconci le(JavaReconcilingStrategy.java:39) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconci le(JavaReconcilingStrategy.java:51) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconcil er.java:66) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread .run(AbstractReconciler.java:153) "HelpServer" (TID:0x1fb7320, sys_thread_t:0x13b5c698, state:R, native ID:0x6 74) prio=5 at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:430) at java.net.ServerSocket.implAccept(ServerSocket.java:255) at java.net.ServerSocket.accept(ServerSocket.java:234) at org.eclipse.help.internal.server.HelpServer.run(HelpServer.java:127) "Java indexing: org.eclipse.jdt.internal.core.search.indexing.IndexManager" (TID:0x8e6ad0, sys_thread_t:0x123ca2a0, state:CW, native ID:0x6c8) prio=5 at java.lang.Thread.sleep(Native Method) at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobMan ager.java(Compiled Code)) at java.lang.Thread.run(Thread.java:498) "Finalizer" (TID:0x8e8708, sys_thread_t:0x86b710, state:CW, native ID:0x4c0) prio=8 at java.lang.Object.wait(Native Method) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java(Compiled Code )) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java(Compiled Code )) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java(Compiled C ode)) "Reference Handler" (TID:0x8e8750, sys_thread_t:0x839cc0, state:CW, native I D:0x668) prio=10 at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:421) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java(Compiled Code)) "Signal dispatcher" (TID:0x8e8798, sys_thread_t:0x835310, state:R, native ID :0x5dc) prio=5 "main" (TID:0x8e87e0, sys_thread_t:0x2355d8, state:CW, native ID:0x58c) prio =5 at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSave(C ompilationUnitEditor.java:252) at org.eclipse.ui.internal.EditorManager$9.run(EditorManager.java:776) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalCont ext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDi alog.java:335) at org.eclipse.ui.internal.EditorManager.runProgressMonitorOperation(Edi torManager.java:634) at org.eclipse.ui.internal.EditorManager.saveEditor(EditorManager.java:7 81) at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:1 173) at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:31) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(Act ionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContri butionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handle Event(ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:645) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1359) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1160) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:675) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoa der.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52) Monitor pool info: Initial monitor count: 32 Minimum number of free monitors before expansion: 5 Pool will next be expanded by: 16 Current total number of monitors: 32 Current number of free monitors: 9 Monitor Pool Dump (inflated object-monitors): sys_mon_t:0x00234ec0 infl_mon_t: 0x00234ab0: java.lang.ref.Reference$Lock@8F1738/8F1740: <unowned> Waiting to be notified: "Reference Handler" (0x839cc0) sys_mon_t:0x00234f10 infl_mon_t: 0x00234af0: java.lang.ref.ReferenceQueue$Lock@8F4350/8F4358: <unowned> Waiting to be notified: "Finalizer" (0x86b710) sys_mon_t:0x002351e8 infl_mon_t: 0x00000000: org.eclipse.jdt.internal.core.WorkingCopy@2DAF488/2DAF490: <unowned> Waiting to be notified: "main" (0x2355d8) sys_mon_t:0x00235210 infl_mon_t: 0x00234d50: org.eclipse.swt.widgets.RunnableLock@43C6310/43C6318: <unowned> Waiting to be notified: "org.eclipse.jface.text.reconciler.MonoReconciler" (0x13d10ab0) JVM System Monitor Dump (registered monitors): ACS Heap lock: <unowned> System Heap lock: <unowned> Sleep lock: <unowned> Waiting to be notified: "Java indexing: org.eclipse.jdt.internal.core.search.indexing.IndexM anager" (0x123ca2a0) Method trace lock: <unowned> UTF8 Cache lock: <unowned> Heap lock: <unowned> Rewrite Code lock: <unowned> Monitor Cache lock: owner "Signal dispatcher" (0x835310) 1 entry JNI Pinning lock: <unowned> JNI Global Reference lock: <unowned> Classloader lock: <unowned> Linking class lock: <unowned> Binclass lock: <unowned> Monitor Registry lock: owner "Signal dispatcher" (0x835310) 1 entry Thread queue lock: owner "Signal dispatcher" (0x835310) 1 entry Thread identifiers (as used in flat monitors): ident 13 "org.eclipse.jface.text.reconciler.MonoReconciler" (0x13d10ab0) ee 0x13d108e0 ident 7 "HelpServer" (0x13b5c698) ee 0x13b5c4c8 ident 6 "Java indexing: org.eclipse.jdt.internal.core.search.indexing.IndexM anager" (0x123ca2a0) ee 0x123ca0d0 ident 5 "Finalizer" (0x86b710) ee 0x0086b540 ident 4 "Reference Handler" (0x839cc0) ee 0x00839af0 ident 3 "Signal dispatcher" (0x835310) ee 0x00835140 ident 2 "main" (0x2355d8) ee 0x00235408 Java Object Monitor Dump (flat & inflated object-monitors): java.lang.ref.Reference$Lock@8F1738/8F1740 locknflags 80000200 Monitor inflated infl_mon 0x00234ab0 java.lang.ref.ReferenceQueue$Lock@8F4350/8F4358 locknflags 80000400 Monitor inflated infl_mon 0x00234af0 java.net.PlainSocketImpl@1142FB8/1142FC0 locknflags 00070000 Flat locked by threadIdent 7. Entrycount 1 org.eclipse.jdt.internal.core.WorkingCopy@2DAF488/2DAF490 locknflags 00130000 Flat locked by threadIdent 13. Entrycount 1 Writing java dump to D:\devel\sdk203/javacore764.1002803130.txt... OK
    resolved fixed
    07b70de
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T15:26:49Z
    2001-10-11T11:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementContentProvider.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.ui; import org.eclipse.core.resources.*; import org.eclipse.jdt.core.*; import org.eclipse.jdt.internal.ui.*; import org.eclipse.jdt.internal.ui.viewsupport.*; import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.*; /** * Standard tree content provider for Java elements. * Use this class when you want to present the Java elements in a viewer. * <p> * The following Java element hierarchy is surfaced by this content provider: * <p> * <pre> Java model (<code>IJavaModel</code>) Java project (<code>IJavaProject</code>) package fragment root (<code>IPackageFragmentRoot</code>) package fragment (<code>IPackageFragment</code>) compilation unit (<code>ICompilationUnit</code>) binary class file (<code>IClassFile</code>) * </pre> * </p> * <p> * Note that when the entire Java project is declared to be package fragment root, * the corresponding package fragment root element that normally appears between the * Java project and the package fragments is automatically filtered out. * </p> * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> */ public class JavaElementContentProvider extends BaseJavaElementContentProvider implements ITreeContentProvider, IElementChangedListener { protected TreeViewer fViewer; protected Object fInput; /* (non-Javadoc) * Method declared on IContentProvider. */ public void dispose() { super.dispose(); JavaCore.removeElementChangedListener(this); } /* (non-Javadoc) * Method declared on IContentProvider. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); fViewer= (TreeViewer)viewer; if (oldInput == null && newInput != null) { JavaCore.addElementChangedListener(this); } else if (oldInput != null && newInput == null) { JavaCore.removeElementChangedListener(this); } fInput= newInput; } /** * Creates a new content provider for Java elements. */ public JavaElementContentProvider() { } /** * Creates a new content provider for Java elements. */ public JavaElementContentProvider(boolean provideMembers) { super(provideMembers); } /* (non-Javadoc) * Method declared on IElementChangedListener. */ public void elementChanged(final ElementChangedEvent event) { try { processDelta(event.getDelta()); } catch(JavaModelException e) { JavaPlugin.getDefault().logErrorStatus(JavaUIMessages.getString("JavaElementContentProvider.errorMessage"), e.getStatus()); //$NON-NLS-1$ } } /** * Processes a delta recursively. When more than two children are affected the * tree is fully refreshed starting at this node. The delta is processed in the * current thread but the viewer updates are posted to the UI thread. */ protected void processDelta(IJavaElementDelta delta) throws JavaModelException { int kind= delta.getKind(); int flags= delta.getFlags(); IJavaElement element= delta.getElement(); // handle open and closing of a solution or project if (((flags & IJavaElementDelta.F_CLOSED) != 0) || ((flags & IJavaElementDelta.F_OPENED) != 0)) { postRefresh(element); return; } if (kind == IJavaElementDelta.REMOVED) { Object parent= internalGetParent(element); postRemove(element); if (parent instanceof IPackageFragment) updatePackageIcon((IPackageFragment)parent); // we are filtering out empty subpackages, so we // a package becomes empty we remove it from the viewer. if (isPackageFragmentEmpty(element.getParent())) { if (fViewer.testFindItem(parent) != null) postRefresh(internalGetParent(parent)); } return; } if (kind == IJavaElementDelta.ADDED) { Object parent= internalGetParent(element); // we are filtering out empty subpackages, so we // have to handle additions to them specially. if (parent instanceof IPackageFragment) { Object grandparent= internalGetParent(parent); // 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View // avoid posting a refresh to an unvisible parent if (parent.equals(fInput)) { postRefresh(parent); } else { // refresh from grandparent if parent isn't visible yet if (fViewer.testFindItem(parent) == null) postRefresh(grandparent); else { postRefresh(parent); } } } else { postAdd(parent, element); } } if (element instanceof ICompilationUnit) { if (kind == IJavaElementDelta.CHANGED) { postRefresh(element); } } // we don't show the contents of a compilation or IClassFile, so don't go any deeper if ((element instanceof ICompilationUnit) || (element instanceof IClassFile)) return; if (isClassPathChange(delta)) { // throw the towel and do a full refresh of the affected java project. postRefresh(element.getJavaProject()); } if (delta.getResourceDeltas() != null) { IResourceDelta[] rd= delta.getResourceDeltas(); IJavaProject project= element.getJavaProject(); for (int i= 0; i < rd.length; i++) { processResourceDelta(rd[i], element); } } IJavaElementDelta[] affectedChildren= delta.getAffectedChildren(); if (affectedChildren.length > 1) { // a package fragment might become non empty refresh from the parent if (element instanceof IPackageFragment) { IJavaElement parent= (IJavaElement)internalGetParent(element); // 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View // avoid posting a refresh to an unvisible parent if (element.equals(fInput)) { postRefresh(element); } else { postRefresh(parent); } return; } // more than one child changed, refresh from here downwards if (element instanceof IPackageFragmentRoot) postRefresh(skipProjectPackageFragmentRoot((IPackageFragmentRoot)element)); else postRefresh(element); return; } for (int i= 0; i < affectedChildren.length; i++) { processDelta(affectedChildren[i]); } } /** * Updates the package icon */ private void updatePackageIcon(final IJavaElement element) { postRunnable(new Runnable() { public void run() { // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window. Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE}); } }); } /** * Process resource deltas */ private void processResourceDelta(IResourceDelta delta, Object parent) { int status= delta.getKind(); IResource resource= delta.getResource(); // filter out changes affecting the output folder if (resource == null) return; // this could be optimized by handling all the added children in the parent if ((status & IResourceDelta.REMOVED) != 0) { if (parent instanceof IPackageFragment) // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent)); else postRemove(resource); } if ((status & IResourceDelta.ADDED) != 0) { if (parent instanceof IPackageFragment) // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent)); else postAdd(parent, resource); } int changeFlags= delta.getFlags(); IResourceDelta[] affectedChildren= delta.getAffectedChildren(); if (affectedChildren.length > 1) { // more than one child changed, refresh from here downwards postRefresh(resource); return; } for (int i= 0; i < affectedChildren.length; i++) processResourceDelta(affectedChildren[i], resource); } private void postRefresh(final Object root) { postRunnable(new Runnable() { public void run() { // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window. Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.refresh(root); } }); } private void postAdd(final Object parent, final Object element) { postRunnable(new Runnable() { public void run() { // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window. Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.add(parent, element); } }); } private void postRemove(final Object element) { postRunnable(new Runnable() { public void run() { // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window. Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.remove(element); } }); } private void postRunnable(final Runnable r) { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().syncExec(r); } } }
    4,385
    Bug 4385 QualifiedAllocationExpression.sourceEnd incorrect if type is an AnonymousLocalTypeDeclaration
    Consider the following source: Protectable p= new Protectable() { public void protect() throws Exception { setUp(); basicRun(result); tearDown(); } }; SourceEnd of the QualifiedAllocationExpression new Protectable is the e of Protectable and not the closing } of the type declaration
    resolved fixed
    5f2190e
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T16:25:05Z
    2001-10-11T14:20:00Z
    org.eclipse.jdt.ui/core
    4,385
    Bug 4385 QualifiedAllocationExpression.sourceEnd incorrect if type is an AnonymousLocalTypeDeclaration
    Consider the following source: Protectable p= new Protectable() { public void protect() throws Exception { setUp(); basicRun(result); tearDown(); } }; SourceEnd of the QualifiedAllocationExpression new Protectable is the e of Protectable and not the closing } of the type declaration
    resolved fixed
    5f2190e
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-11T16:25:05Z
    2001-10-11T14:20:00Z
    refactoring/org/eclipse/jdt/internal/core/refactoring/code/StatementAnalyzer.java
    4,916
    Bug 4916 Potential IDE freeze on Template Preference Page
    Comments from Adam Kiezun: SEVERE: 1. go to template pref page. 2. select the first one 3. edit the name - empty the field and then put a single space whole IDE freezes (infinite loop?)
    resolved fixed
    d8ca187
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-12T12:11:08Z
    2001-10-12T12:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TemplatePreferencePage.java
    package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.text.template.Template; import org.eclipse.jdt.internal.ui.text.template.TemplateContentProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateLabelProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateMessages; import org.eclipse.jdt.internal.ui.text.template.TemplateSet; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jface.dialogs.ControlEnableState; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // preference store keys private static final String PREF_FORMAT_TEMPLATES= JavaUI.ID_PLUGIN + ".template.format"; //$NON-NLS-1$ private CheckboxTableViewer fTableViewer; private Button fAddButton; private Button fRemoveButton; private Button fEnableAllButton; private Button fDisableAllButton; private Group fEditor; private Text fNameText; private Text fDescriptionText; private Combo fContextCombo; private SourceViewer fPatternEditor; private Button fFormatButton; private ControlEnableState fEditorEnabler; private List fEditorComponents; private Template fCurrent; public TemplatePreferencePage() { super(); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$ } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent= new Composite(ancestor, SWT.NULL); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; parent.setLayout(layout); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite firstPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; firstPage.setLayout(layout); TabItem item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.edit")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(firstPage); fTableViewer= new CheckboxTableViewer(firstPage, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Table table= fTableViewer.getTable(); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= convertWidthInCharsToPixels(80); data.heightHint= convertHeightInCharsToPixels(10); fTableViewer.getTable().setLayoutData(data); table.setHeaderVisible(true); table.setLinesVisible(true); TableLayout tableLayout= new TableLayout(); table.setLayout(tableLayout); // TableColumn column1= new TableColumn(table, SWT.NULL); TableColumn column1= table.getColumn(0); column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$ TableColumn column2= new TableColumn(table, SWT.NULL); column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(70)); fTableViewer.setLabelProvider(new TemplateLabelProvider()); fTableViewer.setContentProvider(new TemplateContentProvider(fTableViewer, TemplateSet.getInstance())); fTableViewer.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left= (Template) object1; Template right= (Template) object2; int result= left.getName().compareToIgnoreCase(right.getName()); if (result != 0) return result; return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); } public boolean isSorterProperty(Object element, String property) { return true; } }); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { selectionChanged1(); } }); fTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { Template template= (Template) event.getElement(); template.setEnabled(event.getChecked()); } }); Composite buttons= new Composite(firstPage, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; buttons.setLayout(layout); fAddButton= new Button(buttons, SWT.PUSH); fAddButton.setLayoutData(getButtonGridData(fAddButton)); fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$ fAddButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { add(); } }); fRemoveButton= new Button(buttons, SWT.PUSH); fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton)); fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$ fRemoveButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); fEnableAllButton= new Button(buttons, SWT.PUSH); fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton)); fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$ fEnableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(true); } }); fDisableAllButton= new Button(buttons, SWT.PUSH); fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton)); fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$ fDisableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(false); } }); fEditor= new Group(firstPage, SWT.NULL); fEditor.setText(TemplateMessages.getString("TemplatePreferencePage.editor")); //$NON-NLS-1$ fEditor.setLayoutData(new GridData(GridData.FILL_BOTH)); layout= new GridLayout(); layout.numColumns= 2; fEditor.setLayout(layout); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.name")); //$NON-NLS-1$ Composite composite= new Composite(fEditor, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout= new GridLayout(); layout.numColumns= 3; layout.marginWidth= 0; layout.marginHeight= 0; composite.setLayout(layout); fNameText= createText(composite); fNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setName(fNameText.getText()); fTableViewer.refresh(fCurrent); updateButtons(); } }); createLabel(composite, TemplateMessages.getString("TemplatePreferencePage.context")); //$NON-NLS-1$ fContextCombo= new Combo(composite, SWT.READ_ONLY); fContextCombo.setItems(new String[] {"java", "javadoc"}); //$NON-NLS-1$ //$NON-NLS-2$ fContextCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setContext(fContextCombo.getText()); fTableViewer.refresh(fCurrent); } }); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.description")); //$NON-NLS-1$ fDescriptionText= createText(fEditor); fDescriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setDescription(fDescriptionText.getText()); fTableViewer.refresh(fCurrent); } }); Label patternLabel= createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.pattern")); //$NON-NLS-1$ patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fPatternEditor= createEditor(fEditor); StyledText text= fPatternEditor.getTextWidget(); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setPattern(fPatternEditor.getTextWidget().getText()); } }); Composite secondPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 1; secondPage.setLayout(layout); item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.options")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(secondPage); fFormatButton= new Button(secondPage, SWT.CHECK); fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES)); fTableViewer.setInput(TemplateSet.getInstance()); fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); updateButtons(); WorkbenchHelp.setHelp(parent, new DialogPageContextComputer(this, IJavaHelpContextIds.JRE_PREFERENCE_PAGE)); leaveEditor(); return parent; } private Template[] getEnabledTemplates() { Template[] templates= TemplateSet.getInstance().getTemplates(); List list= new ArrayList(templates.length); for (int i= 0; i != templates.length; i++) if (templates[i].isEnabled()) list.add(templates[i]); return (Template[]) list.toArray(new Template[list.size()]); } private static Label createLabel(Composite parent, String name) { Label label= new Label(parent, SWT.NULL); label.setText(name); label.setLayoutData(new GridData()); return label; } private static Text createText(Composite parent) { Text text= new Text(parent, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return text; } private SourceViewer createEditor(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(true); viewer.setDocument(new Document()); Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); Control control= viewer.getControl(); GridData data= new GridData(GridData.FILL_BOTH); data.heightHint= convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; } private static GridData getButtonGridData(Button button) { GridData data= new GridData(GridData.FILL_HORIZONTAL); data.widthHint= SWTUtil.getButtonWidthHint(button); data.heightHint= SWTUtil.getButtonHeigthHint(button); return data; } private void selectionChanged1() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); if (selection.size() == 1) { Template template= (Template) selection.getFirstElement(); enterEditor(template); } else { leaveEditor(); } updateButtons(); } private void updateButtons() { int selectionCount= ((IStructuredSelection) fTableViewer.getSelection()).size(); int itemCount= fTableViewer.getTable().getItemCount(); boolean error= (fCurrent != null) && (fCurrent.getName().length() == 0); fAddButton.setEnabled(!error); fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount); fEnableAllButton.setEnabled(itemCount > 0); fDisableAllButton.setEnabled(itemCount > 0); StatusInfo status= new StatusInfo(); if (error) status.setError(TemplateMessages.getString("TemplatePreferencePage.error.noname")); //$NON-NLS-1$ setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } private static int getIndex(String context) { if (context.equals("java")) //$NON-NLS-1$ return 0; else if (context.equals("javadoc")) //$NON-NLS-1$ return 1; else return -1; } private void enterEditor(Template template) { fCurrent= template; fNameText.setText(template.getName()); fDescriptionText.setText(template.getDescription()); fContextCombo.select(getIndex(template.getContext())); fPatternEditor.getDocument().set(template.getPattern()); if (fEditorEnabler != null) { fEditorEnabler.restore(); fEditorEnabler= null; } } private void leaveEditor() { fCurrent= null; fNameText.setText(""); //$NON-NLS-1$ fDescriptionText.setText(""); //$NON-NLS-1$ fContextCombo.select(getIndex("")); //$NON-NLS-1$ fPatternEditor.getDocument().set(""); //$NON-NLS-1$ if (fEditorEnabler == null) fEditorEnabler= ControlEnableState.disable(fEditor); } private void add() { Template template= new Template(); template.setContext("java"); //$NON-NLS-1$ TemplateSet.getInstance().add(template); fTableViewer.refresh(); fTableViewer.setChecked(template, template.isEnabled()); enterEditor(template); fNameText.setFocus(); } private void remove() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Iterator elements= selection.iterator(); while (elements.hasNext()) { Template template= (Template) elements.next(); TemplateSet.getInstance().remove(template); } leaveEditor(); fTableViewer.refresh(); } private void enableAll(boolean enable) { Template[] templates= TemplateSet.getInstance().getTemplates(); for (int i= 0; i != templates.length; i++) templates[i].setEnabled(enable); fTableViewer.setAllChecked(enable); } /* * @see IWorkbenchPreferencePage#init(IWorkbench) */ public void init(IWorkbench workbench) {} /* * @see Control#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$ } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES)); TemplateSet.getInstance().restoreDefaults(); fTableViewer.refresh(); } /* * @see PreferencePage#performOk() */ public boolean performOk() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection()); TemplateSet.getInstance().save(); return super.performOk(); } /* * @see PreferencePage#performCancel() */ public boolean performCancel() { TemplateSet.getInstance().reset(); return super.performCancel(); } /** * Initializes the default values of this page in the preference bundle. * Will be called on startup of the JavaPlugin */ public static void initDefaults(IPreferenceStore prefs) { prefs.setDefault(PREF_FORMAT_TEMPLATES, true); } public static boolean useCodeFormatter() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); return prefs.getBoolean(PREF_FORMAT_TEMPLATES); } }
    4,358
    Bug 4358 Template - steals closing bracket
    Steps to reproduce - press new - enter name for - enter description for(collection, type, var) - iterate over collection - enter pattern for (Iterator iter= ${0}.iterator; iter.hasNext(); ) { ${1} ${2}= (${1})iter.next(); ${cursor} - press return several times - position cursor after ${cursor} - press enter - press } - press OK - reopen dialog ==> observe: closing bracket } is missing.
    resolved fixed
    4b44b25
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-12T13:33:04Z
    2001-10-11T11:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TemplatePreferencePage.java
    package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.text.template.Template; import org.eclipse.jdt.internal.ui.text.template.TemplateContentProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateLabelProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateMessages; import org.eclipse.jdt.internal.ui.text.template.TemplateSet; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jface.dialogs.ControlEnableState; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // preference store keys private static final String PREF_FORMAT_TEMPLATES= JavaUI.ID_PLUGIN + ".template.format"; //$NON-NLS-1$ private CheckboxTableViewer fTableViewer; private Button fAddButton; private Button fRemoveButton; private Button fEnableAllButton; private Button fDisableAllButton; private Group fEditor; private Text fNameText; private Text fDescriptionText; private Combo fContextCombo; private SourceViewer fPatternEditor; private Button fFormatButton; private ControlEnableState fEditorEnabler; private List fEditorComponents; private Template fCurrent; public TemplatePreferencePage() { super(); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$ } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent= new Composite(ancestor, SWT.NULL); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; parent.setLayout(layout); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite firstPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; firstPage.setLayout(layout); TabItem item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.edit")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(firstPage); fTableViewer= new CheckboxTableViewer(firstPage, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Table table= fTableViewer.getTable(); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= convertWidthInCharsToPixels(80); data.heightHint= convertHeightInCharsToPixels(10); fTableViewer.getTable().setLayoutData(data); table.setHeaderVisible(true); table.setLinesVisible(true); TableLayout tableLayout= new TableLayout(); table.setLayout(tableLayout); // TableColumn column1= new TableColumn(table, SWT.NULL); TableColumn column1= table.getColumn(0); column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$ TableColumn column2= new TableColumn(table, SWT.NULL); column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(70)); fTableViewer.setLabelProvider(new TemplateLabelProvider()); fTableViewer.setContentProvider(new TemplateContentProvider(fTableViewer, TemplateSet.getInstance())); fTableViewer.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left= (Template) object1; Template right= (Template) object2; int result= left.getName().compareToIgnoreCase(right.getName()); if (result != 0) return result; return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); } public boolean isSorterProperty(Object element, String property) { return true; } }); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { selectionChanged1(); } }); fTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { Template template= (Template) event.getElement(); template.setEnabled(event.getChecked()); } }); Composite buttons= new Composite(firstPage, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; buttons.setLayout(layout); fAddButton= new Button(buttons, SWT.PUSH); fAddButton.setLayoutData(getButtonGridData(fAddButton)); fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$ fAddButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { add(); } }); fRemoveButton= new Button(buttons, SWT.PUSH); fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton)); fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$ fRemoveButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); fEnableAllButton= new Button(buttons, SWT.PUSH); fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton)); fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$ fEnableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(true); } }); fDisableAllButton= new Button(buttons, SWT.PUSH); fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton)); fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$ fDisableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(false); } }); fEditor= new Group(firstPage, SWT.NULL); fEditor.setText(TemplateMessages.getString("TemplatePreferencePage.editor")); //$NON-NLS-1$ fEditor.setLayoutData(new GridData(GridData.FILL_BOTH)); layout= new GridLayout(); layout.numColumns= 2; fEditor.setLayout(layout); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.name")); //$NON-NLS-1$ Composite composite= new Composite(fEditor, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout= new GridLayout(); layout.numColumns= 3; layout.marginWidth= 0; layout.marginHeight= 0; composite.setLayout(layout); fNameText= createText(composite); fNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setName(fNameText.getText()); fTableViewer.refresh(fCurrent); updateButtons(); } }); createLabel(composite, TemplateMessages.getString("TemplatePreferencePage.context")); //$NON-NLS-1$ fContextCombo= new Combo(composite, SWT.READ_ONLY); fContextCombo.setItems(new String[] {"java", "javadoc"}); //$NON-NLS-1$ //$NON-NLS-2$ fContextCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setContext(fContextCombo.getText()); fTableViewer.refresh(fCurrent); } }); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.description")); //$NON-NLS-1$ fDescriptionText= createText(fEditor); fDescriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setDescription(fDescriptionText.getText()); fTableViewer.refresh(fCurrent); } }); Label patternLabel= createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.pattern")); //$NON-NLS-1$ patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fPatternEditor= createEditor(fEditor); StyledText text= fPatternEditor.getTextWidget(); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setPattern(fPatternEditor.getTextWidget().getText()); } }); Composite secondPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 1; secondPage.setLayout(layout); item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.options")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(secondPage); fFormatButton= new Button(secondPage, SWT.CHECK); fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES)); fTableViewer.setInput(TemplateSet.getInstance()); fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); updateButtons(); WorkbenchHelp.setHelp(parent, new DialogPageContextComputer(this, IJavaHelpContextIds.JRE_PREFERENCE_PAGE)); leaveEditor(); return parent; } private Template[] getEnabledTemplates() { Template[] templates= TemplateSet.getInstance().getTemplates(); List list= new ArrayList(templates.length); for (int i= 0; i != templates.length; i++) if (templates[i].isEnabled()) list.add(templates[i]); return (Template[]) list.toArray(new Template[list.size()]); } private static Label createLabel(Composite parent, String name) { Label label= new Label(parent, SWT.NULL); label.setText(name); label.setLayoutData(new GridData()); return label; } private static Text createText(Composite parent) { Text text= new Text(parent, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return text; } private SourceViewer createEditor(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(true); viewer.setDocument(new Document()); Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); Control control= viewer.getControl(); GridData data= new GridData(GridData.FILL_BOTH); data.heightHint= convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; } private static GridData getButtonGridData(Button button) { GridData data= new GridData(GridData.FILL_HORIZONTAL); data.widthHint= SWTUtil.getButtonWidthHint(button); data.heightHint= SWTUtil.getButtonHeigthHint(button); return data; } private void selectionChanged1() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); if (selection.size() == 1) { Template template= (Template) selection.getFirstElement(); enterEditor(template); } else { leaveEditor(); } updateButtons(); } private void updateButtons() { int selectionCount= ((IStructuredSelection) fTableViewer.getSelection()).size(); int itemCount= fTableViewer.getTable().getItemCount(); boolean error= (fCurrent != null) && (fCurrent.getName().length() == 0); fAddButton.setEnabled(!error); fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount); fEnableAllButton.setEnabled(itemCount > 0); fDisableAllButton.setEnabled(itemCount > 0); StatusInfo status= new StatusInfo(); if (error) status.setError(TemplateMessages.getString("TemplatePreferencePage.error.noname")); //$NON-NLS-1$ setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } private static int getIndex(String context) { if (context.equals("java")) //$NON-NLS-1$ return 0; else if (context.equals("javadoc")) //$NON-NLS-1$ return 1; else return -1; } private void enterEditor(Template template) { if (template == fCurrent) // #4916 return; fCurrent= template; fNameText.setText(template.getName()); fDescriptionText.setText(template.getDescription()); fContextCombo.select(getIndex(template.getContext())); fPatternEditor.getDocument().set(template.getPattern()); if (fEditorEnabler != null) { fEditorEnabler.restore(); fEditorEnabler= null; } } private void leaveEditor() { fCurrent= null; fNameText.setText(""); //$NON-NLS-1$ fDescriptionText.setText(""); //$NON-NLS-1$ fContextCombo.select(getIndex("")); //$NON-NLS-1$ fPatternEditor.getDocument().set(""); //$NON-NLS-1$ if (fEditorEnabler == null) fEditorEnabler= ControlEnableState.disable(fEditor); } private void add() { Template template= new Template(); template.setContext("java"); //$NON-NLS-1$ TemplateSet.getInstance().add(template); fTableViewer.refresh(); fTableViewer.setChecked(template, template.isEnabled()); enterEditor(template); fNameText.setFocus(); } private void remove() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Iterator elements= selection.iterator(); while (elements.hasNext()) { Template template= (Template) elements.next(); TemplateSet.getInstance().remove(template); } leaveEditor(); fTableViewer.refresh(); } private void enableAll(boolean enable) { Template[] templates= TemplateSet.getInstance().getTemplates(); for (int i= 0; i != templates.length; i++) templates[i].setEnabled(enable); fTableViewer.setAllChecked(enable); } /* * @see IWorkbenchPreferencePage#init(IWorkbench) */ public void init(IWorkbench workbench) {} /* * @see Control#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$ } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES)); TemplateSet.getInstance().restoreDefaults(); fTableViewer.refresh(); } /* * @see PreferencePage#performOk() */ public boolean performOk() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection()); TemplateSet.getInstance().save(); return super.performOk(); } /* * @see PreferencePage#performCancel() */ public boolean performCancel() { TemplateSet.getInstance().reset(); return super.performCancel(); } /** * Initializes the default values of this page in the preference bundle. * Will be called on startup of the JavaPlugin */ public static void initDefaults(IPreferenceStore prefs) { prefs.setDefault(PREF_FORMAT_TEMPLATES, true); } public static boolean useCodeFormatter() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); return prefs.getBoolean(PREF_FORMAT_TEMPLATES); } }
    4,354
    Bug 4354 Template - pressing new presents an error
    - go to Preferences->Java->Templates - press the new button - you get an error saying that the template name must not be null. This is annoying since I didn't have the change to specify one.
    resolved fixed
    2a1a288
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-12T15:09:58Z
    2001-10-11T08:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TemplatePreferencePage.java
    package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.text.template.Template; import org.eclipse.jdt.internal.ui.text.template.TemplateContentProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateLabelProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateMessages; import org.eclipse.jdt.internal.ui.text.template.TemplateSet; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jface.dialogs.ControlEnableState; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // preference store keys private static final String PREF_FORMAT_TEMPLATES= JavaUI.ID_PLUGIN + ".template.format"; //$NON-NLS-1$ private CheckboxTableViewer fTableViewer; private Button fAddButton; private Button fRemoveButton; private Button fEnableAllButton; private Button fDisableAllButton; private Group fEditor; private Text fNameText; private Text fDescriptionText; private Combo fContextCombo; private SourceViewer fPatternEditor; private Button fFormatButton; private ControlEnableState fEditorEnabler; private List fEditorComponents; private Template fCurrent; public TemplatePreferencePage() { super(); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$ } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent= new Composite(ancestor, SWT.NULL); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; parent.setLayout(layout); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite firstPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; firstPage.setLayout(layout); TabItem item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.edit")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(firstPage); fTableViewer= new CheckboxTableViewer(firstPage, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Table table= fTableViewer.getTable(); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= convertWidthInCharsToPixels(80); data.heightHint= convertHeightInCharsToPixels(10); fTableViewer.getTable().setLayoutData(data); table.setHeaderVisible(true); table.setLinesVisible(true); TableLayout tableLayout= new TableLayout(); table.setLayout(tableLayout); // TableColumn column1= new TableColumn(table, SWT.NULL); TableColumn column1= table.getColumn(0); column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$ TableColumn column2= new TableColumn(table, SWT.NULL); column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(70)); fTableViewer.setLabelProvider(new TemplateLabelProvider()); fTableViewer.setContentProvider(new TemplateContentProvider(fTableViewer, TemplateSet.getInstance())); fTableViewer.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left= (Template) object1; Template right= (Template) object2; int result= left.getName().compareToIgnoreCase(right.getName()); if (result != 0) return result; return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); } public boolean isSorterProperty(Object element, String property) { return true; } }); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { selectionChanged1(); } }); fTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { Template template= (Template) event.getElement(); template.setEnabled(event.getChecked()); } }); Composite buttons= new Composite(firstPage, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; buttons.setLayout(layout); fAddButton= new Button(buttons, SWT.PUSH); fAddButton.setLayoutData(getButtonGridData(fAddButton)); fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$ fAddButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { add(); } }); fRemoveButton= new Button(buttons, SWT.PUSH); fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton)); fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$ fRemoveButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); fEnableAllButton= new Button(buttons, SWT.PUSH); fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton)); fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$ fEnableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(true); } }); fDisableAllButton= new Button(buttons, SWT.PUSH); fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton)); fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$ fDisableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(false); } }); fEditor= new Group(firstPage, SWT.NULL); fEditor.setText(TemplateMessages.getString("TemplatePreferencePage.editor")); //$NON-NLS-1$ fEditor.setLayoutData(new GridData(GridData.FILL_BOTH)); layout= new GridLayout(); layout.numColumns= 2; fEditor.setLayout(layout); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.name")); //$NON-NLS-1$ Composite composite= new Composite(fEditor, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout= new GridLayout(); layout.numColumns= 3; layout.marginWidth= 0; layout.marginHeight= 0; composite.setLayout(layout); fNameText= createText(composite); fNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setName(fNameText.getText()); fTableViewer.refresh(fCurrent); updateButtons(); } }); createLabel(composite, TemplateMessages.getString("TemplatePreferencePage.context")); //$NON-NLS-1$ fContextCombo= new Combo(composite, SWT.READ_ONLY); fContextCombo.setItems(new String[] {"java", "javadoc"}); //$NON-NLS-1$ //$NON-NLS-2$ fContextCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setContext(fContextCombo.getText()); fTableViewer.refresh(fCurrent); } }); createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.description")); //$NON-NLS-1$ fDescriptionText= createText(fEditor); fDescriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (fCurrent == null) return; fCurrent.setDescription(fDescriptionText.getText()); fTableViewer.refresh(fCurrent); } }); Label patternLabel= createLabel(fEditor, TemplateMessages.getString("TemplatePreferencePage.pattern")); //$NON-NLS-1$ patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fPatternEditor= createEditor(fEditor); Composite secondPage= new Composite(folder, SWT.NONE); layout= new GridLayout(); layout.numColumns= 1; secondPage.setLayout(layout); item= new TabItem(folder, SWT.NONE); item.setText(TemplateMessages.getString("TemplatePreferencePage.tab.options")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)); item.setControl(secondPage); fFormatButton= new Button(secondPage, SWT.CHECK); fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES)); fTableViewer.setInput(TemplateSet.getInstance()); fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); updateButtons(); WorkbenchHelp.setHelp(parent, new DialogPageContextComputer(this, IJavaHelpContextIds.JRE_PREFERENCE_PAGE)); leaveEditor(); return parent; } private Template[] getEnabledTemplates() { Template[] templates= TemplateSet.getInstance().getTemplates(); List list= new ArrayList(templates.length); for (int i= 0; i != templates.length; i++) if (templates[i].isEnabled()) list.add(templates[i]); return (Template[]) list.toArray(new Template[list.size()]); } private static Label createLabel(Composite parent, String name) { Label label= new Label(parent, SWT.NULL); label.setText(name); label.setLayoutData(new GridData()); return label; } private static Text createText(Composite parent) { Text text= new Text(parent, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return text; } private SourceViewer createEditor(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(true); viewer.setDocument(new Document()); Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); Control control= viewer.getControl(); GridData data= new GridData(GridData.FILL_BOTH); data.heightHint= convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; } private static GridData getButtonGridData(Button button) { GridData data= new GridData(GridData.FILL_HORIZONTAL); data.widthHint= SWTUtil.getButtonWidthHint(button); data.heightHint= SWTUtil.getButtonHeigthHint(button); return data; } private void selectionChanged1() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); if (selection.size() == 1) { Template template= (Template) selection.getFirstElement(); enterEditor(template); } else { leaveEditor(); } updateButtons(); } private void updateButtons() { int selectionCount= ((IStructuredSelection) fTableViewer.getSelection()).size(); int itemCount= fTableViewer.getTable().getItemCount(); boolean error= (fCurrent != null) && (fCurrent.getName().length() == 0); fAddButton.setEnabled(!error); fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount); fEnableAllButton.setEnabled(itemCount > 0); fDisableAllButton.setEnabled(itemCount > 0); StatusInfo status= new StatusInfo(); if (error) status.setError(TemplateMessages.getString("TemplatePreferencePage.error.noname")); //$NON-NLS-1$ setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } private static int getIndex(String context) { if (context.equals("java")) //$NON-NLS-1$ return 0; else if (context.equals("javadoc")) //$NON-NLS-1$ return 1; else return -1; } private void enterEditor(Template template) { if (template == fCurrent) // #4916 return; if (fCurrent != null) // #4358 leaveEditor(); fCurrent= template; fNameText.setText(template.getName()); fDescriptionText.setText(template.getDescription()); fContextCombo.select(getIndex(template.getContext())); fPatternEditor.getDocument().set(template.getPattern()); if (fEditorEnabler != null) { fEditorEnabler.restore(); fEditorEnabler= null; } } private void leaveEditor() { if (fCurrent == null) return; // #4358 fCurrent.setPattern(fPatternEditor.getTextWidget().getText()); fCurrent= null; fNameText.setText(""); //$NON-NLS-1$ fDescriptionText.setText(""); //$NON-NLS-1$ fContextCombo.select(getIndex("")); //$NON-NLS-1$ fPatternEditor.getDocument().set(""); //$NON-NLS-1$ if (fEditorEnabler == null) fEditorEnabler= ControlEnableState.disable(fEditor); } private void add() { Template template= new Template(); template.setContext("java"); //$NON-NLS-1$ TemplateSet.getInstance().add(template); fTableViewer.refresh(); fTableViewer.setChecked(template, template.isEnabled()); enterEditor(template); fNameText.setFocus(); } private void remove() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Iterator elements= selection.iterator(); while (elements.hasNext()) { Template template= (Template) elements.next(); TemplateSet.getInstance().remove(template); } leaveEditor(); fTableViewer.refresh(); } private void enableAll(boolean enable) { Template[] templates= TemplateSet.getInstance().getTemplates(); for (int i= 0; i != templates.length; i++) templates[i].setEnabled(enable); fTableViewer.setAllChecked(enable); } /* * @see IWorkbenchPreferencePage#init(IWorkbench) */ public void init(IWorkbench workbench) {} /* * @see Control#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$ } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES)); TemplateSet.getInstance().restoreDefaults(); fTableViewer.refresh(); } /* * @see PreferencePage#performOk() */ public boolean performOk() { leaveEditor(); // #4358 IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection()); TemplateSet.getInstance().save(); return super.performOk(); } /* * @see PreferencePage#performCancel() */ public boolean performCancel() { TemplateSet.getInstance().reset(); return super.performCancel(); } /** * Initializes the default values of this page in the preference bundle. * Will be called on startup of the JavaPlugin */ public static void initDefaults(IPreferenceStore prefs) { prefs.setDefault(PREF_FORMAT_TEMPLATES, true); } public static boolean useCodeFormatter() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); return prefs.getBoolean(PREF_FORMAT_TEMPLATES); } }
    3,512
    Bug 3512 Reorg confirmation dialog (1G470GF)
    - the title shouldn't be "Save". It should be more specific regarding the current reorg action. - ok should be the default button. NOTES: EG (11/17/00 12:38:48 PM) not critical
    verified fixed
    ead864c
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T08:44:26Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/reorg/MoveAction.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.reorg; import java.lang.reflect.InvocationTargetException; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.refactoring.Assert; import org.eclipse.jdt.internal.core.refactoring.base.IChange; import org.eclipse.jdt.internal.core.refactoring.base.Refactoring; import org.eclipse.jdt.internal.core.refactoring.reorg.MoveRefactoring; import org.eclipse.jdt.internal.core.refactoring.reorg.ReorgRefactoring; import org.eclipse.jdt.internal.core.refactoring.reorg.ReorgUtils; import org.eclipse.jdt.internal.core.refactoring.text.ITextBufferChangeCreator; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.ElementTreeSelectionDialog; import org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation; import org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard; import org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog; import org.eclipse.jdt.internal.ui.refactoring.actions.StructuredSelectionProvider; import org.eclipse.jdt.internal.ui.refactoring.changes.DocumentTextBufferChangeCreator; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.ui.JavaElementContentProvider; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.texteditor.IDocumentProvider; public class MoveAction extends ReorgDestinationAction { private boolean fShowPreview= false; public MoveAction(StructuredSelectionProvider provider) { this(ReorgMessages.getString("moveAction.label"), provider); //$NON-NLS-1$ } public MoveAction(String name, StructuredSelectionProvider provider) { super(name, provider); setDescription(ReorgMessages.getString("moveAction.description")); //$NON-NLS-1$ } /* non java-doc * see @ReorgDestinationAction#isOkToProceed */ String getActionName() { return ReorgMessages.getString("moveAction.name"); //$NON-NLS-1$ } /* non java-doc * see @ReorgDestinationAction#getDestinationDialogMessage */ String getDestinationDialogMessage() { return ReorgMessages.getString("moveAction.destination.label"); //$NON-NLS-1$ } /* non java-doc * see @ReorgDestinationAction#createRefactoring */ ReorgRefactoring createRefactoring(List elements){ IDocumentProvider documentProvider= JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); ITextBufferChangeCreator changeCreator= new DocumentTextBufferChangeCreator(documentProvider); return new MoveRefactoring(elements, changeCreator); } ElementTreeSelectionDialog createDestinationSelectionDialog(Shell parent, ILabelProvider labelProvider, JavaElementContentProvider cp, ReorgRefactoring refactoring){ return new MoveDestinationDialog(parent, labelProvider, cp, (MoveRefactoring)refactoring); } /* non java-doc * see @ReorgDestinationAction#isOkToProceed */ protected boolean isOkToProceed(ReorgRefactoring refactoring) throws JavaModelException{ return (isOkToMoveReadOnly(refactoring)); } /* * @see ReorgDestinationAction#getExcluded(ReorgRefactoring) */ Set getExcluded(ReorgRefactoring refactoring) throws JavaModelException{ Set elements= refactoring.getElementsThatExistInTarget(); Set result= new HashSet(); for (Iterator iter= elements.iterator(); iter.hasNext(); ){ Object o= iter.next(); int action= askIfOverwrite(ReorgUtils.getName(o)); if (action == IDialogConstants.CANCEL_ID) return null; if (action == IDialogConstants.YES_TO_ALL_ID) return new HashSet(0); //nothing excluded if (action == IDialogConstants.NO_ID) result.add(o); } return result; } private static int askIfOverwrite(String elementName){ Shell shell= JavaPlugin.getActiveWorkbenchShell().getShell(); String title= "Resource Exists"; String question= "Element " + elementName + " already exists. Would you like to overwrite?"; String[] labels= new String[] {IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; final MessageDialog dialog = new MessageDialog(shell, title, null, question, MessageDialog.QUESTION, labels, 0); shell.getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); int result = dialog.getReturnCode(); if (result == 0) return IDialogConstants.YES_ID; if (result == 1) return IDialogConstants.YES_TO_ALL_ID; if (result == 2) return IDialogConstants.NO_ID; return IDialogConstants.CANCEL_ID; } protected void setShowPreview(boolean showPreview) { fShowPreview = showPreview; } private static boolean isOkToMoveReadOnly(ReorgRefactoring refactoring){ for (Iterator iter= refactoring.getElementsToReorg().iterator(); iter.hasNext(); ){ Object element= iter.next(); if (ReorgUtils.shouldConfirmReadOnly(element)) { return MessageDialog.openQuestion( JavaPlugin.getActiveWorkbenchShell(), ReorgMessages.getString("moveAction.checkMove"), //$NON-NLS-1$ ReorgMessages.getString("moveAction.error.readOnly")); //$NON-NLS-1$ } } return true; } /* non java-doc * @see ReorgDestinationAction#doReorg(ReorgRefactoring) */ void doReorg(ReorgRefactoring refactoring) throws JavaModelException{ if (!fShowPreview){ super.doReorg(refactoring); return; } new RefactoringWizardDialog(JavaPlugin.getActiveWorkbenchShell(), new MoveWizard((MoveRefactoring)refactoring)).open(); } //--- static inner classes private static class MoveWizard extends RefactoringWizard{ MoveWizard(MoveRefactoring ref){ //XX incorrect help super(ref, "Move", IJavaHelpContextIds.MOVE_CU_ERROR_WIZARD_PAGE); } /* (non-Javadoc) * Method overridden from RefactoringWizard */ public void addPages() { addPreviewPage(); setupPageTitles(); } public void createPageControls(Composite pageContainer) { super.createPageControls(pageContainer); //XX nasty to have to do it here setChange(); } private void setChange(){ IChange change= null; try{ change= computeChange(getRefactoring()); } catch (CoreException e){ JavaPlugin.log(e.getStatus()); return; } if (change == null) return; setChange(change); } private IChange computeChange(Refactoring ref) throws CoreException{ CreateChangeOperation op= new CreateChangeOperation(ref, CreateChangeOperation.CHECK_NONE); try{ new ProgressMonitorDialog(JavaPlugin.getActiveWorkbenchShell()).run(true, true, op); } catch (InvocationTargetException e) { Throwable t= e.getTargetException(); if (t instanceof CoreException) throw (CoreException)t; if (t instanceof Error) throw (Error)t; if (t instanceof RuntimeException) throw (RuntimeException)t; Assert.isTrue(false);//should never get here return null; } catch (InterruptedException e) { //fall thru } return op.getChange(); } } private class MoveDestinationDialog extends ElementTreeSelectionDialog { private static final int PREVIEW_ID= IDialogConstants.CLIENT_ID + 1; private MoveRefactoring fRefactoring; private Button fCheckbox; private Button fPreview; MoveDestinationDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider, MoveRefactoring refactoring){ super(parent, labelProvider, contentProvider); fRefactoring= refactoring; fShowPreview= false;//from outter instance } protected Control createDialogArea(Composite parent) { Composite result= (Composite)super.createDialogArea(parent); fCheckbox= new Button(result, SWT.CHECK); fCheckbox.setText("Update references to the moved element(s)."); fCheckbox.setEnabled(canUpdateReferences()); fCheckbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updatePreviewButton(); fRefactoring.setUpdateReferences(fCheckbox.getEnabled() && fCheckbox.getSelection()); } }); fCheckbox.setSelection(canUpdateReferences()); return result; } protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); fPreview= createButton(parent, PREVIEW_ID, "Preview", false); } protected void updateOKStatus() { super.updateOKStatus(); try{ fRefactoring.setDestination(getFirstResult()); fCheckbox.setEnabled(getOkButton().getEnabled() && canUpdateReferences()); updatePreviewButton(); } catch (JavaModelException e){ ExceptionHandler.handle(e, "Move", "Unexpected exception occurred. See log for details."); } } protected void buttonPressed(int buttonId) { fShowPreview= (buttonId == PREVIEW_ID); super.buttonPressed(buttonId); if (buttonId == PREVIEW_ID) close(); } private void updatePreviewButton(){ fPreview.setEnabled(fCheckbox.getEnabled() && fCheckbox.getSelection()); } private boolean canUpdateReferences(){ try{ return fRefactoring.canUpdateReferences(); } catch (JavaModelException e){ return false; } } } }
    5,062
    Bug 5062 Walkback in Synchronize clicking on 'Two way compare (ignore ancestor)'
    - Load a java project from a repository - Edit several java files in the project, deleting several methods (I am not sure if it is important, but there were methods added as well) - Synchronize - Double-click on the first modified java file so you can see the Structured Compare view - Now click on the 'Two way compare (ignore ancestor)' button - Internal error, Walkbacks in the log (pasted below) I have never clicked on that button before, so I don't even know what it does. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [main does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [runTest does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_checkSubclass does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:713) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.executeI mportOperation(WizardFileSystemResourceImportPage1.java:303) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.importRe sources(WizardFileSystemResourceImportPage1.java:522) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.finish (WizardFileSystemResourceImportPage1.java:343) at org.eclipse.ui.wizards.datatransfer.FileSystemImportWizard.performFinish (FileSystemImportWizard.java:102) at org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java:570) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:311) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:211) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.ui.internal.ImportResourcesAction.run (ImportResourcesAction.java:62) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Wed Oct 17 22:26:00 EDT 2001 1 org.eclipse.core.resources 4 Unhandled exception caught in event loop. Log: Wed Oct 17 22:26:00 EDT 2001 4 org.eclipse.ui 0 Argument not valid java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:1791) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.setIgnoreAncestor (TextMergeViewer.java:1586) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.access$19 (TextMergeViewer.java:1576) at org.eclipse.compare.contentmergeviewer.TextMergeViewer$15.run (TextMergeViewer.java:1481) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306)
    resolved fixed
    180e359
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T09:58:43Z
    2001-10-18T01:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlineErrorTickUpdater.java
    package org.eclipse.jdt.internal.ui.javaeditor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelListener; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jdt.core.IWorkingCopy; import org.eclipse.jdt.ui.JavaElementLabelProvider; /** * The <code>JavaOutlineErrorTickUpdater</code> will register as a AnnotationModelListener on the annotation model * and update all images in the outliner tree when the annotation model changed. */ public class JavaOutlineErrorTickUpdater implements IAnnotationModelListener { private TreeViewer fViewer; private JavaElementLabelProvider fLabelProvider; private IAnnotationModel fAnnotationModel; /** * @param viewer The viewer of the outliner * @param labelProvider The label provider used by the outliner */ public JavaOutlineErrorTickUpdater(TreeViewer viewer, JavaElementLabelProvider labelProvider) { fViewer= viewer; fLabelProvider= labelProvider; } /** * Defines the annotation model to listen to. To be called when the * annotation model changes. * @param model The new annotation model or <code>null</code> * to uninstall. */ public void setAnnotationModel(IAnnotationModel model) { if (fAnnotationModel != null) { fAnnotationModel.removeAnnotationModelListener(this); } if (model != null) { fAnnotationModel= model; fAnnotationModel.addAnnotationModelListener(this); fLabelProvider.setErrorTickManager(new AnnotationErrorTickProvider(fAnnotationModel)); modelChanged(model); } else { fAnnotationModel= null; fLabelProvider.setErrorTickManager(null); } } /** * @see IAnnotationModelListener#modelChanged(IAnnotationModel) */ public void modelChanged(IAnnotationModel model) { Control control= fViewer.getControl(); if (control != null && !control.isDisposed()) { control.getDisplay().asyncExec(new Runnable() { public void run() { // until we have deltas, update all error ticks doUpdateErrorTicks(); } }); } } private void doUpdateErrorTicks() { // do not look at class files if (!(fViewer.getInput() instanceof IWorkingCopy)) { return; } Tree tree= fViewer.getTree(); if (!tree.isDisposed()) { // defensive code TreeItem[] items= fViewer.getTree().getItems(); for (int i= 0; i < items.length; i++) { updateItem(items[i]); } } } private void updateItem(TreeItem item) { Object data= item.getData(); Image old= item.getImage(); Image image= fLabelProvider.getImage(data); if (image != null && image != old) { item.setImage(image); } TreeItem[] children= item.getItems(); for (int i= 0; i < children.length; i++) { updateItem(children[i]); } } }
    5,062
    Bug 5062 Walkback in Synchronize clicking on 'Two way compare (ignore ancestor)'
    - Load a java project from a repository - Edit several java files in the project, deleting several methods (I am not sure if it is important, but there were methods added as well) - Synchronize - Double-click on the first modified java file so you can see the Structured Compare view - Now click on the 'Two way compare (ignore ancestor)' button - Internal error, Walkbacks in the log (pasted below) I have never clicked on that button before, so I don't even know what it does. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [main does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [runTest does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_checkSubclass does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:713) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.executeI mportOperation(WizardFileSystemResourceImportPage1.java:303) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.importRe sources(WizardFileSystemResourceImportPage1.java:522) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.finish (WizardFileSystemResourceImportPage1.java:343) at org.eclipse.ui.wizards.datatransfer.FileSystemImportWizard.performFinish (FileSystemImportWizard.java:102) at org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java:570) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:311) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:211) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.ui.internal.ImportResourcesAction.run (ImportResourcesAction.java:62) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Wed Oct 17 22:26:00 EDT 2001 1 org.eclipse.core.resources 4 Unhandled exception caught in event loop. Log: Wed Oct 17 22:26:00 EDT 2001 4 org.eclipse.ui 0 Argument not valid java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:1791) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.setIgnoreAncestor (TextMergeViewer.java:1586) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.access$19 (TextMergeViewer.java:1576) at org.eclipse.compare.contentmergeviewer.TextMergeViewer$15.run (TextMergeViewer.java:1481) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306)
    resolved fixed
    180e359
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T09:58:43Z
    2001-10-18T01:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
    package org.eclipse.jdt.internal.ui.javaeditor; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Widget; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.Assert; import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.part.Page; import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IElementChangedListener; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.actions.GenerateGroup; import org.eclipse.jdt.internal.ui.actions.OpenHierarchyPerspectiveItem; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup; import org.eclipse.jdt.internal.ui.reorg.ReorgGroup; import org.eclipse.jdt.internal.ui.search.JavaSearchGroup; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementSorter; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; /** * The content outline page of the Java editor. The viewer implements a proprietary * update mechanism based on Java model deltas. It does not react on domain changes. * It is specified to show the content of ICompilationUnits and IClassFiles. */ class JavaOutlinePage extends Page implements IContentOutlinePage { /** * The element change listener of the java outline viewer. * @see IElementChangedListener */ class ElementChangedListener implements IElementChangedListener { public void elementChanged(final ElementChangedEvent e) { Display d= getControl().getDisplay(); if (d != null) { d.asyncExec(new Runnable() { public void run() { IJavaElementDelta delta= findElement( (ICompilationUnit) fInput, e.getDelta()); if (delta != null && fOutlineViewer != null) { fOutlineViewer.reconcile(delta); } } }); } } protected IJavaElementDelta findElement(ICompilationUnit unit, IJavaElementDelta delta) { if (delta == null || unit == null) return null; IJavaElement element= delta.getElement(); if (unit.equals(element)) return delta; if (element.getElementType() > IJavaElement.CLASS_FILE) return null; IJavaElementDelta[] children= delta.getAffectedChildren(); if (children == null || children.length == 0) return null; for (int i= 0; i < children.length; i++) { IJavaElementDelta d= findElement(unit, children[i]); if (d != null) return d; } return null; } }; /** * Content provider for the children of an ICompilationUnit or * an IClassFile * @see ITreeContentProvider */ class ChildrenProvider implements ITreeContentProvider { protected ElementChangedListener fListener; protected boolean matches(IJavaElement element) { if (element.getElementType() == IJavaElement.METHOD) { String name= element.getElementName(); return (name != null && name.indexOf('<') >= 0); } return false; } protected IJavaElement[] filter(IJavaElement[] children) { boolean initializers= false; for (int i= 0; i < children.length; i++) { if (matches(children[i])) { initializers= true; break; } } if (!initializers) return children; Vector v= new Vector(); for (int i= 0; i < children.length; i++) { if (matches(children[i])) continue; v.addElement(children[i]); } IJavaElement[] result= new IJavaElement[v.size()]; v.copyInto(result); return result; } public Object[] getChildren(Object parent) { if (parent instanceof IParent) { IParent c= (IParent) parent; try { return filter(c.getChildren()); } catch (JavaModelException x) { JavaPlugin.getDefault().logErrorStatus(JavaEditorMessages.getString("JavaOutlinePage.error.ChildrenProvider.getChildren.message1"), x.getStatus()); //$NON-NLS-1$ } } return new Object[0]; } public Object[] getElements(Object parent) { return getChildren(parent); } public Object getParent(Object child) { if (child instanceof IJavaElement) { IJavaElement e= (IJavaElement) child; return e.getParent(); } return null; } public boolean hasChildren(Object parent) { if (parent instanceof IParent) { IParent c= (IParent) parent; try { IJavaElement[] children= filter(c.getChildren()); return (children != null && children.length > 0); } catch (JavaModelException x) { JavaPlugin.getDefault().logErrorStatus(JavaEditorMessages.getString("JavaOutlinePage.error.ChildrenProvider.hasChildren.message1"), x.getStatus()); //$NON-NLS-1$ } } return false; } public boolean isDeleted(Object o) { return false; } public void dispose() { if (fListener != null) { JavaCore.removeElementChangedListener(fListener); fListener= null; } } /** * @see IContentProvider#inputChanged(Viewer, Object, Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { boolean remove= (oldInput instanceof ICompilationUnit && fListener != null); boolean add= (newInput instanceof ICompilationUnit); if (remove && add) return; if (remove) { JavaCore.removeElementChangedListener(fListener); fListener= null; } if (add) { if (fListener == null) fListener= new ElementChangedListener(); JavaCore.addElementChangedListener(fListener); } } }; class JavaOutlineViewer extends TreeViewer { /** * Indicates an item which has been reused. At the point of * its reuse it has been expanded. This field is used to * communicate between <code>internalExpandToLevel</code> and * <code>reuseTreeItem</code>. */ private Item fReusedExpandedItem; public JavaOutlineViewer(Tree tree) { super(tree); setAutoExpandLevel(ALL_LEVELS); } /** * Investigates the given element change event and if affected incrementally * updates the outline. */ public void reconcile(IJavaElementDelta delta) { if (getSorter() == null) { Widget w= findItem(fInput); if (w != null) update(w, delta); } else { // just for now refresh(); } } /** * @see TreeViewer#internalExpandToLevel */ protected void internalExpandToLevel(Widget node, int level) { if (node instanceof Item) { Item i= (Item) node; if (i.getData() instanceof IJavaElement) { IJavaElement je= (IJavaElement) i.getData(); if (je.getElementType() == IJavaElement.IMPORT_CONTAINER || isInnerType(je)) { if (i != fReusedExpandedItem) { setExpanded(i, false); return; } } } } super.internalExpandToLevel(node, level); } protected void reuseTreeItem(Item item, Object element) { // remove children Item[] c= getChildren(item); if (c != null && c.length > 0) { if (getExpanded(item)) fReusedExpandedItem= item; for (int k= 0; k < c.length; k++) { if (c[k].getData() != null) disassociate(c[k]); c[k].dispose(); } } updateItem(item, element); updatePlus(item, element); internalExpandToLevel(item, ALL_LEVELS); fReusedExpandedItem= null; } /** * @see TreeViewer#createTreeItem */ protected void createTreeItem(Widget parent, Object element, int ix) { Item[] children= getChildren(parent); boolean expand= (parent instanceof Item && (children == null || children.length == 0)); Item item= newItem(parent, SWT.NULL, ix); updateItem(item, element); updatePlus(item, element); if (expand) setExpanded((Item) parent, true); internalExpandToLevel(item, ALL_LEVELS); } protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) { if (element instanceof IMethod) { if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) { try { return JavaModelUtil.isMainMethod((IMethod)element); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } } return "main".equals(element.getElementName()); //$NON-NLS-1$ } return false; } protected void update(Widget w, IJavaElementDelta delta) { Item item; Object element; IJavaElement parent= delta.getElement(); IJavaElementDelta[] affected= delta.getAffectedChildren(); Item[] children= getChildren(w); boolean doUpdateParent= false; Vector deletions= new Vector(); Vector additions= new Vector(); go1: for (int i= 0; i < children.length; i++) { item= children[i]; element= item.getData(); for (int j= 0; j < affected.length; j++) { IJavaElement affectedElement= affected[j].getElement(); int status= affected[j].getKind(); if (affectedElement.equals(element)) { // removed if ((status & IJavaElementDelta.REMOVED) != 0) { deletions.addElement(item); doUpdateParent= doUpdateParent || mustUpdateParent(affected[j], affectedElement); continue go1; } // changed if ((status & IJavaElementDelta.CHANGED) != 0) { int change= affected[j].getFlags(); doUpdateParent= doUpdateParent || mustUpdateParent(affected[j], affectedElement); if ((change & IJavaElementDelta.F_MODIFIERS) != 0) { if (filtered(parent, affectedElement)) deletions.addElement(item); else updateItem(item, affectedElement); } if ((change & IJavaElementDelta.F_CONTENT) != 0) updateItem(item, affectedElement); if ((change & IJavaElementDelta.F_CHILDREN) != 0) update(item, affected[j]); continue go1; } } else { // changed if ((status & IJavaElementDelta.CHANGED) != 0 && (affected[j].getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 && !filtered(parent, affectedElement)) additions.addElement(affected[j]); } } } // find all elements to add IJavaElementDelta[] add= delta.getAddedChildren(); if (additions.size() > 0) { IJavaElementDelta[] tmp= new IJavaElementDelta[add.length + additions.size()]; System.arraycopy(add, 0, tmp, 0, add.length); for (int i= 0; i < additions.size(); i++) tmp[i + add.length]= (IJavaElementDelta) additions.elementAt(i); add= tmp; } // add at the right position go2: for (int i= 0; i < add.length; i++) { try { IJavaElement e= add[i].getElement(); if (filtered(parent, e)) continue go2; ISourceReference r= (ISourceReference) e ; doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e); ISourceRange rng= r.getSourceRange(); int start= rng.getOffset(); int end= start + rng.getLength() - 1; Item last= null; item= null; children= getChildren(w); for (int j= 0; j < children.length; j++) { item= children[j]; r= (ISourceReference) item.getData(); if (r == null) { // parent node collapsed and not be opened before -> do nothing continue go2; } try { if (overlaps(r, start, end)) { // be tolerant if the delta is not correct, or if // the tree has been updated other than by a delta reuseTreeItem(item, (Object) add[i].getElement()); continue go2; } else if (r.getSourceRange().getOffset() > start) { if (last != null && deletions.contains(last)) { // reuse item deletions.removeElement(last); reuseTreeItem(last, (Object) add[i].getElement()); } else { // nothing to reuse createTreeItem(w, (Object) add[i].getElement(), j); } continue go2; } } catch (JavaModelException x) { // stumbled over deleted element } last= item; } // add at the end of the list if (last != null && deletions.contains(last)) { // reuse item deletions.removeElement(last); reuseTreeItem(last, (Object) add[i].getElement()); } else { // nothing to reuse createTreeItem(w, (Object) add[i].getElement(), -1); } } catch (JavaModelException x) { // the element to be added is not present -> don't add it } } // remove items which haven't been reused Enumeration e= deletions.elements(); while (e.hasMoreElements()) { item= (Item) e.nextElement(); disassociate(item); item.dispose(); } if (doUpdateParent) updateItem(w, delta.getElement()); } protected boolean overlaps(ISourceReference reference, int start, int end) { try { ISourceRange rng= reference.getSourceRange(); return start <= (rng.getOffset() + rng.getLength() - 1) && rng.getOffset() <= end; } catch (JavaModelException x) { return false; } } protected boolean filtered(IJavaElement parent, IJavaElement child) { Object[] result= new Object[] { child }; ViewerFilter[] filters= getFilters(); for (int i= 0; i < filters.length; i++) { result= filters[i].filter(this, parent, result); if (result.length == 0) return true; } return false; } }; class LexicalSortingAction extends Action { private JavaElementSorter fSorter= new JavaElementSorter(); public LexicalSortingAction() { super(); setText(JavaEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$ boolean checked= JavaPlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$ valueChanged(checked, false); } public void run() { valueChanged(isChecked(), true); } private void valueChanged(boolean on, boolean store) { setChecked(on); fOutlineViewer.setSorter(on ? fSorter : null); setToolTipText(on ? JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip.checked") : JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip.unchecked")); //$NON-NLS-2$ //$NON-NLS-1$ setDescription(on ? JavaEditorMessages.getString("JavaOutlinePage.Sort.description.checked") : JavaEditorMessages.getString("JavaOutlinePage.Sort.description.unchecked")); //$NON-NLS-2$ //$NON-NLS-1$ if (store) JavaPlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$ } }; class FieldFilter extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, Object element) { return !(element instanceof IField); } }; class VisibilityFilter extends ViewerFilter { public final static int PUBLIC= 0; public final static int PROTECTED= 1; public final static int PRIVATE= 2; public final static int DEFAULT= 3; public final static int NOT_STATIC= 4; private int fVisibility; public VisibilityFilter(int visibility) { fVisibility= visibility; } /* * 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces. */ private boolean belongsToInterface(IMember member) { IType type= member.getDeclaringType(); if (type != null) { try { return type.isInterface(); } catch (JavaModelException x) { // ignore } } return false; } public boolean select(Viewer viewer, Object parentElement, Object element) { if ( !(element instanceof IMember)) return true; if (element instanceof IType) { IType type= (IType) element; IJavaElement parent= type.getParent(); if (parent == null) return true; int elementType= parent.getElementType(); if (elementType == IJavaElement.COMPILATION_UNIT || elementType == IJavaElement.CLASS_FILE) return true; } IMember member= (IMember) element; try { int flags= member.getFlags(); switch (fVisibility) { case PUBLIC: /* 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces */ return Flags.isPublic(flags) || belongsToInterface(member); case PROTECTED: return Flags.isProtected(flags); case PRIVATE: return Flags.isPrivate(flags); case DEFAULT: { /* 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces */ boolean dflt= !(Flags.isPublic(flags) || Flags.isProtected(flags) || Flags.isPrivate(flags)); return dflt ? !belongsToInterface(member) : dflt; } case NOT_STATIC: return !Flags.isStatic(flags); } } catch (JavaModelException x) { } // unreachable return false; } }; class FilterAction extends Action { private ViewerFilter fFilter; private String fCheckedDesc; private String fUncheckedDesc; private String fCheckedTooltip; private String fUncheckedTooltip; private String fPreferenceKey; public FilterAction(ViewerFilter filter, String label, String checkedDesc, String uncheckedDesc, String checkedTooltip, String uncheckedTooltip, String prefKey) { super(); fFilter= filter; setText(label); fCheckedDesc= checkedDesc; fUncheckedDesc= uncheckedDesc; fCheckedTooltip= checkedTooltip; fUncheckedTooltip= uncheckedTooltip; fPreferenceKey= prefKey; boolean checked= JavaPlugin.getDefault().getPreferenceStore().getBoolean(fPreferenceKey); valueChanged(checked, false); } public void run() { valueChanged(isChecked(), true); } private void valueChanged(boolean on, boolean store) { setChecked(on); if (on) { fOutlineViewer.addFilter(fFilter); setToolTipText(fCheckedTooltip); setDescription(fCheckedDesc); } else { fOutlineViewer.removeFilter(fFilter); setToolTipText(fUncheckedTooltip); setDescription(fUncheckedDesc); } if (store) JavaPlugin.getDefault().getPreferenceStore().setValue(fPreferenceKey, on); } }; private IJavaElement fInput; private String fContextMenuID; private Menu fMenu; private JavaOutlineViewer fOutlineViewer; private JavaEditor fEditor; private ListenerList fSelectionChangedListeners= new ListenerList(); private Hashtable fActions= new Hashtable(); private ContextMenuGroup[] fActionGroups; private JavaOutlineErrorTickUpdater fErrorTickUpdater; public JavaOutlinePage(String contextMenuID, JavaEditor editor) { super(); Assert.isNotNull(editor); fContextMenuID= contextMenuID; fEditor= editor; } private void fireSelectionChanged(ISelection selection) { SelectionChangedEvent event= new SelectionChangedEvent(this, selection); Object[] listeners= fSelectionChangedListeners.getListeners(); for (int i= 0; i < listeners.length; ++i) ((ISelectionChangedListener) listeners[i]).selectionChanged(event); } /** * @see IPage#createControl */ public void createControl(Composite parent) { Tree tree= new Tree(parent, SWT.MULTI); JavaElementLabelProvider lprovider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_TYPE); fOutlineViewer= new JavaOutlineViewer(tree); fOutlineViewer.setContentProvider(new ChildrenProvider()); fOutlineViewer.setLabelProvider(lprovider); fErrorTickUpdater= new JavaOutlineErrorTickUpdater(fOutlineViewer, lprovider); fErrorTickUpdater.setAnnotationModel(fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput())); MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { contextMenuAboutToShow(manager); } }); fMenu= manager.createContextMenu(tree); tree.setMenu(fMenu); fActionGroups= new ContextMenuGroup[] { new GenerateGroup(), new JavaSearchGroup(), new ReorgGroup() }; fOutlineViewer.setInput(fInput); fOutlineViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { fireSelectionChanged(e.getSelection()); } }); fOutlineViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleKeyPressed(e); } }); } public void dispose() { if (fEditor == null) return; if (fErrorTickUpdater != null) fErrorTickUpdater.setAnnotationModel(null); fEditor.outlinePageClosed(); fEditor= null; Object[] listeners= fSelectionChangedListeners.getListeners(); for (int i= 0; i < listeners.length; i++) fSelectionChangedListeners.remove(listeners[i]); fSelectionChangedListeners= null; if (fMenu != null && !fMenu.isDisposed()) { fMenu.dispose(); fMenu= null; } super.dispose(); } public Control getControl() { if (fOutlineViewer != null) return fOutlineViewer.getControl(); return null; } public void setInput(IJavaElement inputElement) { fInput= inputElement; if (fOutlineViewer != null) fOutlineViewer.setInput(fInput); if (fErrorTickUpdater != null) fErrorTickUpdater.setAnnotationModel(fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput())); } public void select(ISourceReference reference) { if (fOutlineViewer != null) { ISelection s= StructuredSelection.EMPTY; if (reference != null) s= new StructuredSelection(reference); fOutlineViewer.setSelection(s, true); } } public void setAction(String actionID, IAction action) { Assert.isNotNull(actionID); if (action == null) fActions.remove(actionID); else fActions.put(actionID, action); } public IAction getAction(String actionID) { Assert.isNotNull(actionID); return (IAction) fActions.get(actionID); } /** * Convenience method to add the action installed under the given actionID to the * specified group of the menu. */ protected void addAction(IMenuManager menu, String group, String actionID) { IAction action= getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); if (action.isEnabled()) { IMenuManager subMenu= menu.findMenuUsingPath(group); if (subMenu != null) subMenu.add(action); else menu.appendToGroup(group, action); } } } private void addRefactoring(IMenuManager menu){ MenuManager refactoring= new MenuManager(JavaEditorMessages.getString("JavaOutlinePage.ContextMenu.refactoring.label")); //$NON-NLS-1$ ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, fOutlineViewer); if (!refactoring.isEmpty()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring); } private void addOpenPerspectiveItem(IMenuManager menu) { ISelection s= getSelection(); if (s.isEmpty() || ! (s instanceof IStructuredSelection)) return; IStructuredSelection selection= (IStructuredSelection)s; if (selection.size() != 1) return; Object element= selection.getFirstElement(); if (!(element instanceof IType)) return; IType[] input= {(IType)element}; // XXX should get the workbench window form the PartSite IWorkbenchWindow w= JavaPlugin.getActiveWorkbenchWindow(); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new OpenHierarchyPerspectiveItem(w, input)); } protected void contextMenuAboutToShow(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (OrganizeImportsAction.canActionBeAdded(getSelection())) { addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "OrganizeImports"); //$NON-NLS-1$ } addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenImportDeclaration"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_SHOW, "ShowInPackageView"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "DeleteElement"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "ReplaceWithEdition"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "AddEdition"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "AddMethodEntryBreakpoint"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "AddWatchpoint"); //$NON_NLS-1$ ContextMenuGroup.add(menu, fActionGroups, fOutlineViewer); addRefactoring(menu); addOpenPerspectiveItem(menu); } /** * @see Page#setFocus() */ public void setFocus() { if (fOutlineViewer != null) fOutlineViewer.getControl().setFocus(); } /** * @see Page#makeContributions(IMenuManager, IToolBarManager, IStatusLineManager) */ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { if (statusLineManager != null) { StatusBarUpdater updater= new StatusBarUpdater(statusLineManager); addSelectionChangedListener(updater); } Action action= new LexicalSortingAction(); toolBarManager.add(action); action= new FilterAction(new FieldFilter(), JavaEditorMessages.getString("JavaOutlinePage.HideFields.label"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.tooltip.unchecked"), "HideFields.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "fields_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); action= new FilterAction(new VisibilityFilter(VisibilityFilter.NOT_STATIC), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.label"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.tooltip.unchecked"), "HideStaticMembers.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "static_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); action= new FilterAction(new VisibilityFilter(VisibilityFilter.PUBLIC), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.label"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.tooltip.unchecked"), "HideNonePublicMembers.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "public_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); } /** * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) */ public void addSelectionChangedListener(ISelectionChangedListener listener) { fSelectionChangedListeners.add(listener); } /** * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) */ public void removeSelectionChangedListener(ISelectionChangedListener listener) { fSelectionChangedListeners.remove(listener); } /** * @see ISelectionProvider#getSelection() */ public ISelection getSelection() { if (fOutlineViewer == null) return StructuredSelection.EMPTY; return fOutlineViewer.getSelection(); } /** * @see ISelectionProvider#setSelection(ISelection) */ public void setSelection(ISelection selection) { if (fOutlineViewer != null) fOutlineViewer.setSelection(selection); } /** * Checkes whether a given Java element is an inner type. */ private boolean isInnerType(IJavaElement element) { if (element.getElementType() == IJavaElement.TYPE) { IJavaElement parent= element.getParent(); int type= parent.getElementType(); return (type != IJavaElement.COMPILATION_UNIT && type != IJavaElement.CLASS_FILE); } return false; } /** * Handles key events in viewer. */ private void handleKeyPressed(KeyEvent event) { if (event.stateMask != 0) return; IAction action= null; if (event.character == SWT.DEL) action= getAction("DeleteElement"); //$NON-NLS-1$ else if (event.keyCode == SWT.F4) { // Special case since Open Type Hierarchy is no action. OpenTypeHierarchyUtil.open(getSelection(), fEditor.getSite().getWorkbenchWindow()); } if (action != null && action.isEnabled()) action.run(); } }
    5,062
    Bug 5062 Walkback in Synchronize clicking on 'Two way compare (ignore ancestor)'
    - Load a java project from a repository - Edit several java files in the project, deleting several methods (I am not sure if it is important, but there were methods added as well) - Synchronize - Double-click on the first modified java file so you can see the Structured Compare view - Now click on the 'Two way compare (ignore ancestor)' button - Internal error, Walkbacks in the log (pasted below) I have never clicked on that button before, so I don't even know what it does. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [main does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 main does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [runTest does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 runTest does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_checkSubclass does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_checkSubclass does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:10 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetI does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 19:57:11 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java:83) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java:117) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java:91) at org.eclipse.jdt.ui.JavaElementLabelProvider.getImage (JavaElementLabelProvider.java:159) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:91) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java:97) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java:133) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.vcm.internal.ui.ResourceLoader.loadResources (ResourceLoader.java:320) at org.eclipse.vcm.internal.ui.actions.ReplaceWithAction.run (ReplaceWithAction.java:75) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 test_ConstructorLorg_eclipse_swt_widgets_WidgetII does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.core 969 suite does not exist. Log: Tue Oct 16 23:14:15 EDT 2001 4 org.eclipse.jdt.ui 1 Internal Error Java Model Exception: Java Model Status [suite does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:442) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:471) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java(Compiled Code)) at org.eclipse.jdt.internal.core.Member.getFlags(Member.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.computeBaseImageD escriptor(JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.viewsupport.JavaImageLabelProvider.getLabelImage (JavaImageLabelProvider.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.updateItem (JavaOutlineErrorTickUpdater.java(Compiled Code)) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.doUpdateError Ticks(JavaOutlineErrorTickUpdater.java:83) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater.access$0 (JavaOutlineErrorTickUpdater.java:73) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlineErrorTickUpdater$1.run (JavaOutlineErrorTickUpdater.java:67) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:713) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.executeI mportOperation(WizardFileSystemResourceImportPage1.java:303) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.importRe sources(WizardFileSystemResourceImportPage1.java:522) at org.eclipse.ui.wizards.datatransfer.WizardFileSystemResourceImportPage1.finish (WizardFileSystemResourceImportPage1.java:343) at org.eclipse.ui.wizards.datatransfer.FileSystemImportWizard.performFinish (FileSystemImportWizard.java:102) at org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java:570) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:311) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:211) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.ui.internal.ImportResourcesAction.run (ImportResourcesAction.java:62) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) 4 org.eclipse.jdt.core 969 suite does not exist. Log: Wed Oct 17 22:26:00 EDT 2001 1 org.eclipse.core.resources 4 Unhandled exception caught in event loop. Log: Wed Oct 17 22:26:00 EDT 2001 4 org.eclipse.ui 0 Argument not valid java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:1791) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.swt.custom.StyledText.setLineBackground(StyledText.java (Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.doDiff (TextMergeViewer.java(Compiled Code)) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.setIgnoreAncestor (TextMergeViewer.java:1586) at org.eclipse.compare.contentmergeviewer.TextMergeViewer.access$19 (TextMergeViewer.java:1576) at org.eclipse.compare.contentmergeviewer.TextMergeViewer$15.run (TextMergeViewer.java:1481) at org.eclipse.jface.action.Action.runWithEvent(Action.java:451) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306)
    resolved fixed
    180e359
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T09:58:43Z
    2001-10-18T01:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/ProblemItemMapper.java
    package org.eclipse.jdt.internal.ui.viewsupport; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Item; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IOpenable; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * Helper class for updating error markers. * Items are mapped to paths of their underlying resources. * Method <code>problemsChanged</code> updates all items that are affected from the changed * elements. */ public class ProblemItemMapper { // map from path to item private HashMap fPathToItem; public ProblemItemMapper() { fPathToItem= new HashMap(); } /** * Updates the icons of all mapped elements containing to the changed elements. * Must be called from the UI thread. */ public void problemsChanged(Collection changedPaths, ILabelProvider lprovider) { // iterate over the smaller set/map if (changedPaths.size() <= fPathToItem.size()) { iterateChanges(changedPaths, lprovider); } else { iterateItems(changedPaths, lprovider); } } private void iterateChanges(Collection changedPaths, ILabelProvider lprovider) { Iterator elements= changedPaths.iterator(); while (elements.hasNext()) { IPath curr= (IPath) elements.next(); Object obj= fPathToItem.get(curr); if (obj == null) { // not mapped } else if (obj instanceof Item) { refreshIcon(lprovider, (Item)obj); } else { // List of Items List list= (List) obj; for (int i= 0; i < list.size(); i++) { refreshIcon(lprovider, (Item) list.get(i)); } } } } private void iterateItems(Collection changedPaths, ILabelProvider lprovider) { Iterator keys= fPathToItem.keySet().iterator(); while (keys.hasNext()) { IPath curr= (IPath) keys.next(); if (changedPaths.contains(curr)) { Object obj= fPathToItem.get(curr); if (obj instanceof Item) { refreshIcon(lprovider, (Item)obj); } else { // List of Items List list= (List) obj; for (int i= 0; i < list.size(); i++) { refreshIcon(lprovider, (Item) list.get(i)); } } } } } private void refreshIcon(ILabelProvider lprovider, Item item) { if (!item.isDisposed()) { // defensive code Object data= item.getData(); Image old= item.getImage(); Image image= lprovider.getImage(data); if (image != null && image != old) { item.setImage(image); } } } /** * Adds a new item to the map. * @param element Element to map * @param item The item used for the element */ public void addToMap(Object element, Item item) { IPath path= getCorrespondingPath(element); if (path != null) { Object existingMapping= fPathToItem.get(path); if (existingMapping == null) { fPathToItem.put(path, item); } else if (existingMapping instanceof Item) { if (existingMapping != item) { ArrayList list= new ArrayList(2); list.add(existingMapping); list.add(item); fPathToItem.put(path, list); } } else { // List List list= (List)existingMapping; if (!list.contains(item)) { list.add(item); } // leave the list for reuse } } } /** * Removes an element from the map. */ public void removeFromMap(Object element, Item item) { IPath path= getCorrespondingPath(element); if (path != null) { Object existingMapping= fPathToItem.get(path); if (existingMapping == null) { return; } else if (existingMapping instanceof Item) { fPathToItem.remove(path); } else { // List List list= (List) existingMapping; list.remove(item); } } } /** * Clears the map. */ public void clearMap() { fPathToItem.clear(); } /** * Method that decides which elements can have error markers * Returns null if an element can not have error markers. */ private static IPath getCorrespondingPath(Object element) { if (element instanceof IJavaElement) { return getJavaElementPath((IJavaElement)element); } return null; } /** * Gets the path of the underlying resource without throwing * a JavaModelException if the resource does not exist. */ private static IPath getJavaElementPath(IJavaElement elem) { switch (elem.getElementType()) { case IJavaElement.JAVA_MODEL: return null; case IJavaElement.JAVA_PROJECT: return ((IJavaProject)elem).getProject().getFullPath(); case IJavaElement.PACKAGE_FRAGMENT_ROOT: IPackageFragmentRoot root= (IPackageFragmentRoot)elem; if (!root.isArchive()) { return root.getPath(); } return null; case IJavaElement.PACKAGE_FRAGMENT: String packName= elem.getElementName(); IPath rootPath= getCorrespondingPath(elem.getParent()); if (rootPath != null && packName.length() > 0) { rootPath= rootPath.append(packName.replace('.', '/')); } return rootPath; case IJavaElement.CLASS_FILE: case IJavaElement.COMPILATION_UNIT: IPath packPath= getCorrespondingPath(elem.getParent()); if (packPath != null) { packPath= packPath.append(elem.getElementName()); } return packPath; default: IOpenable openable= JavaModelUtil.getOpenable(elem); if (openable instanceof IJavaElement) { return getCorrespondingPath((IJavaElement)openable); } return null; } } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.template.TemplateEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; /** * Java completion processor. */ public class JavaCompletionProcessor implements IContentAssistProcessor { private IEditorPart fEditor; private ResultCollector fCollector; private IWorkingCopyManager fManager; private IContextInformationValidator fValidator; private TemplateEngine fTemplateEngine; public JavaCompletionProcessor(IEditorPart editor) { fEditor= editor; fCollector= new ResultCollector(); fManager= JavaPlugin.getDefault().getWorkingCopyManager(); fTemplateEngine= new TemplateEngine(TemplateEngine.JAVA); //$NON-NLS-1$ } /** * @see IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { return fCollector.getErrorMessage(); } /** * @see IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { if (fValidator == null) fValidator= new JavaParameterListValidator(); return fValidator; } /** * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return new char[] { '.', '(' }; } /** * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { return null; } /** * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); IDocument document= viewer.getDocument(); try { if (unit != null) { fCollector.reset(unit.getJavaProject(), unit); Point selection= viewer.getSelectedRange(); if (selection.y > 0) fCollector.setRegionToReplace(selection.x, selection.y); unit.codeComplete(offset, fCollector); } } catch (JavaModelException x) { Shell shell= viewer.getTextWidget().getShell(); ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$ } ICompletionProposal[] results= fCollector.getResults(); try { if (unit != null) { fTemplateEngine.reset(); fTemplateEngine.complete(unit, offset); } } catch (JavaModelException x) { Shell shell= viewer.getTextWidget().getShell(); ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$ } ICompletionProposal[] exactTemplateResults= fTemplateEngine.getExactResults(); ICompletionProposal[] notExactTemplateResults= fTemplateEngine.getNotExactResults(); // concatenate arrays ICompletionProposal[] total= new ICompletionProposal[results.length + exactTemplateResults.length + notExactTemplateResults.length]; System.arraycopy(exactTemplateResults, 0, total, 0, exactTemplateResults.length); System.arraycopy(results, 0, total, exactTemplateResults.length, results.length); System.arraycopy(notExactTemplateResults, 0, total, exactTemplateResults.length + results.length, notExactTemplateResults.length); return total; } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocCompletionProcessor.java
    package org.eclipse.jdt.internal.ui.text.javadoc; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.template.TemplateEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; /** * Simple Java doc completion processor. */ public class JavaDocCompletionProcessor implements IContentAssistProcessor { private IEditorPart fEditor; private IWorkingCopyManager fManager; private TemplateEngine fTemplateEngine; public JavaDocCompletionProcessor(IEditorPart editor) { fEditor= editor; fManager= JavaPlugin.getDefault().getWorkingCopyManager(); fTemplateEngine= new TemplateEngine(TemplateEngine.JAVADOC); //$NON-NLS-1$ } /** * @see IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { return null; } /** * @see IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { return null; } /** * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { return null; } /** * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); IDocument document= viewer.getDocument(); ICompletionProposal[] results= new ICompletionProposal[0]; try { if (unit != null) { int offset= documentOffset; int length= 0; Point selection= viewer.getSelectedRange(); if (selection.y > 0) { offset= selection.x; length= selection.y; } CompletionEvaluator evaluator= new CompletionEvaluator(unit, document, offset, length); results= evaluator.computeProposals(); } } catch (JavaModelException x) { } try { if (unit != null) { fTemplateEngine.reset(); fTemplateEngine.complete(unit, documentOffset); } } catch (JavaModelException x) { } ICompletionProposal[] exactTemplateResults= fTemplateEngine.getExactResults(); ICompletionProposal[] notExactTemplateResults= fTemplateEngine.getNotExactResults(); // concatenate arrays ICompletionProposal[] total= new ICompletionProposal[results.length + exactTemplateResults.length + notExactTemplateResults.length]; System.arraycopy(exactTemplateResults, 0, total, 0, exactTemplateResults.length); System.arraycopy(results, 0, total, exactTemplateResults.length, results.length); System.arraycopy(notExactTemplateResults, 0, total, exactTemplateResults.length + results.length, notExactTemplateResults.length); return total; } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/ArgumentEvaluator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.text.NumberFormat; public class ArgumentEvaluator implements VariableEvaluator { private final String[] fArguments; /** * Creates an argument evaluator with template arguments. */ public ArgumentEvaluator(String[] arguments) { fArguments= arguments; } /* * @see VariableEvaluator#evaluate(String, int) */ public String evaluate(String variable, int offset) { if (fArguments == null) return null; try { int i= Integer.parseInt(variable); if ((i < 0) || (i >= fArguments.length)) return null; return new String(fArguments[i]); } catch (NumberFormatException e) { return null; } } /* * @see VariableEvaluator#getRecognizedVariables() */ public String[] getRecognizedVariables() { return new String[] {"0", "1"}; // $NON-NLS-1$ // XXX incomplete } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/CodeIndentator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.internal.core.refactoring.TextUtilities; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultLineTracker; import org.eclipse.jface.text.GapTextStore; import org.eclipse.jface.text.ILineTracker; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextStore; /** * The code indentator indentates a text block by a given indentation level. * The interface is similar to <code>CodeFormatter</code>. */ public class CodeIndentator { private int fIndentationLevel= 0; private int[] fPositions; /** * Sets the indentation level. */ public void setIndentationLevel(int indentationLevel) { fIndentationLevel= indentationLevel; } /** * Sets the positions to map. */ public void setPositionsToMap(int[] positions) { fPositions= positions; } /** * Returns the mapped positions. Should be called after an indentation operation. */ public int[] getMappedPositions() { return fPositions; } /** * Indentates a string. */ public String indentate(String string) { StringBuffer buffer = new StringBuffer(string.length()); String indentation= TextUtilities.createIndentString(fIndentationLevel); String[] lines= splitIntoLines(string); int position= 0; for (int i= 0; i != lines.length; i++) { buffer.append(indentation); buffer.append(lines[i]); if (fPositions != null) { for (int j= 0; j != fPositions.length; j++) if (fPositions[j] >= position) fPositions[j] += indentation.length(); } position += lines[i].length(); } return buffer.toString(); } private static String[] splitIntoLines(String text) { try { ITextStore store= new GapTextStore(0, 1); store.set(text); ILineTracker tracker= new DefaultLineTracker(); tracker.set(text); int size= tracker.getNumberOfLines(); String result[]= new String[size]; for (int i= 0; i < size; i++) { String lineDelimiter= null; try { lineDelimiter= tracker.getLineDelimiter(i); } catch (BadLocationException e) {} IRegion region= tracker.getLineInformation(i); if (lineDelimiter == null) { result[i]= store.get(region.getOffset(), region.getLength()); } else { result[i]= store.get(region.getOffset(), region.getLength()) + lineDelimiter; } } return result; } catch (BadLocationException e) { return null; } } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/CursorSelectionEvaluator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; public class CursorSelectionEvaluator implements VariableEvaluator { private static final String CURSOR= "cursor"; // $NON-NLS-1$ private static final String CURSOR_END= "cursor-end"; // $NON-NLS-1$ private int fStart; private int fEnd; /** * Creates an instance of <code>CursorSelectionEvaluator</code>. */ public CursorSelectionEvaluator() { reset(); } /** * Resets the <code>CursorSelectionEvaluator</code>. */ public void reset() { fStart= -1; fEnd= 0; } /** * Returns the position where the selection starts, <code>-1</code> if no * cursor selection/positioning occured. */ public int getStart() { return fStart; } /** * Returns the position where the selection ends. */ public int getEnd() { return fEnd; } /* * @see VariableEvaluator#evaluate(String) */ public String evaluate(String variable, int offset) { if (variable.equals(CURSOR)) { fStart= offset; fEnd= fStart; } else if (variable.equals(CURSOR_END)) { fEnd= offset; } return ""; // $NON-NLS-1$ } /* * @see VariableEvaluator#getRecognizedVariables() */ public String[] getRecognizedVariables() { return new String[] {CURSOR, CURSOR_END}; } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/EditBox.java
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/LocalVariableEvaluator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; public class LocalVariableEvaluator implements VariableEvaluator { private static final String INDEX= "index"; // $NON-NLS-1$ private static final String ARRAY= "array"; // $NON-NLS-1$ private static final String ITERATOR= "iterator"; // $NON-NLS-1$ private static final String COLLECTION= "collection"; // $NON-NLS-1$ private static final String VECTOR= "vector"; // $NON-NLS-1$ private static final String ENUMERATION= "enumeration"; // $NON-NLS-1$ private static final String TYPE= "type"; // $NON-NLS-1$ private static final String ELEMENT_TYPE= "element_type"; // $NON-NLS-1$ private static final String ELEMENT= "element"; // $NON-NLS-1$ /* * @see VariableEvaluator#evaluate(String, int) */ public String evaluate(String variable, int offset) { // XXX return nothing useful for now if (variable.equals(INDEX)) { return "i"; // $NON-NLS-1$ } else if (variable.equals(ARRAY)) { return "array"; // $NON-NLS-1$ } else if (variable.equals(ITERATOR)) { return "iterator"; // $NON-NLS-1$ } else if (variable.equals(COLLECTION)) { return "collection"; // $NON-NLS-1$ } else if (variable.equals(VECTOR)) { return "vector"; // $NON-NLS-1$ } else if (variable.equals(ENUMERATION)) { return "enumeration"; // $NON-NLS-1$ } else if (variable.equals(TYPE)) { return "Type"; // $NON-NLS-1$ } else if (variable.equals(ELEMENT_TYPE)) { return "Type"; // $NON-NLS-1$ } else if (variable.equals(ELEMENT)) { return "element"; // $NON-NLS-1$ } else { return null; } } /* * @see VariableEvaluator#getRecognizedVariables() */ public String[] getRecognizedVariables() { return new String[] {INDEX, ARRAY}; } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/ModelEvaluator.java
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateContext.java
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateEditorPopup.java
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateEngine.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jface.text.contentassist.ICompletionProposal; public class TemplateEngine { private static final char ARGUMENTS_BEGIN= '('; private static final char ARGUMENTS_END= ')'; private static final char HTML_TAG_BEGIN= '<'; private static final char HTML_TAG_END= '>'; private static final char JAVADOC_TAG_BEGIN= '@'; /** * Partition types. */ public static String JAVA= "java"; // $NON-NLS-1$ public static String JAVADOC= "javadoc"; // $NON-NLS-1$ private String fPartitionType; private ArrayList fExactProposals= new ArrayList(); private ArrayList fNotExactProposals= new ArrayList(); public TemplateEngine(String partitionType) { Assert.isNotNull(partitionType); fPartitionType= new String(partitionType); } /** * Empties the collector. */ public void reset() { fExactProposals.clear(); fNotExactProposals.clear(); } /** * Returns an array of templates matching exactly. */ public ICompletionProposal[] getExactResults() { return (ICompletionProposal[]) fExactProposals.toArray(new ICompletionProposal[fExactProposals.size()]); } /** * Returns an array of templates matching not exactly. */ public ICompletionProposal[] getNotExactResults() { return (ICompletionProposal[]) fNotExactProposals.toArray(new ICompletionProposal[fNotExactProposals.size()]); } /** * Inspects the context of the compilation unit around <code>completionPosition</code> * and feeds the collector with proposals. * @param collector the collector for template proposals. * @param sourceUnit the compilation unit. * @param completionPosition the context position in the compilation unit. */ public void complete(ICompilationUnit sourceUnit, int completionPosition) throws JavaModelException { String source= sourceUnit.getSource(); // inspect context int end = completionPosition; int start= guessStart(source, end, fPartitionType); // handle optional argument String request= source.substring(start, end); int index= request.indexOf(ARGUMENTS_BEGIN); String key; String[] arguments; if (index == -1) { key= request; arguments= null; } else { key= request.substring(0, index); String allArguments= request.substring(index + 1, request.length() - 1); List list= new ArrayList(); StringTokenizer tokenizer= new StringTokenizer(allArguments, ","); // $NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String token= tokenizer.nextToken().trim(); list.add(token); } arguments= (String[]) list.toArray(new String[list.size()]); } // match context with template Template[] templates= TemplateSet.getInstance().getMatchingTemplates(key, fPartitionType); for (int i= 0; i != templates.length; i++) { TemplateProposal proposal= new TemplateProposal(templates[i], arguments, start, end); if (templates[i].getName().equals(key)) { fExactProposals.add(proposal); } else { fNotExactProposals.add(proposal); } } } private static final int guessStart(String source, int end, String partitionType) { int start= end; if (partitionType.equals(JAVA)) { // optional arguments if ((start != 0) && (source.charAt(start - 1) == ARGUMENTS_END)) { start--; while ((start != 0) && (source.charAt(start - 1) != ARGUMENTS_BEGIN)) start--; start--; if ((start != 0) && Character.isWhitespace(source.charAt(start - 1))) start--; } while ((start != 0) && Character.isUnicodeIdentifierPart(source.charAt(start - 1))) start--; if ((start != 0) && Character.isUnicodeIdentifierStart(source.charAt(start - 1))) start--; } else if (partitionType.equals(JAVADOC)) { // javadoc tag if ((start != 0) && (source.charAt(start - 1) == HTML_TAG_END)) start--; while ((start != 0) && Character.isUnicodeIdentifierPart(source.charAt(start - 1))) start--; if ((start != 0) && Character.isUnicodeIdentifierStart(source.charAt(start - 1))) start--; // include html and javadoc tags if ((start != 0) && (source.charAt(start - 1) == HTML_TAG_BEGIN) || (source.charAt(start - 1) == JAVADOC_TAG_BEGIN)) { start--; } } return start; } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateInterpolator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.internal.core.Assert; public class TemplateInterpolator { /* * EBNF grammar. * * template := (text | escape)*. * text := character - dollar. * escape := dollar ('{' identifier '}' | dollar). * dollar := '$'. */ // state private static final int TEXT= 0; private static final int ESCAPE= 1; private static final int IDENTIFIER= 2; private static final char ESCAPE_CHARACTER= '$'; private static final char IDENTIFIER_BEGIN= '{'; private static final char IDENTIFIER_END= '}'; /** * Interpolates a string. */ public String interpolate(String string, VariableEvaluator evaluator) { StringBuffer buffer= new StringBuffer(string.length()); StringBuffer identifier= new StringBuffer(); int state= TEXT; for (int i= 0; i != string.length(); i++) { char ch= string.charAt(i); switch (state) { case TEXT: switch (ch) { case ESCAPE_CHARACTER: state= ESCAPE; break; default: buffer.append(ch); break; } break; case ESCAPE: switch (ch) { case ESCAPE_CHARACTER: buffer.append(ch); state= TEXT; break; case IDENTIFIER_BEGIN: identifier.setLength(0); state= IDENTIFIER; break; default: // XXX grammar would not allow occurence of single escape characters buffer.append(ESCAPE_CHARACTER); buffer.append(ch); state= TEXT; break; } break; case IDENTIFIER: switch (ch) { case IDENTIFIER_END: { String value= evaluator.evaluate(identifier.toString(), buffer.length()); if (value == null) { // leave variable untouched buffer.append(ESCAPE_CHARACTER); buffer.append(IDENTIFIER_BEGIN); buffer.append(identifier); buffer.append(IDENTIFIER_END); } else { buffer.append(value); } } state= TEXT; break; default: identifier.append(ch); break; } break; } } return buffer.toString(); } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateModel.java
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateProposal.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.core.refactoring.TextUtilities; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage; import org.eclipse.jdt.internal.ui.preferences.TemplatePreferencePage; import org.eclipse.jdt.internal.ui.refactoring.changes.TextBuffer; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; /** * A template proposal. */ public class TemplateProposal implements ICompletionProposal { private final Template fTemplate; private final int fStart; private final int fEnd; private int fSelectionStart; private int fSelectionEnd; private CursorSelectionEvaluator fCursorSelectionEvaluator= new CursorSelectionEvaluator(); private VariableEvaluator fLocalVariableEvaluator= new LocalVariableEvaluator(); private TemplateInterpolator fInterpolator= new TemplateInterpolator(); private ArgumentEvaluator fArgumentEvaluator; /** * Creates a template proposal with a template and the range of its key. * @param template the template * @param arguments arguments to the template, or <code>null</code> for no arguments * @param start the starting position of the key. * @param end the ending position of the key (exclusive). */ TemplateProposal(Template template, String[] arguments, int start, int end) { Assert.isNotNull(template); Assert.isTrue(start >= 0); Assert.isTrue(end >= start); fTemplate= template; fArgumentEvaluator= new ArgumentEvaluator(arguments); fStart= start; fEnd= end; } /** * @see ICompletionProposal#apply(IDocument) */ public void apply(IDocument document) { int indentationLevel= guessIndentationLevel(document, fStart); String pattern= fTemplate.getPattern(); // interpolate pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); fCursorSelectionEvaluator.reset(); pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); // side effect: stores selection int start= fCursorSelectionEvaluator.getStart(); if (start == -1) { fSelectionStart= pattern.length(); fSelectionEnd= fSelectionStart; } else { fSelectionStart= start; fSelectionEnd= fCursorSelectionEvaluator.getEnd(); } boolean format= TemplatePreferencePage.useCodeFormatter(); if (format) { CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions()); formatter.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); formatter.setInitialIndentationLevel(indentationLevel); pattern= formatter.formatSourceString(pattern); int[] positions= formatter.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } else { CodeIndentator indentator= new CodeIndentator(); indentator.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); indentator.setIndentationLevel(indentationLevel); pattern= indentator.indentate(pattern); int[] positions= indentator.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } // strip indentation on first line String finalString= trimBegin(pattern); int charactersRemoved= pattern.length() - finalString.length(); fSelectionStart -= charactersRemoved; fSelectionEnd -= charactersRemoved; try { document.replace(fStart, fEnd - fStart, finalString); } catch (BadLocationException x) {} // ignore } private static String trimBegin(String string) { int i= 0; while ((i != string.length()) && Character.isWhitespace(string.charAt(i))) i++; return string.substring(i); } /** * @see ICompletionProposal#getSelection(IDocument) */ public Point getSelection(IDocument document) { return new Point(fStart + fSelectionStart, fSelectionEnd - fSelectionStart); } /** * @see ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { String pattern= fTemplate.getPattern(); pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); return textToHTML(pattern); } /** * @see ICompletionProposal#getDisplayString() */ public String getDisplayString() { return fTemplate.getName() + " - " + fTemplate.getDescription(); // $NON-NLS-1$ } /** * @see ICompletionProposal#getImage() */ public Image getImage() { return fTemplate.getImage(); } /** * @see ICompletionProposal#getContextInformation() */ public IContextInformation getContextInformation() { return null; } private static int guessIndentationLevel(IDocument document, int offset) { TextBuffer buffer= new TextBuffer(document); String line= buffer.getLineContentOfOffset(offset); return TextUtilities.getIndent(line, CodeFormatterPreferencePage.getTabSize()); } private static String textToHTML(String string) { StringBuffer buffer= new StringBuffer(string.length()); buffer.append("<pre>"); // $NON-NLS-1$ for (int i= 0; i != string.length(); i++) { char ch= string.charAt(i); switch (ch) { case '&': buffer.append("&amp;"); // $NON-NLS-1$ break; case '<': buffer.append("&lt;"); // $NON-NLS-1$ break; case '>': buffer.append("&gt;"); // $NON-NLS-1$ break; case '\t': buffer.append(" "); // $NON-NLS-1$ break; case '\n': buffer.append("<br>"); // $NON-NLS-1$ break; default: buffer.append(ch); break; } } buffer.append("</pre>"); // $NON-NLS-1$ return buffer.toString(); } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateSet.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.Serializer; import org.apache.xml.serialize.SerializerFactory; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * A user defined template set. */ public class TemplateSet { private static class TemplateComparator implements Comparator { public int compare(Object arg0, Object arg1) { if (arg0 == arg1) return 0; if (arg0 == null) return -1; Template template0= (Template) arg0; Template template1= (Template) arg1; return template0.getName().compareTo(template1.getName()); } } private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$ private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$ private static final String TEMPLATE_TAG= "template"; //$NON-NLS-1$ private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$ private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$ private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$ private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$ private List fTemplates= new ArrayList(); private Comparator fTemplateComparator= new TemplateComparator(); private Template[] fSortedTemplates= new Template[0]; private static TemplateSet fgTemplateSet; public static TemplateSet getInstance() { if (fgTemplateSet == null) fgTemplateSet= create(); return fgTemplateSet; } private static InputStream getDefaultsAsStream() { return TemplateSet.class.getResourceAsStream(DEFAULT_FILE); } private static File getTemplateFile() { IPath path= JavaPlugin.getDefault().getStateLocation(); path= path.append(TEMPLATE_FILE); return path.toFile(); } private TemplateSet() { } private static TemplateSet create() { try { File templateFile= getTemplateFile(); if (!templateFile.exists()) { InputStream inputStream= getDefaultsAsStream(); if (inputStream == null) return new TemplateSet(); if (!templateFile.createNewFile()) return new TemplateSet(); OutputStream outputStream= new FileOutputStream(templateFile); // copy over default templates byte buffer[]= new byte[65536]; while (true) { int bytes= inputStream.read(buffer); if (bytes == -1) break; outputStream.write(buffer, 0, bytes); } inputStream.close(); outputStream.close(); } Assert.isTrue(templateFile.exists()); TemplateSet templateSet= new TemplateSet(); templateSet.addFromStream(new FileInputStream(templateFile)); return templateSet; } catch (IOException e) { JavaPlugin.log(e); return null; } } /** * Resets the template set with the default templates. */ public void restoreDefaults() { clear(); addFromStream(getDefaultsAsStream()); } /** * Resets (reloads) the template set. */ public void reset() { clear(); try { addFromStream(new FileInputStream(getTemplateFile())); } catch (FileNotFoundException e) { JavaPlugin.log(e); } } private boolean addFromStream(InputStream stream) { try { TemplateSet templateSet= new TemplateSet(); DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder parser= factory.newDocumentBuilder(); Document document= parser.parse(new InputSource(stream)); NodeList elements= document.getElementsByTagName(TEMPLATE_TAG); int count= elements.getLength(); for (int i= 0; i != count; i++) { Node node= elements.item(i); NamedNodeMap attributes= node.getAttributes(); if (attributes == null) continue; String name= attributes.getNamedItem(NAME_ATTRIBUTE).getNodeValue(); String description= attributes.getNamedItem(DESCRIPTION_ATTRIBUTE).getNodeValue(); String context= attributes.getNamedItem(CONTEXT_ATTRIBUTE).getNodeValue(); Node enabledNode= attributes.getNamedItem(ENABLED_ATTRIBUTE); boolean enabled= (enabledNode == null) || (enabledNode.getNodeValue().equals("true")); //$NON-NLS-1$ StringBuffer buffer= new StringBuffer(); NodeList children= node.getChildNodes(); for (int j= 0; j != children.getLength(); j++) { String value= children.item(j).getNodeValue(); if (value != null) buffer.append(value); } String pattern= buffer.toString().trim(); Template template= new Template(name, description, context, pattern); template.setEnabled(enabled); add(template); } return true; } catch (ParserConfigurationException e) { JavaPlugin.log(e); } catch (IOException e) { JavaPlugin.log(e); } catch (SAXException e) { JavaPlugin.log(e); } sort(); return false; } /** * Saves the template set. */ public boolean save() { try { fgTemplateSet.save(new FileOutputStream(getTemplateFile())); return true; } catch (IOException e) { JavaPlugin.log(e); return false; } } /** * Saves the template set as XML. */ private boolean save(OutputStream stream) { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Node root= document.createElement("templates"); // $NON-NLS-1$ document.appendChild(root); for (int i= 0; i != fTemplates.size(); i++) { Template template= (Template) fTemplates.get(i); Node node= document.createElement("template"); // $NON-NLS-1$ root.appendChild(node); NamedNodeMap attributes= node.getAttributes(); Attr name= document.createAttribute(NAME_ATTRIBUTE); name.setValue(template.getName()); attributes.setNamedItem(name); Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE); description.setValue(template.getDescription()); attributes.setNamedItem(description); Attr context= document.createAttribute(CONTEXT_ATTRIBUTE); context.setValue(template.getContext()); attributes.setNamedItem(context); Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE); enabled.setValue(template.isEnabled() ? "true" : "false"); // $NON-NLS-1$ // $NON-NLS-2$ attributes.setNamedItem(enabled); Text pattern= document.createTextNode(template.getPattern()); node.appendChild(pattern); } OutputFormat format = new OutputFormat(); format.setPreserveSpace(true); Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$ serializer.asDOMSerializer().serialize(document); return true; } catch (ParserConfigurationException e) { JavaPlugin.log(e); } catch (IOException e) { JavaPlugin.log(e); } return false; } /** * Adds a template to the set. */ public void add(Template template) { fTemplates.add(template); sort(); } /** * Removes a template to the set. */ public void remove(Template template) { fTemplates.remove(template); sort(); } /** * Empties the set. */ public void clear() { fTemplates.clear(); sort(); } /** * Returns all templates. */ public Template[] getTemplates() { return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]); } /** * Returns templates matching a prefix. */ public Template[] getMatchingTemplates(String prefix, String partitionType) { Assert.isNotNull(prefix); Assert.isNotNull(partitionType); List results= new ArrayList(fSortedTemplates.length); for (int i= 0; i != fSortedTemplates.length; i++) { Template template= fSortedTemplates[i]; if (template.matches(prefix, partitionType)) results.add(template); } return (Template[]) results.toArray(new Template[results.size()]); } private void sort() { fSortedTemplates= (Template[]) fTemplates.toArray(new Template[fTemplates.size()]); Arrays.sort(fSortedTemplates, fTemplateComparator); } }
    4,139
    Bug 4139 EC DCR: Code templates feature (1GIVMDV)
    null
    verified fixed
    8fd6bb8
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T10:39:57Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/VariableEvaluator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; /** * An interface to allow custom evaluation of variables. */ public interface VariableEvaluator { /** * Returns the value of a variable. * * @param variable the variable to evaluate. * @param offset the offset at which the variable is evaluated. * @return returns the value of the variable, <code>null</code> if the variable is not recognized. */ String evaluate(String variable, int offset); /** * Returns the names of the variables the evaluator recognizes. */ String[] getRecognizedVariables(); }
    4,977
    Bug 4977 Extra spaces in completion for <code></code>
    Enter <c and type ctrl-space Select <code></code> Note the extra spaces Same for other <*></*>
    resolved fixed
    de7172b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T12:49:17Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateContext.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import java.util.Map; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.codeassist.complete.CompletionParser; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.lookup.Scope; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.problem.ProblemIrritants; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jdt.internal.core.SearchableEnvironment; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider; import org.eclipse.jdt.internal.ui.util.DocumentManager; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; public class TemplateContext implements VariableEvaluator { private static final String FILE= "file"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String LINE= "line"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String DATE= "date"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String INDEX= "index"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String ARRAY= "array"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String ITERATOR= "iterator"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String COLLECTION= "collection"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String VECTOR= "vector"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String ENUMERATION= "enumeration"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String TYPE= "type"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String ELEMENT_TYPE= "element_type"; // $NON-NLS-1$ //$NON-NLS-1$ private static final String ELEMENT= "element"; // $NON-NLS-1$ //$NON-NLS-1$ private ICompilationUnit fUnit; private IDocument fDocument; private int fStart; private int fEnd; private ITextViewer fViewer; public TemplateContext(ICompilationUnit unit, int start, int end, ITextViewer viewer) { Assert.isTrue(start <= end); fUnit= unit; fStart= start; fEnd= end; fViewer= viewer; } public int getStart() { return fStart; } public int getEnd() { return fEnd; } public ITextViewer getViewer() { return fViewer; } public void setDocument(IDocument document) { fDocument= document; } public IDocument getDocument() { return fDocument; } /* * @see VariableEvaluator#reset() */ public void reset() { } /* * @see VariableEvaluator#acceptText(String, int) */ public void acceptText(String variable, int offset) { } /* * @see VariableEvaluator#evaluateVariable(String, int) */ public String evaluateVariable(String variable, int offset) { if (variable.equals(FILE)) { return fUnit.getElementName(); // line number } else if (variable.equals(LINE)) { int line= getLineNumber(fUnit, fEnd); if (line == -1) return null; else return Integer.toString(line); } else if (variable.equals(DATE)) { return DateFormat.getDateInstance().format(new Date()); } else { return null; } } /* * @see VariableEvaluator#getRecognizedVariables() */ public String[] getRecognizedVariables() { return null; } private static int getLineNumber(ICompilationUnit unit, int offset) { CompilationUnitDocumentProvider documentProvider= JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); try { DocumentManager documentManager= new DocumentManager(unit); documentManager.connect(); IDocument document= documentManager.getDocument(); if (document == null) { documentManager.disconnect(); return -1; } try { return document.getLineOfOffset(offset) + 1; } catch (BadLocationException e) { documentManager.disconnect(); } } catch (CoreException e) { } return -1; } }
    4,977
    Bug 4977 Extra spaces in completion for <code></code>
    Enter <c and type ctrl-space Select <code></code> Note the extra spaces Same for other <*></*>
    resolved fixed
    de7172b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T12:49:17Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateProposal.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.core.refactoring.TextUtilities; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage; import org.eclipse.jdt.internal.ui.preferences.TemplatePreferencePage; import org.eclipse.jdt.internal.ui.refactoring.changes.TextBuffer; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.custom.StyledText; /** * A template proposal. */ public class TemplateProposal implements ICompletionProposal { private final Template fTemplate; private final TemplateContext fContext; private int fSelectionStart; private int fSelectionEnd; private CursorSelectionEvaluator fCursorSelectionEvaluator= new CursorSelectionEvaluator(); private VariableEvaluator fLocalVariableEvaluator= new LocalVariableEvaluator(); private TemplateInterpolator fInterpolator= new TemplateInterpolator(); private ArgumentEvaluator fArgumentEvaluator; private ModelEvaluator fModelEvaluator= new ModelEvaluator(); private boolean fDisposed; /** * Creates a template proposal with a template and the range of its key. * @param template the template * @param arguments arguments to the template, or <code>null</code> for no arguments * @param start the starting position of the key. * @param end the ending position of the key (exclusive). */ TemplateProposal(Template template, String[] arguments, TemplateContext context) { Assert.isNotNull(template); Assert.isNotNull(context); fTemplate= template; fArgumentEvaluator= new ArgumentEvaluator(arguments); fContext= context; } /** * @see ICompletionProposal#apply(IDocument) */ public void apply(IDocument document) { int indentationLevel= guessIndentationLevel(document, fContext.getStart()); String pattern= fTemplate.getPattern(); // resolve variables automatically pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fContext); // pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); fInterpolator.interpolate(pattern, fModelEvaluator); TemplateModel model= fModelEvaluator.getModel(); if (model.getEditableCount() == 0) { pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); // side effect: stores selection int cursorStart= fCursorSelectionEvaluator.getStart(); if (cursorStart == -1) { fSelectionStart= pattern.length(); fSelectionEnd= fSelectionStart; } else { fSelectionStart= cursorStart; fSelectionEnd= fCursorSelectionEvaluator.getEnd(); } } else { // resolve variables manually fContext.setDocument(document); TemplateEditorPopup popup= new TemplateEditorPopup(fContext, model); if (!popup.open()) { // leave caret offset fSelectionStart= fContext.getEnd() - fContext.getStart(); fSelectionEnd= fSelectionStart; return; } pattern= popup.getText(); int[] selection= popup.getSelection(); if (selection[0] == -1) { fSelectionStart= pattern.length(); fSelectionEnd= fSelectionStart; } else { fSelectionStart= selection[0]; fSelectionEnd= selection[1]; } } if (TemplatePreferencePage.useCodeFormatter()) { CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions()); formatter.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); formatter.setInitialIndentationLevel(indentationLevel); pattern= formatter.formatSourceString(pattern); int[] positions= formatter.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } else { CodeIndentator indentator= new CodeIndentator(); indentator.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); indentator.setIndentationLevel(indentationLevel); pattern= indentator.indentate(pattern); int[] positions= indentator.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } // strip indentation on first line String finalString= trimBegin(pattern); int charactersRemoved= pattern.length() - finalString.length(); fSelectionStart -= charactersRemoved; fSelectionEnd -= charactersRemoved; int start= fContext.getStart(); int length= fContext.getEnd() - start; try { document.replace(start, length, finalString); } catch (BadLocationException x) {} // ignore } private static String trimBegin(String string) { int i= 0; while ((i != string.length()) && Character.isWhitespace(string.charAt(i))) i++; return string.substring(i); } /** * @see ICompletionProposal#getSelection(IDocument) */ public Point getSelection(IDocument document) { return new Point(fContext.getStart() + fSelectionStart, fSelectionEnd - fSelectionStart); } /** * @see ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { String pattern= fTemplate.getPattern(); pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fContext); pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); return textToHTML(pattern); } /** * @see ICompletionProposal#getDisplayString() */ public String getDisplayString() { return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$ } /** * @see ICompletionProposal#getImage() */ public Image getImage() { return fTemplate.getImage(); } /** * @see ICompletionProposal#getContextInformation() */ public IContextInformation getContextInformation() { return null; } private static int guessIndentationLevel(IDocument document, int offset) { TextBuffer buffer= new TextBuffer(document); String line= buffer.getLineContentOfOffset(offset); return TextUtilities.getIndent(line, CodeFormatterPreferencePage.getTabSize()); } private static String textToHTML(String string) { StringBuffer buffer= new StringBuffer(string.length()); buffer.append("<pre>"); // $NON-NLS-1$ //$NON-NLS-1$ for (int i= 0; i != string.length(); i++) { char ch= string.charAt(i); switch (ch) { case '&': buffer.append("&amp;"); // $NON-NLS-1$ //$NON-NLS-1$ break; case '<': buffer.append("&lt;"); // $NON-NLS-1$ //$NON-NLS-1$ break; case '>': buffer.append("&gt;"); // $NON-NLS-1$ //$NON-NLS-1$ break; case '\t': buffer.append(" "); // $NON-NLS-1$ //$NON-NLS-1$ break; case '\n': buffer.append("<br>"); // $NON-NLS-1$ //$NON-NLS-1$ break; default: buffer.append(ch); break; } } buffer.append("</pre>"); // $NON-NLS-1$ //$NON-NLS-1$ return buffer.toString(); } }
    5,035
    Bug 5035 NPE in Deleterefactoring
    204: In the package viewer: I got jdt.core from the zrh repository (v_0.135), selected all files, delete 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.getPath (DeleteRefactoring.java:170) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.access$0 (DeleteRefactoring.java:168) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring$1.getPathLengt h(DeleteRefactoring.java:185) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring$1.compare (DeleteRefactoring.java:181) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.sort(Arrays.java:1129) at java.util.Collections.sort(Collections.java:122) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.prepareElement List(DeleteRefactoring.java:133) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.createChange (DeleteRefactoring.java:117) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:102) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:118) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.ui.reorg.ReorgAction.perform (ReorgAction.java:52) at org.eclipse.jdt.internal.ui.reorg.DeleteAction.run (DeleteAction.java:54) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.handleKeyPressed (PackageExplorerPart.java:595) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$5.keyPressed (PackageExplorerPart.java:312) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
    resolved fixed
    139bfd2
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T12:57:41Z
    2001-10-17T09:13:20Z
    org.eclipse.jdt.ui/core
    5,035
    Bug 5035 NPE in Deleterefactoring
    204: In the package viewer: I got jdt.core from the zrh repository (v_0.135), selected all files, delete 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.getPath (DeleteRefactoring.java:170) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.access$0 (DeleteRefactoring.java:168) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring$1.getPathLengt h(DeleteRefactoring.java:185) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring$1.compare (DeleteRefactoring.java:181) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.mergeSort(Arrays.java(Compiled Code)) at java.util.Arrays.sort(Arrays.java:1129) at java.util.Collections.sort(Collections.java:122) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.prepareElement List(DeleteRefactoring.java:133) at org.eclipse.jdt.internal.core.refactoring.reorg.DeleteRefactoring.createChange (DeleteRefactoring.java:117) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:102) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:118) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.ui.reorg.ReorgAction.perform (ReorgAction.java:52) at org.eclipse.jdt.internal.ui.reorg.DeleteAction.run (DeleteAction.java:54) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.handleKeyPressed (PackageExplorerPart.java:595) at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$5.keyPressed (PackageExplorerPart.java:312) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
    resolved fixed
    139bfd2
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T12:57:41Z
    2001-10-17T09:13:20Z
    refactoring/org/eclipse/jdt/internal/core/refactoring/reorg/DeleteRefactoring.java
    4,972
    Bug 4972 move CU creates imports at wrong position
    203 1. in package 'a' create a file with wrong package statement: /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package a.b.c.d.e; public interface IDialogFieldListener { void dialogFieldChanged(DialogField field); } 2. Move the cu to package p (update references) 3. Result has an import statement in the middle of the comment / import a.*;* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ ...
    resolved fixed
    1587093
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T14:01:38Z
    2001-10-15T10:00:00Z
    org.eclipse.jdt.ui/core
    4,972
    Bug 4972 move CU creates imports at wrong position
    203 1. in package 'a' create a file with wrong package statement: /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package a.b.c.d.e; public interface IDialogFieldListener { void dialogFieldChanged(DialogField field); } 2. Move the cu to package p (update references) 3. Result has an import statement in the middle of the comment / import a.*;* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ ...
    resolved fixed
    1587093
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T14:01:38Z
    2001-10-15T10:00:00Z
    refactoring/org/eclipse/jdt/internal/core/refactoring/reorg/MoveCuUpdateCreator.java
    5,075
    Bug 5075 Class cast extception in JavaOutliner
    * Using latest code (204++) * Using Junit as a test case * Put a breakpoint in VectorTest#testElementAt(), on the second line of the method * Open a class file editor in the Java Perspective, and make it the active editor (I openned Vector.class) * Debug to the breakpoint * Try to inspect or display "i.intValue == 1" * ClassCastException this= Workbench (id=49) e= SWTException (id=190) backtrace= Object[10] (id=192) code= 46 detailMessage= "Failed to execute runnable" throwable= ClassCastException (id=193) backtrace= Object[11] (id=194) [0]= int[10] (id=196) [1]= Class (org.eclipse.jdt.internal.ui.javaeditor.JavaOutlinePage$1) (id=74) [2]= Class (org.eclipse.swt.widgets.RunnableLock) (id=75) [3]= Class (org.eclipse.swt.widgets.Synchronizer) (id=76) [4]= Class (org.eclipse.swt.widgets.Display) (id=77) [5]= Class (org.eclipse.swt.widgets.Display) (id=77) [6]= Class (org.eclipse.ui.internal.Workbench) (id=40) [7]= Class (org.eclipse.ui.internal.Workbench) (id=40) [8]= Class (org.eclipse.core.internal.boot.InternalBootLoader) (id=46) [9]= Class (org.eclipse.core.boot.BootLoader) (id=47) [10]= Class (SlimLauncher) (id=48) detailMessage= "org.eclipse.jdt.internal.core.ClassFile" msg= "Failed to execute runnable (org.eclipse.jdt.internal.core.ClassFile)"
    resolved fixed
    adb0fef
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-18T14:35:53Z
    2001-10-18T13:00:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
    package org.eclipse.jdt.internal.ui.javaeditor; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Widget; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.Assert; import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.part.Page; import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IElementChangedListener; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.actions.GenerateGroup; import org.eclipse.jdt.internal.ui.actions.OpenHierarchyPerspectiveItem; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup; import org.eclipse.jdt.internal.ui.reorg.ReorgGroup; import org.eclipse.jdt.internal.ui.search.JavaSearchGroup; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementSorter; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; /** * The content outline page of the Java editor. The viewer implements a proprietary * update mechanism based on Java model deltas. It does not react on domain changes. * It is specified to show the content of ICompilationUnits and IClassFiles. */ class JavaOutlinePage extends Page implements IContentOutlinePage { /** * The element change listener of the java outline viewer. * @see IElementChangedListener */ class ElementChangedListener implements IElementChangedListener { public void elementChanged(final ElementChangedEvent e) { Display d= getControl().getDisplay(); if (d != null) { d.asyncExec(new Runnable() { public void run() { IJavaElementDelta delta= findElement( (ICompilationUnit) fInput, e.getDelta()); if (delta != null && fOutlineViewer != null) { fOutlineViewer.reconcile(delta); } } }); } } protected IJavaElementDelta findElement(ICompilationUnit unit, IJavaElementDelta delta) { if (delta == null || unit == null) return null; IJavaElement element= delta.getElement(); if (unit.equals(element)) return delta; if (element.getElementType() > IJavaElement.CLASS_FILE) return null; IJavaElementDelta[] children= delta.getAffectedChildren(); if (children == null || children.length == 0) return null; for (int i= 0; i < children.length; i++) { IJavaElementDelta d= findElement(unit, children[i]); if (d != null) return d; } return null; } }; /** * Content provider for the children of an ICompilationUnit or * an IClassFile * @see ITreeContentProvider */ class ChildrenProvider implements ITreeContentProvider { private ElementChangedListener fListener; private JavaOutlineErrorTickUpdater fErrorTickUpdater; protected boolean matches(IJavaElement element) { if (element.getElementType() == IJavaElement.METHOD) { String name= element.getElementName(); return (name != null && name.indexOf('<') >= 0); } return false; } protected IJavaElement[] filter(IJavaElement[] children) { boolean initializers= false; for (int i= 0; i < children.length; i++) { if (matches(children[i])) { initializers= true; break; } } if (!initializers) return children; Vector v= new Vector(); for (int i= 0; i < children.length; i++) { if (matches(children[i])) continue; v.addElement(children[i]); } IJavaElement[] result= new IJavaElement[v.size()]; v.copyInto(result); return result; } public Object[] getChildren(Object parent) { if (parent instanceof IParent) { IParent c= (IParent) parent; try { return filter(c.getChildren()); } catch (JavaModelException x) { JavaPlugin.getDefault().logErrorStatus(JavaEditorMessages.getString("JavaOutlinePage.error.ChildrenProvider.getChildren.message1"), x.getStatus()); //$NON-NLS-1$ } } return new Object[0]; } public Object[] getElements(Object parent) { return getChildren(parent); } public Object getParent(Object child) { if (child instanceof IJavaElement) { IJavaElement e= (IJavaElement) child; return e.getParent(); } return null; } public boolean hasChildren(Object parent) { if (parent instanceof IParent) { IParent c= (IParent) parent; try { IJavaElement[] children= filter(c.getChildren()); return (children != null && children.length > 0); } catch (JavaModelException x) { JavaPlugin.getDefault().logErrorStatus(JavaEditorMessages.getString("JavaOutlinePage.error.ChildrenProvider.hasChildren.message1"), x.getStatus()); //$NON-NLS-1$ } } return false; } public boolean isDeleted(Object o) { return false; } public void dispose() { if (fListener != null) { JavaCore.removeElementChangedListener(fListener); fListener= null; } if (fErrorTickUpdater != null) { fErrorTickUpdater.setAnnotationModel(null); fErrorTickUpdater= null; } } /** * @see IContentProvider#inputChanged(Viewer, Object, Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (oldInput == null && newInput != null) { if (fListener == null) fListener= new ElementChangedListener(); JavaCore.addElementChangedListener(fListener); if (fErrorTickUpdater == null) { fErrorTickUpdater= new JavaOutlineErrorTickUpdater(fOutlineViewer); } fErrorTickUpdater.setAnnotationModel(fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput())); } else if (oldInput != null && newInput != null) { fErrorTickUpdater.setAnnotationModel(fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput())); } else if (oldInput != null && newInput == null) { JavaCore.removeElementChangedListener(fListener); fListener= null; fErrorTickUpdater.setAnnotationModel(null); fErrorTickUpdater= null; } } }; class JavaOutlineViewer extends TreeViewer { /** * Indicates an item which has been reused. At the point of * its reuse it has been expanded. This field is used to * communicate between <code>internalExpandToLevel</code> and * <code>reuseTreeItem</code>. */ private Item fReusedExpandedItem; public JavaOutlineViewer(Tree tree) { super(tree); setAutoExpandLevel(ALL_LEVELS); } /** * Investigates the given element change event and if affected incrementally * updates the outline. */ public void reconcile(IJavaElementDelta delta) { if (getSorter() == null) { Widget w= findItem(fInput); if (w != null) update(w, delta); } else { // just for now refresh(); } } /** * @see TreeViewer#internalExpandToLevel */ protected void internalExpandToLevel(Widget node, int level) { if (node instanceof Item) { Item i= (Item) node; if (i.getData() instanceof IJavaElement) { IJavaElement je= (IJavaElement) i.getData(); if (je.getElementType() == IJavaElement.IMPORT_CONTAINER || isInnerType(je)) { if (i != fReusedExpandedItem) { setExpanded(i, false); return; } } } } super.internalExpandToLevel(node, level); } protected void reuseTreeItem(Item item, Object element) { // remove children Item[] c= getChildren(item); if (c != null && c.length > 0) { if (getExpanded(item)) fReusedExpandedItem= item; for (int k= 0; k < c.length; k++) { if (c[k].getData() != null) disassociate(c[k]); c[k].dispose(); } } updateItem(item, element); updatePlus(item, element); internalExpandToLevel(item, ALL_LEVELS); fReusedExpandedItem= null; } /** * @see TreeViewer#createTreeItem */ protected void createTreeItem(Widget parent, Object element, int ix) { Item[] children= getChildren(parent); boolean expand= (parent instanceof Item && (children == null || children.length == 0)); Item item= newItem(parent, SWT.NULL, ix); updateItem(item, element); updatePlus(item, element); if (expand) setExpanded((Item) parent, true); internalExpandToLevel(item, ALL_LEVELS); } protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) { if (element instanceof IMethod) { if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) { try { return JavaModelUtil.isMainMethod((IMethod)element); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } } return "main".equals(element.getElementName()); //$NON-NLS-1$ } return false; } protected void update(Widget w, IJavaElementDelta delta) { Item item; Object element; IJavaElement parent= delta.getElement(); IJavaElementDelta[] affected= delta.getAffectedChildren(); Item[] children= getChildren(w); boolean doUpdateParent= false; Vector deletions= new Vector(); Vector additions= new Vector(); go1: for (int i= 0; i < children.length; i++) { item= children[i]; element= item.getData(); for (int j= 0; j < affected.length; j++) { IJavaElement affectedElement= affected[j].getElement(); int status= affected[j].getKind(); if (affectedElement.equals(element)) { // removed if ((status & IJavaElementDelta.REMOVED) != 0) { deletions.addElement(item); doUpdateParent= doUpdateParent || mustUpdateParent(affected[j], affectedElement); continue go1; } // changed if ((status & IJavaElementDelta.CHANGED) != 0) { int change= affected[j].getFlags(); doUpdateParent= doUpdateParent || mustUpdateParent(affected[j], affectedElement); if ((change & IJavaElementDelta.F_MODIFIERS) != 0) { if (filtered(parent, affectedElement)) deletions.addElement(item); else updateItem(item, affectedElement); } if ((change & IJavaElementDelta.F_CONTENT) != 0) updateItem(item, affectedElement); if ((change & IJavaElementDelta.F_CHILDREN) != 0) update(item, affected[j]); continue go1; } } else { // changed if ((status & IJavaElementDelta.CHANGED) != 0 && (affected[j].getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 && !filtered(parent, affectedElement)) additions.addElement(affected[j]); } } } // find all elements to add IJavaElementDelta[] add= delta.getAddedChildren(); if (additions.size() > 0) { IJavaElementDelta[] tmp= new IJavaElementDelta[add.length + additions.size()]; System.arraycopy(add, 0, tmp, 0, add.length); for (int i= 0; i < additions.size(); i++) tmp[i + add.length]= (IJavaElementDelta) additions.elementAt(i); add= tmp; } // add at the right position go2: for (int i= 0; i < add.length; i++) { try { IJavaElement e= add[i].getElement(); if (filtered(parent, e)) continue go2; ISourceReference r= (ISourceReference) e ; doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e); ISourceRange rng= r.getSourceRange(); int start= rng.getOffset(); int end= start + rng.getLength() - 1; Item last= null; item= null; children= getChildren(w); for (int j= 0; j < children.length; j++) { item= children[j]; r= (ISourceReference) item.getData(); if (r == null) { // parent node collapsed and not be opened before -> do nothing continue go2; } try { if (overlaps(r, start, end)) { // be tolerant if the delta is not correct, or if // the tree has been updated other than by a delta reuseTreeItem(item, (Object) add[i].getElement()); continue go2; } else if (r.getSourceRange().getOffset() > start) { if (last != null && deletions.contains(last)) { // reuse item deletions.removeElement(last); reuseTreeItem(last, (Object) add[i].getElement()); } else { // nothing to reuse createTreeItem(w, (Object) add[i].getElement(), j); } continue go2; } } catch (JavaModelException x) { // stumbled over deleted element } last= item; } // add at the end of the list if (last != null && deletions.contains(last)) { // reuse item deletions.removeElement(last); reuseTreeItem(last, (Object) add[i].getElement()); } else { // nothing to reuse createTreeItem(w, (Object) add[i].getElement(), -1); } } catch (JavaModelException x) { // the element to be added is not present -> don't add it } } // remove items which haven't been reused Enumeration e= deletions.elements(); while (e.hasMoreElements()) { item= (Item) e.nextElement(); disassociate(item); item.dispose(); } if (doUpdateParent) updateItem(w, delta.getElement()); } protected boolean overlaps(ISourceReference reference, int start, int end) { try { ISourceRange rng= reference.getSourceRange(); return start <= (rng.getOffset() + rng.getLength() - 1) && rng.getOffset() <= end; } catch (JavaModelException x) { return false; } } protected boolean filtered(IJavaElement parent, IJavaElement child) { Object[] result= new Object[] { child }; ViewerFilter[] filters= getFilters(); for (int i= 0; i < filters.length; i++) { result= filters[i].filter(this, parent, result); if (result.length == 0) return true; } return false; } }; class LexicalSortingAction extends Action { private JavaElementSorter fSorter= new JavaElementSorter(); public LexicalSortingAction() { super(); setText(JavaEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$ boolean checked= JavaPlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$ valueChanged(checked, false); } public void run() { valueChanged(isChecked(), true); } private void valueChanged(boolean on, boolean store) { setChecked(on); fOutlineViewer.setSorter(on ? fSorter : null); setToolTipText(on ? JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip.checked") : JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip.unchecked")); //$NON-NLS-2$ //$NON-NLS-1$ setDescription(on ? JavaEditorMessages.getString("JavaOutlinePage.Sort.description.checked") : JavaEditorMessages.getString("JavaOutlinePage.Sort.description.unchecked")); //$NON-NLS-2$ //$NON-NLS-1$ if (store) JavaPlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$ } }; class FieldFilter extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, Object element) { return !(element instanceof IField); } }; class VisibilityFilter extends ViewerFilter { public final static int PUBLIC= 0; public final static int PROTECTED= 1; public final static int PRIVATE= 2; public final static int DEFAULT= 3; public final static int NOT_STATIC= 4; private int fVisibility; public VisibilityFilter(int visibility) { fVisibility= visibility; } /* * 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces. */ private boolean belongsToInterface(IMember member) { IType type= member.getDeclaringType(); if (type != null) { try { return type.isInterface(); } catch (JavaModelException x) { // ignore } } return false; } public boolean select(Viewer viewer, Object parentElement, Object element) { if ( !(element instanceof IMember)) return true; if (element instanceof IType) { IType type= (IType) element; IJavaElement parent= type.getParent(); if (parent == null) return true; int elementType= parent.getElementType(); if (elementType == IJavaElement.COMPILATION_UNIT || elementType == IJavaElement.CLASS_FILE) return true; } IMember member= (IMember) element; try { int flags= member.getFlags(); switch (fVisibility) { case PUBLIC: /* 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces */ return Flags.isPublic(flags) || belongsToInterface(member); case PROTECTED: return Flags.isProtected(flags); case PRIVATE: return Flags.isPrivate(flags); case DEFAULT: { /* 1GEWBY4: ITPJUI:ALL - filtering incorrect on interfaces */ boolean dflt= !(Flags.isPublic(flags) || Flags.isProtected(flags) || Flags.isPrivate(flags)); return dflt ? !belongsToInterface(member) : dflt; } case NOT_STATIC: return !Flags.isStatic(flags); } } catch (JavaModelException x) { } // unreachable return false; } }; class FilterAction extends Action { private ViewerFilter fFilter; private String fCheckedDesc; private String fUncheckedDesc; private String fCheckedTooltip; private String fUncheckedTooltip; private String fPreferenceKey; public FilterAction(ViewerFilter filter, String label, String checkedDesc, String uncheckedDesc, String checkedTooltip, String uncheckedTooltip, String prefKey) { super(); fFilter= filter; setText(label); fCheckedDesc= checkedDesc; fUncheckedDesc= uncheckedDesc; fCheckedTooltip= checkedTooltip; fUncheckedTooltip= uncheckedTooltip; fPreferenceKey= prefKey; boolean checked= JavaPlugin.getDefault().getPreferenceStore().getBoolean(fPreferenceKey); valueChanged(checked, false); } public void run() { valueChanged(isChecked(), true); } private void valueChanged(boolean on, boolean store) { setChecked(on); if (on) { fOutlineViewer.addFilter(fFilter); setToolTipText(fCheckedTooltip); setDescription(fCheckedDesc); } else { fOutlineViewer.removeFilter(fFilter); setToolTipText(fUncheckedTooltip); setDescription(fUncheckedDesc); } if (store) JavaPlugin.getDefault().getPreferenceStore().setValue(fPreferenceKey, on); } }; private IJavaElement fInput; private String fContextMenuID; private Menu fMenu; private JavaOutlineViewer fOutlineViewer; private JavaEditor fEditor; private ListenerList fSelectionChangedListeners= new ListenerList(); private Hashtable fActions= new Hashtable(); private ContextMenuGroup[] fActionGroups; public JavaOutlinePage(String contextMenuID, JavaEditor editor) { super(); Assert.isNotNull(editor); fContextMenuID= contextMenuID; fEditor= editor; } private void fireSelectionChanged(ISelection selection) { SelectionChangedEvent event= new SelectionChangedEvent(this, selection); Object[] listeners= fSelectionChangedListeners.getListeners(); for (int i= 0; i < listeners.length; ++i) ((ISelectionChangedListener) listeners[i]).selectionChanged(event); } /** * @see IPage#createControl */ public void createControl(Composite parent) { Tree tree= new Tree(parent, SWT.MULTI); JavaElementLabelProvider lprovider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_TYPE); fOutlineViewer= new JavaOutlineViewer(tree); fOutlineViewer.setContentProvider(new ChildrenProvider()); fOutlineViewer.setLabelProvider(lprovider); MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { contextMenuAboutToShow(manager); } }); fMenu= manager.createContextMenu(tree); tree.setMenu(fMenu); fActionGroups= new ContextMenuGroup[] { new GenerateGroup(), new JavaSearchGroup(), new ReorgGroup() }; fOutlineViewer.setInput(fInput); fOutlineViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { fireSelectionChanged(e.getSelection()); } }); fOutlineViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleKeyPressed(e); } }); } public void dispose() { if (fEditor == null) return; fEditor.outlinePageClosed(); fEditor= null; Object[] listeners= fSelectionChangedListeners.getListeners(); for (int i= 0; i < listeners.length; i++) fSelectionChangedListeners.remove(listeners[i]); fSelectionChangedListeners= null; if (fMenu != null && !fMenu.isDisposed()) { fMenu.dispose(); fMenu= null; } super.dispose(); } public Control getControl() { if (fOutlineViewer != null) return fOutlineViewer.getControl(); return null; } public void setInput(IJavaElement inputElement) { fInput= inputElement; if (fOutlineViewer != null) fOutlineViewer.setInput(fInput); } public void select(ISourceReference reference) { if (fOutlineViewer != null) { ISelection s= StructuredSelection.EMPTY; if (reference != null) s= new StructuredSelection(reference); fOutlineViewer.setSelection(s, true); } } public void setAction(String actionID, IAction action) { Assert.isNotNull(actionID); if (action == null) fActions.remove(actionID); else fActions.put(actionID, action); } public IAction getAction(String actionID) { Assert.isNotNull(actionID); return (IAction) fActions.get(actionID); } /** * Convenience method to add the action installed under the given actionID to the * specified group of the menu. */ protected void addAction(IMenuManager menu, String group, String actionID) { IAction action= getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); if (action.isEnabled()) { IMenuManager subMenu= menu.findMenuUsingPath(group); if (subMenu != null) subMenu.add(action); else menu.appendToGroup(group, action); } } } private void addRefactoring(IMenuManager menu){ MenuManager refactoring= new MenuManager(JavaEditorMessages.getString("JavaOutlinePage.ContextMenu.refactoring.label")); //$NON-NLS-1$ ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, fOutlineViewer); if (!refactoring.isEmpty()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring); } private void addOpenPerspectiveItem(IMenuManager menu) { ISelection s= getSelection(); if (s.isEmpty() || ! (s instanceof IStructuredSelection)) return; IStructuredSelection selection= (IStructuredSelection)s; if (selection.size() != 1) return; Object element= selection.getFirstElement(); if (!(element instanceof IType)) return; IType[] input= {(IType)element}; // XXX should get the workbench window form the PartSite IWorkbenchWindow w= JavaPlugin.getActiveWorkbenchWindow(); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new OpenHierarchyPerspectiveItem(w, input)); } protected void contextMenuAboutToShow(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (OrganizeImportsAction.canActionBeAdded(getSelection())) { addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "OrganizeImports"); //$NON-NLS-1$ } addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenImportDeclaration"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_SHOW, "ShowInPackageView"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "DeleteElement"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "ReplaceWithEdition"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_REORGANIZE, "AddEdition"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "AddMethodEntryBreakpoint"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "AddWatchpoint"); //$NON_NLS-1$ ContextMenuGroup.add(menu, fActionGroups, fOutlineViewer); addRefactoring(menu); addOpenPerspectiveItem(menu); } /** * @see Page#setFocus() */ public void setFocus() { if (fOutlineViewer != null) fOutlineViewer.getControl().setFocus(); } /** * @see Page#makeContributions(IMenuManager, IToolBarManager, IStatusLineManager) */ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { if (statusLineManager != null) { StatusBarUpdater updater= new StatusBarUpdater(statusLineManager); addSelectionChangedListener(updater); } Action action= new LexicalSortingAction(); toolBarManager.add(action); action= new FilterAction(new FieldFilter(), JavaEditorMessages.getString("JavaOutlinePage.HideFields.label"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideFields.tooltip.unchecked"), "HideFields.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "fields_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); action= new FilterAction(new VisibilityFilter(VisibilityFilter.NOT_STATIC), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.label"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideStaticMembers.tooltip.unchecked"), "HideStaticMembers.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "static_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); action= new FilterAction(new VisibilityFilter(VisibilityFilter.PUBLIC), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.label"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.description.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.description.unchecked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.tooltip.checked"), JavaEditorMessages.getString("JavaOutlinePage.HideNonePublicMembers.tooltip.unchecked"), "HideNonePublicMembers.isChecked"); //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(action, "public_co.gif"); //$NON-NLS-1$ toolBarManager.add(action); } /** * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) */ public void addSelectionChangedListener(ISelectionChangedListener listener) { fSelectionChangedListeners.add(listener); } /** * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) */ public void removeSelectionChangedListener(ISelectionChangedListener listener) { fSelectionChangedListeners.remove(listener); } /** * @see ISelectionProvider#getSelection() */ public ISelection getSelection() { if (fOutlineViewer == null) return StructuredSelection.EMPTY; return fOutlineViewer.getSelection(); } /** * @see ISelectionProvider#setSelection(ISelection) */ public void setSelection(ISelection selection) { if (fOutlineViewer != null) fOutlineViewer.setSelection(selection); } /** * Checkes whether a given Java element is an inner type. */ private boolean isInnerType(IJavaElement element) { if (element.getElementType() == IJavaElement.TYPE) { IJavaElement parent= element.getParent(); int type= parent.getElementType(); return (type != IJavaElement.COMPILATION_UNIT && type != IJavaElement.CLASS_FILE); } return false; } /** * Handles key events in viewer. */ private void handleKeyPressed(KeyEvent event) { if (event.stateMask != 0) return; IAction action= null; if (event.character == SWT.DEL) action= getAction("DeleteElement"); //$NON-NLS-1$ else if (event.keyCode == SWT.F4) { // Special case since Open Type Hierarchy is no action. OpenTypeHierarchyUtil.open(getSelection(), fEditor.getSite().getWorkbenchWindow()); } if (action != null && action.isEnabled()) action.run(); } }
    5,095
    Bug 5095 template: toarray incorrect
    its defintion should be: (${type}[]) ${collection}.toArray(new ${type}[${collection}.size()]); rather than (${type}[]) ${collection}.toArray(new ${type}[${collection}]);
    resolved fixed
    9a943d1
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T12:16:52Z
    2001-10-19T11:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/Template.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.swt.graphics.Image; /** * A template consiting of a name and a pattern. */ public class Template { private String fName; private String fDescription; private String fContext; private String fPattern; private boolean fEnabled= true; public Template() { this("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } /** * Creates a template. * @param name the name of the template. * @param description the description of the template. * @param context the context in which the template can be applied. * @param pattern the template pattern. */ public Template(String name, String description, String context, String pattern) { fName= new String(name); fDescription= new String(description); fContext= new String(context); fPattern= new String(pattern); } /** * Sets the description of the template. */ public void setDescription(String description) { fDescription= new String(description); } /** * Returns the description of the template. */ public String getDescription() { return new String(fDescription); } /** * Sets the context of the template. */ public void setContext(String context) { fContext= new String(context); } /** * Returns the context in which the cursor was. */ public String getContext() { return new String(fContext); } /** * Sets the name of the template. */ public void setName(String name) { fName= new String(name); } /** * Returns the name of the template. */ public String getName() { return new String(fName); } /** * Returns the image of the template. */ public Image getImage() { if (fContext.equals("javadoc") && fName.startsWith("<")) //$NON-NLS-1$ //$NON-NLS-2$ return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_HTMLTAG); else return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE); } /** * Sets the pattern of the template. */ public void setPattern(String pattern) { fPattern= new String(pattern); } /** * Returns the template pattern. */ public String getPattern() { return new String(fPattern); } /** * Sets the enable state of the template. */ public void setEnabled(boolean enable) { fEnabled= enable; } /** * Returns <code>true</code> if template is enabled, <code>false</code> otherwise. */ public boolean isEnabled() { return fEnabled; } /** * Returns <code>true</code> if template matches the prefix and context, * <code>false</code> otherwise. */ public boolean matches(String prefix, String context) { return fEnabled && fContext.equals(context) && (prefix.length() != 0) && fName.toLowerCase().startsWith(prefix.toLowerCase()); } }
    5,095
    Bug 5095 template: toarray incorrect
    its defintion should be: (${type}[]) ${collection}.toArray(new ${type}[${collection}.size()]); rather than (${type}[]) ${collection}.toArray(new ${type}[${collection}]);
    resolved fixed
    9a943d1
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T12:16:52Z
    2001-10-19T11:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateSet.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.Serializer; import org.apache.xml.serialize.SerializerFactory; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * A user defined template set. */ public class TemplateSet { private static class TemplateComparator implements Comparator { public int compare(Object arg0, Object arg1) { if (arg0 == arg1) return 0; if (arg0 == null) return -1; Template template0= (Template) arg0; Template template1= (Template) arg1; return template0.getName().compareTo(template1.getName()); } } private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$ private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$ private static final String TEMPLATE_TAG= "template"; //$NON-NLS-1$ private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$ private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$ private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$ private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$ private List fTemplates= new ArrayList(); private Comparator fTemplateComparator= new TemplateComparator(); private Template[] fSortedTemplates= new Template[0]; private static TemplateSet fgTemplateSet; public static TemplateSet getInstance() { if (fgTemplateSet == null) fgTemplateSet= create(); return fgTemplateSet; } private static InputStream getDefaultsAsStream() { return TemplateSet.class.getResourceAsStream(DEFAULT_FILE); } private static File getTemplateFile() { IPath path= JavaPlugin.getDefault().getStateLocation(); path= path.append(TEMPLATE_FILE); return path.toFile(); } public TemplateSet() { } private static TemplateSet create() { try { File templateFile= getTemplateFile(); if (!templateFile.exists()) { InputStream inputStream= getDefaultsAsStream(); if (inputStream == null) return new TemplateSet(); if (!templateFile.createNewFile()) return new TemplateSet(); OutputStream outputStream= new FileOutputStream(templateFile); // copy over default templates byte buffer[]= new byte[65536]; while (true) { int bytes= inputStream.read(buffer); if (bytes == -1) break; outputStream.write(buffer, 0, bytes); } inputStream.close(); outputStream.close(); } Assert.isTrue(templateFile.exists()); TemplateSet templateSet= new TemplateSet(); templateSet.addFromStream(new FileInputStream(templateFile)); return templateSet; } catch (IOException e) { JavaPlugin.log(e); return null; } } /** * Resets the template set with the default templates. */ public void restoreDefaults() { clear(); addFromStream(getDefaultsAsStream()); } /** * Resets (reloads) the template set. */ public void reset() { clear(); try { addFromStream(new FileInputStream(getTemplateFile())); } catch (FileNotFoundException e) { JavaPlugin.log(e); } } public boolean addFromStream(InputStream stream) { try { TemplateSet templateSet= new TemplateSet(); DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder parser= factory.newDocumentBuilder(); Document document= parser.parse(new InputSource(stream)); NodeList elements= document.getElementsByTagName(TEMPLATE_TAG); int count= elements.getLength(); for (int i= 0; i != count; i++) { Node node= elements.item(i); NamedNodeMap attributes= node.getAttributes(); if (attributes == null) continue; String name= attributes.getNamedItem(NAME_ATTRIBUTE).getNodeValue(); String description= attributes.getNamedItem(DESCRIPTION_ATTRIBUTE).getNodeValue(); String context= attributes.getNamedItem(CONTEXT_ATTRIBUTE).getNodeValue(); Node enabledNode= attributes.getNamedItem(ENABLED_ATTRIBUTE); boolean enabled= (enabledNode == null) || (enabledNode.getNodeValue().equals("true")); //$NON-NLS-1$ StringBuffer buffer= new StringBuffer(); NodeList children= node.getChildNodes(); for (int j= 0; j != children.getLength(); j++) { String value= children.item(j).getNodeValue(); if (value != null) buffer.append(value); } String pattern= buffer.toString().trim(); Template template= new Template(name, description, context, pattern); template.setEnabled(enabled); add(template); } return true; } catch (ParserConfigurationException e) { JavaPlugin.log(e); } catch (IOException e) { JavaPlugin.log(e); } catch (SAXException e) { JavaPlugin.log(e); } sort(); return false; } /** * Saves the template set. */ public boolean save() { try { fgTemplateSet.saveToStream(new FileOutputStream(getTemplateFile())); return true; } catch (IOException e) { JavaPlugin.log(e); return false; } } /** * Saves the template set as XML. */ public void saveToStream(OutputStream stream) throws IOException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Node root= document.createElement("templates"); // $NON-NLS-1$ //$NON-NLS-1$ document.appendChild(root); for (int i= 0; i != fTemplates.size(); i++) { Template template= (Template) fTemplates.get(i); Node node= document.createElement("template"); // $NON-NLS-1$ //$NON-NLS-1$ root.appendChild(node); NamedNodeMap attributes= node.getAttributes(); Attr name= document.createAttribute(NAME_ATTRIBUTE); name.setValue(template.getName()); attributes.setNamedItem(name); Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE); description.setValue(template.getDescription()); attributes.setNamedItem(description); Attr context= document.createAttribute(CONTEXT_ATTRIBUTE); context.setValue(template.getContext()); attributes.setNamedItem(context); Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE); enabled.setValue(template.isEnabled() ? "true" : "false"); // $NON-NLS-1$ // $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$ attributes.setNamedItem(enabled); Text pattern= document.createTextNode(template.getPattern()); node.appendChild(pattern); } OutputFormat format = new OutputFormat(); format.setPreserveSpace(true); Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$ serializer.asDOMSerializer().serialize(document); } catch (ParserConfigurationException e) { JavaPlugin.log(e); } } /** * Adds a template to the set. */ public void add(Template template) { fTemplates.add(template); sort(); } /** * Removes a template to the set. */ public void remove(Template template) { fTemplates.remove(template); sort(); } /** * Empties the set. */ public void clear() { fTemplates.clear(); sort(); } /** * Returns all templates. */ public Template[] getTemplates() { return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]); } /** * Returns templates matching a prefix. */ public Template[] getMatchingTemplates(String prefix, String partitionType) { Assert.isNotNull(prefix); Assert.isNotNull(partitionType); List results= new ArrayList(fSortedTemplates.length); for (int i= 0; i != fSortedTemplates.length; i++) { Template template= fSortedTemplates[i]; if (template.matches(prefix, partitionType)) results.add(template); } return (Template[]) results.toArray(new Template[results.size()]); } private void sort() { fSortedTemplates= (Template[]) fTemplates.toArray(new Template[fTemplates.size()]); Arrays.sort(fSortedTemplates, fTemplateComparator); } }
    5,099
    Bug 5099 TypeCache duplicated
    TypeCache exists in two packages. Both used!
    resolved fixed
    144f383
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:04:23Z
    2001-10-19T14:00:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TypeCache.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.dialogs; import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IElementChangedListener; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope; import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine; import org.eclipse.jface.operation.IRunnableContext; public class TypeCache{ private static int fgLastStyle= -1; private static List fgTypeList; private static boolean fgIsRegistered= false; // no instances private TypeCache(){ } public static List findTypes(AllTypesSearchEngine engine, int style, IRunnableContext runnableContext, IJavaSearchScope scope) { checkIfOkToReuse(style, scope); if (fgTypeList == null) { fgTypeList= engine.searchTypes(runnableContext, scope, style); if (!fgIsRegistered){ JavaCore.addElementChangedListener(new DeltaListener()); fgIsRegistered= true; } } // must not return null if (fgTypeList == null) return new ArrayList(0); else return fgTypeList; } private static void checkIfOkToReuse(int style, IJavaSearchScope scope) { if (style != fgLastStyle) flushCache(); if (! (scope instanceof JavaWorkspaceScope)) flushCache(); fgLastStyle= style; } private static void flushCache(){ fgTypeList= null; } private static class DeltaListener implements IElementChangedListener { public void elementChanged(ElementChangedEvent event) { if (fgTypeList == null) return; IJavaElementDelta delta= event.getDelta(); IJavaElement element= delta.getElement(); int type= element.getElementType(); if (type == IJavaElement.CLASS_FILE) return; processDelta(delta); } private boolean mustFlush(IJavaElementDelta delta) { if (delta.getKind() != IJavaElementDelta.CHANGED) return true; // if it's a cu we wait if (delta.getElement().getElementType() == IJavaElement.COMPILATION_UNIT) return false; // must be only children if (delta.getFlags() != IJavaElementDelta.F_CHILDREN) return true; // special case: if it's a type then _it_ must be added or removed if (delta.getElement().getElementType() == IJavaElement.TYPE) return false; if ((delta.getAddedChildren() != null) && (delta.getAddedChildren().length != 0)) return true; return false; } /* * returns false iff list is flushed and we can stop processing */ private boolean processDelta(IJavaElementDelta delta) { if (shouldStopProcessing(delta)) return true; if (mustFlush(delta)) { flushCache(); return false; } IJavaElementDelta[] affectedChildren= delta.getAffectedChildren(); if (affectedChildren == null) return true; for (int i= 0; i < affectedChildren.length; i++) { if (!processDelta(affectedChildren[i])) return false; } return true; } private static boolean shouldStopProcessing(IJavaElementDelta delta) { //fix for: 1GEUFCP switch (delta.getElement().getElementType()) { case IJavaElement.CLASS_FILE: case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: return true; default: return false; } } } }
    5,099
    Bug 5099 TypeCache duplicated
    TypeCache exists in two packages. Both used!
    resolved fixed
    144f383
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:04:23Z
    2001-10-19T14:00:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.dialogs; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.util.Assert; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine; import org.eclipse.jdt.internal.ui.util.TypeInfo; import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider; /** * A dialog to select a type from a list of types. */ public class TypeSelectionDialog extends TwoPaneElementSelector { private IRunnableContext fRunnableContext; private IJavaSearchScope fScope; private int fStyle; /** * Constructs a type selection dialog. * @param parent the parent shell. * @param context the runnable context. * @param scope the java search scope. * @param style the widget style. */ public TypeSelectionDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style) { super(parent, new TypeInfoLabelProvider(0), new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_PACKAGE_ONLY + TypeInfoLabelProvider.SHOW_ROOT_POSTFIX)); Assert.isNotNull(context); Assert.isNotNull(scope); fRunnableContext= context; fScope= scope; fStyle= style; setUpperListLabel(JavaUIMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$ setLowerListLabel(JavaUIMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$ } public void create() { if (getFilter() == null) setFilter("A"); //$NON-NLS-1$ super.create(); } /** * @see Window#open() */ public int open() { AllTypesSearchEngine engine= new AllTypesSearchEngine(JavaPlugin.getWorkspace()); List typeList= TypeCache.findTypes(engine, fStyle, fRunnableContext, fScope); if (typeList.isEmpty()) { String title= JavaUIMessages.getString("TypeSelectionDialog.notypes.title"); //$NON-NLS-1$ String message= JavaUIMessages.getString("TypeSelectionDialog.notypes.message"); //$NON-NLS-1$ MessageDialog.openInformation(getShell(), title, message); return CANCEL; } TypeInfo[] typeRefs= (TypeInfo[])typeList.toArray(new TypeInfo[typeList.size()]); setElements(typeRefs); return super.open(); } /** * @see SelectionStatusDialog#computeResult() */ protected void computeResult() { TypeInfo ref= (TypeInfo) getLowerSelectedElement(); if (ref == null) return; try { IType type= ref.resolveType(fScope); if (type == null) { // not a class file or compilation unit String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$ String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); setResult(null); } else { List result= new ArrayList(1); result.add(type); setResult(result); } } catch (JavaModelException e) { String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$ String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); setResult(null); } } }
    5,077
    Bug 5077 org.eclipse.jdt.junit does not compile under Java 1.2.2
    org.eclipse.jdt.junit.internal.LauncherUtil:29 getPath() is not defined in URL
    verified fixed
    0d6659c
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:16:35Z
    2001-10-18T13:00:00Z
    org.eclipse.jdt.junit/Eclipse
    5,077
    Bug 5077 org.eclipse.jdt.junit does not compile under Java 1.2.2
    org.eclipse.jdt.junit.internal.LauncherUtil:29 getPath() is not defined in URL
    verified fixed
    0d6659c
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:16:35Z
    2001-10-18T13:00:00Z
    JUnit/org/eclipse/jdt/junit/internal/LauncherUtil.java
    5,092
    Bug 5092 Open type list - no longer works if ever cancelled during indexing
    Build 205 Attempting to patch a binary project. I manually expanded its sources in a source folder, and then force a refresh from local. Then immediatly, I tried to open the type I wanted to patch, I got a dialog indicating that indexing was still in progress. I then cancelled my action (open type), and got a "No types available". Tried again later. The dialog came up again with "No types available", even though indexing was finished by then. It seems to have cached the empty list, and I remember this bug around 0.9.
    resolved fixed
    0fc6001
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:52:20Z
    2001-10-19T08:26:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/TypeCache.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.util; import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IElementChangedListener; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope; import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine; import org.eclipse.jface.operation.IRunnableContext; /** * Cache used by AllTypesSeachEngine */ class TypeCache{ private static int fgLastStyle= -1; private static List fgTypeList; private static boolean fgIsRegistered= false; //no instances private TypeCache(){ } static List getCachedTypes() { //must not return null if (fgTypeList == null) return new ArrayList(0); else return fgTypeList; } static boolean canReuse(int style, IJavaSearchScope scope){ if (style != fgLastStyle) return false; if (! (scope instanceof JavaWorkspaceScope)) return false; if (fgTypeList == null) return false; return true; } static void flush(){ fgTypeList= null; } static void setConfiguration(int style){ fgLastStyle= style; } static void setCachedTypes(List types){ //copy is passed here - no reason to copy again fgTypeList= types; } static void registerIfNecessary(){ if (fgIsRegistered) return; JavaCore.addElementChangedListener(new DeltaListener()); fgIsRegistered= true; } private static class DeltaListener implements IElementChangedListener { public void elementChanged(ElementChangedEvent event) { if (fgTypeList == null) return; IJavaElementDelta delta= event.getDelta(); IJavaElement element= delta.getElement(); int type= element.getElementType(); if (type == IJavaElement.CLASS_FILE) return; processDelta(delta); } private boolean mustFlush(IJavaElementDelta delta) { if (delta.getKind() != IJavaElementDelta.CHANGED) return true; //if it's a cu we wait if (delta.getElement().getElementType() == IJavaElement.COMPILATION_UNIT) return false; //must be only children if (delta.getFlags() != IJavaElementDelta.F_CHILDREN) return true; //special case: if it's a type then the type itself must be added or removed if (delta.getElement().getElementType() == IJavaElement.TYPE) return false; if ((delta.getAddedChildren() != null) && (delta.getAddedChildren().length != 0)) return true; return false; } /* * returns false iff list is flushed and we can stop processing */ private boolean processDelta(IJavaElementDelta delta) { if (mustStopProcessing(delta)) return true; if (mustFlush(delta)) { flush(); return false; } IJavaElementDelta[] affectedChildren= delta.getAffectedChildren(); if (affectedChildren == null) return true; for (int i= 0; i < affectedChildren.length; i++) { if (!processDelta(affectedChildren[i])) return false; } return true; } private static boolean mustStopProcessing(IJavaElementDelta delta) { int type= delta.getElement().getElementType(); if (type == IJavaElement.CLASS_FILE) return true; if (type == IJavaElement.FIELD) return true; if (type == IJavaElement.METHOD) return true; if (type == IJavaElement.INITIALIZER) return true; if (type == IJavaElement.PACKAGE_DECLARATION) return true; if (type == IJavaElement.IMPORT_CONTAINER) return true; if (type == IJavaElement.IMPORT_DECLARATION) return true; return false; } } }
    5,093
    Bug 5093 Lost exported classpath entries
    Build 205 1. Create new java project 2. Open build path properties 3. Check JRE_LIB so it is exported 4. Press OK 5. Open build path properties again Observe: JRE_LIB is not exported (but it is according to the .classpath) If you press OK without paying attention, you will loose the fact that JRE_LIB was exported.
    resolved fixed
    007faab
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:58:58Z
    2001-10-19T08:26:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TypeCache.java
    5,093
    Bug 5093 Lost exported classpath entries
    Build 205 1. Create new java project 2. Open build path properties 3. Check JRE_LIB so it is exported 4. Press OK 5. Open build path properties again Observe: JRE_LIB is not exported (but it is according to the .classpath) If you press OK without paying attention, you will loose the fact that JRE_LIB was exported.
    resolved fixed
    007faab
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:58:58Z
    2001-10-19T08:26:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaElementInfoPage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.core.resources.IResource; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.JavaUIMessages; /** * This is a dummy PropertyPage for JavaElements. * Copied from the ResourceInfoPage */ public class JavaElementInfoPage extends PropertyPage { protected Control createContents(Composite parent) { // ensure the page has no special buttons noDefaultAndApplyButton(); IJavaElement element= (IJavaElement)getElement(); IResource resource= null; try { resource= element.getUnderlyingResource(); } catch (JavaModelException e) { JavaPlugin.getDefault().logErrorStatus("Creating ElementInfoPage", e.getStatus()); //$NON-NLS-1$ } Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); Label nameLabel= new Label(composite, SWT.NONE); nameLabel.setText(JavaUIMessages.getString("JavaElementInfoPage.nameLabel")); //$NON-NLS-1$ Label nameValueLabel= new Label(composite, SWT.NONE); nameValueLabel.setText(element.getElementName()); if (resource != null) { // path label Label pathLabel= new Label(composite, SWT.NONE); pathLabel.setText(JavaUIMessages.getString("JavaElementInfoPage.resource_path")); //$NON-NLS-1$ // path value label Label pathValueLabel= new Label(composite, SWT.NONE); pathValueLabel.setText(resource.getFullPath().toString()); } if (element instanceof ICompilationUnit) { ICompilationUnit unit= (ICompilationUnit)element; Label packageLabel= new Label(composite, SWT.NONE); packageLabel.setText(JavaUIMessages.getString("JavaElementInfoPage.package")); //$NON-NLS-1$ Label packageName= new Label(composite, SWT.NONE); packageName.setText(unit.getParent().getElementName()); } if (element instanceof IPackageFragment) { IPackageFragment packageFragment= (IPackageFragment)element; Label packageContents= new Label(composite, SWT.NONE); packageContents.setText(JavaUIMessages.getString("JavaElementInfoPage.package_contents")); //$NON-NLS-1$ Label packageContentsType= new Label(composite, SWT.NONE); try { if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE) packageContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.source")); //$NON-NLS-1$ else packageContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.binary")); //$NON-NLS-1$ } catch (JavaModelException e) { packageContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.not_present")); //$NON-NLS-1$ } } if (element instanceof IPackageFragmentRoot) { Label rootContents= new Label(composite, SWT.NONE); rootContents.setText(JavaUIMessages.getString("JavaElementInfoPage.classpath_entry_kind")); //$NON-NLS-1$ Label rootContentsType= new Label(composite, SWT.NONE); try { IClasspathEntry entry= JavaModelUtil.getRawClasspathEntry((IPackageFragmentRoot)element); if (entry != null) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.source")); break; //$NON-NLS-1$ case IClasspathEntry.CPE_PROJECT: rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.project")); break; //$NON-NLS-1$ case IClasspathEntry.CPE_LIBRARY: rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.library")); break; //$NON-NLS-1$ case IClasspathEntry.CPE_VARIABLE: rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.variable")); //$NON-NLS-1$ Label varPath= new Label(composite, SWT.NONE); varPath.setText(JavaUIMessages.getString("JavaElementInfoPage.variable_path")); //$NON-NLS-1$ Label varPathVar= new Label(composite, SWT.NONE); varPathVar.setText(entry.getPath().makeRelative().toString()); break; } } else { rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.not_present")); //$NON-NLS-1$ } } catch (JavaModelException e) { rootContentsType.setText(JavaUIMessages.getString("JavaElementInfoPage.not_present")); //$NON-NLS-1$ } } return composite; } /** */ protected boolean doOk() { // nothing to do - read-only page return true; } }
    5,093
    Bug 5093 Lost exported classpath entries
    Build 205 1. Create new java project 2. Open build path properties 3. Check JRE_LIB so it is exported 4. Press OK 5. Open build path properties again Observe: JRE_LIB is not exported (but it is according to the .classpath) If you press OK without paying attention, you will loose the fact that JRE_LIB was exported.
    resolved fixed
    007faab
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T13:58:58Z
    2001-10-19T08:26:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementSorter.java
    package org.eclipse.jdt.internal.ui.viewsupport; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IInitializer; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * Sorts Java elements: * Package fragment roots are sorted as ordered in the classpath. */ public class JavaElementSorter extends ViewerSorter { private static final int CU_MEMBERS= 0; private static final int INNER_TYPES= 1; private static final int CONSTRUCTORS= 2; private static final int STATIC_INIT= 3; private static final int STATIC_METHODS= 4; private static final int INIT= 5; private static final int METHODS= 6; private static final int STATIC_FIELDS= 7; private static final int FIELDS= 8; private static final int JAVAELEMENTS= 9; private static final int PACKAGEFRAGMENTROOT= 10; private static final int RESOURCEPACKAGES= 11; private static final int RESOURCEFOLDERS= 12; private static final int RESOURCES= 13; private static final int STORAGE= 14; private static final int OTHERS= 20; private IClasspathEntry[] fClassPath; /* * @see ViewerSorter#sort */ public void sort(Viewer v, Object[] property) { fClassPath= null; try { super.sort(v, property); } finally { fClassPath= null; } } /* * @see ViewerSorter#isSorterProperty */ public boolean isSorterProperty(Object element, Object property) { return true; } /* * @see ViewerSorter#category */ public int category(Object element) { if (element instanceof IJavaElement) { try { IJavaElement je= (IJavaElement) element; switch (je.getElementType()) { case IJavaElement.METHOD: { IMethod method= (IMethod) je; if (method.isConstructor()) return CONSTRUCTORS; int flags= method.getFlags(); return Flags.isStatic(flags) ? STATIC_METHODS : METHODS; } case IJavaElement.FIELD: { int flags= ((IField) je).getFlags(); return Flags.isStatic(flags) ? STATIC_FIELDS : FIELDS; } case IJavaElement.INITIALIZER: { int flags= ((IInitializer) je).getFlags(); return Flags.isStatic(flags) ? STATIC_INIT : INIT; } case IJavaElement.TYPE: { if (((IType)element).getDeclaringType() != null) { return INNER_TYPES; } else { return CU_MEMBERS; } } case IJavaElement.PACKAGE_DECLARATION: return CU_MEMBERS; case IJavaElement.IMPORT_CONTAINER: return CU_MEMBERS; case IJavaElement.PACKAGE_FRAGMENT: IPackageFragment pack= (IPackageFragment) je; if (!pack.hasChildren() && pack.getNonJavaResources().length > 0) { return RESOURCEPACKAGES; } if (pack.getParent().getUnderlyingResource() instanceof IProject) { return PACKAGEFRAGMENTROOT; } break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: return PACKAGEFRAGMENTROOT; } } catch (JavaModelException x) { JavaPlugin.log(x); } return JAVAELEMENTS; } else if (element instanceof IFile) { return RESOURCES; } else if (element instanceof IContainer) { return RESOURCEFOLDERS; } else if (element instanceof IStorage) { return STORAGE; } return OTHERS; } /* * @see ViewerSorter#compare */ public int compare(Viewer viewer, Object e1, Object e2) { int cat1= category(e1); int cat2= category(e2); if (cat1 != cat2) return cat1 - cat2; switch (cat1) { case OTHERS: // unknown return 0; case CU_MEMBERS: // do not sort elements in CU or ClassFiles return 0; case PACKAGEFRAGMENTROOT: int p1= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e1)); int p2= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e2)); return p2 - p1; case STORAGE: return ((IStorage)e1).getName().compareToIgnoreCase(((IStorage)e2).getName()); case RESOURCES: case RESOURCEFOLDERS: return ((IResource)e1).getName().compareToIgnoreCase(((IResource)e2).getName()); case RESOURCEPACKAGES: return ((IJavaElement)e1).getElementName().compareToIgnoreCase(((IJavaElement)e2).getElementName()); default: return ((IJavaElement)e1).getElementName().compareTo(((IJavaElement)e2).getElementName()); } } private int getClassPathIndex(IPackageFragmentRoot root) { try { if (fClassPath == null) fClassPath= root.getJavaProject().getResolvedClasspath(true); } catch (JavaModelException e) { return 0; } for (int i= 0; i < fClassPath.length; i++) { if (fClassPath[i].getPath().equals(root.getPath())) return i; } return 0; } };
    4,978
    Bug 4978 Completion list not ordered as expected
    Type "fo" and press ctrl-space The best matches are the "for" templates but they are at the end of the list
    resolved fixed
    e607857
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T14:41:16Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TemplatePreferencePage.java
    package org.eclipse.jdt.internal.ui.preferences; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.template.Template; import org.eclipse.jdt.internal.ui.text.template.TemplateContentProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateContext; import org.eclipse.jdt.internal.ui.text.template.TemplateLabelProvider; import org.eclipse.jdt.internal.ui.text.template.TemplateMessages; import org.eclipse.jdt.internal.ui.text.template.TemplateSet; import org.eclipse.jdt.internal.ui.util.SWTUtil; public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // preference store keys private static final String PREF_FORMAT_TEMPLATES= JavaUI.ID_PLUGIN + ".template.format"; //$NON-NLS-1$ private CheckboxTableViewer fTableViewer; private Button fAddButton; private Button fEditButton; private Button fImportButton; private Button fExportButton; private Button fExportAllButton; private Button fRemoveButton; private Button fEnableAllButton; private Button fDisableAllButton; private SourceViewer fPatternViewer; private Button fFormatButton; public TemplatePreferencePage() { super(); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$ } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent= new Composite(ancestor, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; parent.setLayout(layout); fTableViewer= new CheckboxTableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Table table= fTableViewer.getTable(); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= convertWidthInCharsToPixels(80); data.heightHint= convertHeightInCharsToPixels(10); fTableViewer.getTable().setLayoutData(data); table.setHeaderVisible(true); table.setLinesVisible(true); TableLayout tableLayout= new TableLayout(); table.setLayout(tableLayout); TableColumn column1= table.getColumn(0); column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$ TableColumn column2= new TableColumn(table, SWT.NULL); column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.context")); //$NON-NLS-1$ TableColumn column3= new TableColumn(table, SWT.NULL); column3.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); tableLayout.addColumnData(new ColumnWeightData(20)); tableLayout.addColumnData(new ColumnWeightData(70)); fTableViewer.setLabelProvider(new TemplateLabelProvider()); fTableViewer.setContentProvider(new TemplateContentProvider(fTableViewer, TemplateSet.getInstance())); fTableViewer.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left= (Template) object1; Template right= (Template) object2; int result= left.getName().compareToIgnoreCase(right.getName()); if (result != 0) return result; return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); } public boolean isSorterProperty(Object element, String property) { return true; } }); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { selectionChanged1(); } }); fTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { Template template= (Template) event.getElement(); template.setEnabled(event.getChecked()); } }); Composite buttons= new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; buttons.setLayout(layout); fAddButton= new Button(buttons, SWT.PUSH); fAddButton.setLayoutData(getButtonGridData(fAddButton)); fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$ fAddButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { add(); } }); fEditButton= new Button(buttons, SWT.PUSH); fEditButton.setLayoutData(getButtonGridData(fEditButton)); fEditButton.setText(TemplateMessages.getString("TemplatePreferencePage.edit")); //$NON-NLS-1$ fEditButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { edit(); } }); fImportButton= new Button(buttons, SWT.PUSH); fImportButton.setLayoutData(getButtonGridData(fImportButton)); fImportButton.setText(TemplateMessages.getString("TemplatePreferencePage.import")); //$NON-NLS-1$ fImportButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { import_(); } }); fExportButton= new Button(buttons, SWT.PUSH); fExportButton.setLayoutData(getButtonGridData(fExportButton)); fExportButton.setText(TemplateMessages.getString("TemplatePreferencePage.export")); //$NON-NLS-1$ fExportButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { export(); } }); fExportAllButton= new Button(buttons, SWT.PUSH); fExportAllButton.setLayoutData(getButtonGridData(fExportButton)); fExportAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.export.all")); //$NON-NLS-1$ fExportAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { exportAll(); } }); fRemoveButton= new Button(buttons, SWT.PUSH); fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton)); fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$ fRemoveButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); fEnableAllButton= new Button(buttons, SWT.PUSH); fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton)); fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$ fEnableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(true); } }); fDisableAllButton= new Button(buttons, SWT.PUSH); fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton)); fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$ fDisableAllButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { enableAll(false); } }); fPatternViewer= createViewer(parent); fFormatButton= new Button(parent, SWT.CHECK); fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$ IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES)); fTableViewer.setInput(TemplateSet.getInstance()); fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); updateButtons(); // XXX WorkbenchHelp.setHelp(parent, new DialogPageContextComputer(this, IJavaHelpContextIds.JRE_PREFERENCE_PAGE)); return parent; } private Template[] getEnabledTemplates() { Template[] templates= TemplateSet.getInstance().getTemplates(); List list= new ArrayList(templates.length); for (int i= 0; i != templates.length; i++) if (templates[i].isEnabled()) list.add(templates[i]); return (Template[]) list.toArray(new Template[list.size()]); } private SourceViewer createViewer(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER /*| SWT.V_SCROLL | SWT.H_SCROLL*/); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(false); viewer.setDocument(new Document()); Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); Control control= viewer.getControl(); GridData data= new GridData(GridData.FILL_BOTH); data.heightHint= convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; } private static GridData getButtonGridData(Button button) { GridData data= new GridData(GridData.FILL_HORIZONTAL); data.widthHint= SWTUtil.getButtonWidthHint(button); data.heightHint= SWTUtil.getButtonHeigthHint(button); return data; } private void selectionChanged1() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); if (selection.size() == 1) { Template template= (Template) selection.getFirstElement(); fPatternViewer.getTextWidget().setText(template.getPattern()); } else { fPatternViewer.getTextWidget().setText(""); //$NON-NLS-1$ } updateButtons(); } private void updateButtons() { int selectionCount= ((IStructuredSelection) fTableViewer.getSelection()).size(); int itemCount= fTableViewer.getTable().getItemCount(); fEditButton.setEnabled(selectionCount == 1); fExportButton.setEnabled(selectionCount > 0); fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount); fEnableAllButton.setEnabled(itemCount > 0); fDisableAllButton.setEnabled(itemCount > 0); } private void add() { Template template= new Template(); template.setContext(TemplateContext.JAVA); //$NON-NLS-1$ EditTemplateDialog dialog= new EditTemplateDialog(getShell(), template, false); if (dialog.open() == dialog.OK) { TemplateSet.getInstance().add(template); fTableViewer.refresh(); fTableViewer.setChecked(template, template.isEnabled()); fTableViewer.setSelection(new StructuredSelection(template)); } } private void edit() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Template template= (Template) selection.getFirstElement(); EditTemplateDialog dialog= new EditTemplateDialog(getShell(), template, true); if (dialog.open() == dialog.OK) { fTableViewer.refresh(template); fTableViewer.setChecked(template, template.isEnabled()); fTableViewer.setSelection(new StructuredSelection(template)); } } private void import_() { FileDialog dialog= new FileDialog(getShell()); dialog.setText(TemplateMessages.getString("TemplatePreferencePage.import.title")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {TemplateMessages.getString("TemplatePreferencePage.import.extension")}); //$NON-NLS-1$ String path= dialog.open(); if (path == null) return; try { FileInputStream stream= new FileInputStream(path); TemplateSet.getInstance().addFromStream(stream); fTableViewer.refresh(); fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); } catch (IOException e) { JavaPlugin.log(e); MessageDialog.openError(getShell(), TemplateMessages.getString("TemplatePreferencePage.error.import"), e.getMessage()); //$NON-NLS-1$ } } private void exportAll() { export(TemplateSet.getInstance()); } private void export() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Object[] templates= selection.toArray(); TemplateSet templateSet= new TemplateSet(); for (int i= 0; i != templates.length; i++) templateSet.add((Template) templates[i]); export(templateSet); } private void export(TemplateSet templateSet) { FileDialog dialog= new FileDialog(getShell(), SWT.SAVE); dialog.setText(TemplateMessages.getFormattedString("TemplatePreferencePage.export.title", new Integer(templateSet.getTemplates().length))); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {TemplateMessages.getString("TemplatePreferencePage.export.extension")}); //$NON-NLS-1$ dialog.setFileName(TemplateMessages.getString("TemplatePreferencePage.export.filename")); //$NON-NLS-1$ String path= dialog.open(); if (path == null) return; try { FileOutputStream stream= new FileOutputStream(path); templateSet.saveToStream(stream); } catch (IOException e) { JavaPlugin.log(e); MessageDialog.openError(getShell(), TemplateMessages.getString("TemplatePreferencePage.error.export"), e.getMessage()); //$NON-NLS-1$ } } private void remove() { IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection(); Iterator elements= selection.iterator(); while (elements.hasNext()) { Template template= (Template) elements.next(); TemplateSet.getInstance().remove(template); } fTableViewer.refresh(); } private void enableAll(boolean enable) { Template[] templates= TemplateSet.getInstance().getTemplates(); for (int i= 0; i != templates.length; i++) templates[i].setEnabled(enable); fTableViewer.setAllChecked(enable); } /* * @see IWorkbenchPreferencePage#init(IWorkbench) */ public void init(IWorkbench workbench) {} /* * @see Control#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$ } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES)); TemplateSet.getInstance().restoreDefaults(); fTableViewer.refresh(); // manually refresh checks fTableViewer.setAllChecked(false); fTableViewer.setCheckedElements(getEnabledTemplates()); } /* * @see PreferencePage#performOk() */ public boolean performOk() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection()); TemplateSet.getInstance().save(); return super.performOk(); } /* * @see PreferencePage#performCancel() */ public boolean performCancel() { TemplateSet.getInstance().reset(); return super.performCancel(); } /** * Initializes the default values of this page in the preference bundle. * Will be called on startup of the JavaPlugin */ public static void initDefaults(IPreferenceStore prefs) { prefs.setDefault(PREF_FORMAT_TEMPLATES, true); } public static boolean useCodeFormatter() { IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore(); return prefs.getBoolean(PREF_FORMAT_TEMPLATES); } }
    4,978
    Bug 4978 Completion list not ordered as expected
    Type "fo" and press ctrl-space The best matches are the "for" templates but they are at the end of the list
    resolved fixed
    e607857
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T14:41:16Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.template.TemplateEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; /** * Java completion processor. */ public class JavaCompletionProcessor implements IContentAssistProcessor { private IEditorPart fEditor; private ResultCollector fCollector; private IWorkingCopyManager fManager; private IContextInformationValidator fValidator; private TemplateEngine fTemplateEngine; public JavaCompletionProcessor(IEditorPart editor) { fEditor= editor; fCollector= new ResultCollector(); fManager= JavaPlugin.getDefault().getWorkingCopyManager(); fTemplateEngine= new TemplateEngine(TemplateEngine.JAVA); //$NON-NLS-1$ } /** * @see IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { return fCollector.getErrorMessage(); } /** * @see IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { if (fValidator == null) fValidator= new JavaParameterListValidator(); return fValidator; } /** * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return new char[] { '.', '(' }; } /** * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { return null; } /** * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); IDocument document= viewer.getDocument(); try { if (unit != null) { fCollector.reset(unit.getJavaProject(), unit); Point selection= viewer.getSelectedRange(); if (selection.y > 0) fCollector.setRegionToReplace(selection.x, selection.y); unit.codeComplete(offset, fCollector); } } catch (JavaModelException x) { Shell shell= viewer.getTextWidget().getShell(); ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$ } ICompletionProposal[] results= fCollector.getResults(); try { if (unit != null) { fTemplateEngine.reset(viewer); fTemplateEngine.complete(unit, offset); } } catch (JavaModelException x) { Shell shell= viewer.getTextWidget().getShell(); ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$ } ICompletionProposal[] exactTemplateResults= fTemplateEngine.getExactResults(); ICompletionProposal[] notExactTemplateResults= fTemplateEngine.getNotExactResults(); // concatenate arrays ICompletionProposal[] total= new ICompletionProposal[results.length + exactTemplateResults.length + notExactTemplateResults.length]; System.arraycopy(exactTemplateResults, 0, total, 0, exactTemplateResults.length); System.arraycopy(results, 0, total, exactTemplateResults.length, results.length); System.arraycopy(notExactTemplateResults, 0, total, exactTemplateResults.length + results.length, notExactTemplateResults.length); return total; } }
    4,978
    Bug 4978 Completion list not ordered as expected
    Type "fo" and press ctrl-space The best matches are the "for" templates but they are at the end of the list
    resolved fixed
    e607857
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T14:41:16Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocCompletionProcessor.java
    package org.eclipse.jdt.internal.ui.text.javadoc; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.template.TemplateEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; /** * Simple Java doc completion processor. */ public class JavaDocCompletionProcessor implements IContentAssistProcessor { private IEditorPart fEditor; private IWorkingCopyManager fManager; private TemplateEngine fTemplateEngine; public JavaDocCompletionProcessor(IEditorPart editor) { fEditor= editor; fManager= JavaPlugin.getDefault().getWorkingCopyManager(); fTemplateEngine= new TemplateEngine(TemplateEngine.JAVADOC); //$NON-NLS-1$ } /** * @see IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { return null; } /** * @see IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { return null; } /** * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return null; } /** * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { return null; } /** * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); IDocument document= viewer.getDocument(); ICompletionProposal[] results= new ICompletionProposal[0]; try { if (unit != null) { int offset= documentOffset; int length= 0; Point selection= viewer.getSelectedRange(); if (selection.y > 0) { offset= selection.x; length= selection.y; } CompletionEvaluator evaluator= new CompletionEvaluator(unit, document, offset, length); results= evaluator.computeProposals(); } } catch (JavaModelException x) { } try { if (unit != null) { fTemplateEngine.reset(viewer); fTemplateEngine.complete(unit, documentOffset); } } catch (JavaModelException x) { } ICompletionProposal[] exactTemplateResults= fTemplateEngine.getExactResults(); ICompletionProposal[] notExactTemplateResults= fTemplateEngine.getNotExactResults(); // concatenate arrays ICompletionProposal[] total= new ICompletionProposal[results.length + exactTemplateResults.length + notExactTemplateResults.length]; System.arraycopy(exactTemplateResults, 0, total, 0, exactTemplateResults.length); System.arraycopy(results, 0, total, exactTemplateResults.length, results.length); System.arraycopy(notExactTemplateResults, 0, total, exactTemplateResults.length + results.length, notExactTemplateResults.length); return total; } }
    4,978
    Bug 4978 Completion list not ordered as expected
    Type "fo" and press ctrl-space The best matches are the "for" templates but they are at the end of the list
    resolved fixed
    e607857
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T14:41:16Z
    2001-10-15T12:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateEngine.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.ITextViewer; public class TemplateEngine { private static final char ARGUMENTS_BEGIN= '('; private static final char ARGUMENTS_END= ')'; private static final char HTML_TAG_BEGIN= '<'; private static final char HTML_TAG_END= '>'; private static final char JAVADOC_TAG_BEGIN= '@'; /** * Partition types. */ public static String JAVA= "java"; // $NON-NLS-1$ //$NON-NLS-1$ public static String JAVADOC= "javadoc"; // $NON-NLS-1$ //$NON-NLS-1$ private String fPartitionType; private ITextViewer fViewer; private ArrayList fExactProposals= new ArrayList(); private ArrayList fNotExactProposals= new ArrayList(); public TemplateEngine(String partitionType) { Assert.isNotNull(partitionType); fPartitionType= new String(partitionType); } /** * Empties the collector. */ public void reset(ITextViewer viewer) { fViewer= viewer; fExactProposals.clear(); fNotExactProposals.clear(); } /** * Returns an array of templates matching exactly. */ public ICompletionProposal[] getExactResults() { return (ICompletionProposal[]) fExactProposals.toArray(new ICompletionProposal[fExactProposals.size()]); } /** * Returns an array of templates matching not exactly. */ public ICompletionProposal[] getNotExactResults() { return (ICompletionProposal[]) fNotExactProposals.toArray(new ICompletionProposal[fNotExactProposals.size()]); } /** * Inspects the context of the compilation unit around <code>completionPosition</code> * and feeds the collector with proposals. * @param collector the collector for template proposals. * @param sourceUnit the compilation unit. * @param completionPosition the context position in the compilation unit. */ public void complete(ICompilationUnit sourceUnit, int completionPosition) throws JavaModelException { String source= sourceUnit.getSource(); // inspect context int end = completionPosition; int start= guessStart(source, end, fPartitionType); // handle optional argument String request= source.substring(start, end); int index= request.indexOf(ARGUMENTS_BEGIN); String key; String[] arguments; if (index == -1) { key= request; arguments= null; } else { key= request.substring(0, index); String allArguments= request.substring(index + 1, request.length() - 1); List list= new ArrayList(); StringTokenizer tokenizer= new StringTokenizer(allArguments, ","); // $NON-NLS-1$ //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String token= tokenizer.nextToken().trim(); list.add(token); } arguments= (String[]) list.toArray(new String[list.size()]); } Template[] templates= TemplateSet.getInstance().getMatchingTemplates(key, fPartitionType); TemplateContext context= new TemplateContext(sourceUnit, start, end, fViewer); for (int i= 0; i != templates.length; i++) { TemplateProposal proposal= new TemplateProposal(templates[i], arguments, context); if (templates[i].getName().equals(key)) { fExactProposals.add(proposal); } else { fNotExactProposals.add(proposal); } } } private static final int guessStart(String source, int end, String partitionType) { int start= end; if (partitionType.equals(JAVA)) { // optional arguments if ((start != 0) && (source.charAt(start - 1) == ARGUMENTS_END)) { start--; while ((start != 0) && (source.charAt(start - 1) != ARGUMENTS_BEGIN)) start--; start--; if ((start != 0) && Character.isWhitespace(source.charAt(start - 1))) start--; } while ((start != 0) && Character.isUnicodeIdentifierPart(source.charAt(start - 1))) start--; if ((start != 0) && Character.isUnicodeIdentifierStart(source.charAt(start - 1))) start--; } else if (partitionType.equals(JAVADOC)) { // javadoc tag if ((start != 0) && (source.charAt(start - 1) == HTML_TAG_END)) start--; while ((start != 0) && Character.isUnicodeIdentifierPart(source.charAt(start - 1))) start--; if ((start != 0) && Character.isUnicodeIdentifierStart(source.charAt(start - 1))) start--; // include html and javadoc tags if ((start != 0) && (source.charAt(start - 1) == HTML_TAG_BEGIN) || (source.charAt(start - 1) == JAVADOC_TAG_BEGIN)) { start--; } } return start; } }
    5,052
    Bug 5052 Scrolling to the top of page when synching packages view
    Eclipse 200011011 0) Turn on the preference "Link packages view selection to the active editor". 1) Perform a java search on something that will have at least one result. 2) Look at the search and pick a class in the list of results. 3) Go to the packages view and make sure that a) the packages view is open, visible and not stacked with the search view and b) the class selected in the packages view is not the class you picked in step 2. 4) In the search view, click on the entry for the class you selected in step 2. Notice: The editor for that class is opened. The editor is scrolled to the line matching the search result. 5) Click on the editor. Notice: The editor scrolls up to the top of the file and you can no longer see the place where the search pointed. Note: you will only see the problem if the search result points you to somewhere below the first page of the class definition. What I believe is going on is that when you click on the editor in step 5 that editor becomes the active editor and the packages view tries to synch up. As part of synching up with the packages view, the editor is scrolled to the top of the file. I do not think that synching up bewteen the active editor and the packages view should cause the editor to scroll to the top. Why can't the file stay at its current scroll position. I have seen this scrolling in other scenarios as well and it causes me to have to re-locate the place I wanted to edit. In the end I just am forced to turn off "Link packages view selection to the active editor" but then I am frustrated when I want to do something such as compare with another version and I have to go hunt for the class in the packages view.
    resolved fixed
    0690660
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-19T19:04:10Z
    2001-10-17T20:20:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.packageview; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory; import org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction; import org.eclipse.jdt.internal.ui.dnd.DelegatingDragAdapter; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer; import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener; import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput; import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage; import org.eclipse.jdt.internal.ui.IPreferencesConstants; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringAction; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup; import org.eclipse.jdt.internal.ui.refactoring.actions.StructuredSelectionProvider; import org.eclipse.jdt.internal.ui.reorg.DeleteAction; import org.eclipse.jdt.internal.ui.reorg.ReorgGroup; import org.eclipse.jdt.internal.ui.search.JavaSearchGroup; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementSorter; import org.eclipse.jdt.internal.ui.viewsupport.MarkerErrorTickProvider; import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.ui.wizards.NewGroup; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.IPackagesViewPart; import org.eclipse.jdt.ui.JavaElementContentProvider; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeViewerListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSource; import org.eclipse.swt.dnd.FileTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.OpenPerspectiveMenu; import org.eclipse.ui.actions.OpenWithMenu; import org.eclipse.ui.actions.RefreshAction; import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.help.ViewContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.ISetSelectionTarget; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.views.internal.framelist.BackAction; import org.eclipse.ui.views.internal.framelist.ForwardAction; import org.eclipse.ui.views.internal.framelist.FrameList; import org.eclipse.ui.views.internal.framelist.GoIntoAction; import org.eclipse.ui.views.internal.framelist.UpAction; /** * The ViewPart for the ProjectExplorer. It listens to part activation events. * When selection linking with the editor is enabled the view selection tracks * the active editor page. Similarly when a resource is selected in the packages * view the corresponding editor is activated. */ public class PackageExplorerPart extends ViewPart implements ISetSelectionTarget, IMenuListener, IPackagesViewPart, IPropertyChangeListener { public final static String VIEW_ID= JavaUI.ID_PACKAGES; // Persistance tags. static final String TAG_SELECTION= "selection"; //$NON-NLS-1$ static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$ static final String TAG_ELEMENT= "element"; //$NON-NLS-1$ static final String TAG_PATH= "path"; //$NON-NLS-1$ static final String TAG_VERTICAL_POSITION= "verticalPosition"; //$NON-NLS-1$ static final String TAG_HORIZONTAL_POSITION= "horizontalPosition"; //$NON-NLS-1$ static final String TAG_FILTERS = "filters"; //$NON-NLS-1$ static final String TAG_FILTER = "filter"; //$NON-NLS-1$ static final String TAG_SHOWLIBRARIES = "showLibraries"; //$NON-NLS-1$ static final String TAG_SHOWBINARIES = "showBinaries"; //$NON-NLS-1$ private JavaElementPatternFilter fPatternFilter= new JavaElementPatternFilter(); private LibraryFilter fLibraryFilter= new LibraryFilter(); private BinaryProjectFilter fBinaryFilter= new BinaryProjectFilter(); private ProblemTreeViewer fViewer; private PackagesFrameSource fFrameSource; private FrameList fFrameList; private ContextMenuGroup[] fStandardGroups; private Menu fContextMenu; private OpenResourceAction fOpenCUAction; private Action fOpenToAction; private Action fShowTypeHierarchyAction; private Action fShowNavigatorAction; private Action fPropertyDialogAction; private RefactoringAction fDeleteAction; private RefreshAction fRefreshAction; private BackAction fBackAction; private ForwardAction fForwardAction; private GoIntoAction fZoomInAction; private UpAction fUpAction; private GotoTypeAction fGotoTypeAction; private GotoPackageAction fGotoPackageAction; private AddBookmarkAction fAddBookmarkAction; private FilterSelectionAction fFilterAction; private ShowLibrariesAction fShowLibrariesAction; private ShowBinariesAction fShowBinariesAction; private IMemento fMemento; private IPartListener fPartListener= new IPartListener() { public void partActivated(IWorkbenchPart part) { if (part instanceof IEditorPart) editorActivated((IEditorPart) part); } public void partBroughtToTop(IWorkbenchPart part) { } public void partClosed(IWorkbenchPart part) { } public void partDeactivated(IWorkbenchPart part) { } public void partOpened(IWorkbenchPart part) { } }; private ITreeViewerListener fExpansionListener= new ITreeViewerListener() { public void treeCollapsed(TreeExpansionEvent event) { } public void treeExpanded(TreeExpansionEvent event) { Object element= event.getElement(); if (element instanceof ICompilationUnit || element instanceof IClassFile) expandMainType(element); } }; public PackageExplorerPart() { } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento= memento; } /** * Initializes the default preferences */ public static void initDefaults(IPreferenceStore store) { store.setDefault(TAG_SHOWLIBRARIES, true); store.setDefault(TAG_SHOWBINARIES, true); } /** * Returns the package explorer part of the active perspective. If * there isn't any package explorer part <code>null</code> is returned. */ public static PackageExplorerPart getFromActivePerspective() { IViewPart view= JavaPlugin.getActivePage().findView(VIEW_ID); if (view instanceof PackageExplorerPart) return (PackageExplorerPart)view; return null; } /** * Makes the package explorer part visible in the active perspective. If there * isn't a package explorer part registered <code>null</code> is returned. * Otherwise the opened view part is returned. */ public static PackageExplorerPart openInActivePerspective() { try { return (PackageExplorerPart)JavaPlugin.getActivePage().showView(VIEW_ID); } catch(PartInitException pe) { return null; } } public void dispose() { if (fViewer != null) JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fViewer); if (fContextMenu != null && !fContextMenu.isDisposed()) fContextMenu.dispose(); getSite().getPage().removePartListener(fPartListener); JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); if (fViewer != null) fViewer.removeTreeListener(fExpansionListener); super.dispose(); } /** * Implementation of IWorkbenchPart.createPartControl(Composite) */ public void createPartControl(Composite parent) { fViewer= new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); boolean showCUChildren= JavaBasePreferencePage.showCompilationUnitChildren(); fViewer.setContentProvider(new JavaElementContentProvider(showCUChildren)); JavaPlugin.getDefault().getProblemMarkerManager().addListener(fViewer); JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_VARIABLE | JavaElementLabelProvider.SHOW_PARAMETERS; JavaElementLabelProvider labelProvider = new JavaElementLabelProvider(labelFlags); labelProvider.setErrorTickManager(new MarkerErrorTickProvider()); fViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, null)); fViewer.setSorter(new JavaElementSorter()); fViewer.addFilter(new EmptyInnerPackageFilter()); fViewer.setUseHashlookup(true); fViewer.addFilter(fPatternFilter); fViewer.addFilter(fLibraryFilter); fViewer.addFilter(fBinaryFilter); if(fMemento != null) restoreFilters(); else initFilterFromPreferences(); // Set input after filter and sorter has been set. This avoids resorting // and refiltering. fViewer.setInput(findInputElement()); initDragAndDrop(); initFrameList(); initRefreshKey(); updateTitle(); MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(this); fContextMenu= menuMgr.createContextMenu(fViewer.getTree()); fViewer.getTree().setMenu(fContextMenu); getSite().registerContextMenu(menuMgr, fViewer); makeActions(); // call before registering for selection changes fViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged(event); } }); fViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { handleDoubleClick(event); } }); fViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleKeyPressed(e); } }); getSite().setSelectionProvider(fViewer); getSite().getPage().addPartListener(fPartListener); IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager(); fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager)); fViewer.addTreeListener(fExpansionListener); if (fMemento != null) restoreState(fMemento); fMemento= null; // Set help for the view // fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing WorkbenchHelp.setHelp(fViewer.getControl(), new ViewContextComputer(this, IJavaHelpContextIds.PACKAGE_VIEW)); fillActionBars(); } private void fillActionBars() { IActionBars actionBars= getViewSite().getActionBars(); IToolBarManager toolBar= actionBars.getToolBarManager(); toolBar.add(fBackAction); toolBar.add(fForwardAction); toolBar.add(fUpAction); actionBars.updateActionBars(); IMenuManager menu = actionBars.getMenuManager(); menu.add(fFilterAction); menu.add(fShowLibrariesAction); menu.add(fShowBinariesAction); } private Object findInputElement() { Object input= getSite().getPage().getInput(); if (input instanceof IWorkspace) { return JavaCore.create(((IWorkspace)input).getRoot()); } else if (input instanceof IContainer) { return JavaCore.create((IContainer)input); } //1GERPRT: ITPJUI:ALL - Packages View is empty when shown in Type Hierarchy Perspective // we can't handle the input // fall back to show the workspace return JavaCore.create(JavaPlugin.getWorkspace().getRoot()); } /** * Answer the property defined by key. */ public Object getAdapter(Class key) { if (key.equals(ISelectionProvider.class)) return fViewer; return super.getAdapter(key); } /** * Returns the tool tip text for the given element. */ String getToolTipText(Object element) { if (!(element instanceof IResource)) return ((ILabelProvider) getViewer().getLabelProvider()).getText(element); IPath path= ((IResource) element).getFullPath(); if (path.isRoot()) { return PackagesMessages.getString("PackageExplorer.title"); //$NON-NLS-1$ } else { return path.makeRelative().toString(); } } /** * @see IWorkbenchPart#setFocus() */ public void setFocus() { fViewer.getTree().setFocus(); } /** * Returns the shell to use for opening dialogs. * Used in this class, and in the actions. */ private Shell getShell() { return fViewer.getTree().getShell(); } /** * Returns the selection provider. */ private ISelectionProvider getSelectionProvider() { return fViewer; } /** * Returns the current selection. */ private ISelection getSelection() { return fViewer.getSelection(); } //---- Action handling ---------------------------------------------------------- /** * Called when the context menu is about to open. * Override to add your own context dependent menu contributions. */ public void menuAboutToShow(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection(); boolean selectionHasElements= !selection.isEmpty(); Object element= selection.getFirstElement(); // updateActions(selection); if (selection.size() == 1 && fViewer.isExpandable(element)) menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction); addGotoMenu(menu); fOpenCUAction.update(); if (fOpenCUAction.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenCUAction); addOpenWithMenu(menu, selection); addOpenToMenu(menu, selection); addRefactoring(menu); if (selection.size() == 1) { menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fViewer)); menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaAddElementFromHistory(null, fViewer)); } ContextMenuGroup.add(menu, fStandardGroups, fViewer); if (fAddBookmarkAction.canOperateOnSelection()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddBookmarkAction); menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fRefreshAction); fRefreshAction.selectionChanged(selection); if (selectionHasElements) { // update the action to use the right selection since the refresh // action doesn't listen to selection changes. menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fPropertyDialogAction); } } void addGotoMenu(IMenuManager menu) { MenuManager gotoMenu= new MenuManager(PackagesMessages.getString("PackageExplorer.gotoTitle")); //$NON-NLS-1$ menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, gotoMenu); gotoMenu.add(fBackAction); gotoMenu.add(fForwardAction); gotoMenu.add(fUpAction); gotoMenu.add(fGotoTypeAction); gotoMenu.add(fGotoPackageAction); } private void makeActions() { ISelectionProvider provider= getSelectionProvider(); fOpenCUAction= new OpenResourceAction(provider); fPropertyDialogAction= new PropertyDialogAction(getShell(), provider); // fShowTypeHierarchyAction= new ShowTypeHierarchyAction(provider); fShowNavigatorAction= new ShowInNavigatorAction(provider); fAddBookmarkAction= new AddBookmarkAction(provider); fStandardGroups= new ContextMenuGroup[] { new NewGroup(), new BuildGroup(), new ReorgGroup(), new JavaSearchGroup() }; fDeleteAction= new DeleteAction(StructuredSelectionProvider.createFrom(provider)); fRefreshAction= new RefreshAction(getShell()); fFilterAction = new FilterSelectionAction(getShell(), this, PackagesMessages.getString("PackageExplorer.filters")); //$NON-NLS-1$ fShowLibrariesAction = new ShowLibrariesAction(this, PackagesMessages.getString("PackageExplorer.referencedLibs")); //$NON-NLS-1$ fShowBinariesAction = new ShowBinariesAction(getShell(), this, PackagesMessages.getString("PackageExplorer.binaryProjects")); //$NON-NLS-1$ fBackAction= new BackAction(fFrameList); fForwardAction= new ForwardAction(fFrameList); fZoomInAction= new GoIntoAction(fFrameList); fUpAction= new UpAction(fFrameList); fGotoTypeAction= new GotoTypeAction(this); fGotoPackageAction= new GotoPackageAction(this); IActionBars actionService= getViewSite().getActionBars(); actionService.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, fDeleteAction); } private void addRefactoring(IMenuManager menu){ MenuManager refactoring= new MenuManager(PackagesMessages.getString("PackageExplorer.refactoringTitle")); //$NON-NLS-1$ ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, fViewer); if (!refactoring.isEmpty()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring); } private void addOpenToMenu(IMenuManager menu, IStructuredSelection selection) { if (selection.size() != 1) return; IAdaptable element= (IAdaptable) selection.getFirstElement(); IResource resource= (IResource)element.getAdapter(IResource.class); if ((resource instanceof IContainer)) { // Create a menu flyout. MenuManager submenu = new MenuManager(PackagesMessages.getString("PackageExplorer.openPerspective")); //$NON-NLS-1$ submenu.add(new OpenPerspectiveMenu(getSite().getWorkbenchWindow(), resource)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, element); } private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { // If one file is selected get it. // Otherwise, do not show the "open with" menu. if (selection.size() != 1) return; IAdaptable element= (IAdaptable)selection.getFirstElement(); Object resource= element.getAdapter(IResource.class); if (!(resource instanceof IFile)) return; // Create a menu flyout. MenuManager submenu= new MenuManager(PackagesMessages.getString("PackageExplorer.openWith")); //$NON-NLS-1$ submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } private boolean isSelectionOfType(ISelection s, Class clazz, boolean considerUnderlyingResource) { if (! (s instanceof IStructuredSelection) || s.isEmpty()) return false; IStructuredSelection selection= (IStructuredSelection)s; Iterator iter= selection.iterator(); while (iter.hasNext()) { Object o= iter.next(); if (clazz.isInstance(o)) return true; if (considerUnderlyingResource) { if (! (o instanceof IJavaElement)) return false; IJavaElement element= (IJavaElement)o; Object resource= element.getAdapter(IResource.class); if (! clazz.isInstance(resource)) return false; } } return true; } //---- Event handling ---------------------------------------------------------- private void initDragAndDrop() { int ops= DND.DROP_COPY | DND.DROP_MOVE; final LocalSelectionTransfer lt= LocalSelectionTransfer.getInstance(); Transfer[] transfers= new Transfer[] {lt, FileTransfer.getInstance()}; // Drop Adapter TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new SelectionTransferDropAdapter(fViewer), new FileTransferDropAdapter(fViewer) }; fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); // Drag Adapter Control control= fViewer.getControl(); TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(fViewer), new FileTransferDragAdapter(fViewer) }; DragSource source= new DragSource(control, ops); // Note, that the transfer agents are set by the delegating drag adapter itself. source.addDragListener(new DelegatingDragAdapter(dragListeners)); } /** * Handles key events in viewer. */ void handleKeyPressed(KeyEvent event) { if (event.character == SWT.DEL && event.stateMask == 0){ fDeleteAction.update(); if (fDeleteAction.isEnabled()) fDeleteAction.run(); } } /** * Handles double clicks in viewer. * Opens editor if file double-clicked. */ private void handleDoubleClick(DoubleClickEvent event) { IStructuredSelection s= (IStructuredSelection) event.getSelection(); Object element= s.getFirstElement(); // if the resource is already open then always open it if (EditorUtility.isOpenInEditor(element) == null) { if (fOpenCUAction.isEnabled()) { fOpenCUAction.run(); return; } } if (fViewer.isExpandable(element)) { if (JavaBasePreferencePage.doubleClockGoesInto()) fZoomInAction.run(); else { fViewer.setExpandedState(element, !fViewer.getExpandedState(element)); expandMainType(element); } } } /** * Handles selection changed in viewer. * Updates global actions. * Links to editor (if option enabled) */ private void handleSelectionChanged(SelectionChangedEvent event) { IStructuredSelection sel= (IStructuredSelection) event.getSelection(); //updateGlobalActions(sel); fZoomInAction.update(); linkToEditor(sel); } public void selectReveal(ISelection selection) { ISelection javaSelection= convertSelection(selection); fViewer.setSelection(javaSelection, true); } private ISelection convertSelection(ISelection s) { List converted= new ArrayList(); if (s instanceof StructuredSelection) { Object[] elements= ((StructuredSelection)s).toArray(); for (int i= 0; i < elements.length; i++) { Object e= elements[i]; if (e instanceof IJavaElement) converted.add(e); else if (e instanceof IResource) { IJavaElement element= JavaCore.create((IResource)e); if (element != null) converted.add(element); else converted.add(e); } } } return new StructuredSelection(converted.toArray()); } public void selectAndReveal(Object element) { selectReveal(new StructuredSelection(element)); } /** * Returns whether the preference to link selection to active editor is enabled. */ boolean isLinkingEnabled() { return JavaBasePreferencePage.linkPackageSelectionToEditor(); } /** * Links to editor (if option enabled) */ private void linkToEditor(IStructuredSelection selection) { //if (!isLinkingEnabled()) // return; Object obj= selection.getFirstElement(); Object element= null; if (selection.size() == 1) { if (obj instanceof IJavaElement) { IJavaElement cu= JavaModelUtil.findElementOfKind((IJavaElement)obj, IJavaElement.COMPILATION_UNIT); if (cu != null) element= getResourceFor(cu); if (element == null) element= JavaModelUtil.findElementOfKind((IJavaElement)obj, IJavaElement.CLASS_FILE); } else if (obj instanceof IFile) element= obj; if (element == null) return; IWorkbenchPage page= getSite().getPage(); IEditorPart editorArray[]= page.getEditors(); for (int i= 0; i < editorArray.length; ++i) { IEditorPart editor= editorArray[i]; Object input= getElementOfInput(editor.getEditorInput()); if (input != null && input.equals(element)) { page.bringToTop(editor); if (obj instanceof ISourceReference) EditorUtility.revealInEditor(editor, (ISourceReference)obj); return; } } } } private IResource getResourceFor(Object element) { if (element instanceof IJavaElement) { try { element= ((IJavaElement)element).getUnderlyingResource(); } catch (JavaModelException e) { return null; } } if (!(element instanceof IResource) || ((IResource)element).isPhantom()) { return null; } return (IResource)element; } public void saveState(IMemento memento) { if (fViewer == null) { // part has not been created if (fMemento != null) //Keep the old state; memento.putMemento(fMemento); return; } saveExpansionState(memento); saveSelectionState(memento); saveScrollState(memento, fViewer.getTree()); savePatternFilterState(memento); saveFilterState(memento); } protected void saveFilterState(IMemento memento) { boolean showLibraries= getLibraryFilter().getShowLibraries(); String show= "true"; //$NON-NLS-1$ if (!showLibraries) show= "false"; //$NON-NLS-1$ memento.putString(TAG_SHOWLIBRARIES, show); //save binary filter boolean showBinaries= getBinaryFilter().getShowBinaries(); String showBinString= "true"; //$NON-NLS-1$ if (!showBinaries) showBinString= "false"; //$NON-NLS-1$ memento.putString(TAG_SHOWBINARIES, showBinString); } protected void savePatternFilterState(IMemento memento) { String filters[] = getPatternFilter().getPatterns(); if(filters.length > 0) { IMemento filtersMem = memento.createChild(TAG_FILTERS); for (int i = 0; i < filters.length; i++){ IMemento child = filtersMem.createChild(TAG_FILTER); child.putString(TAG_ELEMENT,filters[i]); } } } protected void saveScrollState(IMemento memento, Tree tree) { ScrollBar bar= tree.getVerticalBar(); int position= bar != null ? bar.getSelection() : 0; memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position)); //save horizontal position bar= tree.getHorizontalBar(); position= bar != null ? bar.getSelection() : 0; memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position)); } protected void saveSelectionState(IMemento memento) { Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray(); if (elements.length > 0) { IMemento selectionMem= memento.createChild(TAG_SELECTION); for (int i= 0; i < elements.length; i++) { IMemento elementMem= selectionMem.createChild(TAG_ELEMENT); // we can only persist JavaElements for now Object o= elements[i]; if (o instanceof IJavaElement) elementMem.putString(TAG_PATH, ((IJavaElement) elements[i]).getHandleIdentifier()); } } } protected void saveExpansionState(IMemento memento) { Object expandedElements[]= fViewer.getExpandedElements(); if (expandedElements.length > 0) { IMemento expandedMem= memento.createChild(TAG_EXPANDED); for (int i= 0; i < expandedElements.length; i++) { IMemento elementMem= expandedMem.createChild(TAG_ELEMENT); // we can only persist JavaElements for now Object o= expandedElements[i]; if (o instanceof IJavaElement) elementMem.putString(TAG_PATH, ((IJavaElement) expandedElements[i]).getHandleIdentifier()); } } } void restoreState(IMemento memento) { restoreExpansionState(memento); restoreSelectionState(memento); restoreScrollState(memento, fViewer.getTree()); } protected void restoreScrollState(IMemento memento, Tree tree) { ScrollBar bar= tree.getVerticalBar(); if (bar != null) { try { String posStr= memento.getString(TAG_VERTICAL_POSITION); int position; position= new Integer(posStr).intValue(); bar.setSelection(position); } catch (NumberFormatException e) { // ignore, don't set scrollposition } } bar= tree.getHorizontalBar(); if (bar != null) { try { String posStr= memento.getString(TAG_HORIZONTAL_POSITION); int position; position= new Integer(posStr).intValue(); bar.setSelection(position); } catch (NumberFormatException e) { // ignore don't set scroll position } } } protected void restoreSelectionState(IMemento memento) { IMemento childMem; childMem= memento.getChild(TAG_SELECTION); if (childMem != null) { ArrayList list= new ArrayList(); IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT); for (int i= 0; i < elementMem.length; i++) { Object element= JavaCore.create(elementMem[i].getString(TAG_PATH)); list.add(element); } fViewer.setSelection(new StructuredSelection(list)); } } protected void restoreExpansionState(IMemento memento) { IMemento childMem= memento.getChild(TAG_EXPANDED); if (childMem != null) { ArrayList elements= new ArrayList(); IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT); for (int i= 0; i < elementMem.length; i++) { Object element= JavaCore.create(elementMem[i].getString(TAG_PATH)); elements.add(element); } fViewer.setExpandedElements(elements.toArray()); } } /** * Create the KeyListener for doing the refresh on the viewer. */ private void initRefreshKey() { fViewer.getControl().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { if (event.keyCode == SWT.F5) { fRefreshAction.selectionChanged( (IStructuredSelection) fViewer.getSelection()); if (fRefreshAction.isEnabled()) fRefreshAction.run(); } } }); } void initFrameList() { fFrameSource= new PackagesFrameSource(this); fFrameList= new FrameList(fFrameSource); fFrameSource.connectTo(fFrameList); } /** * An editor has been activated. Set the selection in this Packages Viewer * to be the editor's input, if linking is enabled. */ void editorActivated(IEditorPart editor) { if (!isLinkingEnabled()) return; Object input= getElementOfInput(editor.getEditorInput()); Object element= null; if (input instanceof IFile) element= JavaCore.create((IFile)input); if (element == null) // try a non Java resource element= input; if (element != null) { // if the current selection is a child of the new // selection then ignore it. IStructuredSelection oldSelection= (IStructuredSelection)getSelection(); if (oldSelection.size() == 1) { Object o= oldSelection.getFirstElement(); if (o instanceof IMember) { IMember m= (IMember)o; if (element.equals(m.getCompilationUnit())) return; if (element.equals(m.getClassFile())) return; } } ISelection newSelection= new StructuredSelection(element); if (!fViewer.getSelection().equals(newSelection)) { fViewer.setSelection(newSelection); } } } /** * A compilation unit or class was expanded, expand * the main type. */ void expandMainType(Object element) { try { IType type= null; if (element instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit)element; IType[] types= cu.getTypes(); if (types.length > 0) type= types[0]; } else if (element instanceof IClassFile) { IClassFile cf= (IClassFile)element; type= cf.getType(); } if (type != null) { final IType type2= type; Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().asyncExec(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.expandToLevel(type2, 1); } }); } } } catch(JavaModelException e) { // no reveal } } /** * Returns the element contained in the EditorInput */ Object getElementOfInput(IEditorInput input) { if (input instanceof IFileEditorInput) return ((IFileEditorInput)input).getFile(); else if (input instanceof ClassFileEditorInput) return ((ClassFileEditorInput)input).getClassFile(); else if (input instanceof JarEntryEditorInput) return ((JarEntryEditorInput)input).getStorage(); return null; } /** * Returns the Viewer. */ TreeViewer getViewer() { return fViewer; } /** * Returns the pattern filter for this view. * @return the pattern filter */ JavaElementPatternFilter getPatternFilter() { return fPatternFilter; } /** * Returns the library filter for this view. * @return the library filter */ LibraryFilter getLibraryFilter() { return fLibraryFilter; } /** * Returns the Binary filter for this view. * @return the binary filter */ BinaryProjectFilter getBinaryFilter() { return fBinaryFilter; } void restoreFilters() { IMemento filtersMem= fMemento.getChild(TAG_FILTERS); if(filtersMem != null) { IMemento children[]= filtersMem.getChildren(TAG_FILTER); String filters[]= new String[children.length]; for (int i = 0; i < children.length; i++) { filters[i]= children[i].getString(TAG_ELEMENT); } getPatternFilter().setPatterns(filters); } else { getPatternFilter().setPatterns(new String[0]); } //restore library String show= fMemento.getString(TAG_SHOWLIBRARIES); if (show != null) getLibraryFilter().setShowLibraries(show.equals("true")); //$NON-NLS-1$ else initLibraryFilterFromPreferences(); //restore binary fileter String showbin= fMemento.getString(TAG_SHOWBINARIES); if (showbin != null) getBinaryFilter().setShowBinaries(show.equals("true")); //$NON-NLS-1$ else initBinaryFilterFromPreferences(); } void initFilterFromPreferences() { initBinaryFilterFromPreferences(); initLibraryFilterFromPreferences(); } void initLibraryFilterFromPreferences() { JavaPlugin plugin= JavaPlugin.getDefault(); boolean show= plugin.getPreferenceStore().getBoolean(TAG_SHOWLIBRARIES); getLibraryFilter().setShowLibraries(show); } void initBinaryFilterFromPreferences() { JavaPlugin plugin= JavaPlugin.getDefault(); boolean showbin= plugin.getPreferenceStore().getBoolean(TAG_SHOWBINARIES); getBinaryFilter().setShowBinaries(showbin); } /** * Updates the title text and title tool tip. * Called whenever the input of the viewer changes. */ void updateTitle() { Object input= getViewer().getInput(); String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ if (input == null || (input instanceof IJavaModel)) { setTitle(viewName); setTitleToolTip(""); //$NON-NLS-1$ } else { ILabelProvider labelProvider = (ILabelProvider) getViewer().getLabelProvider(); String inputText= labelProvider.getText(input); String title= PackagesMessages.getFormattedString("PackageExplorer.argTitle", new String[] { viewName, inputText }); //$NON-NLS-1$ setTitle(title); setTitleToolTip(getToolTipText(input)); } } /** * Sets the decorator for the package explorer. * * @param decorator a label decorator or <code>null</code> for no decorations. */ public void setLabelDecorator(ILabelDecorator decorator) { int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_VARIABLE; JavaElementLabelProvider javaProvider= new JavaElementLabelProvider(labelFlags); javaProvider.setErrorTickManager(new MarkerErrorTickProvider()); if (decorator == null) { fViewer.setLabelProvider(javaProvider); } else { fViewer.setLabelProvider(new DecoratingLabelProvider(javaProvider, decorator)); } } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty() != IPreferencesConstants.SHOW_CU_CHILDREN) return; if (fViewer != null) { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); boolean b= store.getBoolean(IPreferencesConstants.SHOW_CU_CHILDREN); ((JavaElementContentProvider)fViewer.getContentProvider()).setProvideMembers(b); fViewer.refresh(); } } }
    5,097
    Bug 5097 Version Info in Package View marks all members of a type as changed
    Version Info in Navigator marks all members of a type as changed, even if only one member actually was modified.
    resolved fixed
    af8bd61
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-20T03:14:41Z
    2001-10-19T11:13:20Z
    org.eclipse.jdt.ui.vcm/vcm/org/eclipse/jdt/ui/vcm/JavaVCMLabelDecorator.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.ui.vcm; import org.eclipse.core.resources.IResource; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.swt.widgets.Shell; import org.eclipse.vcm.internal.ui.VCMLabelDecorator; /** * This label decorator adds Version information to resources. */ public class JavaVCMLabelDecorator extends VCMLabelDecorator { /** * Creates a new decorator with the given shell. The shell is * needed for determining the UI display for updates. */ public JavaVCMLabelDecorator(Shell shell) { super(shell); } /** * Returns the change event to be fired for updates to the given resource. */ protected LabelProviderChangedEvent createLabelEvent(IResource resource) { // check whether there is a corresponding Java resource IJavaElement element= JavaCore.create(resource); if (element != null) return new LabelProviderChangedEvent(this, element); return new LabelProviderChangedEvent(this, resource); } }
    4,360
    Bug 4360 Template - cursor at wrong position
    null
    resolved wontfix
    6498fcf
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T08:12:23Z
    2001-10-11T11:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateEditorPopup.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.TypedEvent; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * A popup dialog to request the user to fill the variables of the chosen template. */ public class TemplateEditorPopup implements ModifyListener, VerifyKeyListener, ControlListener, FocusListener { private static final int BORDER_WIDTH= 1; private TemplateContext fContext; private TemplateModel fModel; private Shell fShell; private Composite fComposite; private SourceViewer fViewer; private EditBox[] fEditBoxes; private boolean fResult; public TemplateEditorPopup(TemplateContext context, TemplateModel model) { fContext= context; fModel= model; } private void create() { Control control= fContext.getViewer().getTextWidget(); control.getShell().addControlListener(this); Display display= control.getDisplay(); // XXX SWT.ON_TOP fobids focus to be gained fShell= new Shell(control.getShell(), /*SWT.ON_TOP |*/ SWT.NO_TRIM | SWT.APPLICATION_MODAL); fShell.setBackground(display.getSystemColor(SWT.COLOR_RED)); fComposite= new Composite(fShell, SWT.NONE); int[] indices= fModel.getEditableTexts(); int count= indices.length; fEditBoxes= new EditBox[count]; for (int i= 0; i != count; i++) { fEditBoxes[i]= new EditBox(fComposite, fContext, fModel, indices[i]); fEditBoxes[i].getText().addFocusListener(this); } fViewer= createViewer(fComposite); fViewer.getTextWidget().setText(fModel.toString()); } private static SourceViewer createViewer(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, SWT.NONE); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); viewer.configure(new JavaSourceViewerConfiguration(tools, null)); viewer.setEditable(false); viewer.setDocument(new Document()); Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); viewer.getTextWidget().setFont(font); return viewer; } private void show() { updateSize(); updatePosition(); fShell.open(); } public void dispose() { if ((fShell != null) && !fShell.isDisposed()) { fShell.dispose(); Control control= fContext.getViewer().getTextWidget(); control.getShell().removeControlListener(this); } fShell= null; } public boolean open() { create(); show(); Display display= fShell.getDisplay(); // XXX kludge: attempt to flush pending events to gain focus while (display.readAndDispatch()); fEditBoxes[0].selectAll(); while ((fShell != null) && !fShell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); return fResult; } private int findEditBoxIndex(TypedEvent e) { StyledText text= (StyledText) e.widget; for (int i= 0; i != fEditBoxes.length; i++) if (fEditBoxes[i].getText().equals(text)) return i; return -1; } private EditBox getEditBox(TypedEvent e) { int index= findEditBoxIndex(e); return fEditBoxes[index]; } public void modifyText(ModifyEvent e) { EditBox box= getEditBox(e); String modifiedText= box.getText().getText(); int rangeIndex= box.getRangeIndex(); // update model fModel.setText(rangeIndex, box.getText().getText()); // update editable and non-editable text for (int i= 0; i != fEditBoxes.length; i++) { if (fModel.shareSameModel(fEditBoxes[i].getRangeIndex(), rangeIndex)) { // update edit boxes if (box.equals(fEditBoxes[i])) { // XXX kludge (computeSize does not work as expected) StyledText text= fEditBoxes[i].getText(); int offset= text.getCaretOffset(); Point selection= text.getSelection(); text.removeModifyListener(this); text.setText(modifiedText); text.addModifyListener(this); text.setCaretOffset(offset); text.setSelection(selection); } else { fEditBoxes[i].getText().setText(modifiedText); } } } fViewer.getTextWidget().setText(fModel.toString()); updateSize(); updatePosition(); } public void verifyKey(VerifyEvent e) { switch (e.character) { // (SHIFT-)TAB = hop between edit boxes case 0x09: int index= findEditBoxIndex(e); if (e.stateMask == SWT.SHIFT) { // does not work // previous if (index == 0) { fShell.getDisplay().beep(); } else { fEditBoxes[index].unselect(); fEditBoxes[index - 1].selectAll(); } } else { // next if (index == fEditBoxes.length - 1) { fShell.getDisplay().beep(); } else { fEditBoxes[index].unselect(); fEditBoxes[index + 1].selectAll(); } } e.doit= false; break; // ENTER = accept case 0x0D: dispose(); fResult= true; e.doit= false; break; // ESC = cancel case 0x1B: dispose(); fResult= false; e.doit= false; break; } } public void controlMoved(ControlEvent e) { updatePosition(); } public void controlResized(ControlEvent e) { updatePosition(); } public void focusGained(FocusEvent e) { EditBox box= getEditBox(e); box.getText().addModifyListener(this); box.getText().addVerifyKeyListener(this); } public void focusLost(FocusEvent e) { EditBox box= getEditBox(e); box.getText().removeModifyListener(this); box.getText().removeVerifyKeyListener(this); box.unselect(); } private void updatePosition() { if ((fShell == null) || fShell.isDisposed()) return; StyledText text= fContext.getViewer().getTextWidget(); Point location= text.getLocationAtOffset(fContext.getStart()); location= text.toDisplay(location); // XXX not enough? location.x -= BORDER_WIDTH; // XXX bidi safe? location.y -= BORDER_WIDTH; Point size= fShell.getSize(); Display display= fShell.getDisplay(); Rectangle rectangle= display.getBounds(); if (location.x > rectangle.width - size.x) location.x = rectangle.width - size.x; if (location.y > rectangle.height - size.y) location.y = rectangle.height - size.y; fShell.setLocation(location.x, location.y); } private void updateSize() { if ((fShell == null) || fShell.isDisposed()) return; StyledText text= fViewer.getTextWidget(); Point size= text.computeSize(SWT.DEFAULT, SWT.DEFAULT); text.setSize(size); fComposite.setSize(size); fComposite.setLocation(BORDER_WIDTH, BORDER_WIDTH); size.x += BORDER_WIDTH * 2; size.y += BORDER_WIDTH * 2; fShell.setSize(size); text.setLocation(0, 0); for (int i= 0; i != fEditBoxes.length; i++) fEditBoxes[i].updatePosition(fViewer.getTextWidget()); } public String getText() { return fModel.toString(); } public int[] getSelection() { return fModel.getSelection(); } }
    4,360
    Bug 4360 Template - cursor at wrong position
    null
    resolved wontfix
    6498fcf
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T08:12:23Z
    2001-10-11T11:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateProposal.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.text.template; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.core.Assert; import org.eclipse.jdt.internal.core.refactoring.TextUtilities; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage; import org.eclipse.jdt.internal.ui.preferences.TemplatePreferencePage; import org.eclipse.jdt.internal.ui.refactoring.changes.TextBuffer; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.custom.StyledText; /** * A template proposal. */ public class TemplateProposal implements ICompletionProposal { private final Template fTemplate; private final TemplateContext fContext; private int fSelectionStart; private int fSelectionEnd; private CursorSelectionEvaluator fCursorSelectionEvaluator= new CursorSelectionEvaluator(); private VariableEvaluator fLocalVariableEvaluator= new LocalVariableEvaluator(); private TemplateInterpolator fInterpolator= new TemplateInterpolator(); private ArgumentEvaluator fArgumentEvaluator; private ModelEvaluator fModelEvaluator= new ModelEvaluator(); private boolean fDisposed; /** * Creates a template proposal with a template and the range of its key. * @param template the template * @param arguments arguments to the template, or <code>null</code> for no arguments * @param start the starting position of the key. * @param end the ending position of the key (exclusive). */ TemplateProposal(Template template, String[] arguments, TemplateContext context) { Assert.isNotNull(template); Assert.isNotNull(context); fTemplate= template; fArgumentEvaluator= new ArgumentEvaluator(arguments); fContext= context; } /** * @see ICompletionProposal#apply(IDocument) */ public void apply(IDocument document) { int indentationLevel= guessIndentationLevel(document, fContext.getStart()); String pattern= fTemplate.getPattern(); // resolve variables automatically pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fContext); // pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); fInterpolator.interpolate(pattern, fModelEvaluator); TemplateModel model= fModelEvaluator.getModel(); if (model.getEditableCount() == 0) { pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); // side effect: stores selection int cursorStart= fCursorSelectionEvaluator.getStart(); if (cursorStart == -1) { fSelectionStart= pattern.length(); fSelectionEnd= fSelectionStart; } else { fSelectionStart= cursorStart; fSelectionEnd= fCursorSelectionEvaluator.getEnd(); } } else { // resolve variables manually TemplateEditorPopup popup= new TemplateEditorPopup(fContext, model); if (!popup.open()) { // leave caret offset fSelectionStart= fContext.getEnd() - fContext.getStart(); fSelectionEnd= fSelectionStart; return; } pattern= popup.getText(); int[] selection= popup.getSelection(); if (selection[0] == -1) { fSelectionStart= pattern.length(); fSelectionEnd= fSelectionStart; } else { fSelectionStart= selection[0]; fSelectionEnd= selection[1]; } } if (TemplatePreferencePage.useCodeFormatter() && fTemplate.getContext().equals("java")) { //$NON-NLS-1$ CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions()); formatter.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); formatter.setInitialIndentationLevel(indentationLevel); pattern= formatter.formatSourceString(pattern); int[] positions= formatter.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } else { CodeIndentator indentator= new CodeIndentator(); indentator.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd}); indentator.setIndentationLevel(indentationLevel); pattern= indentator.indentate(pattern); int[] positions= indentator.getMappedPositions(); fSelectionStart= positions[0]; fSelectionEnd= positions[1]; } // strip indentation on first line String finalString= trimBegin(pattern); int charactersRemoved= pattern.length() - finalString.length(); fSelectionStart -= charactersRemoved; fSelectionEnd -= charactersRemoved; int start= fContext.getStart(); int length= fContext.getEnd() - start; try { document.replace(start, length, finalString); } catch (BadLocationException x) {} // ignore } private static String trimBegin(String string) { int i= 0; while ((i != string.length()) && Character.isWhitespace(string.charAt(i))) i++; return string.substring(i); } /** * @see ICompletionProposal#getSelection(IDocument) */ public Point getSelection(IDocument document) { return new Point(fContext.getStart() + fSelectionStart, fSelectionEnd - fSelectionStart); } /** * @see ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { String pattern= fTemplate.getPattern(); pattern= fInterpolator.interpolate(pattern, fArgumentEvaluator); pattern= fInterpolator.interpolate(pattern, fContext); pattern= fInterpolator.interpolate(pattern, fLocalVariableEvaluator); pattern= fInterpolator.interpolate(pattern, fCursorSelectionEvaluator); return textToHTML(pattern); } /** * @see ICompletionProposal#getDisplayString() */ public String getDisplayString() { return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$ } /** * @see ICompletionProposal#getImage() */ public Image getImage() { return fTemplate.getImage(); } /** * @see ICompletionProposal#getContextInformation() */ public IContextInformation getContextInformation() { return null; } private static int guessIndentationLevel(IDocument document, int offset) { TextBuffer buffer= new TextBuffer(document); String line= buffer.getLineContentOfOffset(offset); return TextUtilities.getIndent(line, CodeFormatterPreferencePage.getTabSize()); } private static String textToHTML(String string) { StringBuffer buffer= new StringBuffer(string.length()); buffer.append("<pre>"); //$NON-NLS-1$ for (int i= 0; i != string.length(); i++) { char ch= string.charAt(i); switch (ch) { case '&': buffer.append("&amp;"); //$NON-NLS-1$ break; case '<': buffer.append("&lt;"); //$NON-NLS-1$ break; case '>': buffer.append("&gt;"); //$NON-NLS-1$ break; case '\t': buffer.append(" "); //$NON-NLS-1$ break; case '\n': buffer.append("<br>"); //$NON-NLS-1$ break; default: buffer.append(ch); break; } } buffer.append("</pre>"); //$NON-NLS-1$ return buffer.toString(); } }
    3,555
    Bug 3555 source for binaries - 'defaults' button does not work (1G840M4)
    AK (1/25/01 2:43:33 PM) 1. create a java project 2. open the properties page for rt.jar in the project 3. clear the 'Sources JAR file' field 4. press 'Defaults' nothing happens NOTES: EG (2/1/01 10:02:53 AM) wait until we finish the Library presentation issue.
    verified fixed
    e593dc7
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T14:06:00Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.preferences; import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock; /** * Property page to configure a archive's JARs source attachment */ public class SourceAttachmentPropertyPage extends PropertyPage implements IStatusChangeListener { private SourceAttachmentBlock fSourceAttachmentBlock; private IPackageFragmentRoot fJarRoot; public SourceAttachmentPropertyPage() { } /* * @see PreferencePage#createContents */ protected Control createContents(Composite composite) { fJarRoot= getJARPackageFragmentRoot(); if (fJarRoot != null) { try { IClasspathEntry entry= JavaModelUtil.getRawClasspathEntry(fJarRoot); if (entry == null) { // use a dummy entry to use for initialization entry= JavaCore.newLibraryEntry(fJarRoot.getPath(), null, null); } IWorkspaceRoot wsroot= fJarRoot.getJavaModel().getWorkspace().getRoot(); fSourceAttachmentBlock= new SourceAttachmentBlock(wsroot, this, entry); return fSourceAttachmentBlock.createControl(composite); } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } Label label= new Label(composite, SWT.LEFT + SWT.WRAP); label.setText(JavaUIMessages.getString("SourceAttachmentPropertyPage.noarchive.message")); //$NON-NLS-1$ label.setFont(composite.getFont()); WorkbenchHelp.setHelp(composite, new DialogPageContextComputer(this, IJavaHelpContextIds.SOURCE_ATTACHMENT_PROPERTY_PAGE)); return label; } /* * @see IPreferencePage#performOk */ public boolean performOk() { if (fSourceAttachmentBlock != null) { try { IRunnableWithProgress runnable= fSourceAttachmentBlock.getRunnable(fJarRoot.getJavaProject(), getShell()); new ProgressMonitorDialog(getShell()).run(true, true, runnable); } catch (InvocationTargetException e) { String title= JavaUIMessages.getString("SourceAttachmentPropertyPage.error.title"); //$NON-NLS-1$ String message= JavaUIMessages.getString("SourceAttachmentPropertyPage.error.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); return false; } catch (InterruptedException e) { // cancelled return false; } } return true; } private IPackageFragmentRoot getJARPackageFragmentRoot() { // try to find it as Java element (needed for external jars) IAdaptable adaptable= getElement(); IJavaElement elem= (IJavaElement) adaptable.getAdapter(IJavaElement.class); if (elem instanceof IPackageFragmentRoot) { IPackageFragmentRoot root= (IPackageFragmentRoot) elem; if (root.isArchive()) { return root; } else { return null; } } // not on classpath or not in a java project IResource resource= (IResource) adaptable.getAdapter(IResource.class); if (resource instanceof IFile) { IProject proj= resource.getProject(); try { if (proj.hasNature(JavaCore.NATURE_ID)) { IJavaProject jproject= JavaCore.create(proj); return jproject.getPackageFragmentRoot(resource); } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return null; } /* * @see IStatusChangeListener#statusChanged */ public void statusChanged(IStatus status) { setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } }
    3,555
    Bug 3555 source for binaries - 'defaults' button does not work (1G840M4)
    AK (1/25/01 2:43:33 PM) 1. create a java project 2. open the properties page for rt.jar in the project 3. clear the 'Sources JAR file' field 4. press 'Defaults' nothing happens NOTES: EG (2/1/01 10:02:53 AM) wait until we finish the Library presentation issue.
    verified fixed
    e593dc7
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T14:06:00Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.wizards.buildpaths; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.zip.ZipFile; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.ElementTreeSelectionDialog; import org.eclipse.jdt.internal.ui.dialogs.ISelectionValidator; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; import org.eclipse.jdt.internal.ui.wizards.swt.MGridData; import org.eclipse.jdt.internal.ui.wizards.swt.MGridLayout; /** * UI to set the source attachment archive and root. * Same implementation for both setting attachments for libraries from * variable entries and for normal (internal or external) jar. */ public class SourceAttachmentBlock { private IStatusChangeListener fContext; private StringButtonDialogField fFileNameField; private SelectionButtonDialogField fInternalButtonField; private StringButtonDialogField fPrefixField; private StringButtonDialogField fJavaDocField; private boolean fIsVariableEntry; private IStatus fNameStatus; private IStatus fPrefixStatus; private IStatus fJavaDocStatus; private IPath fJARPath; /** * The file to which the archive path points to. * Only set when the file exists. */ private File fResolvedFile; /** * The path to which the archive variable points. * Null if invalid path or not resolvable. Must not exist. */ private IPath fFileVariablePath; private URL fJavaDocLocation; private IWorkspaceRoot fRoot; private Control fSWTWidget; private CLabel fFullPathResolvedLabel; private CLabel fPrefixResolvedLabel; public SourceAttachmentBlock(IWorkspaceRoot root, IStatusChangeListener context, IClasspathEntry oldEntry) { fContext= context; fRoot= root; // fIsVariableEntry specifies if the UI is for a variable entry fIsVariableEntry= (oldEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE); fNameStatus= new StatusInfo(); fPrefixStatus= new StatusInfo(); fJavaDocStatus= new StatusInfo(); fJARPath= (oldEntry != null) ? oldEntry.getPath() : Path.EMPTY; SourceAttachmentAdapter adapter= new SourceAttachmentAdapter(); // create the dialog fields (no widgets yet) if (fIsVariableEntry) { fFileNameField= new VariablePathDialogField(adapter); fFileNameField.setDialogFieldListener(adapter); fFileNameField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.filename.varlabel")); //$NON-NLS-1$ fFileNameField.setButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.filename.external.varbutton")); //$NON-NLS-1$ ((VariablePathDialogField)fFileNameField).setVariableButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.filename.variable.button")); //$NON-NLS-1$ fPrefixField= new VariablePathDialogField(adapter); fPrefixField.setDialogFieldListener(adapter); fPrefixField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.prefix.varlabel")); //$NON-NLS-1$ fPrefixField.setButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.prefix.varbutton")); //$NON-NLS-1$ ((VariablePathDialogField)fPrefixField).setVariableButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.prefix.variable.button")); //$NON-NLS-1$ } else { fFileNameField= new StringButtonDialogField(adapter); fFileNameField.setDialogFieldListener(adapter); fFileNameField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.filename.label")); //$NON-NLS-1$ fFileNameField.setButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.filename.external.button")); //$NON-NLS-1$ fInternalButtonField= new SelectionButtonDialogField(SWT.PUSH); fInternalButtonField.setDialogFieldListener(adapter); fInternalButtonField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.filename.internal.button")); //$NON-NLS-1$ fPrefixField= new StringButtonDialogField(adapter); fPrefixField.setDialogFieldListener(adapter); fPrefixField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.prefix.label")); //$NON-NLS-1$ fPrefixField.setButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.prefix.button")); //$NON-NLS-1$ } // not used fJavaDocField= new StringButtonDialogField(adapter); fJavaDocField.setDialogFieldListener(adapter); fJavaDocField.setLabelText(NewWizardMessages.getString("SourceAttachmentBlock.javadoc.label")); //$NON-NLS-1$ fJavaDocField.setButtonLabel(NewWizardMessages.getString("SourceAttachmentBlock.javadoc.button")); //$NON-NLS-1$ // set the old settings if (oldEntry != null && oldEntry.getSourceAttachmentPath() != null) { fFileNameField.setText(oldEntry.getSourceAttachmentPath().toString()); } else { fFileNameField.setText(""); //$NON-NLS-1$ } if (oldEntry != null && oldEntry.getSourceAttachmentRootPath() != null) { fPrefixField.setText(oldEntry.getSourceAttachmentRootPath().toString()); } else { fPrefixField.setText(""); //$NON-NLS-1$ } } /** * Gets the source attachment path chosen by the user */ public IPath getSourceAttachmentPath() { if (fFileNameField.getText().length() == 0) { return null; } return new Path(fFileNameField.getText()); } /** * Gets the source attachment root chosen by the user */ public IPath getSourceAttachmentRootPath() { if (getSourceAttachmentPath() == null) { return null; } else { return new Path(fPrefixField.getText()); } } ///** // * Gets the Java Doc location chosen by the user // */ //public URL getJavaDocLocation() { // return fJavaDocLocation; //} private Label createHelpText(Composite composite, int style, int widthHint, boolean indented, String text) { if (indented) { DialogField.createEmptySpace(composite, 1); } Label helpTextLabel= new Label(composite, style); helpTextLabel.setText(text); MGridData gd= new MGridData(MGridData.HORIZONTAL_ALIGN_FILL); gd.widthHint= widthHint; helpTextLabel.setLayoutData(gd); if (indented) { DialogField.createEmptySpace(composite, 2); gd.horizontalSpan= 1; } else { gd.horizontalSpan= 4; } return helpTextLabel; } /** * Creates the control */ public Control createControl(Composite parent) { fSWTWidget= parent; Composite composite= new Composite(parent, SWT.NONE); MGridLayout layout= new MGridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.minimumWidth= 450; layout.minimumHeight= 0; layout.numColumns= 4; composite.setLayout(layout); createHelpText(composite, SWT.LEFT, SWT.DEFAULT, false, NewWizardMessages.getFormattedString("SourceAttachmentBlock.message", fJARPath.lastSegment())); //$NON-NLS-1$ if (fIsVariableEntry) { createHelpText(composite, SWT.LEFT + SWT.WRAP, 300, true, NewWizardMessages.getString("SourceAttachmentBlock.filename.description")); //$NON-NLS-1$ } // archive name field fFileNameField.doFillIntoGrid(composite, 4); MGridData gd= (MGridData)fFileNameField.getTextControl(null).getLayoutData(); gd.widthHint= 300; if (!fIsVariableEntry) { // aditional 'browse workspace' button for normal jars DialogField.createEmptySpace(composite, 3); fInternalButtonField.doFillIntoGrid(composite, 1); } else { // label that shows the resolved path for variable jars DialogField.createEmptySpace(composite, 1); fFullPathResolvedLabel= new CLabel(composite, SWT.LEFT); fFullPathResolvedLabel.setText(getResolvedLabelString(fFileNameField.getText(), true)); fFullPathResolvedLabel.setLayoutData(new MGridData(MGridData.HORIZONTAL_ALIGN_FILL)); DialogField.createEmptySpace(composite, 2); } // label createHelpText(composite, SWT.LEFT + SWT.WRAP, 300, true, NewWizardMessages.getString("SourceAttachmentBlock.prefix.description")); //$NON-NLS-1$ // root path field fPrefixField.doFillIntoGrid(composite, 4); gd= (MGridData)fPrefixField.getTextControl(null).getLayoutData(); gd.widthHint= 300; if (fIsVariableEntry) { // label that shows the resolved path for variable jars DialogField.createEmptySpace(composite, 1); fPrefixResolvedLabel= new CLabel(composite, SWT.LEFT); fPrefixResolvedLabel.setText(getResolvedLabelString(fPrefixField.getText(), false)); fPrefixResolvedLabel.setLayoutData(new MGridData(MGridData.HORIZONTAL_ALIGN_FILL)); DialogField.createEmptySpace(composite, 2); } fFileNameField.postSetFocusOnDialogField(parent.getDisplay()); //DialogField.createEmptySpace(composite, 1); //Label jdocDescription= new Label(composite, SWT.LEFT + SWT.WRAP); //jdocDescription.setText(NewWizardMessages.getString(JAVADOC + ".description")); //DialogField.createEmptySpace(composite, 1); //fJavaDocField.doFillIntoGrid(composite, 3); WorkbenchHelp.setHelp(composite, new Object[] { IJavaHelpContextIds.SOURCE_ATTACHMENT_BLOCK }); return composite; } private class SourceAttachmentAdapter implements IStringButtonAdapter, IDialogFieldListener { // -------- IStringButtonAdapter -------- public void changeControlPressed(DialogField field) { attachmentChangeControlPressed(field); } // ---------- IDialogFieldListener -------- public void dialogFieldChanged(DialogField field) { attachmentDialogFieldChanged(field); } } private void attachmentChangeControlPressed(DialogField field) { if (field == fFileNameField) { IPath jarFilePath= chooseExtJarFile(); if (jarFilePath != null) { fFileNameField.setText(jarFilePath.toString()); } } else if (field == fPrefixField) { IPath prefixPath= choosePrefix(); if (prefixPath != null) { fPrefixField.setText(prefixPath.toString()); } } else if (field == fJavaDocField) { URL jdocURL= chooseJavaDocLocation(); if (jdocURL != null) { fJavaDocField.setText(jdocURL.toExternalForm()); } } } // ---------- IDialogFieldListener -------- private void attachmentDialogFieldChanged(DialogField field) { if (field == fFileNameField) { fNameStatus= updateFileNameStatus(); } else if (field == fInternalButtonField) { IPath jarFilePath= chooseInternalJarFile(fFileNameField.getText()); if (jarFilePath != null) { fFileNameField.setText(jarFilePath.toString()); } return; } else if (field == fPrefixField) { fPrefixStatus= updatePrefixStatus(); } else if (field == fJavaDocField) { fJavaDocStatus= updateJavaDocLocationStatus(); } doStatusLineUpdate(); } private void doStatusLineUpdate() { fPrefixField.enableButton(canBrowsePrefix()); fFileNameField.enableButton(canBrowseFileName()); // set the resolved path for variable jars if (fFullPathResolvedLabel != null) { fFullPathResolvedLabel.setText(getResolvedLabelString(fFileNameField.getText(), true)); } if (fPrefixResolvedLabel != null) { fPrefixResolvedLabel.setText(getResolvedLabelString(fPrefixField.getText(), false)); } IStatus status= StatusUtil.getMostSevere(new IStatus[] { fNameStatus, fPrefixStatus, fJavaDocStatus }); fContext.statusChanged(status); } private boolean canBrowseFileName() { if (!fIsVariableEntry) { return true; } // to browse with a variable JAR, the variable name must point to a directory if (fFileVariablePath != null) { return fFileVariablePath.toFile().isDirectory(); } return false; } private boolean canBrowsePrefix() { // can browse when the archive name is poiting to a existing file // and (if variable) the prefix variable name is existing if (fResolvedFile != null) { if (fIsVariableEntry) { // prefix has valid format, is resolvable return fPrefixStatus.isOK(); } return true; } return false; } private String getResolvedLabelString(String path, boolean osPath) { IPath resolvedPath= getResolvedPath(new Path(path)); if (resolvedPath != null) { if (osPath) { return resolvedPath.toOSString(); } else { return resolvedPath.toString(); } } return ""; //$NON-NLS-1$ } private IPath getResolvedPath(IPath path) { if (path != null) { String varName= path.segment(0); if (varName != null) { IPath varPath= JavaCore.getClasspathVariable(varName); if (varPath != null) { return varPath.append(path.removeFirstSegments(1)); } } } return null; } private IStatus updatePrefixStatus() { StatusInfo status= new StatusInfo(); String prefix= fPrefixField.getText(); if (prefix.length() == 0) { // no source attachment path return status; } else { if (!Path.EMPTY.isValidPath(prefix)) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.prefix.error.notvalid")); //$NON-NLS-1$ return status; } IPath path= new Path(prefix); if (fIsVariableEntry) { IPath resolvedPath= getResolvedPath(path); if (resolvedPath == null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.prefix.error.varnotexists")); //$NON-NLS-1$ return status; } if (resolvedPath.getDevice() != null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.prefix.error.deviceinvar")); //$NON-NLS-1$ return status; } } else { if (path.getDevice() != null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.prefix.error.deviceinpath")); //$NON-NLS-1$ return status; } } } return status; } private IStatus updateFileNameStatus() { StatusInfo status= new StatusInfo(); fResolvedFile= null; fFileVariablePath= null; String fileName= fFileNameField.getText(); if (fileName.length() == 0) { // no source attachment return status; } else { if (!Path.EMPTY.isValidPath(fileName)) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.filename.error.notvalid")); //$NON-NLS-1$ return status; } IPath filePath= new Path(fileName); IPath resolvedPath; if (fIsVariableEntry) { if (filePath.getDevice() != null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.filename.error.deviceinpath")); //$NON-NLS-1$ return status; } String varName= filePath.segment(0); if (varName == null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.filename.error.notvalid")); //$NON-NLS-1$ return status; } fFileVariablePath= JavaCore.getClasspathVariable(varName); if (fFileVariablePath == null) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.filename.error.varnotexists")); //$NON-NLS-1$ return status; } resolvedPath= fFileVariablePath.append(filePath.removeFirstSegments(1)); if (resolvedPath.isEmpty()) { status.setWarning(NewWizardMessages.getString("SourceAttachmentBlock.filename.warning.varempty")); //$NON-NLS-1$ return status; } File file= resolvedPath.toFile(); if (!file.isFile()) { String message= NewWizardMessages.getFormattedString("SourceAttachmentBlock.filename.error.filenotexists", resolvedPath.toOSString()); //$NON-NLS-1$ status.setWarning(message); return status; } fResolvedFile= file; } else { File file= filePath.toFile(); IResource res= fRoot.findMember(filePath); if (res != null) { file= res.getLocation().toFile(); } if (!file.isFile()) { String message= NewWizardMessages.getFormattedString("SourceAttachmentBlock.filename.error.filenotexists", filePath.toString()); //$NON-NLS-1$ status.setError(message); return status; } fResolvedFile= file; } } return status; } private IStatus updateJavaDocLocationStatus() { StatusInfo status= new StatusInfo(); fJavaDocLocation= null; String jdocLocation= fJavaDocField.getText(); if (!"".equals(jdocLocation)) { //$NON-NLS-1$ try { URL url= new URL(jdocLocation); if ("file".equals(url.getProtocol())) { //$NON-NLS-1$ File dir= new File(url.getFile()); if (!dir.isDirectory()) { status.setError(NewWizardMessages.getString("SourceAttachmentBlock.javadoc.error.notafolder")); //$NON-NLS-1$ return status; } /*else { File indexFile= new File(dir, "index.html"); File packagesFile= new File(dir, "package-list"); if (!packagesFile.exists() || !indexFile.exists()) { fJavaDocStatusInfo.setWarning(NewWizardMessages.getString(ERR_JDOCLOCATION_IDXNOTFOUND)); // only a warning, go on } }*/ } fJavaDocLocation= url; } catch (MalformedURLException e) { status.setError(NewWizardMessages.getFormattedString("SourceAttachmentBlock.javadoc.error.malformed", e.getLocalizedMessage())); //$NON-NLS-1$ return status; } } return status; } /* * Opens a dialog to choose a jar from the file system. */ private IPath chooseExtJarFile() { IPath currPath= new Path(fFileNameField.getText()); if (currPath.isEmpty()) { currPath= fJARPath; } IPath resolvedPath= currPath; if (fIsVariableEntry) { resolvedPath= getResolvedPath(currPath); if (resolvedPath == null) { resolvedPath= Path.EMPTY; } } String ext= resolvedPath.getFileExtension(); if ("jar".equals(ext) || "zip".equals(ext)) { //$NON-NLS-2$ //$NON-NLS-1$ resolvedPath= resolvedPath.removeLastSegments(1); } FileDialog dialog= new FileDialog(getShell()); dialog.setText(NewWizardMessages.getString("SourceAttachmentBlock.extjardialog.text")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {"*.jar;*.zip"}); //$NON-NLS-1$ dialog.setFilterPath(resolvedPath.toOSString()); String res= dialog.open(); if (res != null) { IPath returnPath= new Path(res).makeAbsolute(); if (fIsVariableEntry) { returnPath= modifyPath(returnPath, currPath.segment(0)); } return returnPath; } return null; } /* * Opens a dialog to choose an internal jar. */ private IPath chooseInternalJarFile(String initSelection) { Class[] acceptedClasses= new Class[] { IFile.class }; ISelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); ViewerFilter filter= new ArchiveFileFilter(null); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IResource initSel= fRoot.findMember(new Path(initSelection)); if (initSel == null) { initSel= fRoot.findMember(fJARPath); } ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp); dialog.setAllowMultiple(false); dialog.setValidator(validator); dialog.addFilter(filter); dialog.setTitle(NewWizardMessages.getString("SourceAttachmentBlock.intjardialog.title")); //$NON-NLS-1$ dialog.setMessage(NewWizardMessages.getString("SourceAttachmentBlock.intjardialog.message")); //$NON-NLS-1$ dialog.setInput(fRoot); dialog.setInitialSelection(initSel); if (dialog.open() == dialog.OK) { IFile file= (IFile) dialog.getFirstResult(); return file.getFullPath(); } return null; } /* * Opens a dialog to choose path in a zip file. */ private IPath choosePrefix() { if (fResolvedFile != null) { IPath currPath= new Path(fPrefixField.getText()); String initSelection= null; if (fIsVariableEntry) { IPath resolvedPath= getResolvedPath(currPath); if (resolvedPath != null) { initSelection= resolvedPath.toString(); } } else { initSelection= currPath.toString(); } try { ZipFile zipFile= new ZipFile(fResolvedFile); ZipContentProvider contentProvider= new ZipContentProvider(); contentProvider.setInitialInput(zipFile); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), new ZipLabelProvider(), contentProvider); dialog.setAllowMultiple(false); dialog.setTitle(NewWizardMessages.getString("SourceAttachmentBlock.prefixdialog.title")); //$NON-NLS-1$ dialog.setMessage(NewWizardMessages.getString("SourceAttachmentBlock.prefixdialog.message")); //$NON-NLS-1$ dialog.setInput(zipFile); dialog.setInitialSelection(contentProvider.getSelectedNode(initSelection)); if (dialog.open() == dialog.OK) { Object obj= dialog.getFirstResult(); IPath path= new Path(obj.toString()); if (fIsVariableEntry) { path= modifyPath(path, currPath.segment(0)); } return path; } } catch (IOException e) { String title= NewWizardMessages.getString("SourceAttachmentBlock.prefixdialog.error.title"); //$NON-NLS-1$ String message= NewWizardMessages.getFormattedString("SourceAttachmentBlock.prefixdialog.error.message", fResolvedFile.getPath()); //$NON-NLS-1$ MessageDialog.openError(getShell(), title, message); JavaPlugin.log(e); } } return null; } /* * Opens a dialog to choose a root in the file system. */ private URL chooseJavaDocLocation() { String initPath= ""; //$NON-NLS-1$ if (fJavaDocLocation != null && "file".equals(fJavaDocLocation.getProtocol())) { //$NON-NLS-1$ initPath= (new File(fJavaDocLocation.getFile())).getPath(); } DirectoryDialog dialog= new DirectoryDialog(getShell()); dialog.setText(NewWizardMessages.getString("SourceAttachmentBlock.jdocdialog.text")); //$NON-NLS-1$ dialog.setMessage(NewWizardMessages.getString("SourceAttachmentBlock.jdocdialog.message")); //$NON-NLS-1$ dialog.setFilterPath(initPath); String res= dialog.open(); if (res != null) { try { return (new File(res)).toURL(); } catch (MalformedURLException e) { // should not happen JavaPlugin.log(e); } } return null; } private Shell getShell() { if (fSWTWidget != null) { return fSWTWidget.getShell(); } return JavaPlugin.getActiveWorkbenchShell(); } /** * Takes a path and replaces the beginning with a variable name * (if the beginning matches with the variables value) */ private IPath modifyPath(IPath path, String varName) { if (varName == null || path == null) { return null; } if (path.isEmpty()) { return new Path(varName); } IPath varPath= JavaCore.getClasspathVariable(varName); if (varPath != null) { if (varPath.isPrefixOf(path)) { path= path.removeFirstSegments(varPath.segmentCount()); } else { path= new Path(path.lastSegment()); } } else { path= new Path(path.lastSegment()); } return new Path(varName).append(path); } /** * Creates a runnable that sets the source attachment by modifying the project's classpath. */ public IRunnableWithProgress getRunnable(final IJavaProject jproject, final Shell shell) { return new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { IClasspathEntry newEntry; if (fIsVariableEntry) { newEntry= JavaCore.newVariableEntry(fJARPath, getSourceAttachmentPath(), getSourceAttachmentRootPath(), false); } else { newEntry= JavaCore.newLibraryEntry(fJARPath, getSourceAttachmentPath(), getSourceAttachmentRootPath(), false); } IClasspathEntry[] entries= modifyClasspath(jproject, newEntry, shell); if (entries != null) { jproject.setRawClasspath(entries, monitor); } } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }; } private IClasspathEntry[] modifyClasspath(IJavaProject jproject, IClasspathEntry newEntry, Shell shell) throws JavaModelException{ IClasspathEntry[] oldClasspath= jproject.getRawClasspath(); int nEntries= oldClasspath.length; ArrayList newEntries= new ArrayList(nEntries + 1); int entryKind= newEntry.getEntryKind(); IPath jarPath= newEntry.getPath(); boolean found= false; for (int i= 0; i < nEntries; i++) { IClasspathEntry curr= oldClasspath[i]; if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { // add modified entry newEntries.add(newEntry); found= true; } else { newEntries.add(curr); } } if (!found) { if (newEntry.getSourceAttachmentPath() == null || !putJarOnClasspathDialog(shell)) { return null; } // add new newEntries.add(newEntry); } return (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]); } private boolean putJarOnClasspathDialog(Shell shell) { final boolean[] result= new boolean[1]; shell.getDisplay().syncExec(new Runnable() { public void run() { String title= NewWizardMessages.getString("SourceAttachmentBlock.putoncpdialog.title"); //$NON-NLS-1$ String message= NewWizardMessages.getString("SourceAttachmentBlock.putoncpdialog.message"); //$NON-NLS-1$ result[0]= MessageDialog.openQuestion(JavaPlugin.getActiveWorkbenchShell(), title, message); } }); return result[0]; } }
    5,120
    Bug 5120 Empty popup doc in java editor
    1. Go to Java Perspective. 2. Double click on a java file. 3. Move the i-beam over the beginning prefixes of an import statement. For example, the "org" of "import org.eclipse.swt.SWT". An empty hover help box is displayed.
    resolved fixed
    34be391
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T14:39:24Z
    2001-10-19T19:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/HTMLPrinter.java
    package org.eclipse.jdt.internal.ui.text; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.io.IOException; import java.io.Reader; /** * Provides a set of convenience methods for creating HTML pages. */ public class HTMLPrinter { private HTMLPrinter() { } public static String read(Reader rd) { StringBuffer buffer= new StringBuffer(); char[] readBuffer= new char[2048]; try { int n= rd.read(readBuffer); while (n > 0) { buffer.append(readBuffer, 0, n); n= rd.read(readBuffer); } return buffer.toString(); } catch (IOException x) { } return null; } public static void addPageProlog(StringBuffer buffer) { buffer.append("<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); } public static void addPageEpilog(StringBuffer buffer) { buffer.append("</font></body></html>"); } public static void startBulletList(StringBuffer buffer) { buffer.append("<ul>"); } public static void endBulletList(StringBuffer buffer) { buffer.append("</ul>"); } public static void addBullet(StringBuffer buffer, String bullet) { if (bullet != null) { buffer.append("<li>"); buffer.append(bullet); buffer.append("</li>"); } } public static void addSmallHeader(StringBuffer buffer, String header) { if (header != null) { buffer.append("<h5>"); buffer.append(header); buffer.append("</h5>"); } } public static void addParagraph(StringBuffer buffer, String paragraph) { if (paragraph != null) { buffer.append("<p>"); buffer.append(paragraph); buffer.append("</p>"); } } public static void addParagraph(StringBuffer buffer, Reader paragraphReader) { if (paragraphReader != null) addParagraph(buffer, read(paragraphReader)); } }
    5,120
    Bug 5120 Empty popup doc in java editor
    1. Go to Java Perspective. 2. Double click on a java file. 3. Move the i-beam over the beginning prefixes of an import statement. For example, the "org" of "import org.eclipse.swt.SWT". An empty hover help box is displayed.
    resolved fixed
    34be391
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T14:39:24Z
    2001-10-19T19:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTypeHover.java
    package org.eclipse.jdt.internal.ui.text.java.hover; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.text.HTMLPrinter; import org.eclipse.jdt.internal.ui.text.JavaWordFinder; import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAccess; import org.eclipse.jdt.internal.ui.viewsupport.JavaTextLabelProvider; public class JavaTypeHover implements ITextHover { private IEditorPart fEditor; private JavaTextLabelProvider fTextRenderer; public JavaTypeHover(IEditorPart editor) { fEditor= editor; fTextRenderer= new JavaTextLabelProvider(JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION | JavaElementLabelProvider.SHOW_PARAMETERS); } private ICodeAssist getCodeAssist() { if (fEditor != null) { IEditorInput input= fEditor.getEditorInput(); if (input instanceof ClassFileEditorInput) { ClassFileEditorInput cfeInput= (ClassFileEditorInput) input; return cfeInput.getClassFile(); } IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); return manager.getWorkingCopy(input); } return null; } private String getInfoText(IMember member) { if (member.getElementType() != IJavaElement.TYPE) { StringBuffer buffer= new StringBuffer(); buffer.append(fTextRenderer.getTextLabel(member.getDeclaringType())); buffer.append('.'); buffer.append(fTextRenderer.getTextLabel(member)); return buffer.toString(); } return fTextRenderer.getTextLabel(member); } /* * @see ITextHover#getHoverRegion(ITextViewer, int) */ public IRegion getHoverRegion(ITextViewer textViewer, int offset) { return JavaWordFinder.findWord(textViewer.getDocument(), offset); } /* * @see ITextHover#getHoverInfo(ITextViewer, IRegion) */ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { ICodeAssist resolve= getCodeAssist(); if (resolve != null) { try { IJavaElement[] result= resolve.codeSelect(hoverRegion.getOffset(), hoverRegion.getLength()); if (result == null) return null; int nResults= result.length; if (nResults == 0) return null; StringBuffer buffer= new StringBuffer(); HTMLPrinter.addPageProlog(buffer); if (nResults > 1) { for (int i= 0; i < result.length; i++) { HTMLPrinter.startBulletList(buffer); IJavaElement curr= result[i]; if (curr instanceof IMember) HTMLPrinter.addBullet(buffer, getInfoText((IMember) curr)); HTMLPrinter.endBulletList(buffer); } } else { IJavaElement curr= result[0]; if (curr instanceof IMember) { IMember member= (IMember) curr; HTMLPrinter.addSmallHeader(buffer, getInfoText(member)); HTMLPrinter.addParagraph(buffer, JavaDocAccess.getJavaDoc(member)); } } HTMLPrinter.addPageEpilog(buffer); return buffer.toString(); } catch (JavaModelException x) { JavaPlugin.log(x.getStatus()); } } return null; } }
    3,666
    Bug 3666 CodeCompletion - Hungry code assist (1GDRYW5)
    jkca (5/15/2001 11:04:56 AM) jre-sdk 106 Under certain circumstances code assist eats too much code. Consider the enclosed class. As a programmer, I must add a parameter to the baz call in bar to make the program correct. Steps: 1. Change the baz call to baz(x.x.foo()) 2. Place the cursor after the first "x." 3. Ctrl-Space to bring up code assist 4. Type "f" to filter the list. 5. Select, "foo()" 6. The code is changed to: baz(x.foo().foo()) I would rather it gave me baz(x.foo()x.foo()) public class X { void bar(X x) { baz(x.foo()); } int foo() { return 5; } void baz(int i, int j) { } } KUM (5/21/01 9:02:11 AM) The text to replace is computed by the code assist infrastructure. Moved to ITPJCORE. PM (9/4/2001 2:58:56 PM) Option was added. PM (9/25/2001 2:20:50 PM) Removing option. UI can decide whether it wants to use the codeassist end position (until the end of current identifier) or the cursor location it used to start with, so as to control the amount of source to replace. The choice amongst one or the other should be conditioned by a keystroke (enter=replace until end, insert=replace until cursor location). Moving to ITPJUI. Removing codeassist option.
    verified fixed
    2846b5d
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T15:21:02Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ResultCollector.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import org.eclipse.swt.graphics.Image; import org.eclipse.core.resources.IMarker; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.ICodeCompletionRequestor; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * Bin to collect the proposal of the infrastructure on code assist in a java text. */ public class ResultCollector implements ICodeCompletionRequestor { private class ProposalComparator implements Comparator { public int compare(Object o1, Object o2) { ICompletionProposal c1= (ICompletionProposal) o1; ICompletionProposal c2= (ICompletionProposal) o2; return c1.getDisplayString().compareTo(c2.getDisplayString()); } } private final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-' }; private final static char[] GENERAL_TRIGGERS= new char[] { ';', ',', '.', '\t', '(', '{', '[' }; private ArrayList fFields= new ArrayList(), fKeywords= new ArrayList(), fLabels= new ArrayList(), fMethods= new ArrayList(), fModifiers= new ArrayList(), fPackages= new ArrayList(), fTypes= new ArrayList(), fVariables= new ArrayList(); private IMarker fLastProblem; private IJavaProject fJavaProject; private ICompilationUnit fCompilationUnit; private ArrayList[] fResults = new ArrayList[] { fVariables, fFields, fMethods, fTypes, fKeywords, fModifiers, fLabels, fPackages }; private int fUserReplacementLength; private int fUserReplacementOffset; /* * @see ICompletionRequestor#acceptClass */ public void acceptClass(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) { ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName); fTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_CLASS, new String(typeName), new String(packageName), info)); } /* * @see ICompletionRequestor#acceptError */ public void acceptError(IMarker problemMarker) { fLastProblem= problemMarker; } /* * @see ICompletionRequestor#acceptField */ public void acceptField( char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[] typePackageName, char[] typeName, char[] completionName, int modifiers, int start, int end) { String iconName= JavaPluginImages.IMG_MISC_DEFAULT; if (Flags.isPublic(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PUBLIC; } else if (Flags.isProtected(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PROTECTED; } else if (Flags.isPrivate(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PRIVATE; } StringBuffer nameBuffer= new StringBuffer(); nameBuffer.append(name); if (typeName.length > 0) { nameBuffer.append(" "); //$NON-NLS-1$ nameBuffer.append(typeName); } if (declaringTypeName != null && declaringTypeName.length > 0) { nameBuffer.append(" - "); //$NON-NLS-1$ nameBuffer.append(declaringTypeName); } JavaCompletionProposal proposal= createCompletion(start, end, new String(completionName), iconName, nameBuffer.toString()); proposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name)); fFields.add(proposal); } /* * @see ICompletionRequestor#acceptInterface */ public void acceptInterface(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) { ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName); fTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_INTERFACE, new String(typeName), new String(packageName), info)); } /* * @see ICompletionRequestor#acceptKeyword */ public void acceptKeyword(char[] keyword, int start, int end) { String kw= new String(keyword); fKeywords.add(createCompletion(start, end, kw, null, kw)); } /* * @see ICompletionRequestor#acceptLabel */ public void acceptLabel(char[] labelName, int start, int end) { String ln= new String(labelName); fLabels.add(createCompletion(start, end, ln, null, ln)); } /* * @see ICompletionRequestor#acceptLocalVariable */ public void acceptLocalVariable(char[] name, char[] typePackageName, char[] typeName, int modifiers, int start, int end) { StringBuffer buf= new StringBuffer(); buf.append(name); if (typeName != null) { buf.append(" "); //$NON-NLS-1$ buf.append(typeName); } fVariables.add(createCompletion(start, end, new String(name), null, buf.toString())); } private String getParameterSignature(char[][] parameterTypeNames, char[][] parameterNames) { StringBuffer buf = new StringBuffer(); if (parameterTypeNames != null) { for (int i = 0; i < parameterTypeNames.length; i++) { if (i > 0) { buf.append(','); buf.append(' '); } buf.append(parameterTypeNames[i]); if (parameterNames[i] != null) { buf.append(' '); buf.append(parameterNames[i]); } } } return buf.toString(); } /* * @see ICodeCompletionRequestor#acceptMethod(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int) */ public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) { JavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end); proposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name, parameterPackageNames, parameterTypeNames)); boolean hasClosingBracket= completionName.length > 0 && completionName[completionName.length - 1] == ')'; ProposalContextInformation contextInformation= null; if (hasClosingBracket && parameterTypeNames.length > 0) { contextInformation= new ProposalContextInformation(); contextInformation.setInformationDisplayString(getParameterSignature(parameterTypeNames, parameterNames)); contextInformation.setContextDisplayString(proposal.getDisplayString()); proposal.setContextInformation(contextInformation); } boolean userMustCompleteParameters= (contextInformation != null && completionName.length > 0); char[] triggers= userMustCompleteParameters ? METHOD_WITH_ARGUMENTS_TRIGGERS : GENERAL_TRIGGERS; proposal.setTriggerCharacters(triggers); if (userMustCompleteParameters) { // set the cursor before the closing bracket proposal.setCursorPosition(completionName.length - 1); } fMethods.add(proposal); } /* * @see ICompletionRequestor#acceptModifier */ public void acceptModifier(char[] modifier, int start, int end) { String mod= new String(modifier); fModifiers.add(createCompletion(start, end, mod, null, mod)); } /* * @see ICompletionRequestor#acceptPackage */ public void acceptPackage(char[] packageName, char[] completionName, int start, int end) { fPackages.add(createCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_PACKAGE, new String(packageName))); } /* * @see ICompletionRequestor#acceptType */ public void acceptType(char[] packageName, char[] typeName, char[] completionName, int start, int end) { ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName); fTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.IMG_OBJS_CLASS, new String(typeName), new String(packageName), info)); } /* * @see ICodeCompletionRequestor#acceptMethodDeclaration(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int) */ public void acceptMethodDeclaration(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) { // XXX: To be revised JavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end); fMethods.add(proposal); } /* * @see ICodeCompletionRequestor#acceptVariableName(char[], char[], char[], char[], int, int) */ public void acceptVariableName(char[] typePackageName, char[] typeName, char[] name, char[] completionName, int start, int end) { // XXX: To be revised StringBuffer buf= new StringBuffer(); buf.append(name); if (typeName != null && typeName.length > 0) { buf.append(" - "); //$NON-NLS-1$ buf.append(typeName); } fVariables.add(createCompletion(start, end, new String(completionName), null, buf.toString())); } public String getErrorMessage() { if (fLastProblem != null) return fLastProblem.getAttribute(IMarker.MESSAGE, JavaTextMessages.getString("ResultCollector.compile_error.message")); //$NON-NLS-1$ return ""; //$NON-NLS-1$ } public ICompletionProposal[] getResults() { ArrayList result= new ArrayList(); ProposalComparator comperator= new ProposalComparator(); for (int i= 0; i < fResults.length; i++) { ArrayList bucket = fResults[i]; int size= bucket.size(); if (size == 1) { result.add(bucket.get(0)); } else if (size > 1) { Object[] sortedBucket = new Object[size]; bucket.toArray(sortedBucket); Arrays.sort(sortedBucket, comperator); for (int j= 0; j < sortedBucket.length; j++) result.add(sortedBucket[j]); } } return (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]); } protected JavaCompletionProposal createMethodCompletion(char[] declaringTypeName, char[] name, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) { String iconName= JavaPluginImages.IMG_MISC_DEFAULT; if (Flags.isPublic(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PUBLIC; } else if (Flags.isProtected(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PROTECTED; } else if (Flags.isPrivate(modifiers)) { iconName= JavaPluginImages.IMG_MISC_PRIVATE; } StringBuffer nameBuffer= new StringBuffer(); nameBuffer.append(name); nameBuffer.append('('); if (parameterTypeNames.length > 0) { nameBuffer.append(getParameterSignature(parameterTypeNames, parameterNames)); } nameBuffer.append(')'); if (returnTypeName.length > 0) { nameBuffer.append(" "); //$NON-NLS-1$ nameBuffer.append(returnTypeName); } if (declaringTypeName.length > 0) { nameBuffer.append(" - "); //$NON-NLS-1$ nameBuffer.append(declaringTypeName); } return createCompletion(start, end, new String(completionName), iconName, nameBuffer.toString()); } protected JavaCompletionProposal createTypeCompletion(int start, int end, String completion, String iconName, String typeName, String containerName, ProposalInfo proposalInfo) { IImportDeclaration importDeclaration= null; if (containerName != null && fCompilationUnit != null) { if (completion.equals(JavaModelUtil.concatenateName(containerName, typeName))) { importDeclaration= fCompilationUnit.getImport(completion); completion= typeName; } } StringBuffer buf= new StringBuffer(typeName); if (containerName != null) { buf.append(" - "); //$NON-NLS-1$ buf.append(containerName); } String name= buf.toString(); JavaCompletionProposal proposal= createCompletion(start, end, completion, iconName, name); proposal.setImportDeclaration(importDeclaration); proposal.setProposalInfo(proposalInfo); return proposal; } protected JavaCompletionProposal createCompletion(int start, int end, String completion, String iconName, String name) { int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; } if (fUserReplacementOffset != -1) { start= fUserReplacementOffset; } Image icon= null; if (iconName != null) icon= JavaPluginImages.get(iconName); return new JavaCompletionProposal(completion, start, length, icon, name); } /** * Specifies the context of the code assist operation. * @param jproject The Java project to which the underlying source belongs. * Needed to find types referred. * @param cu The compilation unit that is edited. Used to add import statements. * Can be <code>null</code> if no import statements should be added. */ public void reset(IJavaProject jproject, ICompilationUnit cu) { fJavaProject= jproject; fCompilationUnit= cu; fUserReplacementLength= -1; fUserReplacementOffset= -1; fLastProblem= null; for (int i= 0; i < fResults.length; i++) fResults[i].clear(); } /** * If the replacement length is set, it overrides the length returned from * the content assist infrastructure. * Use this setting if code assist is called with a none empty selection. */ public void setReplacementLength(int length) { fUserReplacementLength= length; } /** * If the replacement offset is set, it overrides the offset used for the content assist. * Use this setting if the code assist proposals generated will be applied on a document different than * the one used for evaluating the code assist. */ public void setReplacementOffset(int offset) { fUserReplacementOffset= offset; } }
    5,144
    Bug 5144 Error when opening display view
    205 1. Put a breakpoint in VectorTest.testCapacity (anywhere) 2. Debug to the breakpoint (IBM JRE) 3. Close the display view. 4. Open the display view again (perspective -> show view) java.lang.NullPointerException Stack trace: java/lang/Throwable.<init>()V java/lang/Throwable.<init>(Ljava/lang/String;)V java/lang/NullPointerException.<init>(Ljava/lang/String;)V org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.update()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.updateEvalActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.initializeActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.createPartControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane$2.run()V org/eclipse/core/internal/runtime/InternalPlatform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/core/runtime/Platform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/ui/internal/PartPane.createChildControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/ViewPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartTabFolder.createPartTab (Lorg/eclipse/ui/internal/LayoutPart;Ljava/lang/String;I) Lorg/eclipse/swt/custom/CTabItem; org/eclipse/ui/internal/PartTabFolder.replaceChild (Lorg/eclipse/ui/internal/PartPlaceholder;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PartTabFolder.replace (Lorg/eclipse/ui/internal/LayoutPart;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PerspectivePresentation.addPart (Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/Perspective.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.busyShowView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.access$4 (Lorg/eclipse/ui/internal/WorkbenchPage;Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage$7.run()V org/eclipse/swt/custom/BusyIndicator.showWhile (Lorg/eclipse/swt/widgets/Display;Ljava/lang/Runnable;)V org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/ShowViewMenu.showOther()V org/eclipse/ui/internal/ShowViewMenu.access$0 (Lorg/eclipse/ui/internal/ShowViewMenu;)V org/eclipse/ui/internal/ShowViewMenu$1.run()V org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.access$0 (Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event ;)V org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/swt/widgets/Widget.notifyListeners (ILorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Display.runDeferredEvents()Z org/eclipse/swt/widgets/Display.readAndDispatch()Z org/eclipse/ui/internal/Workbench.runEventLoop()V org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object; org/eclipse/core/internal/boot/InternalBootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; org/eclipse/core/boot/BootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; SlimLauncher.main([Ljava/lang/String;)V
    verified fixed
    d4387e6
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T20:33:59Z
    2001-10-22T17:00:00Z
    org.eclipse.jdt.ui/ui
    5,144
    Bug 5144 Error when opening display view
    205 1. Put a breakpoint in VectorTest.testCapacity (anywhere) 2. Debug to the breakpoint (IBM JRE) 3. Close the display view. 4. Open the display view again (perspective -> show view) java.lang.NullPointerException Stack trace: java/lang/Throwable.<init>()V java/lang/Throwable.<init>(Ljava/lang/String;)V java/lang/NullPointerException.<init>(Ljava/lang/String;)V org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.update()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.updateEvalActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.initializeActions()V org/eclipse/jdt/internal/debug/ui/display/DisplayView.createPartControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane$2.run()V org/eclipse/core/internal/runtime/InternalPlatform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/core/runtime/Platform.run (Lorg/eclipse/core/runtime/ISafeRunnable;)V org/eclipse/ui/internal/PartPane.createChildControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/ViewPane.createControl (Lorg/eclipse/swt/widgets/Composite;)V org/eclipse/ui/internal/PartTabFolder.createPartTab (Lorg/eclipse/ui/internal/LayoutPart;Ljava/lang/String;I) Lorg/eclipse/swt/custom/CTabItem; org/eclipse/ui/internal/PartTabFolder.replaceChild (Lorg/eclipse/ui/internal/PartPlaceholder;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PartTabFolder.replace (Lorg/eclipse/ui/internal/LayoutPart;Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/PerspectivePresentation.addPart (Lorg/eclipse/ui/internal/LayoutPart;)V org/eclipse/ui/internal/Perspective.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.busyShowView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.access$4 (Lorg/eclipse/ui/internal/WorkbenchPage;Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage$7.run()V org/eclipse/swt/custom/BusyIndicator.showWhile (Lorg/eclipse/swt/widgets/Display;Ljava/lang/Runnable;)V org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;Z) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/WorkbenchPage.showView(Ljava/lang/String;) Lorg/eclipse/ui/IViewPart; org/eclipse/ui/internal/ShowViewMenu.showOther()V org/eclipse/ui/internal/ShowViewMenu.access$0 (Lorg/eclipse/ui/internal/ShowViewMenu;)V org/eclipse/ui/internal/ShowViewMenu$1.run()V org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.access$0 (Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event ;)V org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;) V org/eclipse/swt/widgets/Widget.notifyListeners (ILorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Display.runDeferredEvents()Z org/eclipse/swt/widgets/Display.readAndDispatch()Z org/eclipse/ui/internal/Workbench.runEventLoop()V org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object; org/eclipse/core/internal/boot/InternalBootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; org/eclipse/core/boot/BootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;) Ljava/lang/Object; SlimLauncher.main([Ljava/lang/String;)V
    verified fixed
    d4387e6
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-22T20:33:59Z
    2001-10-22T17:00:00Z
    debug/org/eclipse/jdt/internal/debug/ui/display/EvaluateAction.java
    5,116
    Bug 5116 Showing methods in the Type Hierarchy View is redundant
    It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?
    resolved fixed
    0fa38ed
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-23T11:00:10Z
    2001-10-19T16:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/ToggleOrientationAction.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.typehierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * Toggles horizontaol / vertical layout of the type hierarchy */ public class ToggleOrientationAction extends Action { private TypeHierarchyViewPart fView; public ToggleOrientationAction(TypeHierarchyViewPart v, boolean initHorizontal) { super(TypeHierarchyMessages.getString("ToggleOrientationAction.label")); //$NON-NLS-1$ setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.description")); //$NON-NLS-1$ setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "impl_co.gif"); //$NON-NLS-1$ fView= v; setChecked(initHorizontal); } /* * @see Action#actionPerformed */ public void run() { fView.setOrientation(isChecked()); // will toggle the checked state } /* * @see Action#setChecked */ public void setChecked(boolean checked) { if (checked) { setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.tooltip.checked")); //$NON-NLS-1$ } else { setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.tooltip.unchecked")); //$NON-NLS-1$ } super.setChecked(checked); } }
    5,116
    Bug 5116 Showing methods in the Type Hierarchy View is redundant
    It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?
    resolved fixed
    0fa38ed
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-23T11:00:10Z
    2001-10-19T16:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/ToggleViewAction.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.typehierarchy; import org.eclipse.jface.action.Action; import org.eclipse.ui.help.WorkbenchHelp; /** * Action to switch between the different hierarchy views. */ public class ToggleViewAction extends Action { private TypeHierarchyViewPart fViewPart; private int fViewerIndex; public ToggleViewAction(TypeHierarchyViewPart v, int viewerIndex, String title, String contextHelpId, boolean isChecked) { super(title); fViewPart= v; fViewerIndex= viewerIndex; setChecked(isChecked); WorkbenchHelp.setHelp(this, new Object[] { contextHelpId }); } public int getViewerIndex() { return fViewerIndex; } /* * @see Action#actionPerformed */ public void run() { fViewPart.setView(fViewerIndex); } }
    5,116
    Bug 5116 Showing methods in the Type Hierarchy View is redundant
    It seems that showing methods in the Type Hierarchy View is reduntant. Couldn't we remove it and make the Type Hierarchy Perspective composed by the upper part of the Type Hierarchy View (showing the types) plus the outliner?
    resolved fixed
    0fa38ed
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-23T11:00:10Z
    2001-10-19T16:46:40Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.typehierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ViewForm; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSource; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.viewers.IInputSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.OpenWithMenu; import org.eclipse.ui.help.ViewContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.ITypeHierarchyViewPart; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.actions.AddMethodStubAction; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction; import org.eclipse.jdt.internal.ui.dnd.BasicSelectionTransferDragAdapter; import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.packageview.BuildGroup; import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage; import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup; import org.eclipse.jdt.internal.ui.reorg.ReorgGroup; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.util.SelectionUtil; import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener; import org.eclipse.jdt.internal.ui.viewsupport.MarkerErrorTickProvider; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; /** * view showing the supertypes/subtypes of its input. */ public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart { public static final int VIEW_ID_TYPE= 2; public static final int VIEW_ID_SUPER= 0; public static final int VIEW_ID_SUB= 1; private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String TAG_INPUT= "input"; //$NON-NLS-1$ private static final String TAG_VIEW= "view"; //$NON-NLS-1$ private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$ private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$ private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$ private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$ private IType fInput; private IMemento fMemento; private ArrayList fInputHistory; private int fCurrHistoryIndex; private IProblemChangedListener fHierarchyProblemListener; private TypeHierarchyLifeCycle fHierarchyLifeCycle; private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener; private MethodsViewer fMethodsViewer; private int fCurrentViewerIndex; private TypeHierarchyViewer[] fAllViewers; private boolean fIsEnableMemberFilter; private SashForm fTypeMethodsSplitter; private PageBook fViewerbook; private PageBook fPagebook; private Label fNoHierarchyShownLabel; private Label fEmptyTypesViewer; private ViewForm fTypeViewerViewForm; private CLabel fMethodViewerPaneLabel; private JavaElementLabelProvider fPaneLabelProvider; private IDialogSettings fDialogSettings; private ToggleViewAction[] fViewActions; private HistoryDropDownAction fHistoryDropDownAction; private ToggleOrientationAction fToggleOrientationAction; private EnableMemberFilterAction fEnableMemberFilterAction; private AddMethodStubAction fAddStubAction; private FocusOnTypeAction fFocusOnTypeAction; private FocusOnSelectionAction fFocusOnSelectionAction; private IPartListener fPartListener; public TypeHierarchyViewPart() { fHierarchyLifeCycle= new TypeHierarchyLifeCycle(); fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() { public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) { doTypeHierarchyChanged(typeHierarchy, changedTypes); } }; fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener); fHierarchyProblemListener= null; fIsEnableMemberFilter= false; fInputHistory= new ArrayList(); fCurrHistoryIndex= -1; fAllViewers= null; String title= TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.supertypes.label"); //$NON-NLS-1$ String contextHelpId= IJavaHelpContextIds.SHOW_SUPERTYPES; ToggleViewAction superViewAction= new ToggleViewAction(this, VIEW_ID_SUPER, title, contextHelpId, true); superViewAction.setDescription(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.supertypes.description")); //$NON-NLS-1$ superViewAction.setToolTipText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.supertypes.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(superViewAction, "super_co.gif"); //$NON-NLS-1$ title= TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.subtypes.label"); //$NON-NLS-1$ contextHelpId= IJavaHelpContextIds.SHOW_SUPERTYPES; ToggleViewAction subViewAction= new ToggleViewAction(this, VIEW_ID_SUB, title, contextHelpId, false); subViewAction.setDescription(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.subtypes.description")); //$NON-NLS-1$ subViewAction.setToolTipText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.subtypes.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(subViewAction, "sub_co.gif"); //$NON-NLS-1$ title= TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.vajhierarchy.label"); //$NON-NLS-1$ ToggleViewAction vajViewAction= new ToggleViewAction(this, VIEW_ID_TYPE, title, contextHelpId, false); vajViewAction.setDescription(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.vajhierarchy.description")); //$NON-NLS-1$ vajViewAction.setToolTipText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.toggleaction.vajhierarchy.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(vajViewAction, "hierarchy_co.gif"); //$NON-NLS-2$ fViewActions= new ToggleViewAction[] { vajViewAction, superViewAction, subViewAction }; fDialogSettings= JavaPlugin.getDefault().getDialogSettings(); fHistoryDropDownAction= new HistoryDropDownAction(this); fToggleOrientationAction= new ToggleOrientationAction(this, fDialogSettings.getBoolean(DIALOGSTORE_VIEWORIENTATION)); fEnableMemberFilterAction= new EnableMemberFilterAction(this, false); fFocusOnTypeAction= new FocusOnTypeAction(this); fPaneLabelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS); fPaneLabelProvider.setErrorTickManager(new MarkerErrorTickProvider()); fAddStubAction= new AddMethodStubAction(); fFocusOnSelectionAction= new FocusOnSelectionAction(this); fPartListener= new IPartListener() { public void partActivated(IWorkbenchPart part) { if (part instanceof IEditorPart) editorActivated((IEditorPart) part); } public void partBroughtToTop(IWorkbenchPart part) {} public void partClosed(IWorkbenchPart part) {} public void partDeactivated(IWorkbenchPart part) {} public void partOpened(IWorkbenchPart part) {} }; } /** * Selects an member in the methods list */ public void selectMember(IMember member) { fMethodsViewer.setSelection(new StructuredSelection(member), true); } /** * Gets the current input (IType) */ public IType getInput() { return fInput; } private void addHistoryEntry(IType entry) { fCurrHistoryIndex= fInputHistory.size(); fInputHistory.add(entry); } /** * Gets the entry at the given index. * @param index The index of the entry * @return The entry from the index or null if no entry available */ public IType getHistoryEntry(int index) { while (index >= 0 && index < fInputHistory.size()) { IType type= (IType) fInputHistory.get(index); if (type.exists()) { return type; } else { fInputHistory.remove(index); if (fCurrHistoryIndex >= index && fCurrHistoryIndex > 0) { fCurrHistoryIndex--; } } } return null; } /** * Goes to the next or previous entry from the history */ public void gotoHistoryEntry(int index) { IType elem= getHistoryEntry(index); if (elem != null) { updateInput(elem); fCurrHistoryIndex= index; } } public int getCurrentHistoryIndex() { return fCurrHistoryIndex; } /** * Sets the input to a new type */ public void setInput(IType type) { if (type != null) { ICompilationUnit cu= type.getCompilationUnit(); if (cu != null && cu.isWorkingCopy()) { type= (IType)cu.getOriginal(type); } } if (type != null && !type.equals(fInput)) { addHistoryEntry(type); } updateInput(type); } /** * Changes the input to a new type */ public void updateInput(IType type) { boolean typeChanged= (type != fInput); fInput= type; if (fInput == null) { clearInput(); } else { // turn off member filtering enableMemberFilter(false); try { fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInput); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); clearInput(); return; } fPagebook.showPage(fTypeMethodsSplitter); if (typeChanged) { updateHierarchyViewer(); } getCurrentViewer().setSelection(new StructuredSelection(fInput)); updateMethodViewer(fInput); updateTitle(); } } private void clearInput() { fInput= null; fHierarchyLifeCycle.freeHierarchy(); updateHierarchyViewer(); } /* * @see IWorbenchPart#setFocus */ public void setFocus() { fPagebook.setFocus(); } /* * @see IWorkbenchPart#dispose */ public void dispose() { fHierarchyLifeCycle.freeHierarchy(); fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener); fPaneLabelProvider.dispose(); getSite().getPage().removePartListener(fPartListener); if (fHierarchyProblemListener != null) { JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener); } if (fMethodsViewer != null) { JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fMethodsViewer); } super.dispose(); } private Control createTypeViewerControl(Composite parent) { fViewerbook= new PageBook(parent, SWT.NULL); ISelectionChangedListener selectionChangedListener= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { typeSelectionChanged(event.getSelection()); } }; KeyListener keyListener= new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.stateMask == SWT.NONE) { if (event.keyCode == SWT.F4) { Object elem= SelectionUtil.getSingleElement(getCurrentViewer().getSelection()); if (elem instanceof IType) { IType[] arr= new IType[] { (IType) elem }; OpenTypeHierarchyUtil.open(arr, getSite().getWorkbenchWindow()); } else { getCurrentViewer().getControl().getDisplay().beep(); } return; } else if (event.keyCode == SWT.F5) { updateHierarchyViewer(); return; } } viewPartKeyShortcuts(event); } }; // Create the viewers TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this); initializeTypesViewer(superTypesViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW); TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this); initializeTypesViewer(subTypesViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW); TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this); initializeTypesViewer(vajViewer, selectionChangedListener, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW); fAllViewers= new TypeHierarchyViewer[3]; fAllViewers[VIEW_ID_SUPER]= superTypesViewer; fAllViewers[VIEW_ID_SUB]= subTypesViewer; fAllViewers[VIEW_ID_TYPE]= vajViewer; int currViewerIndex; try { currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW); if (currViewerIndex < 0 || currViewerIndex > 2) { currViewerIndex= VIEW_ID_TYPE; } } catch (NumberFormatException e) { currViewerIndex= VIEW_ID_TYPE; } fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT); for (int i= 0; i < fAllViewers.length; i++) { fAllViewers[i].setInput(fAllViewers[i]); } // force the update fCurrentViewerIndex= -1; setView(currViewerIndex); return fViewerbook; } private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, ISelectionChangedListener selectionChangedListener, KeyListener keyListener, String cotextHelpId) { typesViewer.getControl().setVisible(false); typesViewer.getControl().addKeyListener(keyListener); typesViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillTypesViewerContextMenu(typesViewer, menu); } }, cotextHelpId, getSite()); typesViewer.addSelectionChangedListener(selectionChangedListener); } private Control createMethodViewerControl(Composite parent) { fMethodsViewer= new MethodsViewer(parent, this); fMethodsViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillMethodsViewerContextMenu(menu); } }, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite()); fMethodsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { methodSelectionChanged(event.getSelection()); } }); Control control= fMethodsViewer.getTable(); control.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { viewPartKeyShortcuts(event); } }); JavaPlugin.getDefault().getProblemMarkerManager().addListener(fMethodsViewer); return control; } private void initDragAndDrop() { Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() }; int ops= DND.DROP_COPY; DragSource source= new DragSource(fMethodsViewer.getControl(), ops); source.setTransfer(transfers); source.addDragListener(new BasicSelectionTransferDragAdapter(fMethodsViewer)); for (int i= 0; i < fAllViewers.length; i++) { TypeHierarchyViewer curr= fAllViewers[i]; curr.addDropSupport(ops, transfers, new TypeHierarchyTransferDropAdapter(curr)); } } private void viewPartKeyShortcuts(KeyEvent event) { if (event.stateMask == SWT.CTRL) { if (event.character == '1') { setView(VIEW_ID_TYPE); } else if (event.character == '2') { setView(VIEW_ID_SUPER); } else if (event.character == '3') { setView(VIEW_ID_SUB); } } } /** * Returns the inner component in a workbench part. * @see IWorkbenchPart#createPartControl */ public void createPartControl(Composite container) { fPagebook= new PageBook(container, SWT.NONE); // page 1 of pagebook (viewers) fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL); fTypeMethodsSplitter.setVisible(false); fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE); Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm); fTypeViewerViewForm.setContent(typeViewerControl); ViewForm methodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE); fTypeMethodsSplitter.setWeights(new int[] {35, 65}); Control methodViewerPart= createMethodViewerControl(methodViewerViewForm); methodViewerViewForm.setContent(methodViewerPart); fMethodViewerPaneLabel= new CLabel(methodViewerViewForm, SWT.NONE); methodViewerViewForm.setTopLeft(fMethodViewerPaneLabel); initDragAndDrop(); ToolBar methodViewerToolBar= new ToolBar(methodViewerViewForm, SWT.FLAT | SWT.WRAP); methodViewerViewForm.setTopCenter(methodViewerToolBar); // page 2 of pagebook (no hierarchy label) fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$ MenuManager menu= new MenuManager(); menu.add(fFocusOnTypeAction); fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel)); fPagebook.showPage(fNoHierarchyShownLabel); // will fill the main tool bar setOrientation(fToggleOrientationAction.isChecked()); // set the filter menu items IActionBars actionBars= getViewSite().getActionBars(); IMenuManager viewMenu= actionBars.getMenuManager(); viewMenu.add(fToggleOrientationAction); // fill the method viewer toolbar ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar); lowertbmanager.add(fEnableMemberFilterAction); lowertbmanager.add(new Separator()); fMethodsViewer.contributeToToolBar(lowertbmanager); lowertbmanager.update(true); // selection provider int nHierarchyViewers= fAllViewers.length; Viewer[] trackedViewers= new Viewer[nHierarchyViewers + 1]; for (int i= 0; i < nHierarchyViewers; i++) { trackedViewers[i]= fAllViewers[i]; } trackedViewers[nHierarchyViewers]= fMethodsViewer; ISelectionProvider selProvider= new SelectionProviderMediator(trackedViewers); IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager(); selProvider.addSelectionChangedListener(new StatusBarUpdater(slManager)); getSite().setSelectionProvider(selProvider); getSite().getPage().addPartListener(fPartListener); IType input= determineInputElement(); if (fMemento != null) { restoreState(fMemento, input); } else if (input != null) { setInput(input); } else { setViewerVisibility(false); } // fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing WorkbenchHelp.setHelp(fPagebook, new ViewContextComputer(this, IJavaHelpContextIds.TYPE_HIERARCHY_VIEW)); } /** * called from ToggleOrientationAction */ public void setOrientation(boolean horizontal) { if (fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) { fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); updateMainToolbar(horizontal); } fToggleOrientationAction.setChecked(horizontal); fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, horizontal); } private void updateMainToolbar(boolean horizontal) { IActionBars actionBars= getViewSite().getActionBars(); IToolBarManager tbmanager= actionBars.getToolBarManager(); if (horizontal) { clearMainToolBar(tbmanager); ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP); fillMainToolBar(new ToolBarManager(typeViewerToolBar)); fTypeViewerViewForm.setTopLeft(typeViewerToolBar); } else { fTypeViewerViewForm.setTopLeft(null); fillMainToolBar(tbmanager); } } private void fillMainToolBar(IToolBarManager tbmanager) { tbmanager.removeAll(); tbmanager.add(fHistoryDropDownAction); for (int i= 0; i < fViewActions.length; i++) { tbmanager.add(fViewActions[i]); } tbmanager.update(false); } private void clearMainToolBar(IToolBarManager tbmanager) { tbmanager.removeAll(); tbmanager.update(false); } /** * Creates the context menu for the hierarchy viewers */ private void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) { JavaPlugin.createStandardGroups(menu); // viewer entries viewer.contributeToContextMenu(menu); IStructuredSelection selection= (IStructuredSelection)viewer.getSelection(); if (JavaBasePreferencePage.openTypeHierarchyInPerspective()) { addOpenPerspectiveItem(menu, selection); } addOpenWithMenu(menu, selection); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnTypeAction); if (fFocusOnSelectionAction.canActionBeAdded()) menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnSelectionAction); addRefactoring(menu, viewer); ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, viewer); } /** * Creates the context menu for the method viewer */ private void fillMethodsViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); // viewer entries fMethodsViewer.contributeToContextMenu(menu); if (fAddStubAction.init(fInput, fMethodsViewer.getSelection())) { menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddStubAction); } menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fMethodsViewer)); addOpenWithMenu(menu, (IStructuredSelection)fMethodsViewer.getSelection()); addRefactoring(menu, fMethodsViewer); ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, fMethodsViewer); } private void addRefactoring(IMenuManager menu, IInputSelectionProvider viewer){ MenuManager refactoring= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.refactor")); //$NON-NLS-1$ ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, viewer); if (!refactoring.isEmpty()) menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring); } private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { // If one file is selected get it. // Otherwise, do not show the "open with" menu. if (selection.size() != 1) return; Object element= selection.getFirstElement(); if (!(element instanceof IJavaElement)) return; IResource resource= null; try { resource= ((IJavaElement)element).getUnderlyingResource(); } catch(JavaModelException e) { // ignore } if (!(resource instanceof IFile)) return; // Create a menu flyout. MenuManager submenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.open")); //$NON-NLS-1$ submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } private void addOpenPerspectiveItem(IMenuManager menu, IStructuredSelection selection) { OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, selection); } /** * Toggles between the empty viewer page and the hierarchy */ private void setViewerVisibility(boolean showHierarchy) { if (showHierarchy) { fViewerbook.showPage(getCurrentViewer().getControl()); } else { fViewerbook.showPage(fEmptyTypesViewer); } } /** * Sets the member filter. <code>null</code> disables member filtering. */ private void setMemberFilter(IMember[] memberFilter) { Assert.isNotNull(fAllViewers); for (int i= 0; i < fAllViewers.length; i++) { fAllViewers[i].setMemberFilter(memberFilter); } updateHierarchyViewer(); updateTitle(); } /** * When the input changed or the hierarchy pane becomes visible, * <code>updateHierarchyViewer<code> brings up the correct view and refreshes * the current tree */ private void updateHierarchyViewer() { if (fInput == null) { fPagebook.showPage(fNoHierarchyShownLabel); } else { if (getCurrentViewer().containsElements()) { Runnable runnable= new Runnable() { public void run() { getCurrentViewer().updateContent(); } }; BusyIndicator.showWhile(getDisplay(), runnable); if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) { setViewerVisibility(true); } } else { fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInput.getElementName())); //$NON-NLS-1$ setViewerVisibility(false); } } } private void updateMethodViewer(IType input) { if (input != fMethodsViewer.getInput()) { if (input != null) { fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input)); fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input)); } else { fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$ fMethodViewerPaneLabel.setImage(null); } fMethodsViewer.setInput(input); } } private void methodSelectionChanged(ISelection sel) { if (sel instanceof IStructuredSelection) { List selected= ((IStructuredSelection)sel).toList(); int nSelected= selected.size(); if (fIsEnableMemberFilter) { IMember[] memberFilter= null; if (nSelected > 0) { memberFilter= new IMember[nSelected]; selected.toArray(memberFilter); } setMemberFilter(memberFilter); } if (nSelected == 1) { revealElementInEditor(selected.get(0)); } } } private void typeSelectionChanged(ISelection sel) { if (sel instanceof IStructuredSelection) { List selected= ((IStructuredSelection)sel).toList(); int nSelected= selected.size(); if (nSelected != 0) { List types= new ArrayList(nSelected); for (int i= nSelected-1; i >= 0; i--) { Object elem= selected.get(i); if (elem instanceof IType && !types.contains(elem)) { types.add(elem); } } if (types.size() == 1) { IType selectedType= (IType)types.get(0); if (!fIsEnableMemberFilter && !selectedType.equals(fMethodsViewer.getInput())) { updateMethodViewer(selectedType); } } else if (types.size() == 0) { // method selected, no change } if (nSelected == 1) { revealElementInEditor(selected.get(0)); } } else { if (!fIsEnableMemberFilter && fMethodsViewer.getInput() != null) { updateMethodViewer(null); } } } } private void revealElementInEditor(Object elem) { // only allow revealing when the type hierarchy is the active pagae // no revealing after selection events due to model changes if (getSite().getPage().getActivePart() != this) { return; } IEditorPart editorPart= EditorUtility.isOpenInEditor(elem); if (editorPart != null && (elem instanceof ISourceReference)) { try { EditorUtility.openInEditor(elem, false); EditorUtility.revealInEditor(editorPart, (ISourceReference)elem); } catch (CoreException e) { JavaPlugin.log(e); } } } private Display getDisplay() { if (fPagebook != null && !fPagebook.isDisposed()) { return fPagebook.getDisplay(); } return null; } private boolean isChildVisible(Composite pb, Control child) { Control[] children= pb.getChildren(); for (int i= 0; i < children.length; i++) { if (children[i] == child && children[i].isVisible()) return true; } return false; } private void updateTitle() { String title= getCurrentViewer().getTitle(); setTitle(getCurrentViewer().getTitle()); String tooltip; if (fInput != null) { String[] args= new String[] { title, JavaModelUtil.getFullyQualifiedName(fInput) }; tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$ } else { tooltip= title; } setTitleToolTip(tooltip); } /** * Sets the current view (see view id) * called from ToggleViewAction. Must be called after creation of the viewpart. */ public void setView(int viewerIndex) { Assert.isNotNull(fAllViewers); if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) { fCurrentViewerIndex= viewerIndex; updateHierarchyViewer(); if (fInput != null) { ISelection currSelection= getCurrentViewer().getSelection(); if (currSelection == null || currSelection.isEmpty()) { getCurrentViewer().setSelection(new StructuredSelection(getInput())); } if (!fIsEnableMemberFilter) { typeSelectionChanged(getCurrentViewer().getSelection()); } } updateTitle(); if (fHierarchyProblemListener != null) { JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener); } fHierarchyProblemListener= getCurrentViewer(); JavaPlugin.getDefault().getProblemMarkerManager().addListener(fHierarchyProblemListener); fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex); getCurrentViewer().getTree().setFocus(); } for (int i= 0; i < fViewActions.length; i++) { ToggleViewAction action= fViewActions[i]; action.setChecked(fCurrentViewerIndex == action.getViewerIndex()); } } /** * Gets the curret active view index. */ public int getViewIndex() { return fCurrentViewerIndex; } private TypeHierarchyViewer getCurrentViewer() { return fAllViewers[fCurrentViewerIndex]; } /** * called from EnableMemberFilterAction. * Must be called after creation of the viewpart. */ public void enableMemberFilter(boolean on) { if (on != fIsEnableMemberFilter) { fIsEnableMemberFilter= on; if (!on) { Object methodViewerInput= fMethodsViewer.getInput(); IType input= getInput(); setMemberFilter(null); if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) { // avoid that the method view changes content by selecting the previous input getCurrentViewer().setSelection(new StructuredSelection(methodViewerInput)); } else if (input != null) { // choose a input that exists getCurrentViewer().setSelection(new StructuredSelection(input)); updateMethodViewer(input); } } else { methodSelectionChanged(fMethodsViewer.getSelection()); } } fEnableMemberFilterAction.setChecked(on); } /** * Called from ITypeHierarchyLifeCycleListener. * Can be called from any thread */ private void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final IType[] changedTypes) { Display display= getDisplay(); if (display != null) { display.asyncExec(new Runnable() { public void run() { doTypeHierarchyChangedOnViewers(changedTypes); } }); } } private void doTypeHierarchyChangedOnViewers(IType[] changedTypes) { if (changedTypes == null) { // hierarchy change if (!fHierarchyLifeCycle.getHierarchy().exists()) { clearInput(); } else { try { fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInput); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); clearInput(); return; } updateHierarchyViewer(); } } else { // elements in hierarchy modified if (getCurrentViewer().isMethodFiltering()) { if (changedTypes.length == 1) { getCurrentViewer().refresh(changedTypes[0]); } else { updateHierarchyViewer(); } } else { getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } ); } } } /** * Determines the input element to be used initially . */ private IType determineInputElement() { Object input= getSite().getPage().getInput(); if (input instanceof IType) { return (IType)input; } return null; } /* * @see IViewPart#init */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento= memento; } /* * @see ViewPart#saveState(IMemento) */ public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } if (fInput != null) { memento.putString(TAG_INPUT, fInput.getHandleIdentifier()); } memento.putInteger(TAG_VIEW, getViewIndex()); memento.putInteger(TAG_ORIENTATION, fToggleOrientationAction.isChecked() ? 1 : 0); int weigths[]= fTypeMethodsSplitter.getWeights(); int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); ScrollBar bar= getCurrentViewer().getTree().getVerticalBar(); int position= bar != null ? bar.getSelection() : 0; memento.putInteger(TAG_VERTICAL_SCROLL, position); IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement(); if (selection != null) { memento.putString(TAG_SELECTION, selection.getHandleIdentifier()); } fMethodsViewer.saveState(memento); } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento, IType defaultInput) { IType input= defaultInput; String elementId= memento.getString(TAG_INPUT); if (elementId != null) { input= (IType) JavaCore.create(elementId); if (!input.exists()) { input= null; } } setInput(input); Integer viewerIndex= memento.getInteger(TAG_VIEW); if (viewerIndex != null) { setView(viewerIndex.intValue()); } Integer orientation= memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue() == 1); } Integer ratio= memento.getInteger(TAG_RATIO); if (ratio != null) { fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } ScrollBar bar= getCurrentViewer().getTree().getVerticalBar(); if (bar != null) { Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL); if (vScroll != null) { bar.setSelection(vScroll.intValue()); } } String selectionId= memento.getString(TAG_SELECTION); if (selectionId != null) { IJavaElement elem= JavaCore.create(selectionId); if (getCurrentViewer().isElementShown(elem)) { getCurrentViewer().setSelection(new StructuredSelection(elem)); } } fMethodsViewer.restoreState(memento); } /** * Link selection to active editor. */ private void editorActivated(IEditorPart editor) { if (!JavaBasePreferencePage.linkTypeHierarchySelectionToEditor()) { return; } if (fInput == null) { // no type hierarchy shown return; } IJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class); try { TypeHierarchyViewer currentViewer= getCurrentViewer(); if (elem instanceof IClassFile) { IType type= ((IClassFile)elem).getType(); if (currentViewer.isElementShown(type)) { currentViewer.setSelection(new StructuredSelection(type)); } } else if (elem instanceof ICompilationUnit) { IType[] allTypes= ((ICompilationUnit)elem).getAllTypes(); for (int i= 0; i < allTypes.length; i++) { if (currentViewer.isElementShown(allTypes[i])) { currentViewer.setSelection(new StructuredSelection(allTypes[i])); return; } } } } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } } }
    5,048
    Bug 5048 Too many declarations in hierarchy of (jdt)Parser.initialize()
    Build 204 In a self-hosting workspace, open type Parser (from JDT), and select its initialize() method in outliner. Request to search declarations in hierarchy, it incorrectly finds over 100 matches, as if it was not taking into account the accurate location of the Parser.
    resolved fixed
    f57e9cf
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-24T08:40:31Z
    2001-10-17T17:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindDeclarationsAction.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageDeclaration; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; public class FindDeclarationsAction extends ElementSearchAction { public FindDeclarationsAction() { this(SearchMessages.getString("Search.FindDeclarationAction.label"), new Class[] {IField.class, IMethod.class, IType.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class}); //$NON-NLS-1$ setToolTipText(SearchMessages.getString("Search.FindDeclarationAction.tooltip")); //$NON-NLS-1$ } public FindDeclarationsAction(String label, Class[] validTypes) { super(label, validTypes); setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL); } protected JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException { if (element.getElementType() == IJavaElement.TYPE) { IType type= (IType)element; int searchFor= IJavaSearchConstants.TYPE; String pattern= PrettySignature.getUnqualifiedTypeSignature(type); return new JavaSearchOperation(JavaPlugin.getWorkspace(), pattern, searchFor, getLimitTo(), getScope(type), getScopeDescription(type), getCollector()); } else if (element.getElementType() == IJavaElement.METHOD) { IMethod method= (IMethod)element; int searchFor= IJavaSearchConstants.METHOD; if (method.isConstructor()) searchFor= IJavaSearchConstants.CONSTRUCTOR; IType type= method.getDeclaringType(); String pattern= PrettySignature.getUnqualifiedMethodSignature(method); return new JavaSearchOperation(JavaPlugin.getWorkspace(), pattern, searchFor, getLimitTo(), getScope(type), getScopeDescription(type), getCollector()); } else return super.makeOperation(element); } protected int getLimitTo() { return IJavaSearchConstants.DECLARATIONS; } protected boolean shouldUserBePrompted() { return false; } protected String getScopeDescription(IType type) { return super.getScopeDescription(type); } }
    5,048
    Bug 5048 Too many declarations in hierarchy of (jdt)Parser.initialize()
    Build 204 In a self-hosting workspace, open type Parser (from JDT), and select its initialize() method in outliner. Request to search declarations in hierarchy, it incorrectly finds over 100 matches, as if it was not taking into account the accurate location of the Parser.
    resolved fixed
    f57e9cf
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-24T08:40:31Z
    2001-10-17T17:33:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindHierarchyDeclarationsAction.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; public class FindHierarchyDeclarationsAction extends FindDeclarationsAction { public FindHierarchyDeclarationsAction() { super(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.label"), new Class[] {IField.class, IMethod.class, IType.class} ); //$NON-NLS-1$ setToolTipText(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.tooltip")); //$NON-NLS-1$ } protected IJavaSearchScope getScope(IType type) throws JavaModelException { ICompilationUnit cu= type.getCompilationUnit(); if (cu != null && cu.isWorkingCopy()) { type= (IType)cu.getOriginal(type); } return SearchEngine.createHierarchyScope(type); } protected boolean shouldUserBePrompted() { return true; } protected String getScopeDescription(IType type) { return SearchMessages.getFormattedString("HierarchyScope", new String[] {type.getElementName()}); //$NON-NLS-1$ } }
    4,329
    Bug 4329 No results If searched via Package view selection and dialog (1GLDN1X)
    The package view initializes the Search dialog with the fully qualified name. This is not found when searching for declarations. Search via context menu in packages view works. ==> (Java) Search should first try to get the Java element and if that fails, display the the element name and not the fully qualified name. NOTES:
    resolved fixed
    b975be2
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-24T17:13:09Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.search.internal.ui.SearchManager; import org.eclipse.search.ui.ISearchPage; import org.eclipse.search.ui.ISearchPageContainer; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.IWorkingSet; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.RowLayouter; public class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants { public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$ private static List fgPreviousSearchPatterns= new ArrayList(20); private Combo fPattern; private String fInitialPattern; private boolean fFirstTime= true; private ISearchPageContainer fContainer; private Button[] fSearchFor; private String[] fSearchForText= { SearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.field") }; //$NON-NLS-1$ private Button[] fLimitTo; private String[] fLimitToText= { SearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.allOccurrences")}; //$NON-NLS-1$ private IJavaElement fJavaElement; private static class SearchPatternData { int searchFor; int limitTo; String pattern; IJavaElement javaElement; int scope; IWorkingSet workingSet; public SearchPatternData(int s, int l, String p, IJavaElement element) { this(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null); } public SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) { searchFor= s; limitTo= l; pattern= p; javaElement= element; this.scope= scope; this.workingSet= workingSet; } } //---- Action Handling ------------------------------------------------ public boolean performAction() { SearchPatternData data= getPatternData(); IWorkspace workspace= JavaPlugin.getWorkspace(); // Setup search scope IJavaSearchScope scope= null; String scopeDescription= ""; //$NON-NLS-1$ switch (getContainer().getSelectedScope()) { case ISearchPageContainer.WORKSPACE_SCOPE: scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ scope= SearchEngine.createWorkspaceScope(); break; case ISearchPageContainer.SELECTION_SCOPE: scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$ scope= getSelectedResourcesScope(); break; case ISearchPageContainer.WORKING_SET_SCOPE: IWorkingSet workingSet= getContainer().getSelectedWorkingSet(); scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", new String[] {workingSet.getName()}); //$NON-NLS-1$ scope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources()); } JavaSearchResultCollector collector= new JavaSearchResultCollector(); JavaSearchOperation op= null; if (data.javaElement != null && getPattern().equals(fInitialPattern)) op= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector); else { data.javaElement= null; op= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector); } Shell shell= getControl().getShell(); try { getContainer().getRunnableContext().run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$ return false; } catch (InterruptedException ex) { return false; } return true; } private int getLimitTo() { for (int i= 0; i < fLimitTo.length; i++) { if (fLimitTo[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String[] getPreviousSearchPatterns() { // Search results are not persistent int patternCount= fgPreviousSearchPatterns.size(); String [] patterns= new String[patternCount]; for (int i= 0; i < patternCount; i++) patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern; return patterns; } private int getSearchFor() { for (int i= 0; i < fSearchFor.length; i++) { if (fSearchFor[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String getPattern() { return fPattern.getText(); } /** * Return search pattern data and update previous searches. * An existing entry will be updated. */ private SearchPatternData getPatternData() { String pattern= getPattern(); SearchPatternData match= null; int i= 0; int size= fgPreviousSearchPatterns.size(); while (match == null && i < size) { match= (SearchPatternData) fgPreviousSearchPatterns.get(i); i++; if (!pattern.equals(match.pattern)) match= null; }; if (match == null) { match= new SearchPatternData( getSearchFor(), getLimitTo(), getPattern(), fJavaElement, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSet()); fgPreviousSearchPatterns.add(match); } else { match.searchFor= getSearchFor(); match.limitTo= getLimitTo(); match.javaElement= fJavaElement; match.scope= getContainer().getSelectedScope(); match.workingSet= getContainer().getSelectedWorkingSet(); }; return match; } /* * Implements method from IDialogPage */ public void setVisible(boolean visible) { if (visible && fPattern != null) { if (fFirstTime) { fFirstTime= false; // Set item and text here to prevent page from resizing fPattern.setItems(getPreviousSearchPatterns()); initSelections(); } fPattern.setFocus(); getContainer().setPerformActionEnabled(fPattern.getText().length() > 0); } super.setVisible(visible); } public boolean isValid() { return true; } //---- Widget creation ------------------------------------------------ /** * Creates the page's content. */ public void createControl(Composite parent) { GridData gd; Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.makeColumnsEqualWidth= true; layout.horizontalSpacing= 10; result.setLayout(layout); RowLayouter layouter= new RowLayouter(layout.numColumns); gd= new GridData(); gd.horizontalAlignment= gd.FILL; layouter.setDefaultGridData(gd, 0); layouter.setDefaultGridData(gd, 1); layouter.setDefaultSpan(); layouter.perform(createExpression(result)); layouter.perform(createSearchFor(result), createLimitTo(result), -1); SelectionAdapter javaElementInitializer= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { fJavaElement= null; } }; fSearchFor[FIELD].addSelectionListener(javaElementInitializer); fSearchFor[METHOD].addSelectionListener(javaElementInitializer); fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer); fSearchFor[TYPE].addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleSearchForSelected(((Button)e.widget).getSelection()); } }); setControl(result); WorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE }); } private Control createExpression(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.expression.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 1; result.setLayout(layout); // Pattern combo fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER); fPattern.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handlePatternSelected(); } }); fPattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().setPerformActionEnabled(getPattern().length() > 0); } }); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.widthHint= convertWidthInCharsToPixels(30); fPattern.setLayoutData(gd); // Pattern info Label label= new Label(result, SWT.LEFT); label.setText(SearchMessages.getString("SearchPage.expression.pattern")); //$NON-NLS-1$ return result; } private void handlePatternSelected() { if (fPattern.getSelectionIndex() < 0) return; int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex(); SearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index); for (int i= 0; i < fSearchFor.length; i++) fSearchFor[i].setSelection(false); for (int i= 0; i < fLimitTo.length; i++) fLimitTo[i].setSelection(false); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); fLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE)); fLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE)); fLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE)); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); fJavaElement= values.javaElement; if (values.workingSet != null) getContainer().setSelectedWorkingSet(values.workingSet); else getContainer().setSelectedScope(values.scope); } private void handleSearchForSelected(boolean state) { boolean implState= fLimitTo[IMPLEMENTORS].getSelection(); if (!state && implState) { fLimitTo[IMPLEMENTORS].setSelection(false); fLimitTo[REFERENCES].setSelection(true); } fLimitTo[IMPLEMENTORS].setEnabled(state); fJavaElement= null; } private Control createSearchFor(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 3; result.setLayout(layout); fSearchFor= new Button[fSearchForText.length]; for (int i= 0; i < fSearchForText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fSearchForText[i]); fSearchFor[i]= button; } return result; } private Control createLimitTo(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.limitTo.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 2; result.setLayout(layout); fLimitTo= new Button[fLimitToText.length]; for (int i= 0; i < fLimitToText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fLimitToText[i]); fLimitTo[i]= button; } return result; } private void initSelections() { fJavaElement= null; ISelection selection= getSelection(); SearchPatternData values= null; values= tryTypedTextSelection(selection); if (values == null) values= trySelection(selection); if (values == null) values= trySimpleTextSelection(selection); if (values == null) values= getDefaultInitValues(); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); if (values.searchFor != TYPE) fLimitTo[IMPLEMENTORS].setEnabled(false); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); } private SearchPatternData tryTypedTextSelection(ISelection selection) { if (selection instanceof ITextSelection) { IEditorPart e= getEditorPart(); if (e != null) { ITextSelection ts= (ITextSelection)selection; ICodeAssist assist= getCodeAssist(e); if (assist != null) { IJavaElement[] elements= null; try { elements= assist.codeSelect(ts.getOffset(), ts.getLength()); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ } if (elements != null && elements.length > 0) { if (elements.length == 1) fJavaElement= elements[0]; else fJavaElement= chooseFromList(elements); if (fJavaElement != null) return determineInitValuesFrom(fJavaElement); } } } } return null; } private ICodeAssist getCodeAssist(IEditorPart editorPart) { IEditorInput input= editorPart.getEditorInput(); if (input instanceof ClassFileEditorInput) return ((ClassFileEditorInput)input).getClassFile(); IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); return manager.getWorkingCopy(input); } private SearchPatternData trySelection(ISelection selection) { SearchPatternData result= null; if (selection == null) return result; Object o= null; if (selection instanceof IStructuredSelection) o= ((IStructuredSelection)selection).getFirstElement(); if (o instanceof IJavaElement) { fJavaElement= (IJavaElement)o; result= determineInitValuesFrom(fJavaElement); } else if (o instanceof ISearchResultViewEntry) { fJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker()); result= determineInitValuesFrom(fJavaElement); } else if (o instanceof IAdaptable) { IWorkbenchAdapter element= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class); if (element != null) result= new SearchPatternData(TYPE, REFERENCES, element.getLabel(o), null); } return result; } private IJavaElement getJavaElement(IMarker marker) { try { return JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)); } catch (CoreException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ return null; } } private SearchPatternData determineInitValuesFrom(IJavaElement element) { if (element == null) return null; int searchFor= UNKNOWN; int limitTo= UNKNOWN; String pattern= null; switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_DECLARATION: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.IMPORT_DECLARATION: pattern= element.getElementName(); IImportDeclaration declaration= (IImportDeclaration)element; if (declaration.isOnDemand()) { searchFor= PACKAGE; int index= pattern.lastIndexOf('.'); pattern= pattern.substring(0, index); } else { searchFor= TYPE; } limitTo= DECLARATIONS; break; case IJavaElement.TYPE: searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)element); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(".")); //$NON-NLS-1$ IType mainType= cu.getType(mainTypeName); mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType); try { mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName); if (mainType == null) { // fetch type which is declared first in the file IType[] types= cu.getTypes(); if (types.length > 0) mainType= types[0]; else break; } } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)mainType); break; case IJavaElement.CLASS_FILE: IClassFile cf= (IClassFile)element; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } if (mainType == null) break; searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName(mainType); break; case IJavaElement.FIELD: searchFor= FIELD; limitTo= REFERENCES; IType type= ((IField)element).getDeclaringType(); StringBuffer buffer= new StringBuffer(); buffer.append(JavaModelUtil.getFullyQualifiedName(type)); buffer.append('.'); buffer.append(element.getElementName()); pattern= buffer.toString(); break; case IJavaElement.METHOD: searchFor= METHOD; try { IMethod method= (IMethod)element; if (method.isConstructor()) searchFor= CONSTRUCTOR; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } limitTo= REFERENCES; pattern= PrettySignature.getMethodSignature((IMethod)element); break; } if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null) return new SearchPatternData(searchFor, limitTo, pattern, element); return null; } private SearchPatternData trySimpleTextSelection(ISelection selection) { SearchPatternData result= null; if (selection instanceof ITextSelection) { BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText())); String text; try { text= reader.readLine(); if (text == null) text= ""; //$NON-NLS-1$ } catch (IOException ex) { text= ""; //$NON-NLS-1$ } result= new SearchPatternData(TYPE, REFERENCES, text, null); } return result; } private SearchPatternData getDefaultInitValues() { return new SearchPatternData(TYPE, REFERENCES, "", null); //$NON-NLS-1$ } private IJavaElement chooseFromList(IJavaElement[] openChoices) { ILabelProvider labelProvider= new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle(SearchMessages.getString("SearchElementSelectionDialog.title")); //$NON-NLS-1$ dialog.setMessage(SearchMessages.getString("SearchElementSelectionDialog.message")); //$NON-NLS-1$ dialog.setElements(openChoices); if (dialog.open() == dialog.OK) return (IJavaElement)dialog.getFirstResult(); return null; } /* * Implements method from ISearchPage */ public void setContainer(ISearchPageContainer container) { fContainer= container; } /** * Returns the search page's container. */ private ISearchPageContainer getContainer() { return fContainer; } /** * Returns the current active selection. */ private ISelection getSelection() { return fContainer.getSelection(); } /** * Returns the current active editor part. */ private IEditorPart getEditorPart() { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) return page.getActiveEditor(); } return null; } private IJavaSearchScope getSelectedResourcesScope() { ArrayList resources= new ArrayList(10); if (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) { Iterator iter= ((IStructuredSelection)getSelection()).iterator(); while (iter.hasNext()) { Object selection= iter.next(); if (selection instanceof IResource) resources.add(selection); else if (selection instanceof IAdaptable) { IResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class); if (resource != null) resources.add(resource); } } } return SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()])); } }
    4,329
    Bug 4329 No results If searched via Package view selection and dialog (1GLDN1X)
    The package view initializes the Search dialog with the fully qualified name. This is not found when searching for declarations. Search via context menu in packages view works. ==> (Java) Search should first try to get the Java element and if that fails, display the the element name and not the fully qualified name. NOTES:
    resolved fixed
    b975be2
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-24T17:13:09Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultCollector.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.IInputSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.search.ui.IContextMenuContributor; import org.eclipse.search.ui.ISearchResultView; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.SearchUI; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.search.IJavaSearchResultCollector; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.GroupContext; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.util.SelectionUtil; public class JavaSearchResultCollector implements IJavaSearchResultCollector { private static final String MATCH= SearchMessages.getString("SearchResultCollector.match"); //$NON-NLS-1$ private static final String MATCHES= SearchMessages.getString("SearchResultCollector.matches"); //$NON-NLS-1$ private static final String DONE= SearchMessages.getString("SearchResultCollector.done"); //$NON-NLS-1$ private static final String SEARCHING= SearchMessages.getString("SearchResultCollector.searching"); //$NON-NLS-1$ private static final Integer POTENTIAL_MATCH_VALUE= new Integer(POTENTIAL_MATCH); private IProgressMonitor fMonitor; private IContextMenuContributor fContextMenu; private ISearchResultView fView; private JavaSearchOperation fOperation; private int fMatchCount= 0; private Integer[] fMessageFormatArgs= new Integer[1]; private class ContextMenuContributor implements IContextMenuContributor { public void fill(IMenuManager menu, IInputSelectionProvider inputProvider) { JavaPlugin.createStandardGroups(menu); new JavaSearchGroup().fill(menu, new GroupContext(inputProvider)); OpenTypeHierarchyUtil.addToMenu(getWorbenchWindow(), menu, convertSelection(inputProvider.getSelection())); } private Object convertSelection(ISelection selection) { Object element= SelectionUtil.getSingleElement(selection); if (!(element instanceof ISearchResultViewEntry)) return null; IMarker marker= ((ISearchResultViewEntry)element).getSelectedMarker(); try { return JavaCore.create((String) ((IMarker) marker).getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)); } catch (CoreException ex) { ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-1$ return null; } } } public JavaSearchResultCollector() { fContextMenu= new ContextMenuContributor(); } /** * @see IJavaSearchResultCollector#aboutToStart(). */ public void aboutToStart() { fView= SearchUI.getSearchResultView(); fMatchCount= 0; if (fView != null) { fView.searchStarted( JavaSearchPage.EXTENSION_POINT_ID, fOperation.getDescription(), fOperation.getImageDescriptor(), fContextMenu, JavaSearchResultLabelProvider.INSTANCE, new GotoMarkerAction(), new GroupByKeyComputer(), fOperation); } if (!getProgressMonitor().isCanceled()) getProgressMonitor().subTask(SEARCHING); } /** * @see IJavaSearchResultCollector#accept */ public void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException { IMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER); HashMap attributes; if (accuracy == POTENTIAL_MATCH) { attributes= new HashMap(6); attributes.put(IJavaSearchUIConstants.ATT_ACCURACY, POTENTIAL_MATCH_VALUE); } else attributes= new HashMap(5); JavaCore.addJavaElementMarkerAttributes(attributes, enclosingElement); attributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, enclosingElement.getHandleIdentifier()); attributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0))); attributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0))); if (enclosingElement instanceof IMember && ((IMember)enclosingElement).isBinary()) attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR); else attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CU_EDITOR); marker.setAttributes(attributes); fView.addMatch(enclosingElement.getElementName(), enclosingElement, resource, marker); fMatchCount++; if (!getProgressMonitor().isCanceled()) getProgressMonitor().subTask(getFormattedMatchesString(fMatchCount)); } /** * @see IJavaSearchResultCollector#done(). */ public void done() { if (!getProgressMonitor().isCanceled()) { String matchesString= getFormattedMatchesString(fMatchCount); getProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString})); } if (fView != null) fView.searchFinished(); // Cut no longer unused references because the collector might be re-used fView= null; fMonitor= null; } /** * @see IJavaSearchResultCollector#getProgressMonitor(). */ public IProgressMonitor getProgressMonitor() { return fMonitor; }; void setProgressMonitor(IProgressMonitor pm) { fMonitor= pm; } void setOperation(JavaSearchOperation operation) { fOperation= operation; } private String getFormattedMatchesString(int count) { if (fMatchCount == 1) return MATCH; fMessageFormatArgs[0]= new Integer(count); return MessageFormat.format(MATCHES, fMessageFormatArgs); } private IWorkbenchWindow getWorbenchWindow() { IWorkbenchWindow wbWindow= null; if (fView != null && fView.getSite() != null) wbWindow= fView.getSite().getWorkbenchWindow(); if (wbWindow == null) wbWindow= JavaPlugin.getActiveWorkbenchWindow(); return wbWindow; } }
    5,232
    Bug 5232 Java Search page not initialized correctly from Navigator
    1. Open the Navigator 2. Select a .java file (that's on the classpath) 3. Open the Search dialog (Ctrl+H) 4. Press Search ==> Nothing found. It should give the same result(s) as if the .java file would be selected in the Packages view.
    resolved fixed
    431fffb
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-25T10:25:34Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.search.internal.ui.SearchManager; import org.eclipse.search.ui.ISearchPage; import org.eclipse.search.ui.ISearchPageContainer; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.IWorkingSet; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.RowLayouter; public class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants { public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$ private static List fgPreviousSearchPatterns= new ArrayList(20); private Combo fPattern; private String fInitialPattern; private boolean fFirstTime= true; private ISearchPageContainer fContainer; private Button[] fSearchFor; private String[] fSearchForText= { SearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.field") }; //$NON-NLS-1$ private Button[] fLimitTo; private String[] fLimitToText= { SearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.allOccurrences")}; //$NON-NLS-1$ private IJavaElement fJavaElement; private static class SearchPatternData { int searchFor; int limitTo; String pattern; IJavaElement javaElement; int scope; IWorkingSet workingSet; public SearchPatternData(int s, int l, String p, IJavaElement element) { this(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null); } public SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) { searchFor= s; limitTo= l; pattern= p; javaElement= element; this.scope= scope; this.workingSet= workingSet; } } //---- Action Handling ------------------------------------------------ public boolean performAction() { SearchPatternData data= getPatternData(); IWorkspace workspace= JavaPlugin.getWorkspace(); // Setup search scope IJavaSearchScope scope= null; String scopeDescription= ""; //$NON-NLS-1$ switch (getContainer().getSelectedScope()) { case ISearchPageContainer.WORKSPACE_SCOPE: scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ scope= SearchEngine.createWorkspaceScope(); break; case ISearchPageContainer.SELECTION_SCOPE: scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$ scope= getSelectedResourcesScope(); break; case ISearchPageContainer.WORKING_SET_SCOPE: IWorkingSet workingSet= getContainer().getSelectedWorkingSet(); scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", new String[] {workingSet.getName()}); //$NON-NLS-1$ scope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources()); } JavaSearchResultCollector collector= new JavaSearchResultCollector(); JavaSearchOperation op= null; if (data.javaElement != null && getPattern().equals(fInitialPattern)) op= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector); else { data.javaElement= null; op= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector); } Shell shell= getControl().getShell(); try { getContainer().getRunnableContext().run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$ return false; } catch (InterruptedException ex) { return false; } return true; } private int getLimitTo() { for (int i= 0; i < fLimitTo.length; i++) { if (fLimitTo[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String[] getPreviousSearchPatterns() { // Search results are not persistent int patternCount= fgPreviousSearchPatterns.size(); String [] patterns= new String[patternCount]; for (int i= 0; i < patternCount; i++) patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern; return patterns; } private int getSearchFor() { for (int i= 0; i < fSearchFor.length; i++) { if (fSearchFor[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String getPattern() { return fPattern.getText(); } /** * Return search pattern data and update previous searches. * An existing entry will be updated. */ private SearchPatternData getPatternData() { String pattern= getPattern(); SearchPatternData match= null; int i= 0; int size= fgPreviousSearchPatterns.size(); while (match == null && i < size) { match= (SearchPatternData) fgPreviousSearchPatterns.get(i); i++; if (!pattern.equals(match.pattern)) match= null; }; if (match == null) { match= new SearchPatternData( getSearchFor(), getLimitTo(), getPattern(), fJavaElement, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSet()); fgPreviousSearchPatterns.add(match); } else { match.searchFor= getSearchFor(); match.limitTo= getLimitTo(); match.javaElement= fJavaElement; match.scope= getContainer().getSelectedScope(); match.workingSet= getContainer().getSelectedWorkingSet(); }; return match; } /* * Implements method from IDialogPage */ public void setVisible(boolean visible) { if (visible && fPattern != null) { if (fFirstTime) { fFirstTime= false; // Set item and text here to prevent page from resizing fPattern.setItems(getPreviousSearchPatterns()); initSelections(); } fPattern.setFocus(); getContainer().setPerformActionEnabled(fPattern.getText().length() > 0); } super.setVisible(visible); } public boolean isValid() { return true; } //---- Widget creation ------------------------------------------------ /** * Creates the page's content. */ public void createControl(Composite parent) { GridData gd; Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.makeColumnsEqualWidth= true; layout.horizontalSpacing= 10; result.setLayout(layout); RowLayouter layouter= new RowLayouter(layout.numColumns); gd= new GridData(); gd.horizontalAlignment= gd.FILL; layouter.setDefaultGridData(gd, 0); layouter.setDefaultGridData(gd, 1); layouter.setDefaultSpan(); layouter.perform(createExpression(result)); layouter.perform(createSearchFor(result), createLimitTo(result), -1); SelectionAdapter javaElementInitializer= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { fJavaElement= null; } }; fSearchFor[FIELD].addSelectionListener(javaElementInitializer); fSearchFor[METHOD].addSelectionListener(javaElementInitializer); fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer); fSearchFor[TYPE].addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleSearchForSelected(((Button)e.widget).getSelection()); } }); setControl(result); WorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE }); } private Control createExpression(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.expression.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 1; result.setLayout(layout); // Pattern combo fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER); fPattern.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handlePatternSelected(); } }); fPattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().setPerformActionEnabled(getPattern().length() > 0); } }); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.widthHint= convertWidthInCharsToPixels(30); fPattern.setLayoutData(gd); // Pattern info Label label= new Label(result, SWT.LEFT); label.setText(SearchMessages.getString("SearchPage.expression.pattern")); //$NON-NLS-1$ return result; } private void handlePatternSelected() { if (fPattern.getSelectionIndex() < 0) return; int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex(); SearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index); for (int i= 0; i < fSearchFor.length; i++) fSearchFor[i].setSelection(false); for (int i= 0; i < fLimitTo.length; i++) fLimitTo[i].setSelection(false); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); fLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE)); fLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE)); fLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE)); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); fJavaElement= values.javaElement; if (values.workingSet != null) getContainer().setSelectedWorkingSet(values.workingSet); else getContainer().setSelectedScope(values.scope); } private void handleSearchForSelected(boolean state) { boolean implState= fLimitTo[IMPLEMENTORS].getSelection(); if (!state && implState) { fLimitTo[IMPLEMENTORS].setSelection(false); fLimitTo[REFERENCES].setSelection(true); } fLimitTo[IMPLEMENTORS].setEnabled(state); fJavaElement= null; } private Control createSearchFor(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 3; result.setLayout(layout); fSearchFor= new Button[fSearchForText.length]; for (int i= 0; i < fSearchForText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fSearchForText[i]); fSearchFor[i]= button; } return result; } private Control createLimitTo(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.limitTo.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 2; result.setLayout(layout); fLimitTo= new Button[fLimitToText.length]; for (int i= 0; i < fLimitToText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fLimitToText[i]); fLimitTo[i]= button; } return result; } private void initSelections() { fJavaElement= null; ISelection selection= getSelection(); SearchPatternData values= null; values= tryTypedTextSelection(selection); if (values == null) values= trySelection(selection); if (values == null) values= trySimpleTextSelection(selection); if (values == null) values= getDefaultInitValues(); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); if (values.searchFor != TYPE) fLimitTo[IMPLEMENTORS].setEnabled(false); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); fJavaElement= values.javaElement; } private SearchPatternData tryTypedTextSelection(ISelection selection) { if (selection instanceof ITextSelection) { IEditorPart e= getEditorPart(); if (e != null) { ITextSelection ts= (ITextSelection)selection; ICodeAssist assist= getCodeAssist(e); if (assist != null) { IJavaElement[] elements= null; try { elements= assist.codeSelect(ts.getOffset(), ts.getLength()); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ } if (elements != null && elements.length > 0) { if (elements.length == 1) fJavaElement= elements[0]; else fJavaElement= chooseFromList(elements); if (fJavaElement != null) return determineInitValuesFrom(fJavaElement); } } } } return null; } private ICodeAssist getCodeAssist(IEditorPart editorPart) { IEditorInput input= editorPart.getEditorInput(); if (input instanceof ClassFileEditorInput) return ((ClassFileEditorInput)input).getClassFile(); IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); return manager.getWorkingCopy(input); } private SearchPatternData trySelection(ISelection selection) { SearchPatternData result= null; if (selection == null) return result; Object o= null; if (selection instanceof IStructuredSelection) o= ((IStructuredSelection)selection).getFirstElement(); if (o instanceof IJavaElement) { fJavaElement= (IJavaElement)o; result= determineInitValuesFrom(fJavaElement); } else if (o instanceof ISearchResultViewEntry) { fJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker()); result= determineInitValuesFrom(fJavaElement); } else if (o instanceof IAdaptable) { IWorkbenchAdapter element= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class); if (element != null) result= new SearchPatternData(TYPE, REFERENCES, element.getLabel(o), null); } return result; } private IJavaElement getJavaElement(IMarker marker) { try { return JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)); } catch (CoreException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ return null; } } private SearchPatternData determineInitValuesFrom(IJavaElement element) { if (element == null) return null; int searchFor= UNKNOWN; int limitTo= UNKNOWN; String pattern= null; switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_DECLARATION: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.IMPORT_DECLARATION: pattern= element.getElementName(); IImportDeclaration declaration= (IImportDeclaration)element; if (declaration.isOnDemand()) { searchFor= PACKAGE; int index= pattern.lastIndexOf('.'); pattern= pattern.substring(0, index); } else { searchFor= TYPE; } limitTo= DECLARATIONS; break; case IJavaElement.TYPE: searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)element); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(".")); //$NON-NLS-1$ IType mainType= cu.getType(mainTypeName); mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType); try { mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName); if (mainType == null) { // fetch type which is declared first in the file IType[] types= cu.getTypes(); if (types.length > 0) mainType= types[0]; else break; } } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } searchFor= TYPE; element= mainType; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)mainType); break; case IJavaElement.CLASS_FILE: IClassFile cf= (IClassFile)element; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } if (mainType == null) break; element= mainType; searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName(mainType); break; case IJavaElement.FIELD: searchFor= FIELD; limitTo= REFERENCES; IType type= ((IField)element).getDeclaringType(); StringBuffer buffer= new StringBuffer(); buffer.append(JavaModelUtil.getFullyQualifiedName(type)); buffer.append('.'); buffer.append(element.getElementName()); pattern= buffer.toString(); break; case IJavaElement.METHOD: searchFor= METHOD; try { IMethod method= (IMethod)element; if (method.isConstructor()) searchFor= CONSTRUCTOR; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } limitTo= REFERENCES; pattern= PrettySignature.getMethodSignature((IMethod)element); break; } if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null) return new SearchPatternData(searchFor, limitTo, pattern, element); return null; } private SearchPatternData trySimpleTextSelection(ISelection selection) { SearchPatternData result= null; if (selection instanceof ITextSelection) { BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText())); String text; try { text= reader.readLine(); if (text == null) text= ""; //$NON-NLS-1$ } catch (IOException ex) { text= ""; //$NON-NLS-1$ } result= new SearchPatternData(TYPE, REFERENCES, text, null); } return result; } private SearchPatternData getDefaultInitValues() { return new SearchPatternData(TYPE, REFERENCES, "", null); //$NON-NLS-1$ } private IJavaElement chooseFromList(IJavaElement[] openChoices) { ILabelProvider labelProvider= new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle(SearchMessages.getString("SearchElementSelectionDialog.title")); //$NON-NLS-1$ dialog.setMessage(SearchMessages.getString("SearchElementSelectionDialog.message")); //$NON-NLS-1$ dialog.setElements(openChoices); if (dialog.open() == dialog.OK) return (IJavaElement)dialog.getFirstResult(); return null; } /* * Implements method from ISearchPage */ public void setContainer(ISearchPageContainer container) { fContainer= container; } /** * Returns the search page's container. */ private ISearchPageContainer getContainer() { return fContainer; } /** * Returns the current active selection. */ private ISelection getSelection() { return fContainer.getSelection(); } /** * Returns the current active editor part. */ private IEditorPart getEditorPart() { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) return page.getActiveEditor(); } return null; } private IJavaSearchScope getSelectedResourcesScope() { ArrayList resources= new ArrayList(10); if (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) { Iterator iter= ((IStructuredSelection)getSelection()).iterator(); while (iter.hasNext()) { Object selection= iter.next(); if (selection instanceof IResource) resources.add(selection); else if (selection instanceof IAdaptable) { IResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class); if (resource != null) resources.add(resource); } } } return SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()])); } }
    5,128
    Bug 5128 JavaUI.revealInEditor doesn't handle ICompilationUnits properly
    When calling JavaUI.revealInEditor with an ICompilationUnit, then the package declaration is revealed. This isn't useful, passing an ICompilationUnit should be treated as a no-op. Otherwise clients need to guard against revealing the package declaration in their code (see OpenResourceAction as an example)
    resolved fixed
    5d2cbe7
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-25T15:07:33Z
    2001-10-20T15:00:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
    package org.eclipse.jdt.internal.ui.javaeditor; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.Iterator; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.ui.IEditorActionBarContributor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPartService; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.debug.ui.display.InspectAction; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.AddMethodEntryBreakpointAction; import org.eclipse.jdt.internal.ui.actions.AddWatchpointAction; import org.eclipse.jdt.internal.ui.actions.OpenImportDeclarationAction; import org.eclipse.jdt.internal.ui.actions.ShowInPackageViewAction; import org.eclipse.jdt.internal.ui.search.JavaSearchGroup; /** * Java specific text editor. */ public abstract class JavaEditor extends AbstractTextEditor implements ISelectionChangedListener { /** The outline page */ protected JavaOutlinePage fOutlinePage; /** Outliner context menu Id */ protected String fOutlinerContextMenuId; /** * Returns the smallest ISourceReference also implementing IJavaElement * containing the given position. */ abstract protected ISourceReference getJavaSourceReferenceAt(int position); /** * Sets the input of the editor's outline page. */ abstract protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input); /** * Default constructor. */ public JavaEditor() { super(); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); setSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools, this)); setRangeIndicator(new DefaultRangeIndicator()); setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); } /** * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int) * * This is the code that can be found in 1.0 fixing the bidi rendering of Java code. * Looking for something less vulernable in this stream. * protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ISourceViewer viewer= super.createSourceViewer(parent, ruler, styles); StyledText text= viewer.getTextWidget(); text.setBidiColoring(true); return viewer; } */ /** * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent) */ protected boolean affectsTextPresentation(PropertyChangeEvent event) { JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); return textTools.affectsBehavior(event); } /** * Sets the outliner's context menu ID. */ protected void setOutlinerContextMenuId(String menuId) { fOutlinerContextMenuId= menuId; } /** * @see AbstractTextEditor#editorContextMenuAboutToShow */ public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE); addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE); addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW); MenuManager search= new JavaSearchGroup().getMenuManagerForGroup(isTextSelectionEmpty()); menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, search); addAction(menu, ITextEditorActionConstants.GROUP_FIND, "ShowJavaDoc"); addAction(menu, "Inspect"); //$NON-NLS-1$ addAction(menu, "Display"); //$NON-NLS-1$ addAction(menu, "RunToLine"); //$NON-NLS-1$ } /** * Creates the outline page used with this editor. */ protected JavaOutlinePage createOutlinePage() { JavaOutlinePage page= new JavaOutlinePage(fOutlinerContextMenuId, this); page.addSelectionChangedListener(this); setOutlinePageInput(page, getEditorInput()); // page.setAction("ShowTypeHierarchy", new ShowTypeHierarchyAction(page)); //$NON-NLS-1$ page.setAction("OpenImportDeclaration", new OpenImportDeclarationAction(page)); //$NON-NLS-1$ page.setAction("ShowInPackageView", new ShowInPackageViewAction(getSite(), page)); //$NON-NLS-1$ page.setAction("AddMethodEntryBreakpoint", new AddMethodEntryBreakpointAction(page)); //$NON-NLS-1$ page.setAction("AddWatchpoint", new AddWatchpointAction(page)); // $NON-NLS-1$ return page; } /** * Informs the editor that its outliner has been closed. */ public void outlinePageClosed() { if (fOutlinePage != null) { fOutlinePage.removeSelectionChangedListener(this); fOutlinePage= null; resetHighlightRange(); } } /* * Get the dektop's StatusLineManager */ protected IStatusLineManager getStatusLineManager() { IEditorActionBarContributor contributor= getEditorSite().getActionBarContributor(); if (contributor instanceof EditorActionBarContributor) { return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager(); } return null; } /** * @see AbstractTextEditor#getAdapter(Class) */ public Object getAdapter(Class required) { if (IContentOutlinePage.class.equals(required)) { if (fOutlinePage == null) fOutlinePage= createOutlinePage(); return fOutlinePage; } return super.getAdapter(required); } protected void setSelection(ISourceReference reference, boolean moveCursor) { if (reference != null) { try { ISourceRange range= reference.getSourceRange(); int offset= range.getOffset(); int length= range.getLength(); setHighlightRange(offset, length, moveCursor); if (moveCursor && (reference instanceof IMember)) { range= ((IMember) reference).getNameRange(); offset= range.getOffset(); length= range.getLength(); if (range != null && offset > -1 && length > 0) { if (getSourceViewer() != null) { getSourceViewer().revealRange(offset, length); getSourceViewer().setSelectedRange(offset, length); } } } return; } catch (JavaModelException x) { } catch (IllegalArgumentException x) { } } if (moveCursor) resetHighlightRange(); } public void setSelection(ISourceReference reference) { if (reference == null) return; try { ISourceRange range= reference.getSourceRange(); if (range == null) { return; } // find this source reference in this editor's working copy reference= getJavaSourceReferenceAt(range.getOffset()); } catch (JavaModelException x) { // be tolerant, just go with what is there } if (reference == null) return; // set hightlight range setSelection(reference, true); // set outliner selection if (fOutlinePage != null) { fOutlinePage.removeSelectionChangedListener(this); fOutlinePage.select(reference); fOutlinePage.addSelectionChangedListener(this); } } public void selectionChanged(SelectionChangedEvent event) { ISourceReference reference= null; ISelection selection= event.getSelection(); Iterator iter= ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { Object o= iter.next(); if (o instanceof ISourceReference) { reference= (ISourceReference) o; break; } } if (!isActivePart() && JavaPlugin.getActivePage() != null) JavaPlugin.getActivePage().bringToTop(this); setSelection(reference, !isActivePart()); } /** * @see AbstractTextEditor#adjustHighlightRange(int, int) */ protected void adjustHighlightRange(int offset, int length) { try { ISourceReference reference= getJavaSourceReferenceAt(offset); while (reference != null) { ISourceRange range= reference.getSourceRange(); if (offset < range.getOffset() + range.getLength() && range.getOffset() < offset + length) { setHighlightRange(range.getOffset(), range.getLength(), true); if (fOutlinePage != null) { fOutlinePage.removeSelectionChangedListener(this); fOutlinePage.select(reference); fOutlinePage.addSelectionChangedListener(this); } return; } IJavaElement parent= ((IJavaElement) reference).getParent(); if (parent instanceof ISourceReference) reference= (ISourceReference) parent; else reference= null; } } catch (JavaModelException x) { } resetHighlightRange(); } protected boolean isActivePart() { IWorkbenchWindow window= getSite().getWorkbenchWindow(); IPartService service= window.getPartService(); return (this == service.getActivePart()); } /** * @see AbstractTextEditor#doSetInput */ protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); setOutlinePageInput(fOutlinePage, input); } protected void createActions() { super.createActions(); setAction("ShowJavaDoc", new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION)); setAction("Display", new EditorDisplayAction(this, true)); //$NON-NLS-1$ setAction("RunToLine", new RunToLineAction(this)); //$NON-NLS-1$ setAction("Inspect", new InspectAction(this, true)); //$NON-NLS-1$ } private boolean isTextSelectionEmpty() { ISelection selection= getSelectionProvider().getSelection(); if (!(selection instanceof ITextSelection)) return true; return ((ITextSelection)selection).getLength() == 0; } public void updatedTitleImage(Image image) { setTitleImage(image); } }
    5,233
    Bug 5233 Internal Error during code assist
    Start code assist after item.set (assuming SWT & CTabItem are imported): final CTabItem item= new CTabItem(folder, SWT.NONE); item.set ==> a lot of internal error dialogs are opened. The log is not helpful due to bug in SWT: Log: Thu Oct 25 11:56:08 GMT+02:00 2001 4 org.eclipse.core.runtime 0 Failed to execute runnable (String index out of range: 1) org.eclipse.swt.SWTException: Failed to execute runnable (String index out of range: 1) at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:318) at org.eclipse.ui.internal.Workbench.handleExceptionInEventLoop(Workbench.java:362) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:82 0) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
    resolved fixed
    b0f6f4a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-25T15:08:11Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/HTMLTextPresenter.java
    package org.eclipse.jdt.internal.ui.text; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.Iterator; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Display; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextPresentation; import org.eclipse.jdt.internal.core.util.CharArrayBuffer; import org.eclipse.jdt.internal.ui.JavaPlugin; public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter { private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); private int fCounter; private boolean fEnforceUpperLineLimit; public HTMLTextPresenter(boolean enforceUpperLineLimit) { super(); fEnforceUpperLineLimit= enforceUpperLineLimit; } public HTMLTextPresenter() { this(true); } protected Reader createReader(String hoverInfo, TextPresentation presentation) { return new HTML2TextReader(new StringReader(hoverInfo), presentation); } protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) { int yoursStart= offset; int yoursEnd= offset + insertLength -1; yoursEnd= Math.max(yoursStart, yoursEnd); Iterator e= presentation.getAllStyleRangeIterator(); while (e.hasNext()) { StyleRange range= (StyleRange) e.next(); int myStart= range.start; int myEnd= range.start + range.length -1; myEnd= Math.max(myStart, myEnd); if (myEnd < yoursStart) continue; if (myStart < yoursStart) range.length += insertLength; else range.start += insertLength; } } private void append(StringBuffer buffer, String string, TextPresentation presentation) { int length= string.length(); buffer.append(string); if (presentation != null) adaptTextPresentation(presentation, fCounter, length); fCounter += length; } private String getIndent(String line) { int i= 0; while (Character.isWhitespace(line.charAt(i))) ++ i; return (line.substring(0, i) + " "); } /* * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int) */ public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) { if (hoverInfo == null) return null; GC gc= new GC(display); try { StringBuffer buffer= new StringBuffer(); int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight()); fCounter= 0; LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth); boolean lastLineFormatted= false; String lastLineIndent= null; String line=reader.readLine(); boolean lineFormatted= reader.isFormattedLine(); while (line != null) { if (fEnforceUpperLineLimit && maxNumberOfLines <= 0) break; if (buffer.length() > 0) { if (!lastLineFormatted) append(buffer, LINE_DELIM, null); else { append(buffer, LINE_DELIM, presentation); if (lastLineIndent != null) append(buffer, lastLineIndent, presentation); } } append(buffer, line, null); lastLineFormatted= lineFormatted; if (!lineFormatted) lastLineIndent= null; else if (lastLineIndent == null) lastLineIndent= getIndent(line); line= reader.readLine(); lineFormatted= reader.isFormattedLine(); maxNumberOfLines--; } if (line != null) { append(buffer, LINE_DELIM, lineFormatted ? presentation : null); append(buffer, "...", presentation); } return trim(buffer, presentation); } catch (IOException e) { JavaPlugin.log(e); return null; } finally { gc.dispose(); } } private String trim(StringBuffer buffer, TextPresentation presentation) { int length= buffer.length(); int end= length -1; while (end >= 0 && Character.isWhitespace(buffer.charAt(end))) -- end; if (end == -1) return ""; if (end < length -1) buffer.delete(end + 1, length); else end= length; int start= 0; while (start < end && Character.isWhitespace(buffer.charAt(start))) ++ start; buffer.delete(0, start); presentation.setResultWindow(new Region(start, buffer.length())); return buffer.toString(); } }
    5,161
    Bug 5161 More info in Console open on type dialog
    When open on type gets multiple hits in the same package you cannot determine which file you are opening. For example, if I have one version of a class in source, and one in a jar, then I have no idea which one I'm opening.
    verified fixed
    7d5a2b1
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-25T18:19:19Z
    2001-10-22T22:33:20Z
    org.eclipse.jdt.ui/ui
    5,161
    Bug 5161 More info in Console open on type dialog
    When open on type gets multiple hits in the same package you cannot determine which file you are opening. For example, if I have one version of a class in source, and one in a jar, then I have no idea which one I'm opening.
    verified fixed
    7d5a2b1
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-25T18:19:19Z
    2001-10-22T22:33:20Z
    debug/org/eclipse/jdt/internal/debug/ui/OpenOnConsoleTypeAction.java
    5,231
    Bug 5231 Add search for field read and write references
    The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field.
    resolved fixed
    5c5661b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T13:56:25Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchGroup.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup; import org.eclipse.jdt.internal.ui.actions.GroupContext; import org.eclipse.jdt.ui.IContextMenuConstants; /** * Contribute Java search specific menu elements. */ public class JavaSearchGroup extends ContextMenuGroup { private ElementSearchAction[] fActions; public static final String GROUP_NAME= IContextMenuConstants.GROUP_SEARCH; public JavaSearchGroup() { fActions= new ElementSearchAction[] { new FindReferencesAction(), new FindDeclarationsAction(), new FindHierarchyReferencesAction(), new FindHierarchyDeclarationsAction(), new FindImplementorsAction() }; } public void fill(IMenuManager manager, GroupContext context) { MenuManager javaSearchMM= new MenuManager(SearchMessages.getString(GROUP_NAME), GROUP_NAME); //$NON-NLS-1$ for (int i= 0; i < fActions.length; i++) { ElementSearchAction action= fActions[i]; if (action.canOperateOn(context.getSelection())) javaSearchMM.add(action); } if (!javaSearchMM.isEmpty()) manager.appendToGroup(GROUP_NAME, javaSearchMM); } public String getGroupName() { return GROUP_NAME; } public MenuManager getMenuManagerForGroup(boolean isTextSelectionEmpty) { MenuManager javaSearchMM= new MenuManager(SearchMessages.getString(GROUP_NAME), GROUP_NAME); //$NON-NLS-1$ if (!isTextSelectionEmpty) { javaSearchMM.add(new GroupMarker(GROUP_NAME)); for (int i= 0; i < fActions.length; i++) javaSearchMM.appendToGroup(GROUP_NAME, fActions[i]); } return javaSearchMM; } }
    5,231
    Bug 5231 Add search for field read and write references
    The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field.
    resolved fixed
    5c5661b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T13:56:25Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchOperation.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.internal.ui.JavaPluginImages; public class JavaSearchOperation extends WorkspaceModifyOperation { private IWorkspace fWorkspace; private IJavaElement fElementPattern; private int fLimitTo; private String fStringPattern; private int fSearchFor; private IJavaSearchScope fScope; private String fScopeDescription; private JavaSearchResultCollector fCollector; protected JavaSearchOperation( IWorkspace workspace, int limitTo, IJavaSearchScope scope, String scopeDescription, JavaSearchResultCollector collector) { fWorkspace= workspace; fLimitTo= limitTo; fScope= scope; fScopeDescription= scopeDescription; fCollector= collector; fCollector.setOperation(this); } public JavaSearchOperation( IWorkspace workspace, IJavaElement pattern, int limitTo, IJavaSearchScope scope, String scopeDescription, JavaSearchResultCollector collector) { this(workspace, limitTo, scope, scopeDescription, collector); fElementPattern= pattern; } public JavaSearchOperation( IWorkspace workspace, String pattern, int searchFor, int limitTo, IJavaSearchScope scope, String scopeDescription, JavaSearchResultCollector collector) { this(workspace, limitTo, scope, scopeDescription, collector); fStringPattern= pattern; fSearchFor= searchFor; } protected void execute(IProgressMonitor monitor) throws CoreException { fCollector.setProgressMonitor(monitor); SearchEngine engine= new SearchEngine(); if (fElementPattern != null) engine.search(fWorkspace, fElementPattern, fLimitTo, fScope, fCollector); else engine.search(fWorkspace, fStringPattern, fSearchFor, fLimitTo, fScope, fCollector); } String getDescription() { String desc= null; if (fElementPattern != null) { if (fLimitTo == IJavaSearchConstants.REFERENCES && fElementPattern.getElementType() == IJavaElement.METHOD) desc= PrettySignature.getUnqualifiedMethodSignature((IMethod)fElementPattern); else desc= fElementPattern.getElementName(); if ("".equals(desc) && fElementPattern.getElementType() == IJavaElement.PACKAGE_FRAGMENT) //$NON-NLS-1$ desc= SearchMessages.getString("JavaSearchOperation.default_package"); //$NON-NLS-1$ } else desc= fStringPattern; String[] args= new String[] {desc, "{0}", fScopeDescription}; //$NON-NLS-1$ switch (fLimitTo) { case IJavaSearchConstants.IMPLEMENTORS: return SearchMessages.getFormattedString("JavaSearchOperation.implementorsPostfix", args); //$NON-NLS-1$ case IJavaSearchConstants.DECLARATIONS: return SearchMessages.getFormattedString("JavaSearchOperation.declarationsPostfix", args); //$NON-NLS-1$ case IJavaSearchConstants.REFERENCES: return SearchMessages.getFormattedString("JavaSearchOperation.referencesPostfix", args); //$NON-NLS-1$ case IJavaSearchConstants.ALL_OCCURRENCES: return SearchMessages.getFormattedString("JavaSearchOperation.occurrencesPostfix", args); //$NON-NLS-1$ default: return SearchMessages.getFormattedString("JavaSearchOperation.occurrencesPostfix", args); //$NON-NLS-1$; } } ImageDescriptor getImageDescriptor() { if (fLimitTo == IJavaSearchConstants.IMPLEMENTORS || fLimitTo == IJavaSearchConstants.DECLARATIONS) return JavaPluginImages.DESC_OBJS_SEARCH_DECL; else return JavaPluginImages.DESC_OBJS_SEARCH_REF; } }
    5,231
    Bug 5231 Add search for field read and write references
    The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field.
    resolved fixed
    5c5661b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T13:56:25Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.search.internal.ui.SearchManager; import org.eclipse.search.ui.ISearchPage; import org.eclipse.search.ui.ISearchPageContainer; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.IWorkingSet; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditorInput; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.RowLayouter; public class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants { public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$ private static List fgPreviousSearchPatterns= new ArrayList(20); private Combo fPattern; private String fInitialPattern; private boolean fFirstTime= true; private ISearchPageContainer fContainer; private Button[] fSearchFor; private String[] fSearchForText= { SearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.field") }; //$NON-NLS-1$ private Button[] fLimitTo; private String[] fLimitToText= { SearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.allOccurrences")}; //$NON-NLS-1$ private IJavaElement fJavaElement; private static class SearchPatternData { int searchFor; int limitTo; String pattern; IJavaElement javaElement; int scope; IWorkingSet workingSet; public SearchPatternData(int s, int l, String p, IJavaElement element) { this(s, l, p, element, ISearchPageContainer.WORKSPACE_SCOPE, null); } public SearchPatternData(int s, int l, String p, IJavaElement element, int scope, IWorkingSet workingSet) { searchFor= s; limitTo= l; pattern= p; javaElement= element; this.scope= scope; this.workingSet= workingSet; } } //---- Action Handling ------------------------------------------------ public boolean performAction() { SearchPatternData data= getPatternData(); IWorkspace workspace= JavaPlugin.getWorkspace(); // Setup search scope IJavaSearchScope scope= null; String scopeDescription= ""; //$NON-NLS-1$ switch (getContainer().getSelectedScope()) { case ISearchPageContainer.WORKSPACE_SCOPE: scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ scope= SearchEngine.createWorkspaceScope(); break; case ISearchPageContainer.SELECTION_SCOPE: scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$ scope= getSelectedResourcesScope(); break; case ISearchPageContainer.WORKING_SET_SCOPE: IWorkingSet workingSet= getContainer().getSelectedWorkingSet(); scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", new String[] {workingSet.getName()}); //$NON-NLS-1$ scope= SearchEngine.createJavaSearchScope(getContainer().getSelectedWorkingSet().getResources()); } JavaSearchResultCollector collector= new JavaSearchResultCollector(); JavaSearchOperation op= null; if (data.javaElement != null && getPattern().equals(fInitialPattern)) op= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector); else { data.javaElement= null; op= new JavaSearchOperation(workspace, data.pattern, data.searchFor, data.limitTo, scope, scopeDescription, collector); } Shell shell= getControl().getShell(); try { getContainer().getRunnableContext().run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$ return false; } catch (InterruptedException ex) { return false; } return true; } private int getLimitTo() { for (int i= 0; i < fLimitTo.length; i++) { if (fLimitTo[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String[] getPreviousSearchPatterns() { // Search results are not persistent int patternCount= fgPreviousSearchPatterns.size(); String [] patterns= new String[patternCount]; for (int i= 0; i < patternCount; i++) patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern; return patterns; } private int getSearchFor() { for (int i= 0; i < fSearchFor.length; i++) { if (fSearchFor[i].getSelection()) return i; } Assert.isTrue(false, SearchMessages.getString("SearchPage.shouldNeverHappen")); //$NON-NLS-1$ return -1; } private String getPattern() { return fPattern.getText(); } /** * Return search pattern data and update previous searches. * An existing entry will be updated. */ private SearchPatternData getPatternData() { String pattern= getPattern(); SearchPatternData match= null; int i= 0; int size= fgPreviousSearchPatterns.size(); while (match == null && i < size) { match= (SearchPatternData) fgPreviousSearchPatterns.get(i); i++; if (!pattern.equals(match.pattern)) match= null; }; if (match == null) { match= new SearchPatternData( getSearchFor(), getLimitTo(), getPattern(), fJavaElement, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSet()); fgPreviousSearchPatterns.add(match); } else { match.searchFor= getSearchFor(); match.limitTo= getLimitTo(); match.javaElement= fJavaElement; match.scope= getContainer().getSelectedScope(); match.workingSet= getContainer().getSelectedWorkingSet(); }; return match; } /* * Implements method from IDialogPage */ public void setVisible(boolean visible) { if (visible && fPattern != null) { if (fFirstTime) { fFirstTime= false; // Set item and text here to prevent page from resizing fPattern.setItems(getPreviousSearchPatterns()); initSelections(); } fPattern.setFocus(); getContainer().setPerformActionEnabled(fPattern.getText().length() > 0); } super.setVisible(visible); } public boolean isValid() { return true; } //---- Widget creation ------------------------------------------------ /** * Creates the page's content. */ public void createControl(Composite parent) { GridData gd; Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.makeColumnsEqualWidth= true; layout.horizontalSpacing= 10; result.setLayout(layout); RowLayouter layouter= new RowLayouter(layout.numColumns); gd= new GridData(); gd.horizontalAlignment= gd.FILL; layouter.setDefaultGridData(gd, 0); layouter.setDefaultGridData(gd, 1); layouter.setDefaultSpan(); layouter.perform(createExpression(result)); layouter.perform(createSearchFor(result), createLimitTo(result), -1); SelectionAdapter javaElementInitializer= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { fJavaElement= null; } }; fSearchFor[FIELD].addSelectionListener(javaElementInitializer); fSearchFor[METHOD].addSelectionListener(javaElementInitializer); fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer); fSearchFor[TYPE].addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleSearchForSelected(((Button)e.widget).getSelection()); } }); setControl(result); WorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE }); } private Control createExpression(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.expression.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 1; result.setLayout(layout); // Pattern combo fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER); fPattern.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handlePatternSelected(); } }); fPattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().setPerformActionEnabled(getPattern().length() > 0); } }); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.widthHint= convertWidthInCharsToPixels(30); fPattern.setLayoutData(gd); // Pattern info Label label= new Label(result, SWT.LEFT); label.setText(SearchMessages.getString("SearchPage.expression.pattern")); //$NON-NLS-1$ return result; } private void handlePatternSelected() { if (fPattern.getSelectionIndex() < 0) return; int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex(); SearchPatternData values= (SearchPatternData) fgPreviousSearchPatterns.get(index); for (int i= 0; i < fSearchFor.length; i++) fSearchFor[i].setSelection(false); for (int i= 0; i < fLimitTo.length; i++) fLimitTo[i].setSelection(false); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); fLimitTo[IMPLEMENTORS].setEnabled((values.searchFor == TYPE)); fLimitTo[DECLARATIONS].setEnabled((values.searchFor != PACKAGE)); fLimitTo[ALL_OCCURRENCES].setEnabled((values.searchFor != PACKAGE)); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); fJavaElement= values.javaElement; if (values.workingSet != null) getContainer().setSelectedWorkingSet(values.workingSet); else getContainer().setSelectedScope(values.scope); } private void handleSearchForSelected(boolean state) { boolean implState= fLimitTo[IMPLEMENTORS].getSelection(); if (!state && implState) { fLimitTo[IMPLEMENTORS].setSelection(false); fLimitTo[REFERENCES].setSelection(true); } fLimitTo[IMPLEMENTORS].setEnabled(state); fJavaElement= null; } private Control createSearchFor(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 3; result.setLayout(layout); fSearchFor= new Button[fSearchForText.length]; for (int i= 0; i < fSearchForText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fSearchForText[i]); fSearchFor[i]= button; } return result; } private Control createLimitTo(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.limitTo.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 2; result.setLayout(layout); fLimitTo= new Button[fLimitToText.length]; for (int i= 0; i < fLimitToText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fLimitToText[i]); fLimitTo[i]= button; } return result; } private void initSelections() { fJavaElement= null; ISelection selection= getSelection(); SearchPatternData values= null; values= tryTypedTextSelection(selection); if (values == null) values= trySelection(selection); if (values == null) values= trySimpleTextSelection(selection); if (values == null) values= getDefaultInitValues(); fSearchFor[values.searchFor].setSelection(true); fLimitTo[values.limitTo].setSelection(true); if (values.searchFor != TYPE) fLimitTo[IMPLEMENTORS].setEnabled(false); fInitialPattern= values.pattern; fPattern.setText(fInitialPattern); fJavaElement= values.javaElement; } private SearchPatternData tryTypedTextSelection(ISelection selection) { if (selection instanceof ITextSelection) { IEditorPart e= getEditorPart(); if (e != null) { ITextSelection ts= (ITextSelection)selection; ICodeAssist assist= getCodeAssist(e); if (assist != null) { IJavaElement[] elements= null; try { elements= assist.codeSelect(ts.getOffset(), ts.getLength()); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ } if (elements != null && elements.length > 0) { if (elements.length == 1) fJavaElement= elements[0]; else fJavaElement= chooseFromList(elements); if (fJavaElement != null) return determineInitValuesFrom(fJavaElement); } } } } return null; } private ICodeAssist getCodeAssist(IEditorPart editorPart) { IEditorInput input= editorPart.getEditorInput(); if (input instanceof ClassFileEditorInput) return ((ClassFileEditorInput)input).getClassFile(); IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); return manager.getWorkingCopy(input); } private SearchPatternData trySelection(ISelection selection) { SearchPatternData result= null; if (selection == null) return result; Object o= null; if (selection instanceof IStructuredSelection) o= ((IStructuredSelection)selection).getFirstElement(); if (o instanceof IJavaElement) { fJavaElement= (IJavaElement)o; result= determineInitValuesFrom(fJavaElement); } else if (o instanceof ISearchResultViewEntry) { fJavaElement= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker()); result= determineInitValuesFrom(fJavaElement); } else if (o instanceof IAdaptable) { IJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class); if (element != null) { result= determineInitValuesFrom(element); } else { IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class); result= new SearchPatternData(TYPE, REFERENCES, adapter.getLabel(o), null); } } return result; } private IJavaElement getJavaElement(IMarker marker) { try { return JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)); } catch (CoreException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$ return null; } } private SearchPatternData determineInitValuesFrom(IJavaElement element) { if (element == null) return null; int searchFor= UNKNOWN; int limitTo= UNKNOWN; String pattern= null; switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_DECLARATION: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.IMPORT_DECLARATION: pattern= element.getElementName(); IImportDeclaration declaration= (IImportDeclaration)element; if (declaration.isOnDemand()) { searchFor= PACKAGE; int index= pattern.lastIndexOf('.'); pattern= pattern.substring(0, index); } else { searchFor= TYPE; } limitTo= DECLARATIONS; break; case IJavaElement.TYPE: searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)element); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(".")); //$NON-NLS-1$ IType mainType= cu.getType(mainTypeName); mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType); try { mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName); if (mainType == null) { // fetch type which is declared first in the file IType[] types= cu.getTypes(); if (types.length > 0) mainType= types[0]; else break; } } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } searchFor= TYPE; element= mainType; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)mainType); break; case IJavaElement.CLASS_FILE: IClassFile cf= (IClassFile)element; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } if (mainType == null) break; element= mainType; searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName(mainType); break; case IJavaElement.FIELD: searchFor= FIELD; limitTo= REFERENCES; IType type= ((IField)element).getDeclaringType(); StringBuffer buffer= new StringBuffer(); buffer.append(JavaModelUtil.getFullyQualifiedName(type)); buffer.append('.'); buffer.append(element.getElementName()); pattern= buffer.toString(); break; case IJavaElement.METHOD: searchFor= METHOD; try { IMethod method= (IMethod)element; if (method.isConstructor()) searchFor= CONSTRUCTOR; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } limitTo= REFERENCES; pattern= PrettySignature.getMethodSignature((IMethod)element); break; } if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null) return new SearchPatternData(searchFor, limitTo, pattern, element); return null; } private SearchPatternData trySimpleTextSelection(ISelection selection) { SearchPatternData result= null; if (selection instanceof ITextSelection) { BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText())); String text; try { text= reader.readLine(); if (text == null) text= ""; //$NON-NLS-1$ } catch (IOException ex) { text= ""; //$NON-NLS-1$ } result= new SearchPatternData(TYPE, REFERENCES, text, null); } return result; } private SearchPatternData getDefaultInitValues() { return new SearchPatternData(TYPE, REFERENCES, "", null); //$NON-NLS-1$ } private IJavaElement chooseFromList(IJavaElement[] openChoices) { ILabelProvider labelProvider= new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_CONTAINER_QUALIFICATION); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle(SearchMessages.getString("SearchElementSelectionDialog.title")); //$NON-NLS-1$ dialog.setMessage(SearchMessages.getString("SearchElementSelectionDialog.message")); //$NON-NLS-1$ dialog.setElements(openChoices); if (dialog.open() == dialog.OK) return (IJavaElement)dialog.getFirstResult(); return null; } /* * Implements method from ISearchPage */ public void setContainer(ISearchPageContainer container) { fContainer= container; } /** * Returns the search page's container. */ private ISearchPageContainer getContainer() { return fContainer; } /** * Returns the current active selection. */ private ISelection getSelection() { return fContainer.getSelection(); } /** * Returns the current active editor part. */ private IEditorPart getEditorPart() { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) return page.getActiveEditor(); } return null; } private IJavaSearchScope getSelectedResourcesScope() { ArrayList resources= new ArrayList(10); if (!getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) { Iterator iter= ((IStructuredSelection)getSelection()).iterator(); while (iter.hasNext()) { Object selection= iter.next(); if (selection instanceof IResource) resources.add(selection); else if (selection instanceof IAdaptable) { IResource resource= (IResource)((IAdaptable)selection).getAdapter(IResource.class); if (resource != null) resources.add(resource); } } } return SearchEngine.createJavaSearchScope((IResource[])resources.toArray(new IResource[resources.size()])); } }
    5,231
    Bug 5231 Add search for field read and write references
    The UI should support the following new JDT Core feature: Search for field read and field write references. Two new constants have been added on IJavaSearchConstants to be used when creating a field reference search pattern: - READ_REFERENCES: the search results contain *only* read access to a field. - WRITE_REFERENCES: the search results contain *only* write access to a field. If REFERENCES is used, then search results contain both read and write accesss to a field.
    resolved fixed
    5c5661b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T13:56:25Z
    2001-10-25T08:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultCollector.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.IInputSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.search.ui.IContextMenuContributor; import org.eclipse.search.ui.ISearchResultView; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.SearchUI; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.search.IJavaSearchResultCollector; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.GroupContext; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; import org.eclipse.jdt.internal.ui.util.SelectionUtil; public class JavaSearchResultCollector implements IJavaSearchResultCollector { private static final String MATCH= SearchMessages.getString("SearchResultCollector.match"); //$NON-NLS-1$ private static final String MATCHES= SearchMessages.getString("SearchResultCollector.matches"); //$NON-NLS-1$ private static final String DONE= SearchMessages.getString("SearchResultCollector.done"); //$NON-NLS-1$ private static final String SEARCHING= SearchMessages.getString("SearchResultCollector.searching"); //$NON-NLS-1$ private static final Integer POTENTIAL_MATCH_VALUE= new Integer(POTENTIAL_MATCH); private IProgressMonitor fMonitor; private IContextMenuContributor fContextMenu; private ISearchResultView fView; private JavaSearchOperation fOperation; private int fMatchCount= 0; private Integer[] fMessageFormatArgs= new Integer[1]; private class ContextMenuContributor implements IContextMenuContributor { public void fill(IMenuManager menu, IInputSelectionProvider inputProvider) { JavaPlugin.createStandardGroups(menu); new JavaSearchGroup().fill(menu, new GroupContext(inputProvider)); OpenTypeHierarchyUtil.addToMenu(getWorbenchWindow(), menu, convertSelection(inputProvider.getSelection())); } private Object convertSelection(ISelection selection) { Object element= SelectionUtil.getSingleElement(selection); if (!(element instanceof ISearchResultViewEntry)) return null; IMarker marker= ((ISearchResultViewEntry)element).getSelectedMarker(); try { return JavaCore.create((String) ((IMarker) marker).getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)); } catch (CoreException ex) { ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-1$ return null; } } } public JavaSearchResultCollector() { fContextMenu= new ContextMenuContributor(); } /** * @see IJavaSearchResultCollector#aboutToStart(). */ public void aboutToStart() { fView= SearchUI.getSearchResultView(); fMatchCount= 0; if (fView != null) { fView.searchStarted( JavaSearchPage.EXTENSION_POINT_ID, fOperation.getDescription(), fOperation.getImageDescriptor(), fContextMenu, JavaSearchResultLabelProvider.INSTANCE, new GotoMarkerAction(), new GroupByKeyComputer(), fOperation); } if (!getProgressMonitor().isCanceled()) getProgressMonitor().subTask(SEARCHING); } /** * @see IJavaSearchResultCollector#accept */ public void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException { IMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER); HashMap attributes; Object groupKey= enclosingElement; if (accuracy == POTENTIAL_MATCH) { attributes= new HashMap(6); attributes.put(IJavaSearchUIConstants.ATT_ACCURACY, POTENTIAL_MATCH_VALUE); if (groupKey == null) groupKey= "?:null"; else groupKey= "?:" + enclosingElement.getHandleIdentifier(); } else attributes= new HashMap(5); JavaCore.addJavaElementMarkerAttributes(attributes, enclosingElement); attributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, enclosingElement.getHandleIdentifier()); attributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0))); attributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0))); if (enclosingElement instanceof IMember && ((IMember)enclosingElement).isBinary()) attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR); else attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CU_EDITOR); marker.setAttributes(attributes); fView.addMatch(enclosingElement.getElementName(), groupKey, resource, marker); fMatchCount++; if (!getProgressMonitor().isCanceled()) getProgressMonitor().subTask(getFormattedMatchesString(fMatchCount)); } /** * @see IJavaSearchResultCollector#done(). */ public void done() { if (!getProgressMonitor().isCanceled()) { String matchesString= getFormattedMatchesString(fMatchCount); getProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString})); } if (fView != null) fView.searchFinished(); // Cut no longer unused references because the collector might be re-used fView= null; fMonitor= null; } /** * @see IJavaSearchResultCollector#getProgressMonitor(). */ public IProgressMonitor getProgressMonitor() { return fMonitor; }; void setProgressMonitor(IProgressMonitor pm) { fMonitor= pm; } void setOperation(JavaSearchOperation operation) { fOperation= operation; } private String getFormattedMatchesString(int count) { if (fMatchCount == 1) return MATCH; fMessageFormatArgs[0]= new Integer(count); return MessageFormat.format(MATCHES, fMessageFormatArgs); } private IWorkbenchWindow getWorbenchWindow() { IWorkbenchWindow wbWindow= null; if (fView != null && fView.getSite() != null) wbWindow= fView.getSite().getWorkbenchWindow(); if (wbWindow == null) wbWindow= JavaPlugin.getActiveWorkbenchWindow(); return wbWindow; } }
    4,971
    Bug 4971 Strange 'copy package'
    203 1. Create a new project xxx 2. Package viewer: Select a package in project A e.g. org.eclipse.jdt.internal.ui in jdt.ui 3. From the context menu choose copy 4. Select xxx as destination 5. As result, xx contains a package 'ui'. Should be 'org.eclipse.jdt.internal.ui'
    resolved fixed
    424380a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T16:03:39Z
    2001-10-15T10:00:00Z
    org.eclipse.jdt.ui/core
    4,971
    Bug 4971 Strange 'copy package'
    203 1. Create a new project xxx 2. Package viewer: Select a package in project A e.g. org.eclipse.jdt.internal.ui in jdt.ui 3. From the context menu choose copy 4. Select xxx as destination 5. As result, xx contains a package 'ui'. Should be 'org.eclipse.jdt.internal.ui'
    resolved fixed
    424380a
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-26T16:03:39Z
    2001-10-15T10:00:00Z
    refactoring/org/eclipse/jdt/internal/core/refactoring/reorg/CopyRefactoring.java
    3,348
    Bug 3348 DCR: Code formatter enhancement (1GIYHQR)
    null
    verified fixed
    d723bdd
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T16:49:01Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeFormatterPreferencePage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.preferences; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Hashtable; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; /* * The page for setting code formatter options */ public class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // Preference store keys, see JavaCore.getOptions private static final String PREF_NEWLINE_OPENING_BRACES= "org.eclipse.jdt.core.formatter.newline.openingBrace"; private static final String PREF_NEWLINE_CONTROL_STATEMENT= "org.eclipse.jdt.core.formatter.newline.controlStatement"; private static final String PREF_NEWLINE_CLEAR_ALL= "org.eclipse.jdt.core.formatter.newline.clearAll"; private static final String PREF_NEWLINE_ELSE_IF= "org.eclipse.jdt.core.formatter.newline.elseIf"; private static final String PREF_NEWLINE_EMPTY_BLOCK= "org.eclipse.jdt.core.formatter.newline.emptyBlock"; private static final String PREF_LINE_SPLIT= "org.eclipse.jdt.core.formatter.lineSplit"; private static final String PREF_STYLE_COMPACT_ASSIGNEMENT= "org.eclipse.jdt.core.formatter.style.assignment"; private static final String PREF_TAB_CHAR= "org.eclipse.jdt.core.formatter.tabulation.char"; private static final String PREF_TAB_SIZE= "org.eclipse.jdt.core.formatter.tabulation.size"; // values private static final String INSERT= "insert"; private static final String DO_NOT_INSERT= "do not insert"; private static final String COMPACT= "compact"; private static final String NORMAL= "normal"; private static final String TAB= "tab"; private static final String SPACE= "space"; private static final String CLEAR_ALL= "clear all"; private static final String PRESERVE_ONE= "preserve one"; private static String[] getAllKeys() { return new String[] { PREF_NEWLINE_OPENING_BRACES, PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL, PREF_NEWLINE_ELSE_IF, PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT, PREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE }; } /** * Gets the currently configured tab size */ public static int getTabSize() { String string= (String) JavaCore.getOptions().get(PREF_TAB_SIZE); return getIntValue(string, 4); } /** * Gets the current compating assignement configuration */ public static boolean isCompactingAssignment() { return COMPACT.equals(JavaCore.getOptions().get(PREF_STYLE_COMPACT_ASSIGNEMENT)); } private static int getIntValue(String string, int dflt) { try { return Integer.parseInt(string); } catch (NumberFormatException e) { } return dflt; } /** * Initializes the current options (read from preference store) */ public static void initDefaults(IPreferenceStore store) { Hashtable hashtable= JavaCore.getDefaultOptions(); Hashtable currOptions= JavaCore.getOptions(); String[] allKeys= getAllKeys(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String defValue= (String) hashtable.get(key); if (defValue != null) { store.setDefault(key, defValue); } else { JavaPlugin.logErrorMessage("CodeFormatterPreferencePage: value is null: " + key); } // update the JavaCore options from the pref store String val= store.getString(key); if (val != null) { currOptions.put(key, val); } } JavaCore.setOptions(currOptions); } private static class ControlData { private String fKey; private String[] fValues; public ControlData(String key, String[] values) { fKey= key; fValues= values; } public String getKey() { return fKey; } public String getValue(boolean selection) { int index= selection ? 0 : 1; return fValues[index]; } public String getValue(int index) { return fValues[index]; } public int getSelection(String value) { for (int i= 0; i < fValues.length; i++) { if (value.equals(fValues[i])) { return i; } } throw new IllegalArgumentException(); } } private Hashtable fWorkingValues; private ArrayList fCheckBoxes; private ArrayList fTextBoxes; private SelectionListener fButtonSelectionListener; private ModifyListener fTextModifyListener; private String fPreviewText; private IDocument fPreviewDocument; private Text fTabSizeTextBox; public CodeFormatterPreferencePage() { setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(JavaUIMessages.getString("CodeFormatterPreferencePage.description")); //$NON-NLS-1$ fWorkingValues= JavaCore.getOptions(); fCheckBoxes= new ArrayList(); fTextBoxes= new ArrayList(); fButtonSelectionListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { if (!e.widget.isDisposed()) { controlChanged((Button) e.widget); } } }; fTextModifyListener= new ModifyListener() { public void modifyText(ModifyEvent e) { if (!e.widget.isDisposed()) { textChanged((Text) e.widget); } } }; fPreviewDocument= new Document(); fPreviewText= loadPreviewFile("CodeFormatterPreviewCode.txt"); //$NON-NLS-1$ } /* * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { } /* * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { super.createControl(parent); WorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE)); } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; Composite composite= new Composite(parent, SWT.NONE); composite.setLayout(layout); TabFolder folder= new TabFolder(composite, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); String[] insertNotInsert= new String[] { INSERT, DO_NOT_INSERT }; layout= new GridLayout(); layout.numColumns= 2; Composite newlineComposite= new Composite(folder, SWT.NULL); newlineComposite.setLayout(layout); String label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_opening_braces.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_OPENING_BRACES, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_control_statement.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_CONTROL_STATEMENT, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_clear_lines"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_CLEAR_ALL, new String[] { CLEAR_ALL, PRESERVE_ONE } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_else_if.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_empty_block.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_EMPTY_BLOCK, insertNotInsert); layout= new GridLayout(); layout.numColumns= 2; Composite lineSplittingComposite= new Composite(folder, SWT.NULL); lineSplittingComposite.setLayout(layout); label= JavaUIMessages.getString("CodeFormatterPreferencePage.split_line.label"); //$NON-NLS-1$ addTextField(lineSplittingComposite, label, PREF_LINE_SPLIT); layout= new GridLayout(); layout.numColumns= 2; Composite styleComposite= new Composite(folder, SWT.NULL); styleComposite.setLayout(layout); label= JavaUIMessages.getString("CodeFormatterPreferencePage.style_compact_assignement.label"); //$NON-NLS-1$ addCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ASSIGNEMENT, new String[] { COMPACT, NORMAL } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.tab_char.label"); //$NON-NLS-1$ addCheckBox(styleComposite, label, PREF_TAB_CHAR, new String[] { TAB, SPACE } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.tab_size.label"); //$NON-NLS-1$ fTabSizeTextBox= addTextField(styleComposite, label, PREF_TAB_SIZE); fTabSizeTextBox.setEnabled(!usesTabs()); TabItem item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.newline.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL)); item.setControl(newlineComposite); item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.linesplit.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); item.setControl(lineSplittingComposite); item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.style.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_REF)); item.setControl(styleComposite); createPreview(parent); updatePreview(); return composite; } private Control createPreview(Composite parent) { SourceViewer previewViewer= new SourceViewer(parent, null, SWT.V_SCROLL); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); previewViewer.configure(new JavaSourceViewerConfiguration(tools, null)); previewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); previewViewer.setEditable(false); previewViewer.setDocument(fPreviewDocument); Control control= previewViewer.getControl(); control.setLayoutData(new GridData(GridData.FILL_BOTH)); return control; } private Button addCheckBox(Composite parent, String label, String key, String[] values) { ControlData data= new ControlData(key, values); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan= 2; Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); checkBox.setData(data); checkBox.setLayoutData(gd); String currValue= (String)fWorkingValues.get(key); checkBox.setSelection(data.getSelection(currValue) == 0); checkBox.addSelectionListener(fButtonSelectionListener); fCheckBoxes.add(checkBox); return checkBox; } private Text addTextField(Composite parent, String label, String key) { Label labelControl= new Label(parent, SWT.NONE); labelControl.setText(label); labelControl.setLayoutData(new GridData()); Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE); textBox.setData(key); textBox.setLayoutData(new GridData()); String currValue= (String)fWorkingValues.get(key); textBox.setText(String.valueOf(getIntValue(currValue, 1))); textBox.setTextLimit(3); textBox.addModifyListener(fTextModifyListener); GridData gd= new GridData(); gd.widthHint= convertWidthInCharsToPixels(5); textBox.setLayoutData(gd); fTextBoxes.add(textBox); return textBox; } private void controlChanged(Button button) { ControlData data= (ControlData) button.getData(); boolean selection= button.getSelection(); String newValue= data.getValue(selection); fWorkingValues.put(data.getKey(), newValue); updatePreview(); if (PREF_TAB_CHAR.equals(data.getKey())) { fTabSizeTextBox.setEnabled(!selection); updateStatus(new StatusInfo()); if (selection) { fTabSizeTextBox.setText((String)fWorkingValues.get(PREF_TAB_SIZE)); } } } private void textChanged(Text textControl) { String key= (String) textControl.getData(); String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) { fWorkingValues.put(key, number); } updateStatus(status); updatePreview(); } /* * @see IPreferencePage#performOk() */ public boolean performOk() { String[] allKeys= getAllKeys(); // preserve other options // store in JCore and the preferences Hashtable actualOptions= JavaCore.getOptions(); IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String val= (String) fWorkingValues.get(key); actualOptions.put(key, val); store.putValue(key, val); } JavaCore.setOptions(actualOptions); return super.performOk(); } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fWorkingValues= JavaCore.getDefaultOptions(); updateControls(); super.performDefaults(); } private String loadPreviewFile(String filename) { String separator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer btxt= new StringBuffer(512); BufferedReader rin= null; try { rin= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); String line; while ((line= rin.readLine()) != null) { btxt.append(line); btxt.append(separator); } } catch (IOException io) { JavaPlugin.log(io); } finally { if (rin != null) { try { rin.close(); } catch (IOException e) {} } } return btxt.toString(); } private void updatePreview() { fPreviewDocument.set(CodeFormatter.format(fPreviewText, 0, fWorkingValues)); } private void updateControls() { // update the UI for (int i= fCheckBoxes.size() - 1; i >= 0; i--) { Button curr= (Button) fCheckBoxes.get(i); ControlData data= (ControlData) curr.getData(); String currValue= (String) fWorkingValues.get(data.getKey()); curr.setSelection(data.getSelection(currValue) == 0); } for (int i= fTextBoxes.size() - 1; i >= 0; i--) { Text curr= (Text) fTextBoxes.get(i); String key= (String) curr.getData(); String currValue= (String) fWorkingValues.get(key); curr.setText(currValue); } fTabSizeTextBox.setEnabled(!usesTabs()); } private IStatus validatePositiveNumber(String number) { StatusInfo status= new StatusInfo(); if (number.length() == 0) { status.setError(JavaUIMessages.getString("CodeFormatterPreferencePage.empty_input")); } else { try { int value= Integer.parseInt(number); if (value < 0) { status.setError(JavaUIMessages.getFormattedString("CodeFormatterPreferencePage.invalid_input", number)); } } catch (NumberFormatException e) { status.setError(JavaUIMessages.getFormattedString("CodeFormatterPreferencePage.invalid_input", number)); } } return status; } private void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { // look if there are more severe errors for (int i= 0; i < fTextBoxes.size(); i++) { Text curr= (Text) fTextBoxes.get(i); if (!(curr == fTabSizeTextBox && usesTabs())) { IStatus currStatus= validatePositiveNumber(curr.getText()); status= StatusUtil.getMoreSevere(currStatus, status); } } } setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } private boolean usesTabs() { return TAB.equals(fWorkingValues.get(PREF_TAB_CHAR)); } }
    3,348
    Bug 3348 DCR: Code formatter enhancement (1GIYHQR)
    null
    verified fixed
    d723bdd
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T16:49:01Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultAutoIndentStrategy; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; /** * Auto indent strategy sensitive to brackets. */ public class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy { public JavaAutoIndentStrategy() { } // evaluate the line with the opening bracket that matches the closing bracket on the given line protected int findMatchingOpenBracket(IDocument d, int line, int end, int closingBracketIncrease) throws BadLocationException { int start= d.getLineOffset(line); int brackcount= getBracketCount(d, start, end, false) - closingBracketIncrease; // sum up the brackets counts of each line (closing brackets count negative, // opening positive) until we find a line the brings the count to zero while (brackcount < 0) { line--; if (line < 0) { return -1; } start= d.getLineOffset(line); end= start + d.getLineLength(line) - 1; brackcount += getBracketCount(d, start, end, false); } return line; } private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException { int bracketcount= 0; while (start < end) { char curr= d.getChar(start); start++; switch (curr) { case '/' : if (start < end) { char next= d.getChar(start); if (next == '*') { // a comment starts, advance to the comment end start= getCommentEnd(d, start + 1, end); } else if (next == '/') { // '//'-comment: nothing to do anymore on this line start= end; } } break; case '*' : if (start < end) { char next= d.getChar(start); if (next == '/') { // we have been in a comment: forget what we read before bracketcount= 0; start++; } } break; case '{' : bracketcount++; ignoreCloseBrackets= false; break; case '}' : if (!ignoreCloseBrackets) { bracketcount--; } break; case '"' : case '\'' : start= getStringEnd(d, start, end, curr); break; default : } } return bracketcount; } // ----------- bracket counting ------------------------------------------------------ private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException { while (pos < end) { char curr= d.getChar(pos); pos++; if (curr == '*') { if (pos < end && d.getChar(pos) == '/') { return pos + 1; } } } return end; } protected String getIndentOfLine(IDocument d, int line) throws BadLocationException { if (line > -1) { int start= d.getLineOffset(line); int end= start + d.getLineLength(line) - 1; int whiteend= findEndOfWhiteSpace(d, start, end); return d.get(start, whiteend - start); } else { return ""; //$NON-NLS-1$ } } private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException { while (pos < end) { char curr= d.getChar(pos); pos++; if (curr == '\\') { // ignore escaped characters pos++; } else if (curr == ch) { return pos; } } return end; } protected void smartInsertAfterBracket(IDocument d, DocumentCommand c) { if (c.offset == -1 || d.getLength() == 0) return; try { int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); int start= d.getLineOffset(line); int whiteend= findEndOfWhiteSpace(d, start, c.offset); // shift only when line does not contain any text up to the closing bracket if (whiteend == c.offset) { // evaluate the line with the opening bracket that matches out closing bracket int indLine= findMatchingOpenBracket(d, line, c.offset, 1); if (indLine != -1 && indLine != line) { // take the indent of the found line StringBuffer replaceText= new StringBuffer(getIndentOfLine(d, indLine)); // add the rest of the current line including the just added close bracket replaceText.append(d.get(whiteend, c.offset - whiteend)); replaceText.append(c.text); // modify document command c.length += c.offset - start; c.offset= start; c.text= replaceText.toString(); } } } catch (BadLocationException excp) { System.out.println(JavaTextMessages.getString("AutoIndent.error.bad_location.message1")); //$NON-NLS-1$ } } protected void smartIndentAfterNewLine(IDocument d, DocumentCommand c) { int docLength= d.getLength(); if (c.offset == -1 || docLength == 0) return; try { int p= (c.offset == docLength ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); StringBuffer buf= new StringBuffer(c.text); if (c.offset < docLength && d.getChar(c.offset) == '}') { int indLine= findMatchingOpenBracket(d, line, c.offset, 0); if (indLine == -1) { indLine= line; } buf.append(getIndentOfLine(d, indLine)); } else { int start= d.getLineOffset(line); // if line just ended a javadoc comment, take the indent from the comment's begin line IDocumentPartitioner partitioner= d.getDocumentPartitioner(); if (partitioner != null) { ITypedRegion region= partitioner.getPartition(start); if (JavaPartitionScanner.JAVA_DOC.equals(region.getType())) start= d.getLineInformationOfOffset(region.getOffset()).getOffset(); } int whiteend= findEndOfWhiteSpace(d, start, c.offset); buf.append(d.get(start, whiteend - start)); if (getBracketCount(d, start, c.offset, true) > 0) { buf.append('\t'); } } c.text= buf.toString(); } catch (BadLocationException excp) { System.out.println(JavaTextMessages.getString("AutoIndent.error.bad_location.message2")); //$NON-NLS-1$ } } /** * Returns whether the text ends with one of the given search strings. */ private boolean endsWithDelimiter(IDocument d, String txt) { String[] delimiters= d.getLegalLineDelimiters(); for (int i= 0; i < delimiters.length; i++) { if (txt.endsWith(delimiters[i])) return true; } return false; } /** * @see IAutoIndentStrategy#customizeDocumentCommand */ public void customizeDocumentCommand(IDocument d, DocumentCommand c) { if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text)) smartIndentAfterNewLine(d, c); else if ("}".equals(c.text)) { //$NON-NLS-1$ smartInsertAfterBracket(d, c); } } }
    5,340
    Bug 5340 Cancelling add exception breakpoint has no effect
    1) Go to the breakpoints pane in the debug perspective 2) Click the J! button to add an exception 3) In the progress dialog, click cancel. The progress dialog closes immediately 4) Eventually the exception list comes up, it ignored the cancelation request. It should either honour the cancellation request or diable the cancel button (when calling ProgressMonitorDialog.run pass false for the canceleable parameter).
    verified fixed
    8cf182b
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T17:03:12Z
    2001-10-29T21:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/launcher/AddExceptionDialog.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.launcher; import java.lang.reflect.InvocationTargetException; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.FilteredList; import org.eclipse.jdt.internal.ui.dialogs.StatusDialog; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine; import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.util.TypeInfo; import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider; /** * Lots of stuff commented out because pending API change in * Debugger */ public class AddExceptionDialog extends StatusDialog { private static final String DIALOG_SETTINGS= "AddExceptionDialog"; //$NON-NLS-1$ private static final String SETTING_CAUGHT_CHECKED= "caughtChecked"; //$NON-NLS-1$ private static final String SETTING_UNCAUGHT_CHECKED= "uncaughtChecked"; //$NON-NLS-1$ private Text fFilterText; private FilteredList fTypeList; private boolean fTypeListInitialized= false; private Button fCaughtBox; private Button fUncaughtBox; public static final int CHECKED_EXCEPTION= 0; public static final int UNCHECKED_EXCEPTION= 1; public static final int NO_EXCEPTION= -1; private SelectionListener fListListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { validateListSelection(); } public void widgetDefaultSelected(SelectionEvent e) { validateListSelection(); if (getStatus().isOK()) okPressed(); } }; private Object fResult; private int fExceptionType= NO_EXCEPTION; private boolean fIsCaughtSelected= true; private boolean fIsUncaughtSelected= true; /** * Constructor for AddExceptionDialog */ public AddExceptionDialog(Shell parentShell) { super(parentShell); setTitle(LauncherMessages.getString("AddExceptionDialog.title")); //$NON-NLS-1$ } protected Control createDialogArea(Composite ancestor) { initFromDialogSettings(); Composite parent= new Composite(ancestor, SWT.NULL); GridLayout layout= new GridLayout(); parent.setLayout(layout); Label l= new Label(parent, SWT.NULL); l.setLayoutData(new GridData()); l.setText(LauncherMessages.getString("AddExceptionDialog.message")); //$NON-NLS-1$ fFilterText = new Text(parent, SWT.BORDER); GridData data= new GridData(); data.grabExcessVerticalSpace= false; data.grabExcessHorizontalSpace= true; data.horizontalAlignment= GridData.FILL; data.verticalAlignment= GridData.BEGINNING; fFilterText.setLayoutData(data); Listener listener= new Listener() { public void handleEvent(Event e) { fTypeList.setFilter(fFilterText.getText()); } }; fFilterText.addListener(SWT.Modify, listener); fTypeList= new FilteredList(parent, SWT.BORDER | SWT.SINGLE, new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_PACKAGE_POSTFIX), true, true, true); GridData gd= new GridData(GridData.FILL_BOTH); //gd.horizontalIndent= convertWidthInCharsToPixels(4); gd.widthHint= convertWidthInCharsToPixels(65); gd.heightHint= convertHeightInCharsToPixels(20); fTypeList.setLayoutData(gd); fCaughtBox= new Button(parent, SWT.CHECK); fCaughtBox.setLayoutData(new GridData()); fCaughtBox.setText(LauncherMessages.getString("AddExceptionDialog.caught")); //$NON-NLS-1$ fCaughtBox.setSelection(fIsCaughtSelected); fUncaughtBox= new Button(parent, SWT.CHECK); fUncaughtBox.setLayoutData(new GridData()); // fix: 1GEUWCI: ITPDUI:Linux - Add Exception box has confusing checkbox fUncaughtBox.setText(LauncherMessages.getString("AddExceptionDialog.uncaught")); //$NON-NLS-1$ // end fix. fUncaughtBox.setSelection(fIsUncaughtSelected); addFromListSelected(true); return parent; } public void addFromListSelected(boolean selected) { fTypeList.setEnabled(selected); if (selected) { if (!fTypeListInitialized) { initializeTypeList(); } fTypeList.addSelectionListener(fListListener); validateListSelection(); } else fTypeList.removeSelectionListener(fListListener); } protected void okPressed() { TypeInfo typeRef= (TypeInfo)fTypeList.getSelection()[0]; IType resolvedType= null; try { resolvedType= typeRef.resolveType(SearchEngine.createWorkspaceScope()); } catch (JavaModelException e) { updateStatus(e.getStatus()); return; } fExceptionType= getExceptionType(resolvedType); if (fExceptionType == NO_EXCEPTION) { StatusInfo status= new StatusInfo(); status.setError(LauncherMessages.getString("AddExceptionDialog.error.notThrowable")); //$NON-NLS-1$ updateStatus(status); return; } fIsCaughtSelected= fCaughtBox.getSelection(); fIsUncaughtSelected= fUncaughtBox.getSelection(); fResult= resolvedType; saveDialogSettings(); super.okPressed(); } private int getExceptionType(final IType type) { final int[] result= new int[] { NO_EXCEPTION }; BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext(); IRunnableWithProgress runnable= new IRunnableWithProgress() { public void run(IProgressMonitor pm) { try { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(pm); IType curr= type; while (curr != null) { String name= JavaModelUtil.getFullyQualifiedName(curr); if ("java.lang.Throwable".equals(name)) { //$NON-NLS-1$ result[0]= CHECKED_EXCEPTION; return; } if ("java.lang.RuntimeException".equals(name) || "java.lang.Error".equals(name)) { //$NON-NLS-2$ //$NON-NLS-1$ result[0]= UNCHECKED_EXCEPTION; return; } curr= hierarchy.getSuperclass(curr); } } catch (JavaModelException e) { JavaPlugin.log(e); } } }; try { context.run(false, false, runnable); } catch (InterruptedException e) { } catch (InvocationTargetException e) { JavaPlugin.log(e); } return result[0]; } public Object getResult() { return fResult; } public int getExceptionType() { return fExceptionType; } public boolean isCaughtSelected() { return fIsCaughtSelected; } public boolean isUncaughtSelected() { return fIsUncaughtSelected; } public void initializeTypeList() { AllTypesSearchEngine searchEngine= new AllTypesSearchEngine(JavaPlugin.getWorkspace()); int flags= IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_CLASSES | IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS; List result= searchEngine.searchTypes(new ProgressMonitorDialog(getShell()), SearchEngine.createWorkspaceScope(), flags); fFilterText.setText("*Exception*"); //$NON-NLS-1$ fTypeList.setElements(result.toArray()); // XXX inefficient fTypeListInitialized= true; } private void validateListSelection() { StatusInfo status= new StatusInfo(); if (fTypeList.getSelection().length != 1) { status.setError(LauncherMessages.getString("AddExceptionDialog.error.noSelection")); //$NON-NLS-1$ } updateStatus(status); } private void initFromDialogSettings() { IDialogSettings allSetttings= JavaPlugin.getDefault().getDialogSettings(); IDialogSettings section= allSetttings.getSection(DIALOG_SETTINGS); if (section == null) { section= allSetttings.addNewSection(DIALOG_SETTINGS); section.put(SETTING_CAUGHT_CHECKED, true); section.put(SETTING_UNCAUGHT_CHECKED, true); } fIsCaughtSelected= section.getBoolean(SETTING_CAUGHT_CHECKED); fIsUncaughtSelected= section.getBoolean(SETTING_UNCAUGHT_CHECKED); } private void saveDialogSettings() { IDialogSettings allSetttings= JavaPlugin.getDefault().getDialogSettings(); IDialogSettings section= allSetttings.getSection(DIALOG_SETTINGS); // won't be null since we initialize it in the method above. section.put(SETTING_CAUGHT_CHECKED, fIsCaughtSelected); section.put(SETTING_UNCAUGHT_CHECKED, fIsUncaughtSelected); } public void create() { super.create(); fFilterText.selectAll(); fFilterText.setFocus(); } }
    5,165
    Bug 5165 package viewer project sorting
    i have a (library) project Refactoring Tests Resources and other projects org.eclipse.... before 205 they used to be sorted alphabetically now they're not. is that intentional?
    resolved fixed
    21646f3
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T17:03:20Z
    2001-10-23T09:40:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementSorter.java
    package org.eclipse.jdt.internal.ui.viewsupport; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IInitializer; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * Sorts Java elements: * Package fragment roots are sorted as ordered in the classpath. */ public class JavaElementSorter extends ViewerSorter { private static final int CU_MEMBERS= 0; private static final int INNER_TYPES= 1; private static final int CONSTRUCTORS= 2; private static final int STATIC_INIT= 3; private static final int STATIC_METHODS= 4; private static final int INIT= 5; private static final int METHODS= 6; private static final int STATIC_FIELDS= 7; private static final int FIELDS= 8; private static final int JAVAELEMENTS= 9; private static final int PACKAGEFRAGMENTROOT= 10; private static final int RESOURCEPACKAGES= 11; private static final int RESOURCEFOLDERS= 12; private static final int RESOURCES= 13; private static final int STORAGE= 14; private static final int OTHERS= 20; private IClasspathEntry[] fClassPath; /* * @see ViewerSorter#sort */ public void sort(Viewer v, Object[] property) { fClassPath= null; try { super.sort(v, property); } finally { fClassPath= null; } } /* * @see ViewerSorter#isSorterProperty */ public boolean isSorterProperty(Object element, Object property) { return true; } /* * @see ViewerSorter#category */ public int category(Object element) { if (element instanceof IJavaElement) { try { IJavaElement je= (IJavaElement) element; switch (je.getElementType()) { case IJavaElement.METHOD: { IMethod method= (IMethod) je; if (method.isConstructor()) return CONSTRUCTORS; int flags= method.getFlags(); return Flags.isStatic(flags) ? STATIC_METHODS : METHODS; } case IJavaElement.FIELD: { int flags= ((IField) je).getFlags(); return Flags.isStatic(flags) ? STATIC_FIELDS : FIELDS; } case IJavaElement.INITIALIZER: { int flags= ((IInitializer) je).getFlags(); return Flags.isStatic(flags) ? STATIC_INIT : INIT; } case IJavaElement.TYPE: { if (((IType)element).getDeclaringType() != null) { return INNER_TYPES; } else { return CU_MEMBERS; } } case IJavaElement.PACKAGE_DECLARATION: return CU_MEMBERS; case IJavaElement.IMPORT_CONTAINER: return CU_MEMBERS; case IJavaElement.PACKAGE_FRAGMENT: IPackageFragment pack= (IPackageFragment) je; if (!pack.hasChildren() && pack.getNonJavaResources().length > 0) { return RESOURCEPACKAGES; } if (pack.getParent().getUnderlyingResource() instanceof IProject) { return PACKAGEFRAGMENTROOT; } break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: return PACKAGEFRAGMENTROOT; } } catch (JavaModelException x) { JavaPlugin.log(x); } return JAVAELEMENTS; } else if (element instanceof IFile) { return RESOURCES; } else if (element instanceof IContainer) { return RESOURCEFOLDERS; } else if (element instanceof IStorage) { return STORAGE; } return OTHERS; } /* * @see ViewerSorter#compare */ public int compare(Viewer viewer, Object e1, Object e2) { int cat1= category(e1); int cat2= category(e2); if (cat1 != cat2) return cat1 - cat2; switch (cat1) { case OTHERS: // unknown return 0; case CU_MEMBERS: // do not sort elements in CU or ClassFiles return 0; case PACKAGEFRAGMENTROOT: int p1= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e1)); int p2= getClassPathIndex(JavaModelUtil.getPackageFragmentRoot((IJavaElement)e2)); return p1 - p2; case STORAGE: return ((IStorage)e1).getName().compareToIgnoreCase(((IStorage)e2).getName()); case RESOURCES: case RESOURCEFOLDERS: return ((IResource)e1).getName().compareToIgnoreCase(((IResource)e2).getName()); case RESOURCEPACKAGES: return ((IJavaElement)e1).getElementName().compareToIgnoreCase(((IJavaElement)e2).getElementName()); default: return ((IJavaElement)e1).getElementName().compareTo(((IJavaElement)e2).getElementName()); } } private int getClassPathIndex(IPackageFragmentRoot root) { try { if (fClassPath == null) fClassPath= root.getJavaProject().getResolvedClasspath(true); } catch (JavaModelException e) { return 0; } for (int i= 0; i < fClassPath.length; i++) { if (fClassPath[i].getPath().equals(root.getPath())) return i; } return 0; } };
    5,367
    Bug 5367 Meaningless brackets presented with primitive display options
    With the primitive display options all turned on, booleans are rendered: enableCancelButton= false [] doubles have the same problem
    verified fixed
    add38a7
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T18:11:54Z
    2001-10-30T22:13:20Z
    org.eclipse.jdt.ui/ui
    5,367
    Bug 5367 Meaningless brackets presented with primitive display options
    With the primitive display options all turned on, booleans are rendered: enableCancelButton= false [] doubles have the same problem
    verified fixed
    add38a7
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T18:11:54Z
    2001-10-30T22:13:20Z
    debug/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java
    5,328
    Bug 5328 NPE in Open Super Method action
    1) make an empty selection in the text editor outside of a type's range, e.g, in the import 2) execute Show in Packages View ->NPE Notice: I've changed the Show in Packages View action and it might be the culprit. Issue: unclear why this code is executed when running the other action. org.eclipse.jface.util.Assert$AssertionFailedException: null argument; at org.eclipse.jface.util.Assert.isNotNull(Assert.java:133) at org.eclipse.jface.util.Assert.isNotNull(Assert.java(Compiled Code)) at org.eclipse.jface.viewers.StructuredSelection.<init> (StructuredSelection.java:54) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$Adapter.asStruct uredSelection(StructuredSelectionProvider.java:75) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$Adapter.asStruct uredSelection(StructuredSelectionProvider.java:48) at org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider$SelectionService Adapter.getSelection(StructuredSelectionProvider.java:138) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.getMethod (OpenSuperImplementationAction.java:69) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.canOperateOn (OpenSuperImplementationAction.java:61) at org.eclipse.jdt.internal.ui.actions.OpenSuperImplementationAction.update (OpenSuperImplementationAction.java:57) at org.eclipse.ui.texteditor.AbstractTextEditor.addAction (AbstractTextEditor.java:1693) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.editorContextMenuAboutToShow (JavaEditor.java:138) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.editorContextMenuAb outToShow(CompilationUnitEditor.java:298) at org.eclipse.ui.texteditor.AbstractTextEditor$2.menuAboutToShow (AbstractTextEditor.java:659) at org.eclipse.jface.action.MenuManager.fireAboutToShow (MenuManager.java:220) at org.eclipse.jface.action.MenuManager.handleAboutToShow (MenuManager.java:253) at org.eclipse.jface.action.MenuManager.access$0(MenuManager.java:250) at org.eclipse.jface.action.MenuManager$1.menuShown (MenuManager.java:280) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:112) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:828) at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:2787) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:983) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method) at org.eclipse.swt.widgets.Menu.setVisible(Menu.java:740) at org.eclipse.swt.widgets.Control.WM_CONTEXTMENU(Control.java:2612) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java (Compiled Code)) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java (Compiled Code)) at org.eclipse.swt.widgets.Control.WM_RBUTTONUP(Control.java:3446) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1136) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1165) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:675) at org.eclipse.ui.internal.Workbench.run(Workbench.java:658) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at SlimLauncher.main(SlimLauncher.java:14)
    resolved fixed
    b6c438e
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T18:17:00Z
    2001-10-29T15:40:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/StructuredSelectionProvider.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.actions; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.ISelectionService; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; /** */ public abstract class StructuredSelectionProvider { public static int FLAGS_DO_CODERESOLVE= 1; public static int FLAGS_DO_ELEMENT_AT_OFFSET= 2; private static abstract class Adapter extends StructuredSelectionProvider { private ITextSelection fLastTextSelection; private IStructuredSelection fLastStructuredSelection; private Adapter() { } protected IStructuredSelection asStructuredSelection(ITextSelection selection, int flags) { IEditorPart editor= JavaPlugin.getActivePage().getActiveEditor(); if (editor == null) return null; return asStructuredSelection(selection, editor, flags); } protected IStructuredSelection asStructuredSelection(ITextSelection selection, IEditorPart editor, int flags) { if ((flags & FLAGS_DO_CODERESOLVE) != 0) { if (selection.getLength() == 0) return StructuredSelection.EMPTY; IStructuredSelection result= considerCache(selection); if (result != null) return result; IJavaElement assist= getEditorInput(editor); if (assist instanceof ICodeAssist) { try { IJavaElement[] elements= ((ICodeAssist)assist).codeSelect(selection.getOffset(), selection.getLength()); result= new StructuredSelection(elements); } catch (JavaModelException e) { ExceptionHandler.handle(e, "Selection Converter", "Unexpected exception while converting text selection."); } cacheResult(selection, result); return result; } } else if ((flags & FLAGS_DO_ELEMENT_AT_OFFSET) != 0) { try { IJavaElement assist= getEditorInput(editor); if (assist instanceof ICompilationUnit) { IJavaElement ref= ((ICompilationUnit)assist).getElementAt(selection.getOffset()); return new StructuredSelection(ref); } else if (assist instanceof IClassFile) { IJavaElement ref= ((IClassFile)assist).getElementAt(selection.getOffset()); return new StructuredSelection(ref); } } catch (JavaModelException e) { ExceptionHandler.handle(e, "Selection Converter", "Unexpected exception while converting text selection."); } } return StructuredSelection.EMPTY; } private IStructuredSelection considerCache(ITextSelection selection) { if (selection != fLastTextSelection) { fLastTextSelection= null; fLastStructuredSelection= null; } return fLastStructuredSelection; } private void cacheResult(ITextSelection selection, IStructuredSelection result) { fLastTextSelection= selection; fLastStructuredSelection= result; } private IJavaElement getEditorInput(IEditorPart editorPart) { IEditorInput input= editorPart.getEditorInput(); if (input instanceof IClassFileEditorInput) return ((IClassFileEditorInput)input).getClassFile(); IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); return manager.getWorkingCopy(input); } } private static class SelectionProviderAdapter extends Adapter { private ISelectionProvider fProvider; public SelectionProviderAdapter(ISelectionProvider provider) { super(); fProvider= provider; Assert.isNotNull(fProvider); } public IStructuredSelection getSelection(int flags) { ISelection result= fProvider.getSelection(); if (result instanceof IStructuredSelection) return (IStructuredSelection)result; if (result instanceof ITextSelection && fProvider instanceof IEditorPart) return asStructuredSelection((ITextSelection)result, (IEditorPart)fProvider, flags); return StructuredSelection.EMPTY; } } private static class SelectionServiceAdapter extends Adapter { private ISelectionService fService; public SelectionServiceAdapter(ISelectionService service) { super(); fService= service; Assert.isNotNull(fService); } public IStructuredSelection getSelection(int flags) { ISelection result= fService.getSelection(); if (result instanceof IStructuredSelection) return (IStructuredSelection)result; if (result instanceof ITextSelection) return asStructuredSelection((ITextSelection)result, flags); return null; } } public IStructuredSelection getSelection() { return getSelection(FLAGS_DO_CODERESOLVE); } public abstract IStructuredSelection getSelection(int flags); private StructuredSelectionProvider() { // prevent instantiation. } public static StructuredSelectionProvider createFrom(ISelectionProvider provider) { return new SelectionProviderAdapter(provider); } public static StructuredSelectionProvider createFrom(ISelectionService service) { return new SelectionServiceAdapter(service); } }
    5,358
    Bug 5358 Suspicious usage of IJavaElementDelta.getFlags()
    Build 20011025 Searching for references to IJavaElement.getFlags(), I found suspicious usage in JDT UI code. There are pattern of code like this one: delta.getFlags() == IJavaElementDelta.F_CONTENT where it should be: (delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0
    resolved fixed
    10e602c
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T18:22:06Z
    2001-10-30T16:40:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.typehierarchy; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IElementChangedListener; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IRegion; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.ITypeHierarchyChangedListener; import org.eclipse.jdt.core.IWorkingCopy; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; import org.eclipse.jdt.internal.ui.util.JavaModelUtil; /** * Manages a type hierarchy, to keep it refreshed, and to allow it to be shared. */ public class TypeHierarchyLifeCycle implements ITypeHierarchyChangedListener, IElementChangedListener { private boolean fHierarchyRefreshNeeded; private ITypeHierarchy fHierarchy; private IJavaElement fInputElement; private boolean fIsSuperTypesOnly; private List fChangeListeners; public TypeHierarchyLifeCycle() { this(false); } public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) { fHierarchy= null; fInputElement= null; fIsSuperTypesOnly= isSuperTypesOnly; fChangeListeners= new ArrayList(2); } public ITypeHierarchy getHierarchy() { return fHierarchy; } public IJavaElement getInputElement() { return fInputElement; } public void freeHierarchy() { if (fHierarchy != null) { fHierarchy.removeTypeHierarchyChangedListener(this); JavaCore.removeElementChangedListener(this); fHierarchy= null; fInputElement= null; } } public void removeChangedListener(ITypeHierarchyLifeCycleListener listener) { fChangeListeners.remove(listener); } public void addChangedListener(ITypeHierarchyLifeCycleListener listener) { if (!fChangeListeners.contains(listener)) { fChangeListeners.add(listener); } } private void fireChange(IType[] changedTypes) { for (int i= fChangeListeners.size()-1; i>=0; i--) { ITypeHierarchyLifeCycleListener curr= (ITypeHierarchyLifeCycleListener) fChangeListeners.get(i); curr.typeHierarchyChanged(this, changedTypes); } } public void ensureRefreshedTypeHierarchy() throws JavaModelException { if (fHierarchy != null) { ensureRefreshedTypeHierarchy(fInputElement); } } public void ensureRefreshedTypeHierarchy(final IJavaElement element) throws JavaModelException { if (element == null) { freeHierarchy(); return; } boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement)); if (hierachyCreationNeeded || fHierarchyRefreshNeeded) { IRunnableWithProgress op= new IRunnableWithProgress() { public void run(IProgressMonitor pm) throws InvocationTargetException { try { doHierarchyRefresh(element, pm); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }; try { new BusyIndicatorRunnableContext().run(true, false, op); } catch (InvocationTargetException e) { Throwable th= e.getTargetException(); if (th instanceof JavaModelException) { throw (JavaModelException)th; } else { throw new JavaModelException(th, IStatus.ERROR); } } catch (InterruptedException e) { // Not cancelable. } fHierarchyRefreshNeeded= false; } } private void doHierarchyRefresh(IJavaElement element, IProgressMonitor pm) throws JavaModelException { boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement)); if (hierachyCreationNeeded) { if (fHierarchy != null) { fHierarchy.removeTypeHierarchyChangedListener(this); JavaCore.removeElementChangedListener(this); } fInputElement= element; if (element.getElementType() == IJavaElement.TYPE) { IType type= (IType) element; if (fIsSuperTypesOnly) { fHierarchy= type.newSupertypeHierarchy(pm); } else { fHierarchy= type.newTypeHierarchy(pm); } } else { IJavaProject jproject= element.getJavaProject(); IRegion region= JavaCore.newRegion(); region.add(element); fHierarchy= jproject.newTypeHierarchy(region, pm); } fHierarchy.addTypeHierarchyChangedListener(this); JavaCore.addElementChangedListener(this); } else { fHierarchy.refresh(pm); } } /* * @see ITypeHierarchyChangedListener#typeHierarchyChanged */ public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) { fHierarchyRefreshNeeded= true; } /* * @see IElementChangedListener#elementChanged(ElementChangedEvent) */ public void elementChanged(ElementChangedEvent event) { IJavaElement elem= event.getDelta().getElement(); if (elem instanceof IWorkingCopy && ((IWorkingCopy)elem).isWorkingCopy()) { return; } if (fHierarchyRefreshNeeded) { fireChange(null); } else { ArrayList changedTypes= new ArrayList(); processDelta(event.getDelta(), changedTypes); fireChange((IType[]) changedTypes.toArray(new IType[changedTypes.size()])); } } /* * Assume that the hierarchy is intact (no refresh needed) */ private void processDelta(IJavaElementDelta delta, ArrayList changedTypes) { IJavaElement element= delta.getElement(); switch (element.getElementType()) { case IJavaElement.TYPE: processTypeDelta((IType) element, changedTypes); processChildrenDelta(delta, changedTypes); // (inner types) break; case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.PACKAGE_FRAGMENT: processChildrenDelta(delta, changedTypes); break; case IJavaElement.COMPILATION_UNIT: if (delta.getKind() == IJavaElementDelta.CHANGED && delta.getFlags() == IJavaElementDelta.F_CONTENT) { try { IType[] types= ((ICompilationUnit) element).getAllTypes(); for (int i= 0; i < types.length; i++) { processTypeDelta(types[i], changedTypes); } } catch (JavaModelException e) { JavaPlugin.log(e); } } else { processChildrenDelta(delta, changedTypes); } break; case IJavaElement.CLASS_FILE: if (delta.getKind() == IJavaElementDelta.CHANGED && delta.getFlags() == IJavaElementDelta.F_CONTENT) { try { IType type= ((IClassFile) element).getType(); processTypeDelta(type, changedTypes); } catch (JavaModelException e) { JavaPlugin.log(e); } } else { processChildrenDelta(delta, changedTypes); } break; } } private void processTypeDelta(IType type, ArrayList changedTypes) { if (getHierarchy().contains(type)) { changedTypes.add(type); } } private void processChildrenDelta(IJavaElementDelta delta, ArrayList changedTypes) { IJavaElementDelta[] children= delta.getAffectedChildren(); for (int i= 0; i < children.length; i++) { processDelta(children[i], changedTypes); // recursive } } }
    5,361
    Bug 5361 No error tick on imports in Packages view
    Add an import that causes an error (e.g. dani.is.bad) and save. ==> The Outline view shows the error ticks on the imports but the package view doesn't
    resolved fixed
    491a8fb
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-10-31T18:31:06Z
    2001-10-30T16:40:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/MarkerErrorTickProvider.java
    package org.eclipse.jdt.internal.ui.viewsupport; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModelMarker; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Used by the JavaElementLabelProvider to evaluate the error tick state of * an element. */ public class MarkerErrorTickProvider implements IErrorTickProvider { /* * @see IErrorTickProvider#getErrorInfo */ public int getErrorInfo(IJavaElement element) { int info= 0; try { IResource res= null; ISourceRange range= null; int depth= IResource.DEPTH_INFINITE; int type= element.getElementType(); if (type == IJavaElement.JAVA_PROJECT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT || type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.CLASS_FILE || type == IJavaElement.COMPILATION_UNIT) { res= element.getCorrespondingResource(); if (type == IJavaElement.PACKAGE_FRAGMENT) { depth= IResource.DEPTH_ONE; } else if (type == IJavaElement.JAVA_PROJECT) { IMarker[] bpMarkers= res.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, true, IResource.DEPTH_ONE); info= accumulateProblems(bpMarkers, info, null); } } else if (type == IJavaElement.TYPE || type == IJavaElement.METHOD || type == IJavaElement.INITIALIZER) { // I assume that only source elements can have markers ICompilationUnit cu= ((IMember)element).getCompilationUnit(); if (cu != null) { res= element.getUnderlyingResource(); range= ((IMember)element).getSourceRange(); } } if (res != null) { IMarker[] markers= res.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, depth); if (markers != null) { info= accumulateProblems(markers, info, range); } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } return info; } private int accumulateProblems(IMarker[] markers, int info, ISourceRange range) { if (markers != null) { for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) { IMarker curr= markers[i]; if (range == null || isInRange(curr, range)) { int priority= curr.getAttribute(IMarker.SEVERITY, -1); if (priority == IMarker.SEVERITY_WARNING) { info= ERRORTICK_WARNING; } else if (priority == IMarker.SEVERITY_ERROR) { info= ERRORTICK_ERROR; } } } } return info; } private boolean isInRange(IMarker marker, ISourceRange range) { int pos= marker.getAttribute(IMarker.CHAR_START, -1); int offset= range.getOffset(); return (offset <= pos && offset + range.getLength() > pos); } }
    5,392
    Bug 5392 Eclipse dies without warning
    build 205 on Win98. This happened 3 times. 1). I was looking at Java code and selected something in the Outline view and Eclipse died without any warning. No log messages or dialogs. 2). I restarted, opened up the Java class again, clicked around in the Outline and it was ok. Then I clicked on a method in the outline, did a search, then double-clicked on the single search result and Eclipse died without warning again. Again without a log or dialog. 3). Restarted again. Pressed the Open to Type button, typed in the class name and hit ok. Eclipse died, got 3 dialogs saying that an error has occurred, and got the following in my log file. Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306) Log: Wed Oct 31 13:50:35 EST 2001 2 org.eclipse.ui 2 Problems occurred when invoking code from plug-in: org.eclipse.ui. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:1805) at org.eclipse.swt.SWT.error(SWT.java:1737) at org.eclipse.swt.custom.CTabItem.getDisplay(CTabItem.java:78) at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Item.getText(Item.java:67) at org.eclipse.swt.custom.CTabItem.setText(CTabItem.java:387) at org.eclipse.ui.internal.EditorWorkbook.updateEditorTab (EditorWorkbook.java:681) at org.eclipse.ui.internal.EditorWorkbook.propertyChanged (EditorWorkbook.java:371) at org.eclipse.ui.part.WorkbenchPart$1.run(WorkbenchPart.java:81) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:812) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.jface.window.Window.runEventLoop(Window.java:536) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.jface.dialogs.MessageDialog.openError (MessageDialog.java:318) at org.eclipse.ui.internal.SafeRunnableAdapter.handleException (SafeRunnableAdapter.java:33) at org.eclipse.ui.part.WorkbenchPart$1.handleException (WorkbenchPart.java:84) at org.eclipse.core.internal.runtime.InternalPlatform.handleException (InternalPlatform.java:429) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:814) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.ui.part.WorkbenchPart.firePropertyChange (WorkbenchPart.java:79) at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange (AbstractTextEditor.java:1952) at org.eclipse.ui.part.WorkbenchPart.setTitleImage (WorkbenchPart.java:222) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updatedTitleImage (JavaEditor.java:343) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.doUpdateErrorT icks(JavaEditorErrorTickUpdater.java:76) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater.access$0 (JavaEditorErrorTickUpdater.java:72) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater$1.run (JavaEditorErrorTickUpdater.java:66) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1336) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1163) at org.eclipse.swt.widgets.Display.release(Display.java:1213) at org.eclipse.swt.graphics.Device.dispose(Device.java:200) at org.eclipse.ui.internal.Workbench.run(Workbench.java:663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:433) at org.eclipse.core.launcher.Main.main(Main.java:306)
    resolved fixed
    02264f5
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-11-01T08:39:47Z
    2001-10-31T17:40:00Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorErrorTickUpdater.java
    package org.eclipse.jdt.internal.ui.javaeditor; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelListener; import org.eclipse.jface.util.Assert; import org.eclipse.ui.IEditorInput; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.ui.JavaElementLabelProvider; /** * The <code>JavaEditorErrorTickUpdater</code> will register as a AnnotationModelListener * on the annotation model of a Java Editor and update the title images when the annotation * model changed. */ public class JavaEditorErrorTickUpdater implements IAnnotationModelListener { private JavaEditor fJavaEditor; private IAnnotationModel fAnnotationModel; private JavaElementLabelProvider fLabelProvider; public JavaEditorErrorTickUpdater(JavaEditor editor) { fJavaEditor= editor; Assert.isNotNull(editor); } /** * Defines the annotation model to listen to. To be called when the * annotation model changes. * @param model The new annotation model or <code>null</code> * to uninstall. */ public void setAnnotationModel(IAnnotationModel model) { if (fAnnotationModel != null) { fAnnotationModel.removeAnnotationModelListener(this); } if (model != null) { fAnnotationModel=model; fAnnotationModel.addAnnotationModelListener(this); if (fLabelProvider == null) { fLabelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS); } fLabelProvider.setErrorTickManager(new AnnotationErrorTickProvider(fAnnotationModel)); modelChanged(fAnnotationModel); } else { fAnnotationModel= null; if (fLabelProvider != null) { fLabelProvider.dispose(); fLabelProvider= null; } } } /** * @see IAnnotationModelListener#modelChanged(IAnnotationModel) */ public void modelChanged(IAnnotationModel model) { if (fJavaEditor.getTitleImage() == null) { return; } Shell shell= fJavaEditor.getEditorSite().getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(new Runnable() { public void run() { doUpdateErrorTicks(); } }); } } private void doUpdateErrorTicks() { IEditorInput input= fJavaEditor.getEditorInput(); if (fLabelProvider != null && input != null) { // running async, tests needed IJavaElement jelement= (IJavaElement) input.getAdapter(IJavaElement.class); if (jelement != null) { fJavaEditor.updatedTitleImage(fLabelProvider.getImage(jelement)); } } } }
    4,273
    Bug 4273 Compiler option changes not handled correctly (1GKWRI3)
    Nothing happens if auto-build is on and (some) compiler options are changed . If something was reported as error and now I choose that to be reported as warning and if autobuild is on I expect a rebuild. Same if I switch from 1.2 to 1.3 compatibilty. NOTES: EG (01.10.2001 14:57:06) we should prompt the user for a rebuild whenever an option changes. MA (01.10.2001 15:16:25) The description in the pages says everything. EG (02.10.2001 18:16:59) yes, but this is isn't sufficient. We should show a dialog with the option to rebuild the workspace after apply.
    resolved fixed
    2c430ec
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-11-01T10:02:10Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerPreferencePage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Hashtable; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Widget; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; /* * The page for setting the compiler options. */ public class CompilerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // Preference store keys, see JavaCore.getOptions private static final String PREF_LOCAL_VARIABLE_ATTR= "org.eclipse.jdt.core.compiler.debug.localVariable"; private static final String PREF_LINE_NUMBER_ATTR= "org.eclipse.jdt.core.compiler.debug.lineNumber"; private static final String PREF_SOURCE_FILE_ATTR= "org.eclipse.jdt.core.compiler.debug.sourceFile"; private static final String PREF_CODEGEN_UNUSED_LOCAL= "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; private static final String PREF_CODEGEN_TARGET_PLATFORM= "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; private static final String PREF_PB_UNREACHABLE_CODE= "org.eclipse.jdt.core.compiler.problem.unreachableCode"; private static final String PREF_PB_INVALID_IMPORT= "org.eclipse.jdt.core.compiler.problem.invalidImport"; private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; private static final String PREF_PB_DEPRECATION= "org.eclipse.jdt.core.compiler.problem.deprecation"; private static final String PREF_PB_HIDDEN_CATCH_BLOCK= "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; private static final String PREF_PB_UNUSED_LOCAL= "org.eclipse.jdt.core.compiler.problem.unusedLocal"; private static final String PREF_PB_UNUSED_PARAMETER= "org.eclipse.jdt.core.compiler.problem.unusedParameter"; private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; private static final String PREF_PB_ASSERT_AS_IDENTIFIER= "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; private static final String PREF_SOURCE_COMPATIBILITY= "org.eclipse.jdt.core.compiler.source"; // values private static final String GENERATE= "generate"; private static final String DO_NOT_GENERATE= "do not generate"; private static final String PRESERVE= "preserve"; private static final String OPTIMIZE_OUT= "optimize out"; private static final String VERSION_1_1= "1.1"; private static final String VERSION_1_2= "1.2"; private static final String VERSION_1_3= "1.3"; private static final String VERSION_1_4= "1.4"; private static final String ERROR= "error"; private static final String WARNING= "warning"; private static final String IGNORE= "ignore"; private static String[] getAllKeys() { return new String[] { PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_UNREACHABLE_CODE, PREF_PB_INVALID_IMPORT, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL, PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_SOURCE_COMPATIBILITY }; } /** * Initializes the current options (read from preference store) */ public static void initDefaults(IPreferenceStore store) { Hashtable hashtable= JavaCore.getDefaultOptions(); Hashtable currOptions= JavaCore.getOptions(); String[] allKeys= getAllKeys(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String defValue= (String) hashtable.get(key); if (defValue != null) { store.setDefault(key, defValue); } else { JavaPlugin.logErrorMessage("CompilerPreferencePage: value is null: " + key); } // update the JavaCore options from the pref store String val= store.getString(key); if (val != null) { currOptions.put(key, val); } } JavaCore.setOptions(currOptions); } private static class ControlData { private String fKey; private String[] fValues; public ControlData(String key, String[] values) { fKey= key; fValues= values; } public String getKey() { return fKey; } public String getValue(boolean selection) { int index= selection ? 0 : 1; return fValues[index]; } public String getValue(int index) { return fValues[index]; } public int getSelection(String value) { for (int i= 0; i < fValues.length; i++) { if (value.equals(fValues[i])) { return i; } } throw new IllegalArgumentException(); } } private Hashtable fWorkingValues; private ArrayList fCheckBoxes; private ArrayList fComboBoxes; private SelectionListener fSelectionListener; public CompilerPreferencePage() { setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(JavaUIMessages.getString("CompilerPreferencePage.description")); //$NON-NLS-1$ fWorkingValues= JavaCore.getOptions(); fCheckBoxes= new ArrayList(); fComboBoxes= new ArrayList(); fSelectionListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { controlChanged(e.widget); } }; } /** * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { } /** * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { // added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages super.createControl(parent); WorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE)); } /** * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { JavaUIMessages.getString("CompilerPreferencePage.error"), JavaUIMessages.getString("CompilerPreferencePage.warning"), JavaUIMessages.getString("CompilerPreferencePage.ignore") }; GridLayout layout= new GridLayout(); layout.numColumns= 2; Composite warningsComposite= new Composite(folder, SWT.NULL); warningsComposite.setLayout(layout); String label= JavaUIMessages.getString("CompilerPreferencePage.pb_unreachable_code.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_UNREACHABLE_CODE, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_invalid_import.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_INVALID_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_method_naming.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_deprecation.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_hidden_catchblock.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_unused_local.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_unused_parameter.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_synth_access_emul.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_non_externalized_strings.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels); label= JavaUIMessages.getString("CompilerPreferencePage.pb_assert_as_identifier.label"); //$NON-NLS-1$ addComboBox(warningsComposite, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels); String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE }; layout= new GridLayout(); layout.numColumns= 2; Composite codeGenComposite= new Composite(folder, SWT.NULL); codeGenComposite.setLayout(layout); label= JavaUIMessages.getString("CompilerPreferencePage.variable_attr.label"); //$NON-NLS-1$ addCheckBox(codeGenComposite, label, PREF_LOCAL_VARIABLE_ATTR, generateValues); label= JavaUIMessages.getString("CompilerPreferencePage.line_number_attr.label"); //$NON-NLS-1$ addCheckBox(codeGenComposite, label, PREF_LINE_NUMBER_ATTR, generateValues); label= JavaUIMessages.getString("CompilerPreferencePage.source_file_attr.label"); //$NON-NLS-1$ addCheckBox(codeGenComposite, label, PREF_SOURCE_FILE_ATTR, generateValues); label= JavaUIMessages.getString("CompilerPreferencePage.codegen_unused_local.label"); //$NON-NLS-1$ addCheckBox(codeGenComposite, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }); String[] values= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 }; String[] valuesLabels= new String[] { JavaUIMessages.getString("CompilerPreferencePage.jvm11"), JavaUIMessages.getString("CompilerPreferencePage.jvm12"), JavaUIMessages.getString("CompilerPreferencePage.jvm13"), JavaUIMessages.getString("CompilerPreferencePage.jvm14") }; label= JavaUIMessages.getString("CompilerPreferencePage.codegen_targetplatform.label"); //$NON-NLS-1$ addComboBox(codeGenComposite, label, PREF_CODEGEN_TARGET_PLATFORM, values, valuesLabels); values= new String[] { VERSION_1_3, VERSION_1_4 }; valuesLabels= new String[] { JavaUIMessages.getString("CompilerPreferencePage.version13"), JavaUIMessages.getString("CompilerPreferencePage.version14") }; label= JavaUIMessages.getString("CompilerPreferencePage.source_compatibility.label"); //$NON-NLS-1$ addComboBox(codeGenComposite, label, PREF_SOURCE_COMPATIBILITY, values, valuesLabels); TabItem item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CompilerPreferencePage.warnings.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING)); item.setControl(warningsComposite); item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CompilerPreferencePage.generation.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); item.setControl(codeGenComposite); return folder; } private void addCheckBox(Composite parent, String label, String key, String[] values) { ControlData data= new ControlData(key, values); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan= 2; Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); checkBox.setData(data); checkBox.setLayoutData(gd); checkBox.addSelectionListener(fSelectionListener); String currValue= (String)fWorkingValues.get(key); checkBox.setSelection(data.getSelection(currValue) == 0); fCheckBoxes.add(checkBox); } private void addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels) { ControlData data= new ControlData(key, values); Label labelControl= new Label(parent, SWT.NONE); labelControl.setText(label); labelControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridData gd= new GridData(); gd.horizontalAlignment= GridData.END; Combo comboBox= new Combo(parent, SWT.READ_ONLY); comboBox.setItems(valueLabels); comboBox.setData(data); comboBox.setLayoutData(gd); comboBox.addSelectionListener(fSelectionListener); String currValue= (String)fWorkingValues.get(key); comboBox.select(data.getSelection(currValue)); fComboBoxes.add(comboBox); } private void controlChanged(Widget widget) { ControlData data= (ControlData) widget.getData(); String newValue= null; if (widget instanceof Button) { newValue= data.getValue(((Button)widget).getSelection()); } else if (widget instanceof Combo) { newValue= data.getValue(((Combo)widget).getSelectionIndex()); } else { return; } fWorkingValues.put(data.getKey(), newValue); } /* * @see IPreferencePage#performOk() */ public boolean performOk() { String[] allKeys= getAllKeys(); // preserve other options // store in JCore and the preferences Hashtable actualOptions= JavaCore.getOptions(); IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String val= (String) fWorkingValues.get(key); actualOptions.put(key, val); store.putValue(key, val); } JavaCore.setOptions(actualOptions); return super.performOk(); } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fWorkingValues= JavaCore.getDefaultOptions(); updateControls(); super.performDefaults(); } private void updateControls() { // update the UI for (int i= fCheckBoxes.size() - 1; i >= 0; i--) { Button curr= (Button) fCheckBoxes.get(i); ControlData data= (ControlData) curr.getData(); String currValue= (String) fWorkingValues.get(data.getKey()); curr.setSelection(data.getSelection(currValue) == 0); } for (int i= fComboBoxes.size() - 1; i >= 0; i--) { Combo curr= (Combo) fComboBoxes.get(i); ControlData data= (ControlData) curr.getData(); String currValue= (String) fWorkingValues.get(data.getKey()); curr.select(data.getSelection(currValue)); } } }
    4,171
    Bug 4171 Accessibility: Code Formatter Page too large with a large text font (1GJL58E)
    If the Text font is set to be very large (say 36 point) the CodeFormatter preference page is created so large that it ends up bigger than the display. The text in the preference page should be scrollable. It also does not pick up changes to the font size so if the user changes the size of the text font they will have to reopen the preference dialog to get the change picked up. STEPS 1) Set the Text Font in the font preference page to be 36 point 2) Close the preference dialog 3) Reopen the preference dialog and select the code formatter page NOTES:
    verified fixed
    c9d4729
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-11-01T10:08:06Z
    2001-10-11T03:13:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeFormatterPreferencePage.java
    /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ package org.eclipse.jdt.internal.ui.preferences; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Hashtable; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.DialogPageContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.formatter.CodeFormatter; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; /* * The page for setting code formatter options */ public class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { // Preference store keys, see JavaCore.getOptions private static final String PREF_NEWLINE_OPENING_BRACES= "org.eclipse.jdt.core.formatter.newline.openingBrace"; private static final String PREF_NEWLINE_CONTROL_STATEMENT= "org.eclipse.jdt.core.formatter.newline.controlStatement"; private static final String PREF_NEWLINE_CLEAR_ALL= "org.eclipse.jdt.core.formatter.newline.clearAll"; private static final String PREF_NEWLINE_ELSE_IF= "org.eclipse.jdt.core.formatter.newline.elseIf"; private static final String PREF_NEWLINE_EMPTY_BLOCK= "org.eclipse.jdt.core.formatter.newline.emptyBlock"; private static final String PREF_LINE_SPLIT= "org.eclipse.jdt.core.formatter.lineSplit"; private static final String PREF_STYLE_COMPACT_ASSIGNEMENT= "org.eclipse.jdt.core.formatter.style.assignment"; private static final String PREF_TAB_CHAR= "org.eclipse.jdt.core.formatter.tabulation.char"; private static final String PREF_TAB_SIZE= "org.eclipse.jdt.core.formatter.tabulation.size"; // values private static final String INSERT= "insert"; private static final String DO_NOT_INSERT= "do not insert"; private static final String COMPACT= "compact"; private static final String NORMAL= "normal"; private static final String TAB= "tab"; private static final String SPACE= "space"; private static final String CLEAR_ALL= "clear all"; private static final String PRESERVE_ONE= "preserve one"; private static String[] getAllKeys() { return new String[] { PREF_NEWLINE_OPENING_BRACES, PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL, PREF_NEWLINE_ELSE_IF, PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT, PREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE }; } /** * Gets the currently configured tab size */ public static int getTabSize() { String string= (String) JavaCore.getOptions().get(PREF_TAB_SIZE); return getIntValue(string, 4); } /** * Gets the current compating assignement configuration */ public static boolean isCompactingAssignment() { return COMPACT.equals(JavaCore.getOptions().get(PREF_STYLE_COMPACT_ASSIGNEMENT)); } /** * Gets the current compating assignement configuration */ public static boolean useSpaces() { return SPACE.equals(JavaCore.getOptions().get(PREF_TAB_CHAR)); } private static int getIntValue(String string, int dflt) { try { return Integer.parseInt(string); } catch (NumberFormatException e) { } return dflt; } /** * Initializes the current options (read from preference store) */ public static void initDefaults(IPreferenceStore store) { Hashtable hashtable= JavaCore.getDefaultOptions(); Hashtable currOptions= JavaCore.getOptions(); String[] allKeys= getAllKeys(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String defValue= (String) hashtable.get(key); if (defValue != null) { store.setDefault(key, defValue); } else { JavaPlugin.logErrorMessage("CodeFormatterPreferencePage: value is null: " + key); } // update the JavaCore options from the pref store String val= store.getString(key); if (val != null) { currOptions.put(key, val); } } JavaCore.setOptions(currOptions); } private static class ControlData { private String fKey; private String[] fValues; public ControlData(String key, String[] values) { fKey= key; fValues= values; } public String getKey() { return fKey; } public String getValue(boolean selection) { int index= selection ? 0 : 1; return fValues[index]; } public String getValue(int index) { return fValues[index]; } public int getSelection(String value) { for (int i= 0; i < fValues.length; i++) { if (value.equals(fValues[i])) { return i; } } throw new IllegalArgumentException(); } } private Hashtable fWorkingValues; private ArrayList fCheckBoxes; private ArrayList fTextBoxes; private SelectionListener fButtonSelectionListener; private ModifyListener fTextModifyListener; private String fPreviewText; private IDocument fPreviewDocument; private Text fTabSizeTextBox; public CodeFormatterPreferencePage() { setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); setDescription(JavaUIMessages.getString("CodeFormatterPreferencePage.description")); //$NON-NLS-1$ fWorkingValues= JavaCore.getOptions(); fCheckBoxes= new ArrayList(); fTextBoxes= new ArrayList(); fButtonSelectionListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { if (!e.widget.isDisposed()) { controlChanged((Button) e.widget); } } }; fTextModifyListener= new ModifyListener() { public void modifyText(ModifyEvent e) { if (!e.widget.isDisposed()) { textChanged((Text) e.widget); } } }; fPreviewDocument= new Document(); fPreviewText= loadPreviewFile("CodeFormatterPreviewCode.txt"); //$NON-NLS-1$ } /* * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { } /* * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { super.createControl(parent); WorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE)); } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; Composite composite= new Composite(parent, SWT.NONE); composite.setLayout(layout); TabFolder folder= new TabFolder(composite, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); String[] insertNotInsert= new String[] { INSERT, DO_NOT_INSERT }; layout= new GridLayout(); layout.numColumns= 2; Composite newlineComposite= new Composite(folder, SWT.NULL); newlineComposite.setLayout(layout); String label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_opening_braces.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_OPENING_BRACES, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_control_statement.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_CONTROL_STATEMENT, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_clear_lines"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_CLEAR_ALL, new String[] { CLEAR_ALL, PRESERVE_ONE } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_else_if.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert); label= JavaUIMessages.getString("CodeFormatterPreferencePage.newline_empty_block.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_EMPTY_BLOCK, insertNotInsert); layout= new GridLayout(); layout.numColumns= 2; Composite lineSplittingComposite= new Composite(folder, SWT.NULL); lineSplittingComposite.setLayout(layout); label= JavaUIMessages.getString("CodeFormatterPreferencePage.split_line.label"); //$NON-NLS-1$ addTextField(lineSplittingComposite, label, PREF_LINE_SPLIT); layout= new GridLayout(); layout.numColumns= 2; Composite styleComposite= new Composite(folder, SWT.NULL); styleComposite.setLayout(layout); label= JavaUIMessages.getString("CodeFormatterPreferencePage.style_compact_assignement.label"); //$NON-NLS-1$ addCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ASSIGNEMENT, new String[] { COMPACT, NORMAL } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.tab_char.label"); //$NON-NLS-1$ addCheckBox(styleComposite, label, PREF_TAB_CHAR, new String[] { TAB, SPACE } ); label= JavaUIMessages.getString("CodeFormatterPreferencePage.tab_size.label"); //$NON-NLS-1$ fTabSizeTextBox= addTextField(styleComposite, label, PREF_TAB_SIZE); fTabSizeTextBox.setEnabled(!usesTabs()); TabItem item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.newline.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL)); item.setControl(newlineComposite); item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.linesplit.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); item.setControl(lineSplittingComposite); item= new TabItem(folder, SWT.NONE); item.setText(JavaUIMessages.getString("CodeFormatterPreferencePage.tab.style.tabtitle")); //$NON-NLS-1$ item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_REF)); item.setControl(styleComposite); createPreview(parent); updatePreview(); return composite; } private Control createPreview(Composite parent) { SourceViewer previewViewer= new SourceViewer(parent, null, SWT.V_SCROLL); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); previewViewer.configure(new JavaSourceViewerConfiguration(tools, null)); previewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); previewViewer.setEditable(false); previewViewer.setDocument(fPreviewDocument); Control control= previewViewer.getControl(); control.setLayoutData(new GridData(GridData.FILL_BOTH)); return control; } private Button addCheckBox(Composite parent, String label, String key, String[] values) { ControlData data= new ControlData(key, values); GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan= 2; Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); checkBox.setData(data); checkBox.setLayoutData(gd); String currValue= (String)fWorkingValues.get(key); checkBox.setSelection(data.getSelection(currValue) == 0); checkBox.addSelectionListener(fButtonSelectionListener); fCheckBoxes.add(checkBox); return checkBox; } private Text addTextField(Composite parent, String label, String key) { Label labelControl= new Label(parent, SWT.NONE); labelControl.setText(label); labelControl.setLayoutData(new GridData()); Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE); textBox.setData(key); textBox.setLayoutData(new GridData()); String currValue= (String)fWorkingValues.get(key); textBox.setText(String.valueOf(getIntValue(currValue, 1))); textBox.setTextLimit(3); textBox.addModifyListener(fTextModifyListener); GridData gd= new GridData(); gd.widthHint= convertWidthInCharsToPixels(5); textBox.setLayoutData(gd); fTextBoxes.add(textBox); return textBox; } private void controlChanged(Button button) { ControlData data= (ControlData) button.getData(); boolean selection= button.getSelection(); String newValue= data.getValue(selection); fWorkingValues.put(data.getKey(), newValue); updatePreview(); if (PREF_TAB_CHAR.equals(data.getKey())) { fTabSizeTextBox.setEnabled(!selection); updateStatus(new StatusInfo()); if (selection) { fTabSizeTextBox.setText((String)fWorkingValues.get(PREF_TAB_SIZE)); } } } private void textChanged(Text textControl) { String key= (String) textControl.getData(); String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) { fWorkingValues.put(key, number); } updateStatus(status); updatePreview(); } /* * @see IPreferencePage#performOk() */ public boolean performOk() { String[] allKeys= getAllKeys(); // preserve other options // store in JCore and the preferences Hashtable actualOptions= JavaCore.getOptions(); IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < allKeys.length; i++) { String key= allKeys[i]; String val= (String) fWorkingValues.get(key); actualOptions.put(key, val); store.putValue(key, val); } JavaCore.setOptions(actualOptions); return super.performOk(); } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fWorkingValues= JavaCore.getDefaultOptions(); updateControls(); super.performDefaults(); } private String loadPreviewFile(String filename) { String separator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer btxt= new StringBuffer(512); BufferedReader rin= null; try { rin= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); String line; while ((line= rin.readLine()) != null) { btxt.append(line); btxt.append(separator); } } catch (IOException io) { JavaPlugin.log(io); } finally { if (rin != null) { try { rin.close(); } catch (IOException e) {} } } return btxt.toString(); } private void updatePreview() { fPreviewDocument.set(CodeFormatter.format(fPreviewText, 0, fWorkingValues)); } private void updateControls() { // update the UI for (int i= fCheckBoxes.size() - 1; i >= 0; i--) { Button curr= (Button) fCheckBoxes.get(i); ControlData data= (ControlData) curr.getData(); String currValue= (String) fWorkingValues.get(data.getKey()); curr.setSelection(data.getSelection(currValue) == 0); } for (int i= fTextBoxes.size() - 1; i >= 0; i--) { Text curr= (Text) fTextBoxes.get(i); String key= (String) curr.getData(); String currValue= (String) fWorkingValues.get(key); curr.setText(currValue); } fTabSizeTextBox.setEnabled(!usesTabs()); } private IStatus validatePositiveNumber(String number) { StatusInfo status= new StatusInfo(); if (number.length() == 0) { status.setError(JavaUIMessages.getString("CodeFormatterPreferencePage.empty_input")); } else { try { int value= Integer.parseInt(number); if (value < 0) { status.setError(JavaUIMessages.getFormattedString("CodeFormatterPreferencePage.invalid_input", number)); } } catch (NumberFormatException e) { status.setError(JavaUIMessages.getFormattedString("CodeFormatterPreferencePage.invalid_input", number)); } } return status; } private void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { // look if there are more severe errors for (int i= 0; i < fTextBoxes.size(); i++) { Text curr= (Text) fTextBoxes.get(i); if (!(curr == fTabSizeTextBox && usesTabs())) { IStatus currStatus= validatePositiveNumber(curr.getText()); status= StatusUtil.getMoreSevere(currStatus, status); } } } setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } private boolean usesTabs() { return TAB.equals(fWorkingValues.get(PREF_TAB_CHAR)); } }
    5,418
    Bug 5418 bracket marker stays in editor
    private void showDebugSourcePage(String typeName) { if (dialog.open() == dialog.OK) { } 1. set the cursor after the opening bracket (after dialog.OK) 2. press enter 3. The bracket box includes all characters insterted by the auto indenter
    resolved fixed
    d287924
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-11-01T19:13:57Z
    2001-11-01T15:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
    package org.eclipse.jdt.internal.ui.javaeditor; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IPositionUpdater; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextInputListener; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.TextPresentation; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.tasklist.TaskList; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory; import org.eclipse.jdt.internal.ui.compare.JavaReplaceWithEditionAction; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.BracketHighlighter.BracketPositionManager; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.BracketHighlighter.HighlightBrackets; import org.eclipse.jdt.internal.ui.text.JavaPairMatcher; /** * Java specific text editor. */ public class CompilationUnitEditor extends JavaEditor { /** * Responsible for highlighting matching pairs of brackets. */ class BracketHighlighter implements KeyListener, MouseListener { /** * Highlights the brackets. */ class HighlightBrackets implements PaintListener { private boolean fHooked= false; private JavaPairMatcher fMatcher= new JavaPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' }); private StyledText fTextWidget; private Color fColor; public HighlightBrackets() { fTextWidget= fSourceViewer.getTextWidget(); fColor= fTextWidget.getDisplay().getSystemColor(SWT.COLOR_MAGENTA); } public void dispose() { if (fMatcher != null) { fMatcher.dispose(); fMatcher= null; } fTextWidget= null; fColor= null; } public void run() { int offset= fSourceViewer.getSelectedRange().x; IRegion pair= fMatcher.match(fSourceViewer.getDocument(), offset); if (pair == null) { removeStyles(); } else { if (pair.getOffset() != fBracketPosition.getOffset() || pair.getLength() != fBracketPosition.getLength()) removeStyles(); fBracketPosition.offset= pair.getOffset(); fBracketPosition.length= pair.getLength(); fBracketPosition.isDeleted= false; applyStyles(); } } public void paintControl(PaintEvent event) { handleDrawRequest(event.gc); } private void handleDrawRequest(GC gc) { IRegion region= fSourceViewer.getVisibleRegion(); int offset= fBracketPosition.getOffset(); int length= fBracketPosition.getLength(); if (region.getOffset() <= offset && region.getOffset() + region.getLength() >= offset + length) { offset -= region.getOffset(); if (length == 2) { draw(gc, offset, length); } else { draw(gc, offset, 1); draw(gc, offset + length -1, 1); } } } private void draw(GC gc, int offset, int length) { if (gc != null) { Point left= fTextWidget.getLocationAtOffset(offset); Point right= fTextWidget.getLocationAtOffset(offset + length); gc.setForeground(fColor); gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1); } else { fTextWidget.redrawRange(offset, length, true); } } private void removeStyles() { fHooked= false; fTextWidget.removePaintListener(this); handleDrawRequest(null); } private void applyStyles() { if (!fHooked) { fHooked= true; fTextWidget.addPaintListener(this); } handleDrawRequest(null); } }; /** * Monitors the input document of the source viewer. */ class BracketPositionManager implements ITextInputListener { private IDocument fDocument; private IPositionUpdater fPositionUpdater; private String fCategory; public BracketPositionManager() { fCategory= getClass().getName() + hashCode(); fPositionUpdater= new DefaultPositionUpdater(fCategory); } public void install() { fSourceViewer.addTextInputListener(this); start(fSourceViewer.getDocument()); } public void dispose() { fSourceViewer.removeTextInputListener(this); if (fDocument != null) { stop(fDocument); fDocument= null; } } private void start(IDocument document) { fDocument= document; fDocument.addPositionCategory(fCategory); fDocument.addPositionUpdater(fPositionUpdater); try { fDocument.addPosition(fCategory, fBracketPosition); } catch (BadPositionCategoryException x) { // should not happen } catch (BadLocationException x) { // should not happen } } private void stop(IDocument document) { if (document == fDocument) { try { document.removePositionUpdater(fPositionUpdater); document.removePositionCategory(fCategory); } catch (BadPositionCategoryException x) { // should not happen } fDocument= null; } } /* * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument) */ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput != null) stop(oldInput); } /* * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument) */ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput != null) start(newInput); } }; private Position fBracketPosition= new Position(0, 0); private BracketPositionManager fManager= new BracketPositionManager(); private ISourceViewer fSourceViewer; private HighlightBrackets fHighlightBrackets; public BracketHighlighter(ISourceViewer sourceViewer) { fSourceViewer= sourceViewer; fHighlightBrackets= new HighlightBrackets(); } public void install() { fManager.install(); StyledText text= fSourceViewer.getTextWidget(); text.addKeyListener(this); text.addMouseListener(this); } public void dispose() { if (fManager != null) { fManager.dispose(); fManager= null; } if (fHighlightBrackets != null) { fHighlightBrackets.dispose(); fHighlightBrackets= null; } if (fSourceViewer != null && fBracketHighlighter != null) { StyledText text= fSourceViewer.getTextWidget(); if (text != null && !text.isDisposed()) { text.removeKeyListener(fBracketHighlighter); text.removeMouseListener(fBracketHighlighter); } fSourceViewer= null; } } /* * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { } /* * @see KeyListener#keyReleased(KeyEvent) */ public void keyReleased(KeyEvent e) { fHighlightBrackets.run(); } /* * @see MouseListener#mouseDoubleClick(MouseEvent) */ public void mouseDoubleClick(MouseEvent e) { } /* * @see MouseListener#mouseDown(MouseEvent) */ public void mouseDown(MouseEvent e) { } /* * @see MouseListener#mouseUp(MouseEvent) */ public void mouseUp(MouseEvent e) { fHighlightBrackets.run(); } }; /** The status line clearer */ protected ISelectionChangedListener fStatusLineClearer; /** The editor's save policy */ protected ISavePolicy fSavePolicy; /** Listener to annotation model changes that updates the error tick in the tab image */ private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater; /** The editor's bracket highlighter */ private BracketHighlighter fBracketHighlighter; /** * Creates a new compilation unit editor. */ public CompilationUnitEditor() { super(); setDocumentProvider(JavaPlugin.getDefault().getCompilationUnitDocumentProvider()); setEditorContextMenuId("#CompilationUnitEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#CompilationUnitRulerContext"); //$NON-NLS-1$ setOutlinerContextMenuId("#CompilationUnitOutlinerContext"); //$NON-NLS-1$ fSavePolicy= null; fJavaEditorErrorTickUpdater= new JavaEditorErrorTickUpdater(this); } /* * @see AbstractTextEditor#createActions */ protected void createActions() { super.createActions(); setAction("ContentAssistProposal", new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS)); //$NON-NLS-1$ //$NON-NLS-2$ setAction("AddImportOnSelection", new AddImportOnSelectionAction(this)); //$NON-NLS-1$ setAction("OrganizeImports", new OrganizeImportsAction(this)); //$NON-NLS-1$ setAction("Comment", new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX)); //$NON-NLS-1$ //$NON-NLS-2$ setAction("Uncomment", new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX)); //$NON-NLS-1$ //$NON-NLS-2$ setAction("Format", new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT)); //$NON-NLS-1$ //$NON-NLS-2$ setAction("AddBreakpoint", new AddBreakpointAction(this)); //$NON-NLS-1$ setAction("ManageBreakpoints", new BreakpointRulerAction(getVerticalRuler(), this)); //$NON-NLS-1$ setAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, getAction("ManageBreakpoints")); //$NON-NLS-1$ } /* * @see JavaEditor#getJavaSourceReferenceAt */ protected ISourceReference getJavaSourceReferenceAt(int position) { IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); if (unit != null) { synchronized (unit) { try { unit.reconcile(); IJavaElement element= unit.getElementAt(position); if (element instanceof ISourceReference) return (ISourceReference) element; } catch (JavaModelException x) { } } } return null; } /* * @see AbstractEditor#editorContextMenuAboutToChange */ public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddImportOnSelection"); //$NON-NLS-1$ addAction(menu, IContextMenuConstants.GROUP_GENERATE, "OrganizeImports"); //$NON-NLS-1$ addAction(menu, ITextEditorActionConstants.GROUP_ADD, "AddBreakpoint"); //$NON-NLS-1$ addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Comment"); //$NON-NLS-1$ addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Uncomment"); //$NON-NLS-1$ addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$ } /* * @see AbstractTextEditor#rulerContextMenuAboutToShow */ protected void rulerContextMenuAboutToShow(IMenuManager menu) { super.rulerContextMenuAboutToShow(menu); addAction(menu, "ManageBreakpoints"); //$NON-NLS-1$ } /* * @see JavaEditor#createOutlinePage */ protected JavaOutlinePage createOutlinePage() { JavaOutlinePage page= super.createOutlinePage(); page.setAction("OrganizeImports", new OrganizeImportsAction(this)); //$NON-NLS-1$ page.setAction("ReplaceWithEdition", new JavaReplaceWithEditionAction(page)); //$NON-NLS-1$ page.setAction("AddEdition", new JavaAddElementFromHistory(this, page)); //$NON-NLS-1$ DeleteISourceManipulationsAction deleteElement= new DeleteISourceManipulationsAction(page); page.setAction("DeleteElement", deleteElement); //$NON-NLS-1$ page.addSelectionChangedListener(deleteElement); return page; } /* * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput) */ protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) { if (page != null) { IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); page.setInput(manager.getWorkingCopy(input)); } } /* * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor) */ protected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p instanceof CompilationUnitDocumentProvider) { CompilationUnitDocumentProvider cp= (CompilationUnitDocumentProvider) p; cp.setSavePolicy(fSavePolicy); } try { super.performSaveOperation(operation, progressMonitor); } finally { if (p instanceof CompilationUnitDocumentProvider) { CompilationUnitDocumentProvider cp= (CompilationUnitDocumentProvider) p; cp.setSavePolicy(null); } } } /* * @see AbstractTextEditor#doSave(IProgressMonitor) */ public void doSave(IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p == null) return; if (p.isDeleted(getEditorInput())) { if (isSaveAsAllowed()) { /* * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. * Changed Behavior to make sure that if called inside a regular save (because * of deletion of input element) there is a way to report back to the caller. */ performSaveAs(progressMonitor); } else { /* * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there * Missing resources. */ Shell shell= getSite().getShell(); MessageDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title1"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$ } } else { getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$ IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); if (unit != null) { synchronized (unit) { performSaveOperation(createSaveOperation(false), progressMonitor); } } else performSaveOperation(createSaveOperation(false), progressMonitor); } } /** * Jumps to the error next according to the given direction. */ public void gotoError(boolean forward) { ISelectionProvider provider= getSelectionProvider(); if (fStatusLineClearer != null) { provider.removeSelectionChangedListener(fStatusLineClearer); fStatusLineClearer= null; } ITextSelection s= (ITextSelection) provider.getSelection(); IMarker nextError= getNextError(s.getOffset(), forward); if (nextError != null) { gotoMarker(nextError); IWorkbenchPage page= getSite().getPage(); IViewPart view= view= page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$ if (view instanceof TaskList) { StructuredSelection ss= new StructuredSelection(nextError); ((TaskList) view).setSelection(ss, true); } getStatusLineManager().setErrorMessage(nextError.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-1$ fStatusLineClearer= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { getSelectionProvider().removeSelectionChangedListener(fStatusLineClearer); fStatusLineClearer= null; getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$ } }; provider.addSelectionChangedListener(fStatusLineClearer); } else { getStatusLineManager().setErrorMessage(""); //$NON-NLS-1$ } } private IMarker getNextError(int offset, boolean forward) { IMarker nextError= null; IDocument document= getDocumentProvider().getDocument(getEditorInput()); int endOfDocument= document.getLength(); int distance= 0; IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); Iterator e= model.getAnnotationIterator(); while (e.hasNext()) { Annotation a= (Annotation) e.next(); if (a instanceof MarkerAnnotation) { MarkerAnnotation ma= (MarkerAnnotation) a; IMarker marker= ma.getMarker(); if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) { Position p= model.getPosition(a); if (!p.includes(offset)) { int currentDistance= 0; if (forward) { currentDistance= p.getOffset() - offset; if (currentDistance < 0) currentDistance= endOfDocument - offset + p.getOffset(); } else { currentDistance= offset - p.getOffset(); if (currentDistance < 0) currentDistance= offset + endOfDocument - p.getOffset(); } if (nextError == null || currentDistance < distance) { distance= currentDistance; nextError= marker; } } } } } return nextError; } /* * @see AbstractTextEditor#isSaveAsAllowed() */ public boolean isSaveAsAllowed() { return true; } /* * 1GF7WG9: ITPJUI:ALL - EXCEPTION: "Save As..." always fails */ protected IPackageFragment getPackage(IWorkspaceRoot root, IPath path) { if (path.segmentCount() == 1) { IProject project= root.getProject(path.toString()); if (project != null) { IJavaProject jProject= JavaCore.create(project); if (jProject != null) { try { IJavaElement element= jProject.findElement(new Path("")); //$NON-NLS-1$ if (element instanceof IPackageFragment) { IPackageFragment fragment= (IPackageFragment) element; IJavaElement parent= fragment.getParent(); if (parent instanceof IPackageFragmentRoot) { IPackageFragmentRoot pRoot= (IPackageFragmentRoot) parent; if ( !pRoot.isArchive() && !pRoot.isExternal() && path.equals(pRoot.getPath())) return fragment; } } } catch (JavaModelException x) { // ignore } } } return null; } else if (path.segmentCount() > 1) { IFolder folder= root.getFolder(path); IJavaElement element= JavaCore.create(folder); if (element instanceof IPackageFragment) return (IPackageFragment) element; } return null; } /* * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. * Changed behavior to make sure that if called inside a regular save (because * of deletion of input element) there is a way to report back to the caller. */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell= getSite().getShell(); SaveAsDialog dialog= new SaveAsDialog(shell); if (dialog.open() == Dialog.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath= dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } filePath= filePath.removeTrailingSeparator(); final String fileName= filePath.lastSegment(); IPath folderPath= filePath.removeLastSegments(1); if (folderPath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); /* * 1GF7WG9: ITPJUI:ALL - EXCEPTION: "Save As..." always fails */ final IPackageFragment fragment= getPackage(root, folderPath); IFile file= root.getFile(filePath); final FileEditorInput newInput= new FileEditorInput(file); WorkspaceModifyOperation op= new WorkspaceModifyOperation() { public void execute(final IProgressMonitor monitor) throws CoreException { if (fragment != null) { try { // copy to another package IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager(); ICompilationUnit unit= manager.getWorkingCopy(getEditorInput()); /* * 1GJXY0L: ITPJUI:WINNT - NPE during save As in Java editor * Introduced null check, just go on in the null case */ if (unit != null) { /* * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there * Changed false to true. */ unit.copy(fragment, null, fileName, true, monitor); return; } } catch (JavaModelException x) { } } // if (fragment == null) then copy to a directory which is not a package // if (unit == null) copy the file that is not a compilation unit /* * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there * Changed false to true. */ getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); } }; boolean success= false; try { if (fragment == null) getDocumentProvider().aboutToChange(newInput); new ProgressMonitorDialog(shell).run(false, true, op); setInput(newInput); success= true; } catch (InterruptedException x) { } catch (InvocationTargetException x) { /* * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there * Missing resources. */ Throwable t= x.getTargetException(); if (t instanceof CoreException) { CoreException cx= (CoreException) t; ErrorDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), cx.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ } else { MessageDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title3"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message3") + t.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } } finally { if (fragment == null) getDocumentProvider().changed(newInput); if (progressMonitor != null) progressMonitor.setCanceled(!success); } } /* * @see AbstractTextEditor#doSetInput(IEditorInput) */ protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); fJavaEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input)); } /* * @see AbstractTextEditor#dispose() */ public void dispose() { if (fJavaEditorErrorTickUpdater != null) { fJavaEditorErrorTickUpdater.setAnnotationModel(null); fJavaEditorErrorTickUpdater= null; } if (fBracketHighlighter != null) { fBracketHighlighter.dispose(); fBracketHighlighter= null; } super.dispose(); } /* * @see AbstractTextEditor#createPartControl(Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); // create and install bracket highlighter ISourceViewer sourceViewer= getSourceViewer(); fBracketHighlighter= new BracketHighlighter(sourceViewer); fBracketHighlighter.install(); } }
    5,418
    Bug 5418 bracket marker stays in editor
    private void showDebugSourcePage(String typeName) { if (dialog.open() == dialog.OK) { } 1. set the cursor after the opening bracket (after dialog.OK) 2. press enter 3. The bracket box includes all characters insterted by the auto indenter
    resolved fixed
    d287924
    JDT
    https://github.com/eclipse-jdt/eclipse.jdt.ui
    eclipse-jdt/eclipse.jdt.ui
    java
    null
    null
    null
    2001-11-01T19:13:57Z
    2001-11-01T15:53:20Z
    org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java
    package org.eclipse.jdt.internal.ui.text.java; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.ArrayList; import java.util.List; import org.eclipse.jface.text.TextAttribute; import org.eclipse.jface.text.rules.EndOfLineRule; import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.rules.SingleLineRule; import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WordRule; import org.eclipse.swt.SWT; import org.eclipse.jdt.ui.text.IColorManager; import org.eclipse.jdt.ui.text.IJavaColorConstants; import org.eclipse.jdt.internal.ui.text.JavaWhitespaceDetector; import org.eclipse.jdt.internal.ui.text.JavaWordDetector; /** * A Java code scanner. */ public class JavaCodeScanner extends RuleBasedScanner { private static String[] fgKeywords= { "abstract", //$NON-NLS-1$ "break", //$NON-NLS-1$ "case", "catch", "class", "const", "continue", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "default", "do", //$NON-NLS-2$ //$NON-NLS-1$ "else", "extends", //$NON-NLS-2$ //$NON-NLS-1$ "final", "finally", "for", //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "goto", //$NON-NLS-1$ "if", "implements", "import", "instanceof", "interface", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "native", "new", //$NON-NLS-2$ //$NON-NLS-1$ "package", "private", "protected", "public", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "return", //$NON-NLS-1$ "static", "super", "switch", "synchronized", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "this", "throw", "throws", "transient", "try", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ "volatile", //$NON-NLS-1$ "while" //$NON-NLS-1$ }; private static String[] fgTypes= { "void", "boolean", "char", "byte", "short", "strictfp", "int", "long", "float", "double" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$ private static String[] fgConstants= { "false", "null", "true" }; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ private Token fKeyword; private Token fType; private Token fString; private Token fComment; private IColorManager fColorManager; /** * Creates a Java code scanner */ public JavaCodeScanner(IColorManager manager) { super(); setDefaultReturnToken(new Token(new TextAttribute(manager.getColor(IJavaColorConstants.JAVA_DEFAULT)))); fColorManager= manager; fKeyword= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_KEYWORD), null, SWT.BOLD)); fType= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_TYPE), null, SWT.BOLD)); fString= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_STRING))); fComment= new Token(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT))); initializeRules(); } private void initializeRules() { List rules= new ArrayList(); // Add rule for single line comments. rules.add(new EndOfLineRule("//", fComment)); //$NON-NLS-1$ // Add rule for strings and character constants. rules.add(new SingleLineRule("\"", "\"", fString, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ rules.add(new SingleLineRule("'", "'", fString, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ // Add generic whitespace rule. rules.add(new WhitespaceRule(new JavaWhitespaceDetector())); // Add word rule for keywords, types, and constants. WordRule wordRule= new WordRule(new JavaWordDetector(), getDefaultReturnToken()); for (int i=0; i<fgKeywords.length; i++) wordRule.addWord(fgKeywords[i], fKeyword); for (int i=0; i<fgTypes.length; i++) wordRule.addWord(fgTypes[i], fType); for (int i=0; i<fgConstants.length; i++) wordRule.addWord(fgConstants[i], fType); rules.add(wordRule); IRule[] result= new IRule[rules.size()]; rules.toArray(result); setRules(result); } public void colorManagerChanged() { IToken token= getDefaultReturnToken(); if (token instanceof Token) ((Token) token).setData(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_DEFAULT))); fKeyword.setData(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_KEYWORD))); fType.setData(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_TYPE))); fString.setData(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_STRING))); fComment.setData(new TextAttribute(fColorManager.getColor(IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT))); } }