Skip to content

Commit

Permalink
Fixed gaze type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin9999 committed Nov 15, 2017
1 parent 826601b commit 6d2969e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/edu/ysu/itrace/ControlView.java
Expand Up @@ -384,7 +384,7 @@ public void partBroughtToTop(IWorkbenchPartReference partRef) {
IEditorPart ep = (IEditorPart)partRef.getPart(true);
ITrace.getDefault().setLineManager(ep.getEditorSite().getActionBars().getStatusLineManager());;
}
}
}

@Override
public void partClosed(IWorkbenchPartReference partRef) {
Expand Down
2 changes: 1 addition & 1 deletion src/edu/ysu/itrace/HandlerBindManager.java
Expand Up @@ -29,7 +29,7 @@ public class HandlerBindManager {
public static void bind(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(true);
Control control = part.getAdapter(Control.class);

System.out.println(control);
//is an EditorPart
if (control != null) {
bindControl(partRef, control, false);
Expand Down
24 changes: 17 additions & 7 deletions src/edu/ysu/itrace/gaze/handlers/StyledTextGazeHandler.java
@@ -1,6 +1,6 @@
package edu.ysu.itrace.gaze.handlers;

import org.eclipse.jface.text.source.projection.ProjectionViewer;
//import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;

Expand All @@ -16,7 +16,7 @@
*/
public class StyledTextGazeHandler implements IGazeHandler {
private StyledText targetStyledText;
private ProjectionViewer projectionViewer;
//private ProjectionViewer projectionViewer;

/**
* Constructs a new gaze handler for the target StyledText object
Expand All @@ -43,16 +43,18 @@ public IStyledTextGazeResponse handleGaze(int absoluteX, int absoluteY,
return null;
AstManager astManager = (AstManager) targetStyledText
.getData(ControlView.KEY_AST);
projectionViewer = astManager.getProjectionViewer();
int lineOffset = targetStyledText.getOffsetAtLine(targetStyledText.getLineIndex(relativeY));
//projectionViewer = astManager.getProjectionViewer();
lineIndex = targetStyledText.getLineIndex(relativeY);
int lineOffset = targetStyledText.getOffsetAtLine(lineIndex);
//int lineOffset = targetStyledText.getOffsetAtLine(targetStyledText.getLineIndex(relativeY));
int offset;
try{
offset = targetStyledText.getOffsetAtLocation(new Point(relativeX, relativeY));
}catch(IllegalArgumentException ex){
return null;
}
col = offset - lineOffset;
lineIndex = projectionViewer.widgetLine2ModelLine(targetStyledText.getLineIndex(relativeY));
//lineIndex = projectionViewer.widgetLine2ModelLine(targetStyledText.getLineIndex(relativeY));

// (0, 0) relative to the control in absolute screen
// coordinates.
Expand Down Expand Up @@ -93,8 +95,16 @@ public String getName() {

@Override
public String getGazeType() {
String[] splitPath = path.split("\\.");
String type = splitPath[splitPath.length-1];
/*String[] splitPath = path.split("\\.");
String type = splitPath[splitPath.length-1];*/
String type = path;
int dotIndex;
for(dotIndex=0; dotIndex<type.length();dotIndex++)
if(path.charAt(dotIndex) == '.')
break;
if(dotIndex+1 == type.length())
return "text";
type = type.substring(dotIndex+1);
return type;
}

Expand Down

0 comments on commit 6d2969e

Please sign in to comment.