Skip to content

Commit e45d337

Browse files
author
Chris
committed
Attempting to fix disabling of tool
1 parent dd1e805 commit e45d337

5 files changed

Lines changed: 64 additions & 12 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
# Program-Navigation-Plugin
22

33
Chris and Justin's Eclipse Plug-in tool
4+
5+
To open and run the tool:
6+
1. Open Eclipse
7+
- Make sure the selected workspace is /home/flower/Desktop/flower
8+
- When Eclipse opens, make sure you're viewing the Plugin Development Perspective
9+
2. In the Package Explorer open the dataTool folder navigate to META-INF/MANIFEST.MF
10+
3. Right-click on MANIFEST.MF and select Run As > Eclipse Application
11+
- When the message pops up about errors in org.eclipse.jdt.ui, click Proceed
12+
4. A new Eclipse window will open with the plugin installed
13+
5. In the toolbar click on the icon with an 'x' inside of a white box to start Flower on the sample project
14+
15+
Testing Flower:
16+
Our tool has many different features to help developers navigate their source code.
17+
* Clicking on any variable automatically invokes the tool and you will be able to see everywhere the variable is being used indicated by the blue highlighting.
18+
- The tool is automatically re-invoked every time you click the mouse in the editor.
19+
* If any occurrences of the selected variable are not visible on the screen, a link will be provided in the top or bottom breadcrumbs displaying the line number where the variable is located based on your current position.
20+
- The top box will display links to occurrences higher in the code outside of the current view.
21+
- The bottom box will display links to occurrences lower in the code.
22+
* In addition to line numbers, the top and bottom boxes also display links to methods where the selected variable is modified or referenced.
23+
- The breadcrumb in the top of the editor will link to methods where the selected variable is passed in as a parameter.
24+
- The breadcrumb at the bottom of the editor will display links to methods that use the current variable as a parameter.
25+
* When variables used as parameters are selected, links will also appear in the editor to link directly to an instance where the method is called if the variable is a formal parameter passed in or to the declaration of the method where the argument is used. The tool will automatically highlight the new variable referencing the data from the previous search.
26+
- A Source Not Found error will be thrown if you click on a link in the breadcrumbs or the editor that is outside the scope of the project.
27+
28+
Log In:
29+
- If needed, the username and password for this virtual machine are both "flower".
30+

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class AnnotationManager implements ISelectionChangedListener {
4848
private static boolean isActive = false;
4949
private IBreadcrumb upBreadcrumb;
5050
private IBreadcrumb downBreadcrumb;
51+
private ShowDataInBreadcrumbAction crumbs;
5152

5253
// the visitor for the editor
5354
private Visitor visitor;
@@ -87,7 +88,7 @@ public void selectionChanged(ITextSelection selection) {
8788
isActive = true;
8889
upBreadcrumb.setText(null);
8990
downBreadcrumb.setText(null);
90-
ShowDataInBreadcrumbAction crumbs = new ShowDataInBreadcrumbAction(j, activePage);
91+
crumbs = new ShowDataInBreadcrumbAction(j, activePage);
9192
crumbs.run();
9293
}
9394
DataCallHierarchy call = new DataCallHierarchy();
@@ -250,8 +251,11 @@ public void dispose() {
250251

251252
public void deactivate() {
252253
isActive = false;
254+
crumbs.stop();
253255
upBreadcrumb.dispose();
254256
downBreadcrumb.dispose();
257+
removeAnnotations();
258+
dispose();
255259
}
256260

257261
public void selectionChanged(SelectionChangedEvent event) {

dataTool/src/dataTool/EnableNavigationAction.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ private void enable(IEditorPart activeEditor) {
6464
annotationManager = new AnnotationManager((AbstractDecoratedTextEditor)activeEditor);
6565
}
6666
}
67+
68+
/**
69+
* Disables the plugin
70+
*/
71+
private void disable() {
72+
if(annotationManager!=null)
73+
annotationManager.deactivate();
74+
}
6775

6876
public void init(IWorkbenchWindow window) {
6977
this.page = window.getActivePage();
@@ -115,16 +123,17 @@ public void partOpened(IWorkbenchPart arg0) {
115123
public void run(IAction action) {
116124
//JavaCore.cre
117125
try {
118-
if(!isEnabled )
119-
enable(page.getActiveEditor());
120-
121-
else
122-
dispose();
123-
126+
if(!isEnabled) {
127+
enable(page.getActiveEditor());
128+
isEnabled = true;
129+
}
130+
else {
131+
isEnabled = false;
132+
disable();
133+
Activator.getDefault().shutdown();
134+
}
124135
} catch (Exception e) {
125136
Activator.logError(e);
126-
} finally {
127-
isEnabled = !isEnabled;
128137
}
129138
}
130139

dataTool/src/dataTool/annotations/SuggestedSelectionAnnotation.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class SuggestedSelectionAnnotation extends Annotation implements ISelfDra
2222
* Function that creates highlight on appropriate word.
2323
*/
2424
public void draw(GC gc, StyledText textWidget, int offset, int length) {
25+
if(gc.getBackground()==color) {
26+
return;
27+
}
2528
gc.setBackground(color);
2629
gc.setAlpha(50);
2730

dataTool/src/dataTool/ui/ShowDataInBreadcrumbAction.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,28 @@ public ShowDataInBreadcrumbAction(JavaEditor editor, IWorkbenchPage wbpage) {
5858
*/
5959
public void run() {
6060
IBreadcrumb breadcrumb = fEditor.getBreadcrumb();
61-
JavaEditorBreadcrumb j = (JavaEditorBreadcrumb)breadcrumb;
6261
IBreadcrumb breadcrumb2 = fEditor.getBreadcrumb2();
63-
JavaEditorBreadcrumb j2 = (JavaEditorBreadcrumb)breadcrumb2;
6462
if (breadcrumb2 == null || breadcrumb2 == null) {
6563
return;
6664
}
6765

68-
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
66+
IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
6967
store.setValue(getPreferenceKey(), true);
7068
fEditor.showBreadcrumbs();
7169
breadcrumb.activate();
7270
breadcrumb2.activate();
7371
}
72+
73+
public void stop() {
74+
IBreadcrumb breadcrumb = fEditor.getBreadcrumb();
75+
IBreadcrumb breadcrumb2 = fEditor.getBreadcrumb2();
76+
if (breadcrumb != null && breadcrumb2 != null) {
77+
breadcrumb.dispose();
78+
breadcrumb2.dispose();
79+
}
80+
IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
81+
store.setValue(getPreferenceKey(), false);
82+
}
7483

7584
/**
7685
* Returns the preference key for the breadcrumb. The

0 commit comments

Comments
 (0)