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
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/IJavaPartitions.java
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaPartitionScanner.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text; import java.util.ArrayList; import java.util.List; import org.eclipse.jface.text.rules.EndOfLineRule; import org.eclipse.jface.text.rules.ICharacterScanner; import org.eclipse.jface.text.rules.IPredicateRule; import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.IWordDetector; import org.eclipse.jface.text.rules.MultiLineRule; import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; import org.eclipse.jface.text.rules.SingleLineRule; import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WordRule; /** * This scanner recognizes the JavaDoc comments and Java multi line comments. */ public class JavaPartitionScanner extends RuleBasedPartitionScanner { private final static String SKIP= "__skip"; //$NON-NLS-1$ public final static String JAVA_STRING= "__java_string"; //$NON-NLS-1$ public final static String JAVA_SINGLE_LINE_COMMENT= "__java_singleline_comment"; //$NON-NLS-1$ public final static String JAVA_MULTI_LINE_COMMENT= "__java_multiline_comment"; //$NON-NLS-1$ public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$ /** * Detector for empty comments. */ static class EmptyCommentDetector implements IWordDetector { /* * @see IWordDetector#isWordStart */ public boolean isWordStart(char c) { return (c == '/'); } /* * @see IWordDetector#isWordPart */ public boolean isWordPart(char c) { return (c == '*' || c == '/'); } }; /** * Word rule for empty comments. */ static class EmptyCommentRule extends WordRule implements IPredicateRule { private IToken fSuccessToken; /** * Constructor for EmptyCommentRule. * @param defaultToken */ public EmptyCommentRule(IToken successToken) { super(new EmptyCommentDetector()); fSuccessToken= successToken; addWord("/**/", fSuccessToken); //$NON-NLS-1$ } /* * @see IPredicateRule#evaluate(ICharacterScanner, boolean) */ public IToken evaluate(ICharacterScanner scanner, boolean resume) { return evaluate(scanner); } /* * @see IPredicateRule#getSuccessToken() */ public IToken getSuccessToken() { return fSuccessToken; } }; /** * Creates the partitioner and sets up the appropriate rules. */ public JavaPartitionScanner() { super(); IToken skip= new Token(SKIP); IToken string= new Token(JAVA_STRING); IToken javaDoc= new Token(JAVA_DOC); IToken multiLineComment= new Token(JAVA_MULTI_LINE_COMMENT); IToken singleLineComment= new Token(JAVA_SINGLE_LINE_COMMENT); List rules= new ArrayList(); // Add rule for single line comments. rules.add(new EndOfLineRule("//", singleLineComment)); //$NON-NLS-1$ // Add rule for strings. rules.add(new SingleLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ // Add rule for character constants. rules.add(new SingleLineRule("'", "'", skip, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ // Add special case word rule. EmptyCommentRule wordRule= new EmptyCommentRule(multiLineComment); rules.add(wordRule); // Add rules for multi-line comments and javadoc. rules.add(new MultiLineRule("/**", "*/", javaDoc)); //$NON-NLS-1$ //$NON-NLS-2$ rules.add(new MultiLineRule("/*", "*/", multiLineComment)); //$NON-NLS-1$ //$NON-NLS-2$ IPredicateRule[] result= new IPredicateRule[rules.size()]; rules.toArray(result); setPredicateRules(result); } }
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavaCorrectionAssistant.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import java.util.Iterator; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.util.Assert; import org.eclipse.ui.IEditorPart; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.IColorManager; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation; import org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationIterator; import org.eclipse.jdt.internal.ui.text.HTMLTextPresenter; import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; public class JavaCorrectionAssistant extends ContentAssistant { private ITextViewer fViewer; private IEditorPart fEditor; private Position fPosition; /** * Constructor for CorrectionAssistant. */ public JavaCorrectionAssistant(IEditorPart editor) { super(); Assert.isNotNull(editor); fEditor= editor; JavaCorrectionProcessor processor= new JavaCorrectionProcessor(editor); setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_STRING); setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_DOC); setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT); setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT); enableAutoActivation(false); enableAutoInsert(false); setContextInformationPopupOrientation(CONTEXT_INFO_ABOVE); setInformationControlCreator(getInformationControlCreator()); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); IColorManager manager= textTools.getColorManager(); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); Color c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager); setProposalSelectorForeground(c); c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager); setProposalSelectorBackground(c); } private IInformationControlCreator getInformationControlCreator() { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, new HTMLTextPresenter()); } }; } private static Color getColor(IPreferenceStore store, String key, IColorManager manager) { RGB rgb= PreferenceConverter.getColor(store, key); return manager.getColor(rgb); } public void install(ITextViewer textViewer) { super.install(textViewer); fViewer= textViewer; } /** * Show completions at caret position. If current * position does not contain quick fixes look for * next quick fix on same line by moving from left * to right and restarting at end of line if the * beginning of the line is reached. * * @see org.eclipse.jface.text.contentassist.IContentAssistant#showPossibleCompletions() */ public String showPossibleCompletions() { if (fViewer == null) // Let superclass deal with this return super.showPossibleCompletions(); Point selectedRange= fViewer.getSelectedRange(); int initalOffset= selectedRange.x; int invocationOffset; int invocationLength; if (areMultipleLinesSelected()) { try { IDocument document= fViewer.getDocument(); IRegion start= document.getLineInformationOfOffset(initalOffset); invocationOffset= start.getOffset(); IRegion end= document.getLineInformationOfOffset(initalOffset + selectedRange.y); if (end.getOffset() == initalOffset + selectedRange.y) { int line= document.getLineOfOffset(end.getOffset()); end= fViewer.getDocument().getLineInformation(line - 1); } invocationLength= end.getOffset() + end.getLength() - invocationOffset; } catch (BadLocationException ex) { invocationOffset= initalOffset; invocationLength= 0; } } else { invocationOffset= computeOffsetWithCorrection(initalOffset); invocationLength= 0; } if (invocationOffset != -1) { storePosition(); fViewer.setSelectedRange(invocationOffset, invocationLength); fViewer.revealRange(invocationOffset, invocationLength); } else { fPosition= null; } String errorMsg= super.showPossibleCompletions(); return errorMsg; } /** * Find offset which contains corrections. * Search on same line by moving from left * to right and restarting at end of line if the * beginning of the line is reached. * * @return an offset where corrections are available or -1 if none */ private int computeOffsetWithCorrection(int initalOffset) { if (fViewer == null || fViewer.getDocument() == null) return -1; IRegion lineInfo= null; try { lineInfo= fViewer.getDocument().getLineInformationOfOffset(initalOffset); } catch (BadLocationException ex) { return -1; } int startOffset= lineInfo.getOffset(); int endOffset= startOffset + lineInfo.getLength(); int result= computeOffsetWithCorrection(startOffset, endOffset, initalOffset); if (result > 0) return result; else return -1; } /** * @return the best matching offset with corrections or -1 if nothing is found */ private int computeOffsetWithCorrection(int startOffset, int endOffset, int initialOffset) { IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput()); int invocationOffset= -1; int offsetOfFirstProblem= Integer.MAX_VALUE; Iterator iter= new JavaAnnotationIterator(model, true); while (iter.hasNext()) { IJavaAnnotation annot= (IJavaAnnotation)iter.next(); Position pos= model.getPosition((Annotation)annot); if (isIncluded(pos, startOffset, endOffset)) { if (JavaCorrectionProcessor.hasCorrections(annot)) { offsetOfFirstProblem= Math.min(offsetOfFirstProblem, pos.getOffset()); invocationOffset= computeBestOffset(invocationOffset, pos, initialOffset); if (initialOffset == invocationOffset) return initialOffset; } } } if (initialOffset < offsetOfFirstProblem && offsetOfFirstProblem != Integer.MAX_VALUE) return offsetOfFirstProblem; else return invocationOffset; } private boolean isIncluded(Position pos, int lineStart, int lineEnd) { return (pos != null) && (pos.getOffset() >= lineStart && (pos.getOffset() + pos.getLength() <= lineEnd)); } /** * Computes and returns the invocation offset given a new * position, the initial offset and the best invocation offset * found so far. * <p> * The closest offset to the left of the initial offset is the * best. If there is no offset on the left, the closest on the * right is the best.</p> */ private int computeBestOffset(int invocationOffset, Position pos, int initalOffset) { int newOffset= pos.offset; if (newOffset <= initalOffset && initalOffset <= newOffset + pos.length) return initalOffset; if (invocationOffset < 0) return newOffset; if (newOffset <= initalOffset && invocationOffset >= initalOffset) return newOffset; if (newOffset <= initalOffset && invocationOffset < initalOffset) return Math.max(invocationOffset, newOffset); if (invocationOffset <= initalOffset) return invocationOffset; return Math.max(invocationOffset, newOffset); } /* * @see org.eclipse.jface.text.contentassist.ContentAssistant#possibleCompletionsClosed() */ protected void possibleCompletionsClosed() { super.possibleCompletionsClosed(); restorePosition(); } /** * Returns <code>true</code> if one line is completely selected or if multiple lines are selected. * Being completely selected means that all characters except the new line characters are * selected. * * @return <code>true</code> if one or multiple lines are selected * @since 2.1 */ private boolean areMultipleLinesSelected() { Point s= fViewer.getSelectedRange(); if (s.y == 0) return false; try { IDocument document= fViewer.getDocument(); int startLine= document.getLineOfOffset(s.x); int endLine= document.getLineOfOffset(s.x + s.y); IRegion line= document.getLineInformation(startLine); return startLine != endLine || (s.x == line.getOffset() && s.y == line.getLength()); } catch (BadLocationException x) { return false; } } private void storePosition() { int initalOffset= fViewer.getSelectedRange().x; int length= fViewer.getSelectedRange().y; fPosition= new Position(initalOffset, length); } private void restorePosition() { if (fPosition != null && !fPosition.isDeleted() && fViewer.getDocument() != null) { fViewer.setSelectedRange(fPosition.offset, fPosition.length); fViewer.revealRange(fPosition.offset, fPosition.length); } fPosition= null; } }
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Nikolay Metchev - Fixed bug 29909 *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import java.util.Iterator; import java.util.NoSuchElementException; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultAutoIndentStrategy; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.corext.Assert; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; /** * Auto indent strategy sensitive to brackets. */ public class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy { private final static String COMMENT= "//"; //$NON-NLS-1$ private int fTabWidth= -1; private boolean fUseSpaces; public JavaAutoIndentStrategy() { fUseSpaces= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SPACES_FOR_TABS); } // 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 e) { JavaPlugin.log(e); } } 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(createIndent(1, useSpaces())); } } c.text= buf.toString(); } catch (BadLocationException e) { JavaPlugin.log(e); } } private static String getLineDelimiter(IDocument document) { try { if (document.getNumberOfLines() > 1) return document.getLineDelimiter(0); } catch (BadLocationException e) { JavaPlugin.log(e); } return System.getProperty("line.separator"); //$NON-NLS-1$ } private static boolean startsWithClosingBrace(String string) { final int length= string.length(); int i= 0; while (i != length && Character.isWhitespace(string.charAt(i))) ++i; if (i == length) return false; return string.charAt(i) == '}'; } protected void smartPaste(IDocument document, DocumentCommand command) { String lineDelimiter= getLineDelimiter(document); try { String pastedText= command.text; Assert.isNotNull(pastedText); Assert.isTrue(pastedText.length() > 1); // extend selection begin if only whitespaces int selectionStart= command.offset; IRegion region= document.getLineInformationOfOffset(selectionStart); String notSelected= document.get(region.getOffset(), selectionStart - region.getOffset()); String selected= document.get(selectionStart, region.getOffset() + region.getLength() - selectionStart); if (notSelected.trim().length() == 0 && selected.trim().length() != 0) { pastedText= notSelected + pastedText; command.length += notSelected.length(); command.offset= region.getOffset(); } // choose smaller indent of block and preceeding non-empty line String blockIndent= getBlockIndent(document, command); String insideBlockIndent= blockIndent == null ? "" : blockIndent + createIndent(1, useSpaces()); //$NON-NLS-1$ // add one indent level int insideBlockIndentSize= calculateDisplayedWidth(insideBlockIndent, getTabWidth()); int previousIndentSize= getIndentSize(document, command); int newIndentSize= insideBlockIndentSize < previousIndentSize ? insideBlockIndentSize : previousIndentSize; // indent is different if block starts with '}' if (startsWithClosingBrace(pastedText)) { int outsideBlockIndentSize= blockIndent == null ? 0 : calculateDisplayedWidth(blockIndent, getTabWidth()); newIndentSize = outsideBlockIndentSize; } // check selection int offset= command.offset; int line= document.getLineOfOffset(offset); int lineOffset= document.getLineOffset(line); String prefix= document.get(lineOffset, offset - lineOffset); boolean formatFirstLine= prefix.trim().length() == 0; String formattedParagraph= format(pastedText, newIndentSize, lineDelimiter, formatFirstLine); // paste if (formatFirstLine) { int end= command.offset + command.length; command.offset= lineOffset; command.length= end - command.offset; } command.text= formattedParagraph; } catch (BadLocationException e) { JavaPlugin.log(e); } } private static String getIndentOfLine(String line) { int i= 0; for (; i < line.length(); i++) { if (! Character.isWhitespace(line.charAt(i))) break; } return line.substring(0, i); } /** * Returns the indent of the first non empty line. * A line is considered empty if it only consists of whitespaces or if it * begins with a single line comment followed by whitespaces only. */ private static int getIndentSizeOfFirstLine(String paragraph, boolean includeFirstLine, int tabWidth) { for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { final String line= (String) iterator.next(); if (!includeFirstLine) { includeFirstLine= true; continue; } String indent= null; if (line.startsWith(COMMENT)) { String commentedLine= line.substring(2); // line is empty if (commentedLine.trim().length() == 0) continue; indent= COMMENT + getIndentOfLine(commentedLine); } else { // line is empty if (line.trim().length() == 0) continue; indent= getIndentOfLine(line); } return calculateDisplayedWidth(indent, tabWidth); } return 0; } /** * Returns the minimal indent size of all non empty lines; */ private static int getMinimalIndentSize(String paragraph, boolean includeFirstLine, int tabWidth) { int minIndentSize= Integer.MAX_VALUE; for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { final String line= (String) iterator.next(); if (!includeFirstLine) { includeFirstLine= true; continue; } String indent= null; if (line.startsWith(COMMENT)) { String commentedLine= line.substring(2); // line is empty if (commentedLine.trim().length() == 0) continue; indent= COMMENT + getIndentOfLine(commentedLine); } else { // line is empty if (line.trim().length() == 0) continue; indent=getIndentOfLine(line); } final int indentSize= calculateDisplayedWidth(indent, tabWidth); if (indentSize < minIndentSize) minIndentSize= indentSize; } return minIndentSize == Integer.MAX_VALUE ? 0 : minIndentSize; } /** * Returns the displayed width of a string, taking in account the displayed tab width. * The result can be compared against the print margin. */ private static int calculateDisplayedWidth(String string, int tabWidth) { int column= 0; for (int i= 0; i < string.length(); i++) if ('\t' == string.charAt(i)) column += tabWidth - (column % tabWidth); else column++; return column; } private static boolean isLineEmpty(IDocument document, int line) throws BadLocationException { IRegion region= document.getLineInformation(line); String string= document.get(region.getOffset(), region.getLength()); return string.trim().length() == 0; } private int getIndentSize(IDocument document, DocumentCommand command) { StringBuffer buffer= new StringBuffer(); int docLength= document.getLength(); if (command.offset == -1 || docLength == 0) return 0; try { int p= (command.offset == docLength ? command.offset - 1 : command.offset); int line= document.getLineOfOffset(p); IRegion region= document.getLineInformation(line); String string= document.get(region.getOffset(), command.offset - region.getOffset()); if (line != 0 && string.trim().length() == 0) --line; while (line != 0 && isLineEmpty(document, line)) --line; int start= document.getLineOffset(line); // if line is at end of a javadoc comment, take the indent from the comment's begin line IDocumentPartitioner partitioner= document.getDocumentPartitioner(); if (partitioner != null) { ITypedRegion typedRegion= partitioner.getPartition(start); if (JavaPartitionScanner.JAVA_DOC.equals(typedRegion.getType())) start= document.getLineInformationOfOffset(typedRegion.getOffset()).getOffset(); else if (JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT.equals(typedRegion.getType())) { buffer.append(COMMENT); start += 2; } } int whiteend= findEndOfWhiteSpace(document, start, command.offset); buffer.append(document.get(start, whiteend - start)); if (getBracketCount(document, start, command.offset, true) > 0) { buffer.append(createIndent(1, useSpaces())); } } catch (BadLocationException e) { JavaPlugin.log(e); } return calculateDisplayedWidth(buffer.toString(), getTabWidth()); } private String getBlockIndent(IDocument d, DocumentCommand c) { if (c.offset < 0 || d.getLength() == 0) return null; try { int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset); int line= d.getLineOfOffset(p); // evaluate the line with the opening bracket that matches out closing bracket int indLine= findMatchingOpenBracket(d, line, c.offset, 1); if (indLine != -1) // take the indent of the found line return getIndentOfLine(d, indLine); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; } private static final class LineIterator implements Iterator { /** The document to iterator over. */ private final IDocument fDocument; /** The line index. */ private int fLineIndex; /** * Creates a line iterator. */ public LineIterator(String string) { fDocument= new Document(string); } /* * @see java.util.Iterator#hasNext() */ public boolean hasNext() { return fLineIndex != fDocument.getNumberOfLines(); } /* * @see java.util.Iterator#next() */ public Object next() { try { IRegion region= fDocument.getLineInformation(fLineIndex++); return fDocument.get(region.getOffset(), region.getLength()); } catch (BadLocationException e) { JavaPlugin.log(e); throw new NoSuchElementException(); } } /* * @see java.util.Iterator#remove() */ public void remove() { throw new UnsupportedOperationException(); } } private String createIndent(int level, boolean useSpaces) { StringBuffer buffer= new StringBuffer(); if (useSpaces) { // Fix for bug 29909 contributed by Nikolay Metchev int width= level * getTabWidth(); for (int i= 0; i != width; ++i) buffer.append(' '); } else { for (int i= 0; i != level; ++i) buffer.append('\t'); } return buffer.toString(); } /** * Extends the string to match displayed width. * String is either the empty string or "//" and should not contain whites. */ private static String changePrefix(String string, int displayedWidth, boolean useSpaces, int tabWidth) { // assumption: string contains no whitspaces final StringBuffer buffer= new StringBuffer(string); int column= calculateDisplayedWidth(buffer.toString(), tabWidth); if (column > displayedWidth) return string; if (useSpaces) { while (column != displayedWidth) { buffer.append(' '); ++column; } } else { while (column != displayedWidth) { if (column + tabWidth - (column % tabWidth) <= displayedWidth) { buffer.append('\t'); column += tabWidth - (column % tabWidth); } else { buffer.append(' '); ++column; } } } return buffer.toString(); } /** * Formats a paragraph such that the first non-empty line of the paragraph * will have an indent of size newIndentSize. */ private String format(String paragraph, int newIndentSize, String lineDelimiter, boolean indentFirstLine) { final int tabWidth= getTabWidth(); final int firstLineIndentSize= getIndentSizeOfFirstLine(paragraph, indentFirstLine, tabWidth); final int minIndentSize= getMinimalIndentSize(paragraph, indentFirstLine, tabWidth); if (newIndentSize < firstLineIndentSize - minIndentSize) newIndentSize= firstLineIndentSize - minIndentSize; final StringBuffer buffer= new StringBuffer(); for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) { String line= (String) iterator.next(); if (indentFirstLine) { String lineIndent= null; if (line.startsWith(COMMENT)) lineIndent= COMMENT + getIndentOfLine(line.substring(2)); else lineIndent= getIndentOfLine(line); String lineContent= line.substring(lineIndent.length()); if (lineContent.length() == 0) { // line was empty; insert as is buffer.append(line); } else { int indentSize= calculateDisplayedWidth(lineIndent, tabWidth); int deltaSize= newIndentSize - firstLineIndentSize; lineIndent= changePrefix(lineIndent.trim(), indentSize + deltaSize, useSpaces(), tabWidth); buffer.append(lineIndent); buffer.append(lineContent); } } else { indentFirstLine= true; buffer.append(line); } if (iterator.hasNext()) buffer.append(lineDelimiter); } return buffer.toString(); } private boolean equalsDelimiter(IDocument d, String txt) { String[] delimiters= d.getLegalLineDelimiters(); for (int i= 0; i < delimiters.length; i++) { if (txt.equals(delimiters[i])) return true; } return false; } private void smartIndentAfterBlockDelimiter(IDocument document, DocumentCommand command) { if (command.text.charAt(0) == '}') smartInsertAfterBracket(document, command); } /* * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand) */ public void customizeDocumentCommand(IDocument d, DocumentCommand c) { if (c.length == 0 && c.text != null && equalsDelimiter(d, c.text)) smartIndentAfterNewLine(d, c); else if (c.text.length() == 1) smartIndentAfterBlockDelimiter(d, c); else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)) smartPaste(d, c); clearCachedValues(); } private static IPreferenceStore getPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } private boolean useSpaces() { return fUseSpaces; } private int getTabWidth() { if (fTabWidth == -1) // Fix for bug 29909 contributed by Nikolay Metchev fTabWidth= Integer.parseInt(((String)JavaCore.getOptions().get(JavaCore.FORMATTER_TAB_SIZE))); return fTabWidth; } private void clearCachedValues() { fTabWidth= -1; fUseSpaces= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SPACES_FOR_TABS); } }
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/SmartBracesAutoEditStrategy.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import java.io.IOException; import java.util.Iterator; import java.util.List; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IAutoEditStrategy; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextInputListener; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.compiler.IScanner; import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.DoStatement; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.ForStatement; import org.eclipse.jdt.core.dom.IfStatement; import org.eclipse.jdt.core.dom.Statement; import org.eclipse.jdt.core.dom.WhileStatement; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.corext.dom.NodeFinder; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.JavaCodeReader; /** * An auto edit strategy which inserts the closing brace automatically if possible. */ public final class SmartBracesAutoEditStrategy implements IAutoEditStrategy { private static class CompilationUnitInfo { public char[] buffer; public int delta; public CompilationUnitInfo(char[] buffer, int delta) { this.buffer= buffer; this.delta= delta; } }; /** The text viewer. */ private final ITextViewer fTextViewer; /** The text input listener. */ private ITextInputListener fTextInputListener; /** The document listener. */ private final IDocumentListener fDocumentListener= new IDocumentListener() { /* * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentAboutToBeChanged(DocumentEvent event) { fSourceRegion= null; fUndoEvent= null; } /* * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentChanged(DocumentEvent event) { } }; /** The last changed caused by user. */ private IRegion fSourceRegion; /** The undo command to undo the last change caused by auto edit strategy. */ private DocumentEvent fUndoEvent; /** * Creates a <code>SmartBracesAutoEditStrategy</code> */ public SmartBracesAutoEditStrategy(ITextViewer textViewer) { if (textViewer == null) throw new IllegalArgumentException(); fTextViewer= textViewer; } private void install(IRegion userRegion, DocumentEvent undoEvent) { if (userRegion == null || undoEvent == null) throw new IllegalArgumentException(); fSourceRegion= userRegion; fUndoEvent= undoEvent; if (fTextInputListener != null) return; IDocument document= fTextViewer.getDocument(); document.addDocumentListener(fDocumentListener); fTextInputListener= new ITextInputListener() { /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput != null) oldInput.removeDocumentListener(fDocumentListener); } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput != null) newInput.addDocumentListener(fDocumentListener); } }; fTextViewer.addTextInputListener(fTextInputListener); } private boolean isBackspace(DocumentCommand command) { return (command.text == null || command.text.length() == 0) && fSourceRegion.getOffset() == command.offset && fSourceRegion.getLength() == command.length; } private boolean isDelete(DocumentCommand command) { return (command.text == null || command.text.length() == 0) && fSourceRegion.getOffset() + fSourceRegion.getLength() == command.offset && command.length > 0; } private boolean isClosingBracket(DocumentCommand command) { return command.offset == fSourceRegion.getOffset() + fSourceRegion.getLength() && command.length <= 1 && "}".equals(command.text); //$NON-NLS-1$ } /* * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand) */ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { try { if (!command.doit) return; if (fSourceRegion != null) { if (isBackspace(command) || isClosingBracket(command)) { // restore command.addCommand(fUndoEvent.getOffset(), fUndoEvent.getLength(), fUndoEvent.getText(), fDocumentListener); command.owner= fDocumentListener; command.doit= false; fSourceRegion= null; fUndoEvent= null; } else if (isDelete(command)) { // delete magically inserted text command.caretOffset= command.offset; command.offset= fUndoEvent.getOffset(); command.length= fUndoEvent.getLength(); command.text= fUndoEvent.getText(); command.owner= fDocumentListener; command.doit= false; fSourceRegion= null; fUndoEvent= null; } } else if (command.text != null && command.text.equals("{")) //$NON-NLS-1$ smartBraces(document, command); } catch (BadLocationException e) { JavaPlugin.log(e); } } private static String getLineDelimiter(IDocument document) { try { if (document.getNumberOfLines() > 1) return document.getLineDelimiter(0); } catch (BadLocationException e) { JavaPlugin.log(e); } return System.getProperty("line.separator"); //$NON-NLS-1$ } private static String getLineIndentation(IDocument document, int line, int maxOffset) throws BadLocationException { int lineOffset= document.getLineOffset(line); String string= document.get(lineOffset, maxOffset - lineOffset); final int length= string.length(); int i= 0; while (i != length && Character.isWhitespace(string.charAt(i))) ++i; return string.substring(0, i); } private static IRegion getToken(IDocument document, IRegion scanRegion, int tokenId) throws BadLocationException { final String source= document.get(scanRegion.getOffset(), scanRegion.getLength()); IScanner scanner= ToolFactory.createScanner(false, false, false, false); scanner.setSource(source.toCharArray()); try { int id= scanner.getNextToken(); while (id != ITerminalSymbols.TokenNameEOF && id != tokenId) id= scanner.getNextToken(); if (id == ITerminalSymbols.TokenNameEOF) return null; int tokenOffset= scanner.getCurrentTokenStartPosition(); int tokenLength= scanner.getCurrentTokenEndPosition() + 1 - tokenOffset; // inclusive end return new Region(tokenOffset + scanRegion.getOffset(), tokenLength); } catch (InvalidInputException e) { return null; } } private void addReplace(IDocument document, DocumentCommand command, int offset, int length, String text) throws BadLocationException { command.addCommand(offset, length, text, fDocumentListener); //$NON-NLS-1$ command.owner= fDocumentListener; command.doit= false; String oldText= document.get(offset, length); int delta= offset <= command.offset ? 0 : (command.text == null ? 0 : command.text.length()) - command.length; IRegion replacedRegion= new Region(command.offset, command.text == null ? 0 : command.text.length()); DocumentEvent undoEvent= new DocumentEvent(document, offset + delta, text == null ? 0 : text.length(), oldText); install(replacedRegion, undoEvent); } /** * Closes the block immediately on the next line. */ private void makeBlock(IDocument document, DocumentCommand command) throws BadLocationException { int offset= command.offset; int insertionLine= document.getLineOfOffset(offset); final String lineDelimiter= getLineDelimiter(document); final String lineIndentation= getLineIndentation(document, insertionLine, offset); final StringBuffer buffer= new StringBuffer(); buffer.append(lineIndentation); buffer.append("}"); //$NON-NLS-1$ buffer.append(lineDelimiter); // skip line delimiter, otherwise it may clash with the insertion of '{' int replaceOffset= document.getLineOffset(insertionLine) + document.getLineLength(insertionLine); addReplace(document, command, replaceOffset, 0, buffer.toString()); } /** * Surrounds a statement with a block. */ private void makeBlock(IDocument document, DocumentCommand command, IRegion replace, IRegion statement, IRegion nextStatement, IRegion prevStatement, boolean followingControl) throws BadLocationException { final int insertionLine= document.getLineOfOffset(replace.getOffset()); final int statementLine= document.getLineOfOffset(statement.getOffset() + statement.getLength()); final int statementLineBegin= document.getLineOfOffset(statement.getOffset()); final String outerSpace= (prevStatement.getOffset() + prevStatement.getLength() == replace.getOffset()) ? "" : " "; //$NON-NLS-1$ //$NON-NLS-2$ final String innerSpace= (replace.getOffset() + replace.getLength() == statement.getOffset()) ? "" : " "; //$NON-NLS-1$ //$NON-NLS-2$ switch (statementLine - insertionLine) { // statement on same line case 0: { int replaceOffset= statement.getOffset() + statement.getLength(); int replaceLength= document.getChar(replaceOffset) == ' ' ? 1 : 0; // eat existing space addReplace(document, command, replaceOffset, replaceLength, innerSpace + "}" + outerSpace); //$NON-NLS-1$ } break; // more than one line distance between block begin and next statement: default: // statement on next line case 1: // statement is too far away, assume normal typing; add closing braces before statement /* Changed due to http://dev.eclipse.org/bugs/show_bug.cgi?id=32082 */ // if (statementLineBegin - insertionLine >= 2) { if (true) { makeBlock(document, command); break; } final String lineDelimiter= getLineDelimiter(document); final String lineIndentation= getLineIndentation(document, insertionLine, replace.getOffset()); final StringBuffer buffer= new StringBuffer(); if (nextStatement == null) { buffer.append(lineDelimiter); buffer.append(lineIndentation); buffer.append("}"); //$NON-NLS-1$ // at end of line to skip a possible comment IRegion region= document.getLineInformation(statementLine); addReplace(document, command, region.getOffset() + region.getLength(), 0, buffer.toString()); } else { final int nextStatementLine=document.getLineOfOffset(nextStatement.getOffset()); if (statementLine == nextStatementLine) { int replaceOffset= statement.getOffset() + statement.getLength(); int replaceLength= document.getChar(replaceOffset) == ' ' ? 1 : 0; // eat existing space addReplace(document, command, replaceOffset, replaceLength, innerSpace + "}" + outerSpace); //$NON-NLS-1$ } else { if (followingControl && JavaCore.DO_NOT_INSERT.equals(JavaCore.getOption(JavaCore.FORMATTER_NEWLINE_CONTROL))) { addReplace(document, command, nextStatement.getOffset(), 0, "}" + outerSpace); //$NON-NLS-1$ } else { buffer.append(lineDelimiter); buffer.append(lineIndentation); buffer.append("}"); //$NON-NLS-1$ // at end of line to skip a possible comment IRegion region= document.getLineInformation(statementLine); addReplace(document, command, region.getOffset() + region.getLength(), 0, buffer.toString()); } } } break; } } private static Statement getNextStatement(Statement statement) { ASTNode node= statement.getParent(); while (node != null && node.getNodeType() != ASTNode.BLOCK) node= node.getParent(); if (node == null) return null; Block block= (Block) node; List statements= block.statements(); for (final Iterator iterator= statements.iterator(); iterator.hasNext(); ) { final Statement nextStatement= (Statement) iterator.next(); if (nextStatement.getStartPosition() >= statement.getStartPosition() + statement.getLength()) return nextStatement; } return null; } private static boolean areBlocksConsistent(IDocument document, int offset) { JavaCodeReader reader= new JavaCodeReader(); try { int begin= offset; int end= offset; while (true) { begin= searchForOpeningPeer(reader, begin, '{', '}', document); end= searchForClosingPeer(reader, end, '{', '}', document); if (begin == -1 && end == -1) return true; if (begin == -1 || end == -1) return false; } } catch (IOException e) { return false; } } private static IRegion getSurroundingBlock(IDocument document, int offset) { JavaCodeReader reader= new JavaCodeReader(); try { int begin= searchForOpeningPeer(reader, offset, '{', '}', document); int end= searchForClosingPeer(reader, offset, '{', '}', document); if (begin == -1 || end == -1) return null; return new Region(begin, end + 1 - begin); } catch (IOException e) { return null; } } private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset) { try { IRegion sourceRange= getSurroundingBlock(document, offset); if (sourceRange == null) return null; String source= document.get(sourceRange.getOffset(), sourceRange.getLength()); StringBuffer contents= new StringBuffer(); contents.append("class C{void m()"); //$NON-NLS-1$ final int methodOffset= contents.length(); contents.append(source); contents.append('}'); char[] buffer= contents.toString().toCharArray(); return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset); } catch (BadLocationException e) { JavaPlugin.log(e); } return null; } private static IRegion createRegion(ASTNode node, int delta) { if (node == null) return null; return new Region(node.getStartPosition() + delta, node.getLength()); } private void smartBraces(IDocument document, DocumentCommand command) throws BadLocationException { if (! JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES)) return; final int offset= command.offset; final int length= command.length; final IRegion replace= new Region(offset, length); CompilationUnitInfo info= getCompilationUnitForMethod(document, offset); if (info == null) return; char[] buffer= info.buffer; int delta= info.delta; // offset of buffer inside document final CompilationUnit compilationUnit= AST.parseCompilationUnit(buffer); // continue only if no problems exist in this method IProblem[] problems= compilationUnit.getProblems(); for (int i= 0; i != problems.length; ++i) if (problems[i].getID() == IProblem.UnmatchedBracket) return; ASTNode node= NodeFinder.perform(compilationUnit, offset - delta, length); if (node == null) return; // get truly enclosing node while (node != null && length == 0 && (offset - delta == node.getStartPosition() || offset - delta == node.getStartPosition() + node.getLength())) node= node.getParent(); switch (node.getNodeType()) { case ASTNode.BLOCK: // normal typing: no useful AST node available if (areBlocksConsistent(document, offset)) makeBlock(document, command); break; case ASTNode.IF_STATEMENT: { IfStatement ifStatement= (IfStatement) node; Expression expression= ifStatement.getExpression(); Statement thenStatement= ifStatement.getThenStatement(); Statement elseStatement= ifStatement.getElseStatement(); Statement nextStatement= getNextStatement(ifStatement); IRegion expressionRegion= createRegion(expression, delta); IRegion thenRegion= createRegion(thenStatement, delta); IRegion elseRegion= createRegion(elseStatement, delta); IRegion nextRegion= createRegion(nextStatement, delta); IRegion elseToken= null; if (elseStatement != null) { int sourceOffset= thenRegion.getOffset() + thenRegion.getLength(); int sourceLength= elseRegion.getOffset() - sourceOffset; elseToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameelse); } // between expression and then statement if (offset >= expressionRegion.getOffset() + expressionRegion.getLength() && offset + length <= thenRegion.getOffset()) { if (thenStatement == null || thenStatement.getNodeType() == ASTNode.BLOCK) return; if (elseToken != null) nextRegion= elseToken; // search for ) int sourceOffset= expressionRegion.getOffset() + expressionRegion.getLength(); int sourceLength= thenRegion.getOffset() - sourceOffset; IRegion rightParenthesisToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameRPAREN); makeBlock(document, command, replace, thenRegion, nextRegion, rightParenthesisToken, elseStatement != null); break; } if (elseStatement == null || elseStatement.getNodeType() == ASTNode.BLOCK) return; // between then and else and if (offset >= elseToken.getOffset() + elseToken.getLength() && offset + length <= elseRegion.getOffset()) makeBlock(document, command, replace, createRegion(elseStatement, delta), nextRegion, elseToken, false); } break; case ASTNode.WHILE_STATEMENT: case ASTNode.FOR_STATEMENT: { Expression expression= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getExpression() : ((ForStatement) node).getExpression(); Statement body= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getBody() : ((ForStatement) node).getBody(); Statement nextStatement= getNextStatement((Statement) node); if (expression == null || body == null || body.getNodeType() == ASTNode.BLOCK) return; IRegion expressionRegion= createRegion(expression, delta); IRegion bodyRegion= createRegion(body, delta); IRegion nextRegion= createRegion(nextStatement, delta); // search for ) int sourceOffset= expressionRegion.getOffset() + expressionRegion.getLength(); int sourceLength= bodyRegion.getOffset() - sourceOffset; IRegion rightParenthesisToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameRPAREN); if (offset >= expressionRegion.getOffset() + expressionRegion.getLength() && offset + length <= bodyRegion.getOffset()) makeBlock(document, command, replace, bodyRegion, nextRegion, rightParenthesisToken, false); } break; case ASTNode.DO_STATEMENT: { DoStatement doStatement= (DoStatement) node; Statement body= doStatement.getBody(); Expression expression= doStatement.getExpression(); //Statement nextStatement= getNextStatement((Statement) node); if (expression == null || body == null || body.getNodeType() == ASTNode.BLOCK) return; IRegion doRegion= createRegion(doStatement, delta); IRegion bodyRegion= createRegion(body, delta); IRegion expressionRegion= createRegion(expression, delta); //IRegion nextRegion= createRegion(nextStatement, delta); int sourceOffset= bodyRegion.getOffset() + bodyRegion.getLength(); int sourceLength= expressionRegion.getOffset() - sourceOffset; IRegion whileToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNamewhile); IRegion prevRegion= getToken(document, doRegion, ITerminalSymbols.TokenNamedo); if (offset >= doRegion.getOffset() && offset + length <= bodyRegion.getOffset()) makeBlock(document, command, replace, bodyRegion, whileToken, prevRegion, true); } break; default: break; } } private static int searchForClosingPeer(JavaCodeReader reader, int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { reader.configureForwardReader(document, offset + 1, document.getLength(), true, true); int stack= 1; int c= reader.read(); while (c != JavaCodeReader.EOF) { if (c == openingPeer && c != closingPeer) stack++; else if (c == closingPeer) stack--; if (stack == 0) return reader.getOffset(); c= reader.read(); } return -1; } private static int searchForOpeningPeer(JavaCodeReader reader, int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { reader.configureBackwardReader(document, offset, true, true); int stack= 1; int c= reader.read(); while (c != JavaCodeReader.EOF) { if (c == closingPeer && c != openingPeer) stack++; else if (c == openingPeer) stack--; if (stack == 0) return reader.getOffset(); c= reader.read(); } return -1; } }
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.text; import java.util.Vector; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.DefaultTextDoubleClickStrategy; import org.eclipse.jface.text.IAutoIndentStrategy; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewerExtension2; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.formatter.ContentFormatter; import org.eclipse.jface.text.formatter.IContentFormatter; import org.eclipse.jface.text.formatter.IFormattingStrategy; import org.eclipse.jface.text.information.IInformationPresenter; import org.eclipse.jface.text.information.IInformationProvider; import org.eclipse.jface.text.information.InformationPresenter; import org.eclipse.jface.text.presentation.IPresentationReconciler; import org.eclipse.jface.text.presentation.PresentationReconciler; import org.eclipse.jface.text.reconciler.IReconciler; import org.eclipse.jface.text.rules.DefaultDamagerRepairer; import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.ContentAssistPreference; import org.eclipse.jdt.internal.ui.text.HTMLTextPresenter; import org.eclipse.jdt.internal.ui.text.JavaAnnotationHover; import org.eclipse.jdt.internal.ui.text.JavaElementProvider; import org.eclipse.jdt.internal.ui.text.JavaOutlineInformationControl; import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; import org.eclipse.jdt.internal.ui.text.JavaReconciler; import org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy; import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor; import org.eclipse.jdt.internal.ui.text.java.JavaDoubleClickSelector; import org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy; import org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy; import org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy; import org.eclipse.jdt.internal.ui.text.java.JavaStringDoubleClickSelector; import org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor; import org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy; import org.eclipse.jdt.internal.ui.text.java.hover.JavaInformationProvider; import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy; import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocCompletionProcessor; /** * Configuration for a source viewer which shows Java code. * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> */ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration { /** * Preference key used to look up display tab width. * * @since 2.0 */ public final static String PREFERENCE_TAB_WIDTH= PreferenceConstants.EDITOR_TAB_WIDTH; /** * Preference key for inserting spaces rather than tabs. * * @since 2.0 */ public final static String SPACES_FOR_TABS= PreferenceConstants.EDITOR_SPACES_FOR_TABS; private JavaTextTools fJavaTextTools; private ITextEditor fTextEditor; /** * Creates a new Java source viewer configuration for viewers in the given editor * using the given Java tools. * * @param tools the Java tools to be used * @param editor the editor in which the configured viewer(s) will reside */ public JavaSourceViewerConfiguration(JavaTextTools tools, ITextEditor editor) { fJavaTextTools= tools; fTextEditor= editor; } /** * Returns the Java source code scanner for this configuration. * * @return the Java source code scanner */ protected RuleBasedScanner getCodeScanner() { return fJavaTextTools.getCodeScanner(); } /** * Returns the Java multiline comment scanner for this configuration. * * @return the Java multiline comment scanner * * @since 2.0 */ protected RuleBasedScanner getMultilineCommentScanner() { return fJavaTextTools.getMultilineCommentScanner(); } /** * Returns the Java singleline comment scanner for this configuration. * * @return the Java singleline comment scanner * * @since 2.0 */ protected RuleBasedScanner getSinglelineCommentScanner() { return fJavaTextTools.getSinglelineCommentScanner(); } /** * Returns the Java string scanner for this configuration. * * @return the Java string scanner * * @since 2.0 */ protected RuleBasedScanner getStringScanner() { return fJavaTextTools.getStringScanner(); } /** * Returns the JavaDoc scanner for this configuration. * * @return the JavaDoc scanner */ protected RuleBasedScanner getJavaDocScanner() { return fJavaTextTools.getJavaDocScanner(); } /** * Returns the color manager for this configuration. * * @return the color manager */ protected IColorManager getColorManager() { return fJavaTextTools.getColorManager(); } /** * Returns the editor in which the configured viewer(s) will reside. * * @return the enclosing editor */ protected ITextEditor getEditor() { return fTextEditor; } /** * Returns the preference store used by this configuration to initialize * the individual bits and pieces. * * @return the preference store used to initialize this configuration * * @since 2.0 */ protected IPreferenceStore getPreferenceStore() { return JavaPlugin.getDefault().getPreferenceStore(); } /* * @see ISourceViewerConfiguration#getPresentationReconciler(ISourceViewer) */ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { PresentationReconciler reconciler= new PresentationReconciler(); DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getCodeScanner()); reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); dr= new DefaultDamagerRepairer(getJavaDocScanner()); reconciler.setDamager(dr, JavaPartitionScanner.JAVA_DOC); reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_DOC); dr= new DefaultDamagerRepairer(getMultilineCommentScanner()); reconciler.setDamager(dr, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT); reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT); dr= new DefaultDamagerRepairer(getSinglelineCommentScanner()); reconciler.setDamager(dr, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT); reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT); dr= new DefaultDamagerRepairer(getStringScanner()); reconciler.setDamager(dr, JavaPartitionScanner.JAVA_STRING); reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_STRING); return reconciler; } /* * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer) */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { if (getEditor() != null) { ContentAssistant assistant= new ContentAssistant(); IContentAssistProcessor processor= new JavaCompletionProcessor(getEditor()); assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); // Register the same processor for strings and single line comments to get code completion at the start of those partitions. assistant.setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_STRING); assistant.setContentAssistProcessor(processor, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT); assistant.setContentAssistProcessor(new JavaDocCompletionProcessor(getEditor()), JavaPartitionScanner.JAVA_DOC); ContentAssistPreference.configure(assistant, getPreferenceStore()); assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE); assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); return assistant; } return null; } /* * @see SourceViewerConfiguration#getReconciler(ISourceViewer) */ public IReconciler getReconciler(ISourceViewer sourceViewer) { if (getEditor() != null && getEditor().isEditable()) { JavaReconciler reconciler= new JavaReconciler(getEditor(), new JavaReconcilingStrategy(getEditor()), false); reconciler.setProgressMonitor(new NullProgressMonitor()); reconciler.setDelay(500); return reconciler; } return null; } /* * @see SourceViewerConfiguration#getAutoIndentStrategy(ISourceViewer, String) */ public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) { if (JavaPartitionScanner.JAVA_DOC.equals(contentType) || JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT.equals(contentType)) return new JavaDocAutoIndentStrategy(); else if (JavaPartitionScanner.JAVA_STRING.equals(contentType)) return new JavaStringAutoIndentStrategy(); return new JavaAutoIndentStrategy(); } /* * @see SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer, String) */ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { if (JavaPartitionScanner.JAVA_DOC.equals(contentType) || JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT.equals(contentType) || JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT.equals(contentType)) return new DefaultTextDoubleClickStrategy(); else if (JavaPartitionScanner.JAVA_STRING.equals(contentType)) return new JavaStringDoubleClickSelector(); return new JavaDoubleClickSelector(); } /* * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String) * @since 2.0 */ public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) { return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$ } /* * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String) */ public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { Vector vector= new Vector(); // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces Preferences preferences= JavaCore.getPlugin().getPluginPreferences(); int tabWidth= preferences.getInt(JavaCore.FORMATTER_TAB_SIZE); boolean useSpaces= getPreferenceStore().getBoolean(SPACES_FOR_TABS); for (int i= 0; i <= tabWidth; i++) { StringBuffer prefix= new StringBuffer(); if (useSpaces) { for (int j= 0; j + i < tabWidth; j++) prefix.append(' '); if (i != 0) prefix.append('\t'); } else { for (int j= 0; j < i; j++) prefix.append(' '); if (i != tabWidth) prefix.append('\t'); } vector.add(prefix.toString()); } vector.add(""); //$NON-NLS-1$ return (String[]) vector.toArray(new String[vector.size()]); } /* * @see SourceViewerConfiguration#getTabWidth(ISourceViewer) */ public int getTabWidth(ISourceViewer sourceViewer) { return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH); } /* * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer) */ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { return new JavaAnnotationHover(); } public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) { JavaEditorTextHoverDescriptor[] hoverDescs= JavaPlugin.getDefault().getJavaEditorTextHoverDescriptors(); int stateMasks[]= new int[hoverDescs.length]; int stateMasksLength= 0; for (int i= 0; i < hoverDescs.length; i++) { if (hoverDescs[i].isEnabled()) { int j= 0; int stateMask= hoverDescs[i].getStateMask(); while (j < stateMasksLength) { if (stateMasks[j] == stateMask) break; j++; } if (j == stateMasksLength) stateMasks[stateMasksLength++]= stateMask; } } if (stateMasksLength == hoverDescs.length) return stateMasks; int[] shortenedStateMasks= new int[stateMasksLength]; System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength); return shortenedStateMasks; } /* * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int) */ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) { JavaEditorTextHoverDescriptor[] hoverDescs= JavaPlugin.getDefault().getJavaEditorTextHoverDescriptors(); int i= 0; while (i < hoverDescs.length) { if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask) return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor()); i++; } return null; } /* * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String) */ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); } /* * @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer) */ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return new String[] { IDocument.DEFAULT_CONTENT_TYPE, JavaPartitionScanner.JAVA_DOC, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT, JavaPartitionScanner.JAVA_STRING }; } /* * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer) */ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { ContentFormatter formatter= new ContentFormatter(); IFormattingStrategy strategy= new JavaFormattingStrategy(sourceViewer); formatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE); formatter.enablePartitionAwareFormatting(false); formatter.setPartitionManagingPositionCategories(fJavaTextTools.getPartitionManagingPositionCategories()); return formatter; } /* * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer) * @since 2.0 */ public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true)); // return new HoverBrowserControl(parent); } }; } private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { int shellStyle= SWT.RESIZE; int style= SWT.V_SCROLL | SWT.H_SCROLL; return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false)); // return new HoverBrowserControl(parent); } }; } private IInformationControlCreator getOutlinePresenterControlCreator(ISourceViewer sourceViewer) { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { int shellStyle= SWT.RESIZE; int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL; return new JavaOutlineInformationControl(parent, shellStyle, treeStyle); } }; } /* * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer) * @since 2.0 */ public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) { InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer)); IInformationProvider provider= new JavaInformationProvider(getEditor()); presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE); presenter.setInformationProvider(provider, JavaPartitionScanner.JAVA_DOC); presenter.setSizeConstraints(60, 10, true, true); return presenter; } /** * Returns the outline presenter which will determine and shown * information requested for the current cursor position. * * @param sourceViewer the source viewer to be configured by this configuration * @return an information presenter * @since 2.1 */ public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) { InformationPresenter presenter= new InformationPresenter(getOutlinePresenterControlCreator(sourceViewer)); presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL); IInformationProvider provider= new JavaElementProvider(getEditor(), doCodeResolve); presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE); presenter.setInformationProvider(provider, JavaPartitionScanner.JAVA_DOC); presenter.setInformationProvider(provider, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT); presenter.setInformationProvider(provider, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT); presenter.setInformationProvider(provider, JavaPartitionScanner.JAVA_STRING); presenter.setSizeConstraints(40, 20, true, false); return presenter; } }
33,629
Bug 33629 Double-quote as character value broken in RC1
There is a series of related bugs under the category of it's really hard to enter a character value containing a double-quote character and when you try it strange things can happen. 1. Single-quote balancing seems not to work at all. When you type a single quote you get a single quote. 2. When you type the character sequence '" the result is '"" (!) 3. When you try to backspace over the extra unwanted " (either the first or the second) both are erased. The only way to get the desired result seems to be to copy and paste the " character. 4. If you try to cut and paste in the ", you can get in some weird mode where the editor thinks a string exists where there is none. I'm still trying to figure out the sequence that produced the following lines: if (c == ''' || c == '"') {" + "} (Leading tabs removed for sake of example.) I only know that the last two " characters were not typed. No doubt another illustration why editor modes are a bad idea.
verified fixed
c0eed80
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-17T19:22:59Z
2003-03-02T18:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaTextTools.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.text; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.rules.DefaultPartitioner; import org.eclipse.jface.text.rules.IPartitionTokenScanner; //import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; //import org.eclipse.jface.text.rules.RuleBasedPartitioner; import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.core.runtime.Preferences; import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner; import org.eclipse.jdt.internal.ui.text.JavaColorManager; import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; import org.eclipse.jdt.internal.ui.text.JavaCommentScanner; import org.eclipse.jdt.internal.ui.text.SingleTokenJavaScanner; import org.eclipse.jdt.internal.ui.text.java.JavaCodeScanner; import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocScanner; /** * Tools required to configure a Java text viewer. * The color manager and all scanner exist only one time, i.e. * the same instances are returned to all clients. Thus, clients * share those tools. * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> */ public class JavaTextTools { private class PreferenceListener implements IPropertyChangeListener, Preferences.IPropertyChangeListener { public void propertyChange(PropertyChangeEvent event) { adaptToPreferenceChange(event); } public void propertyChange(Preferences.PropertyChangeEvent event) { adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue())); } }; /** The color manager */ private JavaColorManager fColorManager; /** The Java source code scanner */ private JavaCodeScanner fCodeScanner; /** The Java multiline comment scanner */ private JavaCommentScanner fMultilineCommentScanner; /** The Java singleline comment scanner */ private JavaCommentScanner fSinglelineCommentScanner; /** The Java string scanner */ private SingleTokenJavaScanner fStringScanner; /** The JavaDoc scanner */ private JavaDocScanner fJavaDocScanner; /** The Java partitions scanner */ private FastJavaPartitionScanner fPartitionScanner; /** The preference store */ private IPreferenceStore fPreferenceStore; /** The core preference store */ private Preferences fCorePreferenceStore; /** The preference change listener */ private PreferenceListener fPreferenceListener= new PreferenceListener(); /** * Creates a new Java text tools collection. * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> should be used to initialize the text tools. * * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.0 */ public JavaTextTools(IPreferenceStore store) { this(store, null, true); } /** * Creates a new Java text tools collection. * * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> shoould be used to initialize the text tools. * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager * automatically disposes all managed colors when the current display gets disposed * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. * * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, boolean autoDisposeOnDisplayDispose) { this(store, null, autoDisposeOnDisplayDispose); } /** * Creates a new Java text tools collection. * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> should be used to initialize the text tools. * @param coreStore optional preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. * * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, Preferences coreStore) { this(store, coreStore, true); } /** * Creates a new Java text tools collection. * * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> shoould be used to initialize the text tools. * @param coreStore optional preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager * automatically disposes all managed colors when the current display gets disposed * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. * * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { fPreferenceStore= store; fPreferenceStore.addPropertyChangeListener(fPreferenceListener); fCorePreferenceStore= coreStore; if (fCorePreferenceStore != null) fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); fColorManager= new JavaColorManager(autoDisposeOnDisplayDispose); fCodeScanner= new JavaCodeScanner(fColorManager, store); fMultilineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(fColorManager, store, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(fColorManager, store, coreStore); fPartitionScanner= new FastJavaPartitionScanner(); } /** * Disposes all the individual tools of this tools collection. */ public void dispose() { fCodeScanner= null; fMultilineCommentScanner= null; fSinglelineCommentScanner= null; fStringScanner= null; fJavaDocScanner= null; fPartitionScanner= null; if (fColorManager != null) { fColorManager.dispose(); fColorManager= null; } if (fPreferenceStore != null) { fPreferenceStore.removePropertyChangeListener(fPreferenceListener); fPreferenceStore= null; if (fCorePreferenceStore != null) { fCorePreferenceStore.removePropertyChangeListener(fPreferenceListener); fCorePreferenceStore= null; } fPreferenceListener= null; } } /** * Returns the color manager which is used to manage * any Java-specific colors needed for such things like syntax highlighting. * * @return the color manager to be used for Java text viewers */ public IColorManager getColorManager() { return fColorManager; } /** * Returns a scanner which is configured to scan Java source code. * * @return a Java source code scanner */ public RuleBasedScanner getCodeScanner() { return fCodeScanner; } /** * Returns a scanner which is configured to scan Java multiline comments. * * @return a Java multiline comment scanner * * @since 2.0 */ public RuleBasedScanner getMultilineCommentScanner() { return fMultilineCommentScanner; } /** * Returns a scanner which is configured to scan Java singleline comments. * * @return a Java singleline comment scanner * * @since 2.0 */ public RuleBasedScanner getSinglelineCommentScanner() { return fSinglelineCommentScanner; } /** * Returns a scanner which is configured to scan Java strings. * * @return a Java string scanner * * @since 2.0 */ public RuleBasedScanner getStringScanner() { return fStringScanner; } /** * Returns a scanner which is configured to scan JavaDoc compliant comments. * Notes that the start sequence "/**" and the corresponding end sequence * are part of the JavaDoc comment. * * @return a JavaDoc scanner */ public RuleBasedScanner getJavaDocScanner() { return fJavaDocScanner; } /** * Returns a scanner which is configured to scan * Java-specific partitions, which are multi-line comments, * JavaDoc comments, and regular Java source code. * * @return a Java partition scanner */ public IPartitionTokenScanner getPartitionScanner() { return fPartitionScanner; } /** * Factory method for creating a Java-specific document partitioner * using this object's partitions scanner. This method is a * convenience method. * * @return a newly created Java document partitioner */ public IDocumentPartitioner createDocumentPartitioner() { String[] types= new String[] { JavaPartitionScanner.JAVA_DOC, JavaPartitionScanner.JAVA_MULTI_LINE_COMMENT, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT, JavaPartitionScanner.JAVA_STRING }; return new DefaultPartitioner(getPartitionScanner(), types); } /** * Returns the names of the document position categories used by the document * partitioners created by this object to manage their partition information. * If the partitioners don't use document position categories, the returned * result is <code>null</code>. * * @return the partition managing position categories or <code>null</code> * if there is none */ public String[] getPartitionManagingPositionCategories() { return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY }; } /** * Determines whether the preference change encoded by the given event * changes the behavior of one its contained components. * * @param event the event to be investigated * @return <code>true</code> if event causes a behavioral change * * @since 2.0 */ public boolean affectsBehavior(PropertyChangeEvent event) { return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event) || fJavaDocScanner.affectsBehavior(event); } /** * Adapts the behavior of the contained components to the change * encoded in the given event. * * @param event the event to which to adapt * @since 2.0 */ protected void adaptToPreferenceChange(PropertyChangeEvent event) { if (fCodeScanner.affectsBehavior(event)) fCodeScanner.adaptToPreferenceChange(event); if (fMultilineCommentScanner.affectsBehavior(event)) fMultilineCommentScanner.adaptToPreferenceChange(event); if (fSinglelineCommentScanner.affectsBehavior(event)) fSinglelineCommentScanner.adaptToPreferenceChange(event); if (fStringScanner.affectsBehavior(event)) fStringScanner.adaptToPreferenceChange(event); if (fJavaDocScanner.affectsBehavior(event)) fJavaDocScanner.adaptToPreferenceChange(event); } }
35,107
Bug 35107 Show in>doesn't work from synchronize view
1) perform a synchronize in the Java perspective 2) select a resource that has changes and is in the workspace 3) Navigate>Show in>Package Explorer -> beep The problem is that the show in logic doesn't check whether the selection (TeamFile) can be adapted to an IResource. This is a common navigation, i.e., you want to check/edit an affected file. Navigating to the PackageExplorer is already possible from the context menu. The fix is to also check for the IResource adapter when the slection isn't an IJavaElement. I'm tempted to fix it for RC3 since it is a real value add. Dirk - I remember you have complained about this too Kai - please approve if you agree
verified fixed
306ac10
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-18T19:23:57Z
2003-03-16T18:40:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.packageview; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; 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.Tree; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; 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.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.IOpenListener; 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.ITreeContentProvider; import org.eclipse.jface.viewers.ITreeViewerListener; import org.eclipse.jface.viewers.OpenEvent; 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.jface.viewers.ViewerFilter; import org.eclipse.core.runtime.IPath; 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.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; 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.IPageLayout; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.part.ISetSelectionTarget; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInTarget; import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.part.ResourceTransfer; import org.eclipse.ui.part.ShowInContext; 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.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; 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.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter; import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer; import org.eclipse.jdt.internal.ui.dnd.ResourceTransferDragAdapter; import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener; import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.FilterUpdater; import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels; import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.ui.IPackagesViewPart; import org.eclipse.jdt.ui.JavaElementSorter; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.StandardJavaElementContentProvider; /** * 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, IShowInTarget, IPackagesViewPart, IPropertyChangeListener, IViewPartInputProvider { private boolean fIsCurrentLayoutFlat; // true means flat, false means hierachical private static final int HIERARCHICAL_LAYOUT= 0x1; private static final int FLAT_LAYOUT= 0x2; 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_LAYOUT= "layout"; //$NON-NLS-1$ private PackageExplorerContentProvider fContentProvider; private FilterUpdater fFilterUpdater; private PackageExplorerActionGroup fActionSet; private ProblemTreeViewer fViewer; private Menu fContextMenu; private IMemento fMemento; private ISelectionChangedListener fSelectionListener; private String fWorkingSetName; 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); } }; private PackageExplorerLabelProvider fLabelProvider; /* (non-Javadoc) * Method declared on IViewPart. */ private boolean fLinkingEnabled; public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento= memento; restoreLayoutState(memento); } private void restoreLayoutState(IMemento memento) { Integer state= null; if (memento != null) state= memento.getInteger(TAG_LAYOUT); // If no memento try an restore from preference store if(state == null) { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); state= new Integer(store.getInt(TAG_LAYOUT)); } if (state.intValue() == FLAT_LAYOUT) fIsCurrentLayoutFlat= true; else if (state.intValue() == HIERARCHICAL_LAYOUT) fIsCurrentLayoutFlat= false; else fIsCurrentLayoutFlat= 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() { IWorkbenchPage activePage= JavaPlugin.getActivePage(); if (activePage == null) return null; IViewPart view= activePage.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 (fContextMenu != null && !fContextMenu.isDisposed()) fContextMenu.dispose(); getSite().getPage().removePartListener(fPartListener); JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); if (fViewer != null) fViewer.removeTreeListener(fExpansionListener); if (fActionSet != null) fActionSet.dispose(); if (fFilterUpdater != null) ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater); super.dispose(); } /** * Implementation of IWorkbenchPart.createPartControl(Composite) */ public void createPartControl(Composite parent) { fViewer= createViewer(parent); fViewer.setUseHashlookup(true); fViewer.setComparer(new PackageExplorerElementComparer()); setProviders(); JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(this); fContextMenu= menuMgr.createContextMenu(fViewer.getTree()); fViewer.getTree().setMenu(fContextMenu); // Register viewer with site. This must be done before making the actions. IWorkbenchPartSite site= getSite(); site.registerContextMenu(menuMgr, fViewer); site.setSelectionProvider(fViewer); site.getPage().addPartListener(fPartListener); if (fMemento != null) { restoreLinkingEnabled(fMemento); } makeActions(); // call before registering for selection changes // Set input after filter and sorter has been set. This avoids resorting and refiltering. restoreFilterAndSorter(); fViewer.setInput(findInputElement()); initFrameActions(); initDragAndDrop(); initKeyListener(); fSelectionListener= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSelectionChanged(event); } }; fViewer.addSelectionChangedListener(fSelectionListener); fViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { fActionSet.handleDoubleClick(event); } }); fViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fActionSet.handleOpen(event); } }); IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager(); fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager)); fViewer.addTreeListener(fExpansionListener); if (fMemento != null) restoreUIState(fMemento); fMemento= null; // Set help for the view JavaUIHelp.setHelp(fViewer, IJavaHelpContextIds.PACKAGES_VIEW); fillActionBars(); updateTitle(); fFilterUpdater= new FilterUpdater(fViewer); ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater); } private void initFrameActions() { fActionSet.getUpAction().update(); fActionSet.getBackAction().update(); fActionSet.getForwardAction().update(); } /** * This viewer ensures that non-leaves in the hierarchical * layout are not removed by any filters. * * @since 2.1 */ private ProblemTreeViewer createViewer(Composite parent) { return new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL) { /* * @see org.eclipse.jface.viewers.StructuredViewer#filter(java.lang.Object) */ protected Object[] getFilteredChildren(Object parent) { List list = new ArrayList(); ViewerFilter[] filters = fViewer.getFilters(); Object[] children = ((ITreeContentProvider) fViewer.getContentProvider()).getChildren(parent); for (int i = 0; i < children.length; i++) { Object object = children[i]; if (!isEssential(object)) { object = filter(object, parent, filters); if (object != null) { list.add(object); } } else list.add(object); } return list.toArray(); } // Sends the object through the given filters private Object filter(Object object, Object parent, ViewerFilter[] filters) { for (int i = 0; i < filters.length; i++) { ViewerFilter filter = filters[i]; if (!filter.select(fViewer, parent, object)) return null; } return object; } /* Checks if a filtered object in essential (ie. is a parent that * should not be removed). */ private boolean isEssential(Object object) { try { if (!isFlatLayout() && object instanceof IPackageFragment) { IPackageFragment fragment = (IPackageFragment) object; return !fragment.isDefaultPackage() && fragment.hasSubpackages(); } } catch (JavaModelException e) { JavaPlugin.log(e); } return false; } protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) { IStructuredSelection is= (IStructuredSelection)invalidSelection; List ns= null; if (newSelection instanceof IStructuredSelection) { ns= new ArrayList(((IStructuredSelection)newSelection).toList()); } else { ns= new ArrayList(); } boolean changed= false; for (Iterator iter= is.iterator(); iter.hasNext();) { Object element= iter.next(); if (element instanceof IJavaProject) { IProject project= ((IJavaProject)element).getProject(); if (!project.isOpen()) { ns.add(project); changed= true; } } else if (element instanceof IProject) { IProject project= (IProject)element; if (project.isOpen()) { IJavaProject jProject= JavaCore.create(project); if (jProject != null && jProject.exists()) ns.add(jProject); changed= true; } } } if (changed) { newSelection= new StructuredSelection(ns); setSelection(newSelection); } super.handleInvalidSelection(invalidSelection, newSelection); } }; } /** * Answers whether this part shows the packages flat or hierarchical. * * @since 2.1 */ boolean isFlatLayout() { return fIsCurrentLayoutFlat; } private void setProviders() { //content provider must be set before the label provider fContentProvider= createContentProvider(); fContentProvider.setIsFlatLayout(fIsCurrentLayoutFlat); fViewer.setContentProvider(fContentProvider); fLabelProvider= createLabelProvider(); fLabelProvider.setIsFlatLayout(fIsCurrentLayoutFlat); fViewer.setLabelProvider(new DecoratingJavaLabelProvider(fLabelProvider, false, false)); // problem decoration provided by PackageLabelProvider } void toggleLayout() { // Update current state and inform content and label providers fIsCurrentLayoutFlat= !fIsCurrentLayoutFlat; saveLayoutState(null); fContentProvider.setIsFlatLayout(isFlatLayout()); fLabelProvider.setIsFlatLayout(isFlatLayout()); fViewer.getControl().setRedraw(false); fViewer.refresh(); fViewer.getControl().setRedraw(true); } /** * This method should only be called inside this class * and from test cases. */ public PackageExplorerContentProvider createContentProvider() { IPreferenceStore store= PreferenceConstants.getPreferenceStore(); boolean showCUChildren= store.getBoolean(PreferenceConstants.SHOW_CU_CHILDREN); boolean reconcile= PreferenceConstants.UPDATE_WHILE_EDITING.equals(store.getString(PreferenceConstants.UPDATE_JAVA_VIEWS)); return new PackageExplorerContentProvider(this, showCUChildren, reconcile); } private PackageExplorerLabelProvider createLabelProvider() { return new PackageExplorerLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS, fContentProvider); } private void fillActionBars() { IActionBars actionBars= getViewSite().getActionBars(); fActionSet.fillActionBars(actionBars); } private Object findInputElement() { Object input= getSite().getPage().getInput(); if (input instanceof IWorkspace) { return JavaCore.create(((IWorkspace)input).getRoot()); } else if (input instanceof IContainer) { IJavaElement element= JavaCore.create((IContainer)input); if (element != null && element.exists()) return element; return 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; if (key == IShowInSource.class) { return getShowInSource(); } if (key == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { IPageLayout.ID_RES_NAV }; } }; } return super.getAdapter(key); } /** * Returns the tool tip text for the given element. */ String getToolTipText(Object element) { String result; if (!(element instanceof IResource)) { if (element instanceof IJavaModel) result= PackagesMessages.getString("PackageExplorerPart.workspace"); //$NON-NLS-1$ else result= JavaElementLabels.getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS); } else { IPath path= ((IResource) element).getFullPath(); if (path.isRoot()) { result= PackagesMessages.getString("PackageExplorer.title"); //$NON-NLS-1$ } else { result= path.makeRelative().toString(); } } if (fWorkingSetName == null) return result; String wsstr= PackagesMessages.getFormattedString("PackageExplorer.toolTip", new String[] { fWorkingSetName }); //$NON-NLS-1$ if (result.length() == 0) return wsstr; return PackagesMessages.getFormattedString("PackageExplorer.toolTip2", new String[] { result, fWorkingSetName }); //$NON-NLS-1$ } public String getTitleToolTip() { if (fViewer == null) return super.getTitleToolTip(); return getToolTipText(fViewer.getInput()); } /** * @see IWorkbenchPart#setFocus() */ public void setFocus() { fViewer.getTree().setFocus(); } /** * 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); fActionSet.setContext(new ActionContext(getSelection())); fActionSet.fillContextMenu(menu); fActionSet.setContext(null); } private void makeActions() { fActionSet= new PackageExplorerActionGroup(this); } //---- Event handling ---------------------------------------------------------- private void initDragAndDrop() { initDrag(); initDrop(); } private void initDrag() { int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()}; TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(fViewer), new ResourceTransferDragAdapter(fViewer), new FileTransferDragAdapter(fViewer) }; fViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fViewer, dragListeners)); } private void initDrop() { int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT; Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), FileTransfer.getInstance()}; TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new SelectionTransferDropAdapter(fViewer), new FileTransferDropAdapter(fViewer) }; fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); } /** * Handles selection changed in viewer. * Updates global actions. * Links to editor (if option enabled) */ private void handleSelectionChanged(SelectionChangedEvent event) { IStructuredSelection selection= (IStructuredSelection) event.getSelection(); fActionSet.handleSelectionChanged(event); // if (OpenStrategy.getOpenMethod() != OpenStrategy.SINGLE_CLICK) linkToEditor(selection); } public void selectReveal(ISelection selection) { selectReveal(selection, 0); } private void selectReveal(final ISelection selection, final int count) { Control ctrl= getViewer().getControl(); if (ctrl == null || ctrl.isDisposed()) return; ISelection javaSelection= convertSelection(selection); fViewer.setSelection(javaSelection, true); PackageExplorerContentProvider provider= (PackageExplorerContentProvider)getViewer().getContentProvider(); ISelection cs= fViewer.getSelection(); // If we have Pending changes and the element could not be selected then // we try it again on more time by posting the select and reveal asynchronuoulsy // to the event queue. See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=30700 // for a discussion of the underlying problem. if (count == 0 && provider.hasPendingChanges() && !javaSelection.equals(cs)) { ctrl.getDisplay().asyncExec(new Runnable() { public void run() { selectReveal(selection, count + 1); } }); } } private ISelection convertSelection(ISelection s) { if (!(s instanceof IStructuredSelection)) return s; Object[] elements= ((StructuredSelection)s).toArray(); if (!containsResources(elements)) return s; for (int i= 0; i < elements.length; i++) { Object o= elements[i]; if (o instanceof IResource) { IJavaElement jElement= JavaCore.create((IResource)o); if (jElement != null && jElement.exists()) elements[i]= jElement; } } return new StructuredSelection(elements); } private boolean containsResources(Object[] elements) { for (int i = 0; i < elements.length; i++) { if (elements[i] instanceof IResource) return true; } return false; } public void selectAndReveal(Object element) { selectReveal(new StructuredSelection(element)); } boolean isLinkingEnabled() { return fLinkingEnabled; } /** * Initializes the linking enabled setting from the preference store. */ private void initLinkingEnabled() { fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.LINK_PACKAGES_TO_EDITOR); } /** * Links to editor (if option enabled) */ private void linkToEditor(IStructuredSelection selection) { // ignore selection changes if the package explorer is not the active part. // In this case the selection change isn't triggered by a user. if (!isActivePart()) return; Object obj= selection.getFirstElement(); if (selection.size() == 1) { IEditorPart part= EditorUtility.isOpenInEditor(obj); if (part != null) { IWorkbenchPage page= getSite().getPage(); page.bringToTop(part); if (obj instanceof IJavaElement) EditorUtility.revealInEditor(part, (IJavaElement) obj); } } } private boolean isActivePart() { return this == getSite().getPage().getActivePart(); } 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); saveLayoutState(memento); saveLinkingEnabled(memento); // commented out because of http://bugs.eclipse.org/bugs/show_bug.cgi?id=4676 //saveScrollState(memento, fViewer.getTree()); fActionSet.saveFilterAndSorterState(memento); } private void saveLinkingEnabled(IMemento memento) { memento.putInteger(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, fLinkingEnabled ? 1 : 0); } /** * Saves the current layout state. * * @param memento the memento to save the state into or * <code>null</code> to store the state in the preferences * @since 2.1 */ private void saveLayoutState(IMemento memento) { if (memento != null) { memento.putInteger(TAG_LAYOUT, getLayoutAsInt()); } else { //if memento is null save in preference store IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(TAG_LAYOUT, getLayoutAsInt()); } } private int getLayoutAsInt() { if (fIsCurrentLayoutFlat) return FLAT_LAYOUT; else return HIERARCHICAL_LAYOUT; } 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.getVisibleExpandedElements(); 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()); } } } private void restoreFilterAndSorter() { fViewer.setSorter(new JavaElementSorter()); if (fMemento != null) fActionSet.restoreFilterAndSorterState(fMemento); } private void restoreUIState(IMemento memento) { restoreExpansionState(memento); restoreSelectionState(memento); // commented out because of http://bugs.eclipse.org/bugs/show_bug.cgi?id=4676 //restoreScrollState(memento, fViewer.getTree()); } private void restoreLinkingEnabled(IMemento memento) { Integer val= memento.getInteger(PreferenceConstants.LINK_PACKAGES_TO_EDITOR); if (val != null) { fLinkingEnabled= val.intValue() != 0; } } 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)); if (element != null) 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)); if (element != null) elements.add(element); } fViewer.setExpandedElements(elements.toArray()); } } /** * Create the KeyListener for doing the refresh on the viewer. */ private void initKeyListener() { fViewer.getControl().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { fActionSet.handleKeyEvent(event); } }); } /** * 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; showInput(getElementOfInput(editor.getEditorInput())); } boolean showInput(Object input) { Object element= null; if (input instanceof IFile && isOnClassPath((IFile)input)) { element= JavaCore.create((IFile)input); } if (element == null) // try a non Java resource element= input; if (element != null) { ISelection newSelection= new StructuredSelection(element); if (!fViewer.getSelection().equals(newSelection)) { try { fViewer.removeSelectionChangedListener(fSelectionListener); fViewer.setSelection(newSelection); while (element != null && fViewer.getSelection().isEmpty()) { // Try to select parent in case element is filtered element= getParent(element); if (element != null) { newSelection= new StructuredSelection(element); fViewer.setSelection(newSelection); } } } finally { fViewer.addSelectionChangedListener(fSelectionListener); } } return true; } return false; } private boolean isOnClassPath(IFile file) { IJavaProject jproject= JavaCore.create(file.getProject()); return jproject.isOnClasspath(file); } /** * Returns the element's parent. * * @return the parent or <code>null</code> if there's no parent */ private Object getParent(Object element) { if (element instanceof IJavaElement) return ((IJavaElement)element).getParent(); else if (element instanceof IResource) return ((IResource)element).getParent(); // else if (element instanceof IStorage) { // can't get parent - see bug 22376 // } return null; } /** * 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 IClassFileEditorInput) return ((IClassFileEditorInput)input).getClassFile(); else if (input instanceof IFileEditorInput) return ((IFileEditorInput)input).getFile(); else if (input instanceof JarEntryEditorInput) return ((JarEntryEditorInput)input).getStorage(); return null; } /** * Returns the Viewer. */ TreeViewer getViewer() { return fViewer; } /** * Returns the TreeViewer. */ public TreeViewer getTreeViewer() { return fViewer; } boolean isExpandable(Object element) { if (fViewer == null) return false; return fViewer.isExpandable(element); } void setWorkingSetName(String workingSetName) { fWorkingSetName= workingSetName; } /** * Updates the title text and title tool tip. * Called whenever the input of the viewer changes. */ void updateTitle() { Object input= fViewer.getInput(); String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ if (input == null || (input instanceof IJavaModel)) { setTitle(viewName); setTitleToolTip(""); //$NON-NLS-1$ } else { String inputText= JavaElementLabels.getTextLabel(input, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS); 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. * @deprecated To be removed */ public void setLabelDecorator(ILabelDecorator decorator) { } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (fViewer == null) return; boolean refreshViewer= false; if (PreferenceConstants.SHOW_CU_CHILDREN.equals(event.getProperty())) { fActionSet.updateActionBars(getViewSite().getActionBars()); boolean showCUChildren= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SHOW_CU_CHILDREN); ((StandardJavaElementContentProvider)fViewer.getContentProvider()).setProvideMembers(showCUChildren); refreshViewer= true; } else if (PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(event.getProperty())) { refreshViewer= true; } if (refreshViewer) fViewer.refresh(); } /* (non-Javadoc) * @see IViewPartInputProvider#getViewPartInput() */ public Object getViewPartInput() { if (fViewer != null) { return fViewer.getInput(); } return null; } public void collapseAll() { fViewer.getControl().setRedraw(false); fViewer.collapseToLevel(getViewPartInput(), TreeViewer.ALL_LEVELS); fViewer.getControl().setRedraw(true); } public PackageExplorerPart() { initLinkingEnabled(); } public boolean show(ShowInContext context) { Object input= context.getInput(); if (input instanceof IEditorInput) { Object elementOfInput= getElementOfInput((IEditorInput)context.getInput()); if (elementOfInput == null) return false; return showInput(elementOfInput); } ISelection selection= context.getSelection(); if (selection != null) { selectReveal(selection); return true; } return false; } /** * Returns the <code>IShowInSource</code> for this view. */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( getViewer().getInput(), getViewer().getSelection()); } }; } /** * @see IResourceNavigator#setLinkingEnabled(boolean) * @since 2.1 */ public void setLinkingEnabled(boolean enabled) { fLinkingEnabled= enabled; PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, enabled); if (enabled) { IEditorPart editor = getSite().getPage().getActiveEditor(); if (editor != null) { editorActivated(editor); } } } /** * Returns the name for the given element. * Used as the name for the current frame. */ String getFrameName(Object element) { if (element instanceof IJavaElement) { return ((IJavaElement) element).getElementName(); } else { return ((ILabelProvider) getTreeViewer().getLabelProvider()).getText(element); } } void projectStateChanged(Object root) { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { fViewer.refresh(root, true); // trigger a syntetic selection change so that action refresh their // enable state. fViewer.setSelection(fViewer.getSelection()); } } }
34,040
Bug 34040 It takes a minute to expand a project in Package explorer
Build: RC1 For scalability testing, I'm developing against WSADIE. I imported a plug-in whose classpath contains >200 external jar entries. The project is initially collpsed. In the package explorer view, if you click on the + to expand the project, it will take about 60 seconds for the project to expand. After it expanded, I went into the view filters and changed it so that I could see the hidden '.*' files, it will take another minute to update the view.
verified fixed
f99ce52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-18T20:58:46Z
2003-03-07T01:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.packageview; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.widgets.Control; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.IClasspathEntry; 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.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IWorkingCopy; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.StandardJavaElementContentProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * Content provider for the PackageExplorer. * * <p> * Since 2.1 this content provider can provide the children for flat or hierarchical * layout. The hierarchical layout is done by delegating to the <code>PackageFragmentProvider</code>. * </p> * * @see org.eclipse.jdt.ui.StandardJavaElementContentProvider * @see org.eclipse.jdt.internal.ui.packageview.PackageFragmentProvider */ class PackageExplorerContentProvider extends StandardJavaElementContentProvider implements ITreeContentProvider, IElementChangedListener { private TreeViewer fViewer; private Object fInput; private boolean fIsFlatLayout; private PackageFragmentProvider fPackageFragmentProvider= new PackageFragmentProvider(); private int fPendingChanges; private PackageExplorerPart fPart; /** * Creates a new content provider for Java elements. */ public PackageExplorerContentProvider(PackageExplorerPart part, boolean provideMembers, boolean provideWorkingCopy) { super(provideMembers, provideWorkingCopy); fPart= part; } /* (non-Javadoc) * Method declared on IElementChangedListener. */ public void elementChanged(final ElementChangedEvent event) { try { processDelta(event.getDelta()); } catch(JavaModelException e) { JavaPlugin.log(e); } } /* (non-Javadoc) * Method declared on IContentProvider. */ public void dispose() { super.dispose(); JavaCore.removeElementChangedListener(this); fPackageFragmentProvider.dispose(); } // ------ Code which delegates to PackageFragmentProvider ------ private boolean needsToDelegateGetChildren(Object element) { int type= -1; if (element instanceof IJavaElement) type= ((IJavaElement)element).getElementType(); return (!fIsFlatLayout && (type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT || type == IJavaElement.JAVA_PROJECT)); } public Object[] getChildren(Object parentElement) { Object[] children= NO_CHILDREN; try { if (parentElement instanceof IJavaModel) return concatenate(getJavaProjects((IJavaModel)parentElement), getNonJavaProjects((IJavaModel)parentElement)); if (parentElement instanceof ClassPathContainer) return getContainerPackageFragmentRoots((ClassPathContainer)parentElement); if (parentElement instanceof IProject) return ((IProject)parentElement).members(); if (needsToDelegateGetChildren(parentElement)) { Object[] packageFragments= fPackageFragmentProvider.getChildren(parentElement); children= getWithParentsResources(packageFragments, parentElement); } else { children= super.getChildren(parentElement); } if (parentElement instanceof IJavaProject) { IJavaProject project= (IJavaProject)parentElement; return rootsAndContainers(project, children); } else return children; } catch (CoreException e) { return NO_CHILDREN; } } private Object[] rootsAndContainers(IJavaProject project, Object[] roots) { List result= new ArrayList(roots.length); Set containers= new HashSet(roots.length); for (int i= 0; i < roots.length; i++) { if (roots[i] instanceof IPackageFragmentRoot) { IPackageFragmentRoot root= (IPackageFragmentRoot)roots[i]; IClasspathEntry entry= null; try { entry= root.getRawClasspathEntry(); } catch (JavaModelException e) { continue; } if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) containers.add(entry); else result.add(root); } else { result.add(roots[i]); } } for (Iterator each= containers.iterator(); each.hasNext();) { IClasspathEntry element= (IClasspathEntry) each.next(); result.add(new ClassPathContainer(project, element)); } return result.toArray(); } private Object[] getContainerPackageFragmentRoots(ClassPathContainer container) throws JavaModelException { return container.getPackageFragmentRoots(); } private Object[] getNonJavaProjects(IJavaModel model) throws JavaModelException { return model.getNonJavaResources(); } public Object getParent(Object child) { if (needsToDelegateGetParent(child)) { return fPackageFragmentProvider.getParent(child); } else return super.getParent(child); } protected Object internalGetParent(Object element) { // since we insert logical package containers we have to fix // up the parent for package fragment roots so that they refer // to the container and containers refere to the project // if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root= (IPackageFragmentRoot)element; IJavaProject project= root.getJavaProject(); try { IClasspathEntry[] entries= project.getRawClasspath(); for (int i= 0; i < entries.length; i++) { IClasspathEntry entry= entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (ClassPathContainer.contains(project, entry, root)) return new ClassPathContainer(project, entry); } } } catch (JavaModelException e) { // fall through } } if (element instanceof ClassPathContainer) { return ((ClassPathContainer)element).getJavaProject(); } return super.internalGetParent(element); } private boolean needsToDelegateGetParent(Object element) { int type= -1; if (element instanceof IJavaElement) type= ((IJavaElement)element).getElementType(); return (!fIsFlatLayout && type == IJavaElement.PACKAGE_FRAGMENT); } /** * Returns the given objects with the resources of the parent. */ private Object[] getWithParentsResources(Object[] existingObject, Object parent) { Object[] objects= super.getChildren(parent); List list= new ArrayList(); // Add everything that is not a PackageFragment for (int i= 0; i < objects.length; i++) { Object object= objects[i]; if (!(object instanceof IPackageFragment)) { list.add(object); } } if (existingObject != null) list.addAll(Arrays.asList(existingObject)); return list.toArray(); } /* (non-Javadoc) * Method declared on IContentProvider. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); fPackageFragmentProvider.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; } // ------ delta processing ------ /** * 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. */ public void processDelta(IJavaElementDelta delta) throws JavaModelException { int kind= delta.getKind(); int flags= delta.getFlags(); IJavaElement element= delta.getElement(); if(element.getElementType()!= IJavaElement.JAVA_MODEL && element.getElementType()!= IJavaElement.JAVA_PROJECT){ IJavaProject proj= element.getJavaProject(); if (proj == null || !proj.getProject().isOpen()) return; } if (!fIsFlatLayout && element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { fPackageFragmentProvider.processDelta(delta); if (processResourceDeltas(delta.getResourceDeltas(), element)) return; IJavaElementDelta[] affectedChildren= delta.getAffectedChildren(); processAffectedChildren(affectedChildren); return; } if (!getProvideWorkingCopy() && isWorkingCopy(element)) return; if (element != null && element.getElementType() == IJavaElement.COMPILATION_UNIT && !isOnClassPath((ICompilationUnit)element)) return; // handle open and closing of a project if (((flags & IJavaElementDelta.F_CLOSED) != 0) || ((flags & IJavaElementDelta.F_OPENED) != 0)) { postRefresh(element); return; } if (kind == IJavaElementDelta.REMOVED) { // when a working copy is removed all we have to do // is to refresh the compilation unit if (isWorkingCopy(element)) { refreshWorkingCopy((IWorkingCopy)element); return; } Object parent= internalGetParent(element); postRemove(element); if (parent instanceof IPackageFragment) postUpdateIcon((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) { // when a working copy is added all we have to do // is to refresh the compilation unit if (isWorkingCopy(element)) { refreshWorkingCopy((IWorkingCopy)element); return; } 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); } } return; } else { postAdd(parent, element); } } if (element instanceof ICompilationUnit) { if (getProvideWorkingCopy()) { IJavaElement original= ((IWorkingCopy)element).getOriginalElement(); if (original != null) element= original; } if (kind == IJavaElementDelta.CHANGED) { postRefresh(element); updateSelection(delta); return; } } // 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; // the contents of an external JAR has changed if (element instanceof IPackageFragmentRoot && ((flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0)) { postRefresh(element); return; } // the source attachment of a JAR has changed if (element instanceof IPackageFragmentRoot && (((flags & IJavaElementDelta.F_SOURCEATTACHED) != 0 || ((flags & IJavaElementDelta.F_SOURCEDETACHED)) != 0))) postUpdateIcon(element); if (isClassPathChange(delta)) { // throw the towel and do a full refresh of the affected java project. postRefresh(element.getJavaProject()); return; } if (processResourceDeltas(delta.getResourceDeltas(), element)) return; handleAffectedChildren(delta, element); } private void handleAffectedChildren(IJavaElementDelta delta, IJavaElement element) throws JavaModelException { 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; } processAffectedChildren(affectedChildren); } protected void processAffectedChildren(IJavaElementDelta[] affectedChildren) throws JavaModelException { for (int i= 0; i < affectedChildren.length; i++) { processDelta(affectedChildren[i]); } } private boolean isOnClassPath(ICompilationUnit element) throws JavaModelException { IJavaProject project= element.getJavaProject(); if (project == null || !project.exists()) return false; return project.isOnClasspath(element); } /** * Updates the selection. It finds newly added elements * and selects them. */ private void updateSelection(IJavaElementDelta delta) { final IJavaElement addedElement= findAddedElement(delta); if (addedElement != null) { final StructuredSelection selection= new StructuredSelection(addedElement); postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { // 19431 // if the item is already visible then select it if (fViewer.testFindItem(addedElement) != null) fViewer.setSelection(selection); } } }); } } private IJavaElement findAddedElement(IJavaElementDelta delta) { if (delta.getKind() == IJavaElementDelta.ADDED) return delta.getElement(); IJavaElementDelta[] affectedChildren= delta.getAffectedChildren(); for (int i= 0; i < affectedChildren.length; i++) return findAddedElement(affectedChildren[i]); return null; } /** * Refreshes the Compilation unit corresponding to the workging copy * @param iWorkingCopy */ private void refreshWorkingCopy(IWorkingCopy workingCopy) { IJavaElement original= workingCopy.getOriginalElement(); if (original != null) postRefresh(original, false); } private boolean isWorkingCopy(IJavaElement element) { return (element instanceof IWorkingCopy) && ((IWorkingCopy)element).isWorkingCopy(); } /** * Updates the package icon */ private void postUpdateIcon(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}); } }); } /** 1 * Process a resource delta. * * @return true if the parent got refreshed */ private boolean processResourceDelta(IResourceDelta delta, Object parent) { int status= delta.getKind(); int flags= delta.getFlags(); IResource resource= delta.getResource(); // filter out changes affecting the output folder if (resource == null) return false; // 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)); return true; } 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)); return true; } else postAdd(parent, resource); } // open/close state change of a project if ((flags & IResourceDelta.OPEN) != 0) { postProjectStateChanged(internalGetParent(parent)); return true; } processResourceDeltas(delta.getAffectedChildren(), resource); return false; } void setIsFlatLayout(boolean state) { fIsFlatLayout= state; } /** * Process resource deltas. * * @return true if the parent got refreshed */ private boolean processResourceDeltas(IResourceDelta[] deltas, Object parent) { if (deltas == null) return false; if (deltas.length > 1) { // more than one child changed, refresh from here downwards postRefresh(parent); return true; } for (int i= 0; i < deltas.length; i++) { if (processResourceDelta(deltas[i], parent)) return true; } return false; } private void postRefresh(Object root) { // JFace doesn't refresh when object isn't part of the viewer // Therefore move the refresh start down to the viewer's input if (isParent(root, fInput)) root= fInput; postRefresh(root, true); } boolean isParent(Object root, Object child) { Object parent= getParent(child); if (parent == null) return false; if (parent.equals(root)) return true; return isParent(root, parent); } private void postRefresh(final Object root, final boolean updateLabels) { postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()){ fViewer.refresh(root, updateLabels); } } }); } private void postAdd(final Object parent, final Object element) { postRunnable(new Runnable() { public void run() { 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() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { fViewer.remove(element); } } }); } private void postProjectStateChanged(final Object root) { postRunnable(new Runnable() { public void run() { fPart.projectStateChanged(root); } }); } private void postRunnable(final Runnable r) { Control ctrl= fViewer.getControl(); final Runnable trackedRunnable= new Runnable() { public void run() { try { r.run(); } finally { removePendingChange(); } } }; if (ctrl != null && !ctrl.isDisposed()) { addPendingChange(); try { ctrl.getDisplay().asyncExec(trackedRunnable); } catch (RuntimeException e) { removePendingChange(); throw e; } catch (Error e) { removePendingChange(); throw e; } } } // ------ Pending change management due to the use of asyncExec in postRunnable. public synchronized boolean hasPendingChanges() { return fPendingChanges > 0; } private synchronized void addPendingChange() { fPendingChanges++; // System.out.print(fPendingChanges); } private synchronized void removePendingChange() { fPendingChanges--; if (fPendingChanges < 0) fPendingChanges= 0; // System.out.print(fPendingChanges); } }
35,246
Bug 35246 NPE selecting Javadoc location for a JAR
Win32 - 2.1 I0317 I have a project that contains a single JAR. If I select the Javadoc location option under Properties of the JAR, the following exception occurs: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations.getJavadocBaseLocation (JavaDocLocations.java:164) at org.eclipse.jdt.ui.JavaUI.getJavadocBaseLocation(JavaUI.java:710) at org.eclipse.jdt.internal.ui.preferences.JavadocConfigurationPropertyPage.create Contents(JavadocConfigurationPropertyPage.java:74) at org.eclipse.jface.preference.PreferencePage.createControl (PreferencePage.java:215) at org.eclipse.jdt.internal.ui.preferences.JavadocConfigurationPropertyPage.create Control(JavadocConfigurationPropertyPage.java:63) at org.eclipse.jface.preference.PreferenceDialog.showPage (PreferenceDialog.java:1017) at org.eclipse.jface.preference.PreferenceDialog$9.run (PreferenceDialog.java:496) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:69) at org.eclipse.jface.preference.PreferenceDialog$8.widgetSelected (PreferenceDialog.java:490) at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent (OpenStrategy.java:198) at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:193) at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:333) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:98) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1758) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1493) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.ui.dialogs.PropertyDialogAction.run (PropertyDialogAction.java:164) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1781) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1489) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539)
verified fixed
e6681bc
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-19T14:38:36Z
2003-03-18T20:40:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.net.URL; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.help.WorkbenchHelp; 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.core.JavaModelException; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; /** * Property page used to set the project's Javadoc location for sources */ public class JavadocConfigurationPropertyPage extends PropertyPage implements IStatusChangeListener { private JavadocConfigurationBlock fJavadocConfigurationBlock; public JavadocConfigurationPropertyPage() { } /** * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { IJavaElement elem= getJavaElement(); if (elem instanceof IPackageFragmentRoot) setDescription(PreferencesMessages.getString("JavadocConfigurationPropertyPage.IsPackageFragmentRoot.description")); //$NON-NLS-1$ else if (elem instanceof IJavaProject) setDescription(PreferencesMessages.getString("JavadocConfigurationPropertyPage.IsJavaProject.description")); //$NON-NLS-1$ else setDescription(PreferencesMessages.getString("JavadocConfigurationPropertyPage.IsIncorrectElement.description")); //$NON-NLS-1$ super.createControl(parent); } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { IJavaElement elem= getJavaElement(); URL initialLocation= null; try { initialLocation= JavaUI.getJavadocBaseLocation(elem); } catch (JavaModelException e) { JavaPlugin.log(e); } fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, initialLocation); Control control= fJavadocConfigurationBlock.createContents(parent); WorkbenchHelp.setHelp(control, IJavaHelpContextIds.JAVADOC_CONFIGURATION_PROPERTY_PAGE); Dialog.applyDialogFont(control); return control; } private IJavaElement getJavaElement() { IAdaptable adaptable= getElement(); IJavaElement elem= (IJavaElement) adaptable.getAdapter(IJavaElement.class); if (elem == null) { IResource resource= (IResource) adaptable.getAdapter(IResource.class); //special case when the .jar is a file try { if (resource instanceof IFile) { IProject proj= resource.getProject(); if (proj.hasNature(JavaCore.NATURE_ID)) { IJavaProject jproject= JavaCore.create(proj); IPackageFragmentRoot root= jproject.findPackageFragmentRoot(resource.getFullPath()); if (root != null && root.isArchive()) { elem= root; } } } } catch (CoreException e) { JavaPlugin.log(e); } } return elem; } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fJavadocConfigurationBlock.performDefaults(); super.performDefaults(); } /** * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); IJavaElement elem= getJavaElement(); if (elem instanceof IJavaProject) { JavaUI.setProjectJavadocLocation((IJavaProject) elem, javadocLocation); } else { JavaUI.setLibraryJavadocLocation(elem.getPath(), javadocLocation); } return true; } /** * @see IStatusChangeListener#statusChanged(IStatus) */ public void statusChanged(IStatus status) { setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } }
35,265
Bug 35265 NPE in classpath variables page
Build: I-20030317 I was switching back and forth between target platform and classpath variables preference pages, changing values on target platform page and seeing if changes are reflected on classpath variables page. At some point, I got the following null pointer: java.lang.NullPointerException at org.eclipse.jdt.internal.ui.wizards.buildpaths.CPVariableElementLabelProvider.ge tImage(CPVariableElementLabelProvider.java:55) at org.eclipse.jface.viewers.TableViewer.doUpdateItem(TableViewer.java:202) at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run (StructuredViewer.java:119) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:867) at org.eclipse.core.runtime.Platform.run(Platform.java:413) at org.eclipse.jface.viewers.StructuredViewer.updateItem (StructuredViewer.java:1271) at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:454) at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:431) at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:861) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection (StructuredViewer.java:801) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:859) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:821) at org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField.refresh (ListDialogField.java:739) at org.eclipse.jdt.internal.ui.wizards.buildpaths.VariableBlock.refresh (VariableBlock.java:406) at org.eclipse.jdt.internal.ui.preferences.ClasspathVariablesPreferencePage.setVisi ble(ClasspathVariablesPreferencePage.java:80) at org.eclipse.jface.preference.PreferenceDialog.showPage (PreferenceDialog.java:1064) at org.eclipse.jface.preference.PreferenceDialog$9.run (PreferenceDialog.java:496)
verified fixed
f448de3
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-19T14:50:31Z
2003-03-18T23:26:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/VariableBlock.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.wizards.buildpaths; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import org.eclipse.core.resources.IncrementalProjectBuilder; 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.core.runtime.SubProgressMonitor; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 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.IListAdapter; import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField; public class VariableBlock { private ListDialogField fVariablesList; private Control fControl; private List fSelectedElements; private boolean fAskToBuild; /** * Constructor for VariableBlock */ public VariableBlock(boolean inPreferencePage, String initSelection) { fSelectedElements= new ArrayList(0); fAskToBuild= true; String[] buttonLabels= new String[] { /* 0 */ NewWizardMessages.getString("VariableBlock.vars.add.button"), //$NON-NLS-1$ /* 1 */ NewWizardMessages.getString("VariableBlock.vars.edit.button"), //$NON-NLS-1$ /* 2 */ null, /* 3 */ NewWizardMessages.getString("VariableBlock.vars.remove.button") //$NON-NLS-1$ }; VariablesAdapter adapter= new VariablesAdapter(); CPVariableElementLabelProvider labelProvider= new CPVariableElementLabelProvider(!inPreferencePage); fVariablesList= new ListDialogField(adapter, buttonLabels, labelProvider); fVariablesList.setDialogFieldListener(adapter); fVariablesList.setLabelText(NewWizardMessages.getString("VariableBlock.vars.label")); //$NON-NLS-1$ fVariablesList.setRemoveButtonIndex(3); fVariablesList.enableButton(1, false); fVariablesList.setViewerSorter(new ViewerSorter() { public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof CPVariableElement && e2 instanceof CPVariableElement) { return ((CPVariableElement)e1).getName().compareTo(((CPVariableElement)e2).getName()); } return super.compare(viewer, e1, e2); } }); CPVariableElement initSelectedElement= null; String[] reservedName= getReservedVariableNames(); ArrayList reserved= new ArrayList(reservedName.length); addAll(reservedName, reserved); String[] entries= JavaCore.getClasspathVariableNames(); ArrayList elements= new ArrayList(entries.length); for (int i= 0; i < entries.length; i++) { String name= entries[i]; CPVariableElement elem; IPath entryPath= JavaCore.getClasspathVariable(name); if (entryPath != null) { elem= new CPVariableElement(name, entryPath, reserved.contains(name)); elements.add(elem); if (name.equals(initSelection)) { initSelectedElement= elem; } } else { JavaPlugin.logErrorMessage("VariableBlock: Classpath variable with null value: " + name); //$NON-NLS-1$ } } fVariablesList.setElements(elements); if (initSelectedElement != null) { ISelection sel= new StructuredSelection(initSelectedElement); fVariablesList.selectElements(sel); } else { fVariablesList.selectFirstElement(); } } private String[] getReservedVariableNames() { return new String[] { JavaRuntime.JRELIB_VARIABLE, JavaRuntime.JRESRC_VARIABLE, JavaRuntime.JRESRCROOT_VARIABLE, }; } public Control createContents(Composite parent) { Composite composite= new Composite(parent, SWT.NONE); LayoutUtil.doDefaultLayout(composite, new DialogField[] { fVariablesList }, true, 0, 0); LayoutUtil.setHorizontalGrabbing(fVariablesList.getListControl(null)); fControl= composite; return composite; } public void addDoubleClickListener(IDoubleClickListener listener) { fVariablesList.getTableViewer().addDoubleClickListener(listener); } public void addSelectionChangedListener(ISelectionChangedListener listener) { fVariablesList.getTableViewer().addSelectionChangedListener(listener); } private Shell getShell() { if (fControl != null) { return fControl.getShell(); } return JavaPlugin.getActiveWorkbenchShell(); } private class VariablesAdapter implements IDialogFieldListener, IListAdapter { // -------- IListAdapter -------- public void customButtonPressed(ListDialogField field, int index) { switch (index) { case 0: /* add */ editEntries(null); break; case 1: /* edit */ List selected= field.getSelectedElements(); editEntries((CPVariableElement)selected.get(0)); break; } } public void selectionChanged(ListDialogField field) { doSelectionChanged(field); } public void doubleClicked(ListDialogField field) { } // ---------- IDialogFieldListener -------- public void dialogFieldChanged(DialogField field) { } } private boolean containsReserved(List selected) { for (int i= selected.size()-1; i >= 0; i--) { if (((CPVariableElement)selected.get(i)).isReserved()) { return true; } } return false; } private static void addAll(Object[] objs, Collection dest) { for (int i= 0; i < objs.length; i++) { dest.add(objs[i]); } } private void doSelectionChanged(DialogField field) { List selected= fVariablesList.getSelectedElements(); boolean isSingleSelected= selected.size() == 1; boolean containsReserved= containsReserved(selected); // edit fVariablesList.enableButton(1, isSingleSelected && !containsReserved); // remove button fVariablesList.enableButton(3, !containsReserved); fSelectedElements= selected; } private void editEntries(CPVariableElement entry) { List existingEntries= fVariablesList.getElements(); VariableCreationDialog dialog= new VariableCreationDialog(getShell(), entry, existingEntries); if (dialog.open() != VariableCreationDialog.OK) { return; } CPVariableElement newEntry= dialog.getClasspathElement(); if (entry == null) { fVariablesList.addElement(newEntry); entry= newEntry; } else { entry.setName(newEntry.getName()); entry.setPath(newEntry.getPath()); fVariablesList.refresh(); } fVariablesList.selectElements(new StructuredSelection(entry)); } public List getSelectedElements() { return fSelectedElements; } public void performDefaults() { fVariablesList.removeAllElements(); String[] reservedName= getReservedVariableNames(); for (int i= 0; i < reservedName.length; i++) { CPVariableElement elem= new CPVariableElement(reservedName[i], Path.EMPTY, true); elem.setReserved(true); fVariablesList.addElement(elem); } } public boolean performOk() { ArrayList removedVariables= new ArrayList(); ArrayList changedVariables= new ArrayList(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List changedElements= fVariablesList.getElements(); for (int i= changedElements.size()-1; i >= 0; i--) { CPVariableElement curr= (CPVariableElement) changedElements.get(i); if (curr.isReserved()) { changedElements.remove(curr); } else { IPath path= curr.getPath(); IPath prevPath= JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps= changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild= false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title= NewWizardMessages.getString("VariableBlock.needsbuild.title"); //$NON-NLS-1$ String message= NewWizardMessages.getString("VariableBlock.needsbuild.message"); //$NON-NLS-1$ MessageDialog buildDialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res= buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild= (res == 0); } IRunnableWithProgress runnable= new VariableBlockRunnable(removedVariables, changedElements, needsBuild); ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), NewWizardMessages.getString("VariableBlock.operation_errror.title"), NewWizardMessages.getString("VariableBlock.operation_errror.message")); //$NON-NLS-1$ //$NON-NLS-2$ return false; } catch (InterruptedException e) { return true; } } return true; } private boolean doesChangeRequireFullBuild(List removed, List changed) { try { IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); IJavaProject[] projects= model.getJavaProjects(); for (int i= 0; i < projects.length; i++) { IClasspathEntry[] entries= projects[i].getRawClasspath(); for (int k= 0; k < entries.length; k++) { IClasspathEntry curr= entries[k]; if (curr.getEntryKind() == IClasspathEntry.CPE_VARIABLE) { String var= curr.getPath().segment(0); if (removed.contains(var) || changed.contains(var)) { return true; } } } } } catch (JavaModelException e) { return true; } return false; } private class VariableBlockRunnable implements IRunnableWithProgress { private List fToRemove; private List fToChange; private boolean fDoBuild; public VariableBlockRunnable(List toRemove, List toChange, boolean doBuild) { fToRemove= toRemove; fToChange= toChange; fDoBuild= doBuild; } /* * @see IRunnableWithProgress#run(IProgressMonitor) */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(NewWizardMessages.getString("VariableBlock.operation_desc"), fDoBuild ? 2 : 1); //$NON-NLS-1$ try { int nVariables= fToChange.size() + fToRemove.size(); String[] names= new String[nVariables]; IPath[] paths= new IPath[nVariables]; int k= 0; for (int i= 0; i < fToChange.size(); i++) { CPVariableElement curr= (CPVariableElement) fToChange.get(i); names[k]= curr.getName(); paths[k]= curr.getPath(); k++; } for (int i= 0; i < fToRemove.size(); i++) { names[k]= (String) fToRemove.get(i); paths[k]= null; k++; } JavaCore.setClasspathVariables(names, paths, new SubProgressMonitor(monitor, 1)); if (fDoBuild) { JavaPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor, 1)); } } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } } /** * If set to true, a dialog will ask the user to build on variable changed * @param askToBuild The askToBuild to set */ public void setAskToBuild(boolean askToBuild) { fAskToBuild= askToBuild; } /** * */ public void refresh() { int nElements= fVariablesList.getSize(); for (int i= 0; i < nElements; i++) { CPVariableElement curr= (CPVariableElement) fVariablesList.getElement(i); IPath entryPath= JavaCore.getClasspathVariable(curr.getName()); curr.setPath(entryPath); } fVariablesList.refresh(); } }
35,291
Bug 35291 OrganizeImports proposes less variants, than manual code assist proposals
I've got the following code: for (int i = 0; i < list.getLength(); i++) { Node item = list.item(i); if (item.getNodeType() == Node.ELEMENT_NODE) { result.add(getElementUniqueName((Element) item)); } } return result; All types except "Element" are resolved. Apply "Organize Imports", there are 3 variants (including e.g. javax.swing.text.Element), but no org.w3c.dom one. On manual code assist (i.e. CTRL-SPACE after "Element"), I'm getting required org.w3c.dom. There are no clashes in imports. Eclipse 200303120800.
resolved fixed
8a1f388
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-20T18:43:24Z
2003-03-19T16:06:40Z
org.eclipse.jdt.ui/core
35,291
Bug 35291 OrganizeImports proposes less variants, than manual code assist proposals
I've got the following code: for (int i = 0; i < list.getLength(); i++) { Node item = list.item(i); if (item.getNodeType() == Node.ELEMENT_NODE) { result.add(getElementUniqueName((Element) item)); } } return result; All types except "Element" are resolved. Apply "Organize Imports", there are 3 variants (including e.g. javax.swing.text.Element), but no org.w3c.dom one. On manual code assist (i.e. CTRL-SPACE after "Element"), I'm getting required org.w3c.dom. There are no clashes in imports. Eclipse 200303120800.
resolved fixed
8a1f388
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-20T18:43:24Z
2003-03-19T16:06:40Z
extension/org/eclipse/jdt/internal/corext/util/AllTypesCache.java
35,236
Bug 35236 Attaching source redraws editor many times, causing much flashing
build I20030316 Kevin called in to report the following: - with an installed JRE that does not have source attached, - open a type in the rt.jar (e.g. java.awt.Color) - attach source - the editor flashes many times before it displays the source, then continues to flash for several more seconds I was able to reproduce it on Win XP.
resolved fixed
4935d05
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:35:17Z
2003-03-18T17:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModelStatusConstants; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.util.IClassFileDisassembler; import org.eclipse.jdt.core.util.IClassFileReader; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaUIStatus; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentDialog; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.IWidgetTokenKeeper; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; 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.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IMemento; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditorActionConstants; /** * Java specific text editor. */ public class ClassFileEditor extends JavaEditor implements ClassFileDocumentProvider.InputChangeListener { /** The horizontal scroll increment. */ private static final int HORIZONTAL_SCROLL_INCREMENT= 10; /** The vertical scroll increment. */ private static final int VERTICAL_SCROLL_INCREMENT= 10; /** * A form to attach source to a class file. */ private class SourceAttachmentForm implements IPropertyChangeListener { private final IClassFile fFile; private ScrolledComposite fScrolledComposite; private Color fBackgroundColor; private Color fForegroundColor; private Color fSeparatorColor; private List fBannerLabels= new ArrayList(); private List fHeaderLabels= new ArrayList(); private Font fFont; /** * Creates a source attachment form for a class file. */ public SourceAttachmentForm(IClassFile file) { fFile= file; } /** * Returns the package fragment root of this file. */ private IPackageFragmentRoot getPackageFragmentRoot(IClassFile file) { IJavaElement element= file.getParent(); while (element != null && element.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) element= element.getParent(); return (IPackageFragmentRoot) element; } /** * Creates the control of the source attachment form. */ public Control createControl(Composite parent) { Display display= parent.getDisplay(); fBackgroundColor= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); fForegroundColor= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); fSeparatorColor= new Color(display, 152, 170, 203); JFaceResources.getFontRegistry().addListener(this); fScrolledComposite= new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); fScrolledComposite.setAlwaysShowScrollBars(false); fScrolledComposite.setExpandHorizontal(true); fScrolledComposite.setExpandVertical(true); fScrolledComposite.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { JFaceResources.getFontRegistry().removeListener(SourceAttachmentForm.this); fScrolledComposite= null; fSeparatorColor.dispose(); fSeparatorColor= null; fBannerLabels.clear(); fHeaderLabels.clear(); if (fFont != null) { fFont.dispose(); fFont= null; } } }); fScrolledComposite.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) {} public void controlResized(ControlEvent e) { Rectangle clientArea = fScrolledComposite.getClientArea(); ScrollBar verticalBar= fScrolledComposite.getVerticalBar(); verticalBar.setIncrement(VERTICAL_SCROLL_INCREMENT); verticalBar.setPageIncrement(clientArea.height - verticalBar.getIncrement()); ScrollBar horizontalBar= fScrolledComposite.getHorizontalBar(); horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT); horizontalBar.setPageIncrement(clientArea.width - horizontalBar.getIncrement()); } }); Composite composite= createComposite(fScrolledComposite); composite.setLayout(new GridLayout()); createTitleLabel(composite, JavaEditorMessages.getString("SourceAttachmentForm.title")); //$NON-NLS-1$ createLabel(composite, null); createLabel(composite, null); createHeadingLabel(composite, JavaEditorMessages.getString("SourceAttachmentForm.heading")); //$NON-NLS-1$ Composite separator= createCompositeSeparator(composite); GridData data= new GridData(GridData.FILL_HORIZONTAL); data.heightHint= 2; separator.setLayoutData(data); try { IPackageFragmentRoot root= getPackageFragmentRoot(fFile); if (root != null) { createSourceAttachmentControls(composite, root); } } catch (JavaModelException e) { String title= JavaEditorMessages.getString("SourceAttachmentForm.error.title"); //$NON-NLS-1$ String message= JavaEditorMessages.getString("SourceAttachmentForm.error.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, fScrolledComposite.getShell(), title, message); } separator= createCompositeSeparator(composite); data= new GridData(GridData.FILL_HORIZONTAL); data.heightHint= 2; separator.setLayoutData(data); StyledText styledText= createCodeView(composite); data= new GridData(GridData.FILL_BOTH); styledText.setLayoutData(data); updateCodeView(styledText, fFile); fScrolledComposite.setContent(composite); fScrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); return fScrolledComposite; } private void createSourceAttachmentControls(Composite composite, IPackageFragmentRoot root) throws JavaModelException { IClasspathEntry entry= root.getRawClasspathEntry(); IPath containerPath= null; IJavaProject jproject= root.getJavaProject(); if (entry == null || !root.isArchive()) { createLabel(composite, JavaEditorMessages.getFormattedString("SourceAttachmentForm.message.noSource", fFile.getElementName())); //$NON-NLS-1$ return; } if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { containerPath= entry.getPath(); entry= SourceAttachmentDialog.getClasspathEntryToEdit(jproject, containerPath, root.getPath()); if (entry == null) { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject()); String containerName= container == null ? entry.getPath().toString() : container.getDescription(); createLabel(composite, JavaEditorMessages.getFormattedString("SourceAttachmentForm.message.containerEntry", containerName)); //$NON-NLS-1$ return; } } Button button; IPath path= entry.getSourceAttachmentPath(); if (path == null || path.isEmpty()) { createLabel(composite, JavaEditorMessages.getFormattedString("SourceAttachmentForm.message.noSourceAttachment", root.getElementName())); //$NON-NLS-1$ createLabel(composite, JavaEditorMessages.getString("SourceAttachmentForm.message.pressButtonToAttach")); //$NON-NLS-1$ createLabel(composite, null); button= createButton(composite, JavaEditorMessages.getString("SourceAttachmentForm.button.attachSource")); //$NON-NLS-1$ } else { createLabel(composite, JavaEditorMessages.getFormattedString("SourceAttachmentForm.message.noSourceInAttachment", fFile.getElementName())); //$NON-NLS-1$ createLabel(composite, JavaEditorMessages.getString("SourceAttachmentForm.message.pressButtonToChange")); //$NON-NLS-1$ createLabel(composite, null); button= createButton(composite, JavaEditorMessages.getString("SourceAttachmentForm.button.changeAttachedSource")); //$NON-NLS-1$ } button.addSelectionListener(getButtonListener(entry, containerPath, jproject)); } private SelectionListener getButtonListener(final IClasspathEntry entry, final IPath containerPath, final IJavaProject jproject) { return new SelectionListener() { public void widgetSelected(SelectionEvent event) { try { SourceAttachmentDialog dialog= new SourceAttachmentDialog(fScrolledComposite.getShell(), entry, containerPath, jproject, true); if (dialog.open() == SourceAttachmentDialog.OK) verifyInput(getEditorInput()); } catch (CoreException e) { String title= JavaEditorMessages.getString("SourceAttachmentForm.error.title"); //$NON-NLS-1$ String message= JavaEditorMessages.getString("SourceAttachmentForm.error.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, fScrolledComposite.getShell(), title, message); } } public void widgetDefaultSelected(SelectionEvent e) {} }; } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { for (Iterator iterator = fBannerLabels.iterator(); iterator.hasNext();) { Label label = (Label) iterator.next(); label.setFont(JFaceResources.getBannerFont()); } for (Iterator iterator = fHeaderLabels.iterator(); iterator.hasNext();) { Label label = (Label) iterator.next(); label.setFont(JFaceResources.getHeaderFont()); } Control control= fScrolledComposite.getContent(); fScrolledComposite.setMinSize(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)); fScrolledComposite.setContent(control); fScrolledComposite.layout(true); fScrolledComposite.redraw(); } // --- copied from org.eclipse.update.ui.forms.internal.FormWidgetFactory private Composite createComposite(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setBackground(fBackgroundColor); // composite.addMouseListener(new MouseAdapter() { // public void mousePressed(MouseEvent e) { // ((Control) e.widget).setFocus(); // } // }); return composite; } private Composite createCompositeSeparator(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setBackground(fSeparatorColor); return composite; } private StyledText createCodeView(Composite parent) { int styles= SWT.MULTI | SWT.FULL_SELECTION; StyledText styledText= new StyledText(parent, styles); styledText.setBackground(fBackgroundColor); styledText.setForeground(fForegroundColor); styledText.setEditable(false); return styledText; } private Label createLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); if (text != null) label.setText(text); label.setBackground(fBackgroundColor); label.setForeground(fForegroundColor); return label; } private Label createTitleLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); if (text != null) label.setText(text); label.setBackground(fBackgroundColor); label.setForeground(fForegroundColor); label.setFont(JFaceResources.getHeaderFont()); fHeaderLabels.add(label); return label; } private Label createHeadingLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); if (text != null) label.setText(text); label.setBackground(fBackgroundColor); label.setForeground(fForegroundColor); label.setFont(JFaceResources.getBannerFont()); fBannerLabels.add(label); return label; } private Button createButton(Composite parent, String text) { Button button = new Button(parent, SWT.FLAT); button.setBackground(fBackgroundColor); button.setForeground(fForegroundColor); if (text != null) button.setText(text); // button.addFocusListener(visibilityHandler); return button; } private void updateCodeView(StyledText styledText, IClassFile classFile) { String content= null; int flags= IClassFileReader.FIELD_INFOS | IClassFileReader.METHOD_INFOS | IClassFileReader.SUPER_INTERFACES; IClassFileReader classFileReader= ToolFactory.createDefaultClassFileReader(classFile, flags); if (classFileReader != null) { IClassFileDisassembler disassembler= ToolFactory.createDefaultClassFileDisassembler(); content= disassembler.disassemble(classFileReader, "\n"); //$NON-NLS-1$ } styledText.setText(content == null ? "" : content); //$NON-NLS-1$ } }; private StackLayout fStackLayout; private Composite fParent; private Composite fViewerComposite; private Control fSourceAttachmentForm; /** * Default constructor. */ public ClassFileEditor() { super(); setDocumentProvider(JavaPlugin.getDefault().getClassFileDocumentProvider()); setEditorContextMenuId("#ClassFileEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#ClassFileRulerContext"); //$NON-NLS-1$ setOutlinerContextMenuId("#ClassFileOutlinerContext"); //$NON-NLS-1$ // don't set help contextId, we install our own help context } /* * @see AbstractTextEditor#createActions() */ protected void createActions() { super.createActions(); setAction(ITextEditorActionConstants.SAVE, null); setAction(ITextEditorActionConstants.REVERT_TO_SAVED, null); /* * 1GF82PL: ITPJUI:ALL - Need to be able to add bookmark to classfile * * // replace default action with class file specific ones * * setAction(ITextEditorActionConstants.BOOKMARK, new AddClassFileMarkerAction("AddBookmark.", this, IMarker.BOOKMARK, true)); //$NON-NLS-1$ * setAction(ITextEditorActionConstants.ADD_TASK, new AddClassFileMarkerAction("AddTask.", this, IMarker.TASK, false)); //$NON-NLS-1$ * setAction(ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS, new ClassFileMarkerRulerAction("ManageBookmarks.", getVerticalRuler(), this, IMarker.BOOKMARK, true)); //$NON-NLS-1$ * setAction(ITextEditorActionConstants.RULER_MANAGE_TASKS, new ClassFileMarkerRulerAction("ManageTasks.", getVerticalRuler(), this, IMarker.TASK, true)); //$NON-NLS-1$ */ setAction(ITextEditorActionConstants.BOOKMARK, null); setAction(ITextEditorActionConstants.ADD_TASK, null); } /* * @see JavaEditor#getElementAt(int) */ protected IJavaElement getElementAt(int offset) { if (getEditorInput() instanceof IClassFileEditorInput) { try { IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput(); return input.getClassFile().getElementAt(offset); } catch (JavaModelException x) { } } return null; } /* * @see JavaEditor#getCorrespondingElement(IJavaElement) */ protected IJavaElement getCorrespondingElement(IJavaElement element) { if (getEditorInput() instanceof IClassFileEditorInput) { IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput(); IJavaElement parent= element.getAncestor(IJavaElement.CLASS_FILE); if (input.getClassFile().equals(parent)) return element; } return null; } /* * @see IEditorPart#saveState(IMemento) */ public void saveState(IMemento memento) { } /* * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput) */ protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) { if (page != null && input instanceof IClassFileEditorInput) { IClassFileEditorInput cfi= (IClassFileEditorInput) input; page.setInput(cfi.getClassFile()); } } /* * 1GEPKT5: ITPJUI:Linux - Source in editor for external classes is editable * Removed methods isSaveOnClosedNeeded and isDirty. * Added method isEditable. */ /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#isEditable() */ public boolean isEditable() { return false; } /** * Translates the given editor input into an <code>ExternalClassFileEditorInput</code> * if it is a file editor input representing an external class file. * * @param input the editor input to be transformed if necessary * @return the transformed editor input */ protected IEditorInput transformEditorInput(IEditorInput input) { if (input instanceof IFileEditorInput) { IFile file= ((IFileEditorInput) input).getFile(); IClassFileEditorInput classFileInput= new ExternalClassFileEditorInput(file); if (classFileInput.getClassFile() != null) input= classFileInput; } return input; } /* * @see AbstractTextEditor#doSetInput(IEditorInput) */ protected void doSetInput(IEditorInput input) throws CoreException { input= transformEditorInput(input); if (!(input instanceof IClassFileEditorInput)) throw new CoreException(JavaUIStatus.createError( IJavaModelStatusConstants.INVALID_RESOURCE_TYPE, JavaEditorMessages.getString("ClassFileEditor.error.invalid_input_message"), //$NON-NLS-1$ null)); //$NON-NLS-1$ JavaModelException e= probeInputForSource(input); if (e != null) { IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input; IClassFile file= classFileEditorInput.getClassFile(); if (!file.getJavaProject().exists() || !file.getJavaProject().isOnClasspath(file)) { throw new CoreException(JavaUIStatus.createError( IJavaModelStatusConstants.INVALID_RESOURCE, JavaEditorMessages.getString("ClassFileEditor.error.classfile_not_on_classpath"), //$NON-NLS-1$ null)); //$NON-NLS-1$ } else { throw e; } } IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider instanceof ClassFileDocumentProvider) ((ClassFileDocumentProvider) documentProvider).removeInputChangeListener(this); super.doSetInput(input); documentProvider= getDocumentProvider(); if (documentProvider instanceof ClassFileDocumentProvider) ((ClassFileDocumentProvider) documentProvider).addInputChangeListener(this); verifyInput(getEditorInput()); } /* * @see IWorkbenchPart#createPartControl(Composite) */ public void createPartControl(Composite parent) { fParent= new Composite(parent, SWT.NONE); fStackLayout= new StackLayout(); fParent.setLayout(fStackLayout); fViewerComposite= new Composite(fParent, SWT.NONE); fViewerComposite.setLayout(new FillLayout()); super.createPartControl(fViewerComposite); fStackLayout.topControl= fViewerComposite; fParent.layout(); try { verifyInput(getEditorInput()); } catch (CoreException e) { String title= JavaEditorMessages.getString("ClassFileEditor.error.title"); //$NON-NLS-1$ String message= JavaEditorMessages.getString("ClassFileEditor.error.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, fParent.getShell(), title, message); } } private JavaModelException probeInputForSource(IEditorInput input) { if (input == null) return null; IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input; IClassFile file= classFileEditorInput.getClassFile(); try { file.getSourceRange(); } catch (JavaModelException e) { return e; } return null; } /** * Checks if the class file input has no source attached. If so, a source attachment form is shown. */ private void verifyInput(IEditorInput input) throws CoreException { if (fParent == null || input == null) return; IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input; IClassFile file= classFileEditorInput.getClassFile(); // show source attachment form if no source found if (file.getSourceRange() == null) { // dispose old source attachment form if (fSourceAttachmentForm != null) fSourceAttachmentForm.dispose(); SourceAttachmentForm form= new SourceAttachmentForm(file); fSourceAttachmentForm= form.createControl(fParent); fStackLayout.topControl= fSourceAttachmentForm; fParent.layout(); // show source viewer } else { if (fSourceAttachmentForm != null) { fSourceAttachmentForm.dispose(); fSourceAttachmentForm= null; fStackLayout.topControl= fViewerComposite; fParent.layout(); } } } /* * @see ClassFileDocumentProvider.InputChangeListener#inputChanged(IClassFileEditorInput) */ public void inputChanged(final IClassFileEditorInput input) { if (input != null && input.equals(getEditorInput())) { ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText textWidget= viewer.getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { textWidget.getDisplay().asyncExec(new Runnable() { public void run() { setInput(input); } }); } } } } /* * @see JavaEditor#createJavaSourceViewer(Composite, IVerticalRuler, int) */ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { return new SourceViewer(parent, ruler, styles) { public boolean requestWidgetToken(IWidgetTokenKeeper requester) { if (WorkbenchHelp.isContextHelpDisplayed()) return false; return super.requestWidgetToken(requester); } }; } /* * @see org.eclipse.ui.IWorkbenchPart#dispose() */ public void dispose() { // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18510 IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider instanceof ClassFileDocumentProvider) ((ClassFileDocumentProvider) documentProvider).removeInputChangeListener(this); super.dispose(); } /* * @see org.eclipse.ui.IWorkbenchPart#setFocus() */ public void setFocus() { super.setFocus(); if (fSourceAttachmentForm != null && !fSourceAttachmentForm.isDisposed()) fSourceAttachmentForm.setFocus(); } }
35,487
Bug 35487 Clipped message in refactoring dialog
Build: 2.1 RC3a The refactor > change method signature refactoring opens a dialog where parameter ordering is specified, etc. On Linux Motif, the message at the bottom is clipped to be only a couple of pixels high. It is impossible to read. From Windows, I can see this message says, "Specify the new order of parameters and/or their new names".
resolved fixed
b281f1e
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:41:24Z
2003-03-21T18:06:40Z
org.eclipse.jdt.ui/ui
35,487
Bug 35487 Clipped message in refactoring dialog
Build: 2.1 RC3a The refactor > change method signature refactoring opens a dialog where parameter ordering is specified, etc. On Linux Motif, the message at the bottom is clipped to be only a couple of pixels high. It is impossible to read. From Windows, I can see this message says, "Specify the new order of parameters and/or their new names".
resolved fixed
b281f1e
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:41:24Z
2003-03-21T18:06:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringWizardDialog2.java
35,448
Bug 35448 Outline does not reflect access modifier changes in editor
The Outline view does not reflect the change (by changing the icon) if you modify the access modifier of a method in the editor view. e.g. a class has a method public void foo() {} you change the method signature by typing in the java editor into void foo() {} The outline view still shows the green dot (even after saving the class). Only reopening the class helps. The same happens if you declare a method final/non-final. Everything works well if you declare a method static/non-static, change the name or arguments. Build id is 200303192032. I am sure this bug was not existing in a earlier build.
resolved fixed
6567b0b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:45:06Z
2003-03-21T09:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; import java.util.Vector; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.ITextSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.dnd.DND; 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.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.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IBaseLabelProvider; 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.LabelProviderChangedEvent; 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.IActionBars; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInTarget; import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.internal.model.WorkbenchAdapter; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.part.Page; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.texteditor.TextEditorAction; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; 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.IInitializer; 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.JavaElementSorter; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.ProblemsLabelDecorator.ProblemsLabelChangedEvent; import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.JdtActionConstants; import org.eclipse.jdt.ui.actions.MemberFilterActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; 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.CompositeActionGroup; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter; 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.packageview.SelectionTransferDragAdapter; import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDropAdapter; import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels; 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. * Pulishes its context menu under <code>JavaPlugin.getDefault().getPluginId() + ".outline"</code>. */ public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdaptable { static Object[] NO_CHILDREN= new Object[0]; /** * The element change listener of the java outline viewer. * @see IElementChangedListener */ class ElementChangedListener implements IElementChangedListener { public void elementChanged(final ElementChangedEvent e) { if (getControl() == null) return; Display d= getControl().getDisplay(); if (d != null) { d.asyncExec(new Runnable() { public void run() { ICompilationUnit cu= (ICompilationUnit) fInput; IJavaElement base= cu; if (fTopLevelTypeOnly) { base= getMainType(cu); if (base == null) { if (fOutlineViewer != null) fOutlineViewer.refresh(false); return; } } IJavaElementDelta delta= findElement(base, e.getDelta()); if (delta != null && fOutlineViewer != null) { fOutlineViewer.reconcile(delta); } } }); } } protected IJavaElementDelta findElement(IJavaElement 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; } }; static class NoClassElement extends WorkbenchAdapter implements IAdaptable { /* * @see java.lang.Object#toString() */ public String toString() { return JavaEditorMessages.getString("JavaOutlinePage.error.NoTopLevelType"); //$NON-NLS-1$ } /* * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) */ public Object getAdapter(Class clas) { if (clas == IWorkbenchAdapter.class) return this; return null; } } /** * Content provider for the children of an ICompilationUnit or * an IClassFile * @see ITreeContentProvider */ class ChildrenProvider implements ITreeContentProvider { private Object[] NO_CLASS= new Object[] {new NoClassElement()}; private 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.log(x); } } return NO_CHILDREN; } public Object[] getElements(Object parent) { if (fTopLevelTypeOnly) { if (parent instanceof ICompilationUnit) { try { IType type= getMainType((ICompilationUnit) parent); return type != null ? type.getChildren() : NO_CLASS; } catch (JavaModelException e) { JavaPlugin.log(e); } } else if (parent instanceof IClassFile) { try { IType type= getMainType((IClassFile) parent); return type != null ? type.getChildren() : NO_CLASS; } catch (JavaModelException e) { JavaPlugin.log(e); } } } 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.log(x); } } 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 isCU= (newInput instanceof ICompilationUnit); if (isCU && fListener == null) { fListener= new ElementChangedListener(); JavaCore.addElementChangedListener(fListener); } else if (!isCU && fListener != null) { JavaCore.removeElementChangedListener(fListener); fListener= 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; private boolean fReorderedMembers; 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) { fReorderedMembers= false; if (getSorter() == null) { if (fTopLevelTypeOnly && delta.getElement() instanceof IType && (delta.getKind() & IJavaElementDelta.ADDED) != 0) { refresh(false); } else { Widget w= findItem(fInput); if (w != null && !w.isDisposed()) update(w, delta); if (fReorderedMembers) { refresh(false); fReorderedMembers= false; } } } else { // just for now refresh(false); } } /* * @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; } protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) { if (element instanceof IMethod) { if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) { try { return ((IMethod)element).isMainMethod(); } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } } return "main".equals(element.getElementName()); //$NON-NLS-1$ } return false; } protected ISourceRange getSourceRange(IJavaElement element) throws JavaModelException { if (element instanceof IMember && !(element instanceof IInitializer)) return ((IMember) element).getNameRange(); if (element instanceof ISourceReference) return ((ISourceReference) element).getSourceRange(); return null; } protected boolean overlaps(ISourceRange range, int start, int end) { return start <= (range.getOffset() + range.getLength() - 1) && range.getOffset() <= end; } 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; } protected void update(Widget w, IJavaElementDelta delta) { Item item; IJavaElement parent= delta.getElement(); IJavaElementDelta[] affected= delta.getAffectedChildren(); Item[] children= getChildren(w); boolean doUpdateParent= false; Vector deletions= new Vector(); Vector additions= new Vector(); for (int i= 0; i < affected.length; i++) { IJavaElementDelta affectedDelta= affected[i]; IJavaElement affectedElement= affectedDelta.getElement(); int status= affected[i].getKind(); // find tree item with affected element int j; for (j= 0; j < children.length; j++) if (affectedElement.equals(children[j].getData())) break; if (j == children.length) { // addition if ((status & IJavaElementDelta.CHANGED) != 0 && (affectedDelta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 && !filtered(parent, affectedElement)) { additions.addElement(affectedDelta); } continue; } item= children[j]; // removed if ((status & IJavaElementDelta.REMOVED) != 0) { deletions.addElement(item); doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement); // changed } else if ((status & IJavaElementDelta.CHANGED) != 0) { int change= affectedDelta.getFlags(); doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, 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, affectedDelta); if ((change & IJavaElementDelta.F_REORDER) != 0) fReorderedMembers= true; } } // 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; doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e); ISourceRange rng= getSourceRange(e); 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]; IJavaElement r= (IJavaElement) item.getData(); if (r == null) { // parent node collapsed and not be opened before -> do nothing continue go2; } try { rng= getSourceRange(r); if (overlaps(rng, start, end)) { // be tolerant if the delta is not correct, or if // the tree has been updated other than by a delta reuseTreeItem(item, e); continue go2; } else if (rng.getOffset() > start) { if (last != null && deletions.contains(last)) { // reuse item deletions.removeElement(last); reuseTreeItem(last, (Object) e); } else { // nothing to reuse createTreeItem(w, (Object) e, 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, e); } else { // nothing to reuse createTreeItem(w, e, -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()); } /* * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent) */ protected void handleLabelProviderChanged(LabelProviderChangedEvent event) { Object input= getInput(); if (event instanceof ProblemsLabelChangedEvent) { ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event; if (e.isMarkerChange() && input instanceof ICompilationUnit) { return; // marker changes can be ignored } } // look if the underlying resource changed Object[] changed= event.getElements(); if (changed != null) { IResource resource= getUnderlyingResource(); if (resource != null) { for (int i= 0; i < changed.length; i++) { if (changed[i] != null && changed[i].equals(resource)) { // change event to a full refresh event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource()); break; } } } } super.handleLabelProviderChanged(event); } private IResource getUnderlyingResource() { Object input= getInput(); if (input instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) input; if (cu.isWorkingCopy()) { return cu.getOriginalElement().getResource(); } else { return cu.getResource(); } } else if (input instanceof IClassFile) { return ((IClassFile) input).getResource(); } return null; } }; class LexicalSortingAction extends Action { private JavaElementSorter fSorter= new JavaElementSorter(); public LexicalSortingAction() { super(); WorkbenchHelp.setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION); setText(JavaEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$ setToolTipText(JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip")); //$NON-NLS-1$ setDescription(JavaEditorMessages.getString("JavaOutlinePage.Sort.description")); //$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(final boolean on, boolean store) { setChecked(on); BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() { public void run() { fOutlineViewer.setSorter(on ? fSorter : null); } }); if (store) JavaPlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$ } }; class ClassOnlyAction extends Action { public ClassOnlyAction() { super(); WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION); setText(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.label")); //$NON-NLS-1$ setToolTipText(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$ setDescription(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.description")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "gointo_toplevel_type.gif"); //$NON-NLS-1$ IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore(); boolean showclass= preferenceStore.getBoolean("GoIntoTopLevelTypeAction.isChecked"); //$NON-NLS-1$ setTopLevelTypeOnly(showclass); } /* * @see org.eclipse.jface.action.Action#run() */ public void run() { setTopLevelTypeOnly(!fTopLevelTypeOnly); } private void setTopLevelTypeOnly(boolean show) { fTopLevelTypeOnly= show; setChecked(show); fOutlineViewer.refresh(false); IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore(); preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$ } }; /** A flag to show contents of top level type only */ private boolean fTopLevelTypeOnly; private IJavaElement fInput; private String fContextMenuID; private Menu fMenu; private JavaOutlineViewer fOutlineViewer; private JavaEditor fEditor; private MemberFilterActionGroup fMemberFilterActionGroup; private ListenerList fSelectionChangedListeners= new ListenerList(); private Hashtable fActions= new Hashtable(); private TogglePresentationAction fTogglePresentation; private GotoErrorAction fPreviousError; private GotoErrorAction fNextError; private TextEditorAction fShowJavadoc; private TextOperationAction fUndo; private TextOperationAction fRedo; private CompositeActionGroup fActionGroups; private CCPActionGroup fCCPActionGroup; private IPropertyChangeListener fPropertyChangeListener; public JavaOutlinePage(String contextMenuID, JavaEditor editor) { super(); Assert.isNotNull(editor); fContextMenuID= contextMenuID; fEditor= editor; fTogglePresentation= new TogglePresentationAction(); fPreviousError= new GotoErrorAction("PreviousError.", false); //$NON-NLS-1$ fPreviousError.setImageDescriptor(JavaPluginImages.DESC_TOOL_GOTO_PREV_ERROR); fNextError= new GotoErrorAction("NextError.", true); //$NON-NLS-1$ fNextError.setImageDescriptor(JavaPluginImages.DESC_TOOL_GOTO_NEXT_ERROR); fShowJavadoc= (TextEditorAction) fEditor.getAction("ShowJavaDoc"); //$NON-NLS-1$ fUndo= (TextOperationAction) fEditor.getAction(ITextEditorActionConstants.UNDO); fRedo= (TextOperationAction) fEditor.getAction(ITextEditorActionConstants.REDO); fTogglePresentation.setEditor(editor); fPreviousError.setEditor(editor); fNextError.setEditor(editor); fPropertyChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { doPropertyChange(event); } }; JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); } /** * Returns the primary type of a compilation unit (has the same * name as the compilation unit). * * @param compilationUnit the compilation unit * @return returns the primary type of the compilation unit, or * <code>null</code> if is does not have one */ protected IType getMainType(ICompilationUnit compilationUnit) { String name= compilationUnit.getElementName(); int index= name.indexOf('.'); if (index != -1) name= name.substring(0, index); IType type= compilationUnit.getType(name); return type.exists() ? type : null; } /** * Returns the primary type of a class file. * * @param classFile the class file * @return returns the primary type of the class file, or <code>null</code> * if is does not have one */ protected IType getMainType(IClassFile classFile) { try { IType type= classFile.getType(); return type != null && type.exists() ? type : null; } catch (JavaModelException e) { return null; } } /* (non-Javadoc) * Method declared on Page */ public void init(IPageSite pageSite) { super.init(pageSite); } private void doPropertyChange(PropertyChangeEvent event) { if (fOutlineViewer != null) { if (PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(event.getProperty())) { fOutlineViewer.refresh(false); } } } /* * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) */ public void addSelectionChangedListener(ISelectionChangedListener listener) { if (fOutlineViewer != null) fOutlineViewer.addPostSelectionChangedListener(listener); else fSelectionChangedListeners.add(listener); } /* * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) */ public void removeSelectionChangedListener(ISelectionChangedListener listener) { if (fOutlineViewer != null) fOutlineViewer.removePostSelectionChangedListener(listener); else fSelectionChangedListeners.remove(listener); } /* * @see ISelectionProvider#setSelection(ISelection) */ public void setSelection(ISelection selection) { if (fOutlineViewer != null) fOutlineViewer.setSelection(selection); } /* * @see ISelectionProvider#getSelection() */ public ISelection getSelection() { if (fOutlineViewer == null) return StructuredSelection.EMPTY; return fOutlineViewer.getSelection(); } private void registerToolbarActions() { IToolBarManager toolBarManager= getSite().getActionBars().getToolBarManager(); if (toolBarManager != null) { toolBarManager.add(new ClassOnlyAction()); toolBarManager.add(new LexicalSortingAction()); fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "JavaOutlineViewer"); //$NON-NLS-1$ fMemberFilterActionGroup.contributeToToolBar(toolBarManager); } } /* * @see IPage#createControl */ public void createControl(Composite parent) { Tree tree= new Tree(parent, SWT.MULTI); AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.F_APP_TYPE_SIGNATURE, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS ); fOutlineViewer= new JavaOutlineViewer(tree); fOutlineViewer.setContentProvider(new ChildrenProvider()); fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(lprovider)); Object[] listeners= fSelectionChangedListeners.getListeners(); for (int i= 0; i < listeners.length; i++) { fSelectionChangedListeners.remove(listeners[i]); fOutlineViewer.addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]); } 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); IPageSite site= getSite(); site.registerContextMenu(JavaPlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$ site.setSelectionProvider(fOutlineViewer); // we must create the groups after we have set the selection provider to the site fActionGroups= new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(this), fCCPActionGroup= new CCPActionGroup(this), new GenerateActionGroup(this), new RefactorActionGroup(this), new JavaSearchActionGroup(this)}); // register global actions IActionBars bars= site.getActionBars(); bars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fUndo); bars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fRedo); bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousError); bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextError); bars.setGlobalActionHandler(JdtActionConstants.SHOW_JAVA_DOC, fShowJavadoc); bars.setGlobalActionHandler(IJavaEditorActionConstants.TOGGLE_PRESENTATION, fTogglePresentation); // http://dev.eclipse.org/bugs/show_bug.cgi?id=18968 bars.setGlobalActionHandler(IJavaEditorActionConstants.PREVIOUS_ERROR, fPreviousError); bars.setGlobalActionHandler(IJavaEditorActionConstants.NEXT_ERROR, fNextError); fActionGroups.fillActionBars(bars); IStatusLineManager statusLineManager= site.getActionBars().getStatusLineManager(); if (statusLineManager != null) { StatusBarUpdater updater= new StatusBarUpdater(statusLineManager); fOutlineViewer.addPostSelectionChangedListener(updater); } registerToolbarActions(); fOutlineViewer.setInput(fInput); fOutlineViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { handleKeyReleased(e); } }); initDragAndDrop(); } public void dispose() { if (fEditor == null) return; if (fMemberFilterActionGroup != null) { fMemberFilterActionGroup.dispose(); fMemberFilterActionGroup= null; } fEditor.outlinePageClosed(); fEditor= null; fSelectionChangedListeners.clear(); fSelectionChangedListeners= null; if (fPropertyChangeListener != null) { JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); fPropertyChangeListener= null; } if (fMenu != null && !fMenu.isDisposed()) { fMenu.dispose(); fMenu= null; } if (fActionGroups != null) fActionGroups.dispose(); fTogglePresentation.setEditor(null); fPreviousError.setEditor(null); fNextError.setEditor(null); fOutlineViewer= 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= fOutlineViewer.getSelection(); if (s instanceof IStructuredSelection) { IStructuredSelection ss= (IStructuredSelection) s; List elements= ss.toList(); if (!elements.contains(reference)) { s= (reference == null ? StructuredSelection.EMPTY : 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); } /** * Answer the property defined by key. */ public Object getAdapter(Class key) { if (key == IShowInSource.class) { return getShowInSource(); } if (key == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { JavaUI.ID_PACKAGES }; } }; } if (key == IShowInTarget.class) { return getShowInTarget(); } return null; } /** * 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); } } } protected void contextMenuAboutToShow(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); IStructuredSelection selection= (IStructuredSelection)getSelection(); fActionGroups.setContext(new ActionContext(selection)); fActionGroups.fillContextMenu(menu); } /* * @see Page#setFocus() */ public void setFocus() { if (fOutlineViewer != null) fOutlineViewer.getControl().setFocus(); } /** * 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 handleKeyReleased(KeyEvent event) { if (event.stateMask != 0) return; IAction action= null; if (event.character == SWT.DEL) { action= fCCPActionGroup.getDeleteAction(); } if (action != null && action.isEnabled()) action.run(); } /** * Returns the <code>IShowInSource</code> for this view. */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( null, getSite().getSelectionProvider().getSelection()); } }; } /** * Returns the <code>IShowInTarget</code> for this view. */ protected IShowInTarget getShowInTarget() { return new IShowInTarget() { public boolean show(ShowInContext context) { ISelection sel= context.getSelection(); if (sel instanceof ITextSelection) { ITextSelection tsel= (ITextSelection) sel; int offset= tsel.getOffset(); IJavaElement element= fEditor.getElementAt(offset); if (element != null) { setSelection(new StructuredSelection(element)); return true; } } return false; } }; } private void initDragAndDrop() { int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() }; // Drop Adapter TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new SelectionTransferDropAdapter(fOutlineViewer) }; fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners)); // Drag Adapter TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(fOutlineViewer) }; fOutlineViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fOutlineViewer, dragListeners)); } }
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
org.eclipse.jdt.ui/core
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
org.eclipse.jdt.ui/core
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
org.eclipse.jdt.ui/core
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoring.java
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
org.eclipse.jdt.ui/core
35,523
Bug 35523 Scalability of refactoring (avoid OOMs during change execution).
Build: 2.1 RC3a VM: IBM JRE 1.3.0 build cn130-20010502 I was testing the scalability of some of the java refactorings with today's build. I was getting OutOfMemoryErrors for a number of tests, which I've almost never experienced with this VM. For example, I tried: 1) Import jdt.ui and all required projects as source using the plugin import wizard. 2) Refactor > Change Method Signature on org.eclipse.core.runtime.Status 3) Change order of method arguments. This was giving me OutOfMemoryErrors on Windows and Linux. After setting my max java heap very high (-Xmx700M), it was successful, but VM size according to Windows went from 150M to over 700M allocated. This refactoring isn't as big as it seems. There were under 700 references to this constructor, so that's almost 1MB of memory per reference.
resolved fixed
b59b14b
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-03-24T18:53:07Z
2003-03-21T20:53:20Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PushDownRefactoring.java
36,439
Bug 36439 IndexOutOfBoundsException in HTML2TextReader
R2.1 1. Open java.regex.Pattern 2. Hover over "Pattern" ==> IndexOutOfBoundsException
resolved fixed
f0c2dc1
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-14T10:02:19Z
2003-04-14T08:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/HTML2TextReader.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text; import java.io.IOException; import java.io.PushbackReader; import java.io.Reader; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.jface.text.TextPresentation; import org.eclipse.jdt.internal.ui.JavaUIMessages; /** * Reads the text contents from a reader of HTML contents and translates * the tags or cut them out. */ public class HTML2TextReader extends SubstitutionTextReader { private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ private static final String EMPTY_STRING= ""; //$NON-NLS-1$ private static final Map fgEntityLookup; private static final Set fgTags; static { fgTags= new HashSet(); fgTags.add("b"); //$NON-NLS-1$ fgTags.add("br"); //$NON-NLS-1$ fgTags.add("h5"); //$NON-NLS-1$ fgTags.add("p"); //$NON-NLS-1$ fgTags.add("dl"); //$NON-NLS-1$ fgTags.add("dt"); //$NON-NLS-1$ fgTags.add("dd"); //$NON-NLS-1$ fgTags.add("li"); //$NON-NLS-1$ fgTags.add("ul"); //$NON-NLS-1$ fgTags.add("pre"); //$NON-NLS-1$ fgEntityLookup= new HashMap(7); fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$ fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$ } private int fCounter= 0; private TextPresentation fTextPresentation; private int fBold= 0; private int fStartOffset= -1; private boolean fInParagraph= false; private boolean fIsPreformattedText= false; /** * Transforms the html text from the reader to formatted text. * @param presentation If not <code>null</code>, formattings will be applied to * the presentation. */ public HTML2TextReader(Reader reader, TextPresentation presentation) { super(new PushbackReader(reader)); fTextPresentation= presentation; } public int read() throws IOException { int c= super.read(); if (c != -1) ++ fCounter; return c; } protected void startBold() { if (fBold == 0) fStartOffset= fCounter; ++ fBold; } protected void startPreformattedText() { fIsPreformattedText= true; setSkipWhitespace(false); } protected void stopPreformattedText() { fIsPreformattedText= false; setSkipWhitespace(true); } protected void stopBold() { -- fBold; if (fBold == 0) { if (fTextPresentation != null) { fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD)); } fStartOffset= -1; } } /* * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) */ protected String computeSubstitution(int c) throws IOException { if (c == '<') return processHTMLTag(); else if (c == '&') return processEntity(); else if (fIsPreformattedText) return processPreformattedText(c); return null; } private String html2Text(String html) { String tag= html; if ('/' == tag.charAt(0)) tag= tag.substring(1); if (!fgTags.contains(tag)) return EMPTY_STRING; if ("pre".equals(html)) { //$NON-NLS-1$ startPreformattedText(); return EMPTY_STRING; } if ("/pre".equals(html)) { //$NON-NLS-1$ stopPreformattedText(); return EMPTY_STRING; } if (fIsPreformattedText) return EMPTY_STRING; if ("b".equals(html)) { //$NON-NLS-1$ startBold(); return EMPTY_STRING; } if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$ startBold(); return EMPTY_STRING; } if ("dl".equals(html)) //$NON-NLS-1$ return LINE_DELIM; if ("dd".equals(html)) //$NON-NLS-1$ return "\t"; //$NON-NLS-1$ if ("li".equals(html)) //$NON-NLS-1$ return LINE_DELIM + "\t" + JavaUIMessages.getString("HTML2TextReader.dash"); //$NON-NLS-1$ //$NON-NLS-2$ if ("/b".equals(html)) { //$NON-NLS-1$ stopBold(); return EMPTY_STRING; } if ("p".equals(html)) { //$NON-NLS-1$ fInParagraph= true; return LINE_DELIM; } if ("br".equals(html)) //$NON-NLS-1$ return LINE_DELIM; if ("/p".equals(html)) { //$NON-NLS-1$ boolean inParagraph= fInParagraph; fInParagraph= false; return inParagraph ? EMPTY_STRING : LINE_DELIM; } if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$ stopBold(); return LINE_DELIM; } if ("/dd".equals(html)) //$NON-NLS-1$ return LINE_DELIM; return EMPTY_STRING; } /* * A '<' has been read. Process a html tag */ private String processHTMLTag() throws IOException { StringBuffer buf= new StringBuffer(); int ch; do { ch= nextChar(); while (ch != -1 && ch != '>') { buf.append(Character.toLowerCase((char) ch)); ch= nextChar(); if (ch == '"'){ buf.append(Character.toLowerCase((char) ch)); ch= nextChar(); while (ch != -1 && ch != '"'){ buf.append(Character.toLowerCase((char) ch)); ch= nextChar(); } } if (ch == '<'){ unread(ch); return '<' + buf.toString(); } } if (ch == -1) return null; int tagLen= buf.length(); // needs special treatment for comments if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$ && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$ // unfinished comment buf.append(ch); } else { break; } } while (true); return html2Text(buf.toString()); } private String processPreformattedText(int c) { if (c == '\r' || c == '\n') fCounter++; return null; } private void unread(int ch) throws IOException { ((PushbackReader) getReader()).unread(ch); } protected String entity2Text(String symbol) { if (symbol.length() > 1 && symbol.charAt(0) == '#') { int ch; try { if (symbol.charAt(1) == 'x') { ch= Integer.parseInt(symbol.substring(2), 16); } else { ch= Integer.parseInt(symbol.substring(1), 10); } return EMPTY_STRING + (char)ch; } catch (NumberFormatException e) { } } else { String str= (String) fgEntityLookup.get(symbol); if (str != null) { return str; } } return "&" + symbol; // not found //$NON-NLS-1$ } /* * A '&' has been read. Process a entity */ private String processEntity() throws IOException { StringBuffer buf= new StringBuffer(); int ch= nextChar(); while (Character.isLetterOrDigit((char)ch) || ch == '#') { buf.append((char) ch); ch= nextChar(); } if (ch == ';') return entity2Text(buf.toString()); buf.insert(0, '&'); if (ch != -1) buf.append((char) ch); return buf.toString(); } }
35,977
Bug 35977 What's New documentation uses wrong keystroke
I was reading the Whats New in Eclipse 2.1, and one of the new features claims to be 'Structured selections': using Edit->Expand Selection or Ctrl+Shift+Up Arrow to highlight progressively larger amounts of Java text. However, the keystroke for this is actually Alt+Shift+Up Arrow; Ctrl+Shift+Up Arrow goes to previous member.
verified fixed
17ef904
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-15T14:08:52Z
2003-04-02T13:26:40Z
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/NewTestSuiteCreationWizardPage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.junit.wizards; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; 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.IMethod; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaConventions; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.junit.ui.IJUnitHelpContextIds; import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; import org.eclipse.jdt.internal.junit.util.ExceptionHandler; import org.eclipse.jdt.internal.junit.util.JUnitStatus; import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.internal.junit.util.LayoutUtil; import org.eclipse.jdt.internal.junit.util.SWTUtil; import org.eclipse.jdt.internal.junit.util.TestSearchEngine; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.Viewer; 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.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.help.WorkbenchHelp; /** * Wizard page to select the test classes to include * in the test suite. */ public class NewTestSuiteCreationWizardPage extends NewTypeWizardPage { private final static String PAGE_NAME= "NewTestSuiteCreationWizardPage"; //$NON-NLS-1$ private final static String CLASSES_IN_SUITE= PAGE_NAME + ".classesinsuite"; //$NON-NLS-1$ private final static String SUITE_NAME= PAGE_NAME + ".suitename"; //$NON-NLS-1$ protected final static String STORE_GENERATE_MAIN= PAGE_NAME + ".GENERATE_MAIN"; //$NON-NLS-1$ protected final static String STORE_USE_TESTRUNNER= PAGE_NAME + ".USE_TESTRUNNER"; //$NON-NLS-1$ protected final static String STORE_TESTRUNNER_TYPE= PAGE_NAME + ".TESTRUNNER_TYPE"; //$NON-NLS-1$ public static final String START_MARKER= "//$JUnit-BEGIN$"; //$NON-NLS-1$ public static final String END_MARKER= "//$JUnit-END$"; //$NON-NLS-1$ private IPackageFragment fCurrentPackage; private CheckboxTableViewer fClassesInSuiteTable; private Button fSelectAllButton; private Button fDeselectAllButton; private Label fSelectedClassesLabel; private Label fSuiteNameLabel; private Text fSuiteNameText; private String fSuiteNameTextInitialValue; private MethodStubsSelectionButtonGroup fMethodStubsButtons; private boolean fUpdatedExistingClassButton; protected IStatus fClassesInSuiteStatus; protected IStatus fSuiteNameStatus; public NewTestSuiteCreationWizardPage() { super(true, PAGE_NAME); fSuiteNameStatus= new JUnitStatus(); fSuiteNameTextInitialValue= ""; //$NON-NLS-1$ setTitle(WizardMessages.getString("NewTestSuiteWizPage.title")); //$NON-NLS-1$ setDescription(WizardMessages.getString("NewTestSuiteWizPage.description")); //$NON-NLS-1$ String[] buttonNames= new String[] { "public static void main(Strin&g[] args)", //$NON-NLS-1$ /* Add testrunner statement to main Method */ WizardMessages.getString("NewTestClassWizPage.methodStub.testRunner"), //$NON-NLS-1$ }; fMethodStubsButtons= new MethodStubsSelectionButtonGroup(SWT.CHECK, buttonNames, 1); fMethodStubsButtons.setLabelText(WizardMessages.getString("NewTestClassWizPage2.method.Stub.label")); //$NON-NLS-1$ fClassesInSuiteStatus= new JUnitStatus(); } /** * @see IDialogPage#createControl(Composite) */ public void createControl(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); int nColumns= 4; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; composite.setLayout(layout); createContainerControls(composite, nColumns); createPackageControls(composite, nColumns); createSeparator(composite, nColumns); createSuiteNameControl(composite, nColumns); setTypeName("AllTests", true); //$NON-NLS-1$ createSeparator(composite, nColumns); createClassesInSuiteControl(composite, nColumns); createMethodStubSelectionControls(composite, nColumns); setControl(composite); restoreWidgetValues(); Dialog.applyDialogFont(composite); WorkbenchHelp.setHelp(composite, IJUnitHelpContextIds.NEW_TESTSUITE_WIZARD_PAGE); } protected void createMethodStubSelectionControls(Composite composite, int nColumns) { LayoutUtil.setHorizontalSpan(fMethodStubsButtons.getLabelControl(composite), nColumns); LayoutUtil.createEmptySpace(composite,1); LayoutUtil.setHorizontalSpan(fMethodStubsButtons.getSelectionButtonsGroup(composite), nColumns - 1); } /** * Should be called from the wizard with the initial selection. */ public void init(IStructuredSelection selection) { IJavaElement jelem= getInitialJavaElement(selection); initContainerPage(jelem); initTypePage(jelem); doStatusUpdate(); fMethodStubsButtons.setSelection(0, false); //main fMethodStubsButtons.setSelection(1, false); //add textrunner fMethodStubsButtons.setEnabled(1, false); //add text } /** * @see NewContainerWizardPage#handleFieldChanged */ protected void handleFieldChanged(String fieldName) { super.handleFieldChanged(fieldName); if (fieldName.equals(PACKAGE) || fieldName.equals(CONTAINER)) { if (fieldName.equals(PACKAGE)) fPackageStatus= packageChanged(); updateClassesInSuiteTable(); } else if (fieldName.equals(CLASSES_IN_SUITE)) { fClassesInSuiteStatus= classesInSuiteChanged(); fSuiteNameStatus= testSuiteChanged(); //must check this one too updateSelectedClassesLabel(); } else if (fieldName.equals(SUITE_NAME)) { fSuiteNameStatus= testSuiteChanged(); } doStatusUpdate(); } // ------ validation -------- private void doStatusUpdate() { // status of all used components IStatus[] status= new IStatus[] { fContainerStatus, fPackageStatus, fSuiteNameStatus, fClassesInSuiteStatus }; // the most severe status will be displayed and the ok button enabled/disabled. updateStatus(status); } /** * @see DialogPage#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { setFocus(); updateClassesInSuiteTable(); handleAllFieldsChanged(); } } private void handleAllFieldsChanged() { handleFieldChanged(PACKAGE); handleFieldChanged(CONTAINER); handleFieldChanged(CLASSES_IN_SUITE); handleFieldChanged(SUITE_NAME); } protected void updateClassesInSuiteTable() { if (fClassesInSuiteTable != null) { IPackageFragment pack= getPackageFragment(); if (pack == null) { IPackageFragmentRoot root= getPackageFragmentRoot(); if (root != null) pack= root.getPackageFragment(""); //$NON-NLS-1$ else return; } fCurrentPackage= pack; fClassesInSuiteTable.setInput(pack); fClassesInSuiteTable.setAllChecked(true); updateSelectedClassesLabel(); } } protected void createClassesInSuiteControl(Composite parent, int nColumns) { if (fClassesInSuiteTable == null) { Label label = new Label(parent, SWT.LEFT); label.setText(WizardMessages.getString("NewTestSuiteWizPage.classes_in_suite.label")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalAlignment = GridData.FILL; gd.horizontalSpan= nColumns; label.setLayoutData(gd); fClassesInSuiteTable= CheckboxTableViewer.newCheckList(parent, SWT.BORDER); gd= new GridData(GridData.FILL_BOTH); gd.heightHint= 80; gd.horizontalSpan= nColumns-1; fClassesInSuiteTable.getTable().setLayoutData(gd); fClassesInSuiteTable.setContentProvider(new ClassesInSuitContentProvider()); fClassesInSuiteTable.setLabelProvider(new JavaElementLabelProvider()); fClassesInSuiteTable.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { handleFieldChanged(CLASSES_IN_SUITE); } }); Composite buttonContainer= new Composite(parent, SWT.NONE); gd= new GridData(GridData.FILL_VERTICAL); buttonContainer.setLayoutData(gd); GridLayout buttonLayout= new GridLayout(); buttonLayout.marginWidth= 0; buttonLayout.marginHeight= 0; buttonContainer.setLayout(buttonLayout); fSelectAllButton= new Button(buttonContainer, SWT.PUSH); fSelectAllButton.setText(WizardMessages.getString("NewTestSuiteWizPage.selectAll")); //$NON-NLS-1$ GridData bgd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); bgd.heightHint = SWTUtil.getButtonHeigthHint(fSelectAllButton); bgd.widthHint = SWTUtil.getButtonWidthHint(fSelectAllButton); fSelectAllButton.setLayoutData(bgd); fSelectAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fClassesInSuiteTable.setAllChecked(true); handleFieldChanged(CLASSES_IN_SUITE); } }); fDeselectAllButton= new Button(buttonContainer, SWT.PUSH); fDeselectAllButton.setText(WizardMessages.getString("NewTestSuiteWizPage.deselectAll")); //$NON-NLS-1$ bgd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); bgd.heightHint = SWTUtil.getButtonHeigthHint(fDeselectAllButton); bgd.widthHint = SWTUtil.getButtonWidthHint(fDeselectAllButton); fDeselectAllButton.setLayoutData(bgd); fDeselectAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fClassesInSuiteTable.setAllChecked(false); handleFieldChanged(CLASSES_IN_SUITE); } }); // No of selected classes label fSelectedClassesLabel= new Label(parent, SWT.LEFT | SWT.WRAP); fSelectedClassesLabel.setFont(parent.getFont()); updateSelectedClassesLabel(); gd = new GridData(); gd.horizontalSpan = 2; fSelectedClassesLabel.setLayoutData(gd); } } static class ClassesInSuitContentProvider implements IStructuredContentProvider { public Object[] getElements(Object parent) { if (! (parent instanceof IPackageFragment)) return new Object[0]; IPackageFragment pack= (IPackageFragment) parent; if (! pack.exists()) return new Object[0]; try { ICompilationUnit[] cuArray= pack.getCompilationUnits(); List typesArrayList= new ArrayList(); for (int i= 0; i < cuArray.length; i++) { ICompilationUnit cu= cuArray[i]; IType[] types= cu.getTypes(); for (int j= 0; j < types.length; j++) { IType type= types[j]; if (type.isClass() && ! Flags.isAbstract(type.getFlags()) && TestSearchEngine.isTestImplementor(type)) typesArrayList.add(types[j]); } } return typesArrayList.toArray(); } catch (JavaModelException e) { JUnitPlugin.log(e); return new Object[0]; } } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } /* * @see TypePage#evalMethods */ protected void createTypeMembers(IType type, ImportsManager imports, IProgressMonitor monitor) throws CoreException { writeImports(imports); if (fMethodStubsButtons.isEnabled() && fMethodStubsButtons.isSelected(0)) createMain(type); type.createMethod(getSuiteMethodString(), null, false, null); } protected void createMain(IType type) throws JavaModelException { type.createMethod(fMethodStubsButtons.getMainMethod(getTypeName()), null, false, null); } /** * Returns the string content for creating a new suite() method. */ public String getSuiteMethodString() throws JavaModelException { IPackageFragment pack= getPackageFragment(); String packName= pack.getElementName(); StringBuffer suite= new StringBuffer("public static Test suite () {TestSuite suite= new TestSuite(\"Test for "+((packName.equals(""))?"default package":packName)+"\");\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ suite.append(getUpdatableString()); suite.append("\nreturn suite;}"); //$NON-NLS-1$ return suite.toString(); } /** * Returns the new code to be included in a new suite() or which replaces old code in an existing suite(). */ public static String getUpdatableString(Object[] selectedClasses) throws JavaModelException { StringBuffer suite= new StringBuffer(); suite.append(START_MARKER+"\n"); //$NON-NLS-1$ for (int i= 0; i < selectedClasses.length; i++) { if (selectedClasses[i] instanceof IType) { IType testType= (IType) selectedClasses[i]; IMethod suiteMethod= testType.getMethod("suite", new String[] {}); //$NON-NLS-1$ if (!suiteMethod.exists()) { suite.append("suite.addTest(new TestSuite("+testType.getElementName()+".class));"); //$NON-NLS-1$ //$NON-NLS-2$ } else { suite.append("suite.addTest("+testType.getElementName()+".suite());"); //$NON-NLS-1$ //$NON-NLS-2$ } } } suite.append("\n"+END_MARKER); //$NON-NLS-1$ return suite.toString(); } private String getUpdatableString() throws JavaModelException { return getUpdatableString(fClassesInSuiteTable.getCheckedElements()); } /** * Runnable for replacing an existing suite() method. */ public IRunnableWithProgress getRunnable() { return new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { if (monitor == null) { monitor= new NullProgressMonitor(); } updateExistingClass(monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; } protected void updateExistingClass(IProgressMonitor monitor) throws CoreException, InterruptedException { try { IPackageFragment pack= getPackageFragment(); ICompilationUnit cu= pack.getCompilationUnit(getTypeName() + ".java"); //$NON-NLS-1$ if (!cu.exists()) { createType(monitor); fUpdatedExistingClassButton= false; return; } if (! UpdateTestSuite.checkValidateEditStatus(cu, getShell())) return; IType suiteType= cu.getType(getTypeName()); monitor.beginTask(WizardMessages.getString("NewTestSuiteWizPage.createType.beginTask"), 10); //$NON-NLS-1$ IMethod suiteMethod= suiteType.getMethod("suite", new String[] {}); //$NON-NLS-1$ monitor.worked(1); String lineDelimiter= JUnitStubUtility.getLineDelimiterUsed(cu); if (suiteMethod.exists()) { ISourceRange range= suiteMethod.getSourceRange(); if (range != null) { IBuffer buf= cu.getBuffer(); String originalContent= buf.getText(range.getOffset(), range.getLength()); StringBuffer source= new StringBuffer(originalContent); //using JDK 1.4 //int start= source.toString().indexOf(START_MARKER) --> int start= source.indexOf(START_MARKER); int start= source.toString().indexOf(START_MARKER); if (start > -1) { //using JDK 1.4 //int end= source.toString().indexOf(END_MARKER, start) --> int end= source.indexOf(END_MARKER, start) int end= source.toString().indexOf(END_MARKER, start); if (end > -1) { monitor.subTask(WizardMessages.getString("NewTestSuiteWizPage.createType.updating.suite_method")); //$NON-NLS-1$ monitor.worked(1); end += END_MARKER.length(); source.replace(start, end, getUpdatableString()); buf.replace(range.getOffset(), range.getLength(), source.toString()); cu.reconcile(); originalContent= buf.getText(0, buf.getLength()); monitor.worked(1); String formattedContent= JUnitStubUtility.codeFormat(originalContent, 0, lineDelimiter); buf.replace(0, buf.getLength(), formattedContent); monitor.worked(1); cu.save(new SubProgressMonitor(monitor, 1), false); } else { cannotUpdateSuiteError(); } } else { cannotUpdateSuiteError(); } } else { MessageDialog.openError(getShell(), WizardMessages.getString("NewTestSuiteWizPage.createType.updateErrorDialog.title"), WizardMessages.getString("NewTestSuiteWizPage.createType.updateErrorDialog.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } else { suiteType.createMethod(getSuiteMethodString(), null, true, monitor); ISourceRange range= cu.getSourceRange(); IBuffer buf= cu.getBuffer(); String originalContent= buf.getText(range.getOffset(), range.getLength()); monitor.worked(2); String formattedContent= JUnitStubUtility.codeFormat(originalContent, 0, lineDelimiter); buf.replace(range.getOffset(), range.getLength(), formattedContent); monitor.worked(1); cu.save(new SubProgressMonitor(monitor, 1), false); } monitor.done(); fUpdatedExistingClassButton= true; } catch (JavaModelException e) { String title= WizardMessages.getString("NewTestSuiteWizPage.error_tile"); //$NON-NLS-1$ String message= WizardMessages.getString("NewTestSuiteWizPage.error_message"); //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); } } /** * Returns true iff an existing suite() method has been replaced. */ public boolean hasUpdatedExistingClass() { return fUpdatedExistingClassButton; } private IStatus classesInSuiteChanged() { JUnitStatus status= new JUnitStatus(); if (fClassesInSuiteTable.getCheckedElements().length <= 0) status.setWarning(WizardMessages.getString("NewTestSuiteWizPage.classes_in_suite.error.no_testclasses_selected")); //$NON-NLS-1$ return status; } private void updateSelectedClassesLabel() { int noOfClassesChecked= fClassesInSuiteTable.getCheckedElements().length; String key= (noOfClassesChecked==1) ? "NewTestClassWizPage.treeCaption.classSelected" : "NewTestClassWizPage.treeCaption.classesSelected"; //$NON-NLS-1$ //$NON-NLS-2$ fSelectedClassesLabel.setText(WizardMessages.getFormattedString(key, new Integer(noOfClassesChecked))); } protected void createSuiteNameControl(Composite composite, int nColumns) { fSuiteNameLabel= new Label(composite, SWT.LEFT | SWT.WRAP); fSuiteNameLabel.setFont(composite.getFont()); fSuiteNameLabel.setText(WizardMessages.getString("NewTestSuiteWizPage.suiteName.text")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= 1; fSuiteNameLabel.setLayoutData(gd); fSuiteNameText= new Text(composite, SWT.SINGLE | SWT.BORDER); // moved up due to 1GEUNW2 fSuiteNameText.setEnabled(true); fSuiteNameText.setFont(composite.getFont()); fSuiteNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleFieldChanged(SUITE_NAME); } }); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; gd.grabExcessHorizontalSpace= true; gd.horizontalSpan= nColumns - 2; fSuiteNameText.setLayoutData(gd); Label space= new Label(composite, SWT.LEFT); space.setText(" "); //$NON-NLS-1$ gd= new GridData(); gd.horizontalSpan= 1; space.setLayoutData(gd); } /** * Gets the type name. */ public String getTypeName() { return (fSuiteNameText==null)?fSuiteNameTextInitialValue:fSuiteNameText.getText(); } /** * Sets the type name. * @param canBeModified Selects if the type name can be changed by the user */ public void setTypeName(String name, boolean canBeModified) { if (fSuiteNameText == null) { fSuiteNameTextInitialValue= name; } else { fSuiteNameText.setText(name); fSuiteNameText.setEnabled(canBeModified); } } /** * Called when the type name has changed. * The method validates the type name and returns the status of the validation. * Can be extended to add more validation */ protected IStatus testSuiteChanged() { JUnitStatus status= new JUnitStatus(); String typeName= getTypeName(); // must not be empty if (typeName.length() == 0) { status.setError(WizardMessages.getString("NewTestSuiteWizPage.typeName.error.name_empty")); //$NON-NLS-1$ return status; } if (typeName.indexOf('.') != -1) { status.setError(WizardMessages.getString("NewTestSuiteWizPage.typeName.error.name_qualified")); //$NON-NLS-1$ return status; } IStatus val= JavaConventions.validateJavaTypeName(typeName); if (val.getSeverity() == IStatus.ERROR) { status.setError(WizardMessages.getString("NewTestSuiteWizPage.typeName.error.name_not_valid")+val.getMessage()); //$NON-NLS-1$ return status; } else if (val.getSeverity() == IStatus.WARNING) { status.setWarning(WizardMessages.getString("NewTestSuiteWizPage.typeName.error.name.name_discouraged")+val.getMessage()); //$NON-NLS-1$ // continue checking } JUnitStatus recursiveSuiteInclusionStatus= checkRecursiveTestSuiteInclusion(); if (! recursiveSuiteInclusionStatus.isOK()) return recursiveSuiteInclusionStatus; IPackageFragment pack= getPackageFragment(); if (pack != null) { ICompilationUnit cu= pack.getCompilationUnit(typeName + ".java"); //$NON-NLS-1$ if (cu.exists()) { status.setWarning(WizardMessages.getString("NewTestSuiteWizPage.typeName.warning.already_exists")); //$NON-NLS-1$ fMethodStubsButtons.setEnabled(false); return status; } } fMethodStubsButtons.setEnabled(true); return status; } private JUnitStatus checkRecursiveTestSuiteInclusion(){ if (fClassesInSuiteTable == null) return new JUnitStatus(); String typeName= getTypeName(); JUnitStatus status= new JUnitStatus(); Object[] checkedClasses= fClassesInSuiteTable.getCheckedElements(); for (int i= 0; i < checkedClasses.length; i++) { IType checkedClass= (IType)checkedClasses[i]; if (checkedClass.getElementName().equals(typeName)){ status.setWarning(WizardMessages.getString("NewTestSuiteCreationWizardPage.infinite_recursion")); //$NON-NLS-1$ return status; } } return new JUnitStatus(); } /** * Sets the focus. */ protected void setFocus() { fSuiteNameText.setFocus(); } /** * Sets the classes in <code>elements</code> as checked. */ public void setCheckedElements(Object[] elements) { fClassesInSuiteTable.setCheckedElements(elements); } protected void cannotUpdateSuiteError() { MessageDialog.openError(getShell(), WizardMessages.getString("NewTestSuiteWizPage.cannotUpdateDialog.title"), //$NON-NLS-1$ WizardMessages.getFormattedString("NewTestSuiteWizPage.cannotUpdateDialog.message", new String[] {START_MARKER, END_MARKER})); //$NON-NLS-1$ } private void writeImports(ImportsManager imports) { imports.addImport("junit.framework.Test"); //$NON-NLS-1$ imports.addImport("junit.framework.TestSuite"); //$NON-NLS-1$ } /** * Use the dialog store to restore widget values to the values that they held * last time this wizard was used to completion */ private void restoreWidgetValues() { IDialogSettings settings= getDialogSettings(); if (settings != null) { boolean generateMain= settings.getBoolean(STORE_GENERATE_MAIN); fMethodStubsButtons.setSelection(0, generateMain); fMethodStubsButtons.setEnabled(1, generateMain); fMethodStubsButtons.setSelection(1,settings.getBoolean(STORE_USE_TESTRUNNER)); //The next 2 lines are necessary. Otherwise, if fMethodsStubsButtons is disabled, and USE_TESTRUNNER gets enabled, //then the checkbox for USE_TESTRUNNER will be the only enabled component of fMethodsStubsButton fMethodStubsButtons.setEnabled(!fMethodStubsButtons.isEnabled()); fMethodStubsButtons.setEnabled(!fMethodStubsButtons.isEnabled()); try { fMethodStubsButtons.setComboSelection(settings.getInt(STORE_TESTRUNNER_TYPE)); } catch(NumberFormatException e) {} } } /** * Since Finish was pressed, write widget values to the dialog store so that they * will persist into the next invocation of this wizard page */ void saveWidgetValues() { IDialogSettings settings= getDialogSettings(); if (settings != null) { settings.put(STORE_GENERATE_MAIN, fMethodStubsButtons.isSelected(0)); settings.put(STORE_USE_TESTRUNNER, fMethodStubsButtons.isSelected(1)); settings.put(STORE_TESTRUNNER_TYPE, fMethodStubsButtons.getComboSelection()); } } }
26,247
Bug 26247 JUnit: New Test Case wizard does not init dialogs when browsing for test class
Build 20021113 Open the new Test Case wizard Browse for a test class, select a class (e.g. TestCase), press OK Press the browse button again and press OK Previous selection is replaced with first entry in list. This happens because the dialog is not initialized with the current value (in my example TestCase).
resolved fixed
bfcd00e
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-15T15:43:13Z
2002-11-14T10:33:20Z
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/NewTestCaseCreationWizardPage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.junit.wizards; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.ListIterator; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; 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.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.dialogs.SelectionDialog; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; 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.ITypeHierarchy; import org.eclipse.jdt.core.JavaConventions; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; import org.eclipse.jdt.internal.junit.ui.IJUnitHelpContextIds; import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; import org.eclipse.jdt.internal.junit.util.JUnitStatus; import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.internal.junit.util.LayoutUtil; import org.eclipse.jdt.internal.junit.util.TestSearchEngine; import org.eclipse.jdt.internal.junit.util.JUnitStubUtility.GenStubSettings; import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; /** * The first page of the TestCase creation wizard. */ public class NewTestCaseCreationWizardPage extends NewTypeWizardPage { protected final static String PAGE_NAME= "NewTestCaseCreationWizardPage"; //$NON-NLS-1$ protected final static String CLASS_TO_TEST= PAGE_NAME + ".classtotest"; //$NON-NLS-1$ protected final static String TEST_CLASS= PAGE_NAME + ".testclass"; //$NON-NLS-1$ protected final static String TEST_SUFFIX= "Test"; //$NON-NLS-1$ protected final static String SETUP= "setUp"; //$NON-NLS-1$ protected final static String TEARDOWN= "tearDown"; //$NON-NLS-1$ protected final static String STORE_GENERATE_MAIN= PAGE_NAME + ".GENERATE_MAIN"; //$NON-NLS-1$ protected final static String STORE_USE_TESTRUNNER= PAGE_NAME + ".USE_TESTRUNNER"; //$NON-NLS-1$ protected final static String STORE_TESTRUNNER_TYPE= PAGE_NAME + ".TESTRUNNER_TYPE"; //$NON-NLS-1$ private String fDefaultClassToTest; private NewTestCaseCreationWizardPage2 fPage2; private MethodStubsSelectionButtonGroup fMethodStubsButtons; private IType fClassToTest; protected IStatus fClassToTestStatus; protected IStatus fTestClassStatus; private int fIndexOfFirstTestMethod; private Label fClassToTestLabel; private Text fClassToTestText; private Button fClassToTestButton; private Label fTestClassLabel; private Text fTestClassText; private String fTestClassTextInitialValue; private boolean fFirstTime; public NewTestCaseCreationWizardPage() { super(true, PAGE_NAME); fFirstTime= true; fTestClassTextInitialValue= ""; //$NON-NLS-1$ setTitle(WizardMessages.getString("NewTestClassWizPage.title")); //$NON-NLS-1$ setDescription(WizardMessages.getString("NewTestClassWizPage.description")); //$NON-NLS-1$ String[] buttonNames= new String[] { "public static void main(Strin&g[] args)", //$NON-NLS-1$ /* Add testrunner statement to main Method */ WizardMessages.getString("NewTestClassWizPage.methodStub.testRunner"), //$NON-NLS-1$ WizardMessages.getString("NewTestClassWizPage.methodStub.setUp"), //$NON-NLS-1$ WizardMessages.getString("NewTestClassWizPage.methodStub.tearDown") //$NON-NLS-1$ }; fMethodStubsButtons= new MethodStubsSelectionButtonGroup(SWT.CHECK, buttonNames, 1); fMethodStubsButtons.setLabelText(WizardMessages.getString("NewTestClassWizPage.method.Stub.label")); //$NON-NLS-1$ fClassToTestStatus= new JUnitStatus(); fTestClassStatus= new JUnitStatus(); fDefaultClassToTest= ""; //$NON-NLS-1$ } // -------- Initialization --------- /** * Should be called from the wizard with the initial selection and the 2nd page of the wizard.. */ public void init(IStructuredSelection selection, NewTestCaseCreationWizardPage2 page2) { fPage2= page2; IJavaElement element= getInitialJavaElement(selection); initContainerPage(element); initTypePage(element); doStatusUpdate(); // put default class to test if (element != null) { IType classToTest= null; // evaluate the enclosing type IType typeInCompUnit= (IType) element.getAncestor(IJavaElement.TYPE); if (typeInCompUnit != null) { if (typeInCompUnit.getCompilationUnit() != null) { classToTest= typeInCompUnit; } } else { ICompilationUnit cu= (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) classToTest= cu.findPrimaryType(); else { if (element instanceof IClassFile) { try { IClassFile cf= (IClassFile) element; if (cf.isStructureKnown()) classToTest= cf.getType(); } catch(JavaModelException e) { JUnitPlugin.log(e); } } } } if (classToTest != null) { try { if (!TestSearchEngine.isTestImplementor(classToTest)) { fDefaultClassToTest= classToTest.getFullyQualifiedName(); } } catch (JavaModelException e) { JUnitPlugin.log(e); } } } fMethodStubsButtons.setSelection(0, false); //main fMethodStubsButtons.setSelection(1, false); //add textrunner fMethodStubsButtons.setEnabled(1, false); //add text fMethodStubsButtons.setSelection(2, false); //setUp fMethodStubsButtons.setSelection(3, false); //tearDown } /** * @see NewContainerWizardPage#handleFieldChanged */ protected void handleFieldChanged(String fieldName) { super.handleFieldChanged(fieldName); if (fieldName.equals(CLASS_TO_TEST)) { fClassToTestStatus= classToTestClassChanged(); updateDefaultName(); } else if (fieldName.equals(SUPER)) { validateSuperClass(); if (!fFirstTime) fTestClassStatus= testClassChanged(); } else if (fieldName.equals(TEST_CLASS)) { fTestClassStatus= testClassChanged(); } else if (fieldName.equals(PACKAGE) || fieldName.equals(CONTAINER) || fieldName.equals(SUPER)) { if (fieldName.equals(PACKAGE)) fPackageStatus= packageChanged(); if (!fFirstTime) { validateSuperClass(); fClassToTestStatus= classToTestClassChanged(); fTestClassStatus= testClassChanged(); } if (fieldName.equals(CONTAINER)) { validateJUnitOnBuildPath(); } } doStatusUpdate(); } // ------ validation -------- private void doStatusUpdate() { // status of all used components IStatus[] status= new IStatus[] { fContainerStatus, fPackageStatus, fTestClassStatus, fClassToTestStatus, fModifierStatus, fSuperClassStatus }; // the mode severe status will be displayed and the ok button enabled/disabled. updateStatus(status); } protected void updateDefaultName() { String s= fClassToTestText.getText(); if (s.lastIndexOf('.') > -1) s= s.substring(s.lastIndexOf('.') + 1); if (s.length() > 0) setTypeName(s + TEST_SUFFIX, true); } /* * @see IDialogPage#createControl(Composite) */ public void createControl(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); int nColumns= 4; GridLayout layout= new GridLayout(); layout.numColumns= nColumns; composite.setLayout(layout); createContainerControls(composite, nColumns); createPackageControls(composite, nColumns); createSeparator(composite, nColumns); createTestClassControls(composite, nColumns); createClassToTestControls(composite, nColumns); createSuperClassControls(composite, nColumns); createMethodStubSelectionControls(composite, nColumns); setSuperClass(JUnitPlugin.TEST_SUPERCLASS_NAME, true); setControl(composite); //set default and focus fClassToTestText.setText(fDefaultClassToTest); restoreWidgetValues(); Dialog.applyDialogFont(composite); WorkbenchHelp.setHelp(composite, IJUnitHelpContextIds.NEW_TESTCASE_WIZARD_PAGE); } protected void createMethodStubSelectionControls(Composite composite, int nColumns) { LayoutUtil.setHorizontalSpan(fMethodStubsButtons.getLabelControl(composite), nColumns); LayoutUtil.createEmptySpace(composite,1); LayoutUtil.setHorizontalSpan(fMethodStubsButtons.getSelectionButtonsGroup(composite), nColumns - 1); } protected void createClassToTestControls(Composite composite, int nColumns) { fClassToTestLabel= new Label(composite, SWT.LEFT | SWT.WRAP); fClassToTestLabel.setFont(composite.getFont()); fClassToTestLabel.setText(WizardMessages.getString("NewTestClassWizPage.class_to_test.label")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= 1; fClassToTestLabel.setLayoutData(gd); fClassToTestText= new Text(composite, SWT.SINGLE | SWT.BORDER); fClassToTestText.setEnabled(true); fClassToTestText.setFont(composite.getFont()); fClassToTestText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleFieldChanged(CLASS_TO_TEST); } }); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; gd.grabExcessHorizontalSpace= true; gd.horizontalSpan= nColumns - 2; fClassToTestText.setLayoutData(gd); fClassToTestButton= new Button(composite, SWT.PUSH); fClassToTestButton.setText(WizardMessages.getString("NewTestClassWizPage.class_to_test.browse")); //$NON-NLS-1$ fClassToTestButton.setEnabled(true); fClassToTestButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { classToTestButtonPressed(); } public void widgetSelected(SelectionEvent e) { classToTestButtonPressed(); } }); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; gd.grabExcessHorizontalSpace= false; gd.horizontalSpan= 1; gd.heightHint = SWTUtil.getButtonHeigthHint(fClassToTestButton); gd.widthHint = SWTUtil.getButtonWidthHint(fClassToTestButton); fClassToTestButton.setLayoutData(gd); } private void classToTestButtonPressed() { IType type= chooseClassToTestType(); if (type != null) { fClassToTestText.setText(JavaModelUtil.getFullyQualifiedName(type)); handleFieldChanged(CLASS_TO_TEST); } } private IType chooseClassToTestType() { IPackageFragmentRoot root= getPackageFragmentRoot(); if (root == null) return null; IJavaElement[] elements= new IJavaElement[] { root.getJavaProject() }; IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); IType type= null; try { SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), getWizard().getContainer(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, null); dialog.setTitle(WizardMessages.getString("NewTestClassWizPage.class_to_test.dialog.title")); //$NON-NLS-1$ dialog.setMessage(WizardMessages.getString("NewTestClassWizPage.class_to_test.dialog.message")); //$NON-NLS-1$ dialog.open(); if (dialog.getReturnCode() != SelectionDialog.OK) return type; else { Object[] resultArray= dialog.getResult(); if (resultArray != null && resultArray.length > 0) type= (IType) resultArray[0]; } } catch (JavaModelException e) { JUnitPlugin.log(e); } return type; } protected IStatus classToTestClassChanged() { fClassToTestButton.setEnabled(getPackageFragmentRoot() != null); IStatus status= validateClassToTest(); return status; } /** * Returns the content of the class to test text field. */ public String getClassToTestText() { return fClassToTestText.getText(); } /** * Returns the class to be tested. */ public IType getClassToTest() { return fClassToTest; } /** * Sets the name of the class to test. */ public void setClassToTest(String name) { fClassToTestText.setText(name); } /** * @see NewTypeWizardPage#createTypeMembers */ protected void createTypeMembers(IType type, ImportsManager imports, IProgressMonitor monitor) throws CoreException { fIndexOfFirstTestMethod= 0; createConstructor(type, imports); if (fMethodStubsButtons.isSelected(0)) createMain(type); if (fMethodStubsButtons.isSelected(2)) { createSetUp(type, imports); } if (fMethodStubsButtons.isSelected(3)) { createTearDown(type, imports); } if (isNextPageValid()) { createTestMethodStubs(type); } } protected void createConstructor(IType type, ImportsManager imports) throws JavaModelException { ITypeHierarchy typeHierarchy= null; IType[] superTypes= null; String constr= ""; //$NON-NLS-1$ IMethod methodTemplate= null; if (type.exists()) { typeHierarchy= type.newSupertypeHierarchy(null); superTypes= typeHierarchy.getAllSuperclasses(type); for (int i= 0; i < superTypes.length; i++) { if (superTypes[i].exists()) { IMethod constrMethod= superTypes[i].getMethod(superTypes[i].getElementName(), new String[] {"Ljava.lang.String;"}); //$NON-NLS-1$ if (constrMethod.exists() && constrMethod.isConstructor()) { methodTemplate= constrMethod; break; } } } } CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); if (methodTemplate != null) { GenStubSettings genStubSettings= new GenStubSettings(settings); genStubSettings.fCallSuper= true; genStubSettings.fMethodOverwrites= true; constr= JUnitStubUtility.genStub(getTypeName(), methodTemplate, genStubSettings, imports); } else { constr += "public "+getTypeName()+"(String name) {" + //$NON-NLS-1$ //$NON-NLS-2$ getLineDelimiter() + "super(name);" + //$NON-NLS-1$ getLineDelimiter() + "}" + //$NON-NLS-1$ getLineDelimiter() + getLineDelimiter(); } type.createMethod(constr, null, true, null); fIndexOfFirstTestMethod++; } protected void createMain(IType type) throws JavaModelException { type.createMethod(fMethodStubsButtons.getMainMethod(getTypeName()), null, false, null); fIndexOfFirstTestMethod++; } protected void createSetUp(IType type, ImportsManager imports) throws JavaModelException { ITypeHierarchy typeHierarchy= null; IType[] superTypes= null; String setUp= ""; //$NON-NLS-1$ IMethod methodTemplate= null; if (type.exists()) { typeHierarchy= type.newSupertypeHierarchy(null); superTypes= typeHierarchy.getAllSuperclasses(type); for (int i= 0; i < superTypes.length; i++) { if (superTypes[i].exists()) { IMethod testMethod= superTypes[i].getMethod(SETUP, new String[] {}); if (testMethod.exists()) { methodTemplate= testMethod; break; } } } } CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); if (methodTemplate != null) { GenStubSettings genStubSettings= new GenStubSettings(settings); genStubSettings.fCallSuper= true; genStubSettings.fMethodOverwrites= true; setUp= JUnitStubUtility.genStub(getTypeName(), methodTemplate, genStubSettings, imports); } else { if (settings.createComments) setUp= "/**" + //$NON-NLS-1$ getLineDelimiter() + " * Sets up the fixture, for example, open a network connection." + //$NON-NLS-1$ getLineDelimiter() + " * This method is called before a test is executed." + //$NON-NLS-1$ getLineDelimiter() + " * @throws Exception" + //$NON-NLS-1$ getLineDelimiter() + " */" + //$NON-NLS-1$ getLineDelimiter(); setUp+= "protected void "+SETUP+"() throws Exception {}" + //$NON-NLS-1$ //$NON-NLS-2$ getLineDelimiter() + getLineDelimiter(); } type.createMethod(setUp, null, false, null); fIndexOfFirstTestMethod++; } protected void createTearDown(IType type, ImportsManager imports) throws JavaModelException { ITypeHierarchy typeHierarchy= null; IType[] superTypes= null; String tearDown= ""; //$NON-NLS-1$ IMethod methodTemplate= null; if (type.exists()) { if (typeHierarchy == null) { typeHierarchy= type.newSupertypeHierarchy(null); superTypes= typeHierarchy.getAllSuperclasses(type); } for (int i= 0; i < superTypes.length; i++) { if (superTypes[i].exists()) { IMethod testM= superTypes[i].getMethod(TEARDOWN, new String[] {}); if (testM.exists()) { methodTemplate= testM; break; } } } } CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(); if (methodTemplate != null) { GenStubSettings genStubSettings= new GenStubSettings(settings); genStubSettings.fCallSuper= true; genStubSettings.fMethodOverwrites= true; tearDown= JUnitStubUtility.genStub(getTypeName(), methodTemplate, genStubSettings, imports); type.createMethod(tearDown, null, false, null); fIndexOfFirstTestMethod++; } } protected void createTestMethodStubs(IType type) throws JavaModelException { IMethod[] methods= fPage2.getCheckedMethods(); if (methods.length == 0) return; /* find overloaded methods */ IMethod[] allMethodsArray= fPage2.getAllMethods(); List allMethods= new ArrayList(); allMethods.addAll(Arrays.asList(allMethodsArray)); List overloadedMethods= getOveloadedMethods(allMethods); /* used when for example both sum and Sum methods are present. Then * sum -> testSum * Sum -> testSum1 */ List newMethodsNames= new ArrayList(); for (int i = 0; i < methods.length; i++) { IMethod testedMethod= methods[i]; String elementName= testedMethod.getElementName(); StringBuffer methodName= new StringBuffer(NewTestCaseCreationWizardPage2.PREFIX+Character.toUpperCase(elementName.charAt(0))+elementName.substring(1)); StringBuffer newMethod= new StringBuffer(); if (overloadedMethods.contains(testedMethod)) { appendMethodComment(newMethod, testedMethod); String[] params= testedMethod.getParameterTypes(); appendParameterNamesToMethodName(methodName, params); } /* Should I for examples have methods * void foo(java.lang.StringBuffer sb) {} * void foo(mypackage1.StringBuffer sb) {} * void foo(mypackage2.StringBuffer sb) {} * I will get in the test class: * testFooStringBuffer() * testFooStringBuffer1() * testFooStringBuffer2() */ if (newMethodsNames.contains(methodName.toString())) { int suffix= 1; while (newMethodsNames.contains(methodName.toString() + Integer.toString(suffix))) suffix++; methodName.append(Integer.toString(suffix)); } newMethodsNames.add(methodName.toString()); if (fPage2.getCreateFinalMethodStubsButtonSelection()) newMethod.append("final "); //$NON-NLS-1$ newMethod.append("public void ");//$NON-NLS-1$ newMethod.append(methodName.toString()); newMethod.append("()");//$NON-NLS-1$ appendTestMethodBody(newMethod, testedMethod); type.createMethod(newMethod.toString(), null, false, null); } } private String getLineDelimiter(){ IType classToTest= getClassToTest(); if (classToTest != null && classToTest.exists()) return JUnitStubUtility.getLineDelimiterUsed(classToTest); else return JUnitStubUtility.getLineDelimiterUsed(getPackageFragment()); } private void appendTestMethodBody(StringBuffer newMethod, IMethod testedMethod) { newMethod.append("{"); //$NON-NLS-1$ if (createTasks()){ newMethod.append(getLineDelimiter()); newMethod.append("//"); //$NON-NLS-1$ newMethod.append(JUnitStubUtility.getTodoTaskTag(getPackageFragment().getJavaProject())); newMethod.append(WizardMessages.getFormattedString("NewTestClassWizPage.marker.message", testedMethod.getElementName())); //$NON-NLS-1$ newMethod.append(getLineDelimiter()); } newMethod.append("}").append(getLineDelimiter()).append(getLineDelimiter()); //$NON-NLS-1$ } public void appendParameterNamesToMethodName(StringBuffer methodName, String[] params) { for (int i= 0; i < params.length; i++) { String param= params[i]; methodName.append(Signature.getSimpleName(Signature.toString(Signature.getElementType(param)))); for (int j= 0, arrayCount= Signature.getArrayCount(param); j < arrayCount; j++) { methodName.append("Array"); //$NON-NLS-1$ } } } private void appendMethodComment(StringBuffer newMethod, IMethod method) throws JavaModelException { String returnType= Signature.toString(method.getReturnType()); String body= WizardMessages.getFormattedString("NewTestClassWizPage.comment.class_to_test", new String[]{returnType, method.getElementName()}); //$NON-NLS-1$ newMethod.append("/*");//$NON-NLS-1$ newMethod.append(getLineDelimiter()); newMethod.append(" * ");//$NON-NLS-1$ newMethod.append(body); newMethod.append("(");//$NON-NLS-1$ String[] paramTypes= method.getParameterTypes(); if (paramTypes.length > 0) { if (paramTypes.length > 1) { for (int j= 0; j < paramTypes.length-1; j++) { newMethod.append(Signature.toString(paramTypes[j])+", "); //$NON-NLS-1$ } } newMethod.append(Signature.toString(paramTypes[paramTypes.length-1])); } newMethod.append(")");//$NON-NLS-1$ newMethod.append(getLineDelimiter()); newMethod.append(" */");//$NON-NLS-1$ newMethod.append(getLineDelimiter()); } private List getOveloadedMethods(List allMethods) { List overloadedMethods= new ArrayList(); for (int i= 0; i < allMethods.size(); i++) { IMethod current= (IMethod) allMethods.get(i); String currentName= current.getElementName(); boolean currentAdded= false; for (ListIterator iter= allMethods.listIterator(i+1); iter.hasNext(); ) { IMethod iterMethod= (IMethod) iter.next(); if (iterMethod.getElementName().equals(currentName)) { //method is overloaded if (!currentAdded) { overloadedMethods.add(current); currentAdded= true; } overloadedMethods.add(iterMethod); iter.remove(); } } } return overloadedMethods; } /** * @see DialogPage#setVisible(boolean) */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible && fFirstTime) { handleFieldChanged(CLASS_TO_TEST); //creates error message when wizard is opened if TestCase already exists if (getClassToTestText().equals("")) //$NON-NLS-1$ setPageComplete(false); fFirstTime= false; } if (visible) setFocus(); } private void validateJUnitOnBuildPath() { IPackageFragmentRoot root= getPackageFragmentRoot(); if (root == null) return; IJavaProject jp= root.getJavaProject(); try { if (jp.findType(JUnitPlugin.TEST_SUPERCLASS_NAME) != null) return; } catch (JavaModelException e) { } JUnitStatus status= new JUnitStatus(); status.setError(WizardMessages.getString("NewTestClassWizPage.error.junitNotOnbuildpath")); //$NON-NLS-1$ fContainerStatus= status; } /** * Returns the index of the first method that is a test method, i.e. excluding main, setUp() and tearDown(). * If none of the aforementioned method stubs is created, then 0 is returned. As such method stubs are created, * this counter is incremented. */ public int getIndexOfFirstMethod() { return fIndexOfFirstTestMethod; } private boolean createTasks() { return fPage2.getCreateTasksButtonSelection(); } private void validateSuperClass() { fMethodStubsButtons.setEnabled(2, true);//enable setUp() checkbox fMethodStubsButtons.setEnabled(3, true);//enable tearDown() checkbox String superClassName= getSuperClass(); if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$ fSuperClassStatus= new JUnitStatus(); ((JUnitStatus)fSuperClassStatus).setError("Super class name is empty"); //$NON-NLS-1$ return; } if (getPackageFragmentRoot() != null) { //$NON-NLS-1$ try { IType type= resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName); JUnitStatus status = new JUnitStatus(); if (type == null) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.superclass.not_exist")); //$NON-NLS-1$ fSuperClassStatus= status; } else { if (type.isInterface()) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.superclass.is_interface")); //$NON-NLS-1$ fSuperClassStatus= status; } if (!TestSearchEngine.isTestImplementor(type)) { status.setError(WizardMessages.getFormattedString("NewTestClassWizPage.error.superclass.not_implementing_test_interface", JUnitPlugin.TEST_INTERFACE_NAME)); //$NON-NLS-1$ fSuperClassStatus= status; } else { IMethod setupMethod= type.getMethod(SETUP, new String[] {}); IMethod teardownMethod= type.getMethod(TEARDOWN, new String[] {}); if (setupMethod.exists()) fMethodStubsButtons.setEnabled(2, !Flags.isFinal(setupMethod.getFlags())); if (teardownMethod.exists()) fMethodStubsButtons.setEnabled(3, !Flags.isFinal(teardownMethod.getFlags())); } } } catch (JavaModelException e) { JUnitPlugin.log(e); } } } protected void createTestClassControls(Composite composite, int nColumns) { fTestClassLabel= new Label(composite, SWT.LEFT | SWT.WRAP); fTestClassLabel.setFont(composite.getFont()); fTestClassLabel.setText(WizardMessages.getString("NewTestClassWizPage.testcase.label")); //$NON-NLS-1$ GridData gd= new GridData(); gd.horizontalSpan= 1; fTestClassLabel.setLayoutData(gd); fTestClassText= new Text(composite, SWT.SINGLE | SWT.BORDER); fTestClassText.setEnabled(true); fTestClassText.setFont(composite.getFont()); fTestClassText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleFieldChanged(TEST_CLASS); } }); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; gd.grabExcessHorizontalSpace= true; gd.horizontalSpan= nColumns - 2; fTestClassText.setLayoutData(gd); Label space= new Label(composite, SWT.LEFT); space.setText(" "); //$NON-NLS-1$ gd= new GridData(); gd.horizontalSpan= 1; space.setLayoutData(gd); } /** * Gets the type name. */ public String getTypeName() { return (fTestClassText==null)?fTestClassTextInitialValue:fTestClassText.getText(); } /** * Sets the type name. */ public void setTypeName(String name, boolean canBeModified) { if (fTestClassText == null) { fTestClassTextInitialValue= name; } else { fTestClassText.setText(name); fTestClassText.setEnabled(canBeModified); } } /** * Called when the type name has changed. * The method validates the type name and returns the status of the validation. * Can be extended to add more validation */ protected IStatus testClassChanged() { JUnitStatus status= new JUnitStatus(); String typeName= getTypeName(); // must not be empty if (typeName.length() == 0) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.testcase.name_empty")); //$NON-NLS-1$ return status; } if (typeName.indexOf('.') != -1) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.testcase.name_qualified")); //$NON-NLS-1$ return status; } IStatus val= JavaConventions.validateJavaTypeName(typeName); if (val.getSeverity() == IStatus.ERROR) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.testcase.name_not_valid")+val.getMessage()); //$NON-NLS-1$ return status; } else if (val.getSeverity() == IStatus.WARNING) { status.setWarning(WizardMessages.getString("NewTestClassWizPage.error.testcase.name_discouraged")+val.getMessage()); //$NON-NLS-1$ // continue checking } IPackageFragment pack= getPackageFragment(); if (pack != null) { ICompilationUnit cu= pack.getCompilationUnit(typeName + ".java"); //$NON-NLS-1$ if (cu.exists()) { status.setError(WizardMessages.getFormattedString("NewTestClassWizPage.error.testcase.already_exists", typeName));//$NON-NLS-1$ return status; } } return status; } /** * @see IWizardPage#canFlipToNextPage */ public boolean canFlipToNextPage() { return isPageComplete() && getNextPage() != null && isNextPageValid(); } protected boolean isNextPageValid() { return !getClassToTestText().equals(""); //$NON-NLS-1$ } protected JUnitStatus validateClassToTest() { IPackageFragmentRoot root= getPackageFragmentRoot(); IPackageFragment pack= getPackageFragment(); String classToTestName= fClassToTestText.getText(); JUnitStatus status= new JUnitStatus(); fClassToTest= null; if (classToTestName.length() == 0) { return status; } IStatus val= JavaConventions.validateJavaTypeName(classToTestName); // if (!val.isOK()) { if (val.getSeverity() == IStatus.ERROR) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.class_to_test.not_valid")); //$NON-NLS-1$ return status; } if (root != null) { try { IType type= NewTestCaseCreationWizardPage.resolveClassNameToType(root.getJavaProject(), pack, classToTestName); //IType type= wizpage.resolveClassToTestName(); if (type == null) { //status.setWarning("Warning: "+typeLabel+" does not exist in current project."); status.setError(WizardMessages.getString("NewTestClassWizPage.error.class_to_test.not_exist")); //$NON-NLS-1$ return status; } else { if (type.isInterface()) { status.setWarning(WizardMessages.getFormattedString("NewTestClassWizPage.warning.class_to_test.is_interface",classToTestName)); //$NON-NLS-1$ } if (pack != null && !JavaModelUtil.isVisible(type, pack)) { status.setWarning(WizardMessages.getFormattedString("NewTestClassWizPage.warning.class_to_test.not_visible", new String[] {(type.isInterface())?WizardMessages.getString("Interface"):WizardMessages.getString("Class") , classToTestName})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } fClassToTest= type; } catch (JavaModelException e) { status.setError(WizardMessages.getString("NewTestClassWizPage.error.class_to_test.not_valid")); //$NON-NLS-1$ } } else { status.setError(""); //$NON-NLS-1$ } return status; } static public IType resolveClassNameToType(IJavaProject jproject, IPackageFragment pack, String classToTestName) throws JavaModelException { IType type= null; if (type == null && pack != null) { String packName= pack.getElementName(); // search in own package if (!pack.isDefaultPackage()) { type= jproject.findType(packName, classToTestName); } // search in java.lang if (type == null && !"java.lang".equals(packName)) { //$NON-NLS-1$ type= jproject.findType("java.lang", classToTestName); //$NON-NLS-1$ } } // search fully qualified if (type == null) { type= jproject.findType(classToTestName); } return type; } /** * Sets the focus on the type name. */ protected void setFocus() { fTestClassText.setFocus(); fTestClassText.setSelection(fTestClassText.getText().length(), fTestClassText.getText().length()); } /** * Use the dialog store to restore widget values to the values that they held * last time this wizard was used to completion */ private void restoreWidgetValues() { IDialogSettings settings= getDialogSettings(); if (settings != null) { boolean generateMain= settings.getBoolean(STORE_GENERATE_MAIN); fMethodStubsButtons.setSelection(0, generateMain); fMethodStubsButtons.setEnabled(1, generateMain); fMethodStubsButtons.setSelection(1,settings.getBoolean(STORE_USE_TESTRUNNER)); try { fMethodStubsButtons.setComboSelection(settings.getInt(STORE_TESTRUNNER_TYPE)); } catch(NumberFormatException e) {} } } /** * Since Finish was pressed, write widget values to the dialog store so that they * will persist into the next invocation of this wizard page */ void saveWidgetValues() { IDialogSettings settings= getDialogSettings(); if (settings != null) { settings.put(STORE_GENERATE_MAIN, fMethodStubsButtons.isSelected(0)); settings.put(STORE_USE_TESTRUNNER, fMethodStubsButtons.isSelected(1)); settings.put(STORE_TESTRUNNER_TYPE, fMethodStubsButtons.getComboSelection()); } } }
36,511
Bug 36511 call hierarchy: details list should be a table with icons
details list should be a table with icons - we can reuse the icons used by 'find in file'
resolved fixed
199db99
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-16T12:26:08Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private ListViewer fLocationViewer; private Menu fLocationContextMenu; private Menu fTreeContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenDeclarationAction fOpenDeclarationAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } public void createPartControl(Composite parent) { // setTitle("Call Hierarchy"); fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationList(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fTreeContextMenu); disposeMenu(fLocationContextMenu); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { // if (event.keyCode == SWT.F3) { // if ((fOpenDeclarationAction != null) && // fOpenDeclarationAction.isEnabled()) { // fOpenDeclarationAction.run(); // return; // } // } else if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationList(Composite parent) { fLocationViewer = new ListViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); toolBar.add(fRefreshAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fOpenDeclarationAction = new OpenDeclarationAction(this.getSite()); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(this), new RefactorActionGroup(this), fSearchScopeActions, fFiltersActionGroup }); } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,511
Bug 36511 call hierarchy: details list should be a table with icons
details list should be a table with icons - we can reuse the icons used by 'find in file'
resolved fixed
199db99
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-16T12:26:08Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/LocationLabelProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; class LocationLabelProvider extends LabelProvider { /* (non-Javadoc) * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ public String getText(Object element) { if (element instanceof CallLocation) { CallLocation callLocation = (CallLocation) element; return removeWhitespaceOutsideStringLiterals(callLocation.toString()); } return super.getText(element); } /** * @param string * @return String */ private String removeWhitespaceOutsideStringLiterals(String s) { StringBuffer buf = new StringBuffer(); boolean withinString = false; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '"') { withinString = !withinString; } if (withinString) { buf.append(ch); } else if (Character.isWhitespace(ch)) { if ((buf.length() == 0) || !Character.isWhitespace(buf.charAt(buf.length() - 1))) { if (ch != ' ') { ch = ' '; } buf.append(ch); } } else { buf.append(ch); } } return buf.toString(); } }
36,511
Bug 36511 call hierarchy: details list should be a table with icons
details list should be a table with icons - we can reuse the icons used by 'find in file'
resolved fixed
199db99
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-16T12:26:08Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.window.Window; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.ui.IContextMenuConstants; class SearchScopeActionGroup extends ActionGroup { private SearchScopeAction fSelectedAction = null; private String fSelectedWorkingSetName = null; private CallHierarchyViewPart fView; private SearchScopeHierarchyAction fSearchScopeHierarchyAction; private SearchScopeProjectAction fSearchScopeProjectAction; private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction; private SelectWorkingSetAction fSelectWorkingSetAction; private abstract class SearchScopeAction extends Action { public SearchScopeAction(String text) { super(text); } public abstract IJavaSearchScope getSearchScope(); public void run() { setSelected(this); } } private class SearchScopeHierarchyAction extends SearchScopeAction { public SearchScopeHierarchyAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { try { IMethod method = getView().getMethod(); if (method != null) { return SearchEngine.createHierarchyScope(method.getDeclaringType()); } else { return null; } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } } private class SearchScopeProjectAction extends SearchScopeAction { public SearchScopeProjectAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.project.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.project.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { IMethod method = getView().getMethod(); IJavaProject project = null; if (method != null) { project = method.getJavaProject(); } if (project != null) { return SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, false); } else { return null; } } } private class SearchScopeWorkingSetAction extends SearchScopeAction { private IWorkingSet mWorkingSet; public SearchScopeWorkingSetAction(IWorkingSet workingSet) { super(workingSet.getName()); setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.tooltip")); //$NON-NLS-1$ this.mWorkingSet = workingSet; } public IJavaSearchScope getSearchScope() { return SearchEngine.createJavaSearchScope(getJavaElements( mWorkingSet.getElements())); } /** * */ public IWorkingSet getWorkingSet() { return mWorkingSet; } /** * @param adaptables * @return IResource[] */ private IJavaElement[] getJavaElements(IAdaptable[] adaptables) { Collection result = new ArrayList(); for (int i = 0; i < adaptables.length; i++) { IJavaElement element = (IJavaElement) adaptables[i].getAdapter(IJavaElement.class); if (element != null) { result.add(element); } } return (IJavaElement[]) result.toArray(new IJavaElement[result.size()]); } } private class SearchScopeWorkspaceAction extends SearchScopeAction { public SearchScopeWorkspaceAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { return SearchEngine.createWorkspaceScope(); } } private class SelectWorkingSetAction extends Action { public SelectWorkingSetAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.tooltip")); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ public void run() { IWorkingSetManager workingSetManager = getWorkingSetManager(); IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getShell(), false); IWorkingSet workingSet = getActiveWorkingSet(); if (workingSet != null) { dialog.setSelection(new IWorkingSet[] { workingSet }); } if (dialog.open() == Window.OK) { IWorkingSet[] result = dialog.getSelection(); if ((result != null) && (result.length > 0)) { setActiveWorkingSet(result[0]); workingSetManager.addRecentWorkingSet(result[0]); } else { setActiveWorkingSet(null); } } } } public SearchScopeActionGroup(CallHierarchyViewPart view) { this.fView = view; createActions(); } /** * @return IJavaSearchScope */ public IJavaSearchScope getSearchScope() { if (fSelectedAction != null) { return fSelectedAction.getSearchScope(); } return null; } public void fillActionBars(IActionBars actionBars) { super.fillActionBars(actionBars); fillViewMenu(actionBars.getMenuManager()); } public void fillContextMenu(IMenuManager menu) { // MenuManager javaSearchMM = new MenuManager(MENU_TEXT, // ICallHierarchyConstants.GROUP_SEARCH_SCOPE); // // javaSearchMM.addMenuListener(new IMenuListener() { // /* (non-Javadoc) // * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) // */ // public void menuAboutToShow(IMenuManager manager) { // fillSearchActions(manager); // } // }); // menu.appendToGroup(ICallHierarchyConstants.GROUP_SEARCH_SCOPE, javaSearchMM); } /** * @param set * @param b */ protected void setActiveWorkingSet(IWorkingSet set) { if (set != null) { fSelectedWorkingSetName = set.getName(); fSelectedAction = new SearchScopeWorkingSetAction(set); } else { fSelectedWorkingSetName = null; fSelectedAction = null; } } /** * @return */ protected IWorkingSet getActiveWorkingSet() { if (fSelectedWorkingSetName != null) { return getWorkingSetManager().getWorkingSet(fSelectedWorkingSetName); } return null; } protected void setSelected(SearchScopeAction newSelection) { if (newSelection instanceof SearchScopeWorkingSetAction) { fSelectedWorkingSetName = ((SearchScopeWorkingSetAction) newSelection).getWorkingSet() .getName(); } else { fSelectedWorkingSetName = null; } fSelectedAction = newSelection; } /** * @return CallHierarchyViewPart */ protected CallHierarchyViewPart getView() { return fView; } protected IWorkingSetManager getWorkingSetManager() { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); return workingSetManager; } protected void fillSearchActions(IMenuManager javaSearchMM) { javaSearchMM.removeAll(); Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action action = actions[i]; if (action.isEnabled()) { javaSearchMM.add(action); } } javaSearchMM.setVisible(!javaSearchMM.isEmpty()); } void fillViewMenu(IMenuManager menu) { menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.getString("SearchScopeActionGroup.searchScope"), //$NON-NLS-1$ IContextMenuConstants.GROUP_SEARCH); javaSearchMM.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillSearchActions(manager); } }); menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM); } /** * @return SearchScopeAction[] */ private Action[] getActions() { List actions = new ArrayList(); addAction(actions, fSearchScopeWorkspaceAction); addAction(actions, fSearchScopeProjectAction); addAction(actions, fSearchScopeHierarchyAction); addAction(actions, fSelectWorkingSetAction); IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); IWorkingSet[] sets = workingSetManager.getRecentWorkingSets(); for (int i = 0; i < sets.length; i++) { SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(sets[i]); if (sets[i].getName().equals(fSelectedWorkingSetName)) { workingSetAction.setChecked(true); } actions.add(workingSetAction); } return (Action[]) actions.toArray(new Action[actions.size()]); } private void addAction(List actions, Action action) { if (action == fSelectedAction) { action.setChecked(true); } else { action.setChecked(false); } actions.add(action); } /** * @param view */ private void createActions() { fSearchScopeWorkspaceAction = new SearchScopeWorkspaceAction(); fSelectWorkingSetAction = new SelectWorkingSetAction(); fSearchScopeHierarchyAction = new SearchScopeHierarchyAction(); fSearchScopeProjectAction = new SearchScopeProjectAction(); setSelected(fSearchScopeWorkspaceAction); } }
36,554
Bug 36554 JDT/UI plugin activation fails when activated in non UI thread
2.1 Activating the JDT/UI plug-in in a non UI thread fails with an SWT.Error. The stack trace is: org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:2332) at org.eclipse.swt.SWT.error(SWT.java:2262) at org.eclipse.swt.widgets.Widget.error(Widget.java:385) at org.eclipse.swt.widgets.Shell.<init>(Shell.java:246) at org.eclipse.swt.widgets.Shell.<init>(Shell.java:237) at org.eclipse.swt.widgets.Shell.<init>(Shell.java:190) at org.eclipse.swt.widgets.Shell.<init>(Shell.java:128) at org.eclipse.jface.resource.FontRegistry.defaultFont (FontRegistry.java:293) at org.eclipse.jface.resource.FontRegistry.get(FontRegistry.java:370) at org.eclipse.jface.resource.JFaceResources.getFont (JFaceResources.java:183) at org.eclipse.jdt.internal.ui.JavaPlugin.startup(JavaPlugin.java:241) at org.eclipse.core.internal.plugins.PluginDescriptor$1.run (PluginDescriptor.java:728) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:889) at org.eclipse.core.internal.plugins.PluginDescriptor.internalDoPluginActivation (PluginDescriptor.java:740) at org.eclipse.core.internal.plugins.PluginDescriptor.doPluginActivation (PluginDescriptor.java:188) at org.eclipse.core.internal.plugins.PluginClassLoader.activatePlugin (PluginClassLoader.java:112) at org.eclipse.core.internal.plugins.PluginClassLoader.internalFindClassParentsSel f(PluginClassLoader.java:185) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.findClassParentsSelf (DelegatingURLClassLoader.java:490) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass (DelegatingURLClassLoader.java:882) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.access$0 (DelegatingURLClassLoader.java:876) at org.eclipse.core.internal.boot.DelegatingURLClassLoader$DelegateLoader.loadClas s(DelegatingURLClassLoader.java:90) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.findClassPrerequisites (DelegatingURLClassLoader.java:554) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass (DelegatingURLClassLoader.java:890) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass (DelegatingURLClassLoader.java:862) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at org.eclipse.core.internal.plugins.PluginDescriptor.internalDoPluginActivation (PluginDescriptor.java:701) at org.eclipse.core.internal.plugins.PluginDescriptor.doPluginActivation (PluginDescriptor.java:188) at org.eclipse.core.internal.plugins.PluginClassLoader.activatePlugin (PluginClassLoader.java:112) at org.eclipse.core.internal.plugins.PluginClassLoader.internalFindClassParentsSel f(PluginClassLoader.java:185) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.findClassParentsSelf (DelegatingURLClassLoader.java:485) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass (DelegatingURLClassLoader.java:882) at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass (DelegatingURLClassLoader.java:862) at java.lang.ClassLoader.loadClass(Unknown Source) at org.eclipse.core.internal.plugins.PluginDescriptor.createExecutableExtension (PluginDescriptor.java:130) at org.eclipse.core.internal.plugins.PluginDescriptor.createExecutableExtension (PluginDescriptor.java:167) at org.eclipse.core.internal.plugins.ConfigurationElement.createExecutableExtensio n(ConfigurationElement.java:103) at org.eclipse.core.internal.events.BuildManager.instantiateBuilder (BuildManager.java:555) at org.eclipse.core.internal.events.BuildManager.initializeBuilder (BuildManager.java:509) at org.eclipse.core.internal.events.BuildManager.getBuilder (BuildManager.java:359) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:170) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:191) at org.eclipse.core.internal.events.BuildManager$1.run (BuildManager.java:151) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:889) at org.eclipse.core.runtime.Platform.run(Platform.java:413) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:165) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop (BuildManager.java:243) at org.eclipse.core.internal.events.BuildManager.build (BuildManager.java:212) at org.eclipse.core.internal.resources.Workspace.endOperation (Workspace.java:884) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1600) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:85) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
verified fixed
64b6ec8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-16T14:55:59Z
2003-04-16T08:00:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.IWorkingCopyManager; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; import org.eclipse.jdt.internal.ui.javaeditor.ClassFileDocumentProvider; import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider; import org.eclipse.jdt.internal.ui.javaeditor.WorkingCopyManager; import org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache; import org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor; import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry; import org.eclipse.jdt.internal.ui.viewsupport.ProblemMarkerManager; /** * Represents the java plugin. It provides a series of convenience methods such as * access to the workbench, keeps track of elements shared by all editors and viewers * of the plugin such as document providers and find-replace-dialogs. */ public class JavaPlugin extends AbstractUIPlugin { private static JavaPlugin fgJavaPlugin; private IWorkingCopyManager fWorkingCopyManager; private CompilationUnitDocumentProvider fCompilationUnitDocumentProvider; private ClassFileDocumentProvider fClassFileDocumentProvider; private JavaTextTools fJavaTextTools; private ProblemMarkerManager fProblemMarkerManager; private ImageDescriptorRegistry fImageDescriptorRegistry; private JavaElementAdapterFactory fJavaElementAdapterFactory; private MarkerAdapterFactory fMarkerAdapterFactory; private EditorInputAdapterFactory fEditorInputAdapterFactory; private ResourceAdapterFactory fResourceAdapterFactory; private LogicalPackageAdapterFactory fLogicalPackageAdapterFactory; private MembersOrderPreferenceCache fMembersOrderPreferenceCache; private IPropertyChangeListener fFontPropertyChangeListener; private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors; public static JavaPlugin getDefault() { return fgJavaPlugin; } public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } public static IWorkbenchPage getActivePage() { return getDefault().internalGetActivePage(); } public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } public static Shell getActiveWorkbenchShell() { return getActiveWorkbenchWindow().getShell(); } /** * Returns an array of all editors that have an unsaved content. If the identical content is * presented in more than one editor, only one of those editor parts is part of the result. * * @return an array of all dirty editor parts. */ public static IEditorPart[] getDirtyEditors() { Set inputs= new HashSet(); List result= new ArrayList(0); IWorkbench workbench= getDefault().getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchPage[] pages= windows[i].getPages(); for (int x= 0; x < pages.length; x++) { IEditorPart[] editors= pages[x].getDirtyEditors(); for (int z= 0; z < editors.length; z++) { IEditorPart ep= editors[z]; IEditorInput input= ep.getEditorInput(); if (!inputs.contains(input)) { inputs.add(input); result.add(ep); } } } } return (IEditorPart[])result.toArray(new IEditorPart[result.size()]); } /** * Returns an array of all instanciated editors. */ public static IEditorPart[] getInstanciatedEditors() { List result= new ArrayList(0); IWorkbench workbench= getDefault().getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int windowIndex= 0; windowIndex < windows.length; windowIndex++) { IWorkbenchPage[] pages= windows[windowIndex].getPages(); for (int pageIndex= 0; pageIndex < pages.length; pageIndex++) { IEditorReference[] references= pages[pageIndex].getEditorReferences(); for (int refIndex= 0; refIndex < references.length; refIndex++) { IEditorPart editor= references[refIndex].getEditor(false); if (editor != null) result.add(editor); } } } return (IEditorPart[])result.toArray(new IEditorPart[result.size()]); } public static String getPluginId() { return getDefault().getDescriptor().getUniqueIdentifier(); } public static void log(IStatus status) { getDefault().getLog().log(status); } public static void logErrorMessage(String message) { log(new Status(IStatus.ERROR, getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null)); } public static void logErrorStatus(String message, IStatus status) { if (status == null) { logErrorMessage(message); return; } MultiStatus multi= new MultiStatus(getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null); multi.add(status); log(multi); } public static void log(Throwable e) { log(new Status(IStatus.ERROR, getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$ } public static boolean isDebug() { return getDefault().isDebugging(); } /* package */ static IPath getInstallLocation() { return new Path(getDefault().getDescriptor().getInstallURL().getFile()); } public static ImageDescriptorRegistry getImageDescriptorRegistry() { return getDefault().internalGetImageDescriptorRegistry(); } public JavaPlugin(IPluginDescriptor descriptor) { super(descriptor); fgJavaPlugin= this; } /* (non - Javadoc) * Method declared in Plugin */ public void startup() throws CoreException { super.startup(); registerAdapters(); /* * Backward compatibility: propagate the Java editor font from a * pre-2.1 plug-in to the Platform UI's preference store to preserve * the Java editor font from a pre-2.1 workspace. This is done only * once. */ String fontPropagatedKey= "fontPropagated"; //$NON-NLS-1$ if (getPreferenceStore().contains(JFaceResources.TEXT_FONT) && !getPreferenceStore().isDefault(JFaceResources.TEXT_FONT)) { if (!getPreferenceStore().getBoolean(fontPropagatedKey)) PreferenceConverter.setValue(PlatformUI.getWorkbench().getPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(getPreferenceStore(), JFaceResources.TEXT_FONT)); } getPreferenceStore().setValue(fontPropagatedKey, true); /* * Backward compatibility: set the Java editor font in this plug-in's * preference store to let older versions access it. Since 2.1 the * Java editor font is managed by the workbench font preference page. */ PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT).getFontData()); fFontPropertyChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT).getFontData()); } }; JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); } /* (non - Javadoc) * Method declared in AbstractUIPlugin */ protected ImageRegistry createImageRegistry() { return JavaPluginImages.getImageRegistry(); } /* (non - Javadoc) * Method declared in Plugin */ public void shutdown() throws CoreException { if (fImageDescriptorRegistry != null) fImageDescriptorRegistry.dispose(); unregisterAdapters(); super.shutdown(); if (fWorkingCopyManager != null) { fWorkingCopyManager.shutdown(); fWorkingCopyManager= null; } if (fCompilationUnitDocumentProvider != null) { fCompilationUnitDocumentProvider.shutdown(); fCompilationUnitDocumentProvider= null; } if (fJavaTextTools != null) { fJavaTextTools.dispose(); fJavaTextTools= null; } JavaDocLocations.shutdownJavadocLocations(); JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); } private IWorkbenchPage internalGetActivePage() { IWorkbenchWindow window= getWorkbench().getActiveWorkbenchWindow(); if (window == null) return null; return getWorkbench().getActiveWorkbenchWindow().getActivePage(); } public synchronized CompilationUnitDocumentProvider getCompilationUnitDocumentProvider() { if (fCompilationUnitDocumentProvider == null) fCompilationUnitDocumentProvider= new CompilationUnitDocumentProvider(); return fCompilationUnitDocumentProvider; } public synchronized ClassFileDocumentProvider getClassFileDocumentProvider() { if (fClassFileDocumentProvider == null) fClassFileDocumentProvider= new ClassFileDocumentProvider(); return fClassFileDocumentProvider; } public synchronized IWorkingCopyManager getWorkingCopyManager() { if (fWorkingCopyManager == null) { CompilationUnitDocumentProvider provider= getCompilationUnitDocumentProvider(); fWorkingCopyManager= new WorkingCopyManager(provider); } return fWorkingCopyManager; } public synchronized ProblemMarkerManager getProblemMarkerManager() { if (fProblemMarkerManager == null) fProblemMarkerManager= new ProblemMarkerManager(); return fProblemMarkerManager; } public synchronized JavaTextTools getJavaTextTools() { if (fJavaTextTools == null) fJavaTextTools= new JavaTextTools(getPreferenceStore(), JavaCore.getPlugin().getPluginPreferences()); return fJavaTextTools; } public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() { if (fMembersOrderPreferenceCache == null) fMembersOrderPreferenceCache= new MembersOrderPreferenceCache(); return fMembersOrderPreferenceCache; } /** * Returns all Java editor text hovers contributed to the workbench. * * @return an array of JavaEditorTextHoverDescriptor * @since 2.1 */ public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() { if (fJavaEditorTextHoverDescriptors == null) fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers(); return fJavaEditorTextHoverDescriptors; } /** * Resets the Java editor text hovers contributed to the workbench. * <p> * This will force a rebuild of the descriptors the next time * a client asks for them. * </p> * * @return an array of JavaEditorTextHoverDescriptor * @since 2.1 */ public void resetJavaEditorTextHoverDescriptors() { fJavaEditorTextHoverDescriptors= null; } /** * Creates the Java plugin standard groups in a context menu. */ public static void createStandardGroups(IMenuManager menu) { if (!menu.isEmpty()) return; menu.add(new Separator(IContextMenuConstants.GROUP_NEW)); menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); menu.add(new Separator(IContextMenuConstants.GROUP_OPEN)); menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW)); menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE)); menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); menu.add(new Separator(IContextMenuConstants.GROUP_BUILD)); menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); } /** * @see AbstractUIPlugin#initializeDefaultPreferences */ protected void initializeDefaultPreferences(IPreferenceStore store) { super.initializeDefaultPreferences(store); PreferenceConstants.initializeDefaultValues(store); } private synchronized ImageDescriptorRegistry internalGetImageDescriptorRegistry() { if (fImageDescriptorRegistry == null) fImageDescriptorRegistry= new ImageDescriptorRegistry(); return fImageDescriptorRegistry; } private void registerAdapters() { fJavaElementAdapterFactory= new JavaElementAdapterFactory(); fMarkerAdapterFactory= new MarkerAdapterFactory(); fEditorInputAdapterFactory= new EditorInputAdapterFactory(); fResourceAdapterFactory= new ResourceAdapterFactory(); fLogicalPackageAdapterFactory= new LogicalPackageAdapterFactory(); IAdapterManager manager= Platform.getAdapterManager(); manager.registerAdapters(fJavaElementAdapterFactory, IJavaElement.class); manager.registerAdapters(fMarkerAdapterFactory, IMarker.class); manager.registerAdapters(fEditorInputAdapterFactory, IEditorInput.class); manager.registerAdapters(fResourceAdapterFactory, IResource.class); manager.registerAdapters(fLogicalPackageAdapterFactory, LogicalPackage.class); } private void unregisterAdapters() { IAdapterManager manager= Platform.getAdapterManager(); manager.unregisterAdapters(fJavaElementAdapterFactory); manager.unregisterAdapters(fMarkerAdapterFactory); manager.unregisterAdapters(fEditorInputAdapterFactory); manager.unregisterAdapters(fResourceAdapterFactory); manager.unregisterAdapters(fLogicalPackageAdapterFactory); } }
36,563
Bug 36563 call hierarchy: IllegalArgumentException after deleting a method
open call hierarchy and then delete the file for which you have it expanded then, try expanding another node boom java.lang.IllegalArgumentException at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:251) at org.eclipse.jdt.internal.corext.callhierarchy.CalleeMethodWrapper.findChildren (CalleeMethodWrapper.java:97) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.performSearch (MethodWrapper.java:287) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.doFindChildren (MethodWrapper.java:227) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.getCalls (MethodWrapper.java:85) at org.eclipse.jdt.internal.corext.callhierarchy.CalleeMethodWrapper.getCalls (CalleeMethodWrapper.java:66) at org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyContentProvider.getChildr en(CallHierarchyContentProvider.java:45) at org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren (AbstractTreeViewer.java:653) at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren (StructuredViewer.java:454) at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren (StructuredViewer.java:558) at org.eclipse.jface.viewers.AbstractTreeViewer$1.run (AbstractTreeViewer.java:301) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren (AbstractTreeViewer.java:289) at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand (AbstractTreeViewer.java:697) at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded (AbstractTreeViewer.java:709) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:177) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:849) at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:1894) at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:3814) at org.eclipse.swt.widgets.Composite.WM_NOTIFY(Composite.java:642) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java) at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java) at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:1502) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:61) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:40) at java.lang.reflect.Method.invoke(Method.java:335) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
resolved fixed
a2438be
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:39:32Z
2003-04-16T13:33:20Z
org.eclipse.jdt.ui/core
36,563
Bug 36563 call hierarchy: IllegalArgumentException after deleting a method
open call hierarchy and then delete the file for which you have it expanded then, try expanding another node boom java.lang.IllegalArgumentException at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:251) at org.eclipse.jdt.internal.corext.callhierarchy.CalleeMethodWrapper.findChildren (CalleeMethodWrapper.java:97) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.performSearch (MethodWrapper.java:287) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.doFindChildren (MethodWrapper.java:227) at org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper.getCalls (MethodWrapper.java:85) at org.eclipse.jdt.internal.corext.callhierarchy.CalleeMethodWrapper.getCalls (CalleeMethodWrapper.java:66) at org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyContentProvider.getChildr en(CallHierarchyContentProvider.java:45) at org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren (AbstractTreeViewer.java:653) at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren (StructuredViewer.java:454) at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren (StructuredViewer.java:558) at org.eclipse.jface.viewers.AbstractTreeViewer$1.run (AbstractTreeViewer.java:301) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren (AbstractTreeViewer.java:289) at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand (AbstractTreeViewer.java:697) at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded (AbstractTreeViewer.java:709) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:177) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:849) at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:1894) at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:3814) at org.eclipse.swt.widgets.Composite.WM_NOTIFY(Composite.java:642) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java) at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java) at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:1502) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:61) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:40) at java.lang.reflect.Method.invoke(Method.java:335) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
resolved fixed
a2438be
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:39:32Z
2003-04-16T13:33:20Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CalleeMethodWrapper.java
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class CallHierarchyContentProvider implements ITreeContentProvider { private final static Object[] EMPTY_ARRAY = new Object[0]; private TreeViewer fViewer; public CallHierarchyContentProvider() { super(); } /** * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ public Object[] getChildren(Object parentElement) { if (parentElement instanceof TreeRoot) { TreeRoot dummyRoot = (TreeRoot) parentElement; return new Object[] { dummyRoot.getRoot() }; } else if (parentElement instanceof MethodWrapper) { MethodWrapper methodWrapper = ((MethodWrapper) parentElement); if (!isMaxCallDepthExceeded(methodWrapper)) { if (isRecursive(methodWrapper)) { return TreeTermination.RECURSION_NODE.getObjectArray(); } return methodWrapper.getCalls(); } else { return TreeTermination.MAX_CALL_DEPTH_NODE.getObjectArray(); } } return EMPTY_ARRAY; } /** * Determines whether the call is recursive * @param methodWrapper * @return */ private boolean isRecursive(MethodWrapper methodWrapper) { return methodWrapper.isRecursive(); } private boolean isMaxCallDepthExceeded(MethodWrapper methodWrapper) { return methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth(); } /** * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { return getChildren(inputElement); } /** * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ public Object getParent(Object element) { if (element instanceof MethodWrapper) { return ((MethodWrapper) element).getParent(); } return null; } /** * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() {} /** * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ public boolean hasChildren(Object element) { if (element == TreeRoot.EMPTY_ROOT || element == TreeTermination.MAX_CALL_DEPTH_NODE || element == TreeTermination.RECURSION_NODE) { return false; } // Only methods can have subelements, so there's no need to fool the user into believing that there is more if (element instanceof MethodWrapper) { return ((MethodWrapper)element).getMember().getElementType() == IJavaElement.METHOD; } return true; } /** * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.fViewer = (TreeViewer) viewer; } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private Menu fTreeContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenDeclarationAction fOpenDeclarationAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } public void createPartControl(Composite parent) { // setTitle("Call Hierarchy"); fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fTreeContextMenu); disposeMenu(fLocationContextMenu); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { // if (event.keyCode == SWT.F3) { // if ((fOpenDeclarationAction != null) && // fOpenDeclarationAction.isEnabled()) { // fOpenDeclarationAction.run(); // return; // } // } else if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); toolBar.add(fRefreshAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fOpenDeclarationAction = new OpenDeclarationAction(this.getSite()); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(this), new RefactorActionGroup(this), fSearchScopeActions, fFiltersActionGroup }); } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewer.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class CallHierarchyViewer extends TreeViewer { private CallHierarchyViewPart fPart; private OpenLocationAction fOpen; /** * @param parent */ CallHierarchyViewer(Composite parent, CallHierarchyViewPart part) { super(new Tree(parent, SWT.SINGLE)); fPart = part; getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); setUseHashlookup(true); setContentProvider(new CallHierarchyContentProvider()); setLabelProvider(new CallHierarchyLabelProvider()); fOpen= new OpenLocationAction(part.getSite()); addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpen.run(); } }); setInput(TreeRoot.EMPTY_TREE); } /** * @param wrapper */ void setMethodWrapper(MethodWrapper wrapper) { setInput(getTreeRoot(wrapper)); expandToLevel(2); getTree().setFocus(); getTree().setSelection(new TreeItem[] { getTree().getItems()[0] }); } CallHierarchyViewPart getPart() { return fPart; } /** * */ void setFocus() { getControl().setFocus(); } boolean isInFocus() { return getControl().isFocusControl(); } /** * @param keyListener */ void addKeyListener(KeyListener keyListener) { getControl().addKeyListener(keyListener); } /** * Wraps the root of a MethodWrapper tree in a dummy root in order to show * it in the tree. * * @param root The root of the MethodWrapper tree. * @return A new MethodWrapper which is a dummy root above the specified root. */ private TreeRoot getTreeRoot(MethodWrapper root) { TreeRoot dummyRoot = new TreeRoot(root); return dummyRoot; } void setJavaLabelFormat(int format) { ((CallHierarchyLabelProvider) getLabelProvider()).setJavaLabelFormat(format); refresh(); } /** * Attaches a contextmenu listener to the tree */ void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) { MenuManager menuMgr= new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(menuListener); Menu menu= menuMgr.createContextMenu(getTree()); getTree().setMenu(menu); viewSite.registerContextMenu(popupId, menuMgr, this); } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FiltersDialog.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; 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.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.Label; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; public class FiltersDialog extends Dialog { private Button fFilterOnNames; private Text fNames; private Text fMaxCallDepth; private SelectionListener selectionListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FiltersDialog.this.widgetSelected(e); } }; /** * @param parentShell */ protected FiltersDialog(Shell parentShell) { super(parentShell); } /* (non-Javadoc) * Method declared on Dialog. */ protected Control createDialogArea(Composite parent) { Composite superComposite = (Composite) super.createDialogArea(parent); Font font = parent.getFont(); Composite composite = new Composite(superComposite, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); composite.setFont(font); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); createNamesArea(composite); createMaxCallDepthArea(composite); updateUIFromFilter(); return composite; } /* (non-Javadoc) * Method declared on Window. */ protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(CallHierarchyMessages.getString("FiltersDialog.filter")); //$NON-NLS-1$ // TODO: WorkbenchHelp.setHelp(newShell, ITaskListHelpContextIds.FILTERS_DIALOG); } void createMaxCallDepthArea(Composite parent) { new Label(parent, SWT.NONE).setText(CallHierarchyMessages.getString("FiltersDialog.maxCallDepth")); //$NON-NLS-1$ fMaxCallDepth = new Text(parent, SWT.SINGLE | SWT.BORDER); fMaxCallDepth.setTextLimit(6); GridData gridData = new GridData(); gridData.widthHint = convertWidthInCharsToPixels(10); fMaxCallDepth.setLayoutData(gridData); fMaxCallDepth.setFont(parent.getFont()); } void createNamesArea(Composite parent) { fFilterOnNames = createCheckbox(parent, CallHierarchyMessages.getString("FiltersDialog.filterOnNames"), false); //$NON-NLS-1$ fFilterOnNames.setLayoutData(new GridData()); fNames= new Text(parent, SWT.SINGLE | SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = convertWidthInCharsToPixels(30); fNames.setLayoutData(gridData); fNames.setFont(parent.getFont()); } /** * Creates a check box button with the given parent and text. * * @param parent the parent composite * @param text the text for the check box * @param grabRow <code>true</code>to grab the remaining horizontal space, * <code>false</code> otherwise * * @return the check box button */ Button createCheckbox(Composite parent, String text, boolean grabRow) { Button button = new Button(parent, SWT.CHECK); if (grabRow) { GridData gridData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(gridData); } button.setText(text); button.addSelectionListener(selectionListener); button.setFont(parent.getFont()); return button; } /** * Updates the enabled state of the widgetry. */ void updateEnabledState() { fNames.setEnabled(fFilterOnNames.getSelection()); } /** * Updates the given filter from the UI state. * * @param filter the filter to update */ void updateFilterFromUI() { int maxCallDepth = Integer.parseInt(this.fMaxCallDepth.getText()); CallHierarchyUI.getDefault().setMaxCallDepth(maxCallDepth); CallHierarchy.getDefault().setFilters(fNames.getText()); CallHierarchy.getDefault().setFilterEnabled(fFilterOnNames.getSelection()); } /** * Updates the UI state from the given filter. * * @param filter the filter to use */ void updateUIFromFilter() { fMaxCallDepth.setText(""+CallHierarchyUI.getDefault().getMaxCallDepth()); //$NON-NLS-1$ fNames.setText(CallHierarchy.getDefault().getFilters()); fFilterOnNames.setSelection(CallHierarchy.getDefault().isFilterEnabled()); updateEnabledState(); } /** * Handles selection on a check box or combo box. */ void widgetSelected(SelectionEvent e) { updateEnabledState(); } /** * Updates the filter from the UI state. * Must be done here rather than by extending open() * because after super.open() is called, the widgetry is disposed. */ protected void okPressed() { try { int maxCallDepth = Integer.parseInt(this.fMaxCallDepth.getText()); if (maxCallDepth < 1 || maxCallDepth > 99) { throw new NumberFormatException(); } updateFilterFromUI(); super.okPressed(); } catch (NumberFormatException eNumberFormat) { MessageBox messageBox = new MessageBox(getShell(), SWT.OK | SWT.APPLICATION_MODAL | SWT.ICON_ERROR); messageBox.setText(CallHierarchyMessages.getString( "FiltersDialog.titleMaxCallDepthInvalid")); //$NON-NLS-1$ messageBox.setMessage(CallHierarchyMessages.getString( "FiltersDialog.messageMaxCallDepthInvalid")); //$NON-NLS-1$ messageBox.open(); if (fMaxCallDepth.forceFocus()) { fMaxCallDepth.setSelection(0, fMaxCallDepth.getCharCount()); fMaxCallDepth.showSelection(); } } } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FocusOnSelectionAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.internal.ui.util.SelectionUtil; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class FocusOnSelectionAction extends Action { private CallHierarchyViewPart fPart; public FocusOnSelectionAction(CallHierarchyViewPart part) { super(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.text")); //$NON-NLS-1$ fPart= part; setDescription(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.tooltip")); //$NON-NLS-1$ } public boolean canActionBeAdded() { Object element = SelectionUtil.getSingleElement(getSelection()); IMethod method = null; if (element instanceof IMethod) { method= (IMethod) element; } else if (element instanceof IAdaptable) { method= (IMethod) ((IAdaptable) element).getAdapter(IMethod.class); } if (method != null) { setText(CallHierarchyMessages.getFormattedString("FocusOnSelectionAction.focusOn.text", method.getElementName())); //$NON-NLS-1$ return true; } return false; } /* * @see Action#run */ public void run() { Object element = SelectionUtil.getSingleElement(getSelection()); if (element instanceof MethodWrapper) { IMember member= ((MethodWrapper) element).getMember(); if (member.getElementType() == IJavaElement.METHOD) { fPart.setMethod((IMethod) member); } } } private ISelection getSelection() { ISelectionProvider provider = fPart.getSite().getSelectionProvider(); if (provider != null) { return provider.getSelection(); } return null; } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/HistoryAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.Assert; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; /** * Action used for the type hierarchy forward / backward buttons */ class HistoryAction extends Action { private static JavaElementLabelProvider fLabelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE); private CallHierarchyViewPart fView; private IMethod fMethod; public HistoryAction(CallHierarchyViewPart viewPart, IMethod element) { super(); fView = viewPart; fMethod = element; String elementName = getElementLabel(element); setText(elementName); setImageDescriptor(getImageDescriptor(element)); setDescription(CallHierarchyMessages.getFormattedString(CallHierarchyMessages.getString("HistoryAction.description"), elementName)); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getFormattedString(CallHierarchyMessages.getString("HistoryAction.tooltip"), elementName)); //$NON-NLS-1$ } private ImageDescriptor getImageDescriptor(IJavaElement elem) { JavaElementImageProvider imageProvider = new JavaElementImageProvider(); ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0); imageProvider.dispose(); return desc; } /* * @see Action#run() */ public void run() { fView.gotoHistoryEntry(fMethod); } /** * @param element * @return String */ private String getElementLabel(IJavaElement element) { Assert.isNotNull(element); return fLabelProvider.getText(element); } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/HistoryDropDownAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.internal.ui.JavaPluginImages; class HistoryDropDownAction extends Action implements IMenuCreator { public static final int RESULTS_IN_DROP_DOWN = 10; private CallHierarchyViewPart fView; private Menu fMenu; public HistoryDropDownAction(CallHierarchyViewPart view) { fView = view; fMenu = null; setToolTipText(CallHierarchyMessages.getString("HistoryDropDownAction.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "history_list.gif"); //$NON-NLS-1$ setMenuCreator(this); } public Menu getMenu(Menu parent) { return null; } public Menu getMenu(Control parent) { if (fMenu != null) { fMenu.dispose(); } fMenu = new Menu(parent); IMethod[] elements = fView.getHistoryEntries(); addEntries(fMenu, elements); return fMenu; } public void dispose() { fView = null; if (fMenu != null) { fMenu.dispose(); fMenu = null; } } public void run() {} protected void addActionToMenu(Menu parent, Action action) { ActionContributionItem item = new ActionContributionItem(action); item.fill(parent, -1); } private boolean addEntries(Menu menu, IMethod[] elements) { boolean checked = false; int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN); for (int i = 0; i < min; i++) { HistoryAction action = new HistoryAction(fView, elements[i]); action.setChecked(elements[i].equals(fView.getMethod())); checked = checked || action.isChecked(); addActionToMenu(menu, action); } return checked; } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ICallHierarchyHelpContextIds.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; public interface ICallHierarchyHelpContextIds { }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/RefreshAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jdt.internal.ui.JavaPluginImages; class RefreshAction extends Action { private CallHierarchyViewPart fPart; public RefreshAction(CallHierarchyViewPart part) { fPart= part; setText(CallHierarchyMessages.getString("RefreshAction.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("RefreshAction.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "refresh_nav.gif");//$NON-NLS-1$ } /** * @see org.eclipse.jface.action.Action#run() */ public void run() { fPart.refresh(); } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.window.Window; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; class SearchScopeActionGroup extends ActionGroup { private SearchScopeAction fSelectedAction = null; private String fSelectedWorkingSetName = null; private CallHierarchyViewPart fView; private SearchScopeHierarchyAction fSearchScopeHierarchyAction; private SearchScopeProjectAction fSearchScopeProjectAction; private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction; private SelectWorkingSetAction fSelectWorkingSetAction; private abstract class SearchScopeAction extends Action { public SearchScopeAction(String text) { super(text); } public abstract IJavaSearchScope getSearchScope(); public void run() { setSelected(this); } } private class SearchScopeHierarchyAction extends SearchScopeAction { public SearchScopeHierarchyAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { try { IMethod method = getView().getMethod(); if (method != null) { return SearchEngine.createHierarchyScope(method.getDeclaringType()); } else { return null; } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } } private class SearchScopeProjectAction extends SearchScopeAction { public SearchScopeProjectAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.project.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.project.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { IMethod method = getView().getMethod(); IJavaProject project = null; if (method != null) { project = method.getJavaProject(); } if (project != null) { return SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, false); } else { return null; } } } private class SearchScopeWorkingSetAction extends SearchScopeAction { private IWorkingSet mWorkingSet; public SearchScopeWorkingSetAction(IWorkingSet workingSet) { super(workingSet.getName()); setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.tooltip")); //$NON-NLS-1$ this.mWorkingSet = workingSet; } public IJavaSearchScope getSearchScope() { return SearchEngine.createJavaSearchScope(getJavaElements( mWorkingSet.getElements())); } /** * */ public IWorkingSet getWorkingSet() { return mWorkingSet; } /** * @param adaptables * @return IResource[] */ private IJavaElement[] getJavaElements(IAdaptable[] adaptables) { Collection result = new ArrayList(); for (int i = 0; i < adaptables.length; i++) { IJavaElement element = (IJavaElement) adaptables[i].getAdapter(IJavaElement.class); if (element != null) { result.add(element); } } return (IJavaElement[]) result.toArray(new IJavaElement[result.size()]); } } private class SearchScopeWorkspaceAction extends SearchScopeAction { public SearchScopeWorkspaceAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.tooltip")); //$NON-NLS-1$ } public IJavaSearchScope getSearchScope() { return SearchEngine.createWorkspaceScope(); } } private class SelectWorkingSetAction extends Action { public SelectWorkingSetAction() { super(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.tooltip")); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ public void run() { IWorkingSetManager workingSetManager = getWorkingSetManager(); IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getShell(), false); IWorkingSet workingSet = getActiveWorkingSet(); if (workingSet != null) { dialog.setSelection(new IWorkingSet[] { workingSet }); } if (dialog.open() == Window.OK) { IWorkingSet[] result = dialog.getSelection(); if ((result != null) && (result.length > 0)) { setActiveWorkingSet(result[0]); workingSetManager.addRecentWorkingSet(result[0]); } else { setActiveWorkingSet(null); } } } } public SearchScopeActionGroup(CallHierarchyViewPart view) { this.fView = view; createActions(); } /** * @return IJavaSearchScope */ public IJavaSearchScope getSearchScope() { if (fSelectedAction != null) { return fSelectedAction.getSearchScope(); } return null; } public void fillActionBars(IActionBars actionBars) { super.fillActionBars(actionBars); fillViewMenu(actionBars.getMenuManager()); } public void fillContextMenu(IMenuManager menu) { // MenuManager javaSearchMM = new MenuManager(MENU_TEXT, // ICallHierarchyConstants.GROUP_SEARCH_SCOPE); // // javaSearchMM.addMenuListener(new IMenuListener() { // /* (non-Javadoc) // * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) // */ // public void menuAboutToShow(IMenuManager manager) { // fillSearchActions(manager); // } // }); // menu.appendToGroup(ICallHierarchyConstants.GROUP_SEARCH_SCOPE, javaSearchMM); } /** * @param set * @param b */ protected void setActiveWorkingSet(IWorkingSet set) { if (set != null) { fSelectedWorkingSetName = set.getName(); fSelectedAction = new SearchScopeWorkingSetAction(set); } else { fSelectedWorkingSetName = null; fSelectedAction = null; } } /** * @return */ protected IWorkingSet getActiveWorkingSet() { if (fSelectedWorkingSetName != null) { return getWorkingSetManager().getWorkingSet(fSelectedWorkingSetName); } return null; } protected void setSelected(SearchScopeAction newSelection) { if (newSelection instanceof SearchScopeWorkingSetAction) { fSelectedWorkingSetName = ((SearchScopeWorkingSetAction) newSelection).getWorkingSet() .getName(); } else { fSelectedWorkingSetName = null; } fSelectedAction = newSelection; } /** * @return CallHierarchyViewPart */ protected CallHierarchyViewPart getView() { return fView; } protected IWorkingSetManager getWorkingSetManager() { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); return workingSetManager; } protected void fillSearchActions(IMenuManager javaSearchMM) { javaSearchMM.removeAll(); Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action action = actions[i]; if (action.isEnabled()) { javaSearchMM.add(action); } } javaSearchMM.setVisible(!javaSearchMM.isEmpty()); } void fillViewMenu(IMenuManager menu) { menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.getString("SearchScopeActionGroup.searchScope"), //$NON-NLS-1$ IContextMenuConstants.GROUP_SEARCH); javaSearchMM.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillSearchActions(manager); } }); menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM); } /** * @return SearchScopeAction[] */ private Action[] getActions() { List actions = new ArrayList(); addAction(actions, fSearchScopeWorkspaceAction); addAction(actions, fSearchScopeProjectAction); addAction(actions, fSearchScopeHierarchyAction); addAction(actions, fSelectWorkingSetAction); IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); IWorkingSet[] sets = workingSetManager.getRecentWorkingSets(); for (int i = 0; i < sets.length; i++) { SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(sets[i]); if (sets[i].getName().equals(fSelectedWorkingSetName)) { workingSetAction.setChecked(true); } actions.add(workingSetAction); } return (Action[]) actions.toArray(new Action[actions.size()]); } private void addAction(List actions, Action action) { if (action == fSelectedAction) { action.setChecked(true); } else { action.setChecked(false); } actions.add(action); } /** * @param view */ private void createActions() { fSearchScopeWorkspaceAction = new SearchScopeWorkspaceAction(); fSelectWorkingSetAction = new SelectWorkingSetAction(); fSearchScopeHierarchyAction = new SearchScopeHierarchyAction(); fSearchScopeProjectAction = new SearchScopeProjectAction(); setSelected(fSearchScopeWorkspaceAction); } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ToggleCallModeAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jface.util.Assert; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * Toggles the call direction of the call hierarchy (i.e. toggles between showing callers and callees.) */ class ToggleCallModeAction extends Action { private CallHierarchyViewPart fView; private int fMode; public ToggleCallModeAction(CallHierarchyViewPart v, int mode) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ if (mode == CallHierarchyViewPart.CALL_MODE_CALLERS) { setText(CallHierarchyMessages.getString("ToggleCallModeAction.callers.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleCallModeAction.callers.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleCallModeAction.callers.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "ch_callers.gif"); //$NON-NLS-1$ } else if (mode == CallHierarchyViewPart.CALL_MODE_CALLEES) { setText(CallHierarchyMessages.getString("ToggleCallModeAction.callees.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleCallModeAction.callees.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleCallModeAction.callees.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "ch_callees.gif"); //$NON-NLS-1$ } else { Assert.isTrue(false); } fView= v; fMode= mode; WorkbenchHelp.setHelp(this, IJavaHelpContextIds.TOGGLE_ORIENTATION_ACTION); // TODO } public int getMode() { return fMode; } /* * @see Action#actionPerformed */ public void run() { fView.setCallMode(fMode); // will toggle the checked state } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ToggleJavaLabelFormatAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jface.util.Assert; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * Toggles the format of the Java labels of the call hierarchy */ class ToggleJavaLabelFormatAction extends Action { private CallHierarchyViewPart fView; private int fFormat; public ToggleJavaLabelFormatAction(CallHierarchyViewPart v, int format) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ if (format == CallHierarchyViewPart.JAVA_LABEL_FORMAT_DEFAULT) { setText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.default.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.default.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.default.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$ } else if (format == CallHierarchyViewPart.JAVA_LABEL_FORMAT_SHORT) { setText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.short.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.short.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.short.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$ } else if (format == CallHierarchyViewPart.JAVA_LABEL_FORMAT_LONG) { setText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.long.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.long.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleJavaLabelFormatAction.long.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$ } else { Assert.isTrue(false); } fView= v; fFormat= format; WorkbenchHelp.setHelp(this, IJavaHelpContextIds.TOGGLE_ORIENTATION_ACTION); // TODO } public int getFormat() { return fFormat; } /* * @see Action#actionPerformed */ public void run() { fView.setJavaLabelFormat(fFormat); // will toggle the checked state } }
36,498
Bug 36498 outline view signature incorrect for templated functions/methods
try this code: class A { template <class B> B aMethod( B aParm ); }; template <class A, typename B> void aFunction( A a, B b ); the name of the method shows up twice in the signature in the outline view.
resolved fixed
19f73e8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T07:54:35Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ToggleOrientationAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jface.util.Assert; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * Toggles the orientationof the layout of the call hierarchy */ class ToggleOrientationAction extends Action { private CallHierarchyViewPart fView; private int fOrientation; public ToggleOrientationAction(CallHierarchyViewPart v, int orientation) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) { setText(CallHierarchyMessages.getString("ToggleOrientationAction.horizontal.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleOrientationAction.horizontal.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleOrientationAction.horizontal.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$ } else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) { setText(CallHierarchyMessages.getString("ToggleOrientationAction.vertical.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleOrientationAction.vertical.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleOrientationAction.vertical.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$ } else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) { setText(CallHierarchyMessages.getString("ToggleOrientationAction.single.label")); //$NON-NLS-1$ setDescription(CallHierarchyMessages.getString("ToggleOrientationAction.single.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("ToggleOrientationAction.single.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$ } else { Assert.isTrue(false); } fView= v; fOrientation= orientation; WorkbenchHelp.setHelp(this, IJavaHelpContextIds.TOGGLE_ORIENTATION_ACTION); } public int getOrientation() { return fOrientation; } /* * @see Action#actionPerformed */ public void run() { fView.setOrientation(fOrientation); // will toggle the checked state } }
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/core
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/core
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/MethodWrapper.java
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewAdapter.java
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private Menu fTreeContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenDeclarationAction fOpenDeclarationAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } public void createPartControl(Composite parent) { // setTitle("Call Hierarchy"); fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fTreeContextMenu); disposeMenu(fLocationContextMenu); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { // if (event.keyCode == SWT.F3) { // if ((fOpenDeclarationAction != null) && // fOpenDeclarationAction.isEnabled()) { // fOpenDeclarationAction.run(); // return; // } // } else if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); JavaUIHelp.setHelp(fLocationViewer, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); if (fOpenDeclarationAction.canActionBeAdded()) { menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenDeclarationAction); } menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); toolBar.add(fRefreshAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fOpenDeclarationAction = new OpenDeclarationAction(this.getSite()); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(this), new RefactorActionGroup(this), fSearchScopeActions, fFiltersActionGroup }); } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,486
Bug 36486 call hierarchy: should use adapters
call hierarchy should use adapters to allow actions contributed on object to be added to the context menu
resolved fixed
c131ae4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T09:02:15Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewSiteAdapter.java
35,556
Bug 35556 [Refactoring] NPE upon inlining method
Eclipse 2.1 RC3a When inlining a method I get (after some time of work) the following stacktrace. Is there any tracing I can turn on to find out which class it's currently working on? -- snip -- java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.flow.LocalFlowInfo.<init> (LocalFlowInfo.java:21) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisitPreP ostfixExpression(FlowAnalyzer.java:845) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisit (FlowAnalyzer.java:640) at org.eclipse.jdt.core.dom.PrefixExpression.accept0 (PrefixExpression.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.MethodInvocation.accept0 (MethodInvocation.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0 (ExpressionStatement.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0 (MethodDeclaration.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.doPerfo rm(InputFlowAnalyzer.java:117) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.perform (InputFlowAnalyzer.java:109) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.flowAnalysis (CallInliner.java:143) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:154) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkI nput(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactori ng(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:91) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:214) at org.eclipse.ui.internal.WWinKeyBindingService$5.widgetSelected (WWinKeyBindingService.java:328) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:65) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
verified fixed
a1290d8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T12:00:47Z
2003-03-24T10:00:00Z
org.eclipse.jdt.ui/core
35,556
Bug 35556 [Refactoring] NPE upon inlining method
Eclipse 2.1 RC3a When inlining a method I get (after some time of work) the following stacktrace. Is there any tracing I can turn on to find out which class it's currently working on? -- snip -- java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.flow.LocalFlowInfo.<init> (LocalFlowInfo.java:21) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisitPreP ostfixExpression(FlowAnalyzer.java:845) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisit (FlowAnalyzer.java:640) at org.eclipse.jdt.core.dom.PrefixExpression.accept0 (PrefixExpression.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.MethodInvocation.accept0 (MethodInvocation.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0 (ExpressionStatement.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0 (MethodDeclaration.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.doPerfo rm(InputFlowAnalyzer.java:117) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.perform (InputFlowAnalyzer.java:109) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.flowAnalysis (CallInliner.java:143) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:154) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkI nput(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactori ng(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:91) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:214) at org.eclipse.ui.internal.WWinKeyBindingService$5.widgetSelected (WWinKeyBindingService.java:328) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:65) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
verified fixed
a1290d8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T12:00:47Z
2003-03-24T10:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java
35,556
Bug 35556 [Refactoring] NPE upon inlining method
Eclipse 2.1 RC3a When inlining a method I get (after some time of work) the following stacktrace. Is there any tracing I can turn on to find out which class it's currently working on? -- snip -- java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.flow.LocalFlowInfo.<init> (LocalFlowInfo.java:21) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisitPreP ostfixExpression(FlowAnalyzer.java:845) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisit (FlowAnalyzer.java:640) at org.eclipse.jdt.core.dom.PrefixExpression.accept0 (PrefixExpression.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.MethodInvocation.accept0 (MethodInvocation.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0 (ExpressionStatement.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0 (MethodDeclaration.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.doPerfo rm(InputFlowAnalyzer.java:117) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.perform (InputFlowAnalyzer.java:109) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.flowAnalysis (CallInliner.java:143) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:154) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkI nput(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactori ng(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:91) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:214) at org.eclipse.ui.internal.WWinKeyBindingService$5.widgetSelected (WWinKeyBindingService.java:328) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:65) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
verified fixed
a1290d8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T12:00:47Z
2003-03-24T10:00:00Z
org.eclipse.jdt.ui/core
35,556
Bug 35556 [Refactoring] NPE upon inlining method
Eclipse 2.1 RC3a When inlining a method I get (after some time of work) the following stacktrace. Is there any tracing I can turn on to find out which class it's currently working on? -- snip -- java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.flow.LocalFlowInfo.<init> (LocalFlowInfo.java:21) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisitPreP ostfixExpression(FlowAnalyzer.java:845) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisit (FlowAnalyzer.java:640) at org.eclipse.jdt.core.dom.PrefixExpression.accept0 (PrefixExpression.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.MethodInvocation.accept0 (MethodInvocation.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0 (ExpressionStatement.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:95) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1423) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:81) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1400) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0 (MethodDeclaration.java:178) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:1353) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.doPerfo rm(InputFlowAnalyzer.java:117) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InputFlowAnalyzer.perform (InputFlowAnalyzer.java:109) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.flowAnalysis (CallInliner.java:143) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:154) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkI nput(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactori ng(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:91) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:214) at org.eclipse.ui.internal.WWinKeyBindingService$5.widgetSelected (WWinKeyBindingService.java:328) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:65) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1842) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1549) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
verified fixed
a1290d8
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-17T12:00:47Z
2003-03-24T10:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/LocalFlowInfo.java
36,487
Bug 36487 call hierarchy: drop should set input
dropping a method to the call hierarchy view should have the same effect as 'focus on'
resolved fixed
41a9841
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:22:02Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java
36,487
Bug 36487 call hierarchy: drop should set input
dropping a method to the call hierarchy view should have the same effect as 'focus on'
resolved fixed
41a9841
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:22:02Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { private CallHierarchyViewSiteAdapter fViewSiteAdapter; private CallHierarchyViewAdapter fViewAdapter; public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } public void createPartControl(Composite parent) { // setTitle("Call Hierarchy"); fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fLocationContextMenu); if (fActionGroups != null) fActionGroups.dispose(); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { // if (event.keyCode == SWT.F3) { // if ((fOpenDeclarationAction != null) && // fOpenDeclarationAction.isEnabled()) { // fOpenDeclarationAction.run(); // return; // } // } else if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); JavaUIHelp.setHelp(fLocationViewer, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); toolBar.add(fRefreshAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenEditorActionGroup(getViewAdapter()), new OpenViewActionGroup(getViewAdapter()), new CCPActionGroup(getViewAdapter()), new GenerateActionGroup(getViewAdapter()), new RefactorActionGroup(getViewAdapter()), new JavaSearchActionGroup(getViewAdapter()), fSearchScopeActions, fFiltersActionGroup }); } private CallHierarchyViewAdapter getViewAdapter() { if (fViewAdapter == null) { fViewAdapter= new CallHierarchyViewAdapter(getViewSiteAdapter()); } return fViewAdapter; } private CallHierarchyViewSiteAdapter getViewSiteAdapter() { if (fViewSiteAdapter == null) { fViewSiteAdapter= new CallHierarchyViewSiteAdapter(this.getViewSite()); } return fViewSiteAdapter; } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,487
Bug 36487 call hierarchy: drop should set input
dropping a method to the call hierarchy view should have the same effect as 'focus on'
resolved fixed
41a9841
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:22:02Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewSiteAdapter.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ISelection; 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.IActionBars; import org.eclipse.ui.IKeyBindingService; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.SelectionUtil; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This class adapts a Call Hierarchy view site. * It converts selection of Call Hierarchy view entries to * be a selection of Java elements. * */ class CallHierarchyViewSiteAdapter implements IViewSite { private ISelectionProvider fProvider; private IWorkbenchSite fSite; private ISelectionChangedListener fListener; public CallHierarchyViewSiteAdapter(IWorkbenchSite site){ fSite= site; setSelectionProvider(site.getSelectionProvider()); } public IWorkbenchPage getPage() { return fSite.getPage(); } public ISelectionProvider getSelectionProvider() { return fProvider; } public Shell getShell() { return JavaPlugin.getActiveWorkbenchShell(); } public IWorkbenchWindow getWorkbenchWindow() { return fSite.getWorkbenchWindow(); } public void setSelectionProvider(final ISelectionProvider provider) { Assert.isNotNull(provider); fProvider= new ISelectionProvider() { public void addSelectionChangedListener(final ISelectionChangedListener listener) { fListener= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { listener.selectionChanged(new SelectionChangedEvent(fProvider, convertSelection(event.getSelection()))); } }; provider.addSelectionChangedListener(fListener); } public ISelection getSelection() { return convertSelection(provider.getSelection()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { provider.removeSelectionChangedListener(fListener); } public void setSelection(ISelection selection) { } }; } private ISelection convertSelection(ISelection selection) { Object element= SelectionUtil.getSingleElement(selection); if (element instanceof MethodWrapper) { MethodWrapper methodWrapper= (MethodWrapper) element; if (methodWrapper != null) { IJavaElement je= methodWrapper.getMember(); if (je != null) return new StructuredSelection(je); } } return StructuredSelection.EMPTY; } // --------- only empty stubs below --------- /* * @see org.eclipse.ui.IWorkbenchPartSite#getId() */ public String getId() { return null; } /* * @see org.eclipse.ui.IWorkbenchPartSite#getKeyBindingService() */ public IKeyBindingService getKeyBindingService() { return null; } /* * @see org.eclipse.ui.IWorkbenchPartSite#getPluginId() */ public String getPluginId() { return null; } /* * @see org.eclipse.ui.IWorkbenchPartSite#getRegisteredName() */ public String getRegisteredName() { return null; } /* * @see org.eclipse.ui.IWorkbenchPartSite#registerContextMenu(MenuManager, ISelectionProvider) */ public void registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider) { } /* * @see org.eclipse.ui.IWorkbenchPartSite#registerContextMenu(String, MenuManager, ISelectionProvider) */ public void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) { } /* (non-Javadoc) * @see org.eclipse.ui.IViewSite#getActionBars() */ public IActionBars getActionBars() { // TODO Auto-generated method stub return null; } }
36,487
Bug 36487 call hierarchy: drop should set input
dropping a method to the call hierarchy view should have the same effect as 'focus on'
resolved fixed
41a9841
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:22:02Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectionProviderAdapter.java
36,616
Bug 36616 Call hierarchy: clicking Show History button should show dialog
When clicking the "Show History List" button (not the drop down arrow) nothing happens. To be consistent with search and the type hierarchy a dialog with the full list should be shown.
resolved fixed
7dd3297
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:54:17Z
2003-04-17T09:00:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/HistoryDropDownAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPluginImages; class HistoryDropDownAction extends Action implements IMenuCreator { public static final int RESULTS_IN_DROP_DOWN = 10; private CallHierarchyViewPart fView; private Menu fMenu; public HistoryDropDownAction(CallHierarchyViewPart view) { fView = view; fMenu = null; setToolTipText(CallHierarchyMessages.getString("HistoryDropDownAction.tooltip")); //$NON-NLS-1$ JavaPluginImages.setLocalImageDescriptors(this, "history_list.gif"); //$NON-NLS-1$ WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_DROP_DOWN_ACTION); setMenuCreator(this); } public Menu getMenu(Menu parent) { return null; } public Menu getMenu(Control parent) { if (fMenu != null) { fMenu.dispose(); } fMenu = new Menu(parent); IMethod[] elements = fView.getHistoryEntries(); addEntries(fMenu, elements); return fMenu; } public void dispose() { fView = null; if (fMenu != null) { fMenu.dispose(); fMenu = null; } } public void run() {} protected void addActionToMenu(Menu parent, Action action) { ActionContributionItem item = new ActionContributionItem(action); item.fill(parent, -1); } private boolean addEntries(Menu menu, IMethod[] elements) { boolean checked = false; int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN); for (int i = 0; i < min; i++) { HistoryAction action = new HistoryAction(fView, elements[i]); action.setChecked(elements[i].equals(fView.getMethod())); checked = checked || action.isChecked(); addActionToMenu(menu, action); } return checked; } }
36,616
Bug 36616 Call hierarchy: clicking Show History button should show dialog
When clicking the "Show History List" button (not the drop down arrow) nothing happens. To be consistent with search and the type hierarchy a dialog with the full list should be shown.
resolved fixed
7dd3297
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T14:54:17Z
2003-04-17T09:00:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/HistoryListAction.java
36,518
Bug 36518 call hierarchy: 'refresh' should available only in dropdown menu
toolbar button is not conventional and not accessible we should remove it from there and put in the dropdown menu (context menu is ok, i guess)
resolved fixed
2a2dec0
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:09:31Z
2003-04-15T18:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * Action group to add the filter action to a view part's toolbar * menu. * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> */ public class CallHierarchyFiltersActionGroup extends ActionGroup { class ShowFilterDialogAction extends Action { ShowFilterDialogAction() { setText(CallHierarchyMessages.getString("ShowFilterDialogAction.text")); //$NON-NLS-1$ setImageDescriptor(JavaPluginImages.DESC_CLCL_FILTER); } public void run() { openDialog(); } } private IViewPart fPart; private StructuredViewer fViewer; /** * Creates a new <code>CustomFiltersActionGroup</code>. * * @param part the view part that owns this action group * @param viewer the viewer to be filtered */ public CallHierarchyFiltersActionGroup(IViewPart part, StructuredViewer viewer) { Assert.isNotNull(part); Assert.isNotNull(viewer); fPart= part; fViewer= viewer; } /* (non-Javadoc) * Method declared on ActionGroup. */ public void fillActionBars(IActionBars actionBars) { fillToolBar(actionBars.getToolBarManager()); fillViewMenu(actionBars.getMenuManager()); } private void fillToolBar(IToolBarManager toolBar) { } private void fillViewMenu(IMenuManager viewMenu) { viewMenu.add(new Separator("filters")); //$NON-NLS-1$ viewMenu.add(new ShowFilterDialogAction()); } /* (non-Javadoc) * Method declared on ActionGroup. */ public void dispose() { super.dispose(); } // ---------- dialog related code ---------- private void openDialog() { FiltersDialog dialog= new FiltersDialog( fPart.getViewSite().getShell()); dialog.open(); } }
36,518
Bug 36518 call hierarchy: 'refresh' should available only in dropdown menu
toolbar button is not conventional and not accessible we should remove it from there and put in the dropdown menu (context menu is ok, i guess)
resolved fixed
2a2dec0
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:09:31Z
2003-04-15T18:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTarget; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter; 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.EditorUtility; import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { private CallHierarchyViewSiteAdapter fViewSiteAdapter; private CallHierarchyViewAdapter fViewAdapter; public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } private void initDragAndDrop() { Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() }; int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; addDragAdapters(fCallHierarchyViewer, ops, transfers); addDropAdapters(fCallHierarchyViewer, ops | DND.DROP_DEFAULT, transfers); addDropAdapters(fLocationViewer, ops | DND.DROP_DEFAULT, transfers); //dnd on empty hierarchy DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT); dropTarget.setTransfer(transfers); dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer)); } private void addDropAdapters(StructuredViewer viewer, int ops, Transfer[] transfers){ TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new CallHierarchyTransferDropAdapter(this, viewer) }; viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); } private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) { TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(new SelectionProviderAdapter(viewer)) }; viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners)); } public void createPartControl(Composite parent) { fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } initDragAndDrop(); } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fLocationContextMenu); if (fActionGroups != null) fActionGroups.dispose(); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { // if (event.keyCode == SWT.F3) { // if ((fOpenDeclarationAction != null) && // fOpenDeclarationAction.isEnabled()) { // fOpenDeclarationAction.run(); // return; // } // } else if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); JavaUIHelp.setHelp(fLocationViewer, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); toolBar.add(fRefreshAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenEditorActionGroup(getViewAdapter()), new OpenViewActionGroup(getViewAdapter()), new CCPActionGroup(getViewAdapter()), new GenerateActionGroup(getViewAdapter()), new RefactorActionGroup(getViewAdapter()), new JavaSearchActionGroup(getViewAdapter()), fSearchScopeActions, fFiltersActionGroup }); } private CallHierarchyViewAdapter getViewAdapter() { if (fViewAdapter == null) { fViewAdapter= new CallHierarchyViewAdapter(getViewSiteAdapter()); } return fViewAdapter; } private CallHierarchyViewSiteAdapter getViewSiteAdapter() { if (fViewSiteAdapter == null) { fViewSiteAdapter= new CallHierarchyViewSiteAdapter(this.getViewSite()); } return fViewSiteAdapter; } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/core
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchy.java
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/core
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CallerMethodWrapper.java
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferenceBasePage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.jdt.internal.ui.JavaPlugin; /** * @see PreferencePage */ public class CallHierarchyPreferenceBasePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public CallHierarchyPreferenceBasePage() { super(FieldEditorPreferencePage.GRID); // Set the preference store for the preference page. IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); setPreferenceStore(store); } /** * @see PreferencePage#init */ public void init(IWorkbench workbench) {} /** * Set the default preferences for this page. */ public static void initDefaults(IPreferenceStore store) { CallHierarchyUI.getDefault().initializeDefaultBasePreferences(store); } /* (non-Javadoc) * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ protected void createFieldEditors() { BooleanFieldEditor useImplementorsForCallerSearch = new BooleanFieldEditor(ICallHierarchyPreferencesConstants.PREF_USE_IMPLEMENTORS_FOR_CALLER_SEARCH, CallHierarchyMessages.getString("CallHierarchyPreferenceBasePage.searchForCallersIncludingImplementors"), //$NON-NLS-1$ getFieldEditorParent()); addField(useImplementorsForCallerSearch); BooleanFieldEditor useImplementorsForCalleeSearch = new BooleanFieldEditor(ICallHierarchyPreferencesConstants.PREF_USE_IMPLEMENTORS_FOR_CALLEE_SEARCH, CallHierarchyMessages.getString("CallHierarchyPreferenceBasePage.searchForCalleesIncludingImplementors"), //$NON-NLS-1$ getFieldEditorParent()); addField(useImplementorsForCalleeSearch); } }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyUI.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.OpenStrategy; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.IJavaStatusConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class CallHierarchyUI { private static final int DEFAULT_MAX_CALL_DEPTH= 10; private static final String PREF_MAX_CALL_DEPTH = "PREF_MAX_CALL_DEPTH"; //$NON-NLS-1$ private static CallHierarchyUI fgInstance; private CallHierarchyUI() { } public static CallHierarchyUI getDefault() { if (fgInstance == null) { fgInstance = new CallHierarchyUI(); } return fgInstance; } /** * Returns the maximum tree level allowed * @return int */ public int getMaxCallDepth() { int maxCallDepth; IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); maxCallDepth = settings.getInt(PREF_MAX_CALL_DEPTH); if (maxCallDepth < 1 || maxCallDepth > 99) { maxCallDepth= DEFAULT_MAX_CALL_DEPTH; } return maxCallDepth; } public void setMaxCallDepth(int maxCallDepth) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); settings.setValue(PREF_MAX_CALL_DEPTH, maxCallDepth); } public void initializeDefaultBasePreferences(IPreferenceStore store) { store.setDefault(ICallHierarchyPreferencesConstants.PREF_USE_IMPLEMENTORS_FOR_CALLER_SEARCH, false); store.setDefault(ICallHierarchyPreferencesConstants.PREF_USE_IMPLEMENTORS_FOR_CALLEE_SEARCH, false); } public static void jumpToMember(IJavaElement element) { if (element != null) { try { IEditorPart methodEditor = EditorUtility.openInEditor(element, true); JavaUI.revealInEditor(methodEditor, (IJavaElement) element); } catch (JavaModelException e) { JavaPlugin.log(e); } catch (PartInitException e) { JavaPlugin.log(e); } } } public static void jumpToLocation(CallLocation callLocation) { try { IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(), false); if (methodEditor instanceof ITextEditor) { ITextEditor editor = (ITextEditor) methodEditor; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } catch (JavaModelException e) { JavaPlugin.log(e); } catch (PartInitException e) { JavaPlugin.log(e); } } public static void openInEditor(Object element, Shell shell, String title) { CallLocation callLocation= null; if (element instanceof CallLocation) { callLocation= (CallLocation) element; } else if (element instanceof CallLocation) { callLocation= CallHierarchy.getCallLocation(element); } if (callLocation == null) { return; } try { boolean activateOnOpen = OpenStrategy.activateOnOpen(); IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(), activateOnOpen); if (methodEditor instanceof ITextEditor) { ITextEditor editor = (ITextEditor) methodEditor; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } catch (JavaModelException e) { JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.message"), e)); //$NON-NLS-1$ ErrorDialog.openError(shell, title, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.messageProblems"), //$NON-NLS-1$ e.getStatus()); } catch (PartInitException x) { String name = callLocation.getCalledMember().getElementName(); MessageDialog.openError(shell, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.messageProblems"), //$NON-NLS-1$ CallHierarchyMessages.getFormattedString( "CallHierarchyUI.open_in_editor.error.messageArgs", //$NON-NLS-1$ new String[] { name, x.getMessage() })); } } /** * @param elem * @return */ public static IEditorPart isOpenInEditor(Object elem) { IJavaElement javaElement= null; if (elem instanceof MethodWrapper) { javaElement= ((MethodWrapper) elem).getMember(); } else if (elem instanceof CallLocation) { javaElement= ((CallLocation) elem).getCalledMember(); } if (javaElement != null) { return EditorUtility.isOpenInEditor(javaElement); } return null; } }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTarget; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter; 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.EditorUtility; import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { private CallHierarchyViewSiteAdapter fViewSiteAdapter; private CallHierarchyViewAdapter fViewAdapter; public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String DIALOGSTORE_JAVA_LABEL_FORMAT = "CallHierarchyViewPart.java_label_format"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_JAVA_LABEL_FORMAT = "java_label_format"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int JAVA_LABEL_FORMAT_DEFAULT = JavaElementLabelProvider.SHOW_DEFAULT; static final int JAVA_LABEL_FORMAT_SHORT = JavaElementLabelProvider.SHOW_BASICS; static final int JAVA_LABEL_FORMAT_LONG = JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_RETURN_TYPE | JavaElementLabelProvider.SHOW_POST_QUALIFIED; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentJavaLabelFormat; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleJavaLabelFormatAction[] fToggleJavaLabelFormatActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setJavaLabelFormat(int format) { if (fCurrentJavaLabelFormat != format) { for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { fToggleJavaLabelFormatActions[i].setChecked(format == fToggleJavaLabelFormatActions[i].getFormat()); } fCurrentJavaLabelFormat = format; fDialogSettings.put(DIALOGSTORE_JAVA_LABEL_FORMAT, format); fCallHierarchyViewer.setJavaLabelFormat(fCurrentJavaLabelFormat); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } private void initDragAndDrop() { Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() }; int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; addDragAdapters(fCallHierarchyViewer, ops, transfers); addDropAdapters(fCallHierarchyViewer, ops | DND.DROP_DEFAULT, transfers); addDropAdapters(fLocationViewer, ops | DND.DROP_DEFAULT, transfers); //dnd on empty hierarchy DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT); dropTarget.setTransfer(transfers); dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer)); } private void addDropAdapters(StructuredViewer viewer, int ops, Transfer[] transfers){ TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new CallHierarchyTransferDropAdapter(this, viewer) }; viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); } private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) { TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(new SelectionProviderAdapter(viewer)) }; viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners)); } public void createPartControl(Composite parent) { fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initJavaLabelFormat(); if (fMemento != null) { restoreState(fMemento); } initDragAndDrop(); } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation = memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode = memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer javaLabelFormat = memento.getInteger(TAG_JAVA_LABEL_FORMAT); if (javaLabelFormat != null) { setJavaLabelFormat(javaLabelFormat.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void initJavaLabelFormat() { int format; try { format = fDialogSettings.getInt(DIALOGSTORE_JAVA_LABEL_FORMAT); if (format > 0) { format = JAVA_LABEL_FORMAT_DEFAULT; } } catch (NumberFormatException e) { format = JAVA_LABEL_FORMAT_DEFAULT; } // force the update fCurrentJavaLabelFormat = -1; // will fill the main tool bar setJavaLabelFormat(format); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleJavaLabelFormatActions.length; i++) { viewMenu.add(fToggleJavaLabelFormatActions[i]); } viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fLocationContextMenu); if (fActionGroups != null) fActionGroups.dispose(); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); memento.putInteger(TAG_JAVA_LABEL_FORMAT, fCurrentJavaLabelFormat); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); JavaUIHelp.setHelp(fLocationViewer, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleJavaLabelFormatActions = new ToggleJavaLabelFormatAction[] { new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_DEFAULT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_SHORT), new ToggleJavaLabelFormatAction(this, JAVA_LABEL_FORMAT_LONG) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenEditorActionGroup(getViewAdapter()), new OpenViewActionGroup(getViewAdapter()), new CCPActionGroup(getViewAdapter()), new GenerateActionGroup(getViewAdapter()), new RefactorActionGroup(getViewAdapter()), new JavaSearchActionGroup(getViewAdapter()), fSearchScopeActions, fFiltersActionGroup }); } private CallHierarchyViewAdapter getViewAdapter() { if (fViewAdapter == null) { fViewAdapter= new CallHierarchyViewAdapter(getViewSiteAdapter()); } return fViewAdapter; } private CallHierarchyViewSiteAdapter getViewSiteAdapter() { if (fViewSiteAdapter == null) { fViewSiteAdapter= new CallHierarchyViewSiteAdapter(this.getViewSite()); } return fViewSiteAdapter; } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FocusOnSelectionAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.util.SelectionUtil; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class FocusOnSelectionAction extends Action { private CallHierarchyViewPart fPart; public FocusOnSelectionAction(CallHierarchyViewPart part) { super(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.text")); //$NON-NLS-1$ fPart= part; setDescription(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.description")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("FocusOnSelectionAction.focusOnSelection.tooltip")); //$NON-NLS-1$ WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_FOCUS_ON_SELECTION_ACTION); } public boolean canActionBeAdded() { Object element = SelectionUtil.getSingleElement(getSelection()); IMethod method = null; if (element instanceof IMethod) { method= (IMethod) element; } else if (element instanceof IAdaptable) { method= (IMethod) ((IAdaptable) element).getAdapter(IMethod.class); } if (method != null) { setText(CallHierarchyMessages.getFormattedString("FocusOnSelectionAction.focusOn.text", method.getElementName())); //$NON-NLS-1$ return true; } return false; } /* * @see Action#run */ public void run() { Object element = SelectionUtil.getSingleElement(getSelection()); if (element instanceof MethodWrapper) { IMember member= ((MethodWrapper) element).getMember(); if (member.getElementType() == IJavaElement.METHOD) { fPart.setMethod((IMethod) member); } } } private ISelection getSelection() { ISelectionProvider provider = fPart.getSite().getSelectionProvider(); if (provider != null) { return provider.getSelection(); } return null; } }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ICallHierarchyPreferencesConstants.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; public interface ICallHierarchyPreferencesConstants { public static final String PREF_USE_IMPLEMENTORS_FOR_CALLER_SEARCH = "PREF_USE_IMPLEMENTORS_FOR_CALLER_SEARCH"; //$NON-NLS-1$ public static final String PREF_USE_IMPLEMENTORS_FOR_CALLEE_SEARCH = "PREF_USE_IMPLEMENTORS_FOR_CALLEE_SEARCH"; //$NON-NLS-1$ }
36,514
Bug 36514 call hierarchy: should remove 'search ... using ..' preferences
we should decide whether the answer should be true or false and remove the preference settings - no user will ever understand what the setting means
resolved fixed
bb8a9b5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:36:14Z
2003-04-15T15:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ToggleImplementorsAction.java
36,623
Bug 36623 call hierarchy: Unable to find calls from static initializer
Calls from a static initializer are not found.
resolved fixed
b5a5d58
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:39:58Z
2003-04-17T11:46:40Z
org.eclipse.jdt.ui/core
36,623
Bug 36623 call hierarchy: Unable to find calls from static initializer
Calls from a static initializer are not found.
resolved fixed
b5a5d58
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:39:58Z
2003-04-17T11:46:40Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java
36,623
Bug 36623 call hierarchy: Unable to find calls from static initializer
Calls from a static initializer are not found.
resolved fixed
b5a5d58
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:39:58Z
2003-04-17T11:46:40Z
org.eclipse.jdt.ui/core
36,623
Bug 36623 call hierarchy: Unable to find calls from static initializer
Calls from a static initializer are not found.
resolved fixed
b5a5d58
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T15:39:58Z
2003-04-17T11:46:40Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/MethodReferencesSearchCollector.java
36,578
Bug 36578 call hierarchy: Needs more test cases
The call hierarchy view needs more test cases.
resolved fixed
f9fba3f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-22T16:10:49Z
2003-04-16T16:20:00Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CallHierarchyTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.ui.tests.core; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; 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.testplugin.JavaProjectHelper; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; public class CallHierarchyTest extends TestCase { private static final Class THIS= CallHierarchyTest.class; private IJavaProject fJavaProject1; private IJavaProject fJavaProject2; public CallHierarchyTest(String name) { super(name); } public static Test suite() { if (true) { return new TestSuite(THIS); } else { TestSuite suite= new TestSuite(); suite.addTest(new CallHierarchyTest("test1")); return suite; } } protected void setUp() throws Exception { fJavaProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin"); fJavaProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin"); } protected void tearDown () throws Exception { JavaProjectHelper.delete(fJavaProject1); JavaProjectHelper.delete(fJavaProject2); } public void test1() throws Exception { IPackageFragmentRoot jdk= JavaProjectHelper.addRTJar(fJavaProject1); assertTrue("jdk not found", jdk != null); IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJavaProject1, "src"); IPackageFragment pack1= root1.createPackageFragment("pack1", true, null); ICompilationUnit cu1= pack1.getCompilationUnit("A.java"); IType type1= cu1.createType("public class A {public void method1() { }\n public void method2() { method1(); }\n}\n", null, true, null); JavaProjectHelper.addRTJar(fJavaProject2); JavaProjectHelper.addRequiredProject(fJavaProject2, fJavaProject1); IPackageFragmentRoot root2= JavaProjectHelper.addSourceContainer(fJavaProject2, "src"); IPackageFragment pack2= root2.createPackageFragment("pack2", true, null); ICompilationUnit cu2= pack2.getCompilationUnit("B.java"); IType type2= cu2.createType("public class B extends pack1.A {public void method3() { method1(); }\n}\n", null, true, null); IMethod method1= type1.getMethod("method1", new String[0]); Collection expectedMethods= new ArrayList(); expectedMethods.add(type1.getMethod("method2", new String[0])); expectedMethods.add(type2.getMethod("method3", new String[0])); MethodWrapper wrapper= CallHierarchy.getDefault().getCallerRoot(method1); MethodWrapper[] uncachedCalls= wrapper.getCalls(); assertCalls(expectedMethods, uncachedCalls); MethodWrapper[] cachedCalls= wrapper.getCalls(); assertCalls(expectedMethods, cachedCalls); } private void assertCalls( Collection expectedMethods, MethodWrapper[] callResults) { Collection calls= Arrays.asList(callResults); Collection foundMethods= new ArrayList(); for (int i= 0; i < callResults.length; i++) { foundMethods.add(callResults[i].getMember()); } assertEquals("Wrong number of callers", expectedMethods.size(), calls.size()); assertTrue("One or more methods not found", foundMethods.containsAll(expectedMethods)); } }
36,683
Bug 36683 NullPointerException doing search [search]
While searching from a file in the Java Browsing Perspecive, I got the following: !SESSION Apr 20, 2003 17:55:58.749 --------------------------------------------- java.version=1.4.1_01 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US Command-line arguments: -os linux -ws gtk -arch x86 -data /home/dgeg/eclipseWorkspaceBinary -install file:/usr/share/eclipse/ !ENTRY org.eclipse.ui 4 4 Apr 20, 2003 17:55:58.753 !MESSAGE Unhandled exception caught in event loop. !ENTRY org.eclipse.ui 4 0 Apr 20, 2003 17:55:58.763 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.ui.actions.FindAction.getType(FindAction.java:332) at org.eclipse.jdt.ui.actions.FindAction.makeOperation(FindAction.java:312) at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:272) at org.eclipse.jdt.ui.actions.FindReferencesAction.run(FindReferencesAction.java:83) at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:238) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:913) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1637) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1429) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
resolved fixed
9c74da7
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-23T05:54:48Z
2003-04-21T01:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.eclipse.search.ui.SearchUI; 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.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionUtil; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.search.JavaSearchOperation; import org.eclipse.jdt.internal.ui.search.JavaSearchResultCollector; import org.eclipse.jdt.internal.ui.search.SearchMessages; import org.eclipse.jdt.internal.ui.search.SearchUtil; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; /** * Abstract class for Java search actions. * <p> * Note: This class is for internal use only. Clients should not use this class. * </p> * * @since 2.0 */ public abstract class FindAction extends SelectionDispatchAction { // A dummy which can't be selected in the UI private static final IJavaElement RETURN_WITHOUT_BEEP= JavaCore.create(JavaPlugin.getWorkspace().getRoot()); private Class[] fValidTypes; private JavaEditor fEditor; FindAction(IWorkbenchSite site, String label, Class[] validTypes) { super(site); setText(label); fValidTypes= validTypes; } FindAction(JavaEditor editor, String label, Class[] validTypes) { this (editor.getEditorSite(), label, validTypes); fEditor= editor; setEnabled(SelectionConverter.canOperateOn(fEditor)); } private boolean canOperateOn(IStructuredSelection sel) { return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true)); } boolean canOperateOn(IJavaElement element) { if (fValidTypes == null || fValidTypes.length == 0) return false; if (element != null) { for (int i= 0; i < fValidTypes.length; i++) { if (fValidTypes[i].isInstance(element)) { if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) return hasChildren((IPackageFragment)element); else return true; } } } return false; } private boolean hasChildren(IPackageFragment packageFragment) { try { return packageFragment.hasChildren(); } catch (JavaModelException ex) { return false; } } private IJavaElement getJavaElement(IJavaElement o, boolean silent) { if (o == null) return null; switch (o.getElementType()) { case IJavaElement.COMPILATION_UNIT: if (silent) return (ICompilationUnit)o; else return findType((ICompilationUnit)o, silent); case IJavaElement.CLASS_FILE: return findType((IClassFile)o); default: return o; } } private IJavaElement getJavaElement(IMarker marker, boolean silent) { return getJavaElement(SearchUtil.getJavaElement(marker), silent); } private IJavaElement getJavaElement(Object o, boolean silent) { if (o instanceof IJavaElement) return getJavaElement((IJavaElement)o, silent); else if (o instanceof IMarker) return getJavaElement((IMarker)o, silent); else if (o instanceof ISelection) return getJavaElement((IStructuredSelection)o, silent); else if (SearchUtil.isISearchResultViewEntry(o)) return getJavaElement(SearchUtil.getJavaElement(o), silent);; return null; } IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) { if (selection.size() == 1) // Selection only enabled if one element selected. return getJavaElement(selection.getFirstElement(), silent); return null; } private void showOperationUnavailableDialog() { MessageDialog.openInformation(getShell(), SearchMessages.getString("JavaElementAction.operationUnavailable.title"), getOperationUnavailableMessage()); //$NON-NLS-1$ } String getOperationUnavailableMessage() { return SearchMessages.getString("JavaElementAction.operationUnavailable.generic"); //$NON-NLS-1$ } private IJavaElement findType(ICompilationUnit cu, boolean silent) { IType[] types= null; try { types= cu.getAllTypes(); } catch (JavaModelException ex) { // silent mode ExceptionHandler.log(ex, SearchMessages.getString("JavaElementAction.error.open.message")); //$NON-NLS-1$ if (silent) return RETURN_WITHOUT_BEEP; else return null; } if (types.length == 1 || (silent && types.length > 0)) return types[0]; if (silent) return RETURN_WITHOUT_BEEP; if (types.length == 0) return null; String title= SearchMessages.getString("JavaElementAction.typeSelectionDialog.title"); //$NON-NLS-1$ String message = SearchMessages.getString("JavaElementAction.typeSelectionDialog.message"); //$NON-NLS-1$ int flags= (JavaElementLabelProvider.SHOW_DEFAULT); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(types); if (dialog.open() == Window.OK) return (IType)dialog.getFirstResult(); else return RETURN_WITHOUT_BEEP; } private IType findType(IClassFile cf) { IType mainType; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.log(ex, SearchMessages.getString("JavaElementAction.error.open.message")); //$NON-NLS-1$ return null; } return mainType; } /* * Method declared on SelectionChangedAction. */ protected void run(IStructuredSelection selection) { IJavaElement element= getJavaElement(selection, false); if (element == null || !element.exists()) { showOperationUnavailableDialog(); return; } else if (element == RETURN_WITHOUT_BEEP) return; run(element); } /* * Method declared on SelectionChangedAction. */ protected void run(ITextSelection selection) { if (!ActionUtil.isProcessable(getShell(), fEditor)) return; try { String title= SearchMessages.getString("SearchElementSelectionDialog.title"); //$NON-NLS-1$ String message= SearchMessages.getString("SearchElementSelectionDialog.message"); //$NON-NLS-1$ IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 0 && canOperateOn(elements[0])) { IJavaElement element= elements[0]; if (elements.length > 1) element= SelectionConverter.codeResolve(fEditor, getShell(), title, message); run(element); } else showOperationUnavailableDialog(); } catch (JavaModelException ex) { JavaPlugin.log(ex); String title= SearchMessages.getString("Search.Error.search.title"); //$NON-NLS-1$ String message= SearchMessages.getString("Search.Error.codeResolve"); //$NON-NLS-1$ ErrorDialog.openError(getShell(), title, message, ex.getStatus()); } } /* * Method declared on SelectionChangedAction. */ protected void selectionChanged(IStructuredSelection selection) { setEnabled(canOperateOn(selection)); } /* * Method declared on SelectionChangedAction. */ protected void selectionChanged(ITextSelection selection) { } void run(IJavaElement element) { if (!ActionUtil.isProcessable(getShell(), element)) return; SearchUI.activateSearchResultView(); Shell shell= JavaPlugin.getActiveWorkbenchShell(); JavaSearchOperation op= null; try { op= makeOperation(element); if (op == null) return; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$ return; } IWorkspaceDescription workspaceDesc= JavaPlugin.getWorkspace().getDescription(); boolean isAutoBuilding= workspaceDesc.isAutoBuilding(); if (isAutoBuilding) { // disable auto-build during search operation workspaceDesc.setAutoBuilding(false); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } try { new ProgressMonitorDialog(shell).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-1$ //$NON-NLS-2$ } catch(InterruptedException e) { } finally { if (isAutoBuilding) { // enable auto-building again workspaceDesc= JavaPlugin.getWorkspace().getDescription(); workspaceDesc.setAutoBuilding(true); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } } } JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException { IType type= getType(element); return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(type), getScopeDescription(type), getCollector()); }; abstract int getLimitTo(); IJavaSearchScope getScope(IType element) throws JavaModelException { return SearchEngine.createWorkspaceScope(); } JavaSearchResultCollector getCollector() { return new JavaSearchResultCollector(); } String getScopeDescription(IType type) { return SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ } IType getType(IJavaElement element) { IType type= null; if (element.getElementType() == IJavaElement.TYPE) type= (IType)element; else if (element instanceof IMember) type= ((IMember)element).getDeclaringType(); if (type != null) { ICompilationUnit cu= type.getCompilationUnit(); if (cu == null) return type; IType wcType= (IType)getWorkingCopy(type); if (wcType != null) return wcType; else return type; } return null; } /** * Tries to find the given element in a working copy. */ private IJavaElement getWorkingCopy(IJavaElement input) { try { if (input instanceof ICompilationUnit) return EditorUtility.getWorkingCopy((ICompilationUnit)input); else return EditorUtility.getWorkingCopy(input, true); } catch (JavaModelException ex) { } return null; } }
36,280
Bug 36280 Duplicate projects in projects view [browsing]
In the Java Browsing view, I have a situation where I have ended up with a duplicate list of projects (as shown in attached screenshot). For some reason, the list of projects seems to have been built twice. I can see each one of them by drilling down through it. I have disabled the '-noupdate' from the launch (trying to get Omondo UML installed) and have restarted several times. It may be due to a glitch in the rebuilding process.
verified fixed
9667241
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-23T13:52:14Z
2003-04-09T12:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/JavaBrowsingContentProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.browsing; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IResource; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; 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.IImportContainer; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IPackageDeclaration; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.IWorkingCopy; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.StandardJavaElementContentProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; class JavaBrowsingContentProvider extends StandardJavaElementContentProvider implements IElementChangedListener { private StructuredViewer fViewer; private Object fInput; private JavaBrowsingPart fBrowsingPart; public JavaBrowsingContentProvider(boolean provideMembers, JavaBrowsingPart browsingPart) { super(provideMembers, reconcileJavaViews()); fBrowsingPart= browsingPart; fViewer= fBrowsingPart.getViewer(); JavaCore.addElementChangedListener(this); } private static boolean reconcileJavaViews() { return PreferenceConstants.UPDATE_WHILE_EDITING.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.UPDATE_JAVA_VIEWS)); } public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; try { if (element instanceof Collection) { Collection elements= (Collection)element; if (elements.isEmpty()) return NO_CHILDREN; Object[] result= new Object[0]; Iterator iter= ((Collection)element).iterator(); while (iter.hasNext()) { Object[] children= getChildren(iter.next()); if (children != NO_CHILDREN) result= concatenate(result, children); } return result; } if (element instanceof IPackageFragment) return getPackageContents((IPackageFragment)element); if (fProvideMembers && element instanceof IType) return getChildren((IType)element); if (fProvideMembers && element instanceof ISourceReference && element instanceof IParent) return removeImportAndPackageDeclarations(super.getChildren(element)); if (element instanceof IJavaProject) return getPackageFragmentRoots((IJavaProject)element); return super.getChildren(element); } catch (JavaModelException e) { return NO_CHILDREN; } } private Object[] getPackageContents(IPackageFragment fragment) throws JavaModelException { ISourceReference[] sourceRefs; if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceRefs= fragment.getCompilationUnits(); if (getProvideWorkingCopy()) { for (int i= 0; i < sourceRefs.length; i++) { IWorkingCopy wc= EditorUtility.getWorkingCopy((ICompilationUnit)sourceRefs[i]); if (wc != null) sourceRefs[i]= (ICompilationUnit)wc; } } } else { IClassFile[] classFiles= fragment.getClassFiles(); List topLevelClassFile= new ArrayList(); for (int i= 0; i < classFiles.length; i++) { IType type= classFiles[i].getType(); if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal()) topLevelClassFile.add(classFiles[i]); } sourceRefs= (ISourceReference[])topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]); } Object[] result= new Object[0]; for (int i= 0; i < sourceRefs.length; i++) result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))); return concatenate(result, fragment.getNonJavaResources()); } private Object[] removeImportAndPackageDeclarations(Object[] members) { ArrayList tempResult= new ArrayList(members.length); for (int i= 0; i < members.length; i++) if (!(members[i] instanceof IImportContainer) && !(members[i] instanceof IPackageDeclaration)) tempResult.add(members[i]); return tempResult.toArray(); } private Object[] getChildren(IType type) throws JavaModelException{ IParent parent; if (type.isBinary()) parent= type.getClassFile(); else { parent= type.getCompilationUnit(); if (getProvideWorkingCopy()) { IWorkingCopy wc= EditorUtility.getWorkingCopy((ICompilationUnit)parent); if (wc != null) { parent= (IParent)wc; IMember wcType= EditorUtility.getWorkingCopy(type); if (wcType != null) type= (IType)wcType; } } } if (type.getDeclaringType() != null) return type.getChildren(); // Add import declarations IJavaElement[] members= parent.getChildren(); ArrayList tempResult= new ArrayList(members.length); for (int i= 0; i < members.length; i++) if ((members[i] instanceof IImportContainer)) tempResult.add(members[i]); tempResult.addAll(Arrays.asList(type.getChildren())); return tempResult.toArray(); } protected Object[] getPackageFragmentRoots(IJavaProject project) throws JavaModelException { if (!project.getProject().isOpen()) return NO_CHILDREN; IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); List list= new ArrayList(roots.length); // filter out package fragments that correspond to projects and // replace them with the package fragments directly for (int i= 0; i < roots.length; i++) { IPackageFragmentRoot root= (IPackageFragmentRoot)roots[i]; if (!root.isExternal()) { Object[] children= root.getChildren(); for (int k= 0; k < children.length; k++) list.add(children[k]); } else if (hasChildren(root)) { list.add(root); } } return concatenate(list.toArray(), project.getNonJavaResources()); } // ---------------- Element change handling /* (non-Javadoc) * Method declared on IContentProvider. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); if (newInput instanceof Collection) { // Get a template object from the collection Collection col= (Collection)newInput; if (!col.isEmpty()) newInput= col.iterator().next(); else newInput= null; } fInput= newInput; } /* (non-Javadoc) * Method declared on IContentProvider. */ public void dispose() { super.dispose(); JavaCore.removeElementChangedListener(this); } /* (non-Javadoc) * Method declared on IElementChangedListener. */ public void elementChanged(final ElementChangedEvent event) { try { processDelta(event.getDelta()); } catch(JavaModelException e) { JavaPlugin.log(e.getStatus()); } } /** * 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(); if (!getProvideWorkingCopy() && element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) return; if (element != null && element.getElementType() == IJavaElement.COMPILATION_UNIT && !isOnClassPath((ICompilationUnit)element)) return; // 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); if (fBrowsingPart.isValidElement(element)) { if (element instanceof IClassFile) { postRemove(((IClassFile)element).getType()); } else if (element instanceof ICompilationUnit && !((ICompilationUnit)element).isWorkingCopy()) { postRefresh(null); } else if (element instanceof ICompilationUnit && ((ICompilationUnit)element).isWorkingCopy()) { if (getProvideWorkingCopy()) postRefresh(null); } else if (parent instanceof ICompilationUnit && getProvideWorkingCopy() && !((ICompilationUnit)parent).isWorkingCopy()) { if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) { // working copy removed from system - refresh postRefresh(null); } } else if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy() && parent != null && parent.equals(fInput)) // closed editor - removing working copy postRefresh(null); else postRemove(element); } if (fBrowsingPart.isAncestorOf(element, fInput)) { if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) { postAdjustInputAndSetSelection(((IWorkingCopy)element).getOriginal((IJavaElement)fInput)); } else postAdjustInputAndSetSelection(null); } if (fInput != null && fInput.equals(element)) postRefresh(null); if (parent instanceof IPackageFragment && fBrowsingPart.isValidElement(parent)) { // refresh if package gets empty (might be filtered) if (isPackageFragmentEmpty((IPackageFragment)parent) && fViewer.testFindItem(parent) != null) postRefresh(null); } return; } if (kind == IJavaElementDelta.ADDED && delta.getMovedFromElement() != null && element instanceof ICompilationUnit) return; if (kind == IJavaElementDelta.ADDED) { if (fBrowsingPart.isValidElement(element)) { Object parent= internalGetParent(element); if (element instanceof IClassFile) { postAdd(parent, ((IClassFile)element).getType()); } else if (element instanceof ICompilationUnit && !((ICompilationUnit)element).isWorkingCopy()) { postAdd(parent, ((ICompilationUnit)element).getTypes()); } else if (parent instanceof ICompilationUnit && getProvideWorkingCopy() && !((ICompilationUnit)parent).isWorkingCopy()) { // do nothing } else if (element instanceof IWorkingCopy && ((IWorkingCopy)element).isWorkingCopy()) { // new working copy comes to live postRefresh(null); } else postAdd(parent, element); } else if (fInput == null) { IJavaElement newInput= fBrowsingPart.findInputForJavaElement(element); if (newInput != null) postAdjustInputAndSetSelection(element); } else if (element instanceof IType && fBrowsingPart.isValidInput(element)) { IJavaElement cu1= element.getAncestor(IJavaElement.COMPILATION_UNIT); IJavaElement cu2= ((IJavaElement)fInput).getAncestor(IJavaElement.COMPILATION_UNIT); if (cu1 != null && cu2 != null && cu1.equals(cu2)) postAdjustInputAndSetSelection(element); } return; } if (fInput != null && fInput.equals(element)) { if (kind == IJavaElementDelta.CHANGED && (flags & IJavaElementDelta.F_CHILDREN) != 0 && (flags & IJavaElementDelta.F_FINE_GRAINED) != 0) { postRefresh(null, true); return; } } if (isClassPathChange(delta)) // throw the towel and do a full refresh postRefresh(null); if ((flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 && fInput instanceof IJavaElement) { IPackageFragmentRoot pkgRoot= (IPackageFragmentRoot)element; IJavaElement inputsParent= ((IJavaElement)fInput).getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (pkgRoot.equals(inputsParent)) postRefresh(null); } // the source attachment of a JAR has changed if (element instanceof IPackageFragmentRoot && (((flags & IJavaElementDelta.F_SOURCEATTACHED) != 0 || ((flags & IJavaElementDelta.F_SOURCEDETACHED)) != 0))) postUpdateIcon(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); // avoid posting a refresh to an unvisible parent if (element.equals(fInput)) { postRefresh(element); } else { postRefresh(parent); } } // more than one child changed, refresh from here downwards if (element instanceof IPackageFragmentRoot && fBrowsingPart.isValidElement(element)) { postRefresh(skipProjectPackageFragmentRoot((IPackageFragmentRoot)element)); return; } } for (int i= 0; i < affectedChildren.length; i++) { processDelta(affectedChildren[i]); } } private boolean isOnClassPath(ICompilationUnit element) throws JavaModelException { IJavaProject project= element.getJavaProject(); if (project == null || !project.exists()) return false; return project.isOnClasspath(element); } /** * Updates the package icon */ private void postUpdateIcon(final IJavaElement element) { postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE}); } }); } private void postRefresh(final Object root, boolean updateLabels) { if (!updateLabels) { postRefresh(root); return; } postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.refresh(root, true); } }); } private void postRefresh(final Object root) { postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) fViewer.refresh(root, false); } }); } private void postAdd(final Object parent, final Object element) { postAdd(parent, new Object[] {element}); } private void postAdd(final Object parent, final Object[] elements) { if (elements == null || elements.length <= 0) return; postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { Object[] newElements= getNewElements(elements); if (fViewer instanceof AbstractTreeViewer) { if (fViewer.testFindItem(parent) == null) { Object root= ((AbstractTreeViewer)fViewer).getInput(); if (root != null) ((AbstractTreeViewer)fViewer).add(root, newElements); } else ((AbstractTreeViewer)fViewer).add(parent, newElements); } else if (fViewer instanceof ListViewer) ((ListViewer)fViewer).add(newElements); else if (fViewer instanceof TableViewer) ((TableViewer)fViewer).add(newElements); if (fViewer.testFindItem(elements[0]) != null) fBrowsingPart.adjustInputAndSetSelection((IJavaElement)elements[0]); } } }); } private Object[] getNewElements(Object[] elements) { int elementsLength= elements.length; ArrayList result= new ArrayList(elementsLength); for (int i= 0; i < elementsLength; i++) { Object element= elements[i]; if (fViewer.testFindItem(element) == null) result.add(element); } return result.toArray(); } private void postRemove(final Object element) { postRemove(new Object[] {element}); } private void postRemove(final Object[] elements) { if (elements.length <= 0) return; postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { if (fViewer instanceof AbstractTreeViewer) ((AbstractTreeViewer)fViewer).remove(elements); else if (fViewer instanceof ListViewer) ((ListViewer)fViewer).remove(elements); else if (fViewer instanceof TableViewer) ((TableViewer)fViewer).remove(elements); } } }); } private void postAdjustInputAndSetSelection(final Object element) { postRunnable(new Runnable() { public void run() { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.setRedraw(false); fBrowsingPart.adjustInputAndSetSelection((IJavaElement)element); ctrl.setRedraw(true); } } }); } private void postRunnable(final Runnable r) { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { fBrowsingPart.setProcessSelectionEvents(false); try { Display currentDisplay= Display.getCurrent(); if (currentDisplay != null && currentDisplay.equals(ctrl.getDisplay())) ctrl.getDisplay().syncExec(r); else ctrl.getDisplay().asyncExec(r); } finally { fBrowsingPart.setProcessSelectionEvents(true); } } } /** * Returns the parent for the element. * <p> * Note: This method will return a working copy if the * parent is a working copy. The super class implementation * returns the original element instead. * </p> */ protected Object internalGetParent(Object element) { if (element instanceof IJavaProject) { return ((IJavaProject)element).getJavaModel(); } // try to map resources to the containing package fragment if (element instanceof IResource) { IResource parent= ((IResource)element).getParent(); Object jParent= JavaCore.create(parent); if (jParent != null) return jParent; return parent; } // for package fragments that are contained in a project package fragment // we have to skip the package fragment root as the parent. if (element instanceof IPackageFragment) { IPackageFragmentRoot parent= (IPackageFragmentRoot)((IPackageFragment)element).getParent(); return skipProjectPackageFragmentRoot(parent); } if (element instanceof IJavaElement) return ((IJavaElement)element).getParent(); return null; } }
36,280
Bug 36280 Duplicate projects in projects view [browsing]
In the Java Browsing view, I have a situation where I have ended up with a duplicate list of projects (as shown in attached screenshot). For some reason, the list of projects seems to have been built twice. I can see each one of them by drilling down through it. I have disabled the '-noupdate' from the launch (trying to get Omondo UML installed) and have restarted several times. It may be due to a glitch in the rebuilding process.
verified fixed
9667241
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-23T13:52:14Z
2003-04-09T12:06:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/ProjectAndSourceFolderContentProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.browsing; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; class ProjectAndSourceFolderContentProvider extends JavaBrowsingContentProvider { ProjectAndSourceFolderContentProvider(JavaBrowsingPart browsingPart) { super(false, browsingPart); } /* (non-Javadoc) * Method declared on ITreeContentProvider. */ public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; try { if (element instanceof IStructuredSelection) { Assert.isLegal(false); Object[] result= new Object[0]; Class clazz= null; Iterator iter= ((IStructuredSelection)element).iterator(); while (iter.hasNext()) { Object item= iter.next(); if (clazz == null) clazz= item.getClass(); if (clazz == item.getClass()) result= concatenate(result, getChildren(item)); else return NO_CHILDREN; } return result; } if (element instanceof IStructuredSelection) { Assert.isLegal(false); Object[] result= new Object[0]; Iterator iter= ((IStructuredSelection)element).iterator(); while (iter.hasNext()) result= concatenate(result, getChildren(iter.next())); return result; } if (element instanceof IJavaProject) return getPackageFragmentRoots((IJavaProject)element); if (element instanceof IPackageFragmentRoot) return NO_CHILDREN; } catch (JavaModelException e) { return NO_CHILDREN; } return super.getChildren(element); } protected Object[] getPackageFragmentRoots(IJavaProject project) throws JavaModelException { if (!project.getProject().isOpen()) return NO_CHILDREN; IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); List list= new ArrayList(roots.length); // filter out package fragments that correspond to projects and // replace them with the package fragments directly for (int i= 0; i < roots.length; i++) { IPackageFragmentRoot root= (IPackageFragmentRoot)roots[i]; if (!isProjectPackageFragmentRoot(root)) list.add(root); } return list.toArray(); } /* (non-Javadoc) * * @see ITreeContentProvider */ public boolean hasChildren(Object element) { return element instanceof IJavaProject && super.hasChildren(element); } }
36,762
Bug 36762 call hierarchy: should work on classfiles too
AST.parseCompilationUnit works on IClassFiles as well - the view should take advantage of that - now, no binary method is reported to have any callees
resolved fixed
eb1a7a5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:00:53Z
2003-04-22T16:46:40Z
org.eclipse.jdt.ui/core
36,762
Bug 36762 call hierarchy: should work on classfiles too
AST.parseCompilationUnit works on IClassFiles as well - the view should take advantage of that - now, no binary method is reported to have any callees
resolved fixed
eb1a7a5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:00:53Z
2003-04-22T16:46:40Z
extension/org/eclipse/jdt/internal/corext/callhierarchy/CalleeMethodWrapper.java
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui; import org.eclipse.jdt.ui.JavaUI; /** * Help context ids for the Java UI. * <p> * This interface contains constants only; it is not intended to be implemented * or extended. * </p> * */ public interface IJavaHelpContextIds { public static final String PREFIX= JavaUI.ID_PLUGIN + '.'; // Actions public static final String GETTERSETTER_ACTION= PREFIX + "getter_setter_action_context"; //$NON-NLS-1$ public static final String ADD_METHODSTUB_ACTION= PREFIX + "add_methodstub_action_context"; //$NON-NLS-1$ public static final String ADD_UNIMPLEMENTED_METHODS_ACTION= PREFIX + "add_unimplemented_methods_action_context"; //$NON-NLS-1$ public static final String ADD_UNIMPLEMENTED_CONSTRUCTORS_ACTION= PREFIX + "add_unimplemented_constructors_action_context"; //$NON-NLS-1$ public static final String SHOW_IN_PACKAGEVIEW_ACTION= PREFIX + "show_in_packageview_action_context"; //$NON-NLS-1$ public static final String SHOW_IN_HIERARCHYVIEW_ACTION= PREFIX + "show_in_hierarchyview_action_context"; //$NON-NLS-1$ public static final String FOCUS_ON_SELECTION_ACTION= PREFIX + "focus_on_selection_action"; //$NON-NLS-1$ public static final String FOCUS_ON_TYPE_ACTION= PREFIX + "focus_on_type_action"; //$NON-NLS-1$ public static final String TYPEHIERARCHY_HISTORY_ACTION= PREFIX + "typehierarchy_history_action"; //$NON-NLS-1$ public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action"; //$NON-NLS-1$ public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action"; //$NON-NLS-1$ public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action"; //$NON-NLS-1$ public static final String SHOW_INHERITED_ACTION= PREFIX + "show_inherited_action"; //$NON-NLS-1$ public static final String SHOW_SUPERTYPES= PREFIX + "show_supertypes_action"; //$NON-NLS-1$ public static final String SHOW_SUBTYPES= PREFIX + "show_subtypes_action"; //$NON-NLS-1$ public static final String SHOW_HIERARCHY= PREFIX + "show_hierarchy_action"; //$NON-NLS-1$ public static final String ENABLE_METHODFILTER_ACTION= PREFIX + "enable_methodfilter_action"; //$NON-NLS-1$ public static final String ADD_IMPORT_ON_SELECTION_ACTION= PREFIX + "add_imports_on_selection_action_context"; //$NON-NLS-1$ public static final String ORGANIZE_IMPORTS_ACTION= PREFIX + "organize_imports_action_context"; //$NON-NLS-1$ public static final String ADD_TO_CLASSPATH_ACTION= PREFIX + "addjtoclasspath_action_context"; //$NON-NLS-1$ public static final String REMOVE_FROM_CLASSPATH_ACTION= PREFIX + "removefromclasspath_action_context"; //$NON-NLS-1$ public static final String TOGGLE_PRESENTATION_ACTION= PREFIX + "toggle_presentation_action_context"; //$NON-NLS-1$ public static final String TOGGLE_TEXTHOVER_ACTION= PREFIX + "toggle_texthover_action_context"; //$NON-NLS-1$ public static final String OPEN_CLASS_WIZARD_ACTION= PREFIX + "open_class_wizard_action"; //$NON-NLS-1$ public static final String OPEN_INTERFACE_WIZARD_ACTION= PREFIX + "open_interface_wizard_action"; //$NON-NLS-1$ public static final String SORT_MEMBERS_ACTION= PREFIX + "sort_members_action"; //$NON-NLS-1$ public static final String OPEN_PACKAGE_WIZARD_ACTION= PREFIX + "open_package_wizard_action"; //$NON-NLS-1$ public static final String OPEN_PROJECT_WIZARD_ACTION= PREFIX + "open_project_wizard_action"; //$NON-NLS-1$ public static final String OPEN_SNIPPET_WIZARD_ACTION= PREFIX + "open_snippet_wizard_action"; //$NON-NLS-1$ public static final String EDIT_WORKING_SET_ACTION= PREFIX + "edit_working_set_action"; //$NON-NLS-1$ public static final String CLEAR_WORKING_SET_ACTION= PREFIX + "clear_working_set_action"; //$NON-NLS-1$ public static final String GOTO_MARKER_ACTION= PREFIX + "goto_marker_action"; //$NON-NLS-1$ public static final String GOTO_PACKAGE_ACTION= PREFIX + "goto_package_action"; //$NON-NLS-1$ public static final String GOTO_TYPE_ACTION= PREFIX + "goto_type_action"; //$NON-NLS-1$ public static final String GOTO_MATCHING_BRACKET_ACTION= PREFIX + "goto_matching_bracket_action"; //$NON-NLS-1$ public static final String GOTO_NEXT_MEMBER_ACTION= PREFIX + "goto_next_member_action"; //$NON-NLS-1$ public static final String GOTO_PREVIOUS_MEMBER_ACTION= PREFIX + "goto_previous_member_action"; //$NON-NLS-1$ public static final String HISTORY_ACTION= PREFIX + "history_action"; //$NON-NLS-1$ public static final String HISTORY_LIST_ACTION= PREFIX + "history_list_action"; //$NON-NLS-1$ public static final String LEXICAL_SORTING_OUTLINE_ACTION= PREFIX + "lexical_sorting_outline_action"; //$NON-NLS-1$ public static final String LEXICAL_SORTING_BROWSING_ACTION= PREFIX + "lexical_sorting_browsing_action"; //$NON-NLS-1$ public static final String OPEN_JAVA_PERSPECTIVE_ACTION= PREFIX + "open_java_perspective_action"; //$NON-NLS-1$ public static final String ADD_DELEGATE_METHODS_ACTION= PREFIX + "add_delegate_methods_action"; //$NON-NLS-1$ public static final String OPEN_JAVA_BROWSING_PERSPECTIVE_ACTION= PREFIX + "open_java_browsing_perspective_action"; //$NON-NLS-1$ public static final String OPEN_PROJECT_ACTION= PREFIX + "open_project_action"; //$NON-NLS-1$ public static final String OPEN_TYPE_ACTION= PREFIX + "open_type_action"; //$NON-NLS-1$ public static final String OPEN_TYPE_IN_HIERARCHY_ACTION= PREFIX + "open_type_in_hierarchy_action"; //$NON-NLS-1$ public static final String ADD_JAVADOC_STUB_ACTION= PREFIX + "add_javadoc_stub_action"; //$NON-NLS-1$ public static final String ADD_TASK_ACTION= PREFIX + "add_task_action"; //$NON-NLS-1$ public static final String EXTERNALIZE_STRINGS_ACTION= PREFIX + "externalize_strings_action"; //$NON-NLS-1$ public static final String EXTRACT_METHOD_ACTION= PREFIX + "extract_method_action"; //$NON-NLS-1$ public static final String EXTRACT_TEMP_ACTION= PREFIX + "extract_temp_action"; //$NON-NLS-1$ public static final String PROMOTE_TEMP_TO_FIELD_ACTION= PREFIX + "promote_temp_to_field_action"; //$NON-NLS-1$ public static final String CONVERT_ANONYMOUS_TO_NESTED_ACTION= PREFIX + "convert_anonymous_to_nested_action"; //$NON-NLS-1$ public static final String EXTRACT_CONSTANT_ACTION= PREFIX + "extract_constant_action"; //$NON-NLS-1$ public static final String EXTRACT_INTERFACE_ACTION= PREFIX + "extract_interface_action"; //$NON-NLS-1$ public static final String MOVE_INNER_TO_TOP_ACTION= PREFIX + "move_inner_to_top_level_action"; //$NON-NLS-1$ public static final String USE_SUPERTYPE_ACTION= PREFIX + "use_supertype_action"; //$NON-NLS-1$ public static final String FIND_DECLARATIONS_IN_WORKSPACE_ACTION= PREFIX + "find_declarations_in_workspace_action"; //$NON-NLS-1$ public static final String FIND_DECLARATIONS_IN_HIERARCHY_ACTION= PREFIX + "find_declarations_in_hierarchy_action"; //$NON-NLS-1$ public static final String FIND_DECLARATIONS_IN_WORKING_SET_ACTION= PREFIX + "find_declarations_in_working_set_action"; //$NON-NLS-1$ public static final String FIND_IMPLEMENTORS_IN_WORKSPACE_ACTION= PREFIX + "find_implementors_in_workspace_action"; //$NON-NLS-1$ public static final String FIND_IMPLEMENTORS_IN_WORKING_SET_ACTION= PREFIX + "find_implementors_in_working_set_action"; //$NON-NLS-1$ public static final String FIND_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_references_in_workspace_action"; //$NON-NLS-1$ public static final String FIND_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_references_in_hierarchy_action"; //$NON-NLS-1$ public static final String FIND_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_references_in_working_set_action"; //$NON-NLS-1$ public static final String FIND_READ_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_read_references_in_workspace_action"; //$NON-NLS-1$ public static final String FIND_READ_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_read_references_in_hierarchy_action"; //$NON-NLS-1$ public static final String FIND_READ_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_read_references_in_working_set_action"; //$NON-NLS-1$ public static final String FIND_WRITE_REFERENCES_IN_HIERARCHY_ACTION= PREFIX + "find_write_references_in_hierarchy_action"; //$NON-NLS-1$ public static final String FIND_WRITE_REFERENCES_IN_WORKING_SET_ACTION= PREFIX + "find_write_references_in_working_set_action"; //$NON-NLS-1$ public static final String FIND_WRITE_REFERENCES_IN_WORKSPACE_ACTION= PREFIX + "find_write_references_in_workspace_action"; //$NON-NLS-1$ public static final String FIND_OCCURRENCES_IN_FILE_ACTION= PREFIX + "find_occurrences_in_file_action"; //$NON-NLS-1$ public static final String WORKING_SET_FIND_ACTION= PREFIX + "working_set_find_action"; //$NON-NLS-1$ public static final String FIND_STRINGS_TO_EXTERNALIZE_ACTION= PREFIX + "find_strings_to_externalize_action"; //$NON-NLS-1$ public static final String INLINE_ACTION= PREFIX + "inline_action"; //$NON-NLS-1$ public static final String MODIFY_PARAMETERS_ACTION= PREFIX + "modify_parameters_action"; //$NON-NLS-1$ public static final String MOVE_ACTION= PREFIX + "move_action"; //$NON-NLS-1$ public static final String OPEN_ACTION= PREFIX + "open_action"; //$NON-NLS-1$ public static final String OPEN_EXTERNAL_JAVADOC_ACTION= PREFIX + "open_external_javadoc_action"; //$NON-NLS-1$ public static final String OPEN_SUPER_IMPLEMENTATION_ACTION= PREFIX + "open_super_implementation_action"; //$NON-NLS-1$ public static final String PULL_UP_ACTION= PREFIX + "pull_up_action"; //$NON-NLS-1$ public static final String PUSH_DOWN_ACTION= PREFIX + "push_down_action"; //$NON-NLS-1$ public static final String REFRESH_ACTION= PREFIX + "refresh_action"; //$NON-NLS-1$ public static final String RENAME_ACTION= PREFIX + "rename_action"; //$NON-NLS-1$ public static final String SELF_ENCAPSULATE_ACTION= PREFIX + "self_encapsulate_action"; //$NON-NLS-1$ public static final String SHOW_IN_NAVIGATOR_VIEW_ACTION= PREFIX + "show_in_navigator_action"; //$NON-NLS-1$ public static final String SURROUND_WITH_TRY_CATCH_ACTION= PREFIX + "surround_with_try_catch_action"; //$NON-NLS-1$ public static final String OPEN_RESOURCE_ACTION= PREFIX + "open_resource_action"; //$NON-NLS-1$ public static final String SELECT_WORKING_SET_ACTION= PREFIX + "select_working_set_action"; //$NON-NLS-1$ public static final String STRUCTURED_SELECTION_HISTORY_ACTION= PREFIX + "structured_selection_history_action"; //$NON-NLS-1$ public static final String STRUCTURED_SELECT_ENCLOSING_ACTION= PREFIX + "structured_select_enclosing_action"; //$NON-NLS-1$ public static final String STRUCTURED_SELECT_NEXT_ACTION= PREFIX + "structured_select_next_action"; //$NON-NLS-1$ public static final String STRUCTURED_SELECT_PREVIOUS_ACTION= PREFIX + "structured_select_previous_action"; //$NON-NLS-1$ public static final String TOGGLE_ORIENTATION_ACTION= PREFIX + "toggle_orientations_action"; //$NON-NLS-1$ public static final String CUT_ACTION= PREFIX + "cut_action"; //$NON-NLS-1$ public static final String COPY_ACTION= PREFIX + "copy_action"; //$NON-NLS-1$ public static final String PASTE_ACTION= PREFIX + "paste_action"; //$NON-NLS-1$ public static final String DELETE_ACTION= PREFIX + "delete_action"; //$NON-NLS-1$ public static final String SELECT_ALL_ACTION= PREFIX + "select_all_action"; //$NON-NLS-1$ public static final String OPEN_TYPE_HIERARCHY_ACTION= PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$ public static final String COLLAPSE_ALL_ACTION= PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$ public static final String GOTO_RESOURCE_ACTION= PREFIX + "goto_resource_action"; //$NON-NLS-1$ public static final String LINK_EDITOR_ACTION= PREFIX + "link_editor_action"; //$NON-NLS-1$ public static final String GO_INTO_TOP_LEVEL_TYPE_ACTION= PREFIX + "go_into_top_level_type_action"; //$NON-NLS-1$ public static final String COMPARE_WITH_HISTORY_ACTION= PREFIX + "compare_with_history_action"; //$NON-NLS-1$ public static final String REPLACE_WITH_PREVIOUS_FROM_HISTORY_ACTION= PREFIX + "replace_with_previous_from_history_action"; //$NON-NLS-1$ public static final String REPLACE_WITH_HISTORY_ACTION= PREFIX + "replace_with_history_action"; //$NON-NLS-1$ public static final String ADD_FROM_HISTORY_ACTION= PREFIX + "add_from_history_action"; //$NON-NLS-1$ public static final String LAYOUT_FLAT_ACTION= PREFIX + "layout_flat_action"; //$NON-NLS-1$ public static final String LAYOUT_HIERARCHICAL_ACTION= PREFIX + "layout_hierarchical_action"; //$NON-NLS-1$ public static final String NEXT_CHANGE_ACTION= PREFIX + "next_change_action"; //$NON-NLS-1$ public static final String PREVIOUS_CHANGE_ACTION= PREFIX + "previous_change_action"; //$NON-NLS-1$ public static final String NEXT_PROBLEM_ACTION= PREFIX + "next_problem_action"; //$NON-NLS-1$ public static final String PREVIOUS_PROBLEM_ACTION= PREFIX + "previous_problem_action"; //$NON-NLS-1$ public static final String JAVA_SELECT_MARKER_RULER_ACTION= PREFIX + "java_select_marker_ruler_action"; //$NON-NLS-1$ public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action"; //$NON-NLS-1$ public static final String GOTO_PREVIOUS_ERROR_ACTION= PREFIX + "goto_previous_error_action"; //$NON-NLS-1$ public static final String SHOW_QUALIFIED_NAMES_ACTION= PREFIX + "show_qualified_names_action"; //$NON-NLS-1$ public static final String SORT_BY_DEFINING_TYPE_ACTION= PREFIX + "sort_by_defining_type_action"; //$NON-NLS-1$ public static final String FORMAT_ACTION= PREFIX + "format_action"; //$NON-NLS-1$ public static final String COMMENT_ACTION= PREFIX + "comment_action"; //$NON-NLS-1$ public static final String UNCOMMENT_ACTION= PREFIX + "uncomment_action"; //$NON-NLS-1$ public static final String QUICK_FIX_ACTION= PREFIX + "quick_fix_action"; //$NON-NLS-1$ public static final String CONTENT_ASSIST_ACTION= PREFIX + "content_assist_action"; //$NON-NLS-1$ public static final String PARAMETER_HINTS_ACTION= PREFIX + "parameter_hints_action"; //$NON-NLS-1$ public static final String SHOW_JAVADOC_ACTION= PREFIX + "show_javadoc_action"; //$NON-NLS-1$ public static final String SHOW_OUTLINE_ACTION= PREFIX + "show_outline_action"; //$NON-NLS-1$ public static final String OPEN_STRUCTURE_ACTION= PREFIX + "open_structure_action"; //$NON-NLS-1$ // Dialogs public static final String MAINTYPE_SELECTION_DIALOG= PREFIX + "maintype_selection_dialog_context"; //$NON-NLS-1$ public static final String OPEN_TYPE_DIALOG= PREFIX + "open_type_dialog_context"; //$NON-NLS-1$ public static final String SOURCE_ATTACHMENT_DIALOG= PREFIX + "source_attachment_dialog_context"; //$NON-NLS-1$ public static final String LIBRARIES_WORKBOOK_PAGE_ADVANCED_DIALOG= PREFIX + "advanced_dialog_context"; //$NON-NLS-1$ public static final String CONFIRM_SAVE_MODIFIED_RESOURCES_DIALOG= PREFIX + "confirm_save_modified_resources_dialog_context"; //$NON-NLS-1$ public static final String NEW_VARIABLE_ENTRY_DIALOG= PREFIX + "new_variable_dialog_context"; //$NON-NLS-1$ public static final String NONNLS_DIALOG= PREFIX + "nonnls_dialog_context"; //$NON-NLS-1$ public static final String MULTI_MAIN_TYPE_SELECTION_DIALOG= PREFIX + "multi_main_type_selection_dialog_context"; //$NON-NLS-1$ public static final String MULTI_TYPE_SELECTION_DIALOG= PREFIX + "multi_type_selection_dialog_context"; //$NON-NLS-1$ public static final String SUPER_INTERFACE_SELECTION_DIALOG= PREFIX + "super_interface_selection_dialog_context"; //$NON-NLS-1$ public static final String OVERRIDE_TREE_SELECTION_DIALOG= PREFIX + "override_tree_selection_dialog_context"; //$NON-NLS-1$ public static final String MOVE_DESTINATION_DIALOG= PREFIX + "move_destination_dialog_context"; //$NON-NLS-1$ public static final String CHOOSE_VARIABLE_DIALOG= PREFIX + "choose_variable_dialog_context"; //$NON-NLS-1$ public static final String EDIT_TEMPLATE_DIALOG= PREFIX + "edit_template_dialog_context"; //$NON-NLS-1$ public static final String HISTORY_LIST_DIALOG= PREFIX + "history_list_dialog_context"; //$NON-NLS-1$ public static final String IMPORT_ORGANIZE_INPUT_DIALOG= PREFIX + "import_organize_input_dialog_context"; //$NON-NLS-1$ public static final String TODO_TASK_INPUT_DIALOG= PREFIX + "todo_task_input_dialog_context"; //$NON-NLS-1$ public static final String JAVADOC_PROPERTY_DIALOG= PREFIX + "javadoc_property_dialog_context"; //$NON-NLS-1$ public static final String NEW_CONTAINER_DIALOG= PREFIX + "new_container_dialog_context"; //$NON-NLS-1$ public static final String EXCLUSION_PATTERN_DIALOG= PREFIX + "exclusion_pattern_dialog_context"; //$NON-NLS-1$ public static final String OUTPUT_LOCATION_DIALOG= PREFIX + "output_location_dialog_context"; //$NON-NLS-1$ public static final String VARIABLE_CREATION_DIALOG= PREFIX + "variable_creation_dialog_context"; //$NON-NLS-1$ public static final String JAVA_SEARCH_PAGE= PREFIX + "java_search_page_context"; //$NON-NLS-1$ public static final String NLS_SEARCH_PAGE= PREFIX + "nls_search_page_context"; //$NON-NLS-1$ public static final String JAVA_EDITOR= PREFIX + "java_editor_context"; //$NON-NLS-1$ public static final String GOTO_RESOURCE_DIALOG= PREFIX + "goto_resource_dialog"; //$NON-NLS-1$ public static final String COMPARE_DIALOG= PREFIX + "compare_dialog_context"; //$NON-NLS-1$ public static final String ADD_ELEMENT_FROM_HISTORY_DIALOG= PREFIX + "add_element_from_history_dialog_context"; //$NON-NLS-1$ public static final String COMPARE_ELEMENT_WITH_HISTORY_DIALOG= PREFIX + "compare_element_with_history_dialog_context"; //$NON-NLS-1$ public static final String REPLACE_ELEMENT_WITH_HISTORY_DIALOG= PREFIX + "replace_element_with_history_dialog_context"; //$NON-NLS-1$ // view parts public static final String TYPE_HIERARCHY_VIEW= PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$ public static final String PACKAGES_VIEW= PREFIX + "package_view_context"; //$NON-NLS-1$ public static final String PROJECTS_VIEW= PREFIX + "projects_view_context"; //$NON-NLS-1$ public static final String PACKAGES_BROWSING_VIEW= PREFIX + "packages_browsing_view_context"; //$NON-NLS-1$ public static final String TYPES_VIEW= PREFIX + "types_view_context"; //$NON-NLS-1$ public static final String MEMBERS_VIEW= PREFIX + "members_view_context"; //$NON-NLS-1$ // Preference/Property pages public static final String APPEARANCE_PREFERENCE_PAGE= PREFIX + "appearance_preference_page_context"; //$NON-NLS-1$ public static final String SORT_ORDER_PREFERENCE_PAGE= PREFIX + "sort_order_preference_page_context"; //$NON-NLS-1$ public static final String BUILD_PATH_PROPERTY_PAGE= PREFIX + "build_path_property_page_context"; //$NON-NLS-1$ public static final String CP_VARIABLES_PREFERENCE_PAGE= PREFIX + "cp_variables_preference_page_context"; //$NON-NLS-1$ public static final String CODEFORMATTER_PREFERENCE_PAGE= PREFIX + "codeformatter_preference_page_context"; //$NON-NLS-1$ public static final String SOURCE_ATTACHMENT_PROPERTY_PAGE= PREFIX + "source_attachment_property_page_context"; //$NON-NLS-1$ public static final String COMPILER_PROPERTY_PAGE= PREFIX + "compiler_property_page_context"; //$NON-NLS-1$ public static final String TODOTASK_PROPERTY_PAGE= PREFIX + "tasktags_property_page_context"; //$NON-NLS-1$ public static final String CODE_MANIPULATION_PREFERENCE_PAGE= PREFIX + "code_manipulation_preference_context"; //$NON-NLS-1$ public static final String ORGANIZE_IMPORTS_PREFERENCE_PAGE= PREFIX + "organizeimports_preference_page_context"; //$NON-NLS-1$ public static final String JAVA_BASE_PREFERENCE_PAGE= PREFIX + "java_base_preference_page_context"; //$NON-NLS-1$ public static final String REFACTORING_PREFERENCE_PAGE= PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$ public static final String JAVA_EDITOR_PREFERENCE_PAGE= PREFIX + "java_editor_preference_page_context"; //$NON-NLS-1$ public static final String COMPILER_PREFERENCE_PAGE= PREFIX + "compiler_preference_page_context"; //$NON-NLS-1$ public static final String TODOTASK_PREFERENCE_PAGE= PREFIX + "tasktags_preference_page_context"; //$NON-NLS-1$ public static final String TEMPLATE_PREFERENCE_PAGE= PREFIX + "template_preference_page_context"; //$NON-NLS-1$ public static final String JAVADOC_PREFERENCE_PAGE= PREFIX + "javadoc_preference_page_context"; //$NON-NLS-1$ public static final String NEW_JAVA_PROJECT_PREFERENCE_PAGE= PREFIX + "new_java_project_preference_page_context"; //$NON-NLS-1$ public static final String JAVADOC_CONFIGURATION_PROPERTY_PAGE= PREFIX + "new_java_project_preference_page_context"; //$NON-NLS-1$ public static final String JAVA_ELEMENT_INFO_PAGE= PREFIX + "java_element_info_page_context"; //$NON-NLS-1$ // Wizard pages public static final String NEW_JAVAPROJECT_WIZARD_PAGE= PREFIX + "new_javaproject_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_SNIPPET_WIZARD_PAGE= PREFIX + "new_snippet_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_PACKAGE_WIZARD_PAGE= PREFIX + "new_package_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_CLASS_WIZARD_PAGE= PREFIX + "new_class_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_INTERFACE_WIZARD_PAGE= PREFIX + "new_interface_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_PACKAGEROOT_WIZARD_PAGE= PREFIX + "new_packageroot_wizard_page_context"; //$NON-NLS-1$ public static final String JARPACKAGER_WIZARD_PAGE= PREFIX + "jar_packager_wizard_page_context"; //$NON-NLS-1$ public static final String JARMANIFEST_WIZARD_PAGE= PREFIX + "jar_manifest_wizard_page_context"; //$NON-NLS-1$ public static final String JAROPTIONS_WIZARD_PAGE= PREFIX + "jar_options_wizard_page_context"; //$NON-NLS-1$ public static final String JAVA_WORKING_SET_PAGE= PREFIX + "java_working_set_page_context"; //$NON-NLS-1$ public static final String CLASSPATH_CONTAINER_DEFAULT_PAGE= PREFIX + "classpath_container_default_page_context"; //$NON-NLS-1$ public static final String JAVADOC_STANDARD_PAGE= PREFIX + "javadoc_standard_page_context"; //$NON-NLS-1$ public static final String JAVADOC_SPECIFICS_PAGE= PREFIX + "javadoc_specifics_page_context"; //$NON-NLS-1$ public static final String JAVADOC_TREE_PAGE= PREFIX + "javadoc_tree_page_context"; //$NON-NLS-1$ // same help for all refactoring preview pages public static final String REFACTORING_PREVIEW_WIZARD_PAGE= PREFIX + "refactoring_preview_wizard_page_context"; //$NON-NLS-1$ public static final String MOVE_CU_ERROR_WIZARD_PAGE= PREFIX + "move_cu_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_PARAMS_WIZARD_PAGE= PREFIX + "rename_params_wizard_page"; //$NON-NLS-1$ public static final String RENAME_PARAMS_ERROR_WIZARD_PAGE= PREFIX + "rename_params_error_wizard_page"; //$NON-NLS-1$ public static final String EXTERNALIZE_WIZARD_KEYVALUE_PAGE= PREFIX + "externalize_wizard_keyvalue_page_context"; //$NON-NLS-1$ public static final String EXTERNALIZE_WIZARD_PROPERTIES_FILE_PAGE= PREFIX + "externalize_wizard_properties_file_page_context"; //$NON-NLS-1$ public static final String EXTERNALIZE_ERROR_WIZARD_PAGE= PREFIX + "externalize_error_wizard_page_context"; //$NON-NLS-1$ public static final String EXTRACT_INTERFACE_WIZARD_PAGE= PREFIX + "extract_interface_temp_page_context"; //$NON-NLS-1$ public static final String EXTRACT_INTERFACE_ERROR_WIZARD_PAGE= PREFIX + "extract_interface_error_wizard_page_context"; //$NON-NLS-1$ public static final String EXTRACT_METHOD_WIZARD_PAGE= PREFIX + "extract_method_wizard_page_context"; //$NON-NLS-1$ public static final String EXTRACT_METHOD_ERROR_WIZARD_PAGE= PREFIX + "extract_method_error_wizard_page_context"; //$NON-NLS-1$ public static final String EXTRACT_TEMP_WIZARD_PAGE= PREFIX + "extract_temp_page_context"; //$NON-NLS-1$ public static final String EXTRACT_TEMP_ERROR_WIZARD_PAGE= PREFIX + "extract_temp_error_wizard_page_context"; //$NON-NLS-1$ public static final String EXTRACT_CONSTANT_WIZARD_PAGE= PREFIX + "extract_constant_page_context"; //$NON-NLS-1$ public static final String EXTRACT_CONSTANT_ERROR_WIZARD_PAGE= PREFIX + "extract_constant_error_wizard_page_context"; //$NON-NLS-1$ public static final String PROMOTE_TEMP_TO_FIELD_WIZARD_PAGE= PREFIX + "promote_temp_to_field_page_context"; //$NON-NLS-1$ public static final String PROMOTE_TEMP_TO_FIELD_ERROR_WIZARD_PAGE= PREFIX + "promote_temp_to_field_error_wizard_page_context"; //$NON-NLS-1$ public static final String CONVERT_ANONYMOUS_TO_NESTED_WIZARD_PAGE= PREFIX + "convert_anonymous_to_nested_page_context"; //$NON-NLS-1$ public static final String CONVERT_ANONYMOUS_TO_NESTED_ERROR_WIZARD_PAGE= PREFIX + "convert_anonymous_to_nested_error_wizard_page_context"; //$NON-NLS-1$ public static final String MODIFY_PARAMETERS_WIZARD_PAGE= PREFIX + "modify_parameters_wizard_page_context"; //$NON-NLS-1$ public static final String MODIFY_PARAMETERS_ERROR_WIZARD_PAGE= PREFIX + "modify_parameters_error_wizard_page_context"; //$NON-NLS-1$ public static final String MOVE_MEMBERS_WIZARD_PAGE= PREFIX + "move_members_wizard_page_context"; //$NON-NLS-1$ public static final String MOVE_MEMBERS_ERROR_WIZARD_PAGE= PREFIX + "move_members_error_error_wizard_page_context"; //$NON-NLS-1$ public static final String MOVE_INNER_TO_TOP_WIZARD_PAGE= PREFIX + "move_inner_to_top_wizard_page_context"; //$NON-NLS-1$ public static final String MOVE_INNER_TO_TOP_ERROR_WIZARD_PAGE= PREFIX + "move_inner_to_top_error_error_wizard_page_context"; //$NON-NLS-1$ public static final String PULL_UP_WIZARD_PAGE= PREFIX + "pull_up_wizard_page_context"; //$NON-NLS-1$ public static final String PULL_UP_ERROR_WIZARD_PAGE= PREFIX + "pull_up_error_error_wizard_page_context"; //$NON-NLS-1$ public static final String PUSH_DOWN_WIZARD_PAGE= PREFIX + "push_down_wizard_page_context"; //$NON-NLS-1$ public static final String PUSH_DOWN_ERROR_WIZARD_PAGE= PREFIX + "push_down_error_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_PACKAGE_WIZARD_PAGE= PREFIX + "rename_package_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_PACKAGE_ERROR_WIZARD_PAGE= PREFIX + "rename_package_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_TEMP_WIZARD_PAGE= PREFIX + "rename_local_variable_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_TEMP_ERROR_WIZARD_PAGE= PREFIX + "rename_local_variable_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_CU_WIZARD_PAGE= PREFIX + "rename_cu_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_CU_ERROR_WIZARD_PAGE= PREFIX + "rename_cu_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_METHOD_WIZARD_PAGE= PREFIX + "rename_method_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_METHOD_ERROR_WIZARD_PAGE= PREFIX + "rename_method_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_TYPE_WIZARD_PAGE= PREFIX + "rename_type_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_TYPE_ERROR_WIZARD_PAGE= PREFIX + "rename_type_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_FIELD_WIZARD_PAGE= PREFIX + "rename_field_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_FIELD_ERROR_WIZARD_PAGE= PREFIX + "rename_field_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_RESOURCE_WIZARD_PAGE= PREFIX + "rename_resource_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_RESOURCE_ERROR_WIZARD_PAGE= PREFIX + "rename_resource_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_JAVA_PROJECT_WIZARD_PAGE= PREFIX + "rename_java_project_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_JAVA_PROJECT_ERROR_WIZARD_PAGE= PREFIX + "rename_java_project_error_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_SOURCE_FOLDER_WIZARD_PAGE= PREFIX + "rename_source_folder_wizard_page_context"; //$NON-NLS-1$ public static final String RENAME_SOURCE_FOLDER_ERROR_WIZARD_PAGE= PREFIX + "rename_source_folder_error_wizard_page_context"; //$NON-NLS-1$ public static final String SEF_WIZARD_PAGE= PREFIX + "self_encapsulate_field_wizard_page_context"; //$NON-NLS-1$ public static final String SEF_ERROR_WIZARD_PAGE= PREFIX + "self_encapsulate_field_error_wizard_page_context"; //$NON-NLS-1$ public static final String USE_SUPERTYPE_WIZARD_PAGE= PREFIX + "use_supertype_wizard_page_context"; //$NON-NLS-1$ public static final String USE_SUPERTYPE_ERROR_WIZARD_PAGE= PREFIX + "use_supertype_error_wizard_page_context"; //$NON-NLS-1$ public static final String INLINE_METHOD_WIZARD_PAGE= PREFIX + "inline_method_wizard_page_context"; //$NON-NLS-1$ public static final String INLINE_METHOD_ERROR_WIZARD_PAGE= PREFIX + "inline_method_error_wizard_page_context"; //$NON-NLS-1$ public static final String INLINE_CONSTANT_WIZARD_PAGE= PREFIX + "inline_constant_wizard_page_context"; //$NON-NLS-1$ public static final String INLINE_CONSTANT_ERROR_WIZARD_PAGE= PREFIX + "inline_constant_error_wizard_page_context"; //$NON-NLS-1$ public static final String INLINE_TEMP_ERROR_WIZARD_PAGE= PREFIX + "inline_temp_error_wizard_page_context"; //$NON-NLS-1$ // reused ui-blocks public static final String BUILD_PATH_BLOCK= PREFIX + "build_paths_context"; //$NON-NLS-1$ public static final String SOURCE_ATTACHMENT_BLOCK= PREFIX + "source_attachment_context"; //$NON-NLS-1$ // Custom Filters public static final String CUSTOM_FILTERS_DIALOG= PREFIX + "open_custom_filters_dialog_context"; //$NON-NLS-1$ // Call Hierarchy public static final String CALL_HIERARCHY_VIEW= PREFIX + "call_hierarchy_view_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_FILTERS_DIALOG= PREFIX + "call_hierarchy_filters_dialog_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_FOCUS_ON_SELECTION_ACTION= PREFIX + "call_hierarchy_focus_on_selection_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_HISTORY_ACTION= PREFIX + "call_hierarchy_history_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_HISTORY_DROP_DOWN_ACTION= PREFIX + "call_hierarchy_history_drop_down_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_REFRESH_ACTION= PREFIX + "call_hierarchy_refresh_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_SEARCH_SCOPE_ACTION= PREFIX + "call_hierarchy_search_scope_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION= PREFIX + "call_hierarchy_toggle_call_mode_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_TOGGLE_JAVA_LABEL_FORMAT_ACTION= PREFIX + "call_hierarchy_toggle_java_label_format_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_TOGGLE_ORIENTATION_ACTION= PREFIX + "call_hierarchy_toggle_call_mode_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_COPY_ACTION= PREFIX + "call_hierarchy_copy_action_context"; //$NON-NLS-1$ public static final String CALL_HIERARCHY_TOGGLE_IMPLEMENTORS_ACTION= PREFIX + "call_hierarchy_toggle_implementors_action_context"; //$NON-NLS-1$ }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyUI.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.OpenStrategy; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.IJavaStatusConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; class CallHierarchyUI { private static final int DEFAULT_MAX_CALL_DEPTH= 10; private static final String PREF_MAX_CALL_DEPTH = "PREF_MAX_CALL_DEPTH"; //$NON-NLS-1$ private static CallHierarchyUI fgInstance; private CallHierarchyUI() { } public static CallHierarchyUI getDefault() { if (fgInstance == null) { fgInstance = new CallHierarchyUI(); } return fgInstance; } /** * Returns the maximum tree level allowed * @return int */ public int getMaxCallDepth() { int maxCallDepth; IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); maxCallDepth = settings.getInt(PREF_MAX_CALL_DEPTH); if (maxCallDepth < 1 || maxCallDepth > 99) { maxCallDepth= DEFAULT_MAX_CALL_DEPTH; } return maxCallDepth; } public void setMaxCallDepth(int maxCallDepth) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); settings.setValue(PREF_MAX_CALL_DEPTH, maxCallDepth); } public static void jumpToMember(IJavaElement element) { if (element != null) { try { IEditorPart methodEditor = EditorUtility.openInEditor(element, true); JavaUI.revealInEditor(methodEditor, (IJavaElement) element); } catch (JavaModelException e) { JavaPlugin.log(e); } catch (PartInitException e) { JavaPlugin.log(e); } } } public static void jumpToLocation(CallLocation callLocation) { try { IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(), false); if (methodEditor instanceof ITextEditor) { ITextEditor editor = (ITextEditor) methodEditor; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } catch (JavaModelException e) { JavaPlugin.log(e); } catch (PartInitException e) { JavaPlugin.log(e); } } public static void openInEditor(Object element, Shell shell, String title) { CallLocation callLocation= null; if (element instanceof CallLocation) { callLocation= (CallLocation) element; } else if (element instanceof CallLocation) { callLocation= CallHierarchy.getCallLocation(element); } if (callLocation == null) { return; } try { boolean activateOnOpen = OpenStrategy.activateOnOpen(); IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(), activateOnOpen); if (methodEditor instanceof ITextEditor) { ITextEditor editor = (ITextEditor) methodEditor; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } catch (JavaModelException e) { JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.message"), e)); //$NON-NLS-1$ ErrorDialog.openError(shell, title, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.messageProblems"), //$NON-NLS-1$ e.getStatus()); } catch (PartInitException x) { String name = callLocation.getCalledMember().getElementName(); MessageDialog.openError(shell, CallHierarchyMessages.getString( "CallHierarchyUI.open_in_editor.error.messageProblems"), //$NON-NLS-1$ CallHierarchyMessages.getFormattedString( "CallHierarchyUI.open_in_editor.error.messageArgs", //$NON-NLS-1$ new String[] { name, x.getMessage() })); } } /** * @param elem * @return */ public static IEditorPart isOpenInEditor(Object elem) { IJavaElement javaElement= null; if (elem instanceof MethodWrapper) { javaElement= ((MethodWrapper) elem).getMember(); } else if (elem instanceof CallLocation) { javaElement= ((CallLocation) elem).getCalledMember(); } if (javaElement != null) { return EditorUtility.isOpenInEditor(javaElement); } return null; } }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewAdapter.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; /** * This class adapts a Call Hierarchy view to return an adapted Call Hierarchy view site. * * @see org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyViewSiteAdapter */ class CallHierarchyViewAdapter implements IViewPart { private IViewSite fSite; /** * Constructor for SearchViewAdapter. */ public CallHierarchyViewAdapter(IViewSite site) { fSite= site; } /** * @see org.eclipse.ui.IWorkbenchPart#getSite() */ public IWorkbenchPartSite getSite() { return fSite; } /* * @see org.eclipse.ui.IViewPart#getViewSite() */ public IViewSite getViewSite() { return fSite; } // --------- only empty stubs below --------- /* * @see org.eclipse.ui.IViewPart#init(IViewSite) */ public void init(IViewSite site) throws PartInitException { } /* * @see org.eclipse.ui.IViewPart#init(IViewSite, IMemento) */ public void init(IViewSite site, IMemento memento) throws PartInitException { } /* * @see org.eclipse.ui.IViewPart#saveState(IMemento) */ public void saveState(IMemento memento) { } /* * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(IPropertyListener) */ public void addPropertyListener(IPropertyListener listener) { } /* * @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite) */ public void createPartControl(Composite parent) { } /* * @see org.eclipse.ui.IWorkbenchPart#dispose() */ public void dispose() { } /* * @see org.eclipse.ui.IWorkbenchPart#getTitle() */ public String getTitle() { return null; } /* * @see org.eclipse.ui.IWorkbenchPart#getTitleImage() */ public Image getTitleImage() { return null; } /* * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() */ public String getTitleToolTip() { return null; } /* * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(IPropertyListener) */ public void removePropertyListener(IPropertyListener listener) { } /* * @see org.eclipse.ui.IWorkbenchPart#setFocus() */ public void setFocus() { } /* * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) */ public Object getAdapter(Class adapter) { return null; } }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTarget; 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.Label; import org.eclipse.swt.widgets.Menu; 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.dialogs.IDialogSettings; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TableViewer; 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.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter; import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter; 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.EditorUtility; import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter; import org.eclipse.jdt.internal.ui.util.JavaUIHelp; import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater; import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy; import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation; import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; /** * This is the main view for the callers plugin. It builds a tree of callers/callees * and allows the user to double click an entry to go to the selected method. * */ public class CallHierarchyViewPart extends ViewPart implements IDoubleClickListener, ISelectionChangedListener { private CallHierarchyViewSiteAdapter fViewSiteAdapter; private CallHierarchyViewAdapter fViewAdapter; public static final String CALLERS_VIEW_ID = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$ private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$ private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$ private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$ private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$ private static final String TAG_IMPLEMENTORS_MODE = "implementors_mode"; //$NON-NLS-1$ private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ static final int VIEW_ORIENTATION_VERTICAL = 0; static final int VIEW_ORIENTATION_HORIZONTAL = 1; static final int VIEW_ORIENTATION_SINGLE = 2; static final int CALL_MODE_CALLERS = 0; static final int CALL_MODE_CALLEES = 1; static final int IMPLEMENTORS_ENABLED = 0; static final int IMPLEMENTORS_DISABLED = 1; static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$ static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.ui.CallHierarchy"; //$NON-NLS-1$ private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$ private static final int PAGE_EMPTY = 0; private static final int PAGE_VIEWER = 1; private Label fNoHierarchyShownLabel; private PageBook fPagebook; private IDialogSettings fDialogSettings; private int fCurrentOrientation; private int fCurrentCallMode; private int fCurrentImplementorsMode; private MethodWrapper fCalleeRoot; private MethodWrapper fCallerRoot; private IMemento fMemento; private IMethod fShownMethod; private SelectionProviderMediator fSelectionProviderMediator; private List fMethodHistory; private TableViewer fLocationViewer; private Menu fLocationContextMenu; private SashForm fHierarchyLocationSplitter; private SearchScopeActionGroup fSearchScopeActions; private ToggleOrientationAction[] fToggleOrientationActions; private ToggleCallModeAction[] fToggleCallModeActions; private ToggleImplementorsAction[] fToggleImplementorsActions; private CallHierarchyFiltersActionGroup fFiltersActionGroup; private HistoryDropDownAction fHistoryDropDownAction; private RefreshAction fRefreshAction; private OpenLocationAction fOpenLocationAction; private FocusOnSelectionAction fFocusOnSelectionAction; private CompositeActionGroup fActionGroups; private CallHierarchyViewer fCallHierarchyViewer; private boolean fShowCallDetails; public CallHierarchyViewPart() { super(); fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); fMethodHistory = new ArrayList(); } public void setFocus() { fPagebook.setFocus(); } /** * Sets the history entries */ public void setHistoryEntries(IMethod[] elems) { fMethodHistory.clear(); for (int i = 0; i < elems.length; i++) { fMethodHistory.add(elems[i]); } updateHistoryEntries(); } /** * Gets all history entries. */ public IMethod[] getHistoryEntries() { if (fMethodHistory.size() > 0) { updateHistoryEntries(); } return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]); } /** * Method setMethod. * @param method */ public void setMethod(IMethod method) { if (method == null) { showPage(PAGE_EMPTY); return; } if ((method != null) && !method.equals(fShownMethod)) { addHistoryEntry(method); } this.fShownMethod = method; refresh(); } public IMethod getMethod() { return fShownMethod; } /** * called from ToggleOrientationAction. * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL */ void setOrientation(int orientation) { if (fCurrentOrientation != orientation) { if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) { if (orientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(false); } else { if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) { setShowCallDetails(true); } boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL; fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL); } fHierarchyLocationSplitter.layout(); } for (int i = 0; i < fToggleOrientationActions.length; i++) { fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation()); } fCurrentOrientation = orientation; fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation); } } /** * called from ToggleCallModeAction. * @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES */ void setCallMode(int mode) { if (fCurrentCallMode != mode) { for (int i = 0; i < fToggleCallModeActions.length; i++) { fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode()); } fCurrentCallMode = mode; fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode); updateView(); } } /** * called from ToggleImplementorsAction. * @param implementorsMode IMPLEMENTORS_USED or IMPLEMENTORS_NOT_USED */ void setImplementorsMode(int implementorsMode) { if (fCurrentImplementorsMode != implementorsMode) { for (int i = 0; i < fToggleImplementorsActions.length; i++) { fToggleImplementorsActions[i].setChecked(implementorsMode == fToggleImplementorsActions[i].getImplementorsMode()); } fCurrentImplementorsMode = implementorsMode; CallHierarchy.getDefault().setSearchUsingImplementorsEnabled(implementorsMode == IMPLEMENTORS_ENABLED); updateView(); } } public IJavaSearchScope getSearchScope() { return fSearchScopeActions.getSearchScope(); } public void setShowCallDetails(boolean show) { fShowCallDetails = show; showOrHideCallDetailsView(); } private void initDragAndDrop() { Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() }; int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; addDragAdapters(fCallHierarchyViewer, ops, transfers); addDropAdapters(fCallHierarchyViewer, ops | DND.DROP_DEFAULT, transfers); addDropAdapters(fLocationViewer, ops | DND.DROP_DEFAULT, transfers); //dnd on empty hierarchy DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT); dropTarget.setTransfer(transfers); dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer)); } private void addDropAdapters(StructuredViewer viewer, int ops, Transfer[] transfers){ TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new CallHierarchyTransferDropAdapter(this, viewer) }; viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); } private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) { TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] { new SelectionTransferDragAdapter(new SelectionProviderAdapter(viewer)) }; viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners)); } public void createPartControl(Composite parent) { fPagebook = new PageBook(parent, SWT.NONE); // Page 1: Viewers createHierarchyLocationSplitter(fPagebook); createCallHierarchyViewer(fHierarchyLocationSplitter); createLocationViewer(fHierarchyLocationSplitter); // Page 2: Nothing selected fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP); fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString( "CallHierarchyViewPart.empty")); //$NON-NLS-1$ showPage(PAGE_EMPTY); WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] { fCallHierarchyViewer, fLocationViewer }); IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager(); fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater( slManager)); getSite().setSelectionProvider(fSelectionProviderMediator); makeActions(); fillViewMenu(); fillActionBars(); initOrientation(); initCallMode(); initImplementorsMode(); if (fMemento != null) { restoreState(fMemento); } initDragAndDrop(); } /** * @param PAGE_EMPTY */ private void showPage(int page) { if (page == PAGE_EMPTY) { fPagebook.showPage(fNoHierarchyShownLabel); } else { fPagebook.showPage(fHierarchyLocationSplitter); } enableActions(page != PAGE_EMPTY); } /** * @param b */ private void enableActions(boolean enabled) { fLocationContextMenu.setEnabled(enabled); // TODO: Is it possible to disable the actions on the toolbar and on the view menu? } /** * Restores the type hierarchy settings from a memento. */ private void restoreState(IMemento memento) { Integer orientation= memento.getInteger(TAG_ORIENTATION); if (orientation != null) { setOrientation(orientation.intValue()); } Integer callMode= memento.getInteger(TAG_CALL_MODE); if (callMode != null) { setCallMode(callMode.intValue()); } Integer implementorsMode= memento.getInteger(TAG_IMPLEMENTORS_MODE); if (implementorsMode != null) { setImplementorsMode(implementorsMode.intValue()); } Integer ratio = memento.getInteger(TAG_RATIO); if (ratio != null) { fHierarchyLocationSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() }); } } private void initCallMode() { int mode; try { mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE); if ((mode < 0) || (mode > 1)) { mode = CALL_MODE_CALLERS; } } catch (NumberFormatException e) { mode = CALL_MODE_CALLERS; } // force the update fCurrentCallMode = -1; // will fill the main tool bar setCallMode(mode); } private void initImplementorsMode() { int mode; mode= CallHierarchy.getDefault().isSearchUsingImplementorsEnabled() ? IMPLEMENTORS_ENABLED : IMPLEMENTORS_DISABLED; fCurrentImplementorsMode= -1; // will fill the main tool bar setImplementorsMode(mode); } private void initOrientation() { int orientation; try { orientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION); if ((orientation < 0) || (orientation > 2)) { orientation = VIEW_ORIENTATION_VERTICAL; } } catch (NumberFormatException e) { orientation = VIEW_ORIENTATION_VERTICAL; } // force the update fCurrentOrientation = -1; // will fill the main tool bar setOrientation(orientation); } private void fillViewMenu() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager viewMenu = actionBars.getMenuManager(); viewMenu.add(new Separator()); for (int i = 0; i < fToggleCallModeActions.length; i++) { viewMenu.add(fToggleCallModeActions[i]); } viewMenu.add(new Separator()); // TODO: Should be reenabled if this toggle should actually be used // for (int i = 0; i < fToggleImplementorsActions.length; i++) { // viewMenu.add(fToggleImplementorsActions[i]); // } // // viewMenu.add(new Separator()); for (int i = 0; i < fToggleOrientationActions.length; i++) { viewMenu.add(fToggleOrientationActions[i]); } } /** * */ public void dispose() { disposeMenu(fLocationContextMenu); if (fActionGroups != null) fActionGroups.dispose(); super.dispose(); } /** * Double click listener which jumps to the method in the source code. * * @return IDoubleClickListener */ public void doubleClick(DoubleClickEvent event) { jumpToSelection(event.getSelection()); } /** * Goes to the selected entry, without updating the order of history entries. */ public void gotoHistoryEntry(IMethod entry) { if (fMethodHistory.contains(entry)) { setMethod(entry); } } /* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); fMemento = memento; } public void jumpToDeclarationOfSelection() { ISelection selection = null; selection = getSelection(); if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof IMember) { CallHierarchyUI.jumpToMember((IMember) structuredSelection); } else if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToMember(((CallLocation) structuredSelection).getCalledMember()); } } } public void jumpToSelection(ISelection selection) { if ((selection != null) && selection instanceof IStructuredSelection) { Object structuredSelection = ((IStructuredSelection) selection).getFirstElement(); if (structuredSelection instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) structuredSelection; CallLocation firstCall = methodWrapper.getMethodCall() .getFirstCallLocation(); if (firstCall != null) { CallHierarchyUI.jumpToLocation(firstCall); } else { CallHierarchyUI.jumpToMember(methodWrapper.getMember()); } } else if (structuredSelection instanceof CallLocation) { CallHierarchyUI.jumpToLocation((CallLocation) structuredSelection); } } } /** * */ public void refresh() { setCalleeRoot(null); setCallerRoot(null); updateView(); } public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } memento.putInteger(TAG_CALL_MODE, fCurrentCallMode); memento.putInteger(TAG_IMPLEMENTORS_MODE, fCurrentImplementorsMode); memento.putInteger(TAG_ORIENTATION, fCurrentOrientation); int[] weigths = fHierarchyLocationSplitter.getWeights(); int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); } /** * @return ISelectionChangedListener */ public void selectionChanged(SelectionChangedEvent e) { if (e.getSelectionProvider() == fCallHierarchyViewer) { methodSelectionChanged(e.getSelection()); } else { locationSelectionChanged(e.getSelection()); } } /** * @param selection */ private void locationSelectionChanged(ISelection selection) {} /** * @param selection */ private void methodSelectionChanged(ISelection selection) { if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof MethodWrapper) { MethodWrapper methodWrapper = (MethodWrapper) selectedElement; revealElementInEditor(methodWrapper, fCallHierarchyViewer); updateLocationsView(methodWrapper); } else { updateLocationsView(null); } } } private void revealElementInEditor(Object elem, Viewer originViewer) { // 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; } if (fSelectionProviderMediator.getViewerInFocus() != originViewer) { return; } if (elem instanceof MethodWrapper) { CallLocation callLocation = CallHierarchy.getCallLocation(elem); if (callLocation != null) { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation); if (editorPart != null) { getSite().getPage().bringToTop(editorPart); if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart())); } } } else { IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember()); } } else if (elem instanceof IJavaElement) { IEditorPart editorPart = EditorUtility.isOpenInEditor(elem); if (editorPart != null) { // getSite().getPage().removePartListener(fPartListener); getSite().getPage().bringToTop(editorPart); EditorUtility.revealInEditor(editorPart, (IJavaElement) elem); // getSite().getPage().addPartListener(fPartListener); } } } /** * Returns the current selection. */ protected ISelection getSelection() { return getSite().getSelectionProvider().getSelection(); } protected void fillContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); } protected void handleKeyEvent(KeyEvent event) { if (event.stateMask == 0) { if (event.keyCode == SWT.F5) { if ((fRefreshAction != null) && fRefreshAction.isEnabled()) { fRefreshAction.run(); return; } } } } private IActionBars getActionBars() { return getViewSite().getActionBars(); } private void setCalleeRoot(MethodWrapper calleeRoot) { this.fCalleeRoot = calleeRoot; } private MethodWrapper getCalleeRoot() { if (fCalleeRoot == null) { fCalleeRoot = (MethodWrapper) CallHierarchy.getDefault().getCalleeRoot(fShownMethod); } return fCalleeRoot; } private void setCallerRoot(MethodWrapper callerRoot) { this.fCallerRoot = callerRoot; } private MethodWrapper getCallerRoot() { if (fCallerRoot == null) { fCallerRoot = (MethodWrapper) CallHierarchy.getDefault().getCallerRoot(fShownMethod); } return fCallerRoot; } /** * Adds the entry if new. Inserted at the beginning of the history entries list. */ private void addHistoryEntry(IJavaElement entry) { if (fMethodHistory.contains(entry)) { fMethodHistory.remove(entry); } fMethodHistory.add(0, entry); fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * @param parent */ private void createLocationViewer(Composite parent) { fLocationViewer = new TableViewer(parent, SWT.NONE); fLocationViewer.setContentProvider(new ArrayContentProvider()); fLocationViewer.setLabelProvider(new LocationLabelProvider()); fLocationViewer.setInput(new ArrayList()); fLocationViewer.getControl().addKeyListener(createKeyListener()); JavaUIHelp.setHelp(fLocationViewer, IJavaHelpContextIds.CALL_HIERARCHY_VIEW); fOpenLocationAction = new OpenLocationAction(getSite()); fLocationViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { fOpenLocationAction.run(); } }); // fListViewer.addDoubleClickListener(this); MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); fLocationContextMenu = menuMgr.createContextMenu(fLocationViewer.getControl()); fLocationViewer.getControl().setMenu(fLocationContextMenu); // Register viewer with site. This must be done before making the actions. getSite().registerContextMenu(menuMgr, fLocationViewer); } private void createHierarchyLocationSplitter(Composite parent) { fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE); fHierarchyLocationSplitter.addKeyListener(createKeyListener()); } private void createCallHierarchyViewer(Composite parent) { fCallHierarchyViewer = new CallHierarchyViewer(parent, this); fCallHierarchyViewer.addKeyListener(createKeyListener()); fCallHierarchyViewer.addSelectionChangedListener(this); fCallHierarchyViewer.initContextMenu(new IMenuListener() { public void menuAboutToShow(IMenuManager menu) { fillCallHierarchyViewerContextMenu(menu); } }, ID_CALL_HIERARCHY, getSite()); } /** * @param fCallHierarchyViewer * @param menu */ protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); } private void disposeMenu(Menu contextMenu) { if ((contextMenu != null) && !contextMenu.isDisposed()) { contextMenu.dispose(); } } private void fillActionBars() { IActionBars actionBars = getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); fActionGroups.fillActionBars(actionBars); toolBar.add(fHistoryDropDownAction); for (int i = 0; i < fToggleCallModeActions.length; i++) { toolBar.add(fToggleCallModeActions[i]); } } private KeyListener createKeyListener() { KeyListener keyListener = new KeyAdapter() { public void keyReleased(KeyEvent event) { handleKeyEvent(event); } }; return keyListener; } /** * */ private void makeActions() { fRefreshAction = new RefreshAction(this); fFocusOnSelectionAction = new FocusOnSelectionAction(this); fSearchScopeActions = new SearchScopeActionGroup(this); fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer); fHistoryDropDownAction = new HistoryDropDownAction(this); fHistoryDropDownAction.setEnabled(false); fToggleOrientationActions = new ToggleOrientationAction[] { new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL), new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE) }; fToggleCallModeActions = new ToggleCallModeAction[] { new ToggleCallModeAction(this, CALL_MODE_CALLERS), new ToggleCallModeAction(this, CALL_MODE_CALLEES) }; fToggleImplementorsActions = new ToggleImplementorsAction[] { new ToggleImplementorsAction(this, IMPLEMENTORS_ENABLED), new ToggleImplementorsAction(this, IMPLEMENTORS_DISABLED) }; fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenEditorActionGroup(getViewAdapter()), new OpenViewActionGroup(getViewAdapter()), new CCPActionGroup(getViewAdapter()), new GenerateActionGroup(getViewAdapter()), new RefactorActionGroup(getViewAdapter()), new JavaSearchActionGroup(getViewAdapter()), fSearchScopeActions, fFiltersActionGroup }); } private CallHierarchyViewAdapter getViewAdapter() { if (fViewAdapter == null) { fViewAdapter= new CallHierarchyViewAdapter(getViewSiteAdapter()); } return fViewAdapter; } private CallHierarchyViewSiteAdapter getViewSiteAdapter() { if (fViewSiteAdapter == null) { fViewSiteAdapter= new CallHierarchyViewSiteAdapter(this.getViewSite()); } return fViewSiteAdapter; } private void showOrHideCallDetailsView() { if (fShowCallDetails) { fHierarchyLocationSplitter.setMaximizedControl(null); } else { fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl()); } } private void updateLocationsView(MethodWrapper methodWrapper) { if (methodWrapper != null) { fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations()); } else { fLocationViewer.setInput(""); //$NON-NLS-1$ } } private void updateHistoryEntries() { for (int i = fMethodHistory.size() - 1; i >= 0; i--) { IMethod method = (IMethod) fMethodHistory.get(i); if (!method.exists()) { fMethodHistory.remove(i); } } fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty()); } /** * Method updateView. */ private void updateView() { if ((fShownMethod != null)) { showPage(PAGE_VIEWER); CallHierarchy.getDefault().setSearchScope(getSearchScope()); if (fCurrentCallMode == CALL_MODE_CALLERS) { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsToMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCallerRoot()); } else { setTitle(CallHierarchyMessages.getString("CallHierarchyViewPart.callsFromMethod")); //$NON-NLS-1$ fCallHierarchyViewer.setMethodWrapper(getCalleeRoot()); } updateLocationsView(null); } } static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) { IWorkbenchPage workbenchPage = site.getPage(); CallHierarchyViewPart callersView = null; try { callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.CALLERS_VIEW_ID); } catch (PartInitException e) { JavaPlugin.log(e); } return callersView; } }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/OpenCallHierarchyActionDelegate.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; /** * @see IEditorActionDelegate */ public class OpenCallHierarchyActionDelegate implements IEditorActionDelegate, IObjectActionDelegate { private IMethod fSelectedMethod; private IEditorPart fEditor; private IWorkbenchPartSite fSite; /** * The constructor. */ public OpenCallHierarchyActionDelegate() {} /** * @see IEditorActionDelegate#setActiveEditor */ public void setActiveEditor(IAction action, IEditorPart targetEditor) { fEditor= targetEditor; fSite= targetEditor != null ? targetEditor.getSite() : null; fSelectedMethod= null; } /* (non-Javadoc) * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { fEditor= null; fSite= targetPart != null ? targetPart.getSite() : null; fSelectedMethod= null; } /** * @see IEditorActionDelegate#run */ public void run(IAction action) { CallHierarchyViewPart callersView = findAndShowCallersView(); if (callersView != null) { try { IJavaElement element = null; if (fSelectedMethod != null) { element = fSelectedMethod; } else { element = SelectionConverter.codeResolve((JavaEditor) fEditor, getShell(), CallHierarchyMessages.getString("OpenCallHierarchyActionDelegate.error.title"), //$NON-NLS-1$ CallHierarchyMessages.getString("OpenCallHierarchyActionDelegate.error.message")); //$NON-NLS-1$ if (element == null || element.getElementType() != IJavaElement.METHOD) { element = SelectionConverter.getElementAtOffset((JavaEditor) fEditor); } } if ((element != null) && (element.getElementType() == IJavaElement.METHOD)) { callersView.setMethod((IMethod) element); } } catch (JavaModelException e) { JavaPlugin.log(e); } } } private Shell getShell() { return JavaPlugin.getActiveWorkbenchWindow().getShell(); } /* (non-Javadoc) * @see IEditorActionDelegate#selectionChanged */ public void selectionChanged(IAction action, ISelection selection) { fSelectedMethod = null; if ((selection != null) && selection instanceof IStructuredSelection) { Object o = ((IStructuredSelection) selection).getFirstElement(); if (o instanceof IMethod) { IMethod method = (IMethod) o; fSelectedMethod = method; } } } private CallHierarchyViewPart findAndShowCallersView() { if (fSite != null) { return CallHierarchyViewPart.findAndShowCallersView(fSite); } return null; } }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/IJavaEditorActionDefinitionIds.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; /** * Defines the definition IDs for the Java editor actions. * * <p> * This interface is not intended to be implemented or extended. * </p>. * * @since 2.0 */ public interface IJavaEditorActionDefinitionIds extends ITextEditorActionDefinitionIds { // edit /** * Action definition ID of the edit -> go to matching bracket action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.matching.bracket"</code>). * * @since 2.1 */ public static final String GOTO_MATCHING_BRACKET= "org.eclipse.jdt.ui.edit.text.java.goto.matching.bracket"; //$NON-NLS-1$ /** * Action definition ID of the edit -> go to next member action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.next.member"</code>). * * @since 2.1 */ public static final String GOTO_NEXT_MEMBER= "org.eclipse.jdt.ui.edit.text.java.goto.next.member"; //$NON-NLS-1$ /** * Action definition ID of the edit -> go to previous member action * (value <code>"org.eclipse.jdt.ui.edit.text.java.goto.previous.member"</code>). * * @since 2.1 */ public static final String GOTO_PREVIOUS_MEMBER= "org.eclipse.jdt.ui.edit.text.java.goto.previous.member"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select enclosing action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.enclosing"</code>). */ public static final String SELECT_ENCLOSING= "org.eclipse.jdt.ui.edit.text.java.select.enclosing"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select next action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.next"</code>). */ public static final String SELECT_NEXT= "org.eclipse.jdt.ui.edit.text.java.select.next"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select previous action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.previous"</code>). */ public static final String SELECT_PREVIOUS= "org.eclipse.jdt.ui.edit.text.java.select.previous"; //$NON-NLS-1$ /** * Action definition ID of the edit -> select restore last action * (value <code>"org.eclipse.jdt.ui.edit.text.java.select.last"</code>). */ public static final String SELECT_LAST= "org.eclipse.jdt.ui.edit.text.java.select.last"; //$NON-NLS-1$ /** * Action definition ID of the edit -> correction assist proposal action * (value <code>"org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"</code>). */ public static final String CORRECTION_ASSIST_PROPOSALS= "org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"; //$NON-NLS-1$ /** * Action definition ID of the edit -> show Javadoc action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.javadoc"</code>). */ public static final String SHOW_JAVADOC= "org.eclipse.jdt.ui.edit.text.java.show.javadoc"; //$NON-NLS-1$ /** * Action definition ID of the edit -> Show Outline action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.outline"</code>). * * @since 2.1 */ public static final String SHOW_OUTLINE= "org.eclipse.jdt.ui.edit.text.java.show.outline"; //$NON-NLS-1$ /** * Action definition ID of the Navigate -> Open Structure action * (value <code>"org.eclipse.jdt.ui.navigate.java.open.structure"</code>). * * @since 2.1 */ public static final String OPEN_STRUCTURE= "org.eclipse.jdt.ui.navigate.java.open.structure"; //$NON-NLS-1$ // source /** * Action definition ID of the source -> comment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.comment"</code>). */ public static final String COMMENT= "org.eclipse.jdt.ui.edit.text.java.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> uncomment action * (value <code>"org.eclipse.jdt.ui.edit.text.java.uncomment"</code>). */ public static final String UNCOMMENT= "org.eclipse.jdt.ui.edit.text.java.uncomment"; //$NON-NLS-1$ /** * Action definition ID of the source -> format action * (value <code>"org.eclipse.jdt.ui.edit.text.java.format"</code>). */ public static final String FORMAT= "org.eclipse.jdt.ui.edit.text.java.format"; //$NON-NLS-1$ /** * Action definition ID of the source -> add import action * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.import"</code>). */ public static final String ADD_IMPORT= "org.eclipse.jdt.ui.edit.text.java.add.import"; //$NON-NLS-1$ /** * Action definition ID of the source -> organize imports action * (value <code>"org.eclipse.jdt.ui.edit.text.java.organize.imports"</code>). */ public static final String ORGANIZE_IMPORTS= "org.eclipse.jdt.ui.edit.text.java.organize.imports"; //$NON-NLS-1$ /** * Action definition ID of the source -> sort order action (value * <code>"org.eclipse.jdt.ui.edit.text.java.sort.members"</code>). * @since 2.1 */ public static final String SORT_MEMBERS= "org.eclipse.jdt.ui.edit.text.java.sort.members"; //$NON-NLS-1$ /** * Action definition ID of the source -> add javadoc comment action (value * <code>"org.eclipse.jdt.ui.edit.text.java.add.javadoc.comment"</code>). * @since 2.1 */ public static final String ADD_JAVADOC_COMMENT= "org.eclipse.jdt.ui.edit.text.java.add.javadoc.comment"; //$NON-NLS-1$ /** * Action definition ID of the source -> surround with try/catch action * (value <code>"org.eclipse.jdt.ui.edit.text.java.surround.with.try.catch"</code>). */ public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.jdt.ui.edit.text.java.surround.with.try.catch"; //$NON-NLS-1$ /** * Action definition ID of the source -> override methods action * (value <code>"org.eclipse.jdt.ui.edit.text.java.override.methods"</code>). */ public static final String OVERRIDE_METHODS= "org.eclipse.jdt.ui.edit.text.java.override.methods"; //$NON-NLS-1$ /** * Action definition ID of the source -> add unimplemented constructors action * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.unimplemented.constructors"</code>). */ public static final String ADD_UNIMPLEMENTED_CONTRUCTORS= "org.eclipse.jdt.ui.edit.text.java.add.unimplemented.constructors"; //$NON-NLS-1$ /** * Action definition ID of the source -> generate setter/getter action * (value <code>"org.eclipse.jdt.ui.edit.text.java.create.getter.setter"</code>). */ public static final String CREATE_GETTER_SETTER= "org.eclipse.jdt.ui.edit.text.java.create.getter.setter"; //$NON-NLS-1$ /** * Action definition ID of the source -> generate delegates action (value * <code>"org.eclipse.jdt.ui.edit.text.java.create.delegate.methods"</code>). * @since 2.1 */ public static final String CREATE_DELEGATE_METHODS= "org.eclipse.jdt.ui.edit.text.java.create.delegate.methods"; //$NON-NLS-1$ /** * Action definition ID of the source -> externalize strings action * (value <code>"org.eclipse.jdt.ui.edit.text.java.externalize.strings"</code>). */ public static final String EXTERNALIZE_STRINGS= "org.eclipse.jdt.ui.edit.text.java.externalize.strings"; //$NON-NLS-1$ /** * Note: this id is for internal use only. */ public static final String SHOW_NEXT_PROBLEM= "org.eclipse.jdt.ui.edit.text.java.show.next.problem"; //$NON-NLS-1$ /** * Note: this id is for internal use only. */ public static final String SHOW_PREVIOUS_PROBLEM= "org.eclipse.jdt.ui.edit.text.java.show.previous.problem"; //$NON-NLS-1$ // refactor /** * Action definition ID of the refactor -> pull up action * (value <code>"org.eclipse.jdt.ui.edit.text.java.pull.up"</code>). */ public static final String PULL_UP= "org.eclipse.jdt.ui.edit.text.java.pull.up"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> push down action * (value <code>"org.eclipse.jdt.ui.edit.text.java.push.down"</code>). * * @since 2.1 */ public static final String PUSH_DOWN= "org.eclipse.jdt.ui.edit.text.java.push.down"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> rename element action * (value <code>"org.eclipse.jdt.ui.edit.text.java.rename.element"</code>). */ public static final String RENAME_ELEMENT= "org.eclipse.jdt.ui.edit.text.java.rename.element"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> modify method parameters action * (value <code>"org.eclipse.jdt.ui.edit.text.java.modify.method.parameters"</code>). */ public static final String MODIFY_METHOD_PARAMETERS= "org.eclipse.jdt.ui.edit.text.java.modify.method.parameters"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> move element action * (value <code>"org.eclipse.jdt.ui.edit.text.java.move.element"</code>). */ public static final String MOVE_ELEMENT= "org.eclipse.jdt.ui.edit.text.java.move.element"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.local.variable"</code>). */ public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.extract.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract constant action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.constant"</code>). * * @since 2.1 */ public static final String EXTRACT_CONSTANT= "org.eclipse.jdt.ui.edit.text.java.extract.constant"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> inline local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.inline.local.variable"</code>). * @deprecated Use INLINE */ public static final String INLINE_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.inline.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> self encapsulate field action * (value <code>"org.eclipse.jdt.ui.edit.text.java.self.encapsulate.field"</code>). */ public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.jdt.ui.edit.text.java.self.encapsulate.field"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract method action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.method"</code>). */ public static final String EXTRACT_METHOD= "org.eclipse.jdt.ui.edit.text.java.extract.method"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> inline action * (value <code>"org.eclipse.jdt.ui.edit.text.java.inline"</code>). * * @since 2.1 */ public static final String INLINE= "org.eclipse.jdt.ui.edit.text.java.inline"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> extract interface action * (value <code>"org.eclipse.jdt.ui.edit.text.java.extract.interface"</code>). * * @since 2.1 */ public static final String EXTRACT_INTERFACE= "org.eclipse.jdt.ui.edit.text.java.extract.interface"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> move inner type to top level action * (value <code>"org.eclipse.jdt.ui.edit.text.java.move.inner.to.top.level"</code>). * * @since 2.1 */ public static final String MOVE_INNER_TO_TOP= "org.eclipse.jdt.ui.edit.text.java.move.inner.to.top.level"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> use supertype action * (value <code>"org.eclipse.jdt.ui.edit.text.java.use.supertype"</code>). * * @since 2.1 */ public static final String USE_SUPERTYPE= "org.eclipse.jdt.ui.edit.text.java.use.supertype"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> promote local variable action * (value <code>"org.eclipse.jdt.ui.edit.text.java.promote.local.variable"</code>). * * @since 2.1 */ public static final String PROMOTE_LOCAL_VARIABLE= "org.eclipse.jdt.ui.edit.text.java.promote.local.variable"; //$NON-NLS-1$ /** * Action definition ID of the refactor -> convert anonynous to nested action * (value <code>"org.eclipse.jdt.ui.edit.text.java.convert.anonymous.to.nested"</code>). * * @since 2.1 */ public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.jdt.ui.edit.text.java.convert.anonymous.to.nested"; //$NON-NLS-1$ // navigate /** * Action definition ID of the navigate -> open action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.editor"</code>). */ public static final String OPEN_EDITOR= "org.eclipse.jdt.ui.edit.text.java.open.editor"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open super implementation action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.super.implementation"</code>). */ public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.jdt.ui.edit.text.java.open.super.implementation"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open external javadoc action * (value <code>"org.eclipse.jdt.ui.edit.text.java.open.external.javadoc"</code>). */ public static final String OPEN_EXTERNAL_JAVADOC= "org.eclipse.jdt.ui.edit.text.java.open.external.javadoc"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> open type hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.org.eclipse.jdt.ui.edit.text.java.open.type.hierarchy"</code>). */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.open.type.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> show in package explorer action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.in.package.view"</code>). */ public static final String SHOW_IN_PACKAGE_VIEW= "org.eclipse.jdt.ui.edit.text.java.show.in.package.view"; //$NON-NLS-1$ /** * Action definition ID of the navigate -> show in navigator action * (value <code>"org.eclipse.jdt.ui.edit.text.java.show.in.navigator.view"</code>). */ public static final String SHOW_IN_NAVIGATOR_VIEW= "org.eclipse.jdt.ui.edit.text.java.show.in.navigator.view"; //$NON-NLS-1$ // search /** * Action definition ID of the search -> references in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace"</code>). */ public static final String SEARCH_REFERENCES_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.references.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> references in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.hierarchy"</code>). */ public static final String SEARCH_REFERENCES_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.references.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> references in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.references.in.working.set"</code>). */ public static final String SEARCH_REFERENCES_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.references.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.workspace"</code>). */ public static final String SEARCH_READ_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.hierarchy"</code>). */ public static final String SEARCH_READ_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> read access in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.read.access.in.working.set"</code>). */ public static final String SEARCH_READ_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.read.access.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.workspace"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.hierarchy"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> write access in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.write.access.in.working.set"</code>). */ public static final String SEARCH_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.write.access.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.workspace"</code>). */ public static final String SEARCH_DECLARATIONS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in hierarchy action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.hierarchy"</code>). */ public static final String SEARCH_DECLARATIONS_IN_HIERARCHY= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.hierarchy"; //$NON-NLS-1$ /** * Action definition ID of the search -> declarations in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.declarations.in.working.set"</code>). */ public static final String SEARCH_DECLARATIONS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.search.declarations.in.working.set"; //$NON-NLS-1$ /** * Action definition ID of the search -> implementors in workspace action * (value <code>"org.eclipse.jdt.ui.edit.text.java.search.implementors.in.workspace"</code>). */ public static final String SEARCH_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.jdt.ui.edit.text.java.search.implementors.in.workspace"; //$NON-NLS-1$ /** * Action definition ID of the search -> implementors in working set action * (value <code>"org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.working.set"</code>). */ public static final String SEARCH_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.jdt.ui.edit.text.java.seach.implementors.in.working.set"; //$NON-NLS-1$ // miscellaneous /** * Action definition ID of the toggle presentation toolbar button action * (value <code>"org.eclipse.jdt.ui.edit.text.java.toggle.presentation"</code>). */ public static final String TOGGLE_PRESENTATION= "org.eclipse.jdt.ui.edit.text.java.toggle.presentation"; //$NON-NLS-1$ /** * Action definition ID of the toggle text hover toolbar button action * (value <code>"org.eclipse.jdt.ui.edit.text.java.toggle.text.hover"</code>). */ public static final String TOGGLE_TEXT_HOVER= "org.eclipse.jdt.ui.edit.text.java.toggle.text.hover"; //$NON-NLS-1$ }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/JdtActionConstants.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; /** * Action ids for standard actions, for groups in the menu bar, and * for actions in context menus of JDT views. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class JdtActionConstants { // Navigate menu /** * Navigate menu: name of standard Goto Type global action * (value <code>"org.eclipse.jdt.ui.actions.GoToType"</code>). */ public static final String GOTO_TYPE= "org.eclipse.jdt.ui.actions.GoToType"; //$NON-NLS-1$ /** * Navigate menu: name of standard Goto Package global action * (value <code>"org.eclipse.jdt.ui.actions.GoToPackage"</code>). */ public static final String GOTO_PACKAGE= "org.eclipse.jdt.ui.actions.GoToPackage"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open global action * (value <code>"org.eclipse.jdt.ui.actions.Open"</code>). */ public static final String OPEN= "org.eclipse.jdt.ui.actions.Open"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open Super Implementation global action * (value <code>"org.eclipse.jdt.ui.actions.OpenSuperImplementation"</code>). */ public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.jdt.ui.actions.OpenSuperImplementation"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open Type Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.OpenTypeHierarchy"</code>). */ public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.jdt.ui.actions.OpenTypeHierarchy"; //$NON-NLS-1$ /** * Navigate menu: name of standard Open External Javadoc global action * (value <code>"org.eclipse.jdt.ui.actions.OpenExternalJavaDoc"</code>). */ public static final String OPEN_EXTERNAL_JAVA_DOC= "org.eclipse.jdt.ui.actions.OpenExternalJavaDoc"; //$NON-NLS-1$ /** * Navigate menu: name of standard Show in Packages View global action * (value <code>"org.eclipse.jdt.ui.actions.ShowInPackagesView"</code>). */ public static final String SHOW_IN_PACKAGE_VIEW= "org.eclipse.jdt.ui.actions.ShowInPackagesView"; //$NON-NLS-1$ /** * Navigate menu: name of standard Show in Navigator View global action * (value <code>"org.eclipse.jdt.ui.actions.ShowInNaviagtorView"</code>). */ public static final String SHOW_IN_NAVIGATOR_VIEW= "org.eclipse.jdt.ui.actions.ShowInNaviagtorView"; //$NON-NLS-1$ // Edit menu /** * Edit menu: name of standard Show Javadoc global action * (value <code>"org.eclipse.jdt.ui.actions.ShowJavaDoc"</code>). */ public static final String SHOW_JAVA_DOC= "org.eclipse.jdt.ui.actions.ShowJavaDoc"; //$NON-NLS-1$ /** * Edit menu: name of standard Code Assist global action * (value <code>"org.eclipse.jdt.ui.actions.ContentAssist"</code>). */ public static final String CONTENT_ASSIST= "org.eclipse.jdt.ui.actions.ContentAssist"; //$NON-NLS-1$ // Source menu /** * Source menu: name of standard Comment global action * (value <code>"org.eclipse.jdt.ui.actions.Comment"</code>). */ public static final String COMMENT= "org.eclipse.jdt.ui.actions.Comment"; //$NON-NLS-1$ /** * Source menu: name of standard Uncomment global action * (value <code>"org.eclipse.jdt.ui.actions.Uncomment"</code>). */ public static final String UNCOMMENT= "org.eclipse.jdt.ui.actions.Uncomment"; //$NON-NLS-1$ /** * Source menu: name of standard Shift Rightl action * (value <code>"org.eclipse.jdt.ui.actions.ShiftRight"</code>). */ public static final String SHIFT_RIGHT= "org.eclipse.jdt.ui.actions.ShiftRight"; //$NON-NLS-1$ /** * Source menu: name of standard Shift Left global action * (value <code>"org.eclipse.jdt.ui.actions.ShiftLeft"</code>). */ public static final String SHIFT_LEFT= "org.eclipse.jdt.ui.actions.ShiftLeft"; //$NON-NLS-1$ /** * Source menu: name of standard Format global action * (value <code>"org.eclipse.jdt.ui.actions.Format"</code>). */ public static final String FORMAT= "org.eclipse.jdt.ui.actions.Format"; //$NON-NLS-1$ /** * Source menu: name of standard Add Import global action * (value <code>"org.eclipse.jdt.ui.actions.AddImport"</code>). */ public static final String ADD_IMPORT= "org.eclipse.jdt.ui.actions.AddImport"; //$NON-NLS-1$ /** * Source menu: name of standard Organize Imports global action * (value <code>"org.eclipse.jdt.ui.actions.OrganizeImports"</code>). */ public static final String ORGANIZE_IMPORTS= "org.eclipse.jdt.ui.actions.OrganizeImports"; //$NON-NLS-1$ /** * Source menu: name of standard Sort Members global action (value * <code>"org.eclipse.jdt.ui.actions.SortMembers"</code>). * @since 2.1 */ public static final String SORT_MEMBERS= "org.eclipse.jdt.ui.actions.SortMembers"; //$NON-NLS-1$ /** * Source menu: name of standard Surround with try/catch block global action * (value <code>"org.eclipse.jdt.ui.actions.SurroundWithTryCatch"</code>). */ public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.jdt.ui.actions.SurroundWithTryCatch"; //$NON-NLS-1$ /** * Source menu: name of standard Override Methods global action * (value <code>"org.eclipse.jdt.ui.actions.OverrideMethods"</code>). */ public static final String OVERRIDE_METHODS= "org.eclipse.jdt.ui.actions.OverrideMethods"; //$NON-NLS-1$ /** * Source menu: name of standard Generate Getter and Setter global action * (value <code>"org.eclipse.jdt.ui.actions.GenerateGetterSetter"</code>). */ public static final String GENERATE_GETTER_SETTER= "org.eclipse.jdt.ui.actions.GenerateGetterSetter"; //$NON-NLS-1$ /** * Source menu: name of standard delegate methdos global action (value * <code>"org.eclipse.jdt.ui.actions.GenerateDelegateMethods"</code>). * @since 2.1 */ public static final String GENERATE_DELEGATE_METHODS= "org.eclipse.jdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$ /** * Source menu: name of standard Add Constructor From Superclass global action * (value <code>"org.eclipse.jdt.ui.actions.AddConstructorFromSuperclass"</code>). */ public static final String ADD_CONSTRUCTOR_FROM_SUPERCLASS= "org.eclipse.jdt.ui.actions.AddConstructorFromSuperclass"; //$NON-NLS-1$ /** * Source menu: name of standard Add Javadoc Comment global action * (value <code>"org.eclipse.jdt.ui.actions.AddJavaDocComment"</code>). */ public static final String ADD_JAVA_DOC_COMMENT= "org.eclipse.jdt.ui.actions.AddJavaDocComment"; //$NON-NLS-1$ /** * Source menu: name of standard Find Strings to Externalize global action * (value <code>"org.eclipse.jdt.ui.actions.FindStringsToExternalize"</code>). */ public static final String FIND_STRINGS_TO_EXTERNALIZE= "org.eclipse.jdt.ui.actions.FindStringsToExternalize"; //$NON-NLS-1$ /** * Source menu: name of standard Externalize Strings global action * (value <code>"org.eclipse.jdt.ui.actions.ExternalizeStrings"</code>). */ public static final String EXTERNALIZE_STRINGS= "org.eclipse.jdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$ /** * Source menu: name of standard Convert Line Delimiters To Windows global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToWindows"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToWindows"; //$NON-NLS-1$ /** * Source menu: name of standard Convert Line Delimiters To UNIX global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToUNIX"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_UNIX= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToUNIX"; //$NON-NLS-1$ /** * Source menu: name of standardConvert Line Delimiters ToMac global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertLineDelimitersToMac"</code>). */ public static String CONVERT_LINE_DELIMITERS_TO_MAC= "org.eclipse.jdt.ui.actions.ConvertLineDelimitersToMac"; //$NON-NLS-1$ // Refactor menu /** * Refactor menu: name of standard Self Encapsulate Field global action * (value <code>"org.eclipse.jdt.ui.actions.SelfEncapsulateField"</code>). */ public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.jdt.ui.actions.SelfEncapsulateField"; //$NON-NLS-1$ /** * Refactor menu: name of standard Modify Parameters global action * (value <code>"org.eclipse.jdt.ui.actions.ModifyParameters"</code>). */ public static final String MODIFY_PARAMETERS= "org.eclipse.jdt.ui.actions.ModifyParameters"; //$NON-NLS-1$ /** * Refactor menu: name of standard Pull Up global action * (value <code>"org.eclipse.jdt.ui.actions.PullUp"</code>). */ public static final String PULL_UP= "org.eclipse.jdt.ui.actions.PullUp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Push Down global action * (value <code>"org.eclipse.jdt.ui.actions.PushDown"</code>). * * @since 2.1 */ public static final String PUSH_DOWN= "org.eclipse.jdt.ui.actions.PushDown"; //$NON-NLS-1$ /** * Refactor menu: name of standard Move Element global action * (value <code>"org.eclipse.jdt.ui.actions.Move"</code>). */ public static final String MOVE= "org.eclipse.jdt.ui.actions.Move"; //$NON-NLS-1$ /** * Refactor menu: name of standard Rename Element global action * (value <code>"org.eclipse.jdt.ui.actions.Rename"</code>). */ public static final String RENAME= "org.eclipse.jdt.ui.actions.Rename"; //$NON-NLS-1$ /** * Refactor menu: name of standard Inline Temp global action * (value <code>"org.eclipse.jdt.ui.actions.InlineTemp"</code>). * @deprecated Use INLINE */ public static final String INLINE_TEMP= "org.eclipse.jdt.ui.actions.InlineTemp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Temp global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractTemp"</code>). */ public static final String EXTRACT_TEMP= "org.eclipse.jdt.ui.actions.ExtractTemp"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Constant global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractConstant"</code>). * * @since 2.1 */ public static final String EXTRACT_CONSTANT= "org.eclipse.jdt.ui.actions.ExtractConstant"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Method global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractMethod"</code>). */ public static final String EXTRACT_METHOD= "org.eclipse.jdt.ui.actions.ExtractMethod"; //$NON-NLS-1$ /** * Refactor menu: name of standard Inline global action * (value <code>"org.eclipse.jdt.ui.actions.Inline"</code>). * * @since 2.1 */ public static final String INLINE= "org.eclipse.jdt.ui.actions.Inline"; //$NON-NLS-1$ /** * Refactor menu: name of standard Extract Interface global action * (value <code>"org.eclipse.jdt.ui.actions.ExtractInterface"</code>). * * @since 2.1 */ public static final String EXTRACT_INTERFACE= "org.eclipse.jdt.ui.actions.ExtractInterface"; //$NON-NLS-1$ /** * Refactor menu: name of standard global action to convert a nested type to a top level type * (value <code>"org.eclipse.jdt.ui.actions.MoveInnerToTop"</code>). * * @since 2.1 */ public static final String CONVERT_NESTED_TO_TOP= "org.eclipse.jdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$ /** * Refactor menu: name of standard Use Supertype global action * (value <code>"org.eclipse.jdt.ui.actions.UseSupertype"</code>). * * @since 2.1 */ public static final String USE_SUPERTYPE= "org.eclipse.jdt.ui.actions.UseSupertype"; //$NON-NLS-1$ /** * Refactor menu: name of standard global action to convert a local * variable to a field (value <code>"org.eclipse.jdt.ui.actions.ConvertLocalToField"</code>). * * @since 2.1 */ public static final String CONVERT_LOCAL_TO_FIELD= "org.eclipse.jdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$ /** * Refactor menu: name of standard Covert Anonymous to Nested global action * (value <code>"org.eclipse.jdt.ui.actions.ConvertAnonymousToNested"</code>). * * @since 2.1 */ public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.jdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$ // Search Menu /** * Search menu: name of standard Find References in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInWorkspace"</code>). */ public static final String FIND_REFERENCES_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ReferencesInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find References in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInHierarchy"</code>). */ public static final String FIND_REFERENCES_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find References in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ReferencesInWorkingSet"</code>). */ public static final String FIND_REFERENCES_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ReferencesInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInWorkspace"</code>). */ public static final String FIND_DECLARATIONS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInHierarchy"</code>). */ public static final String FIND_DECLARATIONS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.DeclarationsInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Declarations in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.DeclarationsInWorkingSet"</code>). */ public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Implementors in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ImplementorsInWorkspace"</code>). */ public static final String FIND_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ImplementorsInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Implementors in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ImplementorsInWorkingSet"</code>). */ public static final String FIND_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ImplementorsInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInWorkspace"</code>). */ public static final String FIND_READ_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.ReadAccessInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInHierarchy"</code>). */ public static final String FIND_READ_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.ReadAccessInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.ReadAccessInWorkingSet"</code>). */ public static final String FIND_READ_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.ReadAccessInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Find Write Access in Workspace global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInWorkspace"</code>). */ public static final String FIND_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.jdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Hierarchy global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInHierarchy"</code>). */ public static final String FIND_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.jdt.ui.actions.WriteAccessInHierarchy"; //$NON-NLS-1$ /** * Search menu: name of standard Find Read Access in Working Set global action * (value <code>"org.eclipse.jdt.ui.actions.WriteAccessInWorkingSet"</code>). */ public static final String FIND_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.jdt.ui.actions.WriteAccessInWorkingSet"; //$NON-NLS-1$ /** * Search menu: name of standard Occurrences in File global action (value * <code>"org.eclipse.jdt.ui.actions.OccurrencesInFile"</code>). * * @since 2.1 */ public static final String FIND_OCCURRENCES_IN_FILE= "org.eclipse.jdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$ }
36,485
Bug 36485 call hierarchy: location of menu entry
'Open Call Hierarchy' menu entry should be located right below 'Open Type Hierarchy'
resolved fixed
270bdc9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T07:45:43Z
2003-04-15T12:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenViewActionGroup.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.part.Page; import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart; /** * Action group that adds actions to open a new JDT view part or an external * viewer to a context menu and the global menu bar. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class OpenViewActionGroup extends ActionGroup { private boolean fEditorIsOwner; private boolean fIsTypeHiararchyViewerOwner; private IWorkbenchSite fSite; private OpenSuperImplementationAction fOpenSuperImplementation; private OpenExternalJavadocAction fOpenExternalJavadoc; private OpenTypeHierarchyAction fOpenTypeHierarchy; private PropertyDialogAction fOpenPropertiesDialog; /** * Creates a new <code>OpenActionGroup</code>. The group requires * that the selection provided by the page's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param page the page that owns this action group */ public OpenViewActionGroup(Page page) { createSiteActions(page.getSite()); } /** * Creates a new <code>OpenActionGroup</code>. The group requires * that the selection provided by the part's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param part the view part that owns this action group */ public OpenViewActionGroup(IViewPart part) { createSiteActions(part.getSite()); fIsTypeHiararchyViewerOwner= part instanceof TypeHierarchyViewPart; } /** * Note: This constructor is for internal use only. Clients should not call this constructor. */ public OpenViewActionGroup(JavaEditor part) { fEditorIsOwner= true; fOpenSuperImplementation= new OpenSuperImplementationAction(part); fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION); part.setAction("OpenSuperImplementation", fOpenSuperImplementation); //$NON-NLS-1$ fOpenExternalJavadoc= new OpenExternalJavadocAction(part); fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC); part.setAction("OpenExternalJavadoc", fOpenExternalJavadoc); //$NON-NLS-1$ fOpenTypeHierarchy= new OpenTypeHierarchyAction(part); fOpenTypeHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY); part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$ initialize(part.getEditorSite()); } private void createSiteActions(IWorkbenchSite site) { fSite= site; fOpenSuperImplementation= new OpenSuperImplementationAction(site); fOpenExternalJavadoc= new OpenExternalJavadocAction(site); fOpenTypeHierarchy= new OpenTypeHierarchyAction(site); fOpenPropertiesDialog= new PropertyDialogAction(site.getShell(), site.getSelectionProvider()); initialize(site); } private void initialize(IWorkbenchSite site) { fSite= site; ISelectionProvider provider= fSite.getSelectionProvider(); ISelection selection= provider.getSelection(); fOpenSuperImplementation.update(selection); fOpenExternalJavadoc.update(selection); fOpenTypeHierarchy.update(selection); if (!fEditorIsOwner) { if (selection instanceof IStructuredSelection) { IStructuredSelection ss= (IStructuredSelection)selection; fOpenPropertiesDialog.selectionChanged(ss); } else { fOpenPropertiesDialog.selectionChanged(selection); } provider.addSelectionChangedListener(fOpenSuperImplementation); provider.addSelectionChangedListener(fOpenExternalJavadoc); provider.addSelectionChangedListener(fOpenTypeHierarchy); // no need to register the open properties dialog action since it registers itself } } /* (non-Javadoc) * Method declared in ActionGroup */ public void fillActionBars(IActionBars actionBar) { super.fillActionBars(actionBar); setGlobalActionHandlers(actionBar); } /* (non-Javadoc) * Method declared in ActionGroup */ public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!fIsTypeHiararchyViewerOwner) appendToGroup(menu, fOpenTypeHierarchy); appendToGroup(menu, fOpenSuperImplementation); IStructuredSelection selection= getStructuredSelection(); if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection)) menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog); } /* * @see ActionGroup#dispose() */ public void dispose() { ISelectionProvider provider= fSite.getSelectionProvider(); provider.removeSelectionChangedListener(fOpenSuperImplementation); provider.removeSelectionChangedListener(fOpenExternalJavadoc); provider.removeSelectionChangedListener(fOpenTypeHierarchy); super.dispose(); } private void setGlobalActionHandlers(IActionBars actionBars) { actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation); actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc); actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_TYPE_HIERARCHY, fOpenTypeHierarchy); actionBars.setGlobalActionHandler(IWorkbenchActionConstants.PROPERTIES, fOpenPropertiesDialog); } private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action); } private IStructuredSelection getStructuredSelection() { ISelection selection= getContext().getSelection(); if (selection instanceof IStructuredSelection) return (IStructuredSelection)selection; return null; } }
36,849
Bug 36849 ImportEdit.removeImport(ITypeBinding)
we have addImport(ITypeBinding) addImport(String) but only removeImport(String) we need the other one for consistency
resolved fixed
f2c263a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T16:53:41Z
2003-04-24T16:00:00Z
org.eclipse.jdt.ui/core
36,849
Bug 36849 ImportEdit.removeImport(ITypeBinding)
we have addImport(ITypeBinding) addImport(String) but only removeImport(String) we need the other one for consistency
resolved fixed
f2c263a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T16:53:41Z
2003-04-24T16:00:00Z
extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportEdit.java
36,849
Bug 36849 ImportEdit.removeImport(ITypeBinding)
we have addImport(ITypeBinding) addImport(String) but only removeImport(String) we need the other one for consistency
resolved fixed
f2c263a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T16:53:41Z
2003-04-24T16:00:00Z
org.eclipse.jdt.ui/core
36,849
Bug 36849 ImportEdit.removeImport(ITypeBinding)
we have addImport(ITypeBinding) addImport(String) but only removeImport(String) we need the other one for consistency
resolved fixed
f2c263a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2003-04-24T16:53:41Z
2003-04-24T16:00:00Z
extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportsStructure.java