Skip to content

Commit e398e75

Browse files
author
Chris
committed
Latest version of the tool, few minor issues to fix
1 parent e79f186 commit e398e75

4 files changed

Lines changed: 40 additions & 36 deletions

File tree

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.eclipse.jdt.core.dom.MethodDeclaration;
1515
import org.eclipse.jdt.core.dom.SimpleName;
1616
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
17+
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditorBreadcrumb;
1718
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.EditorBreadcrumb;
1819
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.IBreadcrumb;
1920
import org.eclipse.jface.action.Action;
@@ -71,24 +72,30 @@ public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
7172
}
7273

7374
public void selectionChanged(ITextSelection selection) {
75+
System.out.println("selectionChanged");
7476
painter.removeAllAnnotations();
7577
try {
7678
DataNode one = getNode(selection.getOffset());
7779
Finder finder = Finder.getInstance();
7880
if(one != null) {
7981
addAnnotation(one);
80-
currentSearch = one.getValue();
82+
currentSearch = one.getBinding();
8183
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
8284
IEditorPart activeEditor = activePage.getActiveEditor();
83-
System.out.println("down "+ one.getDeclarationMethod());
8485
JavaEditor j = (JavaEditor) activeEditor;
8586
upBreadcrumb = j.getBreadcrumb();
8687
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());
8792
if(!isActive) {
8893
isActive = true;
8994
ShowDataInBreadcrumbAction crumbs = new ShowDataInBreadcrumbAction(j, activePage);
9095
crumbs.run();
9196
}
97+
upBreadcrumb.setText(null);
98+
downBreadcrumb.setText(null);
9299
DataCallHierarchy call = new DataCallHierarchy();
93100
Set<IMethod> searchUp = null;
94101
Set<IMethod> searchDown = null;
@@ -129,7 +136,6 @@ else if(dn.getStartPosition() > sourceViewer.getBottomIndexEndOffset()) {
129136
}
130137
upBreadcrumb.setText(textUp);
131138
downBreadcrumb.setText(textDown);
132-
133139
}
134140
else {
135141
removeAnnotations();
@@ -230,7 +236,6 @@ private void addAnnotationsAt(int statementStart, int length, boolean isHighligh
230236
public void removeAnnotations() {
231237
try {
232238
if (highlightAnnotation != null) {
233-
// painter.removeAnnotation(highlightAnnotation);
234239
painter.removeAllAnnotations();
235240
}
236241
} catch (Exception ignore) {
@@ -239,13 +244,10 @@ public void removeAnnotations() {
239244

240245
public void dispose() {
241246
painter.dispose();
242-
//dataBreadcrumb.dispose();
243-
//isActive = false;
244247
currentSearch = null;
245248
}
246249

247250
public void selectionChanged(SelectionChangedEvent event) {
248-
painter.removeAllAnnotations();
249251
selectionChanged((ITextSelection) event.getSelection());
250252
}
251253
}

dataTool/src/dataTool/EnableNavigationAction.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public void partDeactivated(IWorkbenchPart arg0) {
9393

9494
@Override
9595
public void partOpened(IWorkbenchPart arg0) {
96-
// TODO Auto-generated method stub
96+
// Auto-generated method stub
97+
System.out.println("file opened");
9798
arg0.getSite().getPage().activate(arg0);
9899
try {
99100
dispose();
@@ -132,6 +133,11 @@ public void selectionChanged(IAction action, ISelection selection) {
132133
//do nothing
133134
}
134135

136+
/**
137+
* Resets the plugin when user opens a new page
138+
* @param workbench
139+
* @throws JavaModelException
140+
*/
135141
public void reset(IWorkbenchPage workbench) throws JavaModelException {
136142
IWorkbenchPage newPage;
137143
if(workbench == null) {
@@ -140,6 +146,13 @@ public void reset(IWorkbenchPage workbench) throws JavaModelException {
140146
else {
141147
newPage = workbench;
142148
}
149+
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);
143156
init(newPage.getWorkbenchWindow());
144157
run(null);
145158
}

dataTool/src/dataTool/annotations/LinkAnnotation.java

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class LinkAnnotation extends Annotation implements ISelfDrawingAnnotation
5151
public static Set<IMethod> searchResultsUp;
5252
public static Set<IMethod> searchResultsDown;
5353
public String searchMethod = "";
54+
private IEditorPart editor = null;
55+
private boolean load = true;
5456

5557
public static final String INVALID = "Method not in scope of project.";
5658

@@ -68,33 +70,29 @@ public void draw(GC gc, StyledText textWidget, int offset, int length) {
6870

6971
@Override
7072
public void mouseDoubleClick(MouseEvent arg0) {
71-
mouseDown(arg0);
73+
//mouseDown(arg0);
7274
}
7375

7476
@Override
7577
public void mouseDown(MouseEvent arg0) {
78+
79+
}
80+
81+
@Override
82+
public void mouseUp(MouseEvent arg0) {
7683
int click = textWidget.getOffsetAtLocation(new Point(arg0.x,arg0.y));
77-
boolean load = true;
78-
if(click >= style.start && click <= style.start+style.length){
84+
if(click >= style.start && click <= style.start+style.length && load){
85+
load = false;
7986
Object[] search;
8087
IMethod im;
81-
System.out.println("clicked");
8288
if(linkNode.getInvocationMethod() != null) {
8389
search = searchResultsDown.toArray();
8490
for(Object o: search) {
8591
im = (IMethod) o;
86-
try {
87-
if(im.getSource() == null) {
88-
load = false;
89-
JOptionPane.showMessageDialog(null, INVALID, "Error",JOptionPane.ERROR_MESSAGE);
90-
}
91-
} catch (HeadlessException | JavaModelException e1) {
92-
// Auto-generated catch block
93-
e1.printStackTrace();
94-
}
95-
if(load && im.getElementName().equals(linkNode.getInvocationMethod().getName().getIdentifier())) {
92+
if(im.getElementName().equals(linkNode.getInvocationMethod().getName().getIdentifier())) {
9693
try {
9794
JavaUI.openInEditor(im, true, true);
95+
load = true;
9896
} catch (PartInitException | JavaModelException e) {
9997
// Auto-generated catch block
10098
e.printStackTrace();
@@ -108,36 +106,28 @@ else if(linkNode.getDeclarationMethod() != null) {
108106
im = (IMethod)search[0];
109107
try {
110108
if(im.getSource() == null) {
111-
load = false;
112109
JOptionPane.showMessageDialog(null, INVALID, "Error",JOptionPane.ERROR_MESSAGE);
113110
}
114111
} catch (HeadlessException | JavaModelException e1) {
115112
// Auto-generated catch block
116113
e1.printStackTrace();
117114
}
118-
if(load) {
119115
searchMethod = linkNode.getDeclarationMethod().getName().getIdentifier();
120-
IEditorPart editor = JavaUI.openInEditor(im, true, true);
116+
load = false;
117+
editor = JavaUI.openInEditor(im, true, true);
121118
if(editor != null) {
122119
String code = JDTUtils.getCUSource((AbstractTextEditor) editor);
123120
lineSearch(code.toCharArray(), im);
124121
goToLine(editor);
122+
load = true;
125123
}
126-
}
127124
} catch (Exception e) {
128125
// Auto-generated catch block
129126
e.printStackTrace();
130127
}
131128
}
132129
}
133130
}
134-
135-
@Override
136-
public void mouseUp(MouseEvent arg0) {
137-
// Do nothing
138-
139-
}
140-
141131
});
142132
}
143133

dataTool/src/dataTool/ui/ShowDataInBreadcrumbAction.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ public ShowDataInBreadcrumbAction(JavaEditor editor, IWorkbenchPage wbpage) {
5959
public void run() {
6060
IBreadcrumb breadcrumb = fEditor.getBreadcrumb();
6161
JavaEditorBreadcrumb j = (JavaEditorBreadcrumb)breadcrumb;
62-
if (breadcrumb == null)
63-
return;
6462
IBreadcrumb breadcrumb2 = fEditor.getBreadcrumb2();
6563
JavaEditorBreadcrumb j2 = (JavaEditorBreadcrumb)breadcrumb2;
66-
if (breadcrumb2 == null)
64+
if (breadcrumb2 == null || breadcrumb2 == null) {
6765
return;
66+
}
6867

6968
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
7069
store.setValue(getPreferenceKey(), true);

0 commit comments

Comments
 (0)