Skip to content

Commit ce919d0

Browse files
author
Chris
committed
Updates for issues #23/27 and made changes so that plugin will stay active when switching between files.
1 parent 7ecf81c commit ce919d0

7 files changed

Lines changed: 24 additions & 552 deletions

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ public class AnnotationManager implements ISelectionChangedListener {
6161
* @param anEditor
6262
*/
6363
public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
64-
64+
isActive = false;
6565
parseCU(anEditor);
66-
6766
sourceViewer = EclipseHacks.getSourceViewer(anEditor);
6867
painter = new ProgramNavigationPainter(sourceViewer);
6968
painter.addSelectionChangedListener(this);
@@ -72,7 +71,6 @@ public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
7271
}
7372

7473
public void selectionChanged(ITextSelection selection) {
75-
System.out.println("selectionChanged");
7674
painter.removeAllAnnotations();
7775
try {
7876
DataNode one = getNode(selection.getOffset());
@@ -85,12 +83,10 @@ public void selectionChanged(ITextSelection selection) {
8583
JavaEditor j = (JavaEditor) activeEditor;
8684
upBreadcrumb = j.getBreadcrumb();
8785
downBreadcrumb = j.getBreadcrumb2();
88-
System.out.println(isActive+ " is active");
89-
System.out.println(upBreadcrumb.isActive());
90-
System.out.println(downBreadcrumb.isActive());
91-
System.out.println(j.areBreadcrumbsActive());
9286
if(!isActive) {
9387
isActive = true;
88+
upBreadcrumb.setText(null);
89+
downBreadcrumb.setText(null);
9490
ShowDataInBreadcrumbAction crumbs = new ShowDataInBreadcrumbAction(j, activePage);
9591
crumbs.run();
9692
}

dataTool/src/dataTool/EnableNavigationAction.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import org.eclipse.jdt.core.JavaModelException;
88
import org.eclipse.jdt.internal.ui.JavaPlugin;
99
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
10-
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.IBreadcrumb;
11-
import org.eclipse.jdt.internal.ui.javaeditor.ShowInBreadcrumbAction;
1210
import org.eclipse.jdt.internal.ui.javaeditor.ToggleBreadcrumbAction;
11+
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.IBreadcrumb;
1312
import org.eclipse.jdt.ui.JavaUI;
1413
import org.eclipse.jface.action.IAction;
1514
import org.eclipse.jface.preference.IPreferenceStore;
@@ -47,7 +46,7 @@ public class EnableNavigationAction implements IWorkbenchWindowActionDelegate {
4746

4847
//whether the listener is currently enabled
4948
private boolean isEnabled = false;
50-
49+
5150
public void dispose() {
5251
if(annotationManager!=null)
5352
annotationManager.dispose();
@@ -76,7 +75,15 @@ public void partActivated(IWorkbenchPart arg0) {
7675
@Override
7776
public void partBroughtToTop(IWorkbenchPart arg0) {
7877
// Auto-generated method stub
79-
78+
arg0.getSite().getPage().activate(arg0);
79+
try {
80+
dispose();
81+
isEnabled = false;
82+
reset(arg0.getSite().getPage());
83+
} catch (JavaModelException e) {
84+
// Auto-generated catch block
85+
e.printStackTrace();
86+
}
8087
}
8188

8289
@Override
@@ -94,16 +101,7 @@ public void partDeactivated(IWorkbenchPart arg0) {
94101
@Override
95102
public void partOpened(IWorkbenchPart arg0) {
96103
// Auto-generated method stub
97-
System.out.println("file opened");
98-
arg0.getSite().getPage().activate(arg0);
99-
try {
100-
dispose();
101-
isEnabled = false;
102-
reset(arg0.getSite().getPage());
103-
} catch (JavaModelException e) {
104-
// Auto-generated catch block
105-
e.printStackTrace();
106-
}
104+
107105
}
108106

109107
});
@@ -147,12 +145,6 @@ public void reset(IWorkbenchPage workbench) throws JavaModelException {
147145
newPage = workbench;
148146
}
149147
JavaEditor editor = (JavaEditor)newPage.getActiveEditor();
150-
IBreadcrumb top = editor.getBreadcrumb();
151-
IBreadcrumb bottom = editor.getBreadcrumb2();
152-
editor.showBreadcrumbs();
153-
System.out.println(editor.getTitle());
154-
top.setText(null);
155-
bottom.setText(null);
156148
init(newPage.getWorkbenchWindow());
157149
run(null);
158150
}

dataTool/src/dataTool/annotations/LinkAnnotation.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
import dataTool.DataNode;
4040
import dataTool.EnableNavigationAction;
4141
import dataTool.Finder;
42-
import dataTool.ui.NavigationDownBox;
43-
import dataTool.ui.NavigationUpBox;
42+
4443
import edu.pdx.cs.multiview.jdt.util.JDTUtils;
4544
import edu.pdx.cs.multiview.jface.annotation.ISelfDrawingAnnotation;
4645

@@ -104,23 +103,14 @@ else if(linkNode.getDeclarationMethod() != null) {
104103
try {
105104
search = searchResultsUp.toArray();
106105
im = (IMethod)search[0];
107-
try {
108-
if(im.getSource() == null) {
109-
JOptionPane.showMessageDialog(null, INVALID, "Error",JOptionPane.ERROR_MESSAGE);
110-
}
111-
} catch (HeadlessException | JavaModelException e1) {
112-
// Auto-generated catch block
113-
e1.printStackTrace();
106+
searchMethod = linkNode.getDeclarationMethod().getName().getIdentifier();
107+
editor = JavaUI.openInEditor(im, true, true);
108+
if(editor != null) {
109+
String code = JDTUtils.getCUSource((AbstractTextEditor) editor);
110+
lineSearch(code.toCharArray(), im);
111+
goToLine(editor);
112+
load = true;
114113
}
115-
searchMethod = linkNode.getDeclarationMethod().getName().getIdentifier();
116-
load = false;
117-
editor = JavaUI.openInEditor(im, true, true);
118-
if(editor != null) {
119-
String code = JDTUtils.getCUSource((AbstractTextEditor) editor);
120-
lineSearch(code.toCharArray(), im);
121-
goToLine(editor);
122-
load = true;
123-
}
124114
} catch (Exception e) {
125115
// Auto-generated catch block
126116
e.printStackTrace();
@@ -131,31 +121,7 @@ else if(linkNode.getDeclarationMethod() != null) {
131121
});
132122
}
133123

134-
/**
135-
* Searches for line of where method is invoked in new file
136-
* @param source: char[] of code
137-
* @param method: IMethod we're searching for
138-
*/
139-
<<<<<<< HEAD
140-
public static void openLink(IMethod i) {
141-
IEditorPart editor = null;
142-
try {
143-
editor = JavaUI.openInEditor(i, true, true);
144-
} catch (JavaModelException | PartInitException e) {
145-
// Auto-generated catch block
146-
e.printStackTrace();
147-
}
148-
if(editor != null) {
149-
String code = JDTUtils.getCUSource((AbstractTextEditor) editor);
150-
lineSearch(code.toCharArray(), i);
151-
goToLine(editor);
152-
}
153-
}
154-
155-
private static void lineSearch(char[] source, IMethod method) {
156-
=======
157124
private void lineSearch(char[] source, IMethod method) {
158-
>>>>>>> 9e7430d02c6f5eb51c986bd85f19126c29bb5e91
159125
ASTParser parser = ASTParser.newParser(AST.JLS3);
160126
parser.setSource(source);
161127
parser.setKind(ASTParser.K_COMPILATION_UNIT);

dataTool/src/dataTool/annotations/SuggestedSelectionAnnotation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.eclipse.swt.graphics.GC;
77
import org.eclipse.swt.graphics.Point;
88

9-
import dataTool.ui.NavigationUpBox;
109
import edu.pdx.cs.multiview.jface.annotation.ISelfDrawingAnnotation;
1110

1211
/**

dataTool/src/dataTool/ui/NavigationDownBox.java

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)