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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowContext.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/FlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/GenericConditionalFlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/MessageSendFlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/SwitchFlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/ThrowFlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/flow/TryFlowInfo.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/core
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryCatchAnalyzer.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/ui
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringMessages.java
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
org.eclipse.jdt.ui/ui
| |
7,444 |
Bug 7444 surround try/catch: NPE
|
i had code like: public static int getTabSize() { return Integer.parseInt(getIntValue((String) JavaCore.getOption().get (PREF_TAB_SIZE), 4)); } and tried to surroung the returned expression. could not reproduce on a smaller test case 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.NewSelectionAnalyzer.visit (NewSelectionAnalyzer.java:460) at org.eclipse.jdt.internal.corext.refactoring.util.ASTParentTrackingAdapter.visit (ASTParentTrackingAdapter.java:707) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:261) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse (ReturnStatement.java:235) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java(Compiled Code)) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:851) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:228) at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept (AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefacto ring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run (SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:821) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
|
verified fixed
|
8a58ba8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T18:55:46Z | 2002-01-10T19:13:20Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/changes/ChangeExceptionHandler.java
| |
8,068 |
Bug 8068 search: missing working set names on 'seearch for implementors'
|
select sth in the editor, open the context menu, go to: search note: in all 5 entires there are names of working sets you defined except for: 'implementors'
|
verified fixed
|
e2bf5d7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T19:48:22Z | 2002-01-23T10:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindImplementorsInWorkingSetAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.search.ui.IWorkingSet;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.JavaPlugin;
public class FindImplementorsInWorkingSetAction extends FindImplementorsAction {
public FindImplementorsInWorkingSetAction() {
setText(SearchMessages.getString("Search.FindImplementorsInWorkingSetAction.label")); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindImplementorsInWorkingSetAction.tooltip")); //$NON-NLS-1$
}
protected JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException {
IWorkingSet workingSet= queryWorkingSet();
if (workingSet == null)
return null;
updateLRUWorkingSet(workingSet);
return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(workingSet), getScopeDescription(workingSet), getCollector());
};
private IJavaSearchScope getScope(IWorkingSet workingSet) throws JavaModelException {
return JavaSearchScopeFactory.getInstance().createJavaSearchScope(workingSet);
}
private String getScopeDescription(IWorkingSet workingSet) {
return SearchMessages.getFormattedString("WorkingSetScope", new String[] {workingSet.getName()}); //$NON-NLS-1$
}
private IWorkingSet queryWorkingSet() throws JavaModelException {
SelectionDialog dialog= SearchUI.createWorkingSetDialog(JavaPlugin.getActiveWorkbenchShell());
if (dialog.open() == dialog.OK)
return (IWorkingSet)dialog.getResult()[0];
else
return null;
}
}
|
8,068 |
Bug 8068 search: missing working set names on 'seearch for implementors'
|
select sth in the editor, open the context menu, go to: search note: in all 5 entires there are names of working sets you defined except for: 'implementors'
|
verified fixed
|
e2bf5d7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-29T19:48:22Z | 2002-01-23T10:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/ImplementorsSearchGroup.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
/**
* Contribute Java search specific menu elements.
*/
public class ImplementorsSearchGroup extends JavaSearchSubGroup {
public static final String GROUP_NAME= SearchMessages.getString("group.implementors"); //$NON-NLS-1$
protected ElementSearchAction[] getActions() {
return new ElementSearchAction[] {
new FindImplementorsAction(),
new FindImplementorsInWorkingSetAction()
};
}
protected String getName() {
return GROUP_NAME;
}
}
|
8,730 |
Bug 8730 wrong method deleted (packages view)
|
from the newsgroup: public class TestClass { public void foo(String s) { } public void foo(String[] s) { } public void otherfoo(String s) { } } 2. click right on "foo(String s)" in package view, select "delete" ->foo(String s) vanishes in source view, package view is not updated (bug or feature?) 3. click right on "foo(String[] s)" in package view, select "delete" -> otherfoo(String s) vanishes in source view ------------------------------------------------------ 2 is a feature 3 is a bug
|
verified fixed
|
939a7d8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T12:13:20Z | 2002-01-30T11:26:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/reorg/SourceReferenceAction.java
|
package org.eclipse.jdt.internal.ui.reorg;
import java.util.List;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportContainer;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.refactoring.reorg.SourceReferenceUtil;
import org.eclipse.jdt.internal.corext.refactoring.util.WorkingCopyUtil;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.StructuredSelectionProvider;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringAction;
class SourceReferenceAction extends RefactoringAction {
protected SourceReferenceAction(String name, StructuredSelectionProvider provider) {
super(name, provider);
}
protected SourceReferenceAction(String name, ISelectionProvider provider) {
super(name, provider);
}
/*
* @see RefactoringAction#canOperateOn(IStructuredSelection)
*/
public boolean canOperateOn(IStructuredSelection selection) {
try{
if (selection.isEmpty())
return false;
Object[] elems= selection.toArray();
for (int i= 0; i < elems.length; i++) {
Object elem= elems[i];
if (! canWorkOn(elem))
return false;
}
return true;
} catch (JavaModelException e){
JavaPlugin.log(e);
return false;
}
}
private static boolean canWorkOn(Object elem) throws JavaModelException{
if (elem == null)
return false;
if (! (elem instanceof ISourceReference))
return false;
if (! (elem instanceof IJavaElement))
return false;
if (elem instanceof IClassFile)
return false;
if (elem instanceof ICompilationUnit)
return false;
if ((elem instanceof IMember) && ((IMember)elem).isBinary())
return false;
if (isDeletedFromEditor((ISourceReference)elem))
return false;
if (elem instanceof IMember) //binary excluded before
return true;
if (elem instanceof IImportContainer)
return true;
if (elem instanceof IImportDeclaration)
return true;
if (elem instanceof IPackageDeclaration)
return true;
//we never get here normally
return false;
}
private static boolean isDeletedFromEditor(ISourceReference elem) throws JavaModelException{
ICompilationUnit cu= SourceReferenceUtil.getCompilationUnit(elem);
ICompilationUnit wc= WorkingCopyUtil.getWorkingCopyIfExists(cu);
if (wc.equals(cu))
return false;
IJavaElement element= (IJavaElement)elem;
IJavaElement wcElement= JavaModelUtil.findInCompilationUnit(wc, element);
return wcElement == null || ! wcElement.exists();
}
protected ISourceReference[] getSelectedElements(){
List l= getStructuredSelection().toList();
return (ISourceReference[]) l.toArray(new ISourceReference[l.size()]);
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaWorkbenchAdapter.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IParent;
import org.eclipse.jdt.core.JavaModelException;
/**
* An imlementation of the IWorkbenchAdapter for IJavaElements.
*/
public class JavaWorkbenchAdapter implements IWorkbenchAdapter {
protected static final Object[] NO_CHILDREN= new Object[0];
public Object[] getChildren(Object o) {
if (o instanceof IParent) {
try {
return ((IParent)o).getChildren();
} catch(JavaModelException e) {
JavaPlugin.logErrorMessage(getClass().getName() + ": Error getting children for: " + o); //$NON-NLS-1$
}
}
return NO_CHILDREN;
}
public ImageDescriptor getImageDescriptor(Object object) {
return null;
}
public String getLabel(Object o) {
if (o instanceof IJavaElement)
return ((IJavaElement)o).getElementName();
return null;
}
public Object getParent(Object o) {
if (o instanceof IJavaElement)
return ((IJavaElement)o).getParent();
return null;
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ResultCollector.java
|
package org.eclipse.jdt.internal.ui.text.java;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.ICompletionRequestor;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageDescriptor;
/**
* Bin to collect the proposal of the infrastructure on code assist in a java text.
*/
public class ResultCollector implements ICompletionRequestor {
private class ProposalComparator implements Comparator {
public int compare(Object o1, Object o2) {
ICompletionProposal c1= (ICompletionProposal) o1;
ICompletionProposal c2= (ICompletionProposal) o2;
return c1.getDisplayString().compareToIgnoreCase(c2.getDisplayString());
}
};
private final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-', ' ' };
private final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ' };
private final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' };
private final static char[] VAR_TRIGGER= new char[] { '\t', ' ', '=', ';' };
private ArrayList fFields= new ArrayList(), fKeywords= new ArrayList(),
fLabels= new ArrayList(), fMethods= new ArrayList(),
fModifiers= new ArrayList(), fPackages= new ArrayList(),
fTypes= new ArrayList(), fVariables= new ArrayList();
private IMarker fLastProblem;
private IJavaProject fJavaProject;
private ICompilationUnit fCompilationUnit;
private int fCodeAssistOffset;
private ImageDescriptorRegistry fRegistry= JavaPlugin.getImageDescriptorRegistry();
private ArrayList[] fResults = new ArrayList[] {
fVariables, fFields, fMethods, fTypes, fKeywords, fModifiers, fLabels, fPackages
};
private int fUserReplacementLength;
/*
* Is eating code assist enabled or disabled? PR #3666
* When eating is enabled, JavaCompletionProposal must be revisited: PR #5533
*/
private boolean fPreventEating= true;
/*
* @see ICompletionRequestor#acceptClass
*/
public void acceptClass(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) {
ImageDescriptor descriptor= JavaPluginImages.DESC_OBJS_CLASS;
if (Flags.isDeprecated(modifiers))
descriptor= getDeprecatedDescriptor(descriptor);
ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);
fTypes.add(createTypeCompletion(start, end, new String(completionName), descriptor, new String(typeName), new String(packageName), info));
}
/*
* @see ICompletionRequestor#acceptError
*/
public void acceptError(IMarker problemMarker) {
fLastProblem= problemMarker;
}
/*
* @see ICompletionRequestor#acceptField
*/
public void acceptField(
char[] declaringTypePackageName, char[] declaringTypeName, char[] name,
char[] typePackageName, char[] typeName, char[] completionName,
int modifiers, int start, int end) {
ImageDescriptor descriptor= getMemberDescriptor(modifiers);
if (Flags.isDeprecated(modifiers))
descriptor= getDeprecatedDescriptor(descriptor);
StringBuffer nameBuffer= new StringBuffer();
nameBuffer.append(name);
if (typeName.length > 0) {
nameBuffer.append(" "); //$NON-NLS-1$
nameBuffer.append(typeName);
}
if (declaringTypeName != null && declaringTypeName.length > 0) {
nameBuffer.append(" - "); //$NON-NLS-1$
nameBuffer.append(declaringTypeName);
}
JavaCompletionProposal proposal= createCompletion(start, end, new String(completionName), descriptor, nameBuffer.toString());
proposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name));
proposal.setTriggerCharacters(VAR_TRIGGER);
fFields.add(proposal);
}
/*
* @see ICompletionRequestor#acceptInterface
*/
public void acceptInterface(char[] packageName, char[] typeName, char[] completionName, int modifiers, int start, int end) {
ImageDescriptor descriptor= JavaPluginImages.DESC_OBJS_INTERFACE;
if (Flags.isDeprecated(modifiers))
descriptor= getDeprecatedDescriptor(descriptor);
ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);
fTypes.add(createTypeCompletion(start, end, new String(completionName), descriptor, new String(typeName), new String(packageName), info));
}
/*
* @see ICompletionRequestor#acceptAnonymousType(char[], char[], char[][], char[][], char[][], char[], int, int, int)
*/
public void acceptAnonymousType(char[] superTypePackageName, char[] superTypeName, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames,
char[] completionName, int modifiers, int completionStart, int completionEnd) {
JavaCompletionProposal proposal= createAnonymousTypeCompletion(superTypePackageName, superTypeName, parameterTypeNames, parameterNames, completionName, completionStart, completionEnd);
proposal.setProposalInfo(new ProposalInfo(fJavaProject, superTypePackageName, superTypeName));
fTypes.add(proposal);
}
/*
* @see ICompletionRequestor#acceptKeyword
*/
public void acceptKeyword(char[] keyword, int start, int end) {
String kw= new String(keyword);
fKeywords.add(createCompletion(start, end, kw, null, kw));
}
/*
* @see ICompletionRequestor#acceptLabel
*/
public void acceptLabel(char[] labelName, int start, int end) {
String ln= new String(labelName);
fLabels.add(createCompletion(start, end, ln, null, ln));
}
/*
* @see ICompletionRequestor#acceptLocalVariable
*/
public void acceptLocalVariable(char[] name, char[] typePackageName, char[] typeName, int modifiers, int start, int end) {
StringBuffer buf= new StringBuffer();
buf.append(name);
if (typeName != null) {
buf.append(" "); //$NON-NLS-1$
buf.append(typeName);
}
JavaCompletionProposal proposal= createCompletion(start, end, new String(name), null, buf.toString());
proposal.setTriggerCharacters(VAR_TRIGGER);
fVariables.add(proposal);
}
private String getParameterSignature(char[][] parameterTypeNames, char[][] parameterNames) {
StringBuffer buf = new StringBuffer();
if (parameterTypeNames != null) {
for (int i = 0; i < parameterTypeNames.length; i++) {
if (i > 0) {
buf.append(',');
buf.append(' ');
}
buf.append(parameterTypeNames[i]);
if (parameterNames[i] != null) {
buf.append(' ');
buf.append(parameterNames[i]);
}
}
}
return buf.toString();
}
/*
* @see ICompletionRequestor#acceptMethod(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int)
*/
public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] name,
char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames,
char[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers,
int start, int end) {
JavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end);
proposal.setProposalInfo(new ProposalInfo(fJavaProject, declaringTypePackageName, declaringTypeName, name, parameterPackageNames, parameterTypeNames, returnTypeName.length == 0));
boolean hasClosingBracket= completionName.length > 0 && completionName[completionName.length - 1] == ')';
ProposalContextInformation contextInformation= null;
if (hasClosingBracket && parameterTypeNames.length > 0) {
contextInformation= new ProposalContextInformation();
contextInformation.setInformationDisplayString(getParameterSignature(parameterTypeNames, parameterNames));
contextInformation.setContextDisplayString(proposal.getDisplayString());
proposal.setContextInformation(contextInformation);
}
boolean userMustCompleteParameters= (contextInformation != null && completionName.length > 0);
char[] triggers= userMustCompleteParameters ? METHOD_WITH_ARGUMENTS_TRIGGERS : METHOD_TRIGGERS;
proposal.setTriggerCharacters(triggers);
if (userMustCompleteParameters) {
// set the cursor before the closing bracket
proposal.setCursorPosition(completionName.length - 1);
}
fMethods.add(proposal);
}
/*
* @see ICompletionRequestor#acceptModifier
*/
public void acceptModifier(char[] modifier, int start, int end) {
String mod= new String(modifier);
fModifiers.add(createCompletion(start, end, mod, null, mod));
}
/*
* @see ICompletionRequestor#acceptPackage
*/
public void acceptPackage(char[] packageName, char[] completionName, int start, int end) {
fPackages.add(createCompletion(start, end, new String(completionName), JavaPluginImages.DESC_OBJS_PACKAGE, new String(packageName)));
}
/*
* @see ICompletionRequestor#acceptType
*/
public void acceptType(char[] packageName, char[] typeName, char[] completionName, int start, int end) {
ProposalInfo info= new ProposalInfo(fJavaProject, packageName, typeName);
fTypes.add(createTypeCompletion(start, end, new String(completionName), JavaPluginImages.DESC_OBJS_CLASS, new String(typeName), new String(packageName), info));
}
/*
* @see ICodeCompletionRequestor#acceptMethodDeclaration(char[], char[], char[], char[][], char[][], char[][], char[], char[], char[], int, int, int)
*/
public void acceptMethodDeclaration(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypePackageName, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {
// XXX: To be revised
JavaCompletionProposal proposal= createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end);
fMethods.add(proposal);
}
/*
* @see ICodeCompletionRequestor#acceptVariableName(char[], char[], char[], char[], int, int)
*/
public void acceptVariableName(char[] typePackageName, char[] typeName, char[] name, char[] completionName, int start, int end) {
// XXX: To be revised
StringBuffer buf= new StringBuffer();
buf.append(name);
if (typeName != null && typeName.length > 0) {
buf.append(" - "); //$NON-NLS-1$
buf.append(typeName);
}
JavaCompletionProposal proposal= createCompletion(start, end, new String(completionName), null, buf.toString());
proposal.setTriggerCharacters(VAR_TRIGGER);
fVariables.add(proposal);
}
public String getErrorMessage() {
if (fLastProblem != null)
return fLastProblem.getAttribute(IMarker.MESSAGE, JavaTextMessages.getString("ResultCollector.compile_error.message")); //$NON-NLS-1$
return ""; //$NON-NLS-1$
}
public JavaCompletionProposal[] getResults() {
ArrayList result= new ArrayList();
ProposalComparator comperator= new ProposalComparator();
for (int i= 0; i < fResults.length; i++) {
ArrayList bucket = fResults[i];
int size= bucket.size();
if (size == 1) {
result.add(bucket.get(0));
} else if (size > 1) {
Object[] sortedBucket = new Object[size];
bucket.toArray(sortedBucket);
Arrays.sort(sortedBucket, comperator);
for (int j= 0; j < sortedBucket.length; j++)
result.add(sortedBucket[j]);
}
}
return (JavaCompletionProposal[]) result.toArray(new JavaCompletionProposal[result.size()]);
}
protected JavaCompletionProposal createMethodCompletion(char[] declaringTypeName, char[] name, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {
ImageDescriptor descriptor= getMemberDescriptor(modifiers);
if (Flags.isDeprecated(modifiers))
descriptor= getDeprecatedDescriptor(descriptor);
StringBuffer nameBuffer= new StringBuffer();
nameBuffer.append(name);
nameBuffer.append('(');
if (parameterTypeNames.length > 0) {
nameBuffer.append(getParameterSignature(parameterTypeNames, parameterNames));
}
nameBuffer.append(')');
if (returnTypeName.length > 0) {
nameBuffer.append(" "); //$NON-NLS-1$
nameBuffer.append(returnTypeName);
}
if (declaringTypeName.length > 0) {
nameBuffer.append(" - "); //$NON-NLS-1$
nameBuffer.append(declaringTypeName);
}
return createCompletion(start, end, new String(completionName), descriptor, nameBuffer.toString());
}
protected JavaCompletionProposal createAnonymousTypeCompletion(char[] declaringTypePackageName, char[] declaringTypeName, char[][] parameterTypeNames, char[][] parameterNames, char[] completionName, int start, int end) {
StringBuffer declTypeBuf= new StringBuffer();
if (declaringTypePackageName.length > 0) {
declTypeBuf.append(declaringTypePackageName);
declTypeBuf.append('.');
}
declTypeBuf.append(declaringTypeName);
StringBuffer nameBuffer= new StringBuffer();
nameBuffer.append(declaringTypeName);
nameBuffer.append('(');
if (parameterTypeNames.length > 0) {
nameBuffer.append(getParameterSignature(parameterTypeNames, parameterNames));
}
nameBuffer.append(')');
nameBuffer.append(" ");
nameBuffer.append(JavaTextMessages.getString("ResultCollector.anonymous_type")); //$NON-NLS-1$
int length= end - start;
return new AnonymousTypeCompletionProposal(fCompilationUnit, start, length, new String(completionName), nameBuffer.toString(), declTypeBuf.toString());
}
protected JavaCompletionProposal createTypeCompletion(int start, int end, String completion, ImageDescriptor descriptor, String typeName, String containerName, ProposalInfo proposalInfo) {
IImportDeclaration importDeclaration= null;
if (containerName != null && fCompilationUnit != null) {
if (completion.equals(JavaModelUtil.concatenateName(containerName, typeName))) {
importDeclaration= fCompilationUnit.getImport(completion);
completion= typeName;
}
}
StringBuffer buf= new StringBuffer(typeName);
if (containerName != null) {
buf.append(" - "); //$NON-NLS-1$
buf.append(containerName);
}
String name= buf.toString();
JavaCompletionProposal proposal= createCompletion(start, end, completion, descriptor, name);
proposal.setImportDeclaration(importDeclaration);
proposal.setProposalInfo(proposalInfo);
proposal.setTriggerCharacters(TYPE_TRIGGERS);
return proposal;
}
protected ImageDescriptor getMemberDescriptor(int modifiers) {
if (Flags.isPublic(modifiers)) {
return JavaPluginImages.DESC_MISC_PUBLIC;
} else if (Flags.isProtected(modifiers)) {
return JavaPluginImages.DESC_MISC_PROTECTED;
} else if (Flags.isPrivate(modifiers)) {
return JavaPluginImages.DESC_MISC_PRIVATE;
} else {
return JavaPluginImages.DESC_MISC_DEFAULT;
}
}
protected ImageDescriptor getDeprecatedDescriptor(ImageDescriptor descriptor) {
Point size= new Point(16, 16);
return new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.WARNING, size);
}
protected JavaCompletionProposal createCompletion(int start, int end, String completion, ImageDescriptor descriptor, String name) {
int length;
if (fUserReplacementLength == -1) {
length= fPreventEating ? fCodeAssistOffset - start : end - start;
} else {
length= fUserReplacementLength;
// extend length to begin at start
if (start < fCodeAssistOffset) {
length+= fCodeAssistOffset - start;
}
}
Image icon= (descriptor == null)
? null
: fRegistry.get(descriptor);
return new JavaCompletionProposal(completion, start, length, icon, name);
}
/**
* Specifies the context of the code assist operation.
* @param codeAssistOffset The Offset on which the code assist will be called.
* Used to modify the offsets of the created proposals. ('Non Eating')
* @param jproject The Java project to which the underlying source belongs.
* Needed to find types referred.
* @param cu The compilation unit that is edited. Used to add import statements.
* Can be <code>null</code> if no import statements should be added.
*/
public void reset(int codeAssistOffset, IJavaProject jproject, ICompilationUnit cu) {
fJavaProject= jproject;
fCompilationUnit= cu;
fCodeAssistOffset= codeAssistOffset;
fUserReplacementLength= -1;
fLastProblem= null;
for (int i= 0; i < fResults.length; i++)
fResults[i].clear();
}
/**
* If the replacement length is set, it overrides the length returned from
* the content assist infrastructure.
* Use this setting if code assist is called with a none empty selection.
*/
public void setReplacementLength(int length) {
fUserReplacementLength= length;
}
/**
* If set, proposals created will not remove characters after the code assist position
* @param preventEating The preventEating to set
*/
public void setPreventEating(boolean preventEating) {
fPreventEating= preventEating;
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/ErrorTickImageProvider.java
|
package org.eclipse.jdt.internal.ui.viewsupport;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
public class ErrorTickImageProvider extends JavaElementImageProvider {
private static final int ERRORTICK_WARNING= JavaElementImageDescriptor.WARNING;
private static final int ERRORTICK_ERROR= JavaElementImageDescriptor.ERROR;
/*
* @see JavaElementImageProvider#computeExtraAdornmentFlags(Object)
*/
protected int computeExtraAdornmentFlags(Object obj) {
try {
if (obj instanceof IJavaElement) {
IJavaElement element= (IJavaElement) obj;
if (!element.exists()) {
return 0;
}
int type= element.getElementType();
switch (type) {
case IJavaElement.JAVA_PROJECT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
return getErrorTicksFromMarkers(element.getCorrespondingResource(), IResource.DEPTH_INFINITE, null);
case IJavaElement.PACKAGE_FRAGMENT:
case IJavaElement.CLASS_FILE:
return getErrorTicksFromMarkers(element.getCorrespondingResource(), IResource.DEPTH_ONE, null);
case IJavaElement.COMPILATION_UNIT:
case IJavaElement.PACKAGE_DECLARATION:
case IJavaElement.IMPORT_DECLARATION:
case IJavaElement.IMPORT_CONTAINER:
case IJavaElement.TYPE:
case IJavaElement.INITIALIZER:
case IJavaElement.METHOD:
case IJavaElement.FIELD:
ICompilationUnit cu= (ICompilationUnit) JavaModelUtil.findElementOfKind(element, IJavaElement.COMPILATION_UNIT);
if (cu != null && cu.exists()) {
// I assume that only source elements in compilation unit can have markers
ISourceRange range= ((ISourceReference)element).getSourceRange();
// working copy: look at annotation model
if (cu.isWorkingCopy()) {
return getErrorTicksFromWorkingCopy((ICompilationUnit) cu.getOriginalElement(), range);
}
return getErrorTicksFromMarkers(cu.getCorrespondingResource(), IResource.DEPTH_ONE, range);
}
default:
}
} else if (obj instanceof IResource) {
return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null);
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
return 0;
}
private int getErrorTicksFromMarkers(IResource res, int depth, ISourceRange range) throws CoreException {
if (res == null) { // for elements in archives
return 0;
}
int info= 0;
IMarker[] markers= res.findMarkers(IMarker.PROBLEM, true, depth);
if (markers != null) {
for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
IMarker curr= markers[i];
if (range == null || isMarkerInRange(curr, range)) {
int priority= curr.getAttribute(IMarker.SEVERITY, -1);
if (priority == IMarker.SEVERITY_WARNING) {
info= ERRORTICK_WARNING;
} else if (priority == IMarker.SEVERITY_ERROR) {
info= ERRORTICK_ERROR;
}
}
}
}
return info;
}
private boolean isMarkerInRange(IMarker marker, ISourceRange range) throws CoreException {
if (marker.isSubtypeOf(IMarker.TEXT)) {
int pos= marker.getAttribute(IMarker.CHAR_START, -1);
int offset= range.getOffset();
return (offset <= pos && offset + range.getLength() > pos);
}
return false;
}
private int getErrorTicksFromWorkingCopy(ICompilationUnit original, ISourceRange range) throws CoreException {
int info= 0;
if (!original.exists()) {
return 0;
}
FileEditorInput editorInput= new FileEditorInput((IFile) original.getCorrespondingResource());
IAnnotationModel model= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput);
if (model != null) {
Iterator iter= model.getAnnotationIterator();
while ((info != ERRORTICK_ERROR) && iter.hasNext()) {
Annotation curr= (Annotation) iter.next();
IMarker marker= isAnnotationInRange(model, curr, range);
if (marker != null) {
int priority= marker.getAttribute(IMarker.SEVERITY, -1);
if (priority == IMarker.SEVERITY_WARNING) {
info= ERRORTICK_WARNING;
} else if (priority == IMarker.SEVERITY_ERROR) {
info= ERRORTICK_ERROR;
}
}
}
}
return info;
}
private IMarker isAnnotationInRange(IAnnotationModel model, Annotation annot, ISourceRange range) throws CoreException {
if (annot instanceof MarkerAnnotation) {
IMarker marker= ((MarkerAnnotation)annot).getMarker();
if (marker.exists() && marker.isSubtypeOf(IMarker.PROBLEM)) {
Position pos= model.getPosition(annot);
if (pos.overlapsWith(range.getOffset(), range.getLength())) {
return marker;
}
}
}
return null;
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageDescriptor.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.viewsupport;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
/**
* A JavaImageDescriptor consists of a main icon and several adornments. The adornments
* are computed according to Java element's modifiers (e.g. visibility, static, final, ...).
*/
public class JavaElementImageDescriptor extends CompositeImageDescriptor {
/** Flag to render the abstract adornment */
public final static int ABSTRACT= 0x001;
/** Flag to render the final adornment */
public final static int FINAL= 0x002;
/** Flag to render the synchronized adornment */
public final static int SYNCHRONIZED= 0x004;
/** Flag to render the static adornment */
public final static int STATIC= 0x008;
/** Flag to render the runnable adornment */
public final static int RUNNABLE= 0x010;
/** Flag to render the waring adornment */
public final static int WARNING= 0x020;
/** Flag to render the error adornment */
public final static int ERROR= 0x040;
/** Flag to render the error adornment */
public final static int OVERRIDDEN= 0x080;
private ImageDescriptor fBaseImage;
private int fFlags;
private Point fSize;
/**
* Create a new JavaElementImageDescriptor.
*
* @param baseImage an image descriptor used as the base image
* @param flags flags indicating which adornments are to be rendered
* @param size the size of the resulting image
*/
public JavaElementImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
fBaseImage= baseImage;
Assert.isNotNull(fBaseImage);
fFlags= flags;
Assert.isTrue(fFlags >= 0);
fSize= size;
Assert.isNotNull(fSize);
}
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
protected Point getSize() {
return fSize;
}
/* (non-Javadoc)
* Method declared on Object.
*/
public boolean equals(Object object) {
if (!JavaElementImageDescriptor.class.equals(object.getClass()))
return false;
JavaElementImageDescriptor other= (JavaElementImageDescriptor)object;
return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
}
/* (non-Javadoc)
* Method declared on Object.
*/
public int hashCode() {
return fBaseImage.hashCode() | fFlags | fSize.hashCode();
}
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
protected void drawCompositeImage(int width, int height) {
ImageData bg;
if ((bg= fBaseImage.getImageData()) == null)
bg= DEFAULT_IMAGE_DATA;
drawImage(bg, 0, 0);
drawTopRight();
drawBottomRight();
drawBottomLeft();
}
private void drawTopRight() {
int x= getSize().x;
ImageData data= null;
if ((fFlags & ABSTRACT) != 0) {
data= JavaPluginImages.DESC_OVR_ABSTRACT.getImageData();
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & FINAL) != 0) {
data= JavaPluginImages.DESC_OVR_FINAL.getImageData();
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & STATIC) != 0) {
data= JavaPluginImages.DESC_OVR_STATIC.getImageData();
x-= data.width;
drawImage(data, x, 0);
}
}
private void drawBottomRight() {
Point size= getSize();
int x= size.x;
ImageData data= null;
if ((fFlags & SYNCHRONIZED) != 0) {
data= JavaPluginImages.DESC_OVR_SYNCH.getImageData();
x-= data.width;
drawImage(data, x, size.y - data.height);
}
if ((fFlags & RUNNABLE) != 0) {
data= JavaPluginImages.DESC_OVR_RUN.getImageData();
x-= data.width;
drawImage(data, x, size.y - data.height);
}
if ((fFlags & OVERRIDDEN) != 0) {
data= JavaPluginImages.DESC_OVR_OVERRIDDEN.getImageData();
x-= data.width;
drawImage(data, x, size.y - data.height);
}
}
private void drawBottomLeft() {
Point size= getSize();
int x= 0;
ImageData data= null;
if ((fFlags & ERROR) != 0) {
data= JavaPluginImages.DESC_OVR_ERROR.getImageData();
drawImage(data, x, size.y - data.height);
x+= data.width;
}
if ((fFlags & WARNING) != 0) {
data= JavaPluginImages.DESC_OVR_WARNING.getImageData();
drawImage(data, x, size.y - data.height);
x+= data.width;
}
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.viewsupport;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* Default strategy of the Java plugin for the construction of Java element icons.
*/
public class JavaElementImageProvider {
/**
* Flags for the JavaImageLabelProvider:
* Generate images with overlays.
*/
public final static int OVERLAY_ICONS= 0x1;
/**
* Generate small sized images.
*/
public final static int SMALL_ICONS= 0x2;
/**
* Use the 'light' style for rendering types.
*/
public final static int LIGHT_TYPE_ICONS= 0x4;
private static final Point SMALL_SIZE= new Point(16, 16);
private static final Point BIG_SIZE= new Point(22, 16);
private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED;
private static ImageDescriptor DESC_OBJ_PROJECT;
private static ImageDescriptor DESC_OBJ_FOLDER;
{
ISharedImages images= JavaPlugin.getDefault().getWorkbench().getSharedImages();
DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT_CLOSED);
DESC_OBJ_PROJECT= images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT);
DESC_OBJ_FOLDER= images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
private ImageDescriptorRegistry fRegistry;
public JavaElementImageProvider() {
fRegistry= JavaPlugin.getImageDescriptorRegistry();
}
/**
* Returns the icon for a given element. The icon depends on the element type
* and element properties. If configured, overlay icons are constructed for
* <code>ISourceReference</code>s.
* @param flags Flags as defined by the JavaImageLabelProvider
*/
public Image getImageLabel(Object element, int flags) {
ImageDescriptor descriptor= null;
if (element instanceof IJavaElement) {
descriptor= getJavaImageDescriptor((IJavaElement) element, flags);
} else if (element instanceof IAdaptable) {
descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
}
if (descriptor != null) {
return fRegistry.get(descriptor);
}
return null;
}
private boolean showOverlayIcons(int flags) {
return (flags & OVERLAY_ICONS) != 0;
}
private boolean useLightIcons(int flags) {
return (flags & LIGHT_TYPE_ICONS) != 0;
}
private boolean useSmallSize(int flags) {
return (flags & SMALL_ICONS) != 0;
}
/**
* Returns an image descriptor for a java element. The descriptor includes overlays, if specified.
*/
public ImageDescriptor getJavaImageDescriptor(IJavaElement element, int flags) {
int adornmentFlags= showOverlayIcons(flags) ? computeAdornmentFlags(element) : 0;
Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
return new JavaElementImageDescriptor(getBaseImageDescriptor(element, flags), adornmentFlags, size);
}
/**
* Returns an image descriptor for a IAdaptable. The descriptor includes overlays, if specified (only error ticks apply).
* Returns <code>null</code> if no image could be found.
*/
public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
if (wbAdapter == null) {
return null;
}
ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
if (descriptor == null) {
return null;
}
int adornmentFlags= computeExtraAdornmentFlags(adaptable);
Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
return new JavaElementImageDescriptor(descriptor, adornmentFlags, size);
}
// ---- Computation of base image key -------------------------------------------------
/**
* Returns an image descriptor for a java element. This is the base image, no overlays.
*/
public ImageDescriptor getBaseImageDescriptor(IJavaElement element, int renderFlags) {
try {
switch (element.getElementType()) {
case IJavaElement.INITIALIZER:
case IJavaElement.METHOD:
case IJavaElement.FIELD: {
IMember member= (IMember) element;
if (member.getDeclaringType().isInterface())
return JavaPluginImages.DESC_MISC_PUBLIC;
int flags= member.getFlags();
if (Flags.isPublic(flags))
return JavaPluginImages.DESC_MISC_PUBLIC;
if (Flags.isProtected(flags))
return JavaPluginImages.DESC_MISC_PROTECTED;
if (Flags.isPrivate(flags))
return JavaPluginImages.DESC_MISC_PRIVATE;
return JavaPluginImages.DESC_MISC_DEFAULT;
}
case IJavaElement.PACKAGE_DECLARATION:
return JavaPluginImages.DESC_OBJS_PACKDECL;
case IJavaElement.IMPORT_DECLARATION:
return JavaPluginImages.DESC_OBJS_IMPDECL;
case IJavaElement.IMPORT_CONTAINER:
return JavaPluginImages.DESC_OBJS_IMPCONT;
case IJavaElement.TYPE: {
IType type= (IType) element;
if (useLightIcons(renderFlags)) {
if (type.isClass())
return JavaPluginImages.DESC_OBJS_CLASSALT;
else
return JavaPluginImages.DESC_OBJS_INTERFACEALT;
}
int flags= type.getFlags();
boolean hasVisibility= Flags.isPublic(flags) || Flags.isPrivate(flags) || Flags.isProtected(flags);
if (type.isClass())
return hasVisibility ? JavaPluginImages.DESC_OBJS_CLASS : JavaPluginImages.DESC_OBJS_PCLASS;
return hasVisibility ? JavaPluginImages.DESC_OBJS_INTERFACE : JavaPluginImages.DESC_OBJS_PINTERFACE;
}
case IJavaElement.PACKAGE_FRAGMENT_ROOT: {
IPackageFragmentRoot root= (IPackageFragmentRoot) element;
if (root.isArchive()) {
IPath attach= root.getSourceAttachmentPath();
if (root.isExternal()) {
if (attach == null) {
return JavaPluginImages.DESC_OBJS_EXTJAR;
} else {
return JavaPluginImages.DESC_OBJS_EXTJAR_WSRC;
}
} else {
if (attach == null) {
return JavaPluginImages.DESC_OBJS_JAR;
} else {
return JavaPluginImages.DESC_OBJS_JAR_WSRC;
}
}
} else {
return JavaPluginImages.DESC_OBJS_PACKFRAG_ROOT;
}
}
case IJavaElement.PACKAGE_FRAGMENT:
IPackageFragment fragment= (IPackageFragment)element;
try {
// show the folder icon for packages with only non Java resources
// fix for: 1G5WN0V
if (!fragment.hasChildren() && (fragment.getNonJavaResources().length >0))
return DESC_OBJ_FOLDER;
} catch(JavaModelException e) {
return DESC_OBJ_FOLDER;
}
return JavaPluginImages.DESC_OBJS_PACKAGE;
case IJavaElement.COMPILATION_UNIT:
return JavaPluginImages.DESC_OBJS_CUNIT;
case IJavaElement.CLASS_FILE:
/* this is too expensive for large packages
try {
IClassFile cfile= (IClassFile)element;
if (cfile.isClass())
return JavaPluginImages.IMG_OBJS_CFILECLASS;
return JavaPluginImages.IMG_OBJS_CFILEINT;
} catch(JavaModelException e) {
// fall through;
}*/
return JavaPluginImages.DESC_OBJS_CFILE;
case IJavaElement.JAVA_PROJECT:
IJavaProject jp= (IJavaProject)element;
if (jp.getProject().isOpen()) {
IProject project= jp.getProject();
IWorkbenchAdapter adapter= (IWorkbenchAdapter)project.getAdapter(IWorkbenchAdapter.class);
if (adapter != null) {
ImageDescriptor result= adapter.getImageDescriptor(project);
if (result != null)
return result;
}
return DESC_OBJ_PROJECT;
}
return DESC_OBJ_PROJECT_CLOSED;
case IJavaElement.JAVA_MODEL:
return JavaPluginImages.DESC_OBJS_JAVA_MODEL;
}
Assert.isTrue(false, JavaUIMessages.getString("JavaImageLabelprovider.assert.wrongImage")); //$NON-NLS-1$
return null; //$NON-NLS-1$
} catch (CoreException e) {
JavaPlugin.log(e);
return JavaPluginImages.DESC_OBJS_GHOST;
}
}
// ---- Methods to compute the adornments flags ---------------------------------
private int computeAdornmentFlags(IJavaElement element) {
int flags= computeExtraAdornmentFlags(element);
if (element instanceof ISourceReference) {
ISourceReference sourceReference= (ISourceReference)element;
int modifiers= getModifiers(sourceReference);
if (Flags.isAbstract(modifiers) && confirmAbstract((IMember) sourceReference))
flags |= JavaElementImageDescriptor.ABSTRACT;
if (Flags.isFinal(modifiers))
flags |= JavaElementImageDescriptor.FINAL;
if (Flags.isSynchronized(modifiers) && confirmSynchronized((IMember) sourceReference))
flags |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Flags.isStatic(modifiers))
flags |= JavaElementImageDescriptor.STATIC;
if (sourceReference instanceof IType) {
try {
if (JavaModelUtil.hasMainMethod((IType)sourceReference))
flags |= JavaElementImageDescriptor.RUNNABLE;
} catch (JavaModelException e) {
// do nothing. Can't compute runnable adornment.
}
}
}
return flags;
}
protected int computeExtraAdornmentFlags(Object element) {
return 0;
}
private boolean confirmAbstract(IMember member) {
// Although all methods of a Java interface are abstract, the abstract
// icon should not be shown.
IType t= member.getDeclaringType();
if (t == null && member instanceof IType)
t= (IType) member;
if (t != null) {
try {
return !t.isInterface();
} catch (JavaModelException x) {
// do nothing. Can't compute abstract state.
}
}
return true;
}
private boolean confirmSynchronized(IMember member) {
// Synchronized types are allowed but meaningless.
return !(member instanceof IType);
}
private int getModifiers(ISourceReference sourceReference) {
if (sourceReference instanceof IMember) {
try {
return ((IMember) sourceReference).getFlags();
} catch (JavaModelException x) {
// do nothing. Can't compute modifier state.
}
}
return 0;
}
public void dispose() {
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/OverrideImageProvider.java
|
package org.eclipse.jdt.internal.ui.viewsupport;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage;
import org.eclipse.jdt.internal.ui.typehierarchy.ITypeHierarchyLifeCycleListener;
import org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle;
public class OverrideImageProvider extends ErrorTickImageProvider {
private TypeHierarchyLifeCycle fTypeHierarchy;
public OverrideImageProvider() {
fTypeHierarchy= new TypeHierarchyLifeCycle(true);
}
/*
* @see JavaElementImageProvider#computeExtraAdornmentFlags(Object)
*/
protected int computeExtraAdornmentFlags(Object element) {
int adornmentFlags= super.computeExtraAdornmentFlags(element);
if (!WorkInProgressPreferencePage.showOverrideIndicators()) {
return adornmentFlags;
}
if (element instanceof IMethod) {
try {
IMethod method= (IMethod) element;
int flags= method.getFlags();
IType type= method.getDeclaringType();
if (type.isClass() && !method.isConstructor() && !Flags.isPrivate(flags) && !Flags.isStatic(flags)) {
ITypeHierarchy hierarchy= getTypeHierarchy(type);
IMethod overridden= JavaModelUtil.findMethodDeclarationInHierarchy(hierarchy, type, method.getElementName(), method.getParameterTypes(), false);
if (overridden != null) {
adornmentFlags |= JavaElementImageDescriptor.OVERRIDDEN;
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return adornmentFlags;
}
private ITypeHierarchy getTypeHierarchy(IType type) throws JavaModelException {
fTypeHierarchy.ensureRefreshedTypeHierarchy(type);
return fTypeHierarchy.getHierarchy();
}
/*
* @see JavaElementImageProvider#dispose()
*/
public void dispose() {
fTypeHierarchy.freeHierarchy();
super.dispose();
}
}
|
6,299 |
Bug 6299 JavaWorkbenchAdapter does not provide images
|
org.eclipse.jdt.internal.ui.JavaWorkbenchAdapter#getImageDescriptor returns null; not very nice when presenting in a viewer. Solution (just suggestion;): org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider#getImageDescriptor ... org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider imageProvider; ... return imageProvider.getImageDescriptor((IJavaElement)element, JavaElementImageProvider.SMALL_ICONS);
|
resolved fixed
|
cf601cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T15:50:59Z | 2001-11-26T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java
| |
8,611 |
Bug 8611 NPE in text search with Compare to a Version editor open
|
Build: 20020125 Description: Doing a text search on "Selected Resource" causes a NullPointerException if the active editor is a comparison editor. Steps: 1. Right click on a java file in the Packages view and choose Compare With > Version... from the context menu. 2. Once the comparison editor opens, click on a version to make the comparison. 3. Choose Edit > Search... 4. In the dialog that opens, Text search should be the default tab. If not, choose it. 5. Enter some text in the search field and choose "Selected Resources" in the Scope frame. 6. Click on the Search button. 7. Here you get an error. Stack trace from the log: Log: Mon Jan 28 13:32:00 EST 2002 4 org.eclipse.core.runtime 0 Unhandled exception caught in event loop. java.lang.NullPointerException at org.eclipse.search.internal.ui.text.TextSearchPage.getSelectedResourcesScope (TextSearchPage.java:469) at org.eclipse.search.internal.ui.text.TextSearchPage.performAction (TextSearchPage.java:118) at org.eclipse.search.internal.ui.SearchDialog.performAction (SearchDialog.java:215) at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.buttonPressed (ExtendedDialogWindow.java:162) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:344) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:523) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:45) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:32) at org.eclipse.ui.internal.PluginAction.runWithEvent (PluginAction.java:204) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:827) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:878) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:321) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362) 4. Run a text search
|
resolved fixed
|
70463b8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-01-30T16:23:29Z | 2002-01-28T17:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchScopeFactory.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.search.ui.IWorkingSet;
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.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
public class JavaSearchScopeFactory {
private static JavaSearchScopeFactory fgInstance;
private static IJavaSearchScope EMPTY_SCOPE= SearchEngine.createJavaSearchScope(new IJavaElement[] {});
private JavaSearchScopeFactory() {
}
public static JavaSearchScopeFactory getInstance() {
if (fgInstance == null)
fgInstance= new JavaSearchScopeFactory();
return fgInstance;
}
public IJavaSearchScope createJavaSearchScope(IResource[] resources) {
if (resources == null)
return EMPTY_SCOPE;
Set javaElements= new HashSet(resources.length);
addJavaElements(javaElements, resources);
return SearchEngine.createJavaSearchScope((IJavaElement[])javaElements.toArray(new IJavaElement[javaElements.size()]));
}
public IJavaSearchScope createJavaSearchScope(IWorkingSet workingSet) {
return createJavaSearchScope(workingSet.getResources());
}
public IJavaSearchScope createJavaSearchScope(ISelection selection) {
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
Iterator iter= ((IStructuredSelection)selection).iterator();
Set javaElements= new HashSet(((IStructuredSelection)selection).size());
while (iter.hasNext()) {
Object selectedElement= iter.next();
if (selectedElement instanceof IJavaElement)
addJavaElements(javaElements, (IJavaElement)selectedElement);
else if (selectedElement instanceof IResource)
addJavaElements(javaElements, (IResource)selectedElement);
else if (selectedElement instanceof IAdaptable) {
IResource resource= (IResource)((IAdaptable)selectedElement).getAdapter(IResource.class);
if (resource != null)
addJavaElements(javaElements, resource);
}
}
return SearchEngine.createJavaSearchScope((IJavaElement[])javaElements.toArray(new IJavaElement[javaElements.size()]));
}
return EMPTY_SCOPE;
}
private void addJavaElements(Set javaElements, IResource[] resources) {
for (int i= 0; i < resources.length; i++)
addJavaElements(javaElements, resources[i]);
}
private void addJavaElements(Set javaElements, IResource resource) {
IJavaElement javaElement= JavaCore.create(resource);
if (javaElement == null)
// not a Java resource
return;
if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
// add other possible package fragments
try {
addJavaElements(javaElements, ((IFolder)resource).members());
} catch (CoreException ex) {
// don't add elements
}
}
addJavaElements(javaElements, javaElement);
}
private void addJavaElements(Set javaElements, IJavaElement javaElement) {
switch (javaElement.getElementType()) {
case IJavaElement.JAVA_PROJECT:
addJavaElements(javaElements, (IJavaProject)javaElement);
break;
default:
javaElements.add(javaElement);
}
}
private void addJavaElements(Set javaElements, IJavaProject javaProject) {
IPackageFragmentRoot[] roots;
try {
roots= javaProject.getPackageFragmentRoots();
} catch (JavaModelException ex) {
return;
}
for (int i= 0; i < roots.length; i++)
if (!roots[i].isExternal())
javaElements.add(roots[i]);
}
}
|
8,731 |
Bug 8731 Modify method parameters: unclear error message when renaming a paramter
|
Build 20020129 Rename a method parameter for a method that is also declared in an interface. You get the following message: Method ... is declared in an interface. Perform this action there. This makes only sense if I reorder parameters.
|
resolved fixed
|
2ee3ee7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T13:09:37Z | 2002-01-30T11:26:40Z |
org.eclipse.jdt.ui/core
| |
8,731 |
Bug 8731 Modify method parameters: unclear error message when renaming a paramter
|
Build 20020129 Rename a method parameter for a method that is also declared in an interface. You get the following message: Method ... is declared in an interface. Perform this action there. This makes only sense if I reorder parameters.
|
resolved fixed
|
2ee3ee7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T13:09:37Z | 2002-01-30T11:26:40Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ReorderParametersRefactoring.java
| |
6,224 |
Bug 6224 rename java doc reference to parameter [refactoring]
|
as in the summery - we should offer to rename java doc references to paramaters
|
resolved fixed
|
d9c805d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:23:08Z | 2001-11-22T11:53:20Z |
org.eclipse.jdt.ui.tests.refactoring/resources/RenameParameters/canRename/A_test35_in.java
| |
6,224 |
Bug 6224 rename java doc reference to parameter [refactoring]
|
as in the summery - we should offer to rename java doc references to paramaters
|
resolved fixed
|
d9c805d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:23:08Z | 2001-11-22T11:53:20Z |
org.eclipse.jdt.ui.tests.refactoring/resources/RenameParameters/canRename/A_test35_out.java
| |
6,224 |
Bug 6224 rename java doc reference to parameter [refactoring]
|
as in the summery - we should offer to rename java doc references to paramaters
|
resolved fixed
|
d9c805d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:23:08Z | 2001-11-22T11:53:20Z |
org.eclipse.jdt.ui.tests.refactoring/test
| |
6,224 |
Bug 6224 rename java doc reference to parameter [refactoring]
|
as in the summery - we should offer to rename java doc references to paramaters
|
resolved fixed
|
d9c805d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:23:08Z | 2001-11-22T11:53:20Z |
cases/org/eclipse/jdt/ui/tests/refactoring/RenameParametersTests.java
| |
8,673 |
Bug 8673 Bogus change names in preview page when renaming a method
|
Build 20020125 - select a method - open rename wizard - go to the preview page - all nodes are names update method reference
|
resolved fixed
|
21fd7ef
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:54:41Z | 2002-01-29T16:00:00Z |
org.eclipse.jdt.ui/core
| |
8,673 |
Bug 8673 Bogus change names in preview page when renaming a method
|
Build 20020125 - select a method - open rename wizard - go to the preview page - all nodes are names update method reference
|
resolved fixed
|
21fd7ef
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:54:41Z | 2002-01-29T16:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodRefactoring.java
| |
8,673 |
Bug 8673 Bogus change names in preview page when renaming a method
|
Build 20020125 - select a method - open rename wizard - go to the preview page - all nodes are names update method reference
|
resolved fixed
|
21fd7ef
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:54:41Z | 2002-01-29T16:00:00Z |
org.eclipse.jdt.ui/core
| |
8,673 |
Bug 8673 Bogus change names in preview page when renaming a method
|
Build 20020125 - select a method - open rename wizard - go to the preview page - all nodes are names update method reference
|
resolved fixed
|
21fd7ef
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T16:54:41Z | 2002-01-29T16:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePrivateMethodRefactoring.java
| |
9,015 |
Bug 9015 Organize imports feature finds errors in assert statements
|
Eclipse version 2.0, build 20020125, Windows, installed JDK1.4RC3 from Sun, used as external compiler, Compilation settings Java 1.4 (source and bytecode). When I use asserts of the form assert xx != null; in the code and try to invoke the Organize Imports feature, I get an error Compilation unit has syntax errors: Line <someline>: Syntax error on token "!=", ",", ";" expected. The class runs fine and shows no errors / warnings otherwise. Organize imports work fine if I place assert expression in brackets, like this: assert (xx != null);
|
verified fixed
|
37083a2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T19:23:25Z | 2002-02-04T13:40:00Z |
org.eclipse.jdt.ui/core
| |
9,015 |
Bug 9015 Organize imports feature finds errors in assert statements
|
Eclipse version 2.0, build 20020125, Windows, installed JDK1.4RC3 from Sun, used as external compiler, Compilation settings Java 1.4 (source and bytecode). When I use asserts of the form assert xx != null; in the code and try to invoke the Organize Imports feature, I get an error Compilation unit has syntax errors: Line <someline>: Syntax error on token "!=", ",", ";" expected. The class runs fine and shows no errors / warnings otherwise. Organize imports work fine if I place assert expression in brackets, like this: assert (xx != null);
|
verified fixed
|
37083a2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T19:23:25Z | 2002-02-04T13:40:00Z |
extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java
| |
9,015 |
Bug 9015 Organize imports feature finds errors in assert statements
|
Eclipse version 2.0, build 20020125, Windows, installed JDK1.4RC3 from Sun, used as external compiler, Compilation settings Java 1.4 (source and bytecode). When I use asserts of the form assert xx != null; in the code and try to invoke the Organize Imports feature, I get an error Compilation unit has syntax errors: Line <someline>: Syntax error on token "!=", ",", ";" expected. The class runs fine and shows no errors / warnings otherwise. Organize imports work fine if I place assert expression in brackets, like this: assert (xx != null);
|
verified fixed
|
37083a2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T19:23:25Z | 2002-02-04T13:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaStructureCreator.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.compare;
import java.io.InputStream;
import java.util.*;
import org.eclipse.jface.text.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.compare.*;
import org.eclipse.compare.structuremergeviewer.*;
public class JavaStructureCreator implements IStructureCreator {
/**
* Used to bail out from ProblemFactory.
*/
private static class ParseError extends Error {
}
/**
* This problem factory aborts parsing on first error.
*/
static class ProblemFactory implements IProblemFactory {
public IProblem createProblem(char[] originatingFileName, int problemId, String[] arguments, int severity, int startPosition, int endPosition, int lineNumber) {
throw new ParseError();
}
public Locale getLocale() {
return Locale.getDefault();
}
public String getLocalizedMessage(int problemId, String[] problemArguments) {
return "" + problemId; //$NON-NLS-1$
}
}
/**
* RewriteInfos are used temporarily when rewriting the diff tree
* in order to combine similar diff nodes ("smart folding").
*/
static class RewriteInfo {
boolean fIsOut= false;
JavaNode fAncestor= null;
JavaNode fLeft= null;
JavaNode fRight= null;
ArrayList fChildren= new ArrayList();
void add(IDiffElement diff) {
fChildren.add(diff);
}
void setDiff(ICompareInput diff) {
if (fIsOut)
return;
fIsOut= true;
JavaNode a= (JavaNode) diff.getAncestor();
JavaNode y= (JavaNode) diff.getLeft();
JavaNode m= (JavaNode) diff.getRight();
if (a != null) {
if (fAncestor != null)
return;
fAncestor= a;
}
if (y != null) {
if (fLeft != null)
return;
fLeft= y;
}
if (m != null) {
if (fRight != null)
return;
fRight= m;
}
fIsOut= false;
}
/**
* Returns true if some nodes could be successfully combined into one.
*/
boolean matches() {
return !fIsOut && fAncestor != null && fLeft != null && fRight != null;
}
}
public JavaStructureCreator() {
}
/**
* Returns the name that appears in the enclosing pane title bar.
*/
public String getName() {
return CompareMessages.getString("JavaStructureViewer.title"); //$NON-NLS-1$
}
/**
* Returns a tree of JavaNodes for the given input
* which must implement the IStreamContentAccessor interface.
* In case of error null is returned.
*/
public IStructureComparator getStructure(final Object input) {
String contents= null;
if (input instanceof IStreamContentAccessor) {
IStreamContentAccessor sca= (IStreamContentAccessor) input;
try {
contents= JavaCompareUtilities.readString(sca.getContents());
} catch (CoreException ex) {
JavaPlugin.log(ex);
return null;
}
}
if (contents != null) {
int n= contents.length();
char[] buffer= new char[n];
contents.getChars(0, n, buffer, 0);
Document doc= new Document(contents);
IDocumentPartitioner dp= JavaCompareUtilities.createJavaPartitioner();
if (dp != null) {
doc.setDocumentPartitioner(dp);
dp.connect(doc);
}
boolean isEditable= false;
if (input instanceof IEditableContent)
isEditable= ((IEditableContent) input).isEditable();
// we hook into the root node to intercept all node changes
JavaNode root= new JavaNode(doc, isEditable) {
void nodeChanged(JavaNode node) {
save(this, input);
}
};
JavaParseTreeBuilder builder= new JavaParseTreeBuilder(root, buffer);
SourceElementParser parser= new SourceElementParser(builder, new ProblemFactory(), new CompilerOptions());
try {
parser.parseCompilationUnit(builder, false);
} catch (ParseError ex) {
// parse error: bail out
return null;
}
return root;
}
return null;
}
/**
* Returns true because this IStructureCreator knows how to save.
*/
public boolean canSave() {
return true;
}
public void save(IStructureComparator node, Object input) {
if (node instanceof JavaNode && input instanceof IEditableContent) {
IDocument document= ((JavaNode)node).getDocument();
IEditableContent bca= (IEditableContent) input;
bca.setContent(document.get().getBytes());
}
}
/**
* Returns the contents of the given node as a string.
* This string is used to test the content of a Java element
* for equality. Is is never shown in the UI, so any string representing
* the content will do.
* @param node must implement the IStreamContentAccessor interface
* @param ignoreWhiteSpace if true all Java white space (incl. comments) is removed from the contents.
*/
public String getContents(Object node, boolean ignoreWhiteSpace) {
if (! (node instanceof IStreamContentAccessor))
return null;
IStreamContentAccessor sca= (IStreamContentAccessor) node;
String content= null;
try {
content= JavaCompareUtilities.readString(sca.getContents());
} catch (CoreException ex) {
JavaPlugin.log(ex);
return null;
}
if (ignoreWhiteSpace) { // we return everything but Java whitespace
// replace comments and whitespace by a single blank
StringBuffer buf= new StringBuffer();
char[] b= content.toCharArray();
// to avoid the trouble when dealing with Unicode
// we use the Java scanner to extract non-whitespace and non-comment tokens
Scanner scanner= new Scanner(true, true); // however we request Whitespace and Comments
scanner.setSourceBuffer(b);
try {
int token;
while ((token= scanner.getNextToken()) != TerminalSymbols.TokenNameEOF) {
switch (token) {
case Scanner.TokenNameWHITESPACE:
case Scanner.TokenNameCOMMENT_BLOCK:
case Scanner.TokenNameCOMMENT_JAVADOC:
case Scanner.TokenNameCOMMENT_LINE:
int l= buf.length();
if (l > 0 && buf.charAt(l-1) != ' ')
buf.append(' ');
break;
default:
buf.append(b, scanner.startPosition, scanner.currentPosition - scanner.startPosition);
buf.append(' ');
break;
}
}
content= buf.toString(); // success!
} catch (InvalidInputException ex) {
}
}
return content;
}
/**
* Returns true since this IStructureCreator can rewrite the diff tree
* in order to fold certain combinations of additons and deletions.
*/
public boolean canRewriteTree() {
return true;
}
/**
* Tries to detect certain combinations of additons and deletions
* as renames or signature changes and foldes them into a single node.
*/
public void rewriteTree(Differencer differencer, IDiffContainer root) {
HashMap map= new HashMap(10);
Object[] children= root.getChildren();
for (int i= 0; i < children.length; i++) {
DiffNode diff= (DiffNode) children[i];
JavaNode jn= (JavaNode) diff.getId();
if (jn == null)
continue;
int type= jn.getTypeCode();
// we can only combine methods or constructors
if (type == JavaNode.METHOD || type == JavaNode.CONSTRUCTOR) {
// find or create a RewriteInfo for all methods with the same name
String name= jn.extractMethodName();
RewriteInfo nameInfo= (RewriteInfo) map.get(name);
if (nameInfo == null) {
nameInfo= new RewriteInfo();
map.put(name, nameInfo);
}
nameInfo.add(diff);
// find or create a RewriteInfo for all methods with the same
// (non-empty) argument list
String argList= jn.extractArgumentList();
RewriteInfo argInfo= null;
if (argList != null && !argList.equals("()")) { //$NON-NLS-1$
argInfo= (RewriteInfo) map.get(argList);
if (argInfo == null) {
argInfo= new RewriteInfo();
map.put(argList, argInfo);
}
argInfo.add(diff);
}
switch (diff.getKind() & Differencer.CHANGE_TYPE_MASK) {
case Differencer.ADDITION:
case Differencer.DELETION:
// we only consider addition and deletions
// since a rename or arg list change looks
// like a pair of addition and deletions
if (type != JavaNode.CONSTRUCTOR)
nameInfo.setDiff((ICompareInput)diff);
if (argInfo != null)
argInfo.setDiff((ICompareInput)diff);
break;
default:
break;
}
}
// recurse
if (diff instanceof IDiffContainer)
rewriteTree(differencer, (IDiffContainer)diff);
}
// now we have to rebuild the diff tree according to the combined
// changes
Iterator it= map.keySet().iterator();
while (it.hasNext()) {
String name= (String) it.next();
RewriteInfo i= (RewriteInfo) map.get(name);
if (i.matches()) { // we found a RewriteInfo that could be succesfully combined
// we have to find the differences of the newly combined node
// (because in the first pass we only got a deletion and an addition)
DiffNode d= (DiffNode) differencer.findDifferences(true, null, root, i.fAncestor, i.fLeft, i.fRight);
if (d != null) {// there better should be a difference
d.setDontExpand(true);
Iterator it2= i.fChildren.iterator();
while (it2.hasNext()) {
IDiffElement rd= (IDiffElement) it2.next();
root.removeToRoot(rd);
d.add(rd);
}
}
}
}
}
/**
* If selector is an IJavaElement this method tries to return an
* IStructureComparator object for it.
* In case of error or if the given selector cannot be found
* null is returned.
* @param selector the IJavaElement to extract
* @param input must implement the IStreamContentAccessor interface.
*/
public IStructureComparator locate(Object selector, Object input) {
if (!(selector instanceof IJavaElement))
return null;
// try to build the JavaNode tree from input
IStructureComparator structure= getStructure(input);
if (structure == null) // we couldn't parse the structure
return null; // so we can't find anything
// build a path
String[] path= createPath((IJavaElement) selector);
// find the path in the JavaNode tree
return find(structure, path, 0);
}
private static String[] createPath(IJavaElement je) {
// build a path starting at the given Java element and walk
// up the parent chain until we reach a IWorkingCopy or ICompilationUnit
List args= new ArrayList();
while (je != null) {
// each path component has a name that uses the same
// conventions as a JavaNode name
String name= JavaCompareUtilities.getJavaElementID(je);
if (name == null)
return null;
args.add(name);
if (je instanceof IWorkingCopy || je instanceof ICompilationUnit)
break;
je= je.getParent();
}
// revert the path
int n= args.size();
String[] path= new String[n];
for (int i= 0; i < n; i++)
path[i]= (String) args.get(n-1-i);
return path;
}
/**
* Recursivly extracts the given path from the tree.
*/
private static IStructureComparator find(IStructureComparator tree, String[] path, int index) {
if (tree != null) {
Object[] children= tree.getChildren();
if (children != null) {
for (int i= 0; i < children.length; i++) {
IStructureComparator child= (IStructureComparator) children[i];
if (child instanceof ITypedElement && child instanceof DocumentRangeNode) {
String n1= null;
if (child instanceof DocumentRangeNode)
n1= ((DocumentRangeNode)child).getId();
if (n1 == null)
n1= ((ITypedElement)child).getName();
String n2= path[index];
if (n1.equals(n2)) {
if (index == path.length-1)
return child;
IStructureComparator result= find(child, path, index+1);
if (result != null)
return result;
}
}
}
}
}
return null;
}
/**
* Returns true if the given IJavaElement maps to a JavaNode.
* The JavaHistoryAction uses this function to determine whether
* a selected Java element can be replaced by some piece of
* code from the local history.
*/
static boolean hasEdition(IJavaElement je) {
if (je instanceof IMember && ((IMember)je).isBinary())
return false;
switch (je.getElementType()) {
case JavaElement.COMPILATION_UNIT:
case JavaElement.TYPE:
case JavaElement.FIELD:
case JavaElement.METHOD:
case JavaElement.INITIALIZER:
case JavaElement.PACKAGE_DECLARATION:
case JavaElement.IMPORT_CONTAINER:
case JavaElement.IMPORT_DECLARATION:
return true;
}
return false;
}
}
|
6,408 |
Bug 6408 Attempts to set breakpoint on unsaved resource fails
|
Create an empty class call Test Paste in: public static void main(String[] args) { while(true) { try { throwIt(); } catch (Exception e) { } } } public static void throwIt() throws InterruptedException { while(true) { Thread.yield(); } } Do NOT save Attempt to add a breakpoint on the Thread.yield() line We silently do not add the breakpoint.
|
verified fixed
|
596a9af
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-04T23:13:44Z | 2001-11-28T23:26:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/BreakpointRulerAction.java
|
package org.eclipse.jdt.internal.ui.javaeditor;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.MarkerRulerAction;
/**
*
*/
public class BreakpointRulerAction extends MarkerRulerAction {
public BreakpointRulerAction(IVerticalRuler ruler, ITextEditor editor) {
super(JavaEditorMessages.getResourceBundle(), "ManageBreakpoints.", ruler, editor, IBreakpoint.BREAKPOINT_MARKER, false); //$NON-NLS-1$
}
/**
* Checks whether the element the breakpoint refers to is shown in this editor
*/
protected boolean breakpointElementInEditor(IBreakpointManager manager, IMarker marker) {
return true;
}
/**
* @see MarkerRulerAction#getMarkers
*/
protected List getMarkers() {
List breakpoints= new ArrayList();
IResource resource= getResource();
IDocument document= getDocument();
AbstractMarkerAnnotationModel model= getAnnotationModel();
if (model != null) {
try {
IMarker[] markers= null;
if (resource instanceof IFile)
markers= resource.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
else {
IWorkspaceRoot root= JavaPlugin.getWorkspace().getRoot();
//fix for: 1GEUMGZ
markers= root.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
}
if (markers != null) {
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
for (int i= 0; i < markers.length; i++) {
IBreakpoint breakpoint= breakpointManager.getBreakpoint(markers[i]);
if (breakpoint != null && breakpointManager.isRegistered(breakpoint) &&
breakpointElementInEditor(breakpointManager, markers[i]) &&
includesRulerLine(model.getMarkerPosition(markers[i]), document))
breakpoints.add(markers[i]);
}
}
} catch (CoreException x) {
JavaPlugin.logErrorStatus(JavaEditorMessages.getString("ManageBreakpoints.error.retrieving.message"), x.getStatus()); //$NON-NLS-1$
}
}
return breakpoints;
}
/**
* @see MarkerRulerAction#addMarker
*/
protected void addMarker() {
IEditorInput editorInput= getTextEditor().getEditorInput();
IDocument document= getDocument();
int rulerLine= getVerticalRuler().getLineOfLastMouseButtonActivity();
try {
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidBreakpointLocation(document, rulerLine);
if (lineNumber > 0) {
IRegion line= document.getLineInformation(lineNumber - 1);
IType type = null;
if (editorInput instanceof IClassFileEditorInput) {
IClassFileEditorInput input= (IClassFileEditorInput) editorInput;
type = input.getClassFile().getType();
} else if (editorInput instanceof IFileEditorInput) {
IFileEditorInput input= (IFileEditorInput) editorInput;
ICompilationUnit cu = (ICompilationUnit) JavaCore.create(input.getFile());
IJavaElement e = cu.getElementAt(line.getOffset());
if (e instanceof IType)
type = (IType)e;
else if (e != null && e instanceof IMember) {
type = ((IMember)e).getDeclaringType();
}
}
if (type != null) {
if (!JDIDebugModel.lineBreakpointExists(type.getFullyQualifiedName(), lineNumber)) {
Map attributes = new HashMap(10);
JavaCore.addJavaElementMarkerAttributes(attributes, type);
attributes.put("org.eclipse.jdt.debug.ui.JAVA_ELEMENT_HANDLE_ID", type.getHandleIdentifier());
IJavaLineBreakpoint bp = JDIDebugModel.createLineBreakpoint(getBreakpointResource(type), type.getFullyQualifiedName(), lineNumber, line.getOffset(), line.getOffset() + line.getLength(), 0, true, attributes);
}
}
}
} catch (DebugException e) {
Shell shell= getTextEditor().getSite().getShell();
ErrorDialog.openError(shell, JavaEditorMessages.getString("ManageBreakpoints.error.adding.title1"), JavaEditorMessages.getString("ManageBreakpoints.error.adding.message1"), e.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
} catch (CoreException e) {
Shell shell= getTextEditor().getSite().getShell();
ErrorDialog.openError(shell, JavaEditorMessages.getString("ManageBreakpoints.error.adding.title2"), JavaEditorMessages.getString("ManageBreakpoints.error.adding.message2"), e.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
} catch (BadLocationException e) {
Shell shell= getTextEditor().getSite().getShell();
ErrorDialog.openError(shell, JavaEditorMessages.getString("ManageBreakpoints.error.adding.title3"), JavaEditorMessages.getString("ManageBreakpoints.error.adding.message3"), null); //$NON-NLS-2$ //$NON-NLS-1$
}
}
/**
* @see MarkerRulerAction#removeMarkers
*/
protected void removeMarkers(List markers) {
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
try {
Iterator e= markers.iterator();
while (e.hasNext()) {
IBreakpoint breakpoint= breakpointManager.getBreakpoint((IMarker) e.next());
breakpointManager.removeBreakpoint(breakpoint, true);
}
} catch (CoreException e) {
Shell shell= getTextEditor().getSite().getShell();
ErrorDialog.openError(shell, JavaEditorMessages.getString("ManageBreakpoints.error.removing.title1"), JavaEditorMessages.getString("ManageBreakpoints.error.removing.message1"), e.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
}
}
/**
* Returns the resource on which a breakpoint marker should
* be created for the given member. The resource returned is the
* associated file, or project in the case of a class file in
* a jar.
*
* @param member member in which a breakpoint is being created
* @return resource the resource on which a breakpoint marker
* should be created
* @exception CoreException if an exception occurrs accessing the
* underlying resource or Java model elements
*/
public IResource getBreakpointResource(IMember member) throws CoreException {
IResource res = member.getUnderlyingResource();
if (res == null) {
res = member.getJavaProject().getProject();
}
return res;
}
}
|
9,127 |
Bug 9127 JAR Packager: Path of exported resource wrong if src folder not under project
|
Create J project Create folder /x/y Define y as source folder ==> x/y appears as source folder ==> Files in x don't get exported ==> Path for resource files in x/y/ are wrong (i.e. contain /x/y) Note: *.java and *.class files are exported correctly.
|
resolved fixed
|
4dcd13b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-05T19:30:36Z | 2002-02-05T17:26:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.jarpackager;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.jar.Manifest;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.xml.sax.SAXException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaStatusConstants;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
/**
* Operation for exporting a resource and its children to a new JAR file.
*/
public class JarFileExportOperation implements IRunnableWithProgress {
private JarWriter fJarWriter;
private JarPackage fJarPackage;
private IFile[] fDescriptionFiles;
private Shell fParentShell;
private Map fJavaNameToClassFilesMap;
private IContainer fClassFilesMapContainer;
private MultiStatus fProblems;
/**
* Creates an instance of this class.
*
* @param jarPackage the JAR package specification
* @param parent the parent for the dialog,
* or <code>null</code> if no dialog should be presented
*/
public JarFileExportOperation(JarPackage jarPackage, Shell parent) {
this(parent);
fJarPackage= jarPackage;
}
/**
* Creates an instance of this class.
*
* @param descriptions an array with JAR package descriptions
* @param parent the parent for the dialog,
* or <code>null</code> if no dialog should be presented
*/
public JarFileExportOperation(IFile[] descriptions, Shell parent) {
this(parent);
fDescriptionFiles= descriptions;
}
/**
* Adds a new warning to the list with the passed information.
* Normally the export operation continues after a warning.
* @param message the message
* @param exception the throwable that caused the warning, or <code>null</code>
*/
private JarFileExportOperation(Shell parent) {
fParentShell= parent;
fProblems= new MultiStatus(JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, JarPackagerMessages.getString("JarFileExportOperation.exportFinishedWithWarnings"), null); //$NON-NLS-1$
}
protected void addWarning(String message, Throwable error) {
if (fJarPackage == null || fJarPackage.logWarnings())
fProblems.add(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, error));
}
/**
* Adds a new error to the list with the passed information.
* Normally an error terminates the export operation.
* @param message the message
* @param exception the throwable that caused the error, or <code>null</code>
*/
protected void addError(String message, Throwable error) {
if (fJarPackage == null || fJarPackage.logErrors())
fProblems.add(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, error));
}
/**
* Answers the number of file resources specified by the JAR package.
*
* @return int
*/
protected int countSelectedElements() {
int count= 0;
Iterator iter= fJarPackage.getSelectedElements().iterator();
while (iter.hasNext()) {
Object element= iter.next();
IResource resource= null;
if (element instanceof IJavaElement) {
IJavaElement je= (IJavaElement)element;
try {
resource= je.getUnderlyingResource();
} catch (JavaModelException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.underlyingResourceNotFound", je.getElementName()), ex); //$NON-NLS-1$
return count;
}
}
else
resource= (IResource)element;
if (resource.getType() == IResource.FILE)
count++;
else
count += getTotalChildCount((IContainer)resource);
}
return count;
}
private int getTotalChildCount(IContainer container) {
IResource[] members;
try {
members= container.members();
} catch (CoreException ex) {
return 0;
}
int count= 0;
for (int i= 0; i < members.length; i++) {
if (members[i].getType() == IResource.FILE)
count++;
else
count += getTotalChildCount((IContainer)members[i]);
}
return count;
}
/**
* Exports the passed resource to the JAR file
*
* @param element the resource or JavaElement to export
*/
protected void exportElement(Object element, IProgressMonitor progressMonitor) throws InterruptedException {
int leadSegmentsToRemove= 1;
IPackageFragmentRoot pkgRoot= null;
boolean isInJavaProject= false;
IResource resource= null;
IJavaProject jProject= null;
if (element instanceof IJavaElement) {
isInJavaProject= true;
IJavaElement je= (IJavaElement)element;
try {
resource= je.getUnderlyingResource();
} catch (JavaModelException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.underlyingResourceNotFound", je.getElementName()), ex); //$NON-NLS-1$
return;
}
jProject= je.getJavaProject();
pkgRoot= JavaModelUtil.getPackageFragmentRoot(je);
}
else
resource= (IResource)element;
if (!resource.isAccessible()) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.resourceNotFound", resource.getFullPath()), null); //$NON-NLS-1$
return;
}
if (resource.getType() == IResource.FILE) {
if (!resource.isLocal(IResource.DEPTH_ZERO))
try {
resource.setLocal(true , IResource.DEPTH_ZERO, progressMonitor);
} catch (CoreException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.resourceNotLocal", resource.getFullPath()), ex); //$NON-NLS-1$
return;
}
if (!isInJavaProject) {
// check if it's a Java resource
try {
isInJavaProject= resource.getProject().hasNature(JavaCore.NATURE_ID);
} catch (CoreException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.projectNatureNotDeterminable", resource.getFullPath()), ex); //$NON-NLS-1$
return;
}
if (isInJavaProject) {
jProject= JavaCore.create(resource.getProject());
try {
IPackageFragment pkgFragment= jProject.findPackageFragment(resource.getFullPath().removeLastSegments(1));
if (pkgFragment != null)
pkgRoot= JavaModelUtil.getPackageFragmentRoot(pkgFragment);
else
pkgRoot= jProject.findPackageFragmentRoot(resource.getFullPath().uptoSegment(2));
} catch (JavaModelException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.javaPackageNotDeterminable", resource.getFullPath()), ex); //$NON-NLS-1$
return;
}
}
}
if (pkgRoot != null) {
leadSegmentsToRemove= pkgRoot.getPath().segmentCount();
if (fJarPackage.useSourceFolderHierarchy()&& !pkgRoot.getElementName().equals(pkgRoot.DEFAULT_PACKAGEROOT_PATH))
leadSegmentsToRemove--;
}
IPath destinationPath= resource.getFullPath().removeFirstSegments(leadSegmentsToRemove);
boolean isInOutputFolder= false;
if (isInJavaProject) {
try {
isInOutputFolder= jProject.getOutputLocation().isPrefixOf(resource.getFullPath());
} catch (JavaModelException ex) {
isInOutputFolder= false;
}
}
exportClassFiles(progressMonitor, pkgRoot, resource, jProject, destinationPath);
exportResourceFiles(progressMonitor, pkgRoot, isInJavaProject, resource, destinationPath, isInOutputFolder);
progressMonitor.worked(1);
ModalContext.checkCanceled(progressMonitor);
} else
exportContainer(progressMonitor, resource);
}
private void exportContainer(IProgressMonitor progressMonitor, IResource resource) throws java.lang.InterruptedException {
IResource[] children= null;
try {
children= ((IContainer) resource).members();
} catch (CoreException e) {
// this should never happen because an #isAccessible check is done before #members is invoked
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.errorDuringExport", resource.getFullPath()), e); //$NON-NLS-1$
}
for (int i= 0; i < children.length; i++)
exportElement(children[i], progressMonitor);
}
private void exportResourceFiles(IProgressMonitor progressMonitor, IPackageFragmentRoot pkgRoot, boolean isInJavaProject, IResource resource, IPath destinationPath, boolean isInOutputFolder) {
boolean isNonJavaResource= !isInJavaProject || (pkgRoot == null && !isInOutputFolder);
boolean isInClassFolder= false;
try {
isInClassFolder= pkgRoot != null && !pkgRoot.isArchive() && pkgRoot.getKind() == pkgRoot.K_BINARY;
} catch (JavaModelException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.cantGetRootKind", resource.getFullPath()), ex); //$NON-NLS-1$
}
if ((fJarPackage.areClassFilesExported() &&
((isNonJavaResource || (pkgRoot != null && !isJavaFile(resource) && !isClassFile(resource)))
|| isInClassFolder && isClassFile(resource)))
|| (fJarPackage.areJavaFilesExported() && (isNonJavaResource || (pkgRoot != null && !isClassFile(resource))))) {
try {
progressMonitor.subTask(destinationPath.toString());
fJarWriter.write((IFile) resource, destinationPath);
} catch (IOException ex) {
String message= ex.getMessage();
if (message == null)
message= JarPackagerMessages.getFormattedString("JarFileExportOperation.ioErrorDuringExport", resource.getFullPath()); //$NON-NLS-1$
addWarning(message , ex);
} catch (CoreException ex) {
String message= ex.getMessage();
if (message == null)
message= JarPackagerMessages.getFormattedString("JarFileExportOperation.coreErrorDuringExport", resource.getFullPath()); //$NON-NLS-1$
addWarning(message, ex);
}
}
}
private void exportClassFiles(IProgressMonitor progressMonitor, IPackageFragmentRoot pkgRoot, IResource resource, IJavaProject jProject, IPath destinationPath) {
if (fJarPackage.areClassFilesExported() && isJavaFile(resource) && pkgRoot != null) {
try {
// find corresponding file(s) on classpath and export
Iterator iter= filesOnClasspath((IFile)resource, destinationPath, jProject, progressMonitor);
IPath baseDestinationPath= destinationPath.removeLastSegments(1);
while (iter.hasNext()) {
IFile file= (IFile)iter.next();
if (!resource.isLocal(IResource.DEPTH_ZERO))
file.setLocal(true , IResource.DEPTH_ZERO, progressMonitor);
IPath classFilePath= baseDestinationPath.append(file.getName());
progressMonitor.subTask(classFilePath.toString());
fJarWriter.write(file, classFilePath);
}
} catch (IOException ex) {
String message= ex.getMessage();
if (message == null)
message= JarPackagerMessages.getFormattedString("JarFileExportOperation.ioErrorDuringExport", resource.getFullPath()); //$NON-NLS-1$
addWarning(message , ex);
} catch (CoreException ex) {
String message= ex.getMessage();
if (message == null)
message= JarPackagerMessages.getFormattedString("JarFileExportOperation.coreErrorDuringExport", resource.getFullPath()); //$NON-NLS-1$
addWarning(message, ex);
}
}
}
/**
* Exports the resources as specified by the JAR package.
*/
protected void exportSelectedElements(IProgressMonitor progressMonitor) throws InterruptedException {
Iterator iter= fJarPackage.getSelectedElements().iterator();
while (iter.hasNext())
exportElement(iter.next(), progressMonitor);
}
/**
* Returns an iterator on a list with files that correspond to the
* passed file and that are on the classpath of its project.
*
* @param file the file for which to find the corresponding classpath resources
* @param pathInJar the path that the file has in the JAR (i.e. project and source folder segments removed)
* @param javaProject the javaProject that contains the file
* @return the iterator over the corresponding classpath files for the given file
*/
protected Iterator filesOnClasspath(IFile file, IPath pathInJar, IJavaProject javaProject, IProgressMonitor progressMonitor) throws CoreException {
IPath outputPath= javaProject.getOutputLocation();
IContainer outputContainer;
if (javaProject.getProject().getFullPath().equals(outputPath))
outputContainer= javaProject.getProject();
else {
outputContainer= createFolderHandle(outputPath);
if (outputContainer == null || !outputContainer.isAccessible()) {
String msg= JarPackagerMessages.getString("JarFileExportOperation.outputContainerNotAccessible"); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, msg, null));
}
}
if (isJavaFile(file)) {
// Java CU - search files with .class ending
boolean hasErrors= fJarPackage.hasCompileErrors(file);
boolean hasWarnings= fJarPackage.hasCompileWarnings(file);
boolean canBeExported= canBeExported(hasErrors, hasWarnings);
reportPossibleCompileProblems(file, hasErrors, hasWarnings, canBeExported);
if (!canBeExported)
return Collections.EMPTY_LIST.iterator();
IContainer classContainer= outputContainer;
if (pathInJar.segmentCount() > 1)
classContainer= outputContainer.getFolder(pathInJar.removeLastSegments(1));
if (fClassFilesMapContainer == null || !fClassFilesMapContainer.equals(classContainer)) {
fJavaNameToClassFilesMap= buildJavaToClassMap(classContainer);
fClassFilesMapContainer= classContainer;
}
ArrayList classFiles= (ArrayList)fJavaNameToClassFilesMap.get(file.getName());
if (classFiles == null || classFiles.isEmpty()) {
String msg= JarPackagerMessages.getFormattedString("JarFileExportOperation.classFileOnClasspathNotAccessible", file.getFullPath()); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, msg, null));
}
return classFiles.iterator();
}
else {
// resource - search file with same name
List binaryFiles= new ArrayList(1);
IFile cpFile= outputContainer.getFile(pathInJar);
if (cpFile.isAccessible()) {
if (!cpFile.isLocal(IResource.DEPTH_ZERO))
cpFile.setLocal(true , IResource.DEPTH_ZERO, progressMonitor);
binaryFiles.add(cpFile);
}
else {
String msg= JarPackagerMessages.getFormattedString("JarFileExportOperation.resourceOnCasspathNotAccessible", cpFile.getFullPath()); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), JavaStatusConstants.INTERNAL_ERROR, msg, null));
}
return binaryFiles.iterator();
}
}
/**
* Answers whether the given resource is a Java file.
* The resource must be a file whose file name ends with ".java".
*
* @return a <code>true<code> if the given resource is a Java file
*/
boolean isJavaFile(IResource file) {
return file != null
&& file.getType() == IFile.FILE
&& file.getFileExtension() != null
&& file.getFileExtension().equalsIgnoreCase("java"); //$NON-NLS-1$
}
/**
* Answers whether the given resource is a class file.
* The resource must be a file whose file name ends with ".class".
*
* @return a <code>true<code> if the given resource is a class file
*/
boolean isClassFile(IResource file) {
return file != null
&& file.getType() == IFile.FILE
&& file.getFileExtension() != null
&& file.getFileExtension().equalsIgnoreCase("class"); //$NON-NLS-1$
}
/*
* Builds and returns a map that has the class files
* for each java file in a given directory
*/
private Map buildJavaToClassMap(IContainer container) throws CoreException {
if (container == null || !container.isAccessible())
return new HashMap(0);
/*
* XXX: Bug 6584: Need a way to get class files for a java file (or CU)
*/
org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfReader;
IResource[] members= container.members();
Map map= new HashMap(members.length);
for (int i= 0; i < members.length; i++) {
if (isClassFile(members[i])) {
IFile classFile= (IFile)members[i];
try {
cfReader= org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(classFile.getLocation().toFile());
} catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.invalidClassFileFormat", classFile.getLocation().toFile()), ex); //$NON-NLS-1$
continue;
} catch (IOException ex) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.ioErrorDuringClassFileLookup", classFile.getLocation().toFile()), ex); //$NON-NLS-1$
continue;
}
if (cfReader != null) {
if (cfReader.sourceFileName() == null) {
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.classFileWithoutSourceFileAttribute", classFile.getLocation().toFile()), null); //$NON-NLS-1$
continue;
}
String javaName= new String(cfReader.sourceFileName());
Object classFiles= map.get(javaName);
if (classFiles == null) {
classFiles= new ArrayList(3);
map.put(javaName, classFiles);
}
((ArrayList)classFiles).add(classFile);
}
}
}
return map;
}
/**
* Creates a file resource handle for the file with the given workspace path.
* This method does not create the file resource; this is the responsibility
* of <code>createFile</code>.
*
* @param filePath the path of the file resource to create a handle for
* @return the new file resource handle
* @see #createFile
*/
protected IFile createFileHandle(IPath filePath) {
if (filePath.isValidPath(filePath.toString()) && filePath.segmentCount() >= 2)
return JavaPlugin.getWorkspace().getRoot().getFile(filePath);
else
return null;
}
/**
* Creates a folder resource handle for the folder with the given workspace path.
*
* @param folderPath the path of the folder to create a handle for
* @return the new folder resource handle
*/
protected IFolder createFolderHandle(IPath folderPath) {
if (folderPath.isValidPath(folderPath.toString()) && folderPath.segmentCount() >= 2)
return JavaPlugin.getWorkspace().getRoot().getFolder(folderPath);
else
return null;
}
/**
* Returns the status of this operation.
* If there were any errors, the result is a status object containing
* individual status objects for each error.
* If there were no errors, the result is a status object with error code <code>OK</code>.
*
* @return the status of this operation
*/
public IStatus getStatus() {
if (fProblems.getSeverity() == IStatus.ERROR) {
String message= null;
if (fDescriptionFiles != null && fDescriptionFiles.length > 1)
message= JarPackagerMessages.getString("JarFileExportOperation.creationOfSomeJARsFailed"); //$NON-NLS-1$
else
message= JarPackagerMessages.getString("JarFileExportOperation.jarCreationFailed"); //$NON-NLS-1$
// Create new status because we want another message - no API to set message
return new MultiStatus(JavaPlugin.getPluginId(), 0, fProblems.getChildren(), message, null);
}
return fProblems;
}
/**
* Answer a boolean indicating whether the passed child is a descendant
* of one or more members of the passed resources collection
*
* @param resources a List contain potential parents
* @param child the resource to test
* @return a <code>boolean</code> indicating if the child is a descendant
*/
protected boolean isDescendant(List resources, IResource child) {
if (child.getType() == IResource.PROJECT)
return false;
IResource parent= child.getParent();
if (resources.contains(parent))
return true;
return isDescendant(resources, parent);
}
protected boolean canBeExported(boolean hasErrors, boolean hasWarnings) throws CoreException {
return (!hasErrors && !hasWarnings)
|| (hasErrors && fJarPackage.exportErrors())
|| (hasWarnings && fJarPackage.exportWarnings());
}
protected void reportPossibleCompileProblems(IFile file, boolean hasErrors, boolean hasWarnings, boolean canBeExported) {
if (hasErrors) {
if (canBeExported)
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.exportedWithCompileErrors", file.getFullPath()), null); //$NON-NLS-1$
else
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.notExportedDueToCompileErrors", file.getFullPath()), null); //$NON-NLS-1$
}
if (hasWarnings) {
if (canBeExported)
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.exportedWithCompileWarnings", file.getFullPath()), null); //$NON-NLS-1$
else
addWarning(JarPackagerMessages.getFormattedString("JarFileExportOperation.notExportedDueToCompileWarnings", file.getFullPath()), null); //$NON-NLS-1$
}
}
/**
* Exports the resources as specified by the JAR package.
*
* @param progressMonitor the progress monitor that displays the progress
* @see #getStatus()
*/
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
if (fJarPackage != null)
singleRun(progressMonitor);
else {
int jarCount= fDescriptionFiles.length;
for (int i= 0; i < jarCount; i++) {
fJarPackage= readJarPackage(fDescriptionFiles[i]);
if (fJarPackage != null)
singleRun(progressMonitor);
}
}
}
public void singleRun(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
int totalWork= countSelectedElements();
progressMonitor.beginTask(JarPackagerMessages.getString("JarFileExportOperation.exporting"), totalWork); //$NON-NLS-1$
try {
if (!preconditionsOK())
throw new InvocationTargetException(null, JarPackagerMessages.getString("JarFileExportOperation.jarCreationFailedSeeDetails")); //$NON-NLS-1$
fJarWriter= new JarWriter(fJarPackage, fParentShell);
exportSelectedElements(progressMonitor);
if (getStatus().getSeverity() != IStatus.ERROR) {
progressMonitor.subTask(JarPackagerMessages.getString("JarFileExportOperation.savingFiles")); //$NON-NLS-1$
saveFiles();
}
} catch (IOException ex) {
String message= JarPackagerMessages.getFormattedString("JarFileExportOperation.unableToCreateJarFle", ex.getMessage()); //$NON-NLS-1$
addError(message, ex);
throw new InvocationTargetException(ex, message);
} catch (CoreException ex) {
String message= JarPackagerMessages.getFormattedString("JarFileExportOperation.unableToCreateJarFileDueToInvalidManifest", ex.getMessage()); //$NON-NLS-1$
addError(message, ex);
throw new InvocationTargetException(ex, message);
} finally {
try {
if (fJarWriter != null)
fJarWriter.close();
} catch (IOException ex) {
String message= JarPackagerMessages.getFormattedString("JarFileExportOperation.unableToCloseJarFile", ex.getMessage()); //$NON-NLS-1$
addError(message, ex);
throw new InvocationTargetException(ex, message);
}
progressMonitor.done();
}
}
protected boolean preconditionsOK() {
if (!fJarPackage.areClassFilesExported() && !fJarPackage.areJavaFilesExported()) {
addError(JarPackagerMessages.getString("JarFileExportOperation.noExportTypeChosen"), null); //$NON-NLS-1$
return false;
}
if (fJarPackage.getSelectedElements() == null || fJarPackage.getSelectedElements().size() == 0) {
addError(JarPackagerMessages.getString("JarFileExportOperation.noResourcesSelected"), null); //$NON-NLS-1$
return false;
}
if (fJarPackage.getJarLocation() == null) {
addError(JarPackagerMessages.getString("JarFileExportOperation.invalidJarLocation"), null); //$NON-NLS-1$
return false;
}
if (!fJarPackage.doesManifestExist()) {
addError(JarPackagerMessages.getString("JarFileExportOperation.manifestDoesNotExist"), null); //$NON-NLS-1$
return false;
}
if (!fJarPackage.isMainClassValid(new BusyIndicatorRunnableContext())) {
addError(JarPackagerMessages.getString("JarFileExportOperation.invalidMainClass"), null); //$NON-NLS-1$
return false;
}
IEditorPart[] dirtyEditors= JavaPlugin.getDirtyEditors();
if (dirtyEditors.length > 0) {
List unsavedFiles= new ArrayList(dirtyEditors.length);
List selection= fJarPackage.getSelectedResources();
for (int i= 0; i < dirtyEditors.length; i++) {
if (dirtyEditors[i].getEditorInput() instanceof IFileEditorInput) {
IFile dirtyFile= ((IFileEditorInput)dirtyEditors[i].getEditorInput()).getFile();
if (selection.contains(dirtyFile)) {
unsavedFiles.add(dirtyFile);
addError(JarPackagerMessages.getFormattedString("JarFileExportOperation.fileUnsaved", dirtyFile.getFullPath()), null); //$NON-NLS-1$
}
}
}
if (!unsavedFiles.isEmpty())
return false;
}
return true;
}
protected void saveFiles() {
// Save the manifest
if (fJarPackage.isManifestSaved()) {
try {
saveManifest();
} catch (CoreException ex) {
addError(JarPackagerMessages.getString("JarFileExportOperation.errorSavingManifest"), ex); //$NON-NLS-1$
} catch (IOException ex) {
addError(JarPackagerMessages.getString("JarFileExportOperation.errorSavingManifest"), ex); //$NON-NLS-1$
}
}
// Save the description
if (fJarPackage.isDescriptionSaved()) {
try {
saveDescription();
} catch (CoreException ex) {
addError(JarPackagerMessages.getString("JarFileExportOperation.errorSavingDescription"), ex); //$NON-NLS-1$
} catch (IOException ex) {
addError(JarPackagerMessages.getString("JarFileExportOperation.errorSavingDescription"), ex); //$NON-NLS-1$
}
}
}
protected void saveDescription() throws CoreException, IOException {
// Adjust JAR package attributes
if (fJarPackage.isManifestReused())
fJarPackage.setGenerateManifest(false);
ByteArrayOutputStream objectStreamOutput= new ByteArrayOutputStream();
JarPackageWriter objectStream= new JarPackageWriter(objectStreamOutput);
ByteArrayInputStream fileInput= null;
try {
objectStream.writeXML(fJarPackage);
fileInput= new ByteArrayInputStream(objectStreamOutput.toByteArray());
if (fJarPackage.getDescriptionFile().isAccessible()) {
if (fJarPackage.canOverwriteDescription(fParentShell))
fJarPackage.getDescriptionFile().setContents(fileInput, true, true, null);
}
else {
fJarPackage.getDescriptionFile().create(fileInput, true, null);
}
} finally {
if (fileInput != null)
fileInput.close();
if (objectStream != null)
objectStream.close();
}
}
protected void saveManifest() throws CoreException, IOException {
ByteArrayOutputStream manifestOutput= new ByteArrayOutputStream();
ByteArrayInputStream fileInput= null;
try {
Manifest manifest= fJarPackage.getManifestProvider().create(fJarPackage);
manifest.write(manifestOutput);
fileInput= new ByteArrayInputStream(manifestOutput.toByteArray());
if (fJarPackage.getManifestFile().isAccessible()) {
if (fJarPackage.canOverwriteManifest(fParentShell))
fJarPackage.getManifestFile().setContents(fileInput, true, true, null);
}
else {
fJarPackage.getManifestFile().create(fileInput, true, null);
}
} finally {
if (manifestOutput != null)
manifestOutput.close();
if (fileInput != null)
fileInput.close();
}
}
/**
* Reads the JAR package spec from file.
*/
protected JarPackage readJarPackage(IFile description) {
Assert.isLegal(description.isAccessible());
Assert.isNotNull(description.getFileExtension());
Assert.isLegal(description.getFileExtension().equals(JarPackage.DESCRIPTION_EXTENSION));
JarPackage jarPackage= null;
JarPackageReader reader= null;
try {
reader= new JarPackageReader(description.getContents());
// Do not save - only generate JAR
jarPackage= reader.readXML();
jarPackage.setSaveManifest(false);
jarPackage.setSaveDescription(false);
} catch (CoreException ex) {
addError(JarPackagerMessages.getString("JarFileExportOperation.errorReadingJarPackageFromDescription"), ex); //$NON-NLS-1$
} catch (IOException ex) {
String message= JarPackagerMessages.getFormattedString("JarFileExportOperation.errorReadingFile", description.getFullPath(), ex.getMessage()); //$NON-NLS-1$
addError(message, null);
} catch (SAXException ex) {
String message= JarPackagerMessages.getFormattedString("JarFileExportOperation.badXmlFormat", description.getFullPath(), ex.getMessage()); //$NON-NLS-1$
addError(message, null);
} finally {
if ((jarPackage == null || jarPackage.logWarnings()) && reader != null)
// AddWarnings
fProblems.addAll(reader.getWarnings());
try {
if (reader != null)
reader.close();
}
catch (IOException ex) {
addError(JarPackagerMessages.getFormattedString("JarFileExportOperation.errorClosingJarPackageDescriptionReader", description.getFullPath()), ex); //$NON-NLS-1$
}
}
return jarPackage;
}
}
|
8,107 |
Bug 8107 bracket hightlighting: can't change color
|
the color changing option in the preference page seems to be always disabled
|
verified fixed
|
48c416a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T10:04:59Z | 2002-01-23T15:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.preferences;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
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.graphics.Color;
import org.eclipse.swt.graphics.RGB;
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.List;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.help.DialogPageContextComputer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
import org.eclipse.jdt.ui.text.IJavaColorConstants;
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.jdt.internal.ui.util.TabFolderLayout;
/*
* The page for setting the editor options.
*/
public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, JavaSourceViewerConfiguration.PREFERENCE_TAB_WIDTH),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVA_KEYWORD),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVA_KEYWORD + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVA_STRING),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVA_STRING + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVA_DEFAULT),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVA_DEFAULT + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVADOC_KEYWORD),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVADOC_KEYWORD + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVADOC_TAG),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVADOC_TAG + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVADOC_LINK),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVADOC_LINK + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IJavaColorConstants.JAVADOC_DEFAULT),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IJavaColorConstants.JAVADOC_DEFAULT + "_bold"),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CompilationUnitEditor.MATCHING_BRACKETS_COLOR),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CompilationUnitEditor.MATCHING_BRACKETS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOACTIVATION),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVA),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_VISIBLE_PROPOSALS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_IMPORT)
};
private final String[][] fListModel= new String[][] {
{ "Multi-line comment", IJavaColorConstants.JAVA_MULTI_LINE_COMMENT },
{ "Single-line comment", IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT },
{ "Keywords", IJavaColorConstants.JAVA_KEYWORD },
{ "Strings", IJavaColorConstants.JAVA_STRING },
{ "Others", IJavaColorConstants.JAVA_DEFAULT },
{ "JavaDoc keywords", IJavaColorConstants.JAVADOC_KEYWORD },
{ "JavaDoc HTML tags", IJavaColorConstants.JAVADOC_TAG },
{ "JavaDoc links", IJavaColorConstants.JAVADOC_LINK },
{"JavaDoc others", IJavaColorConstants.JAVADOC_DEFAULT }
};
private OverlayPreferenceStore fOverlayStore;
private JavaTextTools fJavaTextTools;
private Map fColorButtons= new HashMap();
private SelectionListener fColorButtonListener= new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
ColorEditor editor= (ColorEditor) e.widget.getData();
PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
}
};
private Map fCheckBoxes= new HashMap();
private SelectionListener fCheckBoxListener= new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
Button button= (Button) e.widget;
fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
};
private Map fTextFields= new HashMap();
private ModifyListener fTextFieldListener= new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text= (Text) e.widget;
fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
}
};
private WorkbenchChainedTextFontFieldEditor fFontEditor;
private List fList;
private ColorEditor fColorEditor;
private Button fBoldCheckBox;
private SourceViewer fPreviewViewer;
public JavaEditorPreferencePage() {
setDescription(JavaUIMessages.getString("JavaEditorPreferencePage.description"));
setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
}
public static void initDefaults(IPreferenceStore store) {
Color color;
Display display= Display.getDefault();
store.setDefault(CompilationUnitEditor.MATCHING_BRACKETS, true);
color= display.getSystemColor(SWT.COLOR_GRAY);
PreferenceConverter.setDefault(store, CompilationUnitEditor.MATCHING_BRACKETS_COLOR, color.getRGB());
WorkbenchChainedTextFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT);
color= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, color.getRGB());
color= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, color.getRGB());
store.setDefault(JavaSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 4);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT, new RGB(63, 127, 95));
store.setDefault(IJavaColorConstants.JAVA_MULTI_LINE_COMMENT + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT, new RGB(63, 127, 95));
store.setDefault(IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVA_KEYWORD, new RGB(127, 0, 85));
store.setDefault(IJavaColorConstants.JAVA_KEYWORD + "_bold", true);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVA_STRING, new RGB(42, 0, 255));
store.setDefault(IJavaColorConstants.JAVA_STRING + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVA_DEFAULT, new RGB(0, 0, 0));
store.setDefault(IJavaColorConstants.JAVA_DEFAULT + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVADOC_KEYWORD, new RGB(127, 159, 191));
store.setDefault(IJavaColorConstants.JAVADOC_KEYWORD + "_bold", true);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVADOC_TAG, new RGB(127, 127, 159));
store.setDefault(IJavaColorConstants.JAVADOC_TAG + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVADOC_LINK, new RGB(63, 63, 191));
store.setDefault(IJavaColorConstants.JAVADOC_LINK + "_bold", false);
PreferenceConverter.setDefault(store, IJavaColorConstants.JAVADOC_DEFAULT, new RGB(63, 95, 191));
store.setDefault(IJavaColorConstants.JAVADOC_DEFAULT + "_bold", false);
store.setDefault(ContentAssistPreference.AUTOACTIVATION, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
store.setDefault(ContentAssistPreference.AUTOINSERT, false);
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVA, ".,");
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, "@");
store.setDefault(ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, true);
store.setDefault(ContentAssistPreference.CASE_SENSITIVITY, false);
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
store.setDefault(ContentAssistPreference.ADD_IMPORT, true);
}
/*
* @see IWorkbenchPreferencePage#init()
*/
public void init(IWorkbench workbench) {
}
/*
* @see PreferencePage#createControl(Composite)
*/
public void createControl(Composite parent) {
super.createControl(parent);
WorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE));
}
private void handleListSelection() {
int i= fList.getSelectionIndex();
String key= fListModel[i][1];
RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
fColorEditor.setColorValue(rgb);
fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + "_bold"));
}
private Control createColorPage(Composite parent) {
Composite colorComposite= new Composite(parent, SWT.NULL);
colorComposite.setLayout(new GridLayout());
Label label= new Label(colorComposite, SWT.LEFT);
label.setText("C&olors:");
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite editorComposite= new Composite(colorComposite, SWT.NULL);
GridLayout layout= new GridLayout();
layout.numColumns= 2;
layout.marginHeight= 0;
layout.marginWidth= 0;
editorComposite.setLayout(layout);
GridData gd= new GridData(GridData.FILL_BOTH);
editorComposite.setLayoutData(gd);
fList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL);
gd= new GridData(GridData.FILL_BOTH);
gd.heightHint= convertHeightInCharsToPixels(5);
fList.setLayoutData(gd);
Composite stylesComposite= new Composite(editorComposite, SWT.NULL);
layout= new GridLayout();
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.numColumns= 2;
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
label= new Label(stylesComposite, SWT.LEFT);
label.setText("Fo®round:");
gd= new GridData();
gd.horizontalAlignment= GridData.BEGINNING;
label.setLayoutData(gd);
fColorEditor= new ColorEditor(stylesComposite);
Button colorButton= fColorEditor.getButton();
gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment= GridData.BEGINNING;
colorButton.setLayoutData(gd);
label= new Label(stylesComposite, SWT.LEFT);
label.setText("&Bold:");
gd= new GridData();
gd.horizontalAlignment= GridData.BEGINNING;
label.setLayoutData(gd);
fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment= GridData.BEGINNING;
fBoldCheckBox.setLayoutData(gd);
label= new Label(colorComposite, SWT.LEFT);
label.setText("Preview:");
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control previewer= createPreviewer(colorComposite);
gd= new GridData(GridData.FILL_BOTH);
gd.widthHint= convertWidthInCharsToPixels(80);
gd.heightHint= convertHeightInCharsToPixels(15);
previewer.setLayoutData(gd);
fList.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
public void widgetSelected(SelectionEvent e) {
handleListSelection();
}
});
colorButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
public void widgetSelected(SelectionEvent e) {
int i= fList.getSelectionIndex();
String key= fListModel[i][1];
PreferenceConverter.setValue(fOverlayStore, key, fColorEditor.getColorValue());
}
});
fBoldCheckBox.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
public void widgetSelected(SelectionEvent e) {
int i= fList.getSelectionIndex();
String key= fListModel[i][1];
fOverlayStore.setValue(key + "_bold", fBoldCheckBox.getSelection());
}
});
return colorComposite;
}
private Control createPreviewer(Composite parent) {
fJavaTextTools= new JavaTextTools(fOverlayStore);
fPreviewViewer= new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL);
fPreviewViewer.configure(new JavaSourceViewerConfiguration(fJavaTextTools, null));
fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
fPreviewViewer.setEditable(false);
String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt");
IDocument document= new Document(content);
IDocumentPartitioner partitioner= fJavaTextTools.createDocumentPartitioner();
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
fPreviewViewer.setDocument(document);
fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
fPreviewViewer.invalidateTextPresentation();
}
});
return fPreviewViewer.getControl();
}
private Control createBehaviorPage(Composite parent) {
Composite behaviorComposite= new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout(); layout.numColumns= 2;
behaviorComposite.setLayout(layout);
String label= "Highlight &matching brackets";
final Button checkBox= addCheckBox(behaviorComposite, label, CompilationUnitEditor.MATCHING_BRACKETS, 0);
label= "Matching &brackets highlight color:";
final Control colorControl= addColorButton(behaviorComposite, label, CompilationUnitEditor.MATCHING_BRACKETS_COLOR, 0);
checkBox.addSelectionListener(new SelectionListener() {
Control control= colorControl;
Button button= checkBox;
ControlEnableState state= button.getSelection() ? null : ControlEnableState.disable(control);
public void widgetSelected(SelectionEvent e) {
if (button.getSelection()) {
if (state != null) {
state.restore();
state= null;
}
} else {
state= ControlEnableState.disable(control);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
label= "Text font:";
addTextFontEditor(behaviorComposite, label, AbstractTextEditor.PREFERENCE_FONT);
label= "Displayed &tab width:";
addTextField(behaviorComposite, label, JavaSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0);
return behaviorComposite;
}
private Control createContentAssistPage(Composite parent) {
Composite contentAssistComposite= new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout(); layout.numColumns= 2;
contentAssistComposite.setLayout(layout);
String label= "Insert single &proposals automatically";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
label= "Show only proposals visible in the invocation conte&xt";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, 0);
// label= "Show only proposals with &matching cases";
// addCheckBox(contentAssistComposite, label, ContentAssistPreference.CASE_SENSITIVITY, 0);
label= "Present proposals in a&lphabetical order";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
label= "&Enable auto activation";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION, 0);
label= "Automatically add &import instead of qualified name";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.ADD_IMPORT, 0);
label= "Auto activation dela&y:";
addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0);
label= "Auto activation &triggers for Java:";
addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVA, 25, 0);
label= "Auto activation triggers for &JavaDoc:";
addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, 25, 0);
label= "&Background for completion proposals:";
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0);
label= "&Foreground for completion proposals:";
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0);
label= "Bac&kground for method parameters:";
addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_BACKGROUND, 0);
label= "Fo®round for method parameters:";
addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0);
return contentAssistComposite;
}
/*
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
fOverlayStore.load();
fOverlayStore.start();
TabFolder folder= new TabFolder(parent, SWT.NONE);
folder.setLayout(new TabFolderLayout());
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
TabItem item= new TabItem(folder, SWT.NONE);
item.setText("&General");
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
item.setControl(createBehaviorPage(folder));
item= new TabItem(folder, SWT.NONE);
item.setText("&Colors");
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
item.setControl(createColorPage(folder));
item= new TabItem(folder, SWT.NONE);
item.setText("Code A&ssist");
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
item.setControl(createContentAssistPage(folder));
initialize();
return folder;
}
private void initialize() {
fFontEditor.setPreferenceStore(getPreferenceStore());
fFontEditor.setPreferencePage(this);
fFontEditor.load();
initializeFields();
for (int i= 0; i < fListModel.length; i++)
fList.add(fListModel[i][0]);
fList.getDisplay().asyncExec(new Runnable() {
public void run() {
fList.select(0);
handleListSelection();
}
});
}
private void initializeFields() {
Iterator e= fColorButtons.keySet().iterator();
while (e.hasNext()) {
ColorEditor c= (ColorEditor) e.next();
String key= (String) fColorButtons.get(c);
RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
c.setColorValue(rgb);
}
e= fCheckBoxes.keySet().iterator();
while (e.hasNext()) {
Button b= (Button) e.next();
String key= (String) fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key));
}
e= fTextFields.keySet().iterator();
while (e.hasNext()) {
Text t= (Text) e.next();
String key= (String) fTextFields.get(t);
t.setText(fOverlayStore.getString(key));
}
}
/*
* @see PreferencePage#performOk()
*/
public boolean performOk() {
fFontEditor.store();
fOverlayStore.propagate();
return true;
}
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
fFontEditor.loadDefault();
fOverlayStore.loadDefaults();
initializeFields();
handleListSelection();
super.performDefaults();
fPreviewViewer.invalidateTextPresentation();
}
/*
* @see DialogPage#dispose()
*/
public void dispose() {
if (fJavaTextTools != null) {
fJavaTextTools= null;
}
fFontEditor.setPreferencePage(null);
fFontEditor.setPreferenceStore(null);
if (fOverlayStore != null) {
fOverlayStore.stop();
fOverlayStore= null;
}
super.dispose();
}
private Control addColorButton(Composite parent, String label, String key, int indentation) {
Composite composite= new Composite(parent, SWT.NONE);
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 2;
composite.setLayoutData(gd);
GridLayout layout= new GridLayout();
layout.numColumns= 2;
layout.marginWidth= 0;
layout.marginHeight= 0;
composite.setLayout(layout);
Label labelControl= new Label(composite, SWT.NONE);
labelControl.setText(label);
gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent= indentation;
labelControl.setLayoutData(gd);
ColorEditor editor= new ColorEditor(composite);
Button button= editor.getButton();
button.setData(editor);
gd= new GridData();
gd.horizontalAlignment= GridData.END;
button.setLayoutData(gd);
button.addSelectionListener(fColorButtonListener);
fColorButtons.put(editor, key);
return composite;
}
private Button addCheckBox(Composite parent, String label, String key, int indentation) {
Button checkBox= new Button(parent, SWT.CHECK);
checkBox.setText(label);
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent= indentation;
gd.horizontalSpan= 2;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(checkBox, key);
return checkBox;
}
private void addTextField(Composite parent, String label, String key, int textLimit, int indentation) {
Label labelControl= new Label(parent, SWT.NONE);
labelControl.setText(label);
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent= indentation;
labelControl.setLayoutData(gd);
Text textControl= new Text(parent, SWT.BORDER | SWT.SINGLE);
gd= new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
gd.horizontalAlignment= GridData.END;
textControl.setLayoutData(gd);
textControl.setTextLimit(textLimit);
textControl.addModifyListener(fTextFieldListener);
fTextFields.put(textControl, key);
}
private void addTextFontEditor(Composite parent, String label, String key) {
Composite editorComposite= new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout();
layout.numColumns= 3;
editorComposite.setLayout(layout);
fFontEditor= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
fFontEditor.setChangeButtonText("C&hange...");
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 2;
editorComposite.setLayoutData(gd);
}
private String loadPreviewContentFromFile(String filename) {
String line;
String separator= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer buffer= new StringBuffer(512);
BufferedReader reader= null;
try {
reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
while ((line= reader.readLine()) != null) {
buffer.append(line);
buffer.append(separator);
}
} catch (IOException io) {
JavaPlugin.log(io);
} finally {
if (reader != null) {
try { reader.close(); } catch (IOException e) {}
}
}
return buffer.toString();
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/test
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.ui.tests.core.AddUnimplementedMethodsTest;
import org.eclipse.jdt.ui.tests.core.ImportOrganizeTest;
import org.eclipse.jdt.ui.tests.core.JavaModelUtilTest;
import org.eclipse.jdt.ui.tests.core.TextBufferTest;
import org.eclipse.jdt.ui.tests.core.TypeHierarchyTest;
import org.eclipse.jdt.ui.tests.core.TypeInfoTest;
/**
* Test all areas of the UI.
*/
public class AutomatedSuite extends TestSuite {
/**
* Returns the suite. This is required to
* use the JUnit Launcher.
*/
public static Test suite() {
return new AutomatedSuite();
}
/**
* Construct the test suite.
*/
public AutomatedSuite() {
addTest(TypeInfoTest.suite());
addTest(AddUnimplementedMethodsTest.suite());
addTest(ImportOrganizeTest.suite());
addTest(JavaModelUtilTest.suite());
addTest(TextBufferTest.suite());
addTest(TypeHierarchyTest.suite());
}
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), AutomatedSuite.class, args);
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddUnimplementedMethodsTest.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests.core;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportDeclaration;
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.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.internal.corext.codemanipulation.AddUnimplementedMethodsOperation;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
public class AddUnimplementedMethodsTest extends TestCase {
private IJavaProject fJavaProject;
private IPackageFragment fPackage;
private IType fClassA, fInterfaceB, fClassC, fClassD, fInterfaceE;
public AddUnimplementedMethodsTest(String name) {
super(name);
}
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), AddUnimplementedMethodsTest.class, args);
}
public static Test suite() {
TestSuite suite= new TestSuite(AddUnimplementedMethodsTest.class.getName());
suite.addTest(new AddUnimplementedMethodsTest("test1"));
suite.addTest(new AddUnimplementedMethodsTest("test2"));
suite.addTest(new AddUnimplementedMethodsTest("test3"));
suite.addTest(new AddUnimplementedMethodsTest("test4"));
return suite;
}
/**
* Creates a new test Java project.
*/
protected void setUp() throws Exception {
fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin");
assertNotNull(JavaProjectHelper.addRTJar(fJavaProject));
IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src");
fPackage= root.createPackageFragment("ibm.util", true, null);
ICompilationUnit cu= fPackage.getCompilationUnit("A.java");
fClassA= cu.createType("public abstract class A {\n}\n", null, true, null);
fClassA.createMethod("public abstract void a();\n", null, true, null);
fClassA.createMethod("public abstract void b(java.util.Vector v);\n", null, true, null);
cu= fPackage.getCompilationUnit("B.java");
fInterfaceB= cu.createType("public interface B {\n}\n", null, true, null);
fInterfaceB.createMethod("void c(java.util.Hashtable h);\n", null, true, null);
cu= fPackage.getCompilationUnit("C.java");
fClassC= cu.createType("public abstract class C {\n}\n", null, true, null);
fClassC.createMethod("public void c(java.util.Hashtable h) {\n}\n", null, true, null);
fClassC.createMethod("public abstract java.util.Enumeration d(java.util.Hashtable h) {\n}\n", null, true, null);
cu= fPackage.getCompilationUnit("D.java");
fClassD= cu.createType("public abstract class D extends C {\n}\n", null, true, null);
fClassD.createMethod("public abstract void c(java.util.Hashtable h);\n", null, true, null);
cu= fPackage.getCompilationUnit("E.java");
fInterfaceE= cu.createType("public interface E {\n}\n", null, true, null);
fInterfaceE.createMethod("void c(java.util.Hashtable h);\n", null, true, null);
fInterfaceE.createMethod("void e() throws java.util.NoSuchElementException;\n", null, true, null);
}
/**
* Removes the test java project.
*/
protected void tearDown () throws Exception {
JavaProjectHelper.delete(fJavaProject);
fJavaProject= null;
fPackage= null;
fClassA= null;
fInterfaceB= null;
fClassC= null;
fClassD= null;
fInterfaceE= null;
}
/*
* basic test: extend an abstract class and an interface
*/
public void test1() throws Exception {
ICompilationUnit cu= fPackage.getCompilationUnit("Test1.java");
IType testClass= cu.createType("public class Test1 extends A implements B {\n}\n", null, true, null);
AddUnimplementedMethodsOperation op= new AddUnimplementedMethodsOperation(testClass, new CodeGenerationSettings(), null, true);
op.run(new NullProgressMonitor());
IMethod[] methods= testClass.getMethods();
checkMethods(new String[] { "a", "b", "c" }, methods);
IImportDeclaration[] imports= cu.getImports();
checkImports(new String[] { "java.util.Hashtable", "java.util.Vector" }, imports);
}
/*
* method c() of interface B is already implemented by class C
*/
public void test2() throws Exception {
ICompilationUnit cu= fPackage.getCompilationUnit("Test2.java");
IType testClass= cu.createType("public class Test2 extends C implements B {\n}\n", null, true, null);
AddUnimplementedMethodsOperation op= new AddUnimplementedMethodsOperation(testClass, new CodeGenerationSettings(), null, true);
op.run(new NullProgressMonitor());
IMethod[] methods= testClass.getMethods();
checkMethods(new String[] { "d" }, methods);
IImportDeclaration[] imports= cu.getImports();
checkImports(new String[] { "java.util.Enumeration", "java.util.Hashtable" }, imports);
}
/*
* method c() is implemented in C but made abstract again in class D
*/
public void test3() throws Exception {
ICompilationUnit cu= fPackage.getCompilationUnit("Test3.java");
IType testClass= cu.createType("public class Test3 extends D {\n}\n", null, true, null);
AddUnimplementedMethodsOperation op= new AddUnimplementedMethodsOperation(testClass, new CodeGenerationSettings(), null, true);
op.run(new NullProgressMonitor());
IMethod[] methods= testClass.getMethods();
checkMethods(new String[] { "c", "d" }, methods);
IImportDeclaration[] imports= cu.getImports();
checkImports(new String[] { "java.util.Hashtable", "java.util.Enumeration" }, imports);
}
/*
* method c() defined in both interfaces B and E
*/
public void test4() throws Exception {
ICompilationUnit cu= fPackage.getCompilationUnit("Test4.java");
IType testClass= cu.createType("public class Test4 implements B, E {\n}\n", null, true, null);
AddUnimplementedMethodsOperation op= new AddUnimplementedMethodsOperation(testClass, new CodeGenerationSettings(), null, true);
op.run(new NullProgressMonitor());
IMethod[] methods= testClass.getMethods();
checkMethods(new String[] { "c", "e" }, methods);
IImportDeclaration[] imports= cu.getImports();
}
private void checkMethods(String[] expected, IMethod[] methods) {
int nMethods= methods.length;
int nExpected= expected.length;
assertTrue("" + nExpected + " methods expected, is " + nMethods, nMethods == nExpected);
for (int i= 0; i < nExpected; i++) {
String methName= expected[i];
assertTrue("method " + methName + " expected", nameContained(methName, methods));
}
}
private void checkImports(String[] expected, IImportDeclaration[] imports) {
int nImports= imports.length;
int nExpected= expected.length;
assertTrue("" + nExpected + " imports expected, is " + nImports, nImports == nExpected);
for (int i= 0; i < nExpected; i++) {
String impName= expected[i];
assertTrue("import " + impName + " expected", nameContained(impName, imports));
}
}
private boolean nameContained(String methName, IJavaElement[] methods) {
for (int i= 0; i < methods.length; i++) {
if (methods[i].getElementName().equals(methName)) {
return true;
}
}
return false;
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AllTypesCacheTest.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests.core;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.ZipFile;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.JavaTestPlugin;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
public class JavaModelUtilTest extends TestCase {
private IJavaProject fJProject1;
private IJavaProject fJProject2;
private static final IPath LIB= new Path("testresources/mylib.jar");
public JavaModelUtilTest(String name) {
super(name);
}
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), JavaModelUtilTest.class, args);
}
public static Test suite() {
return new TestSuite(JavaModelUtilTest.class);
}
protected void setUp() throws Exception {
fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
fJProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin");
IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);
assertTrue("jdk not found", jdk != null);
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC);
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
ZipFile zipfile= new ZipFile(junitSrcArchive);
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", zipfile);
File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(LIB);
assertTrue("lib not found", junitSrcArchive != null && junitSrcArchive.exists());
JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(mylibJar.getPath()), null, null);
JavaProjectHelper.addVariableEntry(fJProject2, new Path("JRE_LIB_TEST"), null, null);
IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJProject2, "src");
IPackageFragment pack1= root1.createPackageFragment("pack1", true, null);
ICompilationUnit cu1= pack1.getCompilationUnit("ReqProjType.java");
IType type1= cu1.createType("public class ReqProjType { static class Inner { static class InnerInner {} }\n}\n", null, true, null);
JavaProjectHelper.addRequiredProject(fJProject1, fJProject2);
}
protected void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject1);
JavaProjectHelper.delete(fJProject2);
}
private void assertElementName(String name, IJavaElement elem, int type) {
assertNotNull(name, elem);
assertEquals(name + "-name", name, elem.getElementName());
assertTrue(name + "-type", type == elem.getElementType());
}
public void testFindType() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.extensions.ExceptionTestCase");
assertElementName("ExceptionTestCase", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "junit.samples.money.IMoney");
assertElementName("IMoney", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "junit.tests.TestCaseTest.TornDown");
assertElementName("TornDown", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib.Foo");
assertElementName("Foo", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib.Foo.FooInner");
assertElementName("FooInner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib.Foo.FooInner.FooInnerInner");
assertElementName("FooInnerInner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1.ReqProjType");
assertElementName("ReqProjType", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1.ReqProjType.Inner");
assertElementName("Inner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1.ReqProjType.Inner.InnerInner");
assertElementName("InnerInner", type, IJavaElement.TYPE);
}
public void testFindType2() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.extensions", "ExceptionTestCase");
assertElementName("ExceptionTestCase", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "junit.samples.money" , "IMoney");
assertElementName("IMoney", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "junit.tests", "TestCaseTest.TornDown");
assertElementName("TornDown", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib" , "Foo");
assertElementName("Foo", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib", "Foo.FooInner");
assertElementName("FooInner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "mylib", "Foo.FooInner.FooInnerInner");
assertElementName("FooInnerInner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1", "ReqProjType");
assertElementName("ReqProjType", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1", "ReqProjType.Inner");
assertElementName("Inner", type, IJavaElement.TYPE);
type= JavaModelUtil.findType(fJProject1, "pack1", "ReqProjType.Inner.InnerInner");
assertElementName("InnerInner", type, IJavaElement.TYPE);
}
public void testFindTypeContainer() throws Exception {
IJavaElement elem= JavaModelUtil.findTypeContainer(fJProject1, "junit.extensions");
assertElementName("junit.extensions", elem, IJavaElement.PACKAGE_FRAGMENT);
elem= JavaModelUtil.findTypeContainer(fJProject1, "junit.tests.TestCaseTest");
assertElementName("TestCaseTest", elem, IJavaElement.TYPE);
elem= JavaModelUtil.findTypeContainer(fJProject1, "mylib" );
assertElementName("mylib", elem, IJavaElement.PACKAGE_FRAGMENT);
elem= JavaModelUtil.findTypeContainer(fJProject1, "mylib.Foo");
assertElementName("Foo", elem, IJavaElement.TYPE);
elem= JavaModelUtil.findTypeContainer(fJProject1, "mylib.Foo.FooInner");
assertElementName("FooInner", elem, IJavaElement.TYPE);
elem= JavaModelUtil.findTypeContainer(fJProject1, "pack1");
assertElementName("pack1", elem, IJavaElement.PACKAGE_FRAGMENT);
elem= JavaModelUtil.findTypeContainer(fJProject1, "pack1.ReqProjType");
assertElementName("ReqProjType", elem, IJavaElement.TYPE);
elem= JavaModelUtil.findTypeContainer(fJProject1, "pack1.ReqProjType.Inner");
assertElementName("Inner", elem, IJavaElement.TYPE);
}
public void testFindTypeInCompilationUnit() throws Exception {
ICompilationUnit cu= (ICompilationUnit) fJProject1.findElement(new Path("junit/tests/TestCaseTest.java"));
assertElementName("TestCaseTest.java", cu, IJavaElement.COMPILATION_UNIT);
IType type= JavaModelUtil.findTypeInCompilationUnit(cu, "TestCaseTest");
assertElementName("TestCaseTest", type, IJavaElement.TYPE);
type= JavaModelUtil.findTypeInCompilationUnit(cu, "TestCaseTest.TornDown");
assertElementName("TornDown", type, IJavaElement.TYPE);
cu= (ICompilationUnit) fJProject1.findElement(new Path("pack1/ReqProjType.java"));
assertElementName("ReqProjType.java", cu, IJavaElement.COMPILATION_UNIT);
type= JavaModelUtil.findTypeInCompilationUnit(cu, "ReqProjType");
assertElementName("ReqProjType", type, IJavaElement.TYPE);
type= JavaModelUtil.findTypeInCompilationUnit(cu, "ReqProjType.Inner");
assertElementName("Inner", type, IJavaElement.TYPE);
type= JavaModelUtil.findTypeInCompilationUnit(cu, "ReqProjType.Inner.InnerInner");
assertElementName("InnerInner", type, IJavaElement.TYPE);
}
public void testFindMemberInCompilationUnit() throws Exception {
ICompilationUnit cu= (ICompilationUnit) fJProject1.findElement(new Path("junit/tests/TestCaseTest.java"));
assertElementName("TestCaseTest.java", cu, IJavaElement.COMPILATION_UNIT);
ArrayList children= new ArrayList();
IType type= JavaModelUtil.findTypeInCompilationUnit(cu, "TestCaseTest");
assertElementName("TestCaseTest", type, IJavaElement.TYPE);
children.addAll(Arrays.asList(type.getChildren()));
type= JavaModelUtil.findTypeInCompilationUnit(cu, "TestCaseTest.TornDown");
assertElementName("TornDown", type, IJavaElement.TYPE);
children.addAll(Arrays.asList(type.getChildren()));
assertTrue("a", children.size() == 19);
for (int i= 0; i < children.size(); i++) {
Object curr= children.get(i);
assertTrue("b", curr instanceof IMember);
IMember member= JavaModelUtil.findMemberInCompilationUnit(cu, (IMember) curr);
assertEquals("b-" + i, curr, member);
}
}
private void assertClasspathEntry(String name, IJavaElement elem, IPath path, int type) throws Exception {
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(elem);
assertNotNull(name + "-noroot", root);
IClasspathEntry entry= JavaModelUtil.getRawClasspathEntry(root);
assertNotNull(name + "-nocp", entry);
assertEquals(name + "-wrongpath", entry.getPath(), path);
assertTrue(name + "-wrongtype", type == entry.getEntryKind());
}
public void testGetRawClasspathEntry() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.extensions.ExceptionTestCase");
assertElementName("ExceptionTestCase", type, IJavaElement.TYPE);
IPath path= fJProject1.getProject().getFullPath().append("src");
assertClasspathEntry("ExceptionTestCase", type, path, IClasspathEntry.CPE_SOURCE);
type= JavaModelUtil.findType(fJProject1, "mylib.Foo");
assertElementName("Foo", type, IJavaElement.TYPE);
path= fJProject1.getProject().getFullPath().append(LIB.lastSegment());
assertClasspathEntry("Foo", type, path, IClasspathEntry.CPE_LIBRARY);
type= JavaModelUtil.findType(fJProject1, "java.lang.Object");
assertElementName("Object", type, IJavaElement.TYPE);
path= new Path("JRE_LIB_TEST");
assertClasspathEntry("Object", type, path, IClasspathEntry.CPE_VARIABLE);
type= JavaModelUtil.findType(fJProject1, "pack1.ReqProjType");
assertElementName("ReqProjType", type, IJavaElement.TYPE);
path= fJProject2.getProject().getFullPath().append("src");
assertClasspathEntry("ReqProjType", type, path, IClasspathEntry.CPE_SOURCE);
}
public void testIsOnBuildPath() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.extensions.ExceptionTestCase");
assertElementName("ExceptionTestCase", type, IJavaElement.TYPE);
assertTrue("ExceptionTestCase-bp1", JavaModelUtil.isOnBuildPath(fJProject1, type));
assertTrue("ExceptionTestCase-bp2", !JavaModelUtil.isOnBuildPath(fJProject2, type));
type= JavaModelUtil.findType(fJProject1, "java.lang.Object");
assertElementName("Object", type, IJavaElement.TYPE);
assertTrue("Object-bp1", JavaModelUtil.isOnBuildPath(fJProject1, type));
// relies on shared objects for library entries
assertTrue("Object-bp2", JavaModelUtil.isOnBuildPath(fJProject2, type));
type= JavaModelUtil.findType(fJProject1, "pack1.ReqProjType");
assertElementName("ReqProjType", type, IJavaElement.TYPE);
assertTrue("ReqProjType-bp1", JavaModelUtil.isOnBuildPath(fJProject1, type));
// relies on shared objects for project entries
assertTrue("ReqProjType-bp2", JavaModelUtil.isOnBuildPath(fJProject2, type));
}
private void assertFindMethod(String methName, String[] paramTypeNames, boolean isConstructor, IType type) throws Exception {
String[] sig= new String[paramTypeNames.length];
for (int i= 0; i < paramTypeNames.length; i++) {
// create as unresolved
String name= Signature.getSimpleName(paramTypeNames[i]);
sig[i]= Signature.createTypeSignature(name, false);
assertNotNull(methName + "-ts1" + i, sig[i]);
}
IMethod meth= JavaModelUtil.findMethod(methName, sig, isConstructor, type);
assertElementName(methName, meth, IJavaElement.METHOD);
assertTrue("methName-nparam1", meth.getParameterTypes().length == paramTypeNames.length);
for (int i= 0; i < paramTypeNames.length; i++) {
// create as resolved
sig[i]= Signature.createTypeSignature(paramTypeNames[i], true);
assertNotNull(methName + "-ts2" + i, sig[i]);
}
meth= JavaModelUtil.findMethod(methName, sig, isConstructor, type);
assertElementName(methName, meth, IJavaElement.METHOD);
assertTrue("methName-nparam2", meth.getParameterTypes().length == paramTypeNames.length);
}
public void testFindMethod() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.framework.Assert");
assertElementName("Assert", type, IJavaElement.TYPE);
assertFindMethod("assertNotNull", new String[] { "java.lang.Object" }, false, type);
assertFindMethod("assertNotNull", new String[] { "java.lang.String", "java.lang.Object" }, false, type);
assertFindMethod("assertEquals", new String[] { "java.lang.String", "double", "double", "double" }, false, type);
assertFindMethod("assertEquals", new String[] { "java.lang.String", "long", "long" }, false, type);
assertFindMethod("Assert", new String[0], true, type);
type= JavaModelUtil.findType(fJProject1, "junit.samples.money.MoneyTest");
assertElementName("MoneyTest", type, IJavaElement.TYPE);
assertFindMethod("main", new String[] { "java.lang.String[]" }, false, type);
assertFindMethod("setUp", new String[0] , false, type);
assertFindMethod("MoneyTest", new String[] { "java.lang.String" } , true, type);
}
private void assertFindMethodInHierarchy(String methName, String[] paramTypeNames, boolean isConstructor, IType type, String declaringTypeName) throws Exception {
ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null);
String[] sig= new String[paramTypeNames.length];
for (int i= 0; i < paramTypeNames.length; i++) {
// create as unresolved
String name= Signature.getSimpleName(paramTypeNames[i]);
sig[i]= Signature.createTypeSignature(name, false);
assertNotNull(methName + "-ts1" + i, sig[i]);
}
IMethod meth= JavaModelUtil.findMethodDeclarationInHierarchy(hierarchy, type, methName, sig, isConstructor);
assertElementName(methName, meth, IJavaElement.METHOD);
assertTrue("methName-nparam1", meth.getParameterTypes().length == paramTypeNames.length);
assertEquals("methName-decltype", declaringTypeName, JavaModelUtil.getFullyQualifiedName(meth.getDeclaringType()));
for (int i= 0; i < paramTypeNames.length; i++) {
// create as resolved
sig[i]= Signature.createTypeSignature(paramTypeNames[i], true);
assertNotNull(methName + "-ts2" + i, sig[i]);
}
meth= JavaModelUtil.findMethodDeclarationInHierarchy(hierarchy, type, methName, sig, isConstructor);
assertElementName(methName, meth, IJavaElement.METHOD);
assertTrue("methName-nparam2", meth.getParameterTypes().length == paramTypeNames.length);
assertEquals("methName-decltype", declaringTypeName, JavaModelUtil.getFullyQualifiedName(meth.getDeclaringType()));
}
public void testFindMethodInHierarchy() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.extensions.TestSetup");
assertElementName("TestSetup", type, IJavaElement.TYPE);
assertFindMethodInHierarchy("run", new String[] { "junit.framework.TestResult" }, false, type, "junit.framework.Test");
assertFindMethodInHierarchy("toString", new String[] {} , false, type, "java.lang.Object");
}
public void testHasMainMethod() throws Exception {
IType type= JavaModelUtil.findType(fJProject1, "junit.samples.money.MoneyTest");
assertElementName("MoneyTest", type, IJavaElement.TYPE);
assertTrue("MoneyTest-nomain", JavaModelUtil.hasMainMethod(type));
type= JavaModelUtil.findType(fJProject1, "junit.framework.TestResult");
assertElementName("TestResult", type, IJavaElement.TYPE);
assertTrue("TestResult-hasmain", !JavaModelUtil.hasMainMethod(type));
type= JavaModelUtil.findType(fJProject1, "junit.samples.VectorTest");
assertElementName("VectorTest", type, IJavaElement.TYPE);
assertTrue("VectorTest-nomain", JavaModelUtil.hasMainMethod(type));
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeHierarchyTest.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests.core;
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.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
public class TypeHierarchyTest extends TestCase {
private IJavaProject fJavaProject1;
private IJavaProject fJavaProject2;
public TypeHierarchyTest(String name) {
super(name);
}
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), TypeHierarchyTest.class, args);
}
public static Test suite() {
return new TestSuite(TypeHierarchyTest.class);
}
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 {\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 {\n}\n", null, true, null);
ITypeHierarchy hierarchy= type2.newSupertypeHierarchy(null);
IType[] allTypes= hierarchy.getAllTypes();
assertTrue("Should contain 3 types, contains: " + allTypes.length, allTypes.length == 3);
IType type= JavaModelUtil.findType(fJavaProject2, "pack1.A");
assertTrue("Type not found", type != null);
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests.core;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipFile;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.ITypeNameRequestor;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.JavaTestPlugin;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.internal.ui.util.TypeInfo;
import org.eclipse.jdt.internal.ui.util.TypeInfoRequestor;
public class TypeInfoTest extends TestCase {
private IJavaProject fJProject1;
private IJavaProject fJProject2;
public TypeInfoTest(String name) {
super(name);
}
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), TypeInfoTest.class, args);
}
public static Test suite() {
return new TestSuite(TypeInfoTest.class);
}
protected void setUp() throws Exception {
fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
assertNotNull("jre is null", JavaProjectHelper.addRTJar(fJProject1));
fJProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin");
assertNotNull("jre is null", JavaProjectHelper.addRTJar(fJProject2));
// add Junit source to project 2
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC);
assertTrue("Junit source", junitSrcArchive != null && junitSrcArchive.exists());
ZipFile zipfile= new ZipFile(junitSrcArchive);
JavaProjectHelper.addSourceContainerWithImport(fJProject2, "src", zipfile);
}
protected void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject1);
JavaProjectHelper.delete(fJProject2);
}
public void test1() throws Exception {
// source folder
IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= root1.createPackageFragment("com.oti", true, null);
ICompilationUnit cu1= pack1.getCompilationUnit("V.java");
IType type1= cu1.createType("public class V {\n static class VInner {\n}\n}\n", null, true, null);
// proj1 has proj2 as prerequisit
JavaProjectHelper.addRequiredProject(fJProject1, fJProject2);
// internal jar
//IPackageFragmentRoot root2= JavaProjectHelper.addLibraryWithImport(fJProject1, JARFILE, null, null);
ArrayList result= new ArrayList();
IJavaElement[] elements= new IJavaElement[] { fJProject1 };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
ITypeNameRequestor requestor= new TypeInfoRequestor(result);
SearchEngine engine= new SearchEngine();
engine.searchAllTypeNames(
fJProject1.getJavaModel().getWorkspace(),
null,
new char[] {'V'},
IJavaSearchConstants.PREFIX_MATCH,
IJavaSearchConstants.CASE_INSENSITIVE,
IJavaSearchConstants.TYPE,
scope,
requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null);
findTypeRef(result, "com.oti.V");
findTypeRef(result, "com.oti.V.VInner");
findTypeRef(result, "java.lang.VerifyError");
findTypeRef(result, "java.lang.Void");
findTypeRef(result, "java.util.Vector");
findTypeRef(result, "junit.samples.VectorTest");
for (int i= 0; i < result.size(); i++) {
TypeInfo ref= (TypeInfo) result.get(i);
//System.out.println(ref.getTypeName());
IType resolvedType= ref.resolveType(scope);
if (resolvedType == null) {
assertTrue("Could not be resolved: " + ref.toString(), false);
}
}
assertTrue("Should find 9 elements, is " + result.size(), result.size() == 9);
}
private void findTypeRef(List refs, String fullname) {
for (int i= 0; i <refs.size(); i++) {
TypeInfo curr= (TypeInfo) refs.get(i);
if (fullname.equals(curr.getFullyQualifiedName())) {
return;
}
}
assertTrue("Type not found: " + fullname, false);
}
public void test2() throws Exception {
ArrayList result= new ArrayList();
IJavaProject[] elements= new IJavaProject[] { fJProject2 };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
ITypeNameRequestor requestor= new TypeInfoRequestor(result);
SearchEngine engine= new SearchEngine();
engine.searchAllTypeNames(
fJProject1.getJavaModel().getWorkspace(),
null,
new char[] {'T'},
IJavaSearchConstants.PREFIX_MATCH,
IJavaSearchConstants.CASE_INSENSITIVE,
IJavaSearchConstants.TYPE,
scope,
requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null);
findTypeRef(result, "junit.extensions.TestDecorator");
findTypeRef(result, "junit.framework.Test");
findTypeRef(result, "junit.framework.TestListener");
findTypeRef(result, "junit.tests.TestCaseTest.TornDown");
assertTrue("Should find 37 elements, is " + result.size(), result.size() == 37);
//System.out.println("Elements found: " + result.size());
for (int i= 0; i < result.size(); i++) {
TypeInfo ref= (TypeInfo) result.get(i);
//System.out.println(ref.getTypeName());
IType resolvedType= ref.resolveType(scope);
if (resolvedType == null) {
assertTrue("Could not be resolved: " + ref.toString(), false);
}
}
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui.tests.dialogs;
import java.util.ArrayList;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestPluginLauncher;
import org.eclipse.jdt.testplugin.util.DialogCheck;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.JavaElementContentProvider;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jdt.ui.tests.core.AddUnimplementedMethodsTest;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.MultiElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.OpenTypeSelectionDialog;
import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine;
import org.eclipse.jdt.internal.ui.util.TypeInfo;
import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementSorter;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
public class DialogsTest extends TestCase {
private static final String PROJECT_NAME = "DummyProject";
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), DialogsTest.class, args);
}
public static Test suite() {
TestSuite suite= new TestSuite(DialogsTest.class.getName());
// suite.addTest(new DialogsTest("testElementListSelectionDialog2"));
suite.addTest(new DialogsTest("testElementListSelectionDialog"));
suite.addTest(new DialogsTest("testMultiElementSelectionDialog"));
suite.addTest(new DialogsTest("testTwoPaneSelectionDialog"));
suite.addTest(new DialogsTest("testElementTreeSelectionDialog"));
suite.addTest(new DialogsTest("testElementListSelectionDialog"));
return suite;
}
public DialogsTest(String name) {
super(name);
}
private Shell getShell() {
return DialogCheck.getShell();
}
private IWorkbench getWorkbench() {
return WorkbenchPlugin.getDefault().getWorkbench();
}
public void testTwoPaneSelectionDialog() throws Exception {
IJavaProject jproject= JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
JavaProjectHelper.addSourceContainer(jproject, "src1");
JavaProjectHelper.addRTJar(jproject);
IProject project= jproject.getProject();
OpenTypeSelectionDialog dialog= new OpenTypeSelectionDialog(getShell(), new ProgressMonitorDialog(getShell()),
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_TYPES);
dialog.setTitle(JavaUIMessages.getString("OpenTypeAction.dialogTitle")); //$NON-NLS-1$
dialog.setMessage(JavaUIMessages.getString("OpenTypeAction.dialogMessage")); //$NON-NLS-1$
DialogCheck.assertDialog(dialog, this);
JavaProjectHelper.delete(jproject);
}
private TypeInfo[] getRefs(ArrayList list, int off, int len) {
TypeInfo[] res= new TypeInfo[len];
for (int i= 0; i < len; i++) {
res[i]= (TypeInfo) list.get(off + i);
}
return res;
}
public void testMultiElementSelectionDialog() throws Exception {
IJavaProject jproject= JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
JavaProjectHelper.addSourceContainer(jproject, "src1");
JavaProjectHelper.addRTJar(jproject);
ILabelProvider labelProvider= new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLYQUALIFIED);
ArrayList list= new ArrayList(200);
IProject project= jproject.getProject();
IJavaSearchScope searchScope= SearchEngine.createJavaSearchScope(new IJavaElement[] { jproject });
AllTypesSearchEngine searchEngine= new AllTypesSearchEngine(project.getWorkspace());
searchEngine.searchTypes(list, searchScope, IJavaElementSearchConstants.CONSIDER_TYPES, null);
MultiElementListSelectionDialog dialog= new MultiElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle("Title"); //$NON-NLS-1$
dialog.setMessage("Description:"); //$NON-NLS-1$
assertTrue(list.size() > 15);
TypeInfo[][] refs= new TypeInfo[][] { getRefs(list, 0, 3), getRefs(list, 4, 6), getRefs(list, 10, 5) };
dialog.setElements(refs);
dialog.setInitialSelections(new Object[refs.length]);
DialogCheck.assertDialog(dialog, this);
JavaProjectHelper.delete(jproject);
}
public void testElementTreeSelectionDialog() throws Exception {
IJavaProject jproject= JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
JavaProjectHelper.addSourceContainer(jproject, "src1");
Object initSelection= JavaProjectHelper.addSourceContainer(jproject, "src2");
IJavaProject jproject2= JavaProjectHelper.createJavaProject("Project2", "bin");
JavaProjectHelper.addSourceContainer(jproject2, "src1");
JavaProjectHelper.addSourceContainer(jproject2, "src2");
JavaElementContentProvider provider= new JavaElementContentProvider();
ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider);
dialog.setSorter(new JavaElementSorter());
dialog.setTitle(NewWizardMessages.getString("ContainerPage.ChooseSourceContainerDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("ContainerPage.ChooseSourceContainerDialog.description")); //$NON-NLS-1$
dialog.setInput(jproject.getJavaModel());
dialog.setInitialSelection(initSelection);
DialogCheck.assertDialog(dialog, this);
JavaProjectHelper.delete(jproject);
JavaProjectHelper.delete(jproject2);
}
public void testElementListSelectionDialog() throws Exception {
IJavaProject jproject= JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
IPackageFragmentRoot root= JavaProjectHelper.addRTJar(jproject);
assertTrue(root != null);
Object[] elements= root.getChildren();
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
dialog.setIgnoreCase(false);
dialog.setTitle(NewWizardMessages.getString("TypePage.ChoosePackageDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.description")); //$NON-NLS-1$
dialog.setEmptyListMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.empty")); //$NON-NLS-1$
dialog.setElements(elements);
DialogCheck.assertDialog(dialog, this);
JavaProjectHelper.delete(jproject);
}
private static class TestLabelProvider extends LabelProvider {
public Image getImage(Object element) {
return null;
}
public String getText(Object element) {
Integer i= (Integer) element;
return "e-" + i.toString();
}
}
public void testElementListSelectionDialog2() throws Exception {
Object[] elements= new Integer[] {
new Integer(0),
new Integer(1),
new Integer(2),
new Integer(7),
new Integer(12),
new Integer(42)
};
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new TestLabelProvider());
dialog.setIgnoreCase(false);
dialog.setTitle(NewWizardMessages.getString("TypePage.ChoosePackageDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.description")); //$NON-NLS-1$
dialog.setEmptyListMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.empty")); //$NON-NLS-1$
dialog.setElements(elements);
dialog.setInitialSelections(new Object[] {new Integer(7)});
DialogCheck.assertDialog(dialog, this);
Object[] results= dialog.getResult();
assertTrue(results.length == 1);
assertEquals(new Integer(7), results[0]);
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/core
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/core
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
extension/org/eclipse/jdt/internal/corext/util/AllTypesCache.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersInputPage.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizardPage2.java
| |
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenTypeAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.actions;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.dialogs.OpenTypeSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
public class OpenTypeAction extends Action implements IWorkbenchWindowActionDelegate {
public OpenTypeAction() {
super();
setText(JavaUIMessages.getString("OpenTypeAction.label")); //$NON-NLS-1$
setDescription(JavaUIMessages.getString("OpenTypeAction.description")); //$NON-NLS-1$
setToolTipText(JavaUIMessages.getString("OpenTypeAction.tooltip")); //$NON-NLS-1$
setImageDescriptor(JavaPluginImages.DESC_TOOL_OPENTYPE);
}
public void run() {
Shell parent= JavaPlugin.getActiveWorkbenchShell();
OpenTypeSelectionDialog dialog= new OpenTypeSelectionDialog(parent, new ProgressMonitorDialog(parent),
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_TYPES);
dialog.setMatchEmptyString(false);
dialog.setTitle(JavaUIMessages.getString("OpenTypeAction.dialogTitle")); //$NON-NLS-1$
dialog.setMessage(JavaUIMessages.getString("OpenTypeAction.dialogMessage")); //$NON-NLS-1$
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
Object[] types= dialog.getResult();
if (types != null && types.length > 0) {
IType type= (IType)types[0];
if (dialog.showInTypeHierarchy()) {
OpenTypeHierarchyUtil.open(new IType[] { type }, JavaPlugin.getActiveWorkbenchWindow());
} else {
try {
IEditorPart part= EditorUtility.openInEditor(type, true);
EditorUtility.revealInEditor(part, type);
} catch (CoreException x) {
String title= JavaUIMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("OpenTypeAction.errorMessage"); //$NON-NLS-1$
ExceptionHandler.handle(x, title, message);
}
}
}
}
//---- IWorkbenchWindowActionDelegate ------------------------------------------------
public void run(IAction action) {
run();
}
public void dispose() {
// do nothing.
}
public void init(IWorkbenchWindow window) {
// do nothing.
}
public void selectionChanged(IAction action, ISelection selection) {
// do nothing. Action doesn't depend on selection.
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiTypeSelectionDialog.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.dialogs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine;
import org.eclipse.jdt.internal.ui.util.TypeInfo;
import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* A dialog to select a type from a list of types. The dialog allows
* multiple selections.
*/
public class MultiTypeSelectionDialog extends ElementListSelectionDialog {
private IRunnableContext fRunnableContext;
private IJavaSearchScope fScope;
private int fStyle;
/**
* Constructs an instance of <code>MultiTypeSelectionDialog</code>.
* @param parent the parent shell.
* @param context the context.
* @param scope the java search scope.
* @param style the widget style.
*/
public MultiTypeSelectionDialog(Shell parent, IRunnableContext context,
IJavaSearchScope scope, int style)
{
super(parent, new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_PACKAGE_POSTFIX));
setMultipleSelection(true);
Assert.isNotNull(context);
Assert.isNotNull(scope);
fRunnableContext= context;
fScope= scope;
fStyle= style;
}
/*
* @see Window#open()
*/
public int open() {
AllTypesSearchEngine engine= new AllTypesSearchEngine(JavaPlugin.getWorkspace());
List typesFound= engine.searchTypes(fRunnableContext, fScope, fStyle);
if (typesFound.size() == 0)
return CANCEL;
setFilter("A"); //$NON-NLS-1$
setElements(typesFound.toArray());
return super.open();
}
/*
* @see SelectionStatusDialog#computeResult()
*/
protected void computeResult() {
List selection= Arrays.asList(getSelectedElements()); // XXX inefficient
int size= selection.size();
if (size == 0) {
setResult(null);
return;
}
List result= new ArrayList(size);
if (result != null) {
for (int i= 0; i < size; i++) {
try {
IType type= ((TypeInfo)selection.get(i)).resolveType(fScope);
if (type == null) {
String title= JavaUIMessages.getString("MultiTypeSelectionDialog.dialogTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("MultiTypeSelectionDialog.dialogMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
} else {
result.add(type);
}
} catch (JavaModelException e) {
String title= JavaUIMessages.getString("MultiTypeSelectionDialog.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("MultiTypeSelectionDialog.errorMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
}
}
}
setResult(result);
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/OpenTypeSelectionDialog.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.dialogs;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* A dialog to select a type from a list of types. The selected type will be
* opened in the editor.
*/
public class OpenTypeSelectionDialog extends TypeSelectionDialog {
private static final String SECTION_NAME= "OpenTypeSelectionDialog"; //$NON-NLS-1$
private static final String SHOW_IN_TYPE_HIERARCHY= "showInTypeHierarchy"; //$NON-NLS-1$
private boolean fShowInTypeHierarchy;
/**
* Constructs an instance of <code>OpenTypeSelectionDialog</code>.
* @param parent the parent shell.
* @param context the context.
* @param scope the java search scope.
* @param style the widget style.
*/
public OpenTypeSelectionDialog(Shell parent, IRunnableContext context,
IJavaSearchScope scope, int style)
{
super(parent, context, scope, style);
fShowInTypeHierarchy= getDialogSetting().getBoolean(SHOW_IN_TYPE_HIERARCHY);
}
/**
* @see Windows#configureShell(Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
WorkbenchHelp.setHelp(newShell, new Object[] { IJavaHelpContextIds.OPEN_TYPE_DIALOG });
}
/**
* Returns whether the opened type is shown in the type hierarchy as well.
*/
public boolean showInTypeHierarchy() {
return fShowInTypeHierarchy;
}
private IDialogSettings getDialogSetting() {
IDialogSettings mainStore= JavaPlugin.getDefault().getDialogSettings();
IDialogSettings result= mainStore.getSection(SECTION_NAME);
if (result == null) {
result= mainStore.addNewSection(SECTION_NAME);
result.put(SHOW_IN_TYPE_HIERARCHY, true);
}
return result;
}
/*
* @see Dialog#createDialogArea(Composite)
*/
public Control createDialogArea(Composite parent) {
Composite contents= (Composite)super.createDialogArea(parent);
final Button check= new Button(contents, SWT.CHECK);
check.setText(JavaUIMessages.getString("OpenTypeSelectionDialog.checkboxtext")); //$NON-NLS-1$
check.setSelection(fShowInTypeHierarchy);
check.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
fShowInTypeHierarchy= check.getSelection();
}
});
return contents;
}
/*
* @see Window#close()
*/
public boolean close() {
if (getReturnCode() != CANCEL)
getDialogSetting().put(SHOW_IN_TYPE_HIERARCHY, fShowInTypeHierarchy);
return super.close();
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.dialogs;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine;
import org.eclipse.jdt.internal.ui.util.StringMatcher;
import org.eclipse.jdt.internal.ui.util.TypeInfo;
import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;
/**
* A dialog to select a type from a list of types.
*/
public class TypeSelectionDialog extends TwoPaneElementSelector {
private static class TypeFilterMatcher implements FilteredList.FilterMatcher {
private StringMatcher fMatcher;
private StringMatcher fQualifierMatcher;
/*
* @see FilteredList.FilterMatcher#setFilter(String, boolean)
*/
public void setFilter(String pattern, boolean ignoreCase, boolean igoreWildCards) {
int qualifierIndex= pattern.lastIndexOf("."); //$NON-NLS-1$
// type
if (qualifierIndex == -1) {
fQualifierMatcher= null;
fMatcher= new StringMatcher(pattern + '*', ignoreCase, igoreWildCards);
// qualified type
} else {
fQualifierMatcher= new StringMatcher(pattern.substring(0, qualifierIndex), ignoreCase, igoreWildCards);
fMatcher= new StringMatcher(pattern.substring(qualifierIndex + 1), ignoreCase, igoreWildCards);
}
}
/*
* @see FilteredList.FilterMatcher#match(Object)
*/
public boolean match(Object element) {
if (!(element instanceof TypeInfo))
return false;
TypeInfo type= (TypeInfo) element;
if (!fMatcher.match(type.getTypeName()))
return false;
if (fQualifierMatcher == null)
return true;
return fQualifierMatcher.match(type.getTypeContainerName());
}
}
/*
* A string comparator which is aware of obfuscated code
* (type names starting with lower case characters).
*/
private static class StringComparator implements Comparator {
public int compare(Object left, Object right) {
String leftString= (String) left;
String rightString= (String) right;
if (Character.isLowerCase(leftString.charAt(0)) &&
!Character.isLowerCase(rightString.charAt(0)))
return +1;
if (Character.isLowerCase(rightString.charAt(0)) &&
!Character.isLowerCase(leftString.charAt(0)))
return -1;
return leftString.compareToIgnoreCase(rightString);
}
}
private IRunnableContext fRunnableContext;
private IJavaSearchScope fScope;
private int fStyle;
/**
* Constructs a type selection dialog.
* @param parent the parent shell.
* @param context the runnable context.
* @param scope the java search scope.
* @param style the widget style.
*/
public TypeSelectionDialog(Shell parent, IRunnableContext context,
IJavaSearchScope scope, int style)
{
super(parent, new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY),
new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_CONTAINER_ONLY + TypeInfoLabelProvider.SHOW_ROOT_POSTFIX));
Assert.isNotNull(context);
Assert.isNotNull(scope);
fRunnableContext= context;
fScope= scope;
fStyle= style;
setUpperListLabel(JavaUIMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$
setLowerListLabel(JavaUIMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$
}
public void create() {
if (getFilter() == null)
setFilter("A"); //$NON-NLS-1$
super.create();
}
/*
* @see AbstractElementListSelectionDialog#createFilteredList(Composite)
*/
protected FilteredList createFilteredList(Composite parent) {
FilteredList list= super.createFilteredList(parent);
fFilteredList.setFilterMatcher(new TypeFilterMatcher());
fFilteredList.setComparator(new StringComparator());
return list;
}
/**
* @see Window#open()
*/
public int open() {
AllTypesSearchEngine engine= new AllTypesSearchEngine(JavaPlugin.getWorkspace());
List typeList= engine.searchTypes(fRunnableContext, fScope, fStyle);
// #6385 workaround: filter out anonymous (!) classes
List filteredList= new ArrayList(typeList.size());
for (Iterator iterator = typeList.iterator(); iterator.hasNext();) {
TypeInfo info = (TypeInfo) iterator.next();
if (info.getTypeName().length() != 0)
filteredList.add(info);
}
if (filteredList.isEmpty()) {
String title= JavaUIMessages.getString("TypeSelectionDialog.notypes.title"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.notypes.message"); //$NON-NLS-1$
MessageDialog.openInformation(getShell(), title, message);
return CANCEL;
}
TypeInfo[] typeRefs= (TypeInfo[])filteredList.toArray(new TypeInfo[filteredList.size()]);
setElements(typeRefs);
return super.open();
}
/**
* @see SelectionStatusDialog#computeResult()
*/
protected void computeResult() {
TypeInfo ref= (TypeInfo) getLowerSelectedElement();
if (ref == null)
return;
try {
IType type= ref.resolveType(fScope);
if (type == null) {
// not a class file or compilation unit
String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
setResult(null);
} else {
List result= new ArrayList(1);
result.add(type);
setResult(result);
}
} catch (JavaModelException e) {
String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
setResult(null);
}
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/FocusOnTypeAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.typehierarchy;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog;
/**
* Refocuses the type hierarchy on a type selection from a all types dialog.
*/
public class FocusOnTypeAction extends Action {
private TypeHierarchyViewPart fViewPart;
private ISelectionProvider fSelectionProvider;
public FocusOnTypeAction(TypeHierarchyViewPart part) {
super(TypeHierarchyMessages.getString("FocusOnTypeAction.label")); //$NON-NLS-1$
setDescription(TypeHierarchyMessages.getString("FocusOnTypeAction.description")); //$NON-NLS-1$
setToolTipText(TypeHierarchyMessages.getString("FocusOnTypeAction.tooltip")); //$NON-NLS-1$
fViewPart= part;
WorkbenchHelp.setHelp(this, new Object[] { IJavaHelpContextIds.FOCUS_ON_TYPE_ACTION });
}
/*
* @see Action#run
*/
public void run() {
Shell parent= fViewPart.getSite().getShell();
TypeSelectionDialog dialog= new TypeSelectionDialog(parent, new ProgressMonitorDialog(parent),
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_TYPES);
dialog.setTitle(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.title")); //$NON-NLS-1$
dialog.setMessage(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.message")); //$NON-NLS-1$
if (dialog.open() != IDialogConstants.OK_ID) {
return;
}
Object[] types= dialog.getResult();
if (types != null && types.length > 0) {
IType type= (IType)types[0];
fViewPart.setInputElement(type);
}
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/AllTypesSearchEngine.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.ITypeNameRequestor;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Assert;
/**
* Search for all types in the workspace. Instead of returning objects of type <code>IType</code>
* the methods of this class returns a list of the lightweight objects <code>TypeInfo</code>.
*/
public class AllTypesSearchEngine {
private IWorkspace fWorkspace;
public AllTypesSearchEngine(IWorkspace workspace) {
Assert.isNotNull(workspace);
fWorkspace= workspace;
}
/**
* Search for type in the given search scope.
* @param style a combination of <code>IJavaElementSearchConstants</code> flags
*/
public List searchTypes(IRunnableContext context, final IJavaSearchScope scope, final int style) {
final List typesFound= new ArrayList(2000);
if (TypeCache.canReuse(style, scope)){
typesFound.addAll(TypeCache.getCachedTypes());
return typesFound;
}
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) {
searchTypes(typesFound, scope, style, pm);
}
};
try {
context.run(true, true, runnable);
} catch (InvocationTargetException e) {
Throwable t= e.getTargetException();
if (t instanceof Error)
throw (Error)t;
if (t instanceof RuntimeException)
throw (RuntimeException)t;
ExceptionHandler.handle(e, "Exception", "Unexpected exception. See log for details.");
} catch (InterruptedException e) {
}
return typesFound;
}
/**
* Search for type in the given search scope.
* @param style a combination of <code>IJavaElementSearchConstants</code> flags
*/
public void searchTypes(List typesFound, IJavaSearchScope scope, int style, IProgressMonitor pm) {
if (TypeCache.canReuse(style, scope)){
typesFound.addAll(TypeCache.getCachedTypes());
pm.done();
return;
}
TypeCache.flush();
TypeCache.setConfiguration(style);
doSearchTypes(typesFound, scope, style, pm);
TypeCache.setCachedTypes(createCopy(typesFound));
TypeCache.registerIfNecessary();
}
private static List createCopy(List list) {
List newList= new ArrayList(list.size());
newList.addAll(list);
return newList;
}
private void doSearchTypes(List typesFound, IJavaSearchScope scope, int style, IProgressMonitor pm) {
Assert.isTrue((style & IJavaElementSearchConstants.CONSIDER_TYPES) != 0);
try {
new SearchEngine().searchAllTypeNames(
fWorkspace,
null,
null,
IJavaSearchConstants.PATTERN_MATCH,
IJavaSearchConstants.CASE_INSENSITIVE,
computeKind(style),
scope,
new TypeInfoRequestor(typesFound),
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
pm);
} catch(JavaModelException e){
ExceptionHandler.handle(e, "Exception", "Unexpected exception. See log for details.");
}
}
private static int computeKind(int style) {
int kind= IJavaSearchConstants.INTERFACE;
if ((style & IJavaElementSearchConstants.CONSIDER_INTERFACES) != 0 && (style & IJavaElementSearchConstants.CONSIDER_CLASSES) != 0)
kind= IJavaSearchConstants.TYPE;
else if ((style & IJavaElementSearchConstants.CONSIDER_CLASSES) != 0)
kind= IJavaSearchConstants.CLASS;
return kind;
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/TypeCache.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.util;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope;
import org.eclipse.jdt.internal.ui.util.AllTypesSearchEngine;
import org.eclipse.jface.operation.IRunnableContext;
/**
* Cache used by AllTypesSeachEngine
*/
class TypeCache{
private static int fgLastStyle= -1;
private static List fgTypeList;
private static boolean fgIsRegistered= false;
//no instances
private TypeCache(){
}
static List getCachedTypes() {
//must not return null
if (fgTypeList == null)
return new ArrayList(0);
else
return fgTypeList;
}
static boolean canReuse(int style, IJavaSearchScope scope){
if (style != fgLastStyle)
return false;
if (! (scope instanceof JavaWorkspaceScope))
return false;
if (fgTypeList == null)
return false;
if (fgTypeList.isEmpty())
return false;
return true;
}
static void flush(){
fgTypeList= null;
}
static void setConfiguration(int style){
fgLastStyle= style;
}
static void setCachedTypes(List types){ //copy is passed here - no reason to copy again
fgTypeList= types;
}
static void registerIfNecessary(){
if (fgIsRegistered)
return;
JavaCore.addElementChangedListener(new DeltaListener());
fgIsRegistered= true;
}
private static class DeltaListener implements IElementChangedListener {
public void elementChanged(ElementChangedEvent event) {
if (fgTypeList == null)
return;
IJavaElementDelta delta= event.getDelta();
IJavaElement element= delta.getElement();
int type= element.getElementType();
if (type == IJavaElement.CLASS_FILE)
return;
processDelta(delta);
}
private boolean mustFlush(IJavaElementDelta delta) {
if (delta.getKind() != IJavaElementDelta.CHANGED)
return true;
//if it's a cu we wait
if (delta.getElement().getElementType() == IJavaElement.COMPILATION_UNIT)
return false;
//must be only children
if (delta.getFlags() != IJavaElementDelta.F_CHILDREN)
return true;
//special case: if it's a type then the type itself must be added or removed
if (delta.getElement().getElementType() == IJavaElement.TYPE)
return false;
if ((delta.getAddedChildren() != null)
&& (delta.getAddedChildren().length != 0))
return true;
return false;
}
/*
* returns false iff list is flushed and we can stop processing
*/
private boolean processDelta(IJavaElementDelta delta) {
if (mustStopProcessing(delta))
return true;
if (mustFlush(delta)) {
flush();
return false;
}
IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
if (affectedChildren == null)
return true;
for (int i= 0; i < affectedChildren.length; i++) {
if (!processDelta(affectedChildren[i]))
return false;
}
return true;
}
private static boolean mustStopProcessing(IJavaElementDelta delta) {
int type= delta.getElement().getElementType();
if (type == IJavaElement.CLASS_FILE)
return true;
if (type == IJavaElement.FIELD)
return true;
if (type == IJavaElement.METHOD)
return true;
if (type == IJavaElement.INITIALIZER)
return true;
if (type == IJavaElement.PACKAGE_DECLARATION)
return true;
if (type == IJavaElement.IMPORT_CONTAINER)
return true;
if (type == IJavaElement.IMPORT_DECLARATION)
return true;
return false;
}
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/TypeInfo.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.util;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
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.IPackageFragmentRoot;
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.internal.corext.util.JavaModelUtil;
public class TypeInfo {
private final String fName;
private final String fPackage;
private final char[][] fEnclosingNames;
private final boolean fIsInterface;
private final String fPath;
private static final char SEPARATOR= '|';
public TypeInfo(char[] pkg, char[] name, char[][] enclosingTypes, String path, boolean isInterface) {
fPath= path;
fPackage= new String(pkg);
fName= new String(name);
fIsInterface= isInterface;
fEnclosingNames= enclosingTypes;
}
public String getTypeName() {
return fName;
}
public String getPackageName() {
return fPackage;
}
/**
* Returns true iff the type info describes an interface.
*/
public boolean isInterface() {
return fIsInterface;
}
/**
* Gets the enclosing name (dot separated).
*/
public String getEnclosingName() {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < fEnclosingNames.length; i++) {
if (i != 0) {
buf.append('.');
}
buf.append(fEnclosingNames[i]);
}
return buf.toString();
}
/**
* Gets the type qualified name: Includes enclosing type names, but
* not package name. Identifiers are separated by dots.
*/
public String getTypeQualifiedName() {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < fEnclosingNames.length; i++) {
buf.append(fEnclosingNames[i]);
buf.append('.');
}
buf.append(fName);
return buf.toString();
}
/**
* Gets the fully qualified type name: Includes enclosing type names and
* package. All identifiers are separated by dots.
*/
public String getFullyQualifiedName() {
StringBuffer buf= new StringBuffer();
if (fPackage.length() > 0) {
buf.append(fPackage);
buf.append('.');
}
for (int i= 0; i < fEnclosingNames.length; i++) {
buf.append(fEnclosingNames[i]);
buf.append('.');
}
buf.append(fName);
return buf.toString();
}
/**
* Gets the fully qualified type container name: Package name or
* enclosing type name with package name.
* All identifiers are separated by dots.
*/
public String getTypeContainerName() {
StringBuffer buf= new StringBuffer();
if (fPackage.length() > 0) {
buf.append(fPackage);
}
for (int i= 0; i < fEnclosingNames.length; i++) {
if (buf.length() > 0) {
buf.append('.');
}
buf.append(fEnclosingNames[i]);
}
return buf.toString();
}
/**
* Contructs the package fragment root name from the type ref path.
*/
public IPath getPackageFragmentRootPath() {
int index= fPath.indexOf(SEPARATOR);
if (index > 0) {
return new Path(fPath.substring(0, index));
} else {
int removeSegments= 1; // the file name
int packNameLen= fPackage.length();
if (packNameLen > 0) {
removeSegments++;
for (int i= 0; i < packNameLen; i++) {
if (fPackage.charAt(i) == '.')
removeSegments++;
}
}
return (new Path(fPath)).removeLastSegments(removeSegments);
}
}
/**
* Resolves the type in a scope if was searched for.
* The parent project of JAR files is the first project found in scope.
* Returns null if the type could not be resolved
*/
public IType resolveType(IJavaSearchScope scope) throws JavaModelException {
IJavaElement elem = getJavaElement(scope);
if (elem instanceof ICompilationUnit)
return JavaModelUtil.findTypeInCompilationUnit((ICompilationUnit)elem, getTypeQualifiedName());
else if (elem instanceof IClassFile)
return ((IClassFile)elem).getType();
return null;
}
private IJavaElement getJavaElement(IJavaSearchScope scope) throws JavaModelException {
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
int index= fPath.indexOf(SEPARATOR);
if (index > 0)
return findJarInScope(root, scope, fPath.substring(0, index), new Path(fPath.substring(index + 1)));
else
return findInFile(root);
}
private IJavaElement findJarInScope(IWorkspaceRoot workspaceRoot, IJavaSearchScope scope, String jarPath, IPath elementPath) throws JavaModelException {
IJavaModel jmodel= JavaCore.create(workspaceRoot);
IPath[] enclosedPaths= scope.enclosingProjectsAndJars();
for (int i= 0; i < enclosedPaths.length; i++) {
IPath curr= enclosedPaths[i];
if (curr.segmentCount() == 1) {
IJavaProject jproject= jmodel.getJavaProject(curr.segment(0));
IPackageFragmentRoot root= jproject.getPackageFragmentRoot(jarPath);
if (root.exists())
return jproject.findElement(elementPath);
}
}
return null;
}
private IJavaElement findInFile(IWorkspaceRoot root) throws JavaModelException {
return JavaCore.create(root.findMember(new Path(fPath)));
}
/* non java-doc
* debugging only
*/
public String toString() {
StringBuffer buf= new StringBuffer();
buf.append("path= "); //$NON-NLS-1$
buf.append(fPath);
buf.append("; pkg= "); //$NON-NLS-1$
buf.append(fPackage);
buf.append("; enclosing= "); //$NON-NLS-1$
buf.append(getEnclosingName());
buf.append("; name= "); //$NON-NLS-1$
buf.append(fName);
return buf.toString();
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/SuperInterfaceSelectionDialog.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.wizards;
import java.util.List;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog;
import org.eclipse.jdt.internal.ui.util.TypeInfo;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
public class SuperInterfaceSelectionDialog extends TypeSelectionDialog {
private static final int ADD_ID= IDialogConstants.CLIENT_ID + 1;
private ListDialogField fList;
private List fOldContent;
public SuperInterfaceSelectionDialog(Shell parent, IRunnableContext context, ListDialogField list, IJavaProject p) {
super(parent, context, createSearchScope(p), IJavaElementSearchConstants.CONSIDER_INTERFACES);
fList= list;
//to restore the content of the dialog field if the dialog is canceled
fOldContent= fList.getElements();
}
/*
* @see Dialog#createButtonsForButtonBar
*/
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, ADD_ID, NewWizardMessages.getString("SuperInterfaceSelectionDialog.addButton.label"), true); //$NON-NLS-1$
super.createButtonsForButtonBar(parent);
}
/*
* @see Dialog#cancelPressed
*/
protected void cancelPressed() {
fList.setElements(fOldContent);
super.cancelPressed();
}
/*
* @see Dialog#buttonPressed
*/
protected void buttonPressed(int buttonId) {
if (buttonId == ADD_ID){
addSelectedInterface();
}
super.buttonPressed(buttonId);
}
/*
* @see Dialog#okPressed
*/
protected void okPressed() {
addSelectedInterface();
super.okPressed();
}
private void addSelectedInterface(){
Object ref= getLowerSelectedElement();
if (ref instanceof TypeInfo)
fList.addElement(((TypeInfo)ref).getFullyQualifiedName());
}
private static IJavaSearchScope createSearchScope(IJavaProject p) {
return SearchEngine.createJavaSearchScope(new IJavaProject[] { p });
}
/*
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
*/
protected void handleDefaultSelected() {
if (validateCurrentSelection())
buttonPressed(ADD_ID);
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/TypePage.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.wizards;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
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.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceRange;
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.JavaElementLabelProvider;
import org.eclipse.jdt.internal.compiler.env.IConstants;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
import org.eclipse.jdt.internal.corext.codemanipulation.IImportsStructure;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportsStructure;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.template.ContextType;
import org.eclipse.jdt.internal.corext.template.ContextTypeRegistry;
import org.eclipse.jdt.internal.corext.template.Template;
import org.eclipse.jdt.internal.corext.template.TemplateBuffer;
import org.eclipse.jdt.internal.corext.template.Templates;
import org.eclipse.jdt.internal.corext.template.java.JavaContext;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.preferences.CodeGenerationPreferencePage;
import org.eclipse.jdt.internal.ui.preferences.ImportOrganizePreferencePage;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
import org.eclipse.jdt.internal.ui.util.SWTUtil;
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.IStringButtonAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.Separator;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonStatusDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.jdt.internal.ui.wizards.swt.MGridData;
import org.eclipse.jdt.internal.ui.wizards.swt.MGridLayout;
/**
* <code>TypePage</code> contains controls and validation routines for a 'New Type WizardPage'
* Implementors decide which components to add and to enable. Implementors can also
* customize the validation code.
* <code>TypePage</code> is intended to serve as base class of all wizards that create types.
* Applets, Servlets, Classes, Interfaces...
* See <code>NewClassCreationWizardPage</code> or <code>NewInterfaceCreationWizardPage</code> for an
* example usage of TypePage.
*/
public abstract class TypePage extends ContainerPage {
private final static String PAGE_NAME= "TypePage"; //$NON-NLS-1$
protected final static String PACKAGE= PAGE_NAME + ".package"; //$NON-NLS-1$
protected final static String ENCLOSING= PAGE_NAME + ".enclosing"; //$NON-NLS-1$
protected final static String ENCLOSINGSELECTION= ENCLOSING + ".selection"; //$NON-NLS-1$
protected final static String TYPENAME= PAGE_NAME + ".typename"; //$NON-NLS-1$
protected final static String SUPER= PAGE_NAME + ".superclass"; //$NON-NLS-1$
protected final static String INTERFACES= PAGE_NAME + ".interfaces"; //$NON-NLS-1$
protected final static String MODIFIERS= PAGE_NAME + ".modifiers"; //$NON-NLS-1$
protected final static String METHODS= PAGE_NAME + ".methods"; //$NON-NLS-1$
private class InterfacesListLabelProvider extends LabelProvider {
private Image fInterfaceImage;
public InterfacesListLabelProvider() {
super();
fInterfaceImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INTERFACE);
}
public Image getImage(Object element) {
return fInterfaceImage;
}
}
private StringButtonStatusDialogField fPackageDialogField;
private SelectionButtonDialogField fEnclosingTypeSelection;
private StringButtonDialogField fEnclosingTypeDialogField;
private boolean fCanModifyPackage;
private boolean fCanModifyEnclosingType;
private IPackageFragment fCurrPackage;
private IType fCurrEnclosingType;
private StringDialogField fTypeNameDialogField;
private StringButtonDialogField fSuperClassDialogField;
private ListDialogField fSuperInterfacesDialogField;
private IType fSuperClass;
private SelectionButtonDialogFieldGroup fAccMdfButtons;
private SelectionButtonDialogFieldGroup fOtherMdfButtons;
private IType fCreatedType;
protected IStatus fEnclosingTypeStatus;
protected IStatus fPackageStatus;
protected IStatus fTypeNameStatus;
protected IStatus fSuperClassStatus;
protected IStatus fModifierStatus;
protected IStatus fSuperInterfacesStatus;
private boolean fIsClass;
private int fStaticMdfIndex;
private final int PUBLIC_INDEX= 0, DEFAULT_INDEX= 1, PRIVATE_INDEX= 2, PROTECTED_INDEX= 3;
private final int ABSTRACT_INDEX= 0, FINAL_INDEX= 1;
public TypePage(boolean isClass, String pageName, IWorkspaceRoot root) {
super(pageName, root);
fCreatedType= null;
fIsClass= isClass;
TypeFieldsAdapter adapter= new TypeFieldsAdapter();
fPackageDialogField= new StringButtonStatusDialogField(adapter);
fPackageDialogField.setDialogFieldListener(adapter);
fPackageDialogField.setLabelText(NewWizardMessages.getString("TypePage.package.label")); //$NON-NLS-1$
fPackageDialogField.setButtonLabel(NewWizardMessages.getString("TypePage.package.button")); //$NON-NLS-1$
fPackageDialogField.setStatusWidthHint(NewWizardMessages.getString("TypePage.default")); //$NON-NLS-1$
fEnclosingTypeSelection= new SelectionButtonDialogField(SWT.CHECK);
fEnclosingTypeSelection.setDialogFieldListener(adapter);
fEnclosingTypeSelection.setLabelText(NewWizardMessages.getString("TypePage.enclosing.selection.label")); //$NON-NLS-1$
fEnclosingTypeDialogField= new StringButtonDialogField(adapter);
fEnclosingTypeDialogField.setDialogFieldListener(adapter);
fEnclosingTypeDialogField.setButtonLabel(NewWizardMessages.getString("TypePage.enclosing.button")); //$NON-NLS-1$
fTypeNameDialogField= new StringDialogField();
fTypeNameDialogField.setDialogFieldListener(adapter);
fTypeNameDialogField.setLabelText(NewWizardMessages.getString("TypePage.typename.label")); //$NON-NLS-1$
fSuperClassDialogField= new StringButtonDialogField(adapter);
fSuperClassDialogField.setDialogFieldListener(adapter);
fSuperClassDialogField.setLabelText(NewWizardMessages.getString("TypePage.superclass.label")); //$NON-NLS-1$
fSuperClassDialogField.setButtonLabel(NewWizardMessages.getString("TypePage.superclass.button")); //$NON-NLS-1$
String[] addButtons= new String[] {
/* 0 */ NewWizardMessages.getString("TypePage.interfaces.add"), //$NON-NLS-1$
/* 1 */ null,
/* 2 */ NewWizardMessages.getString("TypePage.interfaces.remove") //$NON-NLS-1$
};
fSuperInterfacesDialogField= new ListDialogField(adapter, addButtons, new InterfacesListLabelProvider());
fSuperInterfacesDialogField.setDialogFieldListener(adapter);
String interfaceLabel= fIsClass ? NewWizardMessages.getString("TypePage.interfaces.class.label") : NewWizardMessages.getString("TypePage.interfaces.ifc.label"); //$NON-NLS-1$ //$NON-NLS-2$
fSuperInterfacesDialogField.setLabelText(interfaceLabel);
fSuperInterfacesDialogField.setRemoveButtonIndex(2);
String[] buttonNames1= new String[] {
/* 0 == PUBLIC_INDEX */ NewWizardMessages.getString("TypePage.modifiers.public"), //$NON-NLS-1$
/* 1 == DEFAULT_INDEX */ NewWizardMessages.getString("TypePage.modifiers.default"), //$NON-NLS-1$
/* 2 == PRIVATE_INDEX */ NewWizardMessages.getString("TypePage.modifiers.private"), //$NON-NLS-1$
/* 3 == PROTECTED_INDEX*/ NewWizardMessages.getString("TypePage.modifiers.protected") //$NON-NLS-1$
};
fAccMdfButtons= new SelectionButtonDialogFieldGroup(SWT.RADIO, buttonNames1, 4);
fAccMdfButtons.setDialogFieldListener(adapter);
fAccMdfButtons.setLabelText(NewWizardMessages.getString("TypePage.modifiers.acc.label")); //$NON-NLS-1$
fAccMdfButtons.setSelection(0, true);
String[] buttonNames2;
if (fIsClass) {
buttonNames2= new String[] {
/* 0 == ABSTRACT_INDEX */ NewWizardMessages.getString("TypePage.modifiers.abstract"), //$NON-NLS-1$
/* 1 == FINAL_INDEX */ NewWizardMessages.getString("TypePage.modifiers.final"), //$NON-NLS-1$
/* 2 */ NewWizardMessages.getString("TypePage.modifiers.static") //$NON-NLS-1$
};
fStaticMdfIndex= 2; // index of the static checkbox is 2
} else {
buttonNames2= new String[] {
NewWizardMessages.getString("TypePage.modifiers.static") //$NON-NLS-1$
};
fStaticMdfIndex= 0; // index of the static checkbox is 0
}
fOtherMdfButtons= new SelectionButtonDialogFieldGroup(SWT.CHECK, buttonNames2, 4);
fOtherMdfButtons.setDialogFieldListener(adapter);
fAccMdfButtons.enableSelectionButton(PRIVATE_INDEX, false);
fAccMdfButtons.enableSelectionButton(PROTECTED_INDEX, false);
fOtherMdfButtons.enableSelectionButton(fStaticMdfIndex, false);
fPackageStatus= new StatusInfo();
fEnclosingTypeStatus= new StatusInfo();
fCanModifyPackage= true;
fCanModifyEnclosingType= true;
updateEnableState();
fTypeNameStatus= new StatusInfo();
fSuperClassStatus= new StatusInfo();
fSuperInterfacesStatus= new StatusInfo();
fModifierStatus= new StatusInfo();
}
/**
* Initializes all fields provided by the type page with a given
* Java element as selection.
* @param elem The initial selection of this page or null if no
* selection was available
*/
protected void initTypePage(IJavaElement elem) {
String initSuperclass= "java.lang.Object"; //$NON-NLS-1$
ArrayList initSuperinterfaces= new ArrayList(5);
IPackageFragment pack= null;
IType enclosingType= null;
if (elem != null) {
// evaluate the enclosing type
pack= (IPackageFragment) JavaModelUtil.findElementOfKind(elem, IJavaElement.PACKAGE_FRAGMENT);
IType typeInCU= (IType) JavaModelUtil.findElementOfKind(elem, IJavaElement.TYPE);
if (typeInCU != null) {
if (typeInCU.getCompilationUnit() != null) {
enclosingType= typeInCU;
}
} else {
ICompilationUnit cu= (ICompilationUnit) JavaModelUtil.findElementOfKind(elem, IJavaElement.COMPILATION_UNIT);
if (cu != null) {
enclosingType= JavaModelUtil.findPrimaryType(cu);
}
}
try {
IType type= null;
if (elem.getElementType() == IJavaElement.TYPE) {
type= (IType)elem;
if (type.exists()) {
String superName= JavaModelUtil.getFullyQualifiedName(type);
if (type.isInterface()) {
initSuperinterfaces.add(superName);
} else {
initSuperclass= superName;
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
// ignore this exception now
}
}
setPackageFragment(pack, true);
setEnclosingType(enclosingType, true);
setEnclosingTypeSelection(false, true);
setTypeName("", true); //$NON-NLS-1$
setSuperClass(initSuperclass, true);
setSuperInterfaces(initSuperinterfaces, true);
}
// -------- UI Creation ---------
/**
* Creates a separator line.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createSeparator(Composite composite, int nColumns) {
(new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1));
}
/**
* Creates the controls for the package name field.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createPackageControls(Composite composite, int nColumns) {
fPackageDialogField.doFillIntoGrid(composite, 4);
LayoutUtil.setWidthHint(fPackageDialogField.getTextControl(null), getMaxFieldWidth());
}
/**
* Creates the controls for the enclosing type name field.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createEnclosingTypeControls(Composite composite, int nColumns) {
// #6891
Composite tabGroup= new Composite(composite, SWT.NONE);
MGridLayout layout= new MGridLayout();
layout.marginWidth= 0;
layout.marginHeight= 0;
tabGroup.setLayout(layout);
fEnclosingTypeSelection.doFillIntoGrid(tabGroup, 1);
Control c= fEnclosingTypeDialogField.getTextControl(composite);
MGridData gd= new MGridData(MGridData.FILL_HORIZONTAL);
gd.widthHint= getMaxFieldWidth();
gd.horizontalSpan= 2;
c.setLayoutData(gd);
Button button= fEnclosingTypeDialogField.getChangeControl(composite);
gd= new MGridData(MGridData.HORIZONTAL_ALIGN_FILL);
gd.heightHint = SWTUtil.getButtonHeigthHint(button);
gd.widthHint = SWTUtil.getButtonWidthHint(button);
button.setLayoutData(gd);
}
/**
* Creates the controls for the type name field.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createTypeNameControls(Composite composite, int nColumns) {
fTypeNameDialogField.doFillIntoGrid(composite, nColumns - 1);
DialogField.createEmptySpace(composite);
LayoutUtil.setWidthHint(fTypeNameDialogField.getTextControl(null), getMaxFieldWidth());
}
/**
* Creates the controls for the modifiers radio/ceckbox buttons.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createModifierControls(Composite composite, int nColumns) {
LayoutUtil.setHorizontalSpan(fAccMdfButtons.getLabelControl(composite), 1);
Control control= fAccMdfButtons.getSelectionButtonsGroup(composite);
MGridData gd= new MGridData(MGridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns - 2;
control.setLayoutData(gd);
DialogField.createEmptySpace(composite);
DialogField.createEmptySpace(composite);
control= fOtherMdfButtons.getSelectionButtonsGroup(composite);
gd= new MGridData(MGridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns - 2;
control.setLayoutData(gd);
DialogField.createEmptySpace(composite);
}
/**
* Creates the controls for the superclass name field.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createSuperClassControls(Composite composite, int nColumns) {
fSuperClassDialogField.doFillIntoGrid(composite, nColumns);
LayoutUtil.setWidthHint(fSuperClassDialogField.getTextControl(null), getMaxFieldWidth());
}
/**
* Creates the controls for the superclass name field.
* @param composite The parent composite
* @param nColumns Number of columns to span
*/
protected void createSuperInterfacesControls(Composite composite, int nColumns) {
fSuperInterfacesDialogField.doFillIntoGrid(composite, nColumns);
MGridData gd= (MGridData)fSuperInterfacesDialogField.getListControl(null).getLayoutData();
if (fIsClass) {
gd.heightHint= convertHeightInCharsToPixels(3);
} else {
gd.heightHint= convertHeightInCharsToPixels(6);
}
gd.grabExcessVerticalSpace= false;
gd.widthHint= getMaxFieldWidth();
}
/**
* Sets the focus on the container if empty, elso on type name.
*/
protected void setFocus() {
fTypeNameDialogField.setFocus();
}
// -------- TypeFieldsAdapter --------
private class TypeFieldsAdapter implements IStringButtonAdapter, IDialogFieldListener, IListAdapter {
// -------- IStringButtonAdapter
public void changeControlPressed(DialogField field) {
typePageChangeControlPressed(field);
}
// -------- IListAdapter
public void customButtonPressed(DialogField field, int index) {
typePageCustomButtonPressed(field, index);
}
public void selectionChanged(DialogField field) {}
// -------- IDialogFieldListener
public void dialogFieldChanged(DialogField field) {
typePageDialogFieldChanged(field);
}
}
private void typePageChangeControlPressed(DialogField field) {
if (field == fPackageDialogField) {
IPackageFragment pack= choosePackage();
if (pack != null) {
fPackageDialogField.setText(pack.getElementName());
}
} else if (field == fEnclosingTypeDialogField) {
IType type= chooseEnclosingType();
if (type != null) {
fEnclosingTypeDialogField.setText(JavaModelUtil.getFullyQualifiedName(type));
}
} else if (field == fSuperClassDialogField) {
IType type= chooseSuperType();
if (type != null) {
fSuperClassDialogField.setText(JavaModelUtil.getFullyQualifiedName(type));
}
}
}
private void typePageCustomButtonPressed(DialogField field, int index) {
if (field == fSuperInterfacesDialogField) {
chooseSuperInterfaces();
}
}
/*
* A field on the type has changed. The fields' status and all dependend
* status are updated.
*/
private void typePageDialogFieldChanged(DialogField field) {
String fieldName= null;
if (field == fPackageDialogField) {
fPackageStatus= packageChanged();
updatePackageStatusLabel();
fTypeNameStatus= typeNameChanged();
fSuperClassStatus= superClassChanged();
fieldName= PACKAGE;
} else if (field == fEnclosingTypeDialogField) {
fEnclosingTypeStatus= enclosingTypeChanged();
fTypeNameStatus= typeNameChanged();
fSuperClassStatus= superClassChanged();
fieldName= ENCLOSING;
} else if (field == fEnclosingTypeSelection) {
updateEnableState();
boolean isEnclosedType= isEnclosingTypeSelected();
if (!isEnclosedType) {
if (fAccMdfButtons.isSelected(PRIVATE_INDEX) || fAccMdfButtons.isSelected(PROTECTED_INDEX)) {
fAccMdfButtons.setSelection(PRIVATE_INDEX, false);
fAccMdfButtons.setSelection(PROTECTED_INDEX, false);
fAccMdfButtons.setSelection(PUBLIC_INDEX, true);
}
if (fOtherMdfButtons.isSelected(fStaticMdfIndex)) {
fOtherMdfButtons.setSelection(fStaticMdfIndex, false);
}
}
fAccMdfButtons.enableSelectionButton(PRIVATE_INDEX, isEnclosedType && fIsClass);
fAccMdfButtons.enableSelectionButton(PROTECTED_INDEX, isEnclosedType && fIsClass);
fOtherMdfButtons.enableSelectionButton(fStaticMdfIndex, isEnclosedType);
fTypeNameStatus= typeNameChanged();
fSuperClassStatus= superClassChanged();
fieldName= ENCLOSINGSELECTION;
} else if (field == fTypeNameDialogField) {
fTypeNameStatus= typeNameChanged();
fieldName= TYPENAME;
} else if (field == fSuperClassDialogField) {
fSuperClassStatus= superClassChanged();
fieldName= SUPER;
} else if (field == fSuperInterfacesDialogField) {
fSuperInterfacesStatus= superInterfacesChanged();
fieldName= INTERFACES;
} else if (field == fOtherMdfButtons) {
fModifierStatus= modifiersChanged();
fieldName= MODIFIERS;
} else {
fieldName= METHODS;
}
// tell all others
handleFieldChanged(fieldName);
}
// -------- update message ----------------
/**
* Called whenever a content of a field has changed.
* Implementors of TypePage can hook in.
* @see ContainerPage#handleFieldChanged
*/
protected void handleFieldChanged(String fieldName) {
super.handleFieldChanged(fieldName);
if (fieldName == CONTAINER) {
fPackageStatus= packageChanged();
fEnclosingTypeStatus= enclosingTypeChanged();
fTypeNameStatus= typeNameChanged();
fSuperClassStatus= superClassChanged();
fSuperInterfacesStatus= superInterfacesChanged();
}
}
// ---- set / get ----------------
/**
* Gets the text of package field.
*/
public String getPackageText() {
return fPackageDialogField.getText();
}
/**
* Gets the text of enclosing type field.
*/
public String getEnclosingTypeText() {
return fEnclosingTypeDialogField.getText();
}
/**
* Returns the package fragment corresponding to the current input.
* @return Returns <code>null</code> if the input could not be resolved.
*/
public IPackageFragment getPackageFragment() {
if (!isEnclosingTypeSelected()) {
return fCurrPackage;
} else {
if (fCurrEnclosingType != null) {
return fCurrEnclosingType.getPackageFragment();
}
}
return null;
}
/**
* Sets the package fragment.
* This will update model and the text of the control.
* @param canBeModified Selects if the package fragment can be changed by the user
*/
public void setPackageFragment(IPackageFragment pack, boolean canBeModified) {
fCurrPackage= pack;
fCanModifyPackage= canBeModified;
String str= (pack == null) ? "" : pack.getElementName(); //$NON-NLS-1$
fPackageDialogField.setText(str);
updateEnableState();
}
/**
* Returns the encloding type corresponding to the current input.
* @return Returns <code>null</code> if enclosing type is not selected or the input could not
* be resolved.
*/
public IType getEnclosingType() {
if (isEnclosingTypeSelected()) {
return fCurrEnclosingType;
}
return null;
}
/**
* Sets the package fragment.
* This will update model and the text of the control.
* @param canBeModified Selects if the enclosing type can be changed by the user
*/
public void setEnclosingType(IType type, boolean canBeModified) {
fCurrEnclosingType= type;
fCanModifyEnclosingType= canBeModified;
String str= (type == null) ? "" : JavaModelUtil.getFullyQualifiedName(type); //$NON-NLS-1$
fEnclosingTypeDialogField.setText(str);
updateEnableState();
}
/**
* Returns <code>true</code> if the enclosing type selection check box is enabled.
*/
public boolean isEnclosingTypeSelected() {
return fEnclosingTypeSelection.isSelected();
}
/**
* Sets the enclosing type selection checkbox.
* @param canBeModified Selects if the enclosing type selection can be changed by the user
*/
public void setEnclosingTypeSelection(boolean isSelected, boolean canBeModified) {
fEnclosingTypeSelection.setSelection(isSelected);
fEnclosingTypeSelection.setEnabled(canBeModified);
updateEnableState();
}
/**
* Gets the type name.
*/
public String getTypeName() {
return fTypeNameDialogField.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) {
fTypeNameDialogField.setText(name);
fTypeNameDialogField.setEnabled(canBeModified);
}
/**
* Gets the selected modifiers.
* @see Flags
*/
public int getModifiers() {
int mdf= 0;
if (fAccMdfButtons.isSelected(PUBLIC_INDEX)) {
mdf+= IConstants.AccPublic;
} else if (fAccMdfButtons.isSelected(PRIVATE_INDEX)) {
mdf+= IConstants.AccPrivate;
} else if (fAccMdfButtons.isSelected(PROTECTED_INDEX)) {
mdf+= IConstants.AccProtected;
}
if (fOtherMdfButtons.isSelected(ABSTRACT_INDEX) && (fStaticMdfIndex != 0)) {
mdf+= IConstants.AccAbstract;
}
if (fOtherMdfButtons.isSelected(FINAL_INDEX)) {
mdf+= IConstants.AccFinal;
}
if (fOtherMdfButtons.isSelected(fStaticMdfIndex)) {
mdf+= IConstants.AccStatic;
}
return mdf;
}
/**
* Sets the modifiers.
* @param canBeModified Selects if the modifiers can be changed by the user
* @see IConstants
*/
public void setModifiers(int modifiers, boolean canBeModified) {
if (Flags.isPublic(modifiers)) {
fAccMdfButtons.setSelection(PUBLIC_INDEX, true);
} else if (Flags.isPrivate(modifiers)) {
fAccMdfButtons.setSelection(PRIVATE_INDEX, true);
} else if (Flags.isProtected(modifiers)) {
fAccMdfButtons.setSelection(PROTECTED_INDEX, true);
} else {
fAccMdfButtons.setSelection(DEFAULT_INDEX, true);
}
if (Flags.isAbstract(modifiers)) {
fOtherMdfButtons.setSelection(ABSTRACT_INDEX, true);
}
if (Flags.isFinal(modifiers)) {
fOtherMdfButtons.setSelection(FINAL_INDEX, true);
}
if (Flags.isStatic(modifiers)) {
fOtherMdfButtons.setSelection(fStaticMdfIndex, true);
}
fAccMdfButtons.setEnabled(canBeModified);
fOtherMdfButtons.setEnabled(canBeModified);
}
/**
* Gets the content of the super class text field.
*/
public String getSuperClass() {
return fSuperClassDialogField.getText();
}
/**
* Sets the super class name.
* @param canBeModified Selects if the super class can be changed by the user
*/
public void setSuperClass(String name, boolean canBeModified) {
fSuperClassDialogField.setText(name);
fSuperClassDialogField.setEnabled(canBeModified);
}
/**
* Gets the currently chosen super interfaces.
* @return returns a list of String
*/
public List getSuperInterfaces() {
return fSuperInterfacesDialogField.getElements();
}
/**
* Sets the super interfaces.
* @param interfacesNames a list of String
*/
public void setSuperInterfaces(List interfacesNames, boolean canBeModified) {
fSuperInterfacesDialogField.setElements(interfacesNames);
fSuperInterfacesDialogField.setEnabled(canBeModified);
}
// ----------- validation ----------
/**
* Called when the package field has changed.
* The method validates the package name and returns the status of the validation
* This also updates the package fragment model.
* Can be extended to add more validation
*/
protected IStatus packageChanged() {
StatusInfo status= new StatusInfo();
fPackageDialogField.enableButton(getPackageFragmentRoot() != null);
String packName= getPackageText();
if (packName.length() > 0) {
IStatus val= JavaConventions.validatePackageName(packName);
if (val.getSeverity() == IStatus.ERROR) {
status.setError(NewWizardMessages.getFormattedString("TypePage.error.InvalidPackageName", val.getMessage())); //$NON-NLS-1$
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.DiscouragedPackageName", val.getMessage())); //$NON-NLS-1$
// continue
}
}
IPackageFragmentRoot root= getPackageFragmentRoot();
if (root != null) {
IPackageFragment pack= root.getPackageFragment(packName);
try {
IPath rootPath= root.getPath();
IPath outputPath= root.getJavaProject().getOutputLocation();
if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
// if the bin folder is inside of our root, dont allow to name a package
// like the bin folder
IPath packagePath= pack.getUnderlyingResource().getFullPath();
if (outputPath.isPrefixOf(packagePath)) {
status.setError(NewWizardMessages.getString("TypePage.error.ClashOutputLocation")); //$NON-NLS-1$
return status;
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
// let pass
}
fCurrPackage= pack;
} else {
status.setError(""); //$NON-NLS-1$
}
return status;
}
/*
* Updates the 'default' label next to the package field.
*/
private void updatePackageStatusLabel() {
String packName= fPackageDialogField.getText();
if (packName.length() == 0) {
fPackageDialogField.setStatus(NewWizardMessages.getString("TypePage.default")); //$NON-NLS-1$
} else {
fPackageDialogField.setStatus(""); //$NON-NLS-1$
}
}
/*
* Updates the enable state of buttons related to the enclosing type selection checkbox.
*/
private void updateEnableState() {
boolean enclosing= isEnclosingTypeSelected();
fPackageDialogField.setEnabled(fCanModifyPackage && !enclosing);
fEnclosingTypeDialogField.setEnabled(fCanModifyEnclosingType && enclosing);
}
/**
* Called when the enclosing type name has changed.
* The method validates the enclosing type and returns the status of the validation
* This also updates the enclosing type model.
* Can be extended to add more validation
*/
protected IStatus enclosingTypeChanged() {
StatusInfo status= new StatusInfo();
fCurrEnclosingType= null;
IPackageFragmentRoot root= getPackageFragmentRoot();
fEnclosingTypeDialogField.enableButton(root != null);
if (root == null) {
status.setError(""); //$NON-NLS-1$
return status;
}
String enclName= getEnclosingTypeText();
if (enclName.length() == 0) {
status.setError(NewWizardMessages.getString("TypePage.error.EnclosingTypeEnterName")); //$NON-NLS-1$
return status;
}
try {
IType type= JavaModelUtil.findType(root.getJavaProject(), enclName);
if (type == null) {
status.setError(NewWizardMessages.getString("TypePage.error.EnclosingTypeNotExists")); //$NON-NLS-1$
return status;
}
if (type.getCompilationUnit() == null) {
status.setError(NewWizardMessages.getString("TypePage.error.EnclosingNotInCU")); //$NON-NLS-1$
return status;
}
fCurrEnclosingType= type;
IPackageFragmentRoot enclosingRoot= JavaModelUtil.getPackageFragmentRoot(type);
if (!enclosingRoot.equals(root)) {
status.setWarning(NewWizardMessages.getString("TypePage.warning.EnclosingNotInSourceFolder")); //$NON-NLS-1$
}
return status;
} catch (JavaModelException e) {
status.setError(NewWizardMessages.getString("TypePage.error.EnclosingTypeNotExists")); //$NON-NLS-1$
JavaPlugin.log(e.getStatus());
return status;
}
}
/**
* 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 typeNameChanged() {
StatusInfo status= new StatusInfo();
String typeName= getTypeName();
// must not be empty
if (typeName.length() == 0) {
status.setError(NewWizardMessages.getString("TypePage.error.EnterTypeName")); //$NON-NLS-1$
return status;
}
if (typeName.indexOf('.') != -1) {
status.setError(NewWizardMessages.getString("TypePage.error.QualifiedName")); //$NON-NLS-1$
return status;
}
IStatus val= JavaConventions.validateJavaTypeName(typeName);
if (val.getSeverity() == IStatus.ERROR) {
status.setError(NewWizardMessages.getFormattedString("TypePage.error.InvalidTypeName", val.getMessage())); //$NON-NLS-1$
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.TypeNameDiscouraged", val.getMessage())); //$NON-NLS-1$
// continue checking
}
// must not exist
if (!isEnclosingTypeSelected()) {
IPackageFragment pack= getPackageFragment();
if (pack != null) {
ICompilationUnit cu= pack.getCompilationUnit(typeName + ".java"); //$NON-NLS-1$
if (cu.exists()) {
status.setError(NewWizardMessages.getString("TypePage.error.TypeNameExists")); //$NON-NLS-1$
return status;
}
}
} else {
IType type= getEnclosingType();
if (type != null) {
IType member= type.getType(typeName);
if (member.exists()) {
status.setError(NewWizardMessages.getString("TypePage.error.TypeNameExists")); //$NON-NLS-1$
return status;
}
}
}
return status;
}
/**
* Called when the superclass name has changed.
* The method validates the superclass name and returns the status of the validation.
* Can be extended to add more validation
*/
protected IStatus superClassChanged() {
StatusInfo status= new StatusInfo();
IPackageFragmentRoot root= getPackageFragmentRoot();
fSuperClassDialogField.enableButton(root != null);
fSuperClass= null;
String sclassName= getSuperClass();
if (sclassName.length() == 0) {
// accept the empty field (stands for java.lang.Object)
return status;
}
IStatus val= JavaConventions.validateJavaTypeName(sclassName);
if (!val.isOK()) {
status.setError(NewWizardMessages.getString("TypePage.error.InvalidSuperClassName")); //$NON-NLS-1$
return status;
}
if (root != null) {
try {
IType type= resolveSuperTypeName(root.getJavaProject(), sclassName);
if (type == null) {
status.setWarning(NewWizardMessages.getString("TypePage.warning.SuperClassNotExists")); //$NON-NLS-1$
return status;
} else {
if (type.isInterface()) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.SuperClassIsNotClass", sclassName)); //$NON-NLS-1$
return status;
}
int flags= type.getFlags();
if (Flags.isFinal(flags)) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.SuperClassIsFinal", sclassName)); //$NON-NLS-1$
return status;
} else if (!JavaModelUtil.isVisible(type, getPackageFragment())) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.SuperClassIsNotVisible", sclassName)); //$NON-NLS-1$
return status;
}
}
fSuperClass= type;
} catch (JavaModelException e) {
status.setError(NewWizardMessages.getString("TypePage.error.InvalidSuperClassName")); //$NON-NLS-1$
JavaPlugin.log(e.getStatus());
}
} else {
status.setError(""); //$NON-NLS-1$
}
return status;
}
private IType resolveSuperTypeName(IJavaProject jproject, String sclassName) throws JavaModelException {
IType type= null;
if (isEnclosingTypeSelected()) {
// search in the context of the enclosing type
IType enclosingType= getEnclosingType();
if (enclosingType != null) {
String[][] res= enclosingType.resolveType(sclassName);
if (res != null && res.length > 0) {
type= JavaModelUtil.findType(jproject, res[0][0], res[0][1]);
}
}
} else {
IPackageFragment currPack= getPackageFragment();
if (type == null && currPack != null) {
String packName= currPack.getElementName();
// search in own package
if (!currPack.isDefaultPackage()) {
type= JavaModelUtil.findType(jproject, packName, sclassName);
}
// search in java.lang
if (type == null && !"java.lang".equals(packName)) { //$NON-NLS-1$
type= JavaModelUtil.findType(jproject, "java.lang", sclassName); //$NON-NLS-1$
}
}
// search fully qualified
if (type == null) {
type= JavaModelUtil.findType(jproject, sclassName);
}
}
return type;
}
/**
* Called when the list of super interface has changed.
* The method validates the superinterfaces and returns the status of the validation.
* Can be extended to add more validation.
*/
protected IStatus superInterfacesChanged() {
StatusInfo status= new StatusInfo();
IPackageFragmentRoot root= getPackageFragmentRoot();
fSuperInterfacesDialogField.enableButton(0, root != null);
if (root != null) {
List elements= fSuperInterfacesDialogField.getElements();
int nElements= elements.size();
for (int i= 0; i < nElements; i++) {
String intfname= (String)elements.get(i);
try {
IType type= JavaModelUtil.findType(root.getJavaProject(), intfname);
if (type == null) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.InterfaceNotExists", intfname)); //$NON-NLS-1$
return status;
} else {
if (type.isClass()) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.InterfaceIsNotInterface", intfname)); //$NON-NLS-1$
return status;
}
if (!JavaModelUtil.isVisible(type, getPackageFragment())) {
status.setWarning(NewWizardMessages.getFormattedString("TypePage.warning.InterfaceIsNotVisible", intfname)); //$NON-NLS-1$
return status;
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
// let pass, checking is an extra
}
}
}
return status;
}
/**
* Called when the modifiers have changed.
* The method validates the modifiers and returns the status of the validation.
* Can be extended to add more validation.
*/
protected IStatus modifiersChanged() {
StatusInfo status= new StatusInfo();
int modifiers= getModifiers();
if (Flags.isFinal(modifiers) && Flags.isAbstract(modifiers)) {
status.setError(NewWizardMessages.getString("TypePage.error.ModifiersFinalAndAbstract")); //$NON-NLS-1$
}
return status;
}
// selection dialogs
private IPackageFragment choosePackage() {
IPackageFragmentRoot froot= getPackageFragmentRoot();
IJavaElement[] packages= null;
try {
if (froot != null) {
packages= froot.getChildren();
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
if (packages == null) {
packages= new IJavaElement[0];
}
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
dialog.setIgnoreCase(false);
dialog.setTitle(NewWizardMessages.getString("TypePage.ChoosePackageDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.description")); //$NON-NLS-1$
dialog.setEmptyListMessage(NewWizardMessages.getString("TypePage.ChoosePackageDialog.empty")); //$NON-NLS-1$
dialog.setElements(packages);
if (fCurrPackage != null) {
dialog.setInitialSelections(new Object[] { fCurrPackage });
}
if (dialog.open() == dialog.OK) {
return (IPackageFragment) dialog.getFirstResult();
}
return null;
}
private IType chooseEnclosingType() {
IPackageFragmentRoot root= getPackageFragmentRoot();
if (root == null) {
return null;
}
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { root });
TypeSelectionDialog dialog= new TypeSelectionDialog(getShell(), getWizard().getContainer(), scope, IJavaElementSearchConstants.CONSIDER_TYPES);
dialog.setTitle(NewWizardMessages.getString("TypePage.ChooseEnclosingTypeDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.ChooseEnclosingTypeDialog.description")); //$NON-NLS-1$
if (fCurrEnclosingType != null) {
dialog.setInitialSelections(new Object[] { fCurrEnclosingType });
dialog.setFilter(fCurrEnclosingType.getElementName().substring(0, 1));
}
if (dialog.open() == dialog.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
private IType chooseSuperType() {
IPackageFragmentRoot root= getPackageFragmentRoot();
if (root == null) {
return null;
}
IJavaElement[] elements= new IJavaElement[] { root.getJavaProject() };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
TypeSelectionDialog dialog= new TypeSelectionDialog(getShell(), getWizard().getContainer(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES);
dialog.setTitle(NewWizardMessages.getString("TypePage.SuperClassDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.SuperClassDialog.message")); //$NON-NLS-1$
if (fSuperClass != null) {
dialog.setFilter(fSuperClass.getElementName());
}
if (dialog.open() == dialog.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
private void chooseSuperInterfaces() {
IPackageFragmentRoot root= getPackageFragmentRoot();
if (root == null) {
return;
}
IJavaProject project= root.getJavaProject();
SuperInterfaceSelectionDialog dialog= new SuperInterfaceSelectionDialog(getShell(), getWizard().getContainer(), fSuperInterfacesDialogField, project);
dialog.setTitle(NewWizardMessages.getString("TypePage.InterfacesDialog.title")); //$NON-NLS-1$
dialog.setMessage(NewWizardMessages.getString("TypePage.InterfacesDialog.message")); //$NON-NLS-1$
dialog.open();
return;
}
// ---- creation ----------------
/**
* Creates a type using the current field values.
*/
public void createType(IProgressMonitor monitor) throws CoreException, InterruptedException {
monitor.beginTask(NewWizardMessages.getString("TypePage.operationdesc"), 10); //$NON-NLS-1$
IPackageFragmentRoot root= getPackageFragmentRoot();
IPackageFragment pack= getPackageFragment();
if (pack == null) {
pack= root.getPackageFragment(""); //$NON-NLS-1$
}
if (!pack.exists()) {
String packName= pack.getElementName();
pack= root.createPackageFragment(packName, true, null);
}
monitor.worked(1);
String clName= fTypeNameDialogField.getText();
boolean isInnerClass= isEnclosingTypeSelected();
IType createdType;
ImportsStructure imports;
int indent= 0;
String[] prefOrder= ImportOrganizePreferencePage.getImportOrderPreference();
int threshold= ImportOrganizePreferencePage.getImportNumberThreshold();
String lineDelimiter= null;
if (!isInnerClass) {
ICompilationUnit parentCU= pack.getCompilationUnit(clName + ".java"); //$NON-NLS-1$
imports= new ImportsStructure(parentCU, prefOrder, threshold, false);
lineDelimiter= StubUtility.getLineDelimiterUsed(parentCU);
String content= createTypeBody(imports, lineDelimiter, parentCU);
createdType= parentCU.createType(content, null, false, new SubProgressMonitor(monitor, 5));
} else {
IType enclosingType= getEnclosingType();
// if we are working on a enclosed type that is open in an editor,
// then replace the enclosing type with its working copy
IType workingCopy= (IType) EditorUtility.getWorkingCopy(enclosingType);
if (workingCopy != null) {
enclosingType= workingCopy;
}
ICompilationUnit parentCU= enclosingType.getCompilationUnit();
imports= new ImportsStructure(parentCU, prefOrder, threshold, true);
lineDelimiter= StubUtility.getLineDelimiterUsed(enclosingType);
String content= createTypeBody(imports, lineDelimiter, parentCU);
IJavaElement[] elems= enclosingType.getChildren();
IJavaElement sibling= elems.length > 0 ? elems[0] : null;
createdType= enclosingType.createType(content, sibling, false, new SubProgressMonitor(monitor, 1));
indent= StubUtility.getIndentUsed(enclosingType) + 1;
}
// add imports for superclass/interfaces, so the type can be parsed correctly
imports.create(!isInnerClass, new SubProgressMonitor(monitor, 1));
String[] methods= evalMethods(createdType, imports, new SubProgressMonitor(monitor, 1));
if (methods.length > 0) {
for (int i= 0; i < methods.length; i++) {
createdType.createMethod(methods[i], null, false, null);
}
// add imports
imports.create(!isInnerClass, null);
}
monitor.worked(1);
ICompilationUnit cu= createdType.getCompilationUnit();
ISourceRange range;
if (isInnerClass) {
synchronized(cu) {
cu.reconcile();
}
range= createdType.getSourceRange();
} else {
range= cu.getSourceRange();
}
IBuffer buf= cu.getBuffer();
String originalContent= buf.getText(range.getOffset(), range.getLength());
String formattedContent= StubUtility.codeFormat(originalContent, indent, lineDelimiter);
buf.replace(range.getOffset(), range.getLength(), formattedContent);
if (!isInnerClass) {
String fileComment= getFileComment(cu);
if (fileComment != null) {
buf.replace(0, 0, fileComment + lineDelimiter);
}
buf.save(new SubProgressMonitor(monitor, 1), false);
} else {
monitor.worked(1);
}
fCreatedType= createdType;
monitor.done();
}
/**
* Returns the created type. Only valid after createType has been invoked
*/
public IType getCreatedType() {
return fCreatedType;
}
// ---- construct cu body----------------
private void writeSuperClass(StringBuffer buf, IImportsStructure imports) {
String typename= getSuperClass();
if (fIsClass && typename.length() > 0 && !"java.lang.Object".equals(typename)) { //$NON-NLS-1$
buf.append(" extends "); //$NON-NLS-1$
buf.append(Signature.getSimpleName(typename));
if (fSuperClass != null) {
imports.addImport(JavaModelUtil.getFullyQualifiedName(fSuperClass));
} else {
imports.addImport(typename);
}
}
}
private void writeSuperInterfaces(StringBuffer buf, IImportsStructure imports) {
List interfaces= getSuperInterfaces();
int last= interfaces.size() - 1;
if (last >= 0) {
if (fIsClass) {
buf.append(" implements "); //$NON-NLS-1$
} else {
buf.append(" extends "); //$NON-NLS-1$
}
for (int i= 0; i <= last; i++) {
String typename= (String) interfaces.get(i);
imports.addImport(typename);
buf.append(Signature.getSimpleName(typename));
if (i < last) {
buf.append(", "); //$NON-NLS-1$
}
}
}
}
/*
* Called from createType to construct the source for this type
*/
private String createTypeBody(IImportsStructure imports, String lineDelimiter, ICompilationUnit parentCU) {
StringBuffer buf= new StringBuffer();
String typeComment= getTypeComment(parentCU);
if (typeComment != null) {
buf.append(typeComment);
buf.append(lineDelimiter);
}
int modifiers= getModifiers();
buf.append(Flags.toString(modifiers));
if (modifiers != 0) {
buf.append(' ');
}
buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$
buf.append(getTypeName());
writeSuperClass(buf, imports);
writeSuperInterfaces(buf, imports);
buf.append(" {"); //$NON-NLS-1$
buf.append(lineDelimiter);
buf.append(lineDelimiter);
buf.append('}');
buf.append(lineDelimiter);
return buf.toString();
}
/**
* Called from createType to allow adding methods for the newly created type
* Returns array of sources of the methods that have to be added
* @param parent The type where the methods will be added to
*/
protected String[] evalMethods(IType parent, IImportsStructure imports, IProgressMonitor monitor) throws CoreException {
return new String[0];
}
/**
* Called from createType to get a file comment. By default the content of template
* 'filecomment' is taken.
* Returns source or null, if no file comment should be added
*/
protected String getFileComment(ICompilationUnit parentCU) {
if (CodeGenerationPreferencePage.doFileComments()) {
return getTemplate("filecomment", parentCU);
}
return null;
}
/**
* Called from createType to get a type comment.
* Returns source or null, if no type comment should be added
*/
protected String getTypeComment(ICompilationUnit parentCU) {
if (CodeGenerationPreferencePage.doCreateComments()) {
return getTemplate("typecomment", parentCU);
}
return null;
}
protected String getTemplate(String name, ICompilationUnit parentCU) {
Template[] templates= Templates.getInstance().getTemplates();
for (int i= 0; i < templates.length; i++) {
if (name.equals(templates[i].getName())) {
return evaluateTemplate(templates[i], parentCU);
// return templates[i].getPattern();
}
}
return null;
}
private String evaluateTemplate(Template template, ICompilationUnit compilationUnit) {
ContextType contextType= ContextTypeRegistry.getInstance().getContextType("java");
if (contextType == null)
return null;
try {
String string= compilationUnit.getSource();
int position= 0;
JavaContext context= new JavaContext(contextType, string, position, compilationUnit);
context.setForceEvaluation(true);
TemplateBuffer buffer= context.evaluate(template);
return buffer.getString();
} catch (CoreException e) {
JavaPlugin.log(e);
return null;
}
}
/**
* Creates the bodies of all unimplemented methods or/and all constructors
* Can be used by implementors of TypePage to add method stub checkboxes
*/
protected String[] constructInheritedMethods(IType type, boolean doConstructors, boolean doUnimplementedMethods, IImportsStructure imports, IProgressMonitor monitor) throws CoreException {
List newMethods= new ArrayList();
ITypeHierarchy hierarchy= type.newSupertypeHierarchy(monitor);
CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
if (doConstructors) {
IType superclass= hierarchy.getSuperclass(type);
if (superclass != null) {
String[] constructors= StubUtility.evalConstructors(type, superclass, settings, imports);
if (constructors != null) {
for (int i= 0; i < constructors.length; i++) {
newMethods.add(constructors[i]);
}
}
}
}
if (doUnimplementedMethods) {
String[] unimplemented= StubUtility.evalUnimplementedMethods(type, hierarchy, false, settings, null, imports);
if (unimplemented != null) {
for (int i= 0; i < unimplemented.length; i++) {
newMethods.add(unimplemented[i]);
}
}
}
return (String[]) newMethods.toArray(new String[newMethods.size()]);
}
// ---- creation ----------------
/**
* @see NewElementWizardPage#getRunnable
*/
public IRunnableWithProgress getRunnable() {
return new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
createType(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
}
}
|
5,755 |
Bug 5755 Open Type dialog is missing types
|
I can't find any of the classes in some of my packages in the Open Type(Ctrl- Shift-T) dialog. They just aren't there... Class files exist for them. 20011106
|
resolved fixed
|
115d4c2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T16:52:36Z | 2001-11-09T21:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.SharedImages;
import org.eclipse.jdt.internal.ui.dialogs.AbstractElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.MainTypeSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.MultiMainTypeSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.MultiTypeSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
/**
* Central access point for the Java UI plug-in (id <code>"org.eclipse.jdt.ui"</code>).
* This class provides static methods for:
* <ul>
* <li> creating various kinds of selection dialogs to present a collection
* of Java elements to the user and let them make a selection.</li>
* <li> opening a Java editor on a compilation unit.</li>
* </ul>
* <p>
* This class provides static methods and fields only; it is not intended to be
* instantiated or subclassed by clients.
* </p>
*/
public final class JavaUI {
private static ISharedImages fgSharedImages= null;
private JavaUI() {
// prevent instantiation of JavaUI.
}
/**
* The id of the Java plugin (value <code>"org.eclipse.jdt.ui"</code>).
*/
public static final String ID_PLUGIN= "org.eclipse.jdt.ui"; //$NON-NLS-1$
/**
* The id of the Java perspective
* (value <code>"org.eclipse.jdt.ui.JavaPerspective"</code>).
*/
public static final String ID_PERSPECTIVE= "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
/**
* The id of the Java hierarchy perspective
* (value <code>"org.eclipse.jdt.ui.JavaHierarchyPerspective"</code>).
*/
public static final String ID_HIERARCHYPERSPECTIVE= "org.eclipse.jdt.ui.JavaHierarchyPerspective"; //$NON-NLS-1$
/**
* The id of the Java action set
* (value <code>"org.eclipse.jdt.ui.JavaActionSet"</code>).
*/
public static final String ID_ACTION_SET= "org.eclipse.jdt.ui.JavaActionSet"; //$NON-NLS-1$
/**
* The id of the Java Refactoring action set
* (value <code>"org.eclipse.jdt.ui.refactoring.actionSet"</code>).
*
* @since 2.0
*/
public static final String ID_REFACTORING_ACTION_SET= "org.eclipse.jdt.ui.refactoring.actionSet"; //$NON-NLS-1$
/**
* The id of the Java Element Creation action set.
*
* @since 2.0
*/
public static final String ID_ELEMENT_CREATION_ACTION_SET= "org.eclipse.jdt.ui.JavaElementCreationActionSet"; //$NON-NLS-1$
/**
* The editor part id of the editor that presents Java compilation units
* (value <code>"org.eclipse.jdt.ui.CompilationUnitEditor"</code>).
*/
public static final String ID_CU_EDITOR= "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$
/**
* The editor part id of the editor that presents Java binary class files
* (value <code>"org.eclipse.jdt.ui.ClassFileEditor"</code>).
*/
public static final String ID_CF_EDITOR= "org.eclipse.jdt.ui.ClassFileEditor"; //$NON-NLS-1$
/**
* The editor part id of the code snippet editor
* (value <code>"org.eclipse.jdt.ui.SnippetEditor"</code>).
*/
public static final String ID_SNIPPET_EDITOR= "org.eclipse.jdt.ui.SnippetEditor"; //$NON-NLS-1$
/**
* The view part id of the Packages view
* (value <code>"org.eclipse.jdt.ui.PackageExplorer"</code>).
* <p>
* When this id is used to access
* a view part with <code>IWorkbenchPage.findView</code> or
* <code>showView</code>, the returned <code>IViewPart</code>
* can be safely cast to an <code>IPackagesViewPart</code>.
* </p>
*
* @see IPackagesViewPart
* @see org.eclipse.ui.IWorkbenchPage#findView
* @see org.eclipse.ui.IWorkbenchPage#showView
*/
public static final String ID_PACKAGES= "org.eclipse.jdt.ui.PackageExplorer"; //$NON-NLS-1$
/**
* The view part id of the type hierarchy part.
* (value <code>"org.eclipse.jdt.ui.TypeHierarchy"</code>).
* <p>
* When this id is used to access
* a view part with <code>IWorkbenchPage.findView</code> or
* <code>showView</code>, the returned <code>IViewPart</code>
* can be safely cast to an <code>ITypeHierarchyViewPart</code>.
* </p>
*
* @see ITypeHierarchyViewPart
* @see org.eclipse.ui.IWorkbenchPage#findView
* @see org.eclipse.ui.IWorkbenchPage#showView
*/
public static final String ID_TYPE_HIERARCHY= "org.eclipse.jdt.ui.TypeHierarchy"; //$NON-NLS-1$
/**
* The class org.eclipse.debug.core.model.IProcess allows attaching
* String properties to processes. The Java UI contributes a property
* page for IProcess that will show the contents of the property
* with this key.
* The intent of this property is to show the command line a process
* was launched with.
* @deprecated
*/
public final static String ATTR_CMDLINE= JavaPlugin.getPluginId()+".launcher.cmdLine"; //$NON-NLS-1$
/**
* Returns the shared images for the Java UI.
*
* @return the shared images manager
*/
public static ISharedImages getSharedImages() {
if (fgSharedImages == null)
fgSharedImages= new SharedImages();
return fgSharedImages;
}
/**
* Creates a selection dialog that lists all packages of the given Java project.
* The caller is responsible for opening the dialog with <code>Window.open</code>,
* and subsequently extracting the selected packages (of type
* <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
*
* @param parent the parent shell of the dialog to be created
* @param project the Java project
* @param style flags defining the style of the dialog; the valid flags are:
* <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>, indicating that
* packages from binary package fragment roots should be included in addition
* to those from source package fragment roots;
* <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>, indicating that
* packages from required projects should be included as well.
* @param filter the filter
* @return a new selection dialog
* @exception JavaModelException if the selection dialog could not be opened
*/
public static SelectionDialog createPackageDialog(Shell parent, IJavaProject project, int style, String filter) throws JavaModelException {
Assert.isTrue((style | IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) ==
(IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS));
IPackageFragmentRoot[] roots= null;
if ((style & IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) != 0) {
roots= project.getAllPackageFragmentRoots();
} else {
roots= project.getPackageFragmentRoots();
}
List consideredRoots= null;
if ((style & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0) {
consideredRoots= Arrays.asList(roots);
} else {
consideredRoots= new ArrayList(roots.length);
for (int i= 0; i < roots.length; i++) {
IPackageFragmentRoot root= roots[i];
if (root.getKind() != IPackageFragmentRoot.K_BINARY)
consideredRoots.add(root);
}
}
int flags= JavaElementLabelProvider.SHOW_DEFAULT;
if (consideredRoots.size() > 1)
flags= flags | JavaElementLabelProvider.SHOW_ROOT;
List packages= new ArrayList();
Iterator iter= consideredRoots.iterator();
while(iter.hasNext()) {
IPackageFragmentRoot root= (IPackageFragmentRoot)iter.next();
packages.addAll(Arrays.asList(root.getChildren()));
}
ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent, new JavaElementLabelProvider(flags));
dialog.setIgnoreCase(false);
dialog.setElements(packages.toArray()); // XXX inefficient
dialog.setFilter(filter);
return dialog;
}
/**
* @see createPackageDialog(Shell,IJavaProject,int,String)
*/
public static SelectionDialog createPackageDialog(Shell parent, IJavaProject project, int style) throws JavaModelException {
return createPackageDialog(parent, project, style, "A"); //$NON-NLS-1$
}
/**
* Creates a selection dialog that lists all packages under the given package
* fragment root.
* The caller is responsible for opening the dialog with <code>Window.open</code>,
* and subsequently extracting the selected packages (of type
* <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
*
* @param parent the parent shell of the dialog to be created
* @param root the package fragment root
* @param filter the filter
* @return a new selection dialog
* @exception JavaModelException if the selection dialog could not be opened
*/
public static SelectionDialog createPackageDialog(Shell parent, IPackageFragmentRoot root, String filter) throws JavaModelException {
ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
dialog.setIgnoreCase(false);
dialog.setElements(root.getChildren());
dialog.setFilter(filter);
return dialog;
}
/**
* @see createPackageDialog(Shell,IPackageFragmentRoot)
*/
public static SelectionDialog createPackageDialog(Shell parent, IPackageFragmentRoot root) throws JavaModelException {
return createPackageDialog(parent, root, "A"); //$NON-NLS-1$
}
/**
* Creates a selection dialog that lists all types in the given scope.
* The caller is responsible for opening the dialog with <code>Window.open</code>,
* and subsequently extracting the selected packages (of type
* <code>IType</code>) via <code>SelectionDialog.getResult</code>.
*
* @param parent the parent shell of the dialog to be created
* @param context the runnable context used to show progress when the dialog
* is being populated
* @param scope the scope that limits which types are included
* @param style flags defining the style of the dialog; the only valid values are
* <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
* <code>CONSIDER_INTERFACES</code>, or their bitwise OR
* (equivalent to <code>CONSIDER_TYPES</code>)
* @param multipleSelection <code>true</code> if multiple selection is allowed
* @param filter the filter
* @return a new selection dialog
* @exception JavaModelException if the selection dialog could not be opened
*/
public static SelectionDialog createTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) throws JavaModelException {
Assert.isTrue((style | IJavaElementSearchConstants.CONSIDER_TYPES) == IJavaElementSearchConstants.CONSIDER_TYPES);
if (multipleSelection) {
MultiTypeSelectionDialog dialog= new MultiTypeSelectionDialog(parent, context, scope, style);
dialog.setFilter(filter);
return dialog;
} else {
TypeSelectionDialog dialog= new TypeSelectionDialog(parent, context, scope, style);
dialog.setFilter(filter);
return dialog;
}
}
/**
* @see createTypeDialog(Shell,IRunnableContext,IJavaSearchScope,int,boolean,String)
*/
public static SelectionDialog createTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) throws JavaModelException {
return createTypeDialog(parent, context, scope, style, multipleSelection, "A");//$NON-NLS-1$
}
/**
* Creates a selection dialog that lists all types in the given scope containing
* a standard <code>main</code> method.
* The caller is responsible for opening the dialog with <code>Window.open</code>,
* and subsequently extracting the selected packages (of type
* <code>IType</code>) via <code>SelectionDialog.getResult</code>.
* <p>
* [Issue: IJavaSearchScope is not currently part of the Java core API.]
* </p>
*
* @param parent the parent shell of the dialog to be created
* @param context the runnable context used to show progress when the dialog
* is being populated
* @param scope the scope that limits which types are included
* @param style flags defining the style of the dialog; the only valid values are
* <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
* <code>CONSIDER_EXTERNAL_JARS</code>, or their bitwise OR, or <code>0</code>
* @param multipleSelection <code>true</code> if multiple selection is allowed
* @param filter the filter
* @return a new selection dialog
*/
public static SelectionDialog createMainTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) {
AbstractElementListSelectionDialog dialog= null;
if (multipleSelection) {
dialog= new MultiMainTypeSelectionDialog(parent, context, scope, style);
} else {
dialog= new MainTypeSelectionDialog(parent, context, scope, style);
}
dialog.setFilter(filter);
return dialog;
}
/**
* @see createMainTypeDialog(Shell,IRunnableContext,IJavaSearchScope,int,boolean,String)
*/
public static SelectionDialog createMainTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) {
return createMainTypeDialog(parent, context, scope, style, multipleSelection, "A");//$NON-NLS-1$
}
/**
* Creates a selection dialog that lists all types in the given project.
* The caller is responsible for opening the dialog with <code>Window.open</code>,
* and subsequently extracting the selected packages (of type
* <code>IType</code>) via <code>SelectionDialog.getResult</code>.
*
* @param parent the parent shell of the dialog to be created
* @param context the runnable context used to show progress when the dialog
* is being populated
* @param project the Java project
* @param style flags defining the style of the dialog; the only valid values are
* <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
* <code>CONSIDER_INTERFACES</code>, or their bitwise OR
* (equivalent to <code>CONSIDER_TYPES</code>)
* @param multipleSelection <code>true</code> if multiple selection is allowed
* @return a new selection dialog
* @exception JavaModelException if the selection dialog could not be opened
*/
public static SelectionDialog createTypeDialog(Shell parent, IRunnableContext context, IProject project, int style, boolean multipleSelection) throws JavaModelException {
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaProject[] { JavaCore.create(project) });
return createTypeDialog(parent, context, scope, style, multipleSelection);
}
/**
* Opens a Java editor on the given Java compilation unit of class file.
* If there already is an open Java editor for the given element, it is returned.
* <p>
* [Issue: Explain semantics of opening an editor on a class file.]
* </p>
* <p>
* [Issue: Explain under which conditions it returns null, throws JavaModelException,
* or throws JavaModelException.
* ]
* </p>
*
* @param element the input element; either a compilation unit
* (<code>ICompilationUnit</code>) or a class file (</code>IClassFile</code>)
* @return the editor, or </code>null</code> if wrong element type or opening failed
* @exception PartInitException if the editor could not be initialized
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its underlying resource
*/
public static IEditorPart openInEditor(IJavaElement element) throws JavaModelException, PartInitException {
return EditorUtility.openInEditor(element);
}
/**
* Reveals the source range of the given source reference element in the
* given editor. No checking is done if the editor displays a compilation unit or
* class file that contains the given source reference.
* <p>
* [Issue: Explain what is meant by that last sentence.]
* </p>
* <p>
* [Issue: Explain what happens if the source reference is from some other
* compilation unit, editor is not open, etc.]
* </p>
*
* @param part the editor displaying the compilation unit or class file
* @param element the source reference element defining the source range to be revealed
*
* @deprecated use <code>revealInEditor(IEditorPart, IJavaElement)</code> instead
*/
public static void revealInEditor(IEditorPart part, ISourceReference element) {
if (element instanceof IJavaElement)
revealInEditor(part, (IJavaElement) element);
}
/**
* Reveals the given java element in the given editor. No checking is done if the
* editor displays a compilation unit or class file that contains the given element.
* If the element is not contained, nothing happens.
* @param part the editor displaying a compilation unit or class file
* @param element the element to be revealed
*/
public static void revealInEditor(IEditorPart part, IJavaElement element) {
EditorUtility.revealInEditor(part, element);
}
/**
* Returns the working copy manager for the Java UI plug-in.
*
* @return the working copy manager for the Java UI plug-in
*/
public static IWorkingCopyManager getWorkingCopyManager() {
return JavaPlugin.getDefault().getWorkingCopyManager();
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindImplementorsAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
* Defines an action which searches for implementors of Java interfaces.
*/
public class FindImplementorsAction extends ElementSearchAction {
public FindImplementorsAction() {
super(SearchMessages.getString("Search.FindImplementorsAction.label"), new Class[] {IType.class}); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindImplementorsAction.tooltip")); //$NON-NLS-1$
setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);
}
public boolean canOperateOn(ISelection sel) {
if (!super.canOperateOn(sel))
return false;
IJavaElement element= getJavaElement(sel, true);
if (element.getElementType() == IJavaElement.TYPE)
try {
return ((IType) element).isInterface();
} catch (JavaModelException ex) {
ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
return false;
}
// should not happen: handled by super.canOperateOn
return false;
}
protected int getLimitTo() {
return IJavaSearchConstants.IMPLEMENTORS;
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/GotoMarkerAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.search.ui.ISearchResultView;
import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IPackagesViewPart;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
class GotoMarkerAction extends Action {
private IEditorPart fEditor;
public void run() {
ISearchResultView view= SearchUI.getSearchResultView();
view.getSelection();
ISelection selection= view.getSelection();
Object element= null;
if (selection instanceof IStructuredSelection)
element= ((IStructuredSelection)selection).getFirstElement();
if (element instanceof ISearchResultViewEntry) {
ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
show(entry.getSelectedMarker());
}
}
private void show(IMarker marker) {
IResource resource= marker.getResource();
if (resource == null)
return;
IWorkbenchPage wbPage= JavaPlugin.getActivePage();
IJavaElement javaElement= getJavaElement(marker);
if (javaElement == null || !javaElement.exists()) {
beep();
return;
}
if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
// Goto packages view
try {
IViewPart view= wbPage.showView(JavaUI.ID_PACKAGES);
if (view instanceof IPackagesViewPart)
((IPackagesViewPart)view).selectAndReveal(javaElement);
} catch (PartInitException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
}
} else {
if (SearchUI.reuseEditor())
showWithReuse(marker, resource, javaElement, wbPage);
else
showWithoutReuse(marker, javaElement, wbPage);
}
}
private void showWithoutReuse(IMarker marker, IJavaElement javaElement, IWorkbenchPage wbPage) {
if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
// Goto packages view
try {
IViewPart view= wbPage.showView(JavaUI.ID_PACKAGES);
if (view instanceof IPackagesViewPart)
((IPackagesViewPart)view).selectAndReveal(javaElement);
} catch (PartInitException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
}
return;
}
IEditorPart editor= null;
try {
editor= EditorUtility.openInEditor(javaElement, false);
} catch (PartInitException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
}
if (editor != null)
editor.gotoMarker(marker);
}
private void showWithReuse(IMarker marker, IResource resource, IJavaElement javaElement, IWorkbenchPage wbPage) {
if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
// Goto packages view
try {
IViewPart view= wbPage.showView(JavaUI.ID_PACKAGES);
if (view instanceof IPackagesViewPart)
((IPackagesViewPart)view).selectAndReveal(javaElement);
} catch (PartInitException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
}
}
else if (!isBinary(javaElement)) {
if (resource instanceof IFile)
showInEditor(marker, wbPage, new FileEditorInput((IFile)resource), JavaUI.ID_CU_EDITOR);
}
else {
IClassFile cf= getClassFile(javaElement);
if (cf != null)
showInEditor(marker, wbPage, new InternalClassFileEditorInput(cf), JavaUI.ID_CF_EDITOR);
}
}
private void showInEditor(IMarker marker, IWorkbenchPage page, IEditorInput input, String editorId) {
IEditorPart editor= null;
IEditorPart[] editorParts= page.getEditors();
for (int i= 0; i < editorParts.length; i++) {
IEditorPart part= editorParts[i];
if (input.equals(part.getEditorInput())) {
editor= part;
break;
}
}
if (editor == null) {
if (fEditor != null && !fEditor.isDirty())
page.closeEditor(fEditor, false);
try {
editor= page.openEditor(input, editorId, false);
} catch (PartInitException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
return;
}
} else {
page.bringToTop(editor);
}
if (editor != null) {
editor.gotoMarker(marker);
fEditor = editor;
}
}
private IClassFile getClassFile(IJavaElement jElement) {
if (jElement instanceof IMember)
return ((IMember)jElement).getClassFile();
return null;
}
private IJavaElement getJavaElement(IMarker marker) {
try {
return JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));
} catch (CoreException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
}
}
private boolean isBinary(IJavaElement jElement) {
if (jElement instanceof IMember)
return ((IMember)jElement).isBinary();
return false;
}
private void beep() {
Shell shell= JavaPlugin.getActiveWorkbenchShell();
if (shell != null && shell.getDisplay() != null)
shell.getDisplay().beep();
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaElementAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICodeAssist;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
/**
* Abstract class for actions that run on IJavaElement.
*/
public abstract class JavaElementAction extends Action {
// A dummy which can't be selected in the UI
protected static final IJavaElement RETURN_WITHOUT_BEEP= JavaCore.create(JavaPlugin.getDefault().getWorkspace().getRoot());
private Class[] fValidTypes;
public JavaElementAction(String label, Class[] validTypes) {
super(label);
fValidTypes= validTypes;
}
public boolean canOperateOn(ISelection sel) {
boolean hasSelection= !sel.isEmpty();
if (!hasSelection || fValidTypes == null)
return hasSelection;
if (fValidTypes.length == 0)
return false;
IJavaElement element= getJavaElement(sel, true);
if (element != null) {
for (int i= 0; i < fValidTypes.length; i++) {
if (fValidTypes[i].isInstance(element))
return true;
}
}
return false;
}
public void run() {
if (!canOperateOn(getSelection())) {
beep();
return;
}
IJavaElement element= getJavaElement(getSelection(), false);
if (element == null) {
beep();
return;
}
else if (element == RETURN_WITHOUT_BEEP)
return;
run(element);
}
protected abstract void run(IJavaElement element);
private IJavaElement getJavaElement(IJavaElement o, boolean silent) {
if (o == null)
return null;
switch (o.getElementType()) {
case IJavaElement.COMPILATION_UNIT:
return findType((ICompilationUnit)o, silent);
case IJavaElement.CLASS_FILE:
return findType((IClassFile)o);
}
return o;
}
private IJavaElement getJavaElement(IMarker o, boolean silent) {
try {
return getJavaElement(JavaCore.create((String) ((IMarker) o).getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID)), silent);
} catch (CoreException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
}
}
protected IJavaElement getJavaElement(ISelection selection, boolean silent) {
if (selection instanceof ITextSelection)
return getJavaElement((ITextSelection) selection);
else
if (selection instanceof IStructuredSelection)
return getJavaElement((IStructuredSelection) selection, silent);
return null;
}
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((ISelection)o, silent);
else if (o instanceof ISearchResultViewEntry)
return getJavaElement((ISearchResultViewEntry)o, silent);
return null;
}
private IJavaElement getJavaElement(ISearchResultViewEntry entry, boolean silent) {
if (entry != null)
return getJavaElement(entry.getSelectedMarker(), silent);
return null;
}
private IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) {
if (selection.size() == 1)
// Selection only enabled if one element selected.
return getJavaElement(selection.getFirstElement(), silent);
return null;
}
protected IJavaElement getJavaElement(ITextSelection selection) {
IWorkbenchPage wbPage= JavaPlugin.getActivePage();
if (wbPage == null)
return null;
IEditorPart editorPart= wbPage.getActiveEditor();
if (editorPart == null)
return null;
ICodeAssist assist= getCodeAssist(editorPart);
ITextSelection ts= (ITextSelection) selection;
if (assist != null) {
IJavaElement[] elements;
try {
elements= assist.codeSelect(ts.getOffset(), ts.getLength());
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
}
if (elements != null && elements.length > 0) {
if (elements.length == 1 || !shouldUserBePrompted())
return elements[0];
else if (elements.length > 1)
return chooseFromList(elements);
}
}
return null;
}
public ISelection getSelection() {
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();
if (window != null)
return window.getSelectionService().getSelection();
else
return TextSelection.emptySelection();
}
protected ICodeAssist getCodeAssist(IEditorPart editorPart) {
IEditorInput input= editorPart.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput)input).getClassFile();
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input);
}
private IJavaElement chooseFromList(IJavaElement[] openChoices) {
int flags= JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_QUALIFIED;
ILabelProvider labelProvider= new JavaElementLabelProvider(flags);
ElementListSelectionDialog dialog= new ElementListSelectionDialog(JavaPlugin.getActiveWorkbenchShell(), labelProvider);
dialog.setTitle(SearchMessages.getString("SearchElementSelectionDialog.title")); //$NON-NLS-1$
dialog.setMessage(SearchMessages.getString("SearchElementSelectionDialog.message")); //$NON-NLS-1$
dialog.setElements(openChoices);
if (dialog.open() == dialog.OK)
return (IJavaElement)dialog.getFirstResult();
return null;
}
/**
* Answers if a dialog should prompt the user for a unique Java element
*/
protected boolean shouldUserBePrompted() {
return true;
}
protected void beep() {
Shell shell= JavaPlugin.getActiveWorkbenchShell();
if (shell != null && shell.getDisplay() != null)
shell.getDisplay().beep();
}
protected IJavaElement findType(ICompilationUnit cu, boolean silent) {
IType[] types= null;
try {
types= cu.getAllTypes();
} catch (JavaModelException ex) {
// silent mode
ExceptionHandler.log(ex, SearchMessages.getString("OpenTypeAction.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("ShowTypeHierarchyAction.selectionDialog.title"); //$NON-NLS-1$
String message = SearchMessages.getString("ShowTypeHierarchyAction.selectionDialog.message"); //$NON-NLS-1$
Shell parent= JavaPlugin.getActiveWorkbenchShell();
int flags= (JavaElementLabelProvider.SHOW_DEFAULT);
ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent, new JavaElementLabelProvider(flags));
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setElements(types);
if (dialog.open() == dialog.OK)
return (IType)dialog.getFirstResult();
else
return RETURN_WITHOUT_BEEP;
}
protected IType findType(IClassFile cf) {
IType mainType;
try {
mainType= cf.getType();
} catch (JavaModelException ex) {
ExceptionHandler.log(ex, SearchMessages.getString("OpenTypeAction.error.open.message")); //$NON-NLS-1$
return null;
}
return mainType;
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.search.ui.ISearchPage;
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.search.ui.IWorkingSet;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICodeAssist;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.RowLayouter;
public class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants {
public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$
// Dialog store id constants
private final static String PAGE_NAME= "JavaSearchPage"; //$NON-NLS-1$
private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE"; //$NON-NLS-1$
private static List fgPreviousSearchPatterns= new ArrayList(20);
private SearchPatternData fInitialData;
private IJavaElement fJavaElement;
private boolean fFirstTime= true;
private IDialogSettings fDialogSettings;
private boolean fIsCaseSensitive;
private Combo fPattern;
private ISearchPageContainer fContainer;
private Button fCaseSensitive;
private Button[] fSearchFor;
private String[] fSearchForText= {
SearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.searchFor.field")}; //$NON-NLS-1$
private Button[] fLimitTo;
private String[] fLimitToText= {
SearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.limitTo.allOccurrences"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.limitTo.readReferences"), //$NON-NLS-1$
SearchMessages.getString("SearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
private class SearchPatternData {
int searchFor;
int limitTo;
String pattern;
boolean isCaseSensitive;
IJavaElement javaElement;
int scope;
IWorkingSet workingSet;
public SearchPatternData(int s, int l, String p, IJavaElement element) {
this(s, l, p, fIsCaseSensitive || element != null, element, ISearchPageContainer.WORKSPACE_SCOPE, null);
}
public SearchPatternData(int s, int l, String p, boolean i, IJavaElement element, int scope, IWorkingSet workingSet) {
searchFor= s;
limitTo= l;
pattern= p;
isCaseSensitive= i;
javaElement= element;
this.scope= scope;
this.workingSet= workingSet;
}
}
//---- Action Handling ------------------------------------------------
public boolean performAction() {
SearchUI.activateSearchResultView();
SearchPatternData data= getPatternData();
IWorkspace workspace= JavaPlugin.getWorkspace();
// Setup search scope
IJavaSearchScope scope= null;
String scopeDescription= ""; //$NON-NLS-1$
switch (getContainer().getSelectedScope()) {
case ISearchPageContainer.WORKSPACE_SCOPE:
scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
scope= SearchEngine.createWorkspaceScope();
break;
case ISearchPageContainer.SELECTION_SCOPE:
scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$
scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(getSelection());
break;
case ISearchPageContainer.WORKING_SET_SCOPE:
IWorkingSet workingSet= getContainer().getSelectedWorkingSet();
// should not happen - just to be sure
if (workingSet == null)
return false;
scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", new String[] {workingSet.getName()}); //$NON-NLS-1$
scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(getContainer().getSelectedWorkingSet());
ElementSearchAction.updateLRUWorkingSet(getContainer().getSelectedWorkingSet());
}
JavaSearchResultCollector collector= new JavaSearchResultCollector();
JavaSearchOperation op= null;
if (data.javaElement != null && getPattern().equals(fInitialData.pattern))
op= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector);
else {
data.javaElement= null;
op= new JavaSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector);
}
Shell shell= getControl().getShell();
try {
getContainer().getRunnableContext().run(true, true, op);
} catch (InvocationTargetException ex) {
ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$
return false;
} catch (InterruptedException ex) {
return false;
}
return true;
}
private int getLimitTo() {
for (int i= 0; i < fLimitTo.length; i++) {
if (fLimitTo[i].getSelection())
return i;
}
return -1;
}
private void setLimitTo(int searchFor) {
fLimitTo[DECLARATIONS].setEnabled(true);
fLimitTo[IMPLEMENTORS].setEnabled(false);
fLimitTo[REFERENCES].setEnabled(true);
fLimitTo[ALL_OCCURRENCES].setEnabled(true);
fLimitTo[READ_ACCESSES].setEnabled(false);
fLimitTo[WRITE_ACCESSES].setEnabled(false);
if (!(searchFor == TYPE || searchFor == INTERFACE) && fLimitTo[IMPLEMENTORS].getSelection()) {
fLimitTo[IMPLEMENTORS].setSelection(false);
fLimitTo[REFERENCES].setSelection(true);
}
if (!(searchFor == FIELD) && (getLimitTo() == READ_ACCESSES || getLimitTo() == WRITE_ACCESSES)) {
fLimitTo[getLimitTo()].setSelection(false);
fLimitTo[REFERENCES].setSelection(true);
}
switch (searchFor) {
case TYPE | INTERFACE:
fLimitTo[IMPLEMENTORS].setEnabled(true);
case FIELD:
fLimitTo[READ_ACCESSES].setEnabled(true);
fLimitTo[WRITE_ACCESSES].setEnabled(true);
break;
default :
break;
}
}
private String[] getPreviousSearchPatterns() {
// Search results are not persistent
int patternCount= fgPreviousSearchPatterns.size();
String [] patterns= new String[patternCount];
for (int i= 0; i < patternCount; i++)
patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;
return patterns;
}
private int getSearchFor() {
for (int i= 0; i < fSearchFor.length; i++) {
if (fSearchFor[i].getSelection())
return i;
}
Assert.isTrue(false, "shouldNeverHappen"); //$NON-NLS-1$
return -1;
}
private String getPattern() {
return fPattern.getText();
}
/**
* Return search pattern data and update previous searches.
* An existing entry will be updated.
*/
private SearchPatternData getPatternData() {
String pattern= getPattern();
SearchPatternData match= null;
int i= 0;
int size= fgPreviousSearchPatterns.size();
while (match == null && i < size) {
match= (SearchPatternData) fgPreviousSearchPatterns.get(i);
i++;
if (!pattern.equals(match.pattern))
match= null;
};
if (match == null) {
match= new SearchPatternData(
getSearchFor(),
getLimitTo(),
pattern,
fCaseSensitive.getSelection(),
fJavaElement,
getContainer().getSelectedScope(),
getContainer().getSelectedWorkingSet());
fgPreviousSearchPatterns.add(match);
}
else {
match.searchFor= getSearchFor();
match.limitTo= getLimitTo();
match.isCaseSensitive= fCaseSensitive.getSelection();
match.javaElement= fJavaElement;
match.scope= getContainer().getSelectedScope();
match.workingSet= getContainer().getSelectedWorkingSet();
};
return match;
}
/*
* Implements method from IDialogPage
*/
public void setVisible(boolean visible) {
if (visible && fPattern != null) {
if (fFirstTime) {
fFirstTime= false;
// Set item and text here to prevent page from resizing
fPattern.setItems(getPreviousSearchPatterns());
initSelections();
}
fPattern.setFocus();
getContainer().setPerformActionEnabled(fPattern.getText().length() > 0 && getContainer().hasValidScope());
}
super.setVisible(visible);
}
public boolean isValid() {
return true;
}
//---- Widget creation ------------------------------------------------
/**
* Creates the page's content.
*/
public void createControl(Composite parent) {
readConfiguration();
GridData gd;
Composite result= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.numColumns= 2; layout.makeColumnsEqualWidth= true;
layout.horizontalSpacing= 10;
result.setLayout(layout);
RowLayouter layouter= new RowLayouter(layout.numColumns);
gd= new GridData();
gd.horizontalAlignment= gd.FILL;
layouter.setDefaultGridData(gd, 0);
layouter.setDefaultGridData(gd, 1);
layouter.setDefaultSpan();
layouter.perform(createExpression(result));
layouter.perform(createSearchFor(result), createLimitTo(result), -1);
SelectionAdapter javaElementInitializer= new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (getSearchFor() == fInitialData.searchFor)
fJavaElement= fInitialData.javaElement;
else
fJavaElement= null;
setLimitTo(getSearchFor());
updateCaseSensitiveCheckbox();
}
};
fSearchFor[TYPE].addSelectionListener(javaElementInitializer);
fSearchFor[METHOD].addSelectionListener(javaElementInitializer);
fSearchFor[FIELD].addSelectionListener(javaElementInitializer);
fSearchFor[CONSTRUCTOR].addSelectionListener(javaElementInitializer);
fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer);
setControl(result);
WorkbenchHelp.setHelp(result, new Object[] { IJavaHelpContextIds.JAVA_SEARCH_PAGE });
}
private Control createExpression(Composite parent) {
Group result= new Group(parent, SWT.NONE);
result.setText(SearchMessages.getString("SearchPage.expression.label")); //$NON-NLS-1$
GridLayout layout= new GridLayout();
layout.numColumns= 2;
result.setLayout(layout);
// Pattern combo
fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);
fPattern.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handlePatternSelected();
}
});
fPattern.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
getContainer().setPerformActionEnabled(getPattern().length() > 0 && getContainer().hasValidScope());
updateCaseSensitiveCheckbox();
}
});
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint= convertWidthInCharsToPixels(30);
gd.horizontalSpan= 2;
fPattern.setLayoutData(gd);
// Pattern info
Label label= new Label(result, SWT.LEFT);
label.setText(SearchMessages.getString("SearchPage.expression.pattern")); //$NON-NLS-1$
// Ignore case checkbox
fCaseSensitive= new Button(result, SWT.CHECK);
fCaseSensitive.setText(SearchMessages.getString("SearchPage.expression.caseSensitive")); //$NON-NLS-1$
gd= new GridData(); gd.horizontalAlignment= gd.END;
fCaseSensitive.setLayoutData(gd);
fCaseSensitive.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fIsCaseSensitive= fCaseSensitive.getSelection();
writeConfiguration();
}
});
return result;
}
private void updateCaseSensitiveCheckbox() {
if (fInitialData != null && getPattern().equals(fInitialData.pattern) && fJavaElement != null) {
fCaseSensitive.setEnabled(false);
fCaseSensitive.setSelection(true);
}
else {
fCaseSensitive.setEnabled(true);
fCaseSensitive.setSelection(fIsCaseSensitive);
}
}
private void handlePatternSelected() {
if (fPattern.getSelectionIndex() < 0)
return;
int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();
fInitialData= (SearchPatternData) fgPreviousSearchPatterns.get(index);
for (int i= 0; i < fSearchFor.length; i++)
fSearchFor[i].setSelection(false);
for (int i= 0; i < fLimitTo.length; i++)
fLimitTo[i].setSelection(false);
fSearchFor[fInitialData.searchFor].setSelection(true);
setLimitTo(fInitialData.searchFor);
fLimitTo[fInitialData.limitTo].setSelection(true);
fPattern.setText(fInitialData.pattern);
fIsCaseSensitive= fInitialData.isCaseSensitive;
fJavaElement= fInitialData.javaElement;
fCaseSensitive.setEnabled(fJavaElement == null);
fCaseSensitive.setSelection(fInitialData.isCaseSensitive);
if (fInitialData.workingSet != null)
getContainer().setSelectedWorkingSet(fInitialData.workingSet);
else
getContainer().setSelectedScope(fInitialData.scope);
}
private Control createSearchFor(Composite parent) {
Group result= new Group(parent, SWT.NONE);
result.setText(SearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$
GridLayout layout= new GridLayout();
layout.numColumns= 3;
result.setLayout(layout);
result.setLayoutData(new GridData(GridData.FILL_VERTICAL));
fSearchFor= new Button[fSearchForText.length];
for (int i= 0; i < fSearchForText.length; i++) {
Button button= new Button(result, SWT.RADIO);
button.setText(fSearchForText[i]);
fSearchFor[i]= button;
}
return result;
}
private Control createLimitTo(Composite parent) {
Group result= new Group(parent, SWT.NONE);
result.setText(SearchMessages.getString("SearchPage.limitTo.label")); //$NON-NLS-1$
GridLayout layout= new GridLayout();
layout.numColumns= 2;
result.setLayout(layout);
fLimitTo= new Button[fLimitToText.length];
for (int i= 0; i < fLimitToText.length; i++) {
Button button= new Button(result, SWT.RADIO);
button.setText(fLimitToText[i]);
fLimitTo[i]= button;
}
return result;
}
private void initSelections() {
ISelection selection= getSelection();
fInitialData= tryTypedTextSelection(selection);
if (fInitialData == null)
fInitialData= trySelection(selection);
if (fInitialData == null)
fInitialData= trySimpleTextSelection(selection);
if (fInitialData == null)
fInitialData= getDefaultInitValues();
fJavaElement= fInitialData.javaElement;
fCaseSensitive.setSelection(fInitialData.isCaseSensitive);
fCaseSensitive.setEnabled(fInitialData.javaElement == null);
fSearchFor[fInitialData.searchFor].setSelection(true);
setLimitTo(fInitialData.searchFor);
fLimitTo[fInitialData.limitTo].setSelection(true);
fPattern.setText(fInitialData.pattern);
}
private SearchPatternData tryTypedTextSelection(ISelection selection) {
if (selection instanceof ITextSelection) {
IEditorPart e= getEditorPart();
if (e != null) {
ITextSelection ts= (ITextSelection)selection;
ICodeAssist assist= getCodeAssist(e);
if (assist != null) {
IJavaElement[] elements= null;
try {
elements= assist.codeSelect(ts.getOffset(), ts.getLength());
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
}
if (elements != null && elements.length > 0) {
IJavaElement javaElement= null;
if (elements.length == 1)
javaElement= elements[0];
// else
// javaElement= chooseFromList(elements);
if (javaElement != null)
return determineInitValuesFrom(javaElement);
}
}
}
}
return null;
}
private ICodeAssist getCodeAssist(IEditorPart editorPart) {
IEditorInput input= editorPart.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput)input).getClassFile();
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input);
}
private SearchPatternData trySelection(ISelection selection) {
if (!(selection instanceof IStructuredSelection))
return null;
Object o= ((IStructuredSelection)selection).getFirstElement();
if (o instanceof IJavaElement) {
return determineInitValuesFrom((IJavaElement)o);
} else if (o instanceof ISearchResultViewEntry) {
IJavaElement element= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());
return determineInitValuesFrom(element);
} else if (o instanceof IAdaptable) {
IJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class);
if (element != null) {
return determineInitValuesFrom(element);
} else {
IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
return new SearchPatternData(TYPE, REFERENCES, adapter.getLabel(o), null);
}
}
return null;
}
private IJavaElement getJavaElement(IMarker marker) {
try {
return JavaCore.create((String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));
} catch (CoreException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
}
}
private SearchPatternData determineInitValuesFrom(IJavaElement element) {
if (element == null)
return null;
int searchFor= UNKNOWN;
int limitTo= UNKNOWN;
String pattern= null;
switch (element.getElementType()) {
case IJavaElement.PACKAGE_FRAGMENT:
searchFor= PACKAGE;
limitTo= REFERENCES;
pattern= element.getElementName();
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
searchFor= PACKAGE;
limitTo= REFERENCES;
pattern= element.getElementName();
break;
case IJavaElement.PACKAGE_DECLARATION:
searchFor= PACKAGE;
limitTo= REFERENCES;
pattern= element.getElementName();
break;
case IJavaElement.IMPORT_DECLARATION:
pattern= element.getElementName();
IImportDeclaration declaration= (IImportDeclaration)element;
if (declaration.isOnDemand()) {
searchFor= PACKAGE;
int index= pattern.lastIndexOf('.');
pattern= pattern.substring(0, index);
} else {
searchFor= TYPE;
}
limitTo= DECLARATIONS;
break;
case IJavaElement.TYPE:
searchFor= TYPE;
limitTo= REFERENCES;
pattern= JavaModelUtil.getFullyQualifiedName((IType)element);
break;
case IJavaElement.COMPILATION_UNIT:
ICompilationUnit cu= (ICompilationUnit)element;
String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(".")); //$NON-NLS-1$
IType mainType= cu.getType(mainTypeName);
mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType);
try {
mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName);
if (mainType == null) {
// fetch type which is declared first in the file
IType[] types= cu.getTypes();
if (types.length > 0)
mainType= types[0];
else
break;
}
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
break;
}
searchFor= TYPE;
element= mainType;
limitTo= REFERENCES;
pattern= JavaModelUtil.getFullyQualifiedName((IType)mainType);
break;
case IJavaElement.CLASS_FILE:
IClassFile cf= (IClassFile)element;
try {
mainType= cf.getType();
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
break;
}
if (mainType == null)
break;
element= mainType;
searchFor= TYPE;
limitTo= REFERENCES;
pattern= JavaModelUtil.getFullyQualifiedName(mainType);
break;
case IJavaElement.FIELD:
searchFor= FIELD;
limitTo= REFERENCES;
IType type= ((IField)element).getDeclaringType();
StringBuffer buffer= new StringBuffer();
buffer.append(JavaModelUtil.getFullyQualifiedName(type));
buffer.append('.');
buffer.append(element.getElementName());
pattern= buffer.toString();
break;
case IJavaElement.METHOD:
searchFor= METHOD;
try {
IMethod method= (IMethod)element;
if (method.isConstructor())
searchFor= CONSTRUCTOR;
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
break;
}
limitTo= REFERENCES;
pattern= PrettySignature.getMethodSignature((IMethod)element);
break;
}
if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null)
return new SearchPatternData(searchFor, limitTo, pattern, element);
return null;
}
private SearchPatternData trySimpleTextSelection(ISelection selection) {
SearchPatternData result= null;
if (selection instanceof ITextSelection) {
BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));
String text;
try {
text= reader.readLine();
if (text == null)
text= ""; //$NON-NLS-1$
} catch (IOException ex) {
text= ""; //$NON-NLS-1$
}
result= new SearchPatternData(TYPE, REFERENCES, text, null);
}
return result;
}
private SearchPatternData getDefaultInitValues() {
return new SearchPatternData(TYPE, REFERENCES, "", null); //$NON-NLS-1$
}
private IJavaElement chooseFromList(IJavaElement[] openChoices) {
int flags= JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_QUALIFIED;
ILabelProvider labelProvider= new JavaElementLabelProvider(flags);
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle(SearchMessages.getString("SearchElementSelectionDialog.title")); //$NON-NLS-1$
dialog.setMessage(SearchMessages.getString("SearchElementSelectionDialog.message")); //$NON-NLS-1$
dialog.setElements(openChoices);
if (dialog.open() == dialog.OK)
return (IJavaElement)dialog.getFirstResult();
return null;
}
/*
* Implements method from ISearchPage
*/
public void setContainer(ISearchPageContainer container) {
fContainer= container;
}
/**
* Returns the search page's container.
*/
private ISearchPageContainer getContainer() {
return fContainer;
}
/**
* Returns the current active selection.
*/
private ISelection getSelection() {
return fContainer.getSelection();
}
/**
* Returns the current active editor part.
*/
private IEditorPart getEditorPart() {
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page= window.getActivePage();
if (page != null)
return page.getActiveEditor();
}
return null;
}
//--------------- Configuration handling --------------
/**
* Returns the page settings for this Java search page.
*
* @return the page settings to be used
*/
private IDialogSettings getDialogSettings() {
IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
fDialogSettings= settings.getSection(PAGE_NAME);
if (fDialogSettings == null)
fDialogSettings= settings.addNewSection(PAGE_NAME);
return fDialogSettings;
}
/**
* Initializes itself from the stored page settings.
*/
private void readConfiguration() {
IDialogSettings s= getDialogSettings();
fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE);
}
/**
* Stores it current configuration in the dialog store.
*/
private void writeConfiguration() {
IDialogSettings s= getDialogSettings();
s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchSubGroup.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;
import org.eclipse.jdt.internal.ui.actions.GroupContext;
import org.eclipse.jdt.ui.IContextMenuConstants;
/**
* Contribute Java search specific menu elements.
*/
public abstract class JavaSearchSubGroup extends ContextMenuGroup {
public static final String GROUP_ID= IContextMenuConstants.GROUP_SEARCH;
abstract protected ElementSearchAction[] getActions();
abstract protected String getName();
public void fill(IMenuManager manager, GroupContext context) {
MenuManager javaSearchMM= new MenuManager(getName(), GROUP_ID);
ElementSearchAction[] actions= getActions();
for (int i= 0; i < actions.length; i++) {
ElementSearchAction action= actions[i];
if (action.canOperateOn(context.getSelection()))
javaSearchMM.add(action);
}
if (!javaSearchMM.isEmpty())
manager.add(javaSearchMM);
}
public MenuManager getMenuManagerForGroup(boolean isTextSelectionEmpty) {
MenuManager javaSearchMM= new MenuManager(getName(), GROUP_ID); //$NON-NLS-1$
ElementSearchAction[] actions= getActions();
if (!isTextSelectionEmpty) {
for (int i= 0; i < actions.length; i++)
javaSearchMM.add(actions[i]);
}
return javaSearchMM;
}
}
|
8,581 |
Bug 8581 Switch J Search to StructuredContentProvider
| null |
resolved fixed
|
e50b1da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:09:36Z | 2002-01-28T12:13:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/WorkingSetAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.ISelection;
public class WorkingSetAction extends ElementSearchAction {
private ElementSearchAction fAction;
public WorkingSetAction(ElementSearchAction action, String workingSetName) {
super(workingSetName, null);
Assert.isNotNull(action);
fAction= action;
}
public void run() {
fAction.run();
}
public boolean canOperateOn(ISelection sel) {
return fAction.canOperateOn(sel);
}
protected int getLimitTo() {
return -1;
}
}
|
8,686 |
Bug 8686 Type Hierarchy: no methods shown
|
Smoke for build 20020129 - open type hierarchy on TestCase - switch to Subtype hierarchy - observe: you don't see any members of TestCase - lock the method view observe: now it is impossible to get the members back. You can click on any node in the upper class pane. You have to unlock the view
|
verified fixed
|
fdd0d6b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:34:01Z | 2002-01-29T16:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.typehierarchy;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.IInputSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.help.ViewContextComputer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.ITypeHierarchyViewPart;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.AddMethodStubAction;
import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;
import org.eclipse.jdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.packageview.BuildGroup;
import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup;
import org.eclipse.jdt.internal.ui.reorg.ReorgGroup;
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
import org.eclipse.jdt.internal.ui.viewsupport.ErrorTickImageProvider;
import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
/**
* view showing the supertypes/subtypes of its input.
*/
public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart {
public static final int VIEW_ID_TYPE= 2;
public static final int VIEW_ID_SUPER= 0;
public static final int VIEW_ID_SUB= 1;
public static final int VIEW_ORIENTATION_VERTICAL= 0;
public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
public static final int VIEW_ORIENTATION_SINGLE= 2;
private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
private static final String TAG_INPUT= "input"; //$NON-NLS-1$
private static final String TAG_VIEW= "view"; //$NON-NLS-1$
private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
// the selected type in the hierarchy view
private IType fSelectedType;
// input element or null
private IJavaElement fInputElement;
// history of inut elements. No duplicates
private ArrayList fInputHistory;
private IMemento fMemento;
private IProblemChangedListener fHierarchyProblemListener;
private TypeHierarchyLifeCycle fHierarchyLifeCycle;
private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
private MethodsViewer fMethodsViewer;
private int fCurrentViewerIndex;
private TypeHierarchyViewer[] fAllViewers;
private SelectionProviderMediator fSelectionProviderMediator;
private ISelectionChangedListener fSelectionChangedListener;
private boolean fIsEnableMemberFilter;
private SashForm fTypeMethodsSplitter;
private PageBook fViewerbook;
private PageBook fPagebook;
private Label fNoHierarchyShownLabel;
private Label fEmptyTypesViewer;
private ViewForm fTypeViewerViewForm;
private ViewForm fMethodViewerViewForm;
private CLabel fMethodViewerPaneLabel;
private JavaUILabelProvider fPaneLabelProvider;
private IDialogSettings fDialogSettings;
private ToggleViewAction[] fViewActions;
private HistoryDropDownAction fHistoryDropDownAction;
private ToggleOrientationAction[] fToggleOrientationActions;
private int fCurrentOrientation;
private EnableMemberFilterAction fEnableMemberFilterAction;
private AddMethodStubAction fAddStubAction;
private FocusOnTypeAction fFocusOnTypeAction;
private FocusOnSelectionAction fFocusOnSelectionAction;
private IPartListener fPartListener;
public TypeHierarchyViewPart() {
fSelectedType= null;
fInputElement= null;
fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
doTypeHierarchyChanged(typeHierarchy, changedTypes);
}
};
fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
fHierarchyProblemListener= null;
fIsEnableMemberFilter= false;
fInputHistory= new ArrayList();
fAllViewers= null;
fViewActions= new ToggleViewAction[] {
new ToggleViewAction(this, VIEW_ID_TYPE),
new ToggleViewAction(this, VIEW_ID_SUPER),
new ToggleViewAction(this, VIEW_ID_SUB)
};
fDialogSettings= JavaPlugin.getDefault().getDialogSettings();
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)
};
fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
fFocusOnTypeAction= new FocusOnTypeAction(this);
fPaneLabelProvider= new JavaUILabelProvider(new ErrorTickImageProvider());
fAddStubAction= new AddMethodStubAction();
fFocusOnSelectionAction= new FocusOnSelectionAction(this);
fPartListener= new IPartListener() {
public void partActivated(IWorkbenchPart part) {
if (part instanceof IEditorPart)
editorActivated((IEditorPart) part);
}
public void partBroughtToTop(IWorkbenchPart part) {}
public void partClosed(IWorkbenchPart part) {}
public void partDeactivated(IWorkbenchPart part) {}
public void partOpened(IWorkbenchPart part) {}
};
fSelectionChangedListener= new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
doSelectionChanged(event);
}
};
}
/**
* Adds the entry if new. Inserted at the beginning of the history entries list.
*/
private void addHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
fInputHistory.remove(entry);
}
fInputHistory.add(0, entry);
fHistoryDropDownAction.setEnabled(true);
}
private void updateHistoryEntries() {
for (int i= fInputHistory.size() - 1; i >= 0; i--) {
IJavaElement type= (IJavaElement) fInputHistory.get(i);
if (!type.exists()) {
fInputHistory.remove(i);
}
}
fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
}
/**
* Goes to the selected entry, without updating the order of history entries.
*/
public void gotoHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
updateInput(entry);
}
}
/**
* Gets all history entries.
*/
public IJavaElement[] getHistoryEntries() {
if (fInputHistory.size() > 0) {
updateHistoryEntries();
}
return (IJavaElement[]) fInputHistory.toArray(new IJavaElement[fInputHistory.size()]);
}
/**
* Sets the history entries
*/
public void setHistoryEntries(IJavaElement[] elems) {
fInputHistory.clear();
for (int i= 0; i < elems.length; i++) {
fInputHistory.add(elems[i]);
}
updateHistoryEntries();
}
/**
* Selects an member in the methods list
*/
public void selectMember(IMember member) {
ICompilationUnit cu= member.getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
member= (IMember) cu.getOriginal(member);
if (member == null) {
return;
}
}
Control methodControl= fMethodsViewer.getControl();
if (methodControl != null && !methodControl.isDisposed()) {
fMethodsViewer.getControl().setFocus();
}
fMethodsViewer.setSelection(new StructuredSelection(member), true);
}
/**
* @deprecated
*/
public IType getInput() {
if (fInputElement instanceof IType) {
return (IType) fInputElement;
}
return null;
}
/**
* Sets the input to a new type
* @deprecated
*/
public void setInput(IType type) {
setInputElement(type);
}
/**
* Returns the input element of the type hierarchy.
* Can be of type <code>IType</code> or <code>IPackageFragment</code>
*/
public IJavaElement getInputElement() {
return fInputElement;
}
/**
* Sets the input to a new element.
*/
public void setInputElement(IJavaElement element) {
if (element != null) {
if (element instanceof IMember) {
ICompilationUnit cu= ((IMember) element).getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
element= cu.getOriginal(element);
if (!element.exists()) {
MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message"));
return;
}
}
if (element.getElementType() == IJavaElement.METHOD || element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.INITIALIZER) {
element= ((IMember) element).getDeclaringType();
}
}
}
if (element != null && !element.equals(fInputElement)) {
addHistoryEntry(element);
}
updateInput(element);
}
/**
* Changes the input to a new type
*/
private void updateInput(IJavaElement inputElement) {
IJavaElement prevInput= fInputElement;
fInputElement= inputElement;
if (fInputElement == null) {
clearInput();
} else {
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e);
clearInput();
return;
}
fPagebook.showPage(fTypeMethodsSplitter);
if (inputElement.getElementType() != IJavaElement.TYPE) {
setView(VIEW_ID_TYPE);
}
// turn off member filtering
setMemberFilter(null);
fIsEnableMemberFilter= false;
if (!fInputElement.equals(prevInput)) {
updateHierarchyViewer();
}
IType root= getSelectableType(fInputElement);
internalSelectType(root, true);
updateMethodViewer(root);
updateToolbarButtons();
updateTitle();
enableMemberFilter(false);
}
}
private void clearInput() {
fInputElement= null;
fHierarchyLifeCycle.freeHierarchy();
updateHierarchyViewer();
updateToolbarButtons();
}
/*
* @see IWorbenchPart#setFocus
*/
public void setFocus() {
fPagebook.setFocus();
}
/*
* @see IWorkbenchPart#dispose
*/
public void dispose() {
fHierarchyLifeCycle.freeHierarchy();
fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
fPaneLabelProvider.dispose();
getSite().getPage().removePartListener(fPartListener);
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
if (fMethodsViewer != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fMethodsViewer);
}
super.dispose();
}
private Control createTypeViewerControl(Composite parent) {
fViewerbook= new PageBook(parent, SWT.NULL);
KeyListener keyListener= createKeyListener();
HierarchyLabelProvider lprovider= new HierarchyLabelProvider(this);
// Create the viewers
TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);
fAllViewers= new TypeHierarchyViewer[3];
fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
fAllViewers[VIEW_ID_SUB]= subTypesViewer;
fAllViewers[VIEW_ID_TYPE]= vajViewer;
int currViewerIndex;
try {
currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
if (currViewerIndex < 0 || currViewerIndex > 2) {
currViewerIndex= VIEW_ID_TYPE;
}
} catch (NumberFormatException e) {
currViewerIndex= VIEW_ID_TYPE;
}
fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setInput(fAllViewers[i]);
}
// force the update
fCurrentViewerIndex= -1;
setView(currViewerIndex);
return fViewerbook;
}
private KeyListener createKeyListener() {
return new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (event.stateMask == 0) {
if (event.keyCode == SWT.F4) {
OpenTypeHierarchyUtil.open(getSite().getSelectionProvider().getSelection(), getSite().getWorkbenchWindow());
return;
} else if (event.keyCode == SWT.F5) {
updateHierarchyViewer();
return;
}
}
viewPartKeyShortcuts(event);
}
};
}
private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
typesViewer.getControl().setVisible(false);
typesViewer.getControl().addKeyListener(keyListener);
typesViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillTypesViewerContextMenu(typesViewer, menu);
}
}, cotextHelpId, getSite());
typesViewer.addSelectionChangedListener(fSelectionChangedListener);
}
private Control createMethodViewerControl(Composite parent) {
fMethodsViewer= new MethodsViewer(parent, this);
fMethodsViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillMethodsViewerContextMenu(menu);
}
}, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
Control control= fMethodsViewer.getTable();
control.addKeyListener(createKeyListener());
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fMethodsViewer);
return control;
}
private void initDragAndDrop() {
Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
int ops= DND.DROP_COPY;
DragSource source= new DragSource(fMethodsViewer.getControl(), ops);
source.setTransfer(transfers);
source.addDragListener(new BasicSelectionTransferDragAdapter(fMethodsViewer));
for (int i= 0; i < fAllViewers.length; i++) {
TypeHierarchyViewer curr= fAllViewers[i];
curr.addDropSupport(ops, transfers, new TypeHierarchyTransferDropAdapter(curr));
}
}
private void viewPartKeyShortcuts(KeyEvent event) {
if (event.stateMask == SWT.CTRL) {
if (event.character == '1') {
setView(VIEW_ID_TYPE);
} else if (event.character == '2') {
setView(VIEW_ID_SUPER);
} else if (event.character == '3') {
setView(VIEW_ID_SUB);
}
}
}
/**
* Returns the inner component in a workbench part.
* @see IWorkbenchPart#createPartControl
*/
public void createPartControl(Composite container) {
fPagebook= new PageBook(container, SWT.NONE);
// page 1 of pagebook (viewers)
fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
fTypeMethodsSplitter.setVisible(false);
fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
fTypeViewerViewForm.setContent(typeViewerControl);
fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
fTypeMethodsSplitter.setWeights(new int[] {35, 65});
Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
fMethodViewerViewForm.setContent(methodViewerPart);
fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
initDragAndDrop();
ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
// page 2 of pagebook (no hierarchy label)
fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
MenuManager menu= new MenuManager();
menu.add(fFocusOnTypeAction);
fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
fPagebook.showPage(fNoHierarchyShownLabel);
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);
// set the filter menu items
IActionBars actionBars= getViewSite().getActionBars();
IMenuManager viewMenu= actionBars.getMenuManager();
for (int i= 0; i < fToggleOrientationActions.length; i++) {
viewMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
// fill the method viewer toolbar
ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);
lowertbmanager.add(fEnableMemberFilterAction);
lowertbmanager.add(new Separator());
fMethodsViewer.contributeToToolBar(lowertbmanager);
lowertbmanager.update(true);
// selection provider
int nHierarchyViewers= fAllViewers.length;
Viewer[] trackedViewers= new Viewer[nHierarchyViewers + 1];
for (int i= 0; i < nHierarchyViewers; i++) {
trackedViewers[i]= fAllViewers[i];
}
trackedViewers[nHierarchyViewers]= fMethodsViewer;
fSelectionProviderMediator= new SelectionProviderMediator(trackedViewers);
IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
getSite().setSelectionProvider(fSelectionProviderMediator);
getSite().getPage().addPartListener(fPartListener);
IJavaElement input= determineInputElement();
if (fMemento != null) {
restoreState(fMemento, input);
} else if (input != null) {
setInputElement(input);
} else {
setViewerVisibility(false);
}
ReorgGroup.addGlobalReorgActions(getViewSite().getActionBars(), getViewSite().getSelectionProvider());
// fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing
WorkbenchHelp.setHelp(fPagebook, new ViewContextComputer(this, IJavaHelpContextIds.TYPE_HIERARCHY_VIEW));
}
/**
* called from ToggleOrientationAction.
* @param orientation VIEW_ORIENTATION_SINGLE, VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
*/
public void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
boolean methodViewerNeedsUpdate= false;
if (fMethodViewerViewForm != null && !fMethodViewerViewForm.isDisposed()
&& fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {
if (orientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(false);
enableMemberFilter(false);
updateMethodViewer(null);
} else {
if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(true);
methodViewerNeedsUpdate= true;
}
boolean horizontal= orientation == VIEW_ORIENTATION_HORIZONTAL;
fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
}
updateMainToolbar(orientation);
fTypeMethodsSplitter.layout();
}
for (int i= 0; i < fToggleOrientationActions.length; i++) {
fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation());
}
fCurrentOrientation= orientation;
if (methodViewerNeedsUpdate) {
updateMethodViewer(fSelectedType);
}
fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
}
}
private void updateMainToolbar(int orientation) {
IActionBars actionBars= getViewSite().getActionBars();
IToolBarManager tbmanager= actionBars.getToolBarManager();
if (orientation == VIEW_ORIENTATION_HORIZONTAL) {
clearMainToolBar(tbmanager);
ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);
fillMainToolBar(new ToolBarManager(typeViewerToolBar));
fTypeViewerViewForm.setTopLeft(typeViewerToolBar);
} else {
fTypeViewerViewForm.setTopLeft(null);
fillMainToolBar(tbmanager);
}
}
private void fillMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.add(fHistoryDropDownAction);
for (int i= 0; i < fViewActions.length; i++) {
tbmanager.add(fViewActions[i]);
}
tbmanager.update(false);
}
private void clearMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.update(false);
}
/**
* Creates the context menu for the hierarchy viewers
*/
private void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
viewer.contributeToContextMenu(menu);
IStructuredSelection selection= (IStructuredSelection)viewer.getSelection();
if (JavaBasePreferencePage.openTypeHierarchyInPerspective()) {
addOpenPerspectiveItem(menu, selection);
}
addOpenWithMenu(menu, selection);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnTypeAction);
if (fFocusOnSelectionAction.canActionBeAdded())
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnSelectionAction);
addRefactoring(menu, viewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, viewer);
}
/**
* Creates the context menu for the method viewer
*/
private void fillMethodsViewerContextMenu(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
fMethodsViewer.contributeToContextMenu(menu);
if (fSelectedType != null && fAddStubAction.init(fSelectedType, fMethodsViewer.getSelection())) {
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddStubAction);
}
//menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fMethodsViewer));
addOpenWithMenu(menu, (IStructuredSelection)fMethodsViewer.getSelection());
addRefactoring(menu, fMethodsViewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, fMethodsViewer);
}
private void addRefactoring(IMenuManager menu, IInputSelectionProvider viewer){
MenuManager refactoring= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.refactor")); //$NON-NLS-1$
ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, viewer);
if (!refactoring.isEmpty())
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring);
}
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
// If one file is selected get it.
// Otherwise, do not show the "open with" menu.
if (selection.size() != 1)
return;
Object element= selection.getFirstElement();
if (!(element instanceof IJavaElement))
return;
IResource resource= null;
try {
resource= ((IJavaElement)element).getUnderlyingResource();
} catch(JavaModelException e) {
// ignore
}
if (!(resource instanceof IFile))
return;
// Create a menu flyout.
MenuManager submenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.open")); //$NON-NLS-1$
submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
private void addOpenPerspectiveItem(IMenuManager menu, IStructuredSelection selection) {
OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, selection);
}
/**
* Toggles between the empty viewer page and the hierarchy
*/
private void setViewerVisibility(boolean showHierarchy) {
if (showHierarchy) {
fViewerbook.showPage(getCurrentViewer().getControl());
} else {
fViewerbook.showPage(fEmptyTypesViewer);
}
}
/**
* Sets the member filter. <code>null</code> disables member filtering.
*/
private void setMemberFilter(IMember[] memberFilter) {
Assert.isNotNull(fAllViewers);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setMemberFilter(memberFilter);
}
}
private IType getSelectableType(IJavaElement elem) {
ISelection sel= null;
if (elem.getElementType() != IJavaElement.TYPE) {
return (IType) getCurrentViewer().getTreeRootType();
} else {
return (IType) elem;
}
}
private void internalSelectType(IMember elem, boolean reveal) {
TypeHierarchyViewer viewer= getCurrentViewer();
viewer.removeSelectionChangedListener(fSelectionChangedListener);
viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
viewer.addSelectionChangedListener(fSelectionChangedListener);
}
private void internalSelectMember(IMember member) {
fMethodsViewer.removeSelectionChangedListener(fSelectionChangedListener);
fMethodsViewer.setSelection(member != null ? new StructuredSelection(member) : StructuredSelection.EMPTY);
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
}
/**
* When the input changed or the hierarchy pane becomes visible,
* <code>updateHierarchyViewer<code> brings up the correct view and refreshes
* the current tree
*/
private void updateHierarchyViewer() {
if (fInputElement == null) {
fPagebook.showPage(fNoHierarchyShownLabel);
} else {
if (getCurrentViewer().containsElements() != null) {
Runnable runnable= new Runnable() {
public void run() {
getCurrentViewer().updateContent();
}
};
BusyIndicator.showWhile(getDisplay(), runnable);
if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {
setViewerVisibility(true);
}
} else {
fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInputElement.getElementName())); //$NON-NLS-1$
setViewerVisibility(false);
}
}
}
private void updateMethodViewer(IType input) {
if (input != fMethodsViewer.getInput() && !fIsEnableMemberFilter && fCurrentOrientation != VIEW_ORIENTATION_SINGLE) {
if (input != null) {
fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));
fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));
} else {
fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$
fMethodViewerPaneLabel.setImage(null);
}
fMethodsViewer.setInput(input);
}
}
private void doSelectionChanged(SelectionChangedEvent e) {
if (e.getSelectionProvider() == fMethodsViewer) {
methodSelectionChanged(e.getSelection());
} else {
typeSelectionChanged(e.getSelection());
}
}
private void methodSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (fIsEnableMemberFilter) {
IMember[] memberFilter= null;
if (nSelected > 0) {
memberFilter= new IMember[nSelected];
selected.toArray(memberFilter);
}
setMemberFilter(memberFilter);
updateHierarchyViewer();
updateTitle();
internalSelectType(fSelectedType, true);
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), fMethodsViewer);
}
}
}
private void typeSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (nSelected != 0) {
List types= new ArrayList(nSelected);
for (int i= nSelected-1; i >= 0; i--) {
Object elem= selected.get(i);
if (elem instanceof IType && !types.contains(elem)) {
types.add(elem);
}
}
if (types.size() == 1) {
fSelectedType= (IType) types.get(0);
updateMethodViewer(fSelectedType);
} else if (types.size() == 0) {
// method selected, no change
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), getCurrentViewer());
}
} else {
fSelectedType= null;
updateMethodViewer(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;
}
IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
if (editorPart != null && (elem instanceof IJavaElement)) {
try {
getSite().getPage().removePartListener(fPartListener);
EditorUtility.openInEditor(elem, false);
EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
getSite().getPage().addPartListener(fPartListener);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
private Display getDisplay() {
if (fPagebook != null && !fPagebook.isDisposed()) {
return fPagebook.getDisplay();
}
return null;
}
private boolean isChildVisible(Composite pb, Control child) {
Control[] children= pb.getChildren();
for (int i= 0; i < children.length; i++) {
if (children[i] == child && children[i].isVisible())
return true;
}
return false;
}
private void updateTitle() {
String viewerTitle= getCurrentViewer().getTitle();
String tooltip;
String title;
if (fInputElement != null) {
String[] args= new String[] { viewerTitle, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT) };
title= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.title", args); //$NON-NLS-1$
tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$
} else {
title= viewerTitle;
tooltip= viewerTitle;
}
setTitle(title);
setTitleToolTip(tooltip);
}
private void updateToolbarButtons() {
boolean isType= fInputElement instanceof IType;
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
if (action.getViewerIndex() == VIEW_ID_TYPE) {
action.setEnabled(fInputElement != null);
} else {
action.setEnabled(isType);
}
}
}
/**
* Sets the current view (see view id)
* called from ToggleViewAction. Must be called after creation of the viewpart.
*/
public void setView(int viewerIndex) {
Assert.isNotNull(fAllViewers);
if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {
fCurrentViewerIndex= viewerIndex;
updateHierarchyViewer();
if (fInputElement != null) {
ISelection currSelection= getCurrentViewer().getSelection();
if (currSelection == null || currSelection.isEmpty()) {
internalSelectType(getSelectableType(fInputElement), false);
}
if (!fIsEnableMemberFilter) {
typeSelectionChanged(currSelection);
}
}
updateTitle();
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
fHierarchyProblemListener= getCurrentViewer();
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fHierarchyProblemListener);
fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);
getCurrentViewer().getTree().setFocus();
}
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
action.setChecked(fCurrentViewerIndex == action.getViewerIndex());
}
}
/**
* Gets the curret active view index.
*/
public int getViewIndex() {
return fCurrentViewerIndex;
}
private TypeHierarchyViewer getCurrentViewer() {
return fAllViewers[fCurrentViewerIndex];
}
/**
* called from EnableMemberFilterAction.
* Must be called after creation of the viewpart.
*/
public void enableMemberFilter(boolean on) {
if (on != fIsEnableMemberFilter) {
fIsEnableMemberFilter= on;
if (!on) {
IType methodViewerInput= (IType) fMethodsViewer.getInput();
setMemberFilter(null);
updateHierarchyViewer();
updateTitle();
if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {
// avoid that the method view changes content by selecting the previous input
internalSelectType(methodViewerInput, true);
} else if (fSelectedType != null) {
// choose a input that exists
internalSelectType(fSelectedType, true);
updateMethodViewer(fSelectedType);
}
} else {
methodSelectionChanged(fMethodsViewer.getSelection());
}
}
fEnableMemberFilterAction.setChecked(on);
}
/**
* Called from ITypeHierarchyLifeCycleListener.
* Can be called from any thread
*/
private void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final IType[] changedTypes) {
Display display= getDisplay();
if (display != null) {
display.asyncExec(new Runnable() {
public void run() {
doTypeHierarchyChangedOnViewers(changedTypes);
}
});
}
}
private void doTypeHierarchyChangedOnViewers(IType[] changedTypes) {
if (fHierarchyLifeCycle.getHierarchy() == null || !fHierarchyLifeCycle.getHierarchy().exists()) {
clearInput();
} else {
if (changedTypes == null) {
// hierarchy change
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
clearInput();
return;
}
updateHierarchyViewer();
} else {
// elements in hierarchy modified
if (getCurrentViewer().isMethodFiltering()) {
if (changedTypes.length == 1) {
getCurrentViewer().refresh(changedTypes[0]);
} else {
updateHierarchyViewer();
}
} else {
getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );
}
}
}
}
/**
* Determines the input element to be used initially .
*/
private IJavaElement determineInputElement() {
Object input= getSite().getPage().getInput();
if (input instanceof IJavaElement) {
return (IJavaElement) input;
}
return null;
}
/*
* @see IViewPart#init
*/
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento= memento;
}
/*
* @see ViewPart#saveState(IMemento)
*/
public void saveState(IMemento memento) {
if (fPagebook == null) {
// part has not been created
if (fMemento != null) { //Keep the old state;
memento.putMemento(fMemento);
}
return;
}
if (fInputElement != null) {
memento.putString(TAG_INPUT, fInputElement.getHandleIdentifier());
}
memento.putInteger(TAG_VIEW, getViewIndex());
memento.putInteger(TAG_ORIENTATION, fCurrentOrientation);
int weigths[]= fTypeMethodsSplitter.getWeights();
int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
int position= bar != null ? bar.getSelection() : 0;
memento.putInteger(TAG_VERTICAL_SCROLL, position);
IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
if (selection != null) {
memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
}
fMethodsViewer.saveState(memento);
}
/**
* Restores the type hierarchy settings from a memento.
*/
private void restoreState(IMemento memento, IJavaElement defaultInput) {
IJavaElement input= defaultInput;
String elementId= memento.getString(TAG_INPUT);
if (elementId != null) {
input= JavaCore.create(elementId);
if (!input.exists()) {
input= null;
}
}
setInputElement(input);
Integer viewerIndex= memento.getInteger(TAG_VIEW);
if (viewerIndex != null) {
setView(viewerIndex.intValue());
}
Integer orientation= memento.getInteger(TAG_ORIENTATION);
if (orientation != null) {
setOrientation(orientation.intValue());
}
Integer ratio= memento.getInteger(TAG_RATIO);
if (ratio != null) {
fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });
}
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
if (bar != null) {
Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
if (vScroll != null) {
bar.setSelection(vScroll.intValue());
}
}
String selectionId= memento.getString(TAG_SELECTION);
if (selectionId != null) {
IJavaElement elem= JavaCore.create(selectionId);
if (getCurrentViewer().isElementShown(elem) && elem instanceof IMember) {
internalSelectType((IMember)elem, false);
}
}
fMethodsViewer.restoreState(memento);
}
/**
* Link selection to active editor.
*/
private void editorActivated(IEditorPart editor) {
if (!JavaBasePreferencePage.linkTypeHierarchySelectionToEditor()) {
return;
}
if (fInputElement == null) {
// no type hierarchy shown
return;
}
IJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class);
try {
TypeHierarchyViewer currentViewer= getCurrentViewer();
if (elem instanceof IClassFile) {
IType type= ((IClassFile)elem).getType();
if (currentViewer.isElementShown(type)) {
internalSelectType(type, true);
updateMethodViewer(type);
}
} else if (elem instanceof ICompilationUnit) {
IType[] allTypes= ((ICompilationUnit)elem).getAllTypes();
for (int i= 0; i < allTypes.length; i++) {
if (currentViewer.isElementShown(allTypes[i])) {
internalSelectType(allTypes[i], true);
updateMethodViewer(allTypes[i]);
return;
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
}
}
}
|
8,757 |
Bug 8757 Type Hierarchy view - Error decoration not removed when error fixed
|
Eclipse 200201129-I Windows 2000 1) Focus on the hierarchy of class (one that has a few super classes). 2) Cause a compile error to happen in the class and save the change. 3) Select a different class in the hierarchy and then select the class with the error. Note that now the label at the top of the methods list in the TypeHierarchy view nows has a red x on it. I don't know why you have to flip between classes to make this red x appear - it should appear as soon as you save the change that caused a compile error. 4) Now fix the compile error and save the change. The red x does not disappear from the label above the methods list.
|
resolved fixed
|
2a59a99
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T18:52:29Z | 2002-01-30T17:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.typehierarchy;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.IInputSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.help.ViewContextComputer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.ITypeHierarchyViewPart;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.AddMethodStubAction;
import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;
import org.eclipse.jdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.packageview.BuildGroup;
import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup;
import org.eclipse.jdt.internal.ui.reorg.ReorgGroup;
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
import org.eclipse.jdt.internal.ui.viewsupport.ErrorTickImageProvider;
import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
/**
* view showing the supertypes/subtypes of its input.
*/
public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart {
public static final int VIEW_ID_TYPE= 2;
public static final int VIEW_ID_SUPER= 0;
public static final int VIEW_ID_SUB= 1;
public static final int VIEW_ORIENTATION_VERTICAL= 0;
public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
public static final int VIEW_ORIENTATION_SINGLE= 2;
private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
private static final String TAG_INPUT= "input"; //$NON-NLS-1$
private static final String TAG_VIEW= "view"; //$NON-NLS-1$
private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
// the selected type in the hierarchy view
private IType fSelectedType;
// input element or null
private IJavaElement fInputElement;
// history of inut elements. No duplicates
private ArrayList fInputHistory;
private IMemento fMemento;
private IProblemChangedListener fHierarchyProblemListener;
private TypeHierarchyLifeCycle fHierarchyLifeCycle;
private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
private MethodsViewer fMethodsViewer;
private int fCurrentViewerIndex;
private TypeHierarchyViewer[] fAllViewers;
private SelectionProviderMediator fSelectionProviderMediator;
private ISelectionChangedListener fSelectionChangedListener;
private boolean fIsEnableMemberFilter;
private SashForm fTypeMethodsSplitter;
private PageBook fViewerbook;
private PageBook fPagebook;
private Label fNoHierarchyShownLabel;
private Label fEmptyTypesViewer;
private ViewForm fTypeViewerViewForm;
private ViewForm fMethodViewerViewForm;
private CLabel fMethodViewerPaneLabel;
private JavaUILabelProvider fPaneLabelProvider;
private IDialogSettings fDialogSettings;
private ToggleViewAction[] fViewActions;
private HistoryDropDownAction fHistoryDropDownAction;
private ToggleOrientationAction[] fToggleOrientationActions;
private int fCurrentOrientation;
private EnableMemberFilterAction fEnableMemberFilterAction;
private AddMethodStubAction fAddStubAction;
private FocusOnTypeAction fFocusOnTypeAction;
private FocusOnSelectionAction fFocusOnSelectionAction;
private IPartListener fPartListener;
public TypeHierarchyViewPart() {
fSelectedType= null;
fInputElement= null;
fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
doTypeHierarchyChanged(typeHierarchy, changedTypes);
}
};
fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
fHierarchyProblemListener= null;
fIsEnableMemberFilter= false;
fInputHistory= new ArrayList();
fAllViewers= null;
fViewActions= new ToggleViewAction[] {
new ToggleViewAction(this, VIEW_ID_TYPE),
new ToggleViewAction(this, VIEW_ID_SUPER),
new ToggleViewAction(this, VIEW_ID_SUB)
};
fDialogSettings= JavaPlugin.getDefault().getDialogSettings();
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)
};
fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
fFocusOnTypeAction= new FocusOnTypeAction(this);
fPaneLabelProvider= new JavaUILabelProvider(new ErrorTickImageProvider());
fAddStubAction= new AddMethodStubAction();
fFocusOnSelectionAction= new FocusOnSelectionAction(this);
fPartListener= new IPartListener() {
public void partActivated(IWorkbenchPart part) {
if (part instanceof IEditorPart)
editorActivated((IEditorPart) part);
}
public void partBroughtToTop(IWorkbenchPart part) {}
public void partClosed(IWorkbenchPart part) {}
public void partDeactivated(IWorkbenchPart part) {}
public void partOpened(IWorkbenchPart part) {}
};
fSelectionChangedListener= new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
doSelectionChanged(event);
}
};
}
/**
* Adds the entry if new. Inserted at the beginning of the history entries list.
*/
private void addHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
fInputHistory.remove(entry);
}
fInputHistory.add(0, entry);
fHistoryDropDownAction.setEnabled(true);
}
private void updateHistoryEntries() {
for (int i= fInputHistory.size() - 1; i >= 0; i--) {
IJavaElement type= (IJavaElement) fInputHistory.get(i);
if (!type.exists()) {
fInputHistory.remove(i);
}
}
fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
}
/**
* Goes to the selected entry, without updating the order of history entries.
*/
public void gotoHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
updateInput(entry);
}
}
/**
* Gets all history entries.
*/
public IJavaElement[] getHistoryEntries() {
if (fInputHistory.size() > 0) {
updateHistoryEntries();
}
return (IJavaElement[]) fInputHistory.toArray(new IJavaElement[fInputHistory.size()]);
}
/**
* Sets the history entries
*/
public void setHistoryEntries(IJavaElement[] elems) {
fInputHistory.clear();
for (int i= 0; i < elems.length; i++) {
fInputHistory.add(elems[i]);
}
updateHistoryEntries();
}
/**
* Selects an member in the methods list
*/
public void selectMember(IMember member) {
ICompilationUnit cu= member.getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
member= (IMember) cu.getOriginal(member);
if (member == null) {
return;
}
}
Control methodControl= fMethodsViewer.getControl();
if (methodControl != null && !methodControl.isDisposed()) {
fMethodsViewer.getControl().setFocus();
}
fMethodsViewer.setSelection(new StructuredSelection(member), true);
}
/**
* @deprecated
*/
public IType getInput() {
if (fInputElement instanceof IType) {
return (IType) fInputElement;
}
return null;
}
/**
* Sets the input to a new type
* @deprecated
*/
public void setInput(IType type) {
setInputElement(type);
}
/**
* Returns the input element of the type hierarchy.
* Can be of type <code>IType</code> or <code>IPackageFragment</code>
*/
public IJavaElement getInputElement() {
return fInputElement;
}
/**
* Sets the input to a new element.
*/
public void setInputElement(IJavaElement element) {
if (element != null) {
if (element instanceof IMember) {
ICompilationUnit cu= ((IMember) element).getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
element= cu.getOriginal(element);
if (!element.exists()) {
MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message"));
return;
}
}
if (element.getElementType() == IJavaElement.METHOD || element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.INITIALIZER) {
element= ((IMember) element).getDeclaringType();
}
}
}
if (element != null && !element.equals(fInputElement)) {
addHistoryEntry(element);
}
updateInput(element);
}
/**
* Changes the input to a new type
*/
private void updateInput(IJavaElement inputElement) {
IJavaElement prevInput= fInputElement;
fInputElement= inputElement;
if (fInputElement == null) {
clearInput();
} else {
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e);
clearInput();
return;
}
fPagebook.showPage(fTypeMethodsSplitter);
if (inputElement.getElementType() != IJavaElement.TYPE) {
setView(VIEW_ID_TYPE);
}
// turn off member filtering
setMemberFilter(null);
fIsEnableMemberFilter= false;
if (!fInputElement.equals(prevInput)) {
updateHierarchyViewer();
}
IType root= getSelectableType(fInputElement);
internalSelectType(root, true);
updateMethodViewer(root);
updateToolbarButtons();
updateTitle();
enableMemberFilter(false);
}
}
private void clearInput() {
fInputElement= null;
fHierarchyLifeCycle.freeHierarchy();
updateHierarchyViewer();
updateToolbarButtons();
}
/*
* @see IWorbenchPart#setFocus
*/
public void setFocus() {
fPagebook.setFocus();
}
/*
* @see IWorkbenchPart#dispose
*/
public void dispose() {
fHierarchyLifeCycle.freeHierarchy();
fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
fPaneLabelProvider.dispose();
getSite().getPage().removePartListener(fPartListener);
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
if (fMethodsViewer != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fMethodsViewer);
}
super.dispose();
}
private Control createTypeViewerControl(Composite parent) {
fViewerbook= new PageBook(parent, SWT.NULL);
KeyListener keyListener= createKeyListener();
HierarchyLabelProvider lprovider= new HierarchyLabelProvider(this);
// Create the viewers
TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);
fAllViewers= new TypeHierarchyViewer[3];
fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
fAllViewers[VIEW_ID_SUB]= subTypesViewer;
fAllViewers[VIEW_ID_TYPE]= vajViewer;
int currViewerIndex;
try {
currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
if (currViewerIndex < 0 || currViewerIndex > 2) {
currViewerIndex= VIEW_ID_TYPE;
}
} catch (NumberFormatException e) {
currViewerIndex= VIEW_ID_TYPE;
}
fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setInput(fAllViewers[i]);
}
// force the update
fCurrentViewerIndex= -1;
setView(currViewerIndex);
return fViewerbook;
}
private KeyListener createKeyListener() {
return new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (event.stateMask == 0) {
if (event.keyCode == SWT.F4) {
OpenTypeHierarchyUtil.open(getSite().getSelectionProvider().getSelection(), getSite().getWorkbenchWindow());
return;
} else if (event.keyCode == SWT.F5) {
updateHierarchyViewer();
return;
}
}
viewPartKeyShortcuts(event);
}
};
}
private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
typesViewer.getControl().setVisible(false);
typesViewer.getControl().addKeyListener(keyListener);
typesViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillTypesViewerContextMenu(typesViewer, menu);
}
}, cotextHelpId, getSite());
typesViewer.addSelectionChangedListener(fSelectionChangedListener);
}
private Control createMethodViewerControl(Composite parent) {
fMethodsViewer= new MethodsViewer(parent, this);
fMethodsViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillMethodsViewerContextMenu(menu);
}
}, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
Control control= fMethodsViewer.getTable();
control.addKeyListener(createKeyListener());
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fMethodsViewer);
return control;
}
private void initDragAndDrop() {
Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
int ops= DND.DROP_COPY;
DragSource source= new DragSource(fMethodsViewer.getControl(), ops);
source.setTransfer(transfers);
source.addDragListener(new BasicSelectionTransferDragAdapter(fMethodsViewer));
for (int i= 0; i < fAllViewers.length; i++) {
TypeHierarchyViewer curr= fAllViewers[i];
curr.addDropSupport(ops, transfers, new TypeHierarchyTransferDropAdapter(curr));
}
}
private void viewPartKeyShortcuts(KeyEvent event) {
if (event.stateMask == SWT.CTRL) {
if (event.character == '1') {
setView(VIEW_ID_TYPE);
} else if (event.character == '2') {
setView(VIEW_ID_SUPER);
} else if (event.character == '3') {
setView(VIEW_ID_SUB);
}
}
}
/**
* Returns the inner component in a workbench part.
* @see IWorkbenchPart#createPartControl
*/
public void createPartControl(Composite container) {
fPagebook= new PageBook(container, SWT.NONE);
// page 1 of pagebook (viewers)
fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
fTypeMethodsSplitter.setVisible(false);
fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
fTypeViewerViewForm.setContent(typeViewerControl);
fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
fTypeMethodsSplitter.setWeights(new int[] {35, 65});
Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
fMethodViewerViewForm.setContent(methodViewerPart);
fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
initDragAndDrop();
ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
// page 2 of pagebook (no hierarchy label)
fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
MenuManager menu= new MenuManager();
menu.add(fFocusOnTypeAction);
fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
fPagebook.showPage(fNoHierarchyShownLabel);
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);
// set the filter menu items
IActionBars actionBars= getViewSite().getActionBars();
IMenuManager viewMenu= actionBars.getMenuManager();
for (int i= 0; i < fToggleOrientationActions.length; i++) {
viewMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
// fill the method viewer toolbar
ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);
lowertbmanager.add(fEnableMemberFilterAction);
lowertbmanager.add(new Separator());
fMethodsViewer.contributeToToolBar(lowertbmanager);
lowertbmanager.update(true);
// selection provider
int nHierarchyViewers= fAllViewers.length;
Viewer[] trackedViewers= new Viewer[nHierarchyViewers + 1];
for (int i= 0; i < nHierarchyViewers; i++) {
trackedViewers[i]= fAllViewers[i];
}
trackedViewers[nHierarchyViewers]= fMethodsViewer;
fSelectionProviderMediator= new SelectionProviderMediator(trackedViewers);
IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
getSite().setSelectionProvider(fSelectionProviderMediator);
getSite().getPage().addPartListener(fPartListener);
IJavaElement input= determineInputElement();
if (fMemento != null) {
restoreState(fMemento, input);
} else if (input != null) {
setInputElement(input);
} else {
setViewerVisibility(false);
}
ReorgGroup.addGlobalReorgActions(getViewSite().getActionBars(), getViewSite().getSelectionProvider());
// fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing
WorkbenchHelp.setHelp(fPagebook, new ViewContextComputer(this, IJavaHelpContextIds.TYPE_HIERARCHY_VIEW));
}
/**
* called from ToggleOrientationAction.
* @param orientation VIEW_ORIENTATION_SINGLE, VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
*/
public void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
boolean methodViewerNeedsUpdate= false;
if (fMethodViewerViewForm != null && !fMethodViewerViewForm.isDisposed()
&& fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {
if (orientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(false);
enableMemberFilter(false);
updateMethodViewer(null);
} else {
if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(true);
methodViewerNeedsUpdate= true;
}
boolean horizontal= orientation == VIEW_ORIENTATION_HORIZONTAL;
fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
}
updateMainToolbar(orientation);
fTypeMethodsSplitter.layout();
}
for (int i= 0; i < fToggleOrientationActions.length; i++) {
fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation());
}
fCurrentOrientation= orientation;
if (methodViewerNeedsUpdate) {
updateMethodViewer(fSelectedType);
}
fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
}
}
private void updateMainToolbar(int orientation) {
IActionBars actionBars= getViewSite().getActionBars();
IToolBarManager tbmanager= actionBars.getToolBarManager();
if (orientation == VIEW_ORIENTATION_HORIZONTAL) {
clearMainToolBar(tbmanager);
ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);
fillMainToolBar(new ToolBarManager(typeViewerToolBar));
fTypeViewerViewForm.setTopLeft(typeViewerToolBar);
} else {
fTypeViewerViewForm.setTopLeft(null);
fillMainToolBar(tbmanager);
}
}
private void fillMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.add(fHistoryDropDownAction);
for (int i= 0; i < fViewActions.length; i++) {
tbmanager.add(fViewActions[i]);
}
tbmanager.update(false);
}
private void clearMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.update(false);
}
/**
* Creates the context menu for the hierarchy viewers
*/
private void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
viewer.contributeToContextMenu(menu);
IStructuredSelection selection= (IStructuredSelection)viewer.getSelection();
if (JavaBasePreferencePage.openTypeHierarchyInPerspective()) {
addOpenPerspectiveItem(menu, selection);
}
addOpenWithMenu(menu, selection);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnTypeAction);
if (fFocusOnSelectionAction.canActionBeAdded())
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnSelectionAction);
addRefactoring(menu, viewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, viewer);
}
/**
* Creates the context menu for the method viewer
*/
private void fillMethodsViewerContextMenu(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
fMethodsViewer.contributeToContextMenu(menu);
if (fSelectedType != null && fAddStubAction.init(fSelectedType, fMethodsViewer.getSelection())) {
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddStubAction);
}
//menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fMethodsViewer));
addOpenWithMenu(menu, (IStructuredSelection)fMethodsViewer.getSelection());
addRefactoring(menu, fMethodsViewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, fMethodsViewer);
}
private void addRefactoring(IMenuManager menu, IInputSelectionProvider viewer){
MenuManager refactoring= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.refactor")); //$NON-NLS-1$
ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, viewer);
if (!refactoring.isEmpty())
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring);
}
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
// If one file is selected get it.
// Otherwise, do not show the "open with" menu.
if (selection.size() != 1)
return;
Object element= selection.getFirstElement();
if (!(element instanceof IJavaElement))
return;
IResource resource= null;
try {
resource= ((IJavaElement)element).getUnderlyingResource();
} catch(JavaModelException e) {
// ignore
}
if (!(resource instanceof IFile))
return;
// Create a menu flyout.
MenuManager submenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.open")); //$NON-NLS-1$
submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
private void addOpenPerspectiveItem(IMenuManager menu, IStructuredSelection selection) {
OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, selection);
}
/**
* Toggles between the empty viewer page and the hierarchy
*/
private void setViewerVisibility(boolean showHierarchy) {
if (showHierarchy) {
fViewerbook.showPage(getCurrentViewer().getControl());
} else {
fViewerbook.showPage(fEmptyTypesViewer);
}
}
/**
* Sets the member filter. <code>null</code> disables member filtering.
*/
private void setMemberFilter(IMember[] memberFilter) {
Assert.isNotNull(fAllViewers);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setMemberFilter(memberFilter);
}
}
private IType getSelectableType(IJavaElement elem) {
ISelection sel= null;
if (elem.getElementType() != IJavaElement.TYPE) {
return (IType) getCurrentViewer().getTreeRootType();
} else {
return (IType) elem;
}
}
private void internalSelectType(IMember elem, boolean reveal) {
TypeHierarchyViewer viewer= getCurrentViewer();
viewer.removeSelectionChangedListener(fSelectionChangedListener);
viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
viewer.addSelectionChangedListener(fSelectionChangedListener);
}
private void internalSelectMember(IMember member) {
fMethodsViewer.removeSelectionChangedListener(fSelectionChangedListener);
fMethodsViewer.setSelection(member != null ? new StructuredSelection(member) : StructuredSelection.EMPTY);
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
}
/**
* When the input changed or the hierarchy pane becomes visible,
* <code>updateHierarchyViewer<code> brings up the correct view and refreshes
* the current tree
*/
private void updateHierarchyViewer() {
if (fInputElement == null) {
fPagebook.showPage(fNoHierarchyShownLabel);
} else {
if (getCurrentViewer().containsElements() != null) {
Runnable runnable= new Runnable() {
public void run() {
getCurrentViewer().updateContent();
}
};
BusyIndicator.showWhile(getDisplay(), runnable);
if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {
setViewerVisibility(true);
}
} else {
fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInputElement.getElementName())); //$NON-NLS-1$
setViewerVisibility(false);
}
}
}
private void updateMethodViewer(IType input) {
if (input != fMethodsViewer.getInput() && !fIsEnableMemberFilter && fCurrentOrientation != VIEW_ORIENTATION_SINGLE) {
if (input != null) {
fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));
fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));
} else {
fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$
fMethodViewerPaneLabel.setImage(null);
}
fMethodsViewer.setInput(input);
}
}
private void doSelectionChanged(SelectionChangedEvent e) {
if (e.getSelectionProvider() == fMethodsViewer) {
methodSelectionChanged(e.getSelection());
} else {
typeSelectionChanged(e.getSelection());
}
}
private void methodSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (fIsEnableMemberFilter) {
IMember[] memberFilter= null;
if (nSelected > 0) {
memberFilter= new IMember[nSelected];
selected.toArray(memberFilter);
}
setMemberFilter(memberFilter);
updateHierarchyViewer();
updateTitle();
internalSelectType(fSelectedType, true);
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), fMethodsViewer);
}
}
}
private void typeSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (nSelected != 0) {
List types= new ArrayList(nSelected);
for (int i= nSelected-1; i >= 0; i--) {
Object elem= selected.get(i);
if (elem instanceof IType && !types.contains(elem)) {
types.add(elem);
}
}
if (types.size() == 1) {
fSelectedType= (IType) types.get(0);
updateMethodViewer(fSelectedType);
} else if (types.size() == 0) {
// method selected, no change
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), getCurrentViewer());
}
} else {
fSelectedType= null;
updateMethodViewer(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;
}
IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
if (editorPart != null && (elem instanceof IJavaElement)) {
try {
getSite().getPage().removePartListener(fPartListener);
EditorUtility.openInEditor(elem, false);
EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
getSite().getPage().addPartListener(fPartListener);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
private Display getDisplay() {
if (fPagebook != null && !fPagebook.isDisposed()) {
return fPagebook.getDisplay();
}
return null;
}
private boolean isChildVisible(Composite pb, Control child) {
Control[] children= pb.getChildren();
for (int i= 0; i < children.length; i++) {
if (children[i] == child && children[i].isVisible())
return true;
}
return false;
}
private void updateTitle() {
String viewerTitle= getCurrentViewer().getTitle();
String tooltip;
String title;
if (fInputElement != null) {
String[] args= new String[] { viewerTitle, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT) };
title= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.title", args); //$NON-NLS-1$
tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$
} else {
title= viewerTitle;
tooltip= viewerTitle;
}
setTitle(title);
setTitleToolTip(tooltip);
}
private void updateToolbarButtons() {
boolean isType= fInputElement instanceof IType;
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
if (action.getViewerIndex() == VIEW_ID_TYPE) {
action.setEnabled(fInputElement != null);
} else {
action.setEnabled(isType);
}
}
}
/**
* Sets the current view (see view id)
* called from ToggleViewAction. Must be called after creation of the viewpart.
*/
public void setView(int viewerIndex) {
Assert.isNotNull(fAllViewers);
if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {
fCurrentViewerIndex= viewerIndex;
updateHierarchyViewer();
if (fInputElement != null) {
ISelection currSelection= getCurrentViewer().getSelection();
if (currSelection == null || currSelection.isEmpty()) {
internalSelectType(getSelectableType(fInputElement), false);
currSelection= getCurrentViewer().getSelection();
}
if (!fIsEnableMemberFilter) {
typeSelectionChanged(currSelection);
}
}
updateTitle();
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
fHierarchyProblemListener= getCurrentViewer();
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fHierarchyProblemListener);
fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);
getCurrentViewer().getTree().setFocus();
}
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
action.setChecked(fCurrentViewerIndex == action.getViewerIndex());
}
}
/**
* Gets the curret active view index.
*/
public int getViewIndex() {
return fCurrentViewerIndex;
}
private TypeHierarchyViewer getCurrentViewer() {
return fAllViewers[fCurrentViewerIndex];
}
/**
* called from EnableMemberFilterAction.
* Must be called after creation of the viewpart.
*/
public void enableMemberFilter(boolean on) {
if (on != fIsEnableMemberFilter) {
fIsEnableMemberFilter= on;
if (!on) {
IType methodViewerInput= (IType) fMethodsViewer.getInput();
setMemberFilter(null);
updateHierarchyViewer();
updateTitle();
if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {
// avoid that the method view changes content by selecting the previous input
internalSelectType(methodViewerInput, true);
} else if (fSelectedType != null) {
// choose a input that exists
internalSelectType(fSelectedType, true);
updateMethodViewer(fSelectedType);
}
} else {
methodSelectionChanged(fMethodsViewer.getSelection());
}
}
fEnableMemberFilterAction.setChecked(on);
}
/**
* Called from ITypeHierarchyLifeCycleListener.
* Can be called from any thread
*/
private void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final IType[] changedTypes) {
Display display= getDisplay();
if (display != null) {
display.asyncExec(new Runnable() {
public void run() {
doTypeHierarchyChangedOnViewers(changedTypes);
}
});
}
}
private void doTypeHierarchyChangedOnViewers(IType[] changedTypes) {
if (fHierarchyLifeCycle.getHierarchy() == null || !fHierarchyLifeCycle.getHierarchy().exists()) {
clearInput();
} else {
if (changedTypes == null) {
// hierarchy change
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
clearInput();
return;
}
updateHierarchyViewer();
} else {
// elements in hierarchy modified
if (getCurrentViewer().isMethodFiltering()) {
if (changedTypes.length == 1) {
getCurrentViewer().refresh(changedTypes[0]);
} else {
updateHierarchyViewer();
}
} else {
getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );
}
}
}
}
/**
* Determines the input element to be used initially .
*/
private IJavaElement determineInputElement() {
Object input= getSite().getPage().getInput();
if (input instanceof IJavaElement) {
return (IJavaElement) input;
}
return null;
}
/*
* @see IViewPart#init
*/
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento= memento;
}
/*
* @see ViewPart#saveState(IMemento)
*/
public void saveState(IMemento memento) {
if (fPagebook == null) {
// part has not been created
if (fMemento != null) { //Keep the old state;
memento.putMemento(fMemento);
}
return;
}
if (fInputElement != null) {
memento.putString(TAG_INPUT, fInputElement.getHandleIdentifier());
}
memento.putInteger(TAG_VIEW, getViewIndex());
memento.putInteger(TAG_ORIENTATION, fCurrentOrientation);
int weigths[]= fTypeMethodsSplitter.getWeights();
int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
int position= bar != null ? bar.getSelection() : 0;
memento.putInteger(TAG_VERTICAL_SCROLL, position);
IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
if (selection != null) {
memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
}
fMethodsViewer.saveState(memento);
}
/**
* Restores the type hierarchy settings from a memento.
*/
private void restoreState(IMemento memento, IJavaElement defaultInput) {
IJavaElement input= defaultInput;
String elementId= memento.getString(TAG_INPUT);
if (elementId != null) {
input= JavaCore.create(elementId);
if (!input.exists()) {
input= null;
}
}
setInputElement(input);
Integer viewerIndex= memento.getInteger(TAG_VIEW);
if (viewerIndex != null) {
setView(viewerIndex.intValue());
}
Integer orientation= memento.getInteger(TAG_ORIENTATION);
if (orientation != null) {
setOrientation(orientation.intValue());
}
Integer ratio= memento.getInteger(TAG_RATIO);
if (ratio != null) {
fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });
}
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
if (bar != null) {
Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
if (vScroll != null) {
bar.setSelection(vScroll.intValue());
}
}
String selectionId= memento.getString(TAG_SELECTION);
if (selectionId != null) {
IJavaElement elem= JavaCore.create(selectionId);
if (getCurrentViewer().isElementShown(elem) && elem instanceof IMember) {
internalSelectType((IMember)elem, false);
}
}
fMethodsViewer.restoreState(memento);
}
/**
* Link selection to active editor.
*/
private void editorActivated(IEditorPart editor) {
if (!JavaBasePreferencePage.linkTypeHierarchySelectionToEditor()) {
return;
}
if (fInputElement == null) {
// no type hierarchy shown
return;
}
IJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class);
try {
TypeHierarchyViewer currentViewer= getCurrentViewer();
if (elem instanceof IClassFile) {
IType type= ((IClassFile)elem).getType();
if (currentViewer.isElementShown(type)) {
internalSelectType(type, true);
updateMethodViewer(type);
}
} else if (elem instanceof ICompilationUnit) {
IType[] allTypes= ((ICompilationUnit)elem).getAllTypes();
for (int i= 0; i < allTypes.length; i++) {
if (currentViewer.isElementShown(allTypes[i])) {
internalSelectType(allTypes[i], true);
updateMethodViewer(allTypes[i]);
return;
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
}
}
}
|
8,815 |
Bug 8815 Open Hierarchy does not set focus correctly
|
If I open the type hierarchy then the Hierarchy view has the focus but the element inside its viewer is gray - it should be blue. This affects the Java Browsers: the selection is not propagated and the Members view remains empty.
|
verified fixed
|
3820185
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T19:11:21Z | 2002-01-31T09:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.typehierarchy;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.IInputSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.help.ViewContextComputer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.ITypeHierarchyViewPart;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.AddMethodStubAction;
import org.eclipse.jdt.internal.ui.actions.ContextMenuGroup;
import org.eclipse.jdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.packageview.BuildGroup;
import org.eclipse.jdt.internal.ui.preferences.JavaBasePreferencePage;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringGroup;
import org.eclipse.jdt.internal.ui.reorg.ReorgGroup;
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
import org.eclipse.jdt.internal.ui.viewsupport.ErrorTickImageProvider;
import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
/**
* view showing the supertypes/subtypes of its input.
*/
public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart {
public static final int VIEW_ID_TYPE= 2;
public static final int VIEW_ID_SUPER= 0;
public static final int VIEW_ID_SUB= 1;
public static final int VIEW_ORIENTATION_VERTICAL= 0;
public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
public static final int VIEW_ORIENTATION_SINGLE= 2;
private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
private static final String TAG_INPUT= "input"; //$NON-NLS-1$
private static final String TAG_VIEW= "view"; //$NON-NLS-1$
private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
// the selected type in the hierarchy view
private IType fSelectedType;
// input element or null
private IJavaElement fInputElement;
// history of inut elements. No duplicates
private ArrayList fInputHistory;
private IMemento fMemento;
private IProblemChangedListener fHierarchyProblemListener;
private TypeHierarchyLifeCycle fHierarchyLifeCycle;
private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
private MethodsViewer fMethodsViewer;
private int fCurrentViewerIndex;
private TypeHierarchyViewer[] fAllViewers;
private SelectionProviderMediator fSelectionProviderMediator;
private ISelectionChangedListener fSelectionChangedListener;
private boolean fIsEnableMemberFilter;
private SashForm fTypeMethodsSplitter;
private PageBook fViewerbook;
private PageBook fPagebook;
private Label fNoHierarchyShownLabel;
private Label fEmptyTypesViewer;
private ViewForm fTypeViewerViewForm;
private ViewForm fMethodViewerViewForm;
private CLabel fMethodViewerPaneLabel;
private JavaUILabelProvider fPaneLabelProvider;
private IDialogSettings fDialogSettings;
private ToggleViewAction[] fViewActions;
private HistoryDropDownAction fHistoryDropDownAction;
private ToggleOrientationAction[] fToggleOrientationActions;
private int fCurrentOrientation;
private EnableMemberFilterAction fEnableMemberFilterAction;
private AddMethodStubAction fAddStubAction;
private FocusOnTypeAction fFocusOnTypeAction;
private FocusOnSelectionAction fFocusOnSelectionAction;
private IPartListener fPartListener;
public TypeHierarchyViewPart() {
fSelectedType= null;
fInputElement= null;
fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
doTypeHierarchyChanged(typeHierarchy, changedTypes);
}
};
fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
fHierarchyProblemListener= null;
fIsEnableMemberFilter= false;
fInputHistory= new ArrayList();
fAllViewers= null;
fViewActions= new ToggleViewAction[] {
new ToggleViewAction(this, VIEW_ID_TYPE),
new ToggleViewAction(this, VIEW_ID_SUPER),
new ToggleViewAction(this, VIEW_ID_SUB)
};
fDialogSettings= JavaPlugin.getDefault().getDialogSettings();
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)
};
fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
fFocusOnTypeAction= new FocusOnTypeAction(this);
fPaneLabelProvider= new JavaUILabelProvider();
fAddStubAction= new AddMethodStubAction();
fFocusOnSelectionAction= new FocusOnSelectionAction(this);
fPartListener= new IPartListener() {
public void partActivated(IWorkbenchPart part) {
if (part instanceof IEditorPart)
editorActivated((IEditorPart) part);
}
public void partBroughtToTop(IWorkbenchPart part) {}
public void partClosed(IWorkbenchPart part) {}
public void partDeactivated(IWorkbenchPart part) {}
public void partOpened(IWorkbenchPart part) {}
};
fSelectionChangedListener= new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
doSelectionChanged(event);
}
};
}
/**
* Adds the entry if new. Inserted at the beginning of the history entries list.
*/
private void addHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
fInputHistory.remove(entry);
}
fInputHistory.add(0, entry);
fHistoryDropDownAction.setEnabled(true);
}
private void updateHistoryEntries() {
for (int i= fInputHistory.size() - 1; i >= 0; i--) {
IJavaElement type= (IJavaElement) fInputHistory.get(i);
if (!type.exists()) {
fInputHistory.remove(i);
}
}
fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
}
/**
* Goes to the selected entry, without updating the order of history entries.
*/
public void gotoHistoryEntry(IJavaElement entry) {
if (fInputHistory.contains(entry)) {
updateInput(entry);
}
}
/**
* Gets all history entries.
*/
public IJavaElement[] getHistoryEntries() {
if (fInputHistory.size() > 0) {
updateHistoryEntries();
}
return (IJavaElement[]) fInputHistory.toArray(new IJavaElement[fInputHistory.size()]);
}
/**
* Sets the history entries
*/
public void setHistoryEntries(IJavaElement[] elems) {
fInputHistory.clear();
for (int i= 0; i < elems.length; i++) {
fInputHistory.add(elems[i]);
}
updateHistoryEntries();
}
/**
* Selects an member in the methods list
*/
public void selectMember(IMember member) {
ICompilationUnit cu= member.getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
member= (IMember) cu.getOriginal(member);
if (member == null) {
return;
}
}
Control methodControl= fMethodsViewer.getControl();
if (methodControl != null && !methodControl.isDisposed()) {
fMethodsViewer.getControl().setFocus();
}
fMethodsViewer.setSelection(new StructuredSelection(member), true);
}
/**
* @deprecated
*/
public IType getInput() {
if (fInputElement instanceof IType) {
return (IType) fInputElement;
}
return null;
}
/**
* Sets the input to a new type
* @deprecated
*/
public void setInput(IType type) {
setInputElement(type);
}
/**
* Returns the input element of the type hierarchy.
* Can be of type <code>IType</code> or <code>IPackageFragment</code>
*/
public IJavaElement getInputElement() {
return fInputElement;
}
/**
* Sets the input to a new element.
*/
public void setInputElement(IJavaElement element) {
if (element != null) {
if (element instanceof IMember) {
ICompilationUnit cu= ((IMember) element).getCompilationUnit();
if (cu != null && cu.isWorkingCopy()) {
element= cu.getOriginal(element);
if (!element.exists()) {
MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message"));
return;
}
}
if (element.getElementType() == IJavaElement.METHOD || element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.INITIALIZER) {
element= ((IMember) element).getDeclaringType();
}
}
}
if (element != null && !element.equals(fInputElement)) {
addHistoryEntry(element);
}
updateInput(element);
}
/**
* Changes the input to a new type
*/
private void updateInput(IJavaElement inputElement) {
IJavaElement prevInput= fInputElement;
fInputElement= inputElement;
if (fInputElement == null) {
clearInput();
} else {
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e);
clearInput();
return;
}
fPagebook.showPage(fTypeMethodsSplitter);
if (inputElement.getElementType() != IJavaElement.TYPE) {
setView(VIEW_ID_TYPE);
}
// turn off member filtering
setMemberFilter(null);
fIsEnableMemberFilter= false;
if (!fInputElement.equals(prevInput)) {
updateHierarchyViewer();
}
IType root= getSelectableType(fInputElement);
internalSelectType(root, true);
updateMethodViewer(root);
updateToolbarButtons();
updateTitle();
enableMemberFilter(false);
}
}
private void clearInput() {
fInputElement= null;
fHierarchyLifeCycle.freeHierarchy();
updateHierarchyViewer();
updateToolbarButtons();
}
/*
* @see IWorbenchPart#setFocus
*/
public void setFocus() {
fPagebook.setFocus();
}
/*
* @see IWorkbenchPart#dispose
*/
public void dispose() {
fHierarchyLifeCycle.freeHierarchy();
fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
fPaneLabelProvider.dispose();
getSite().getPage().removePartListener(fPartListener);
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
if (fMethodsViewer != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fMethodsViewer);
}
super.dispose();
}
private Control createTypeViewerControl(Composite parent) {
fViewerbook= new PageBook(parent, SWT.NULL);
KeyListener keyListener= createKeyListener();
HierarchyLabelProvider lprovider= new HierarchyLabelProvider(this);
// Create the viewers
TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, lprovider, this);
initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);
fAllViewers= new TypeHierarchyViewer[3];
fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
fAllViewers[VIEW_ID_SUB]= subTypesViewer;
fAllViewers[VIEW_ID_TYPE]= vajViewer;
int currViewerIndex;
try {
currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
if (currViewerIndex < 0 || currViewerIndex > 2) {
currViewerIndex= VIEW_ID_TYPE;
}
} catch (NumberFormatException e) {
currViewerIndex= VIEW_ID_TYPE;
}
fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setInput(fAllViewers[i]);
}
// force the update
fCurrentViewerIndex= -1;
setView(currViewerIndex);
return fViewerbook;
}
private KeyListener createKeyListener() {
return new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (event.stateMask == 0) {
if (event.keyCode == SWT.F4) {
OpenTypeHierarchyUtil.open(getSite().getSelectionProvider().getSelection(), getSite().getWorkbenchWindow());
return;
} else if (event.keyCode == SWT.F5) {
updateHierarchyViewer();
return;
}
}
viewPartKeyShortcuts(event);
}
};
}
private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
typesViewer.getControl().setVisible(false);
typesViewer.getControl().addKeyListener(keyListener);
typesViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillTypesViewerContextMenu(typesViewer, menu);
}
}, cotextHelpId, getSite());
typesViewer.addSelectionChangedListener(fSelectionChangedListener);
}
private Control createMethodViewerControl(Composite parent) {
fMethodsViewer= new MethodsViewer(parent, this);
fMethodsViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillMethodsViewerContextMenu(menu);
}
}, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
Control control= fMethodsViewer.getTable();
control.addKeyListener(createKeyListener());
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fMethodsViewer);
return control;
}
private void initDragAndDrop() {
Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
int ops= DND.DROP_COPY;
DragSource source= new DragSource(fMethodsViewer.getControl(), ops);
source.setTransfer(transfers);
source.addDragListener(new BasicSelectionTransferDragAdapter(fMethodsViewer));
for (int i= 0; i < fAllViewers.length; i++) {
TypeHierarchyViewer curr= fAllViewers[i];
curr.addDropSupport(ops, transfers, new TypeHierarchyTransferDropAdapter(curr));
}
}
private void viewPartKeyShortcuts(KeyEvent event) {
if (event.stateMask == SWT.CTRL) {
if (event.character == '1') {
setView(VIEW_ID_TYPE);
} else if (event.character == '2') {
setView(VIEW_ID_SUPER);
} else if (event.character == '3') {
setView(VIEW_ID_SUB);
}
}
}
/**
* Returns the inner component in a workbench part.
* @see IWorkbenchPart#createPartControl
*/
public void createPartControl(Composite container) {
fPagebook= new PageBook(container, SWT.NONE);
// page 1 of pagebook (viewers)
fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
fTypeMethodsSplitter.setVisible(false);
fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
fTypeViewerViewForm.setContent(typeViewerControl);
fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
fTypeMethodsSplitter.setWeights(new int[] {35, 65});
Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
fMethodViewerViewForm.setContent(methodViewerPart);
fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
initDragAndDrop();
ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
// page 2 of pagebook (no hierarchy label)
fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
MenuManager menu= new MenuManager();
menu.add(fFocusOnTypeAction);
fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
fPagebook.showPage(fNoHierarchyShownLabel);
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);
// set the filter menu items
IActionBars actionBars= getViewSite().getActionBars();
IMenuManager viewMenu= actionBars.getMenuManager();
for (int i= 0; i < fToggleOrientationActions.length; i++) {
viewMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
// fill the method viewer toolbar
ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);
lowertbmanager.add(fEnableMemberFilterAction);
lowertbmanager.add(new Separator());
fMethodsViewer.contributeToToolBar(lowertbmanager);
lowertbmanager.update(true);
// selection provider
int nHierarchyViewers= fAllViewers.length;
Viewer[] trackedViewers= new Viewer[nHierarchyViewers + 1];
for (int i= 0; i < nHierarchyViewers; i++) {
trackedViewers[i]= fAllViewers[i];
}
trackedViewers[nHierarchyViewers]= fMethodsViewer;
fSelectionProviderMediator= new SelectionProviderMediator(trackedViewers);
IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
getSite().setSelectionProvider(fSelectionProviderMediator);
getSite().getPage().addPartListener(fPartListener);
IJavaElement input= determineInputElement();
if (fMemento != null) {
restoreState(fMemento, input);
} else if (input != null) {
setInputElement(input);
} else {
setViewerVisibility(false);
}
ReorgGroup.addGlobalReorgActions(getViewSite().getActionBars(), getViewSite().getSelectionProvider());
// fixed for 1GETAYN: ITPJUI:WIN - F1 help does nothing
WorkbenchHelp.setHelp(fPagebook, new ViewContextComputer(this, IJavaHelpContextIds.TYPE_HIERARCHY_VIEW));
}
/**
* called from ToggleOrientationAction.
* @param orientation VIEW_ORIENTATION_SINGLE, VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
*/
public void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
boolean methodViewerNeedsUpdate= false;
if (fMethodViewerViewForm != null && !fMethodViewerViewForm.isDisposed()
&& fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {
if (orientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(false);
enableMemberFilter(false);
updateMethodViewer(null);
} else {
if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
fMethodViewerViewForm.setVisible(true);
methodViewerNeedsUpdate= true;
}
boolean horizontal= orientation == VIEW_ORIENTATION_HORIZONTAL;
fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
}
updateMainToolbar(orientation);
fTypeMethodsSplitter.layout();
}
for (int i= 0; i < fToggleOrientationActions.length; i++) {
fToggleOrientationActions[i].setChecked(orientation == fToggleOrientationActions[i].getOrientation());
}
fCurrentOrientation= orientation;
if (methodViewerNeedsUpdate) {
updateMethodViewer(fSelectedType);
}
fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
}
}
private void updateMainToolbar(int orientation) {
IActionBars actionBars= getViewSite().getActionBars();
IToolBarManager tbmanager= actionBars.getToolBarManager();
if (orientation == VIEW_ORIENTATION_HORIZONTAL) {
clearMainToolBar(tbmanager);
ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);
fillMainToolBar(new ToolBarManager(typeViewerToolBar));
fTypeViewerViewForm.setTopLeft(typeViewerToolBar);
} else {
fTypeViewerViewForm.setTopLeft(null);
fillMainToolBar(tbmanager);
}
}
private void fillMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.add(fHistoryDropDownAction);
for (int i= 0; i < fViewActions.length; i++) {
tbmanager.add(fViewActions[i]);
}
tbmanager.update(false);
}
private void clearMainToolBar(IToolBarManager tbmanager) {
tbmanager.removeAll();
tbmanager.update(false);
}
/**
* Creates the context menu for the hierarchy viewers
*/
private void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
viewer.contributeToContextMenu(menu);
IStructuredSelection selection= (IStructuredSelection)viewer.getSelection();
if (JavaBasePreferencePage.openTypeHierarchyInPerspective()) {
addOpenPerspectiveItem(menu, selection);
}
addOpenWithMenu(menu, selection);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnTypeAction);
if (fFocusOnSelectionAction.canActionBeAdded())
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fFocusOnSelectionAction);
addRefactoring(menu, viewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, viewer);
}
/**
* Creates the context menu for the method viewer
*/
private void fillMethodsViewerContextMenu(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
// viewer entries
fMethodsViewer.contributeToContextMenu(menu);
if (fSelectedType != null && fAddStubAction.init(fSelectedType, fMethodsViewer.getSelection())) {
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fAddStubAction);
}
//menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new JavaReplaceWithEditionAction(fMethodsViewer));
addOpenWithMenu(menu, (IStructuredSelection)fMethodsViewer.getSelection());
addRefactoring(menu, fMethodsViewer);
ContextMenuGroup.add(menu, new ContextMenuGroup[] { new BuildGroup(), new ReorgGroup() }, fMethodsViewer);
}
private void addRefactoring(IMenuManager menu, IInputSelectionProvider viewer){
MenuManager refactoring= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.refactor")); //$NON-NLS-1$
ContextMenuGroup.add(refactoring, new ContextMenuGroup[] { new RefactoringGroup() }, viewer);
if (!refactoring.isEmpty())
menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, refactoring);
}
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
// If one file is selected get it.
// Otherwise, do not show the "open with" menu.
if (selection.size() != 1)
return;
Object element= selection.getFirstElement();
if (!(element instanceof IJavaElement))
return;
IResource resource= null;
try {
resource= ((IJavaElement)element).getUnderlyingResource();
} catch(JavaModelException e) {
// ignore
}
if (!(resource instanceof IFile))
return;
// Create a menu flyout.
MenuManager submenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.menu.open")); //$NON-NLS-1$
submenu.add(new OpenWithMenu(getSite().getPage(), (IFile) resource));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
private void addOpenPerspectiveItem(IMenuManager menu, IStructuredSelection selection) {
OpenTypeHierarchyUtil.addToMenu(getSite().getWorkbenchWindow(), menu, selection);
}
/**
* Toggles between the empty viewer page and the hierarchy
*/
private void setViewerVisibility(boolean showHierarchy) {
if (showHierarchy) {
fViewerbook.showPage(getCurrentViewer().getControl());
} else {
fViewerbook.showPage(fEmptyTypesViewer);
}
}
/**
* Sets the member filter. <code>null</code> disables member filtering.
*/
private void setMemberFilter(IMember[] memberFilter) {
Assert.isNotNull(fAllViewers);
for (int i= 0; i < fAllViewers.length; i++) {
fAllViewers[i].setMemberFilter(memberFilter);
}
}
private IType getSelectableType(IJavaElement elem) {
ISelection sel= null;
if (elem.getElementType() != IJavaElement.TYPE) {
return (IType) getCurrentViewer().getTreeRootType();
} else {
return (IType) elem;
}
}
private void internalSelectType(IMember elem, boolean reveal) {
TypeHierarchyViewer viewer= getCurrentViewer();
viewer.removeSelectionChangedListener(fSelectionChangedListener);
viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
viewer.addSelectionChangedListener(fSelectionChangedListener);
}
private void internalSelectMember(IMember member) {
fMethodsViewer.removeSelectionChangedListener(fSelectionChangedListener);
fMethodsViewer.setSelection(member != null ? new StructuredSelection(member) : StructuredSelection.EMPTY);
fMethodsViewer.addSelectionChangedListener(fSelectionChangedListener);
}
/**
* When the input changed or the hierarchy pane becomes visible,
* <code>updateHierarchyViewer<code> brings up the correct view and refreshes
* the current tree
*/
private void updateHierarchyViewer() {
if (fInputElement == null) {
fPagebook.showPage(fNoHierarchyShownLabel);
} else {
if (getCurrentViewer().containsElements() != null) {
Runnable runnable= new Runnable() {
public void run() {
getCurrentViewer().updateContent();
}
};
BusyIndicator.showWhile(getDisplay(), runnable);
if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {
setViewerVisibility(true);
}
} else {
fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInputElement.getElementName())); //$NON-NLS-1$
setViewerVisibility(false);
}
}
}
private void updateMethodViewer(IType input) {
if (input != fMethodsViewer.getInput() && !fIsEnableMemberFilter && fCurrentOrientation != VIEW_ORIENTATION_SINGLE) {
if (input != null) {
fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));
fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));
} else {
fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$
fMethodViewerPaneLabel.setImage(null);
}
fMethodsViewer.setInput(input);
}
}
private void doSelectionChanged(SelectionChangedEvent e) {
if (e.getSelectionProvider() == fMethodsViewer) {
methodSelectionChanged(e.getSelection());
} else {
typeSelectionChanged(e.getSelection());
}
}
private void methodSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (fIsEnableMemberFilter) {
IMember[] memberFilter= null;
if (nSelected > 0) {
memberFilter= new IMember[nSelected];
selected.toArray(memberFilter);
}
setMemberFilter(memberFilter);
updateHierarchyViewer();
updateTitle();
internalSelectType(fSelectedType, true);
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), fMethodsViewer);
}
}
}
private void typeSelectionChanged(ISelection sel) {
if (sel instanceof IStructuredSelection) {
List selected= ((IStructuredSelection)sel).toList();
int nSelected= selected.size();
if (nSelected != 0) {
List types= new ArrayList(nSelected);
for (int i= nSelected-1; i >= 0; i--) {
Object elem= selected.get(i);
if (elem instanceof IType && !types.contains(elem)) {
types.add(elem);
}
}
if (types.size() == 1) {
fSelectedType= (IType) types.get(0);
updateMethodViewer(fSelectedType);
} else if (types.size() == 0) {
// method selected, no change
}
if (nSelected == 1) {
revealElementInEditor(selected.get(0), getCurrentViewer());
}
} else {
fSelectedType= null;
updateMethodViewer(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;
}
IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
if (editorPart != null && (elem instanceof IJavaElement)) {
try {
getSite().getPage().removePartListener(fPartListener);
EditorUtility.openInEditor(elem, false);
EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
getSite().getPage().addPartListener(fPartListener);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
private Display getDisplay() {
if (fPagebook != null && !fPagebook.isDisposed()) {
return fPagebook.getDisplay();
}
return null;
}
private boolean isChildVisible(Composite pb, Control child) {
Control[] children= pb.getChildren();
for (int i= 0; i < children.length; i++) {
if (children[i] == child && children[i].isVisible())
return true;
}
return false;
}
private void updateTitle() {
String viewerTitle= getCurrentViewer().getTitle();
String tooltip;
String title;
if (fInputElement != null) {
String[] args= new String[] { viewerTitle, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT) };
title= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.title", args); //$NON-NLS-1$
tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$
} else {
title= viewerTitle;
tooltip= viewerTitle;
}
setTitle(title);
setTitleToolTip(tooltip);
}
private void updateToolbarButtons() {
boolean isType= fInputElement instanceof IType;
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
if (action.getViewerIndex() == VIEW_ID_TYPE) {
action.setEnabled(fInputElement != null);
} else {
action.setEnabled(isType);
}
}
}
/**
* Sets the current view (see view id)
* called from ToggleViewAction. Must be called after creation of the viewpart.
*/
public void setView(int viewerIndex) {
Assert.isNotNull(fAllViewers);
if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {
fCurrentViewerIndex= viewerIndex;
updateHierarchyViewer();
if (fInputElement != null) {
ISelection currSelection= getCurrentViewer().getSelection();
if (currSelection == null || currSelection.isEmpty()) {
internalSelectType(getSelectableType(fInputElement), false);
currSelection= getCurrentViewer().getSelection();
}
if (!fIsEnableMemberFilter) {
typeSelectionChanged(currSelection);
}
}
updateTitle();
if (fHierarchyProblemListener != null) {
JavaPlugin.getDefault().getProblemMarkerManager().removeListener(fHierarchyProblemListener);
}
fHierarchyProblemListener= getCurrentViewer();
JavaPlugin.getDefault().getProblemMarkerManager().addListener(fHierarchyProblemListener);
fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);
getCurrentViewer().getTree().setFocus();
}
for (int i= 0; i < fViewActions.length; i++) {
ToggleViewAction action= fViewActions[i];
action.setChecked(fCurrentViewerIndex == action.getViewerIndex());
}
}
/**
* Gets the curret active view index.
*/
public int getViewIndex() {
return fCurrentViewerIndex;
}
private TypeHierarchyViewer getCurrentViewer() {
return fAllViewers[fCurrentViewerIndex];
}
/**
* called from EnableMemberFilterAction.
* Must be called after creation of the viewpart.
*/
public void enableMemberFilter(boolean on) {
if (on != fIsEnableMemberFilter) {
fIsEnableMemberFilter= on;
if (!on) {
IType methodViewerInput= (IType) fMethodsViewer.getInput();
setMemberFilter(null);
updateHierarchyViewer();
updateTitle();
if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {
// avoid that the method view changes content by selecting the previous input
internalSelectType(methodViewerInput, true);
} else if (fSelectedType != null) {
// choose a input that exists
internalSelectType(fSelectedType, true);
updateMethodViewer(fSelectedType);
}
} else {
methodSelectionChanged(fMethodsViewer.getSelection());
}
}
fEnableMemberFilterAction.setChecked(on);
}
/**
* Called from ITypeHierarchyLifeCycleListener.
* Can be called from any thread
*/
private void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final IType[] changedTypes) {
Display display= getDisplay();
if (display != null) {
display.asyncExec(new Runnable() {
public void run() {
doTypeHierarchyChangedOnViewers(changedTypes);
}
});
}
}
private void doTypeHierarchyChangedOnViewers(IType[] changedTypes) {
if (fHierarchyLifeCycle.getHierarchy() == null || !fHierarchyLifeCycle.getHierarchy().exists()) {
clearInput();
} else {
if (changedTypes == null) {
// hierarchy change
try {
fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement);
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
clearInput();
return;
}
updateHierarchyViewer();
} else {
// elements in hierarchy modified
if (getCurrentViewer().isMethodFiltering()) {
if (changedTypes.length == 1) {
getCurrentViewer().refresh(changedTypes[0]);
} else {
updateHierarchyViewer();
}
} else {
getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );
}
}
}
}
/**
* Determines the input element to be used initially .
*/
private IJavaElement determineInputElement() {
Object input= getSite().getPage().getInput();
if (input instanceof IJavaElement) {
return (IJavaElement) input;
}
return null;
}
/*
* @see IViewPart#init
*/
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento= memento;
}
/*
* @see ViewPart#saveState(IMemento)
*/
public void saveState(IMemento memento) {
if (fPagebook == null) {
// part has not been created
if (fMemento != null) { //Keep the old state;
memento.putMemento(fMemento);
}
return;
}
if (fInputElement != null) {
memento.putString(TAG_INPUT, fInputElement.getHandleIdentifier());
}
memento.putInteger(TAG_VIEW, getViewIndex());
memento.putInteger(TAG_ORIENTATION, fCurrentOrientation);
int weigths[]= fTypeMethodsSplitter.getWeights();
int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
int position= bar != null ? bar.getSelection() : 0;
memento.putInteger(TAG_VERTICAL_SCROLL, position);
IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
if (selection != null) {
memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
}
fMethodsViewer.saveState(memento);
}
/**
* Restores the type hierarchy settings from a memento.
*/
private void restoreState(IMemento memento, IJavaElement defaultInput) {
IJavaElement input= defaultInput;
String elementId= memento.getString(TAG_INPUT);
if (elementId != null) {
input= JavaCore.create(elementId);
if (!input.exists()) {
input= null;
}
}
setInputElement(input);
Integer viewerIndex= memento.getInteger(TAG_VIEW);
if (viewerIndex != null) {
setView(viewerIndex.intValue());
}
Integer orientation= memento.getInteger(TAG_ORIENTATION);
if (orientation != null) {
setOrientation(orientation.intValue());
}
Integer ratio= memento.getInteger(TAG_RATIO);
if (ratio != null) {
fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });
}
ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
if (bar != null) {
Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
if (vScroll != null) {
bar.setSelection(vScroll.intValue());
}
}
String selectionId= memento.getString(TAG_SELECTION);
if (selectionId != null) {
IJavaElement elem= JavaCore.create(selectionId);
if (getCurrentViewer().isElementShown(elem) && elem instanceof IMember) {
internalSelectType((IMember)elem, false);
}
}
fMethodsViewer.restoreState(memento);
}
/**
* Link selection to active editor.
*/
private void editorActivated(IEditorPart editor) {
if (!JavaBasePreferencePage.linkTypeHierarchySelectionToEditor()) {
return;
}
if (fInputElement == null) {
// no type hierarchy shown
return;
}
IJavaElement elem= (IJavaElement)editor.getEditorInput().getAdapter(IJavaElement.class);
try {
TypeHierarchyViewer currentViewer= getCurrentViewer();
if (elem instanceof IClassFile) {
IType type= ((IClassFile)elem).getType();
if (currentViewer.isElementShown(type)) {
internalSelectType(type, true);
updateMethodViewer(type);
}
} else if (elem instanceof ICompilationUnit) {
IType[] allTypes= ((ICompilationUnit)elem).getAllTypes();
for (int i= 0; i < allTypes.length; i++) {
if (currentViewer.isElementShown(allTypes[i])) {
internalSelectType(allTypes[i], true);
updateMethodViewer(allTypes[i]);
return;
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
}
}
}
|
8,142 |
Bug 8142 no scoped type hierarchy on binary projects
|
When I hit F4 on a binary project selection (e.g. org.apache.ant), I get: 'No declaration of selected members in the chosen hierarchy of 'org.apache.ant'. I would expect to see the class hierarchies of the internal jars. BTW, what does the message mean? I don't understand it.
|
verified fixed
|
4b48a12
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T19:17:50Z | 2002-01-23T15:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.typehierarchy;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IRegion;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.ITypeHierarchyChangedListener;
import org.eclipse.jdt.core.IWorkingCopy;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
/**
* Manages a type hierarchy, to keep it refreshed, and to allow it to be shared.
*/
public class TypeHierarchyLifeCycle implements ITypeHierarchyChangedListener, IElementChangedListener {
private boolean fHierarchyRefreshNeeded;
private ITypeHierarchy fHierarchy;
private IJavaElement fInputElement;
private boolean fIsSuperTypesOnly;
private List fChangeListeners;
public TypeHierarchyLifeCycle() {
this(false);
}
public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
fHierarchy= null;
fInputElement= null;
fIsSuperTypesOnly= isSuperTypesOnly;
fChangeListeners= new ArrayList(2);
}
public ITypeHierarchy getHierarchy() {
return fHierarchy;
}
public IJavaElement getInputElement() {
return fInputElement;
}
public void freeHierarchy() {
if (fHierarchy != null) {
fHierarchy.removeTypeHierarchyChangedListener(this);
JavaCore.removeElementChangedListener(this);
fHierarchy= null;
fInputElement= null;
}
}
public void removeChangedListener(ITypeHierarchyLifeCycleListener listener) {
fChangeListeners.remove(listener);
}
public void addChangedListener(ITypeHierarchyLifeCycleListener listener) {
if (!fChangeListeners.contains(listener)) {
fChangeListeners.add(listener);
}
}
private void fireChange(IType[] changedTypes) {
for (int i= fChangeListeners.size()-1; i>=0; i--) {
ITypeHierarchyLifeCycleListener curr= (ITypeHierarchyLifeCycleListener) fChangeListeners.get(i);
curr.typeHierarchyChanged(this, changedTypes);
}
}
public void ensureRefreshedTypeHierarchy(final IJavaElement element) throws JavaModelException {
if (element == null) {
freeHierarchy();
return;
}
boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
IRunnableWithProgress op= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException {
try {
doHierarchyRefresh(element, pm);
} catch (JavaModelException e) {
throw new InvocationTargetException(e);
}
}
};
try {
new BusyIndicatorRunnableContext().run(false, false, op);
} catch (InvocationTargetException e) {
Throwable th= e.getTargetException();
if (th instanceof JavaModelException) {
throw (JavaModelException)th;
} else {
throw new JavaModelException(th, IStatus.ERROR);
}
} catch (InterruptedException e) {
// Not cancelable.
}
fHierarchyRefreshNeeded= false;
}
}
private void doHierarchyRefresh(IJavaElement element, IProgressMonitor pm) throws JavaModelException {
boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
// to ensore the order of the two listeners always remove / add listeners on operations
// on type hierarchies
if (fHierarchy != null) {
fHierarchy.removeTypeHierarchyChangedListener(this);
JavaCore.removeElementChangedListener(this);
}
if (hierachyCreationNeeded) {
fInputElement= element;
if (element.getElementType() == IJavaElement.TYPE) {
IType type= (IType) element;
if (fIsSuperTypesOnly) {
fHierarchy= type.newSupertypeHierarchy(pm);
} else {
fHierarchy= type.newTypeHierarchy(pm);
}
} else {
IRegion region= JavaCore.newRegion();
if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
// for projects only add the contained source folders
IPackageFragmentRoot[] roots= ((IJavaProject) element).getPackageFragmentRoots();
for (int i= 0; i < roots.length; i++) {
if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
region.add(roots[i]);
}
}
} else {
region.add(element);
}
IJavaProject jproject= element.getJavaProject();
fHierarchy= jproject.newTypeHierarchy(region, pm);
}
} else {
fHierarchy.refresh(pm);
}
fHierarchy.addTypeHierarchyChangedListener(this);
JavaCore.addElementChangedListener(this);
}
/*
* @see ITypeHierarchyChangedListener#typeHierarchyChanged
*/
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
fHierarchyRefreshNeeded= true;
}
/*
* @see IElementChangedListener#elementChanged(ElementChangedEvent)
*/
public void elementChanged(ElementChangedEvent event) {
if (fChangeListeners.isEmpty()) {
return;
}
IJavaElement elem= event.getDelta().getElement();
if (elem instanceof IWorkingCopy && ((IWorkingCopy)elem).isWorkingCopy()) {
return;
}
if (fHierarchyRefreshNeeded) {
fireChange(null);
} else {
ArrayList changedTypes= new ArrayList();
processDelta(event.getDelta(), changedTypes);
fireChange((IType[]) changedTypes.toArray(new IType[changedTypes.size()]));
}
}
/*
* Assume that the hierarchy is intact (no refresh needed)
*/
private void processDelta(IJavaElementDelta delta, ArrayList changedTypes) {
IJavaElement element= delta.getElement();
switch (element.getElementType()) {
case IJavaElement.TYPE:
processTypeDelta((IType) element, changedTypes);
processChildrenDelta(delta, changedTypes); // (inner types)
break;
case IJavaElement.JAVA_MODEL:
case IJavaElement.JAVA_PROJECT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
case IJavaElement.PACKAGE_FRAGMENT:
processChildrenDelta(delta, changedTypes);
break;
case IJavaElement.COMPILATION_UNIT:
if (delta.getKind() == IJavaElementDelta.CHANGED && (delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) {
try {
IType[] types= ((ICompilationUnit) element).getAllTypes();
for (int i= 0; i < types.length; i++) {
processTypeDelta(types[i], changedTypes);
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
} else {
processChildrenDelta(delta, changedTypes);
}
break;
case IJavaElement.CLASS_FILE:
if (delta.getKind() == IJavaElementDelta.CHANGED && (delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) {
try {
IType type= ((IClassFile) element).getType();
processTypeDelta(type, changedTypes);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
} else {
processChildrenDelta(delta, changedTypes);
}
break;
}
}
private void processTypeDelta(IType type, ArrayList changedTypes) {
if (getHierarchy().contains(type)) {
changedTypes.add(type);
}
}
private void processChildrenDelta(IJavaElementDelta delta, ArrayList changedTypes) {
IJavaElementDelta[] children= delta.getAffectedChildren();
for (int i= 0; i < children.length; i++) {
processDelta(children[i], changedTypes); // recursive
}
}
}
|
8,205 |
Bug 8205 Missing mnemonic: Outline View->Open Super Implementation
|
Select a method in the outline view. "Open Super Implementation" on the popup menu is missing a mnemonic.
|
resolved fixed
|
f81a291
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T19:25:54Z | 2002-01-23T18:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenExternalJavadocAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.actions;
import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* On a selected member; opens the Javadoc in an external browser (if existing)
*/
public class OpenExternalJavadocAction extends Action implements IUpdate, IObjectActionDelegate {
private StructuredSelectionProvider fSelectionProvider;
/**
* Use only for IWorkbenchWindowActionDelegates!
*/
public OpenExternalJavadocAction() {
this(null);
}
public OpenExternalJavadocAction(StructuredSelectionProvider provider) {
super();
setText("Open External Javadoc@Shift+F2");
setDescription("Opens the Javadoc of the selected element in an external browser");
setToolTipText("Opens the Javadoc of the selected element in an external browser");
fSelectionProvider= provider;
}
public void update() {
setEnabled(canOperateOn());
}
private boolean canOperateOn() {
if (fSelectionProvider != null) {
IStructuredSelection selection= fSelectionProvider.getSelection(StructuredSelectionProvider.FLAGS_GET_EDITOR_INPUT);
return selection.size() == 1;
}
return false;
}
private IJavaElement getDocumentedElement() {
if (fSelectionProvider == null) {
return null;
}
IStructuredSelection selection= fSelectionProvider.getSelection(StructuredSelectionProvider.FLAGS_DO_CODERESOLVE | StructuredSelectionProvider.FLAGS_GET_EDITOR_INPUT);
if (selection.size() != 1)
return null;
Object obj= selection.getFirstElement();
if (obj instanceof IJavaElement) {
IJavaElement elem= (IJavaElement) obj;
int type= elem.getElementType();
if (type == IJavaElement.JAVA_MODEL || type == IJavaElement.JAVA_PROJECT) {
return null;
}
if (type == IJavaElement.IMPORT_DECLARATION) {
return elem;
}
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(elem);
if (JavaDocLocations.getJavadocLocation(root.getPath()) != null) {
return elem;
}
}
return null;
}
public void run() {
IJavaElement element= getDocumentedElement();
if (element == null) {
return;
}
try {
URL url= JavaDocLocations.getJavaDocLocation(element);
if (url != null) {
openInBrowser(url, JavaPlugin.getActiveWorkbenchShell());
}
} catch (CoreException e) {
JavaPlugin.log(e);
String title= "Open External Javadoc";
String message= "Opening Javadoc failed. See log for details.";
ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message, e.getStatus());
}
}
/*
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
run();
}
/*
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
/*
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
fSelectionProvider= StructuredSelectionProvider.createFrom(targetPart.getSite().getWorkbenchWindow().getSelectionService());
}
private static boolean webBrowserOpened = false;
/**
* Copied from AboutPluginsDialog.openMoreInfo
*/
public static void openInBrowser(final URL url, final Shell shell) {
//System.out.println("Opening " + url.toExternalForm());
if (SWT.getPlatform().equals("win32")) { //$NON-NLS-1$
Program.launch(url.toString());
} else {
Thread launcher = new Thread("External Javadoc Launcher") { //$NON-NLS-1$
public void run() {
try {
if (webBrowserOpened) {
Runtime.getRuntime().exec("netscape -remote openURL(" + url.toString() + ")"); //$NON-NLS-1$
} else {
Process p = Runtime.getRuntime().exec("netscape " + url.toString()); //$NON-NLS-1$
webBrowserOpened = true;
try {
if (p != null)
p.waitFor();
} catch (InterruptedException e) {
MessageDialog.openError(shell, "Open External Javadoc", e.getMessage());
} finally {
webBrowserOpened = false;
}
}
} catch (IOException e) {
MessageDialog.openError(shell, "Open External Javadoc", e.getMessage());
}
}
};
launcher.start();
}
}
}
|
8,443 |
Bug 8443 Wording in Compiler prefer page needs to be improved
|
Martin let's discuss how to improve the wording. From Greg: * With respect to the preference page its problematic on several fronts - it requires me to have to rebuild everything - it is separate from the task view & thus does not work as your typical view filter works * the page itself is unclear to a user. When a user first sees this preference page they are not sure what it actually means. This is probably fixed with some simple text that says something like "What severity level do you want to assign to the following problems."
|
resolved fixed
|
32b312f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-07T19:26:43Z | 2002-01-25T00:53:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerPreferencePage.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.preferences;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Hashtable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.help.DialogPageContextComputer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.TabFolderLayout;
/*
* The page for setting the compiler options.
*/
public class CompilerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
// Preference store keys, see JavaCore.getOptions
private static final String PREF_LOCAL_VARIABLE_ATTR= "org.eclipse.jdt.core.compiler.debug.localVariable";
private static final String PREF_LINE_NUMBER_ATTR= "org.eclipse.jdt.core.compiler.debug.lineNumber";
private static final String PREF_SOURCE_FILE_ATTR= "org.eclipse.jdt.core.compiler.debug.sourceFile";
private static final String PREF_CODEGEN_UNUSED_LOCAL= "org.eclipse.jdt.core.compiler.codegen.unusedLocal";
private static final String PREF_CODEGEN_TARGET_PLATFORM= "org.eclipse.jdt.core.compiler.codegen.targetPlatform";
private static final String PREF_PB_UNREACHABLE_CODE= "org.eclipse.jdt.core.compiler.problem.unreachableCode";
private static final String PREF_PB_INVALID_IMPORT= "org.eclipse.jdt.core.compiler.problem.invalidImport";
private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod";
private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName";
private static final String PREF_PB_DEPRECATION= "org.eclipse.jdt.core.compiler.problem.deprecation";
private static final String PREF_PB_HIDDEN_CATCH_BLOCK= "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock";
private static final String PREF_PB_UNUSED_LOCAL= "org.eclipse.jdt.core.compiler.problem.unusedLocal";
private static final String PREF_PB_UNUSED_PARAMETER= "org.eclipse.jdt.core.compiler.problem.unusedParameter";
private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation";
private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral";
private static final String PREF_PB_ASSERT_AS_IDENTIFIER= "org.eclipse.jdt.core.compiler.problem.assertIdentifier";
private static final String PREF_SOURCE_COMPATIBILITY= "org.eclipse.jdt.core.compiler.source";
// values
private static final String GENERATE= "generate";
private static final String DO_NOT_GENERATE= "do not generate";
private static final String PRESERVE= "preserve";
private static final String OPTIMIZE_OUT= "optimize out";
private static final String VERSION_1_1= "1.1";
private static final String VERSION_1_2= "1.2";
private static final String VERSION_1_3= "1.3";
private static final String VERSION_1_4= "1.4";
private static final String ERROR= "error";
private static final String WARNING= "warning";
private static final String IGNORE= "ignore";
private static String[] getAllKeys() {
return new String[] {
PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,
PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_UNREACHABLE_CODE, PREF_PB_INVALID_IMPORT, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS,
PREF_PB_ASSERT_AS_IDENTIFIER, PREF_SOURCE_COMPATIBILITY
};
}
/**
* Initializes the current options (read from preference store)
*/
public static void initDefaults(IPreferenceStore store) {
Hashtable hashtable= JavaCore.getDefaultOptions();
Hashtable currOptions= JavaCore.getOptions();
String[] allKeys= getAllKeys();
for (int i= 0; i < allKeys.length; i++) {
String key= allKeys[i];
String defValue= (String) hashtable.get(key);
if (defValue != null) {
store.setDefault(key, defValue);
} else {
JavaPlugin.logErrorMessage("CompilerPreferencePage: value is null: " + key);
}
// update the JavaCore options from the pref store
String val= store.getString(key);
if (val != null) {
currOptions.put(key, val);
}
}
JavaCore.setOptions(currOptions);
}
private static class ControlData {
private String fKey;
private String[] fValues;
public ControlData(String key, String[] values) {
fKey= key;
fValues= values;
}
public String getKey() {
return fKey;
}
public String getValue(boolean selection) {
int index= selection ? 0 : 1;
return fValues[index];
}
public String getValue(int index) {
return fValues[index];
}
public int getSelection(String value) {
for (int i= 0; i < fValues.length; i++) {
if (value.equals(fValues[i])) {
return i;
}
}
throw new IllegalArgumentException();
}
}
private Hashtable fWorkingValues;
private ArrayList fCheckBoxes;
private ArrayList fComboBoxes;
private SelectionListener fSelectionListener;
public CompilerPreferencePage() {
setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
setDescription(JavaUIMessages.getString("CompilerPreferencePage.description")); //$NON-NLS-1$
fWorkingValues= JavaCore.getOptions();
fCheckBoxes= new ArrayList();
fComboBoxes= new ArrayList();
fSelectionListener= new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
controlChanged(e.widget);
}
};
}
/**
* @see IWorkbenchPreferencePage#init()
*/
public void init(IWorkbench workbench) {
}
/**
* @see PreferencePage#createControl(Composite)
*/
public void createControl(Composite parent) {
// added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages
super.createControl(parent);
WorkbenchHelp.setHelp(getControl(), new DialogPageContextComputer(this, IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE));
}
/**
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
TabFolder folder= new TabFolder(parent, SWT.NONE);
folder.setLayout(new TabFolderLayout());
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
JavaUIMessages.getString("CompilerPreferencePage.error"),
JavaUIMessages.getString("CompilerPreferencePage.warning"),
JavaUIMessages.getString("CompilerPreferencePage.ignore")
};
GridLayout layout= new GridLayout();
layout.numColumns= 2;
Composite warningsComposite= new Composite(folder, SWT.NULL);
warningsComposite.setLayout(layout);
String label= JavaUIMessages.getString("CompilerPreferencePage.pb_unreachable_code.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_UNREACHABLE_CODE, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_invalid_import.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_INVALID_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_method_naming.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_deprecation.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_hidden_catchblock.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_unused_local.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_unused_parameter.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_synth_access_emul.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_non_externalized_strings.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels);
label= JavaUIMessages.getString("CompilerPreferencePage.pb_assert_as_identifier.label"); //$NON-NLS-1$
addComboBox(warningsComposite, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels);
String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE };
layout= new GridLayout();
layout.numColumns= 2;
Composite codeGenComposite= new Composite(folder, SWT.NULL);
codeGenComposite.setLayout(layout);
label= JavaUIMessages.getString("CompilerPreferencePage.variable_attr.label"); //$NON-NLS-1$
addCheckBox(codeGenComposite, label, PREF_LOCAL_VARIABLE_ATTR, generateValues);
label= JavaUIMessages.getString("CompilerPreferencePage.line_number_attr.label"); //$NON-NLS-1$
addCheckBox(codeGenComposite, label, PREF_LINE_NUMBER_ATTR, generateValues);
label= JavaUIMessages.getString("CompilerPreferencePage.source_file_attr.label"); //$NON-NLS-1$
addCheckBox(codeGenComposite, label, PREF_SOURCE_FILE_ATTR, generateValues);
label= JavaUIMessages.getString("CompilerPreferencePage.codegen_unused_local.label"); //$NON-NLS-1$
addCheckBox(codeGenComposite, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT });
String[] values= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 };
String[] valuesLabels= new String[] {
JavaUIMessages.getString("CompilerPreferencePage.jvm11"),
JavaUIMessages.getString("CompilerPreferencePage.jvm12"),
JavaUIMessages.getString("CompilerPreferencePage.jvm13"),
JavaUIMessages.getString("CompilerPreferencePage.jvm14")
};
label= JavaUIMessages.getString("CompilerPreferencePage.codegen_targetplatform.label"); //$NON-NLS-1$
addComboBox(codeGenComposite, label, PREF_CODEGEN_TARGET_PLATFORM, values, valuesLabels);
values= new String[] { VERSION_1_3, VERSION_1_4 };
valuesLabels= new String[] {
JavaUIMessages.getString("CompilerPreferencePage.version13"),
JavaUIMessages.getString("CompilerPreferencePage.version14")
};
label= JavaUIMessages.getString("CompilerPreferencePage.source_compatibility.label"); //$NON-NLS-1$
addComboBox(codeGenComposite, label, PREF_SOURCE_COMPATIBILITY, values, valuesLabels);
TabItem item= new TabItem(folder, SWT.NONE);
item.setText(JavaUIMessages.getString("CompilerPreferencePage.warnings.tabtitle")); //$NON-NLS-1$
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING));
item.setControl(warningsComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(JavaUIMessages.getString("CompilerPreferencePage.generation.tabtitle")); //$NON-NLS-1$
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
item.setControl(codeGenComposite);
return folder;
}
private void addCheckBox(Composite parent, String label, String key, String[] values) {
ControlData data= new ControlData(key, values);
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 2;
Button checkBox= new Button(parent, SWT.CHECK);
checkBox.setText(label);
checkBox.setData(data);
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fSelectionListener);
String currValue= (String)fWorkingValues.get(key);
checkBox.setSelection(data.getSelection(currValue) == 0);
fCheckBoxes.add(checkBox);
}
private void addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels) {
ControlData data= new ControlData(key, values);
Label labelControl= new Label(parent, SWT.NONE);
labelControl.setText(label);
labelControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridData gd= new GridData();
gd.horizontalAlignment= GridData.FILL;
Combo comboBox= new Combo(parent, SWT.READ_ONLY);
comboBox.setItems(valueLabels);
comboBox.setData(data);
comboBox.setLayoutData(gd);
comboBox.addSelectionListener(fSelectionListener);
String currValue= (String)fWorkingValues.get(key);
comboBox.select(data.getSelection(currValue));
fComboBoxes.add(comboBox);
}
private void controlChanged(Widget widget) {
ControlData data= (ControlData) widget.getData();
String newValue= null;
if (widget instanceof Button) {
newValue= data.getValue(((Button)widget).getSelection());
} else if (widget instanceof Combo) {
newValue= data.getValue(((Combo)widget).getSelectionIndex());
} else {
return;
}
fWorkingValues.put(data.getKey(), newValue);
}
/*
* @see IPreferencePage#performOk()
*/
public boolean performOk() {
String[] allKeys= getAllKeys();
// preserve other options
// store in JCore and the preferences
Hashtable actualOptions= JavaCore.getOptions();
IPreferenceStore store= getPreferenceStore();
boolean hasChanges= false;
for (int i= 0; i < allKeys.length; i++) {
String key= allKeys[i];
String val= (String) fWorkingValues.get(key);
String oldVal= (String) actualOptions.get(key);
hasChanges= hasChanges | !val.equals(oldVal);
actualOptions.put(key, val);
store.setValue(key, val);
}
JavaCore.setOptions(actualOptions);
if (hasChanges) {
String title= JavaUIMessages.getString("CompilerPreferencePage.needsbuild.title");
String message= JavaUIMessages.getString("CompilerPreferencePage.needsbuild.message");
if (MessageDialog.openQuestion(getShell(), title, message)) {
doFullBuild();
}
}
return super.performOk();
}
private void doFullBuild() {
ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
try {
dialog.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
JavaPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InterruptedException e) {
// cancelled by user
} catch (InvocationTargetException e) {
String title= JavaUIMessages.getString("CompilerPreferencePage.builderror.title");
String message= JavaUIMessages.getString("CompilerPreferencePage.builderror.message");
ExceptionHandler.handle(e, getShell(), title, message);
}
}
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
fWorkingValues= JavaCore.getDefaultOptions();
updateControls();
super.performDefaults();
}
private void updateControls() {
// update the UI
for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
Button curr= (Button) fCheckBoxes.get(i);
ControlData data= (ControlData) curr.getData();
String currValue= (String) fWorkingValues.get(data.getKey());
curr.setSelection(data.getSelection(currValue) == 0);
}
for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
Combo curr= (Combo) fComboBoxes.get(i);
ControlData data= (ControlData) curr.getData();
String currValue= (String) fWorkingValues.get(data.getKey());
curr.select(data.getSelection(currValue));
}
}
}
|
6,055 |
Bug 6055 rename a read-only package does not issue a warning
|
renaming a read-only package should ask for confirmation (e.g. issue a waring - like it does on projects and source folders)
|
resolved fixed
|
d8d1e8e
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T11:23:54Z | 2001-11-19T11:40:00Z |
org.eclipse.jdt.ui/core
| |
6,055 |
Bug 6055 rename a read-only package does not issue a warning
|
renaming a read-only package should ask for confirmation (e.g. issue a waring - like it does on projects and source folders)
|
resolved fixed
|
d8d1e8e
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T11:23:54Z | 2001-11-19T11:40:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageRefactoring.java
| |
6,835 |
Bug 6835 characters and doesn't work in Java editor on Swedish keyboard
|
On a Swedish keybord the charaters and doesnt work. If I type one of theese charaters 9 gibberlish character symbols occur on the screen. This happens on XFree 4.1.0 X server and Redhat 7.2
|
resolved fixed
|
51cab62
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T11:38:01Z | 2001-12-12T04:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.corext.util.AllTypesCache;
import org.eclipse.jdt.internal.corext.util.TypeInfo;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.StringMatcher;
import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;
/**
* A dialog to select a type from a list of types.
*/
public class TypeSelectionDialog extends TwoPaneElementSelector {
private static class TypeFilterMatcher implements FilteredList.FilterMatcher {
private StringMatcher fMatcher;
private StringMatcher fQualifierMatcher;
/*
* @see FilteredList.FilterMatcher#setFilter(String, boolean)
*/
public void setFilter(String pattern, boolean ignoreCase, boolean igoreWildCards) {
int qualifierIndex= pattern.lastIndexOf("."); //$NON-NLS-1$
// type
if (qualifierIndex == -1) {
fQualifierMatcher= null;
fMatcher= new StringMatcher(pattern + '*', ignoreCase, igoreWildCards);
// qualified type
} else {
fQualifierMatcher= new StringMatcher(pattern.substring(0, qualifierIndex), ignoreCase, igoreWildCards);
fMatcher= new StringMatcher(pattern.substring(qualifierIndex + 1), ignoreCase, igoreWildCards);
}
}
/*
* @see FilteredList.FilterMatcher#match(Object)
*/
public boolean match(Object element) {
if (!(element instanceof TypeInfo))
return false;
TypeInfo type= (TypeInfo) element;
if (!fMatcher.match(type.getTypeName()))
return false;
if (fQualifierMatcher == null)
return true;
return fQualifierMatcher.match(type.getTypeContainerName());
}
}
/*
* A string comparator which is aware of obfuscated code
* (type names starting with lower case characters).
*/
private static class StringComparator implements Comparator {
public int compare(Object left, Object right) {
String leftString= (String) left;
String rightString= (String) right;
if (Character.isLowerCase(leftString.charAt(0)) &&
!Character.isLowerCase(rightString.charAt(0)))
return +1;
if (Character.isLowerCase(rightString.charAt(0)) &&
!Character.isLowerCase(leftString.charAt(0)))
return -1;
return leftString.compareToIgnoreCase(rightString);
}
}
private IRunnableContext fRunnableContext;
private IJavaSearchScope fScope;
private int fElementKinds;
/**
* Constructs a type selection dialog.
* @param parent the parent shell.
* @param context the runnable context.
* @param elementKinds <code>IJavaSearchConstants.CLASS</code>, <code>IJavaSearchConstants.INTERFACE</code>
* or <code>IJavaSearchConstants.TYPE</code>
* @param scope the java search scope.
*/
public TypeSelectionDialog(Shell parent, IRunnableContext context, int elementKinds, IJavaSearchScope scope) {
super(parent, new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY),
new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_CONTAINER_ONLY + TypeInfoLabelProvider.SHOW_ROOT_POSTFIX));
Assert.isNotNull(context);
Assert.isNotNull(scope);
fRunnableContext= context;
fScope= scope;
fElementKinds= elementKinds;
setUpperListLabel(JavaUIMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$
setLowerListLabel(JavaUIMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$
}
public void create() {
if (getFilter() == null)
setFilter("A"); //$NON-NLS-1$
super.create();
}
/*
* @see AbstractElementListSelectionDialog#createFilteredList(Composite)
*/
protected FilteredList createFilteredList(Composite parent) {
FilteredList list= super.createFilteredList(parent);
fFilteredList.setFilterMatcher(new TypeFilterMatcher());
fFilteredList.setComparator(new StringComparator());
return list;
}
/**
* @see Window#open()
*/
public int open() {
final ArrayList typeList= new ArrayList();
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
AllTypesCache.getTypes(fScope, fElementKinds, monitor, typeList);
} catch (JavaModelException e) {
throw new InvocationTargetException(e);
}
if (monitor.isCanceled()) {
throw new InterruptedException();
}
}
};
try {
fRunnableContext.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, "Exception", "Unexpected exception. See log for details.");
} catch (InterruptedException e) {
// cancelled by user
return CANCEL;
}
// #6385 workaround: filter out anonymous (!) classes
List filteredList= new ArrayList(typeList.size());
for (Iterator iterator = typeList.iterator(); iterator.hasNext();) {
TypeInfo info = (TypeInfo) iterator.next();
if (info.getTypeName().length() != 0)
filteredList.add(info);
}
if (filteredList.isEmpty()) {
String title= JavaUIMessages.getString("TypeSelectionDialog.notypes.title"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.notypes.message"); //$NON-NLS-1$
MessageDialog.openInformation(getShell(), title, message);
return CANCEL;
}
TypeInfo[] typeRefs= (TypeInfo[])filteredList.toArray(new TypeInfo[filteredList.size()]);
setElements(typeRefs);
return super.open();
}
/**
* @see SelectionStatusDialog#computeResult()
*/
protected void computeResult() {
TypeInfo ref= (TypeInfo) getLowerSelectedElement();
if (ref == null)
return;
try {
IType type= ref.resolveType(fScope);
if (type == null) {
// not a class file or compilation unit
String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
setResult(null);
} else {
List result= new ArrayList(1);
result.add(type);
setResult(result);
}
} catch (JavaModelException e) {
String title= JavaUIMessages.getString("TypeSelectionDialog.errorTitle"); //$NON-NLS-1$
String message= JavaUIMessages.getString("TypeSelectionDialog.errorMessage"); //$NON-NLS-1$
MessageDialog.openError(getShell(), title, message);
setResult(null);
}
}
}
|
6,682 |
Bug 6682 Search in Hierarchy does not find Declarations in supers
|
20011206 - (happened to be on Windows2000) - Open an editor on a class that is in a deep hierarchy (I was in List in the SWT Widget hierarchy) - In the Outline view, select a method that has a declaration in several classes in the hierarchy (I selected createScrollBar(int) - this method is defined in Scrollable and redefined in List) - Context menu -> Declarations -> Hierarchy - It only found the method that was defined in List, and it missed the one that is defined in Scrollable (super of List) I notice that if you select the method (createScrollBar(int))in the superclass (Scrollable) and search for declarations in the hierarchy, it will find all of the methods. So I suspect that the search algorithm is only looking "down" for declarations, when it needs to look "up" as well.
|
resolved fixed
|
cda0387
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T13:43:51Z | 2001-12-07T18:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindDeclarationsInHierarchyAction.java
|
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.ui.JavaPlugin;
public class FindDeclarationsInHierarchyAction extends FindDeclarationsAction {
public FindDeclarationsInHierarchyAction() {
super(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.label"), new Class[] {IField.class, IMethod.class} ); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.tooltip")); //$NON-NLS-1$
}
protected JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException {
IType type= getType(element);
return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(type), getScopeDescription(type), getCollector());
};
protected IJavaSearchScope getScope(IType type) throws JavaModelException {
if (type != null)
return SearchEngine.createHierarchyScope(type);
else
return super.getScope(type);
}
protected String getScopeDescription(IType type) {
String typeName= ""; //$NON-NLS-1$
if (type != null)
typeName= type.getElementName();
return SearchMessages.getFormattedString("HierarchyScope", new String[] {typeName}); //$NON-NLS-1$
}
}
|
6,935 |
Bug 6935 CodeCompletion: Fill arguments feature bugs (Int1211)
| null |
resolved fixed
|
6261ef6
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T16:57:38Z | 2001-12-14T14:26:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ExperimentalResultCollector.java
|
package org.eclipse.jdt.internal.ui.text.java;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.jface.text.ITextViewer;
/**
* Bin to collect the proposal of the infrastructure on code assist in a java text.
*/
public class ExperimentalResultCollector extends ResultCollector {
private ITextViewer fViewer;
// XXX experimental
protected JavaCompletionProposal createMethodCompletion(char[] declaringTypeName, char[] name, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {
JavaCompletionProposal original= super.createMethodCompletion(declaringTypeName, name, parameterTypeNames, parameterNames, returnTypeName, completionName, modifiers, start, end);
// XXX hack to handle empty code completion
if (completionName.length == 0)
return original;
int count= parameterNames.length;
int[] offsets= new int[count];
int[] lengths= new int[count];
StringBuffer buffer= new StringBuffer();
buffer.append(name);
buffer.append('(');
for (int i= 0; i != count; i++) {
if (i != 0)
buffer.append(", ");
offsets[i]= buffer.length();
buffer.append(parameterNames[i]);
lengths[i]= buffer.length() - offsets[i];
}
buffer.append(')');
if (new String(returnTypeName).equals("void"))
buffer.append(';');
return new ExperimentalProposal(buffer.toString(), start, end - start, original.getImage(),
original.getDisplayString(), offsets, lengths, fViewer);
}
/**
* Sets the viewer.
* @param viewer The viewer to set
*/
public void setViewer(ITextViewer viewer) {
fViewer= viewer;
}
}
|
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
org.eclipse.jdt.ui/core
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/MethodChecks.java
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
org.eclipse.jdt.ui/core
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodInInterfaceRefactoring.java
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
org.eclipse.jdt.ui/core
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameVirtualMethodRefactoring.java
| |
3,968 |
Bug 3968 Rename refactoring for overridden methods should be more supportive (1GFAYM4)
|
EG (6/14/01 10:46:47 AM) 1) try to renaming a method that is overridden from a base class 2) the precondition check tells me that I should do this in the most abstract class. I'm not told what this abstract class is. If we can't compute it easily we should offer to open the type hierarchy on this type. NOTES: AK (8/15/2001 4:14:27 PM) waiting for: 1GII6W0: ITPJCORE:WINNT - search for method declarations in hierarchy does not work as expected
|
resolved fixed
|
b055bd7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2002-02-08T17:18:43Z | 2001-10-11T03:13:20Z |
org.eclipse.jdt.ui/core
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.