Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TestPluginProject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
2 changes: 1 addition & 1 deletion TestPluginProject/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<page
class="testpluginproject.UserLogin"
id="tpp.userlogin"
name="CSC 216 Preferences">
name="CSC Preferences">
</page>
</extension>
</plugin>
Expand Down
29 changes: 25 additions & 4 deletions TestPluginProject/src/testpluginproject/Activator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; //Required for getting OS and other info
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Expand All @@ -80,7 +81,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.internal.Platform;
//import org.eclipse.swt.internal.Platform; //Was causing conflict with org.eclipse.core.runtime.Platform
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
Expand Down Expand Up @@ -581,6 +582,19 @@ public void run() {
}
}
});

//Getting OS Version
String osName = System.getProperty("os.name");
String osVersion = System.getProperty("os.version");
String osArch = System.getProperty("os.arch");

//Getting Java Version
String javaVersion = System.getProperty("java.version");
String javaVendor = System.getProperty("java.vendor");

//Getting Eclipse Version
String eclipseVersion = Platform.getBundle("org.eclipse.core.runtime").getVersion().toString();

List<SequentialEventData> mousEventList = new ArrayList<>();
List<SequentialEventData> keyEvents = new ArrayList<>();
if(mouseClickListener!=null) {
Expand All @@ -600,13 +614,19 @@ public void run() {



//sort based ont he event time
//sort based on the event time
Collections.sort(listSequntialevents, new EventTimeComparator());

EventDataJsonObject edjo = new EventDataJsonObject(listSequntialevents,errorLogList);
// System.out.println("EDJO"+edjo);
edjo.setIPAddress(Utils.getIpAddress());
edjo.setMACAddress(Utils.getMacAddress());
edjo.setPluginVersion("V1.0.1");

//Save OS, Java and Eclipse version info
edjo.setOSInfo(osName, osVersion, osArch);
edjo.setJavaInfo(javaVersion, javaVendor);
edjo.setEclipseInfo(eclipseVersion);
System.out.println("retrived key would be: ");
//System.out.println(retriveKey());
//Save as json
Expand Down Expand Up @@ -710,6 +730,7 @@ private void recordUserAction(String commandId, ICommandService commandService,
//System.out.println("Console Output Data: "+consoleOutput);
//System.out.println("MenubarClick Data: "+MenuBarClickActions);
// System.out.println("WorkSpaceErrorLog Data: "+errorLogList);
keyBoardClickListener.immediateSave(); //Immediate save after some action e.g. cut, copy, paste, etc
Map<String, String> parameters = new HashMap<>();
String [] commandStr = commandId.split("\\.");
String activePart = commandStr[commandStr.length-2];
Expand Down Expand Up @@ -827,12 +848,12 @@ private void showErrorDialog(String message, Throwable throwable) {
private void addSelectionListener(IWorkbenchWindow window) {

if (window != null) {
mouseClickListener = new MouseClickListener(window);
keyBoardClickListener = new KeyBoardClickListener();
mouseClickListener = new MouseClickListener(window, keyBoardClickListener); //Passes keyBoardClickListner info into mouse click for immediate save
window.getShell().getDisplay().addFilter(org.eclipse.swt.SWT.MouseDown, mouseClickListener);
window.getShell().getDisplay().addFilter(org.eclipse.swt.SWT.MouseDoubleClick,mouseClickListener);
window.getShell().getDisplay().addFilter(org.eclipse.swt.SWT.KeyDown, keyBoardClickListener);
window.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(new WindowClickListener(listSequntialevents,window));
window.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(new WindowClickListener(listSequntialevents,window,keyBoardClickListener)); //Passes keyBoardClickListner info into window change for immediate save

}

Expand Down
29 changes: 27 additions & 2 deletions TestPluginProject/src/testpluginproject/UserLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
Expand All @@ -19,13 +20,37 @@ public UserLogin() {
public void createFieldEditors() {
addField(new StringFieldEditor("USERNAME", "Unity ID:", getFieldEditorParent()));
addField(new StringFieldEditor("EMAIL", "NCSU Email:", getFieldEditorParent()));

String[][] semesterOptions = {
{"Fall", "Fall"},
{"Spring", "Spring"},
{"Summer 1", "Summer1"},
{"Summer 2", "Summer2"},
{"Summer 1 and 2", "Summer1&2"},
};
addField(new ComboFieldEditor("SEMESTER", "Semester:", semesterOptions, getFieldEditorParent()));

String[][] courseOptions = {
{"CSC116", "116"},
{"CSC216", "216"},
{"CSC316", "316"},
{"CSC416", "416"},
};
addField(new ComboFieldEditor("COURSE", "Course Number:", courseOptions, getFieldEditorParent()));

String[][] sectionOptions = {
{"Section 001", "001"},
{"Section 002", "002"},
{"Section 003", "003"}
};
addField(new ComboFieldEditor("SECTION", "Section:", sectionOptions, getFieldEditorParent()));
}

@Override
public void init(IWorkbench workbench) {
// second parameter is typically the plug-in id
setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, "csc216.plugin.prefs.page"));
setDescription("CSC 216 Student Info");
setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, "csc.plugin.prefs.page"));
setDescription("CSC Student Info");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public void run() {
}, 5000);

}

//Immediately save whatever is in the buffer
public void immediateSave() {
System.out.println("Immediate save");
if(this.KeyBoardClickEvents.toString().length()!=0) {
processKeyboardEvents();
}
}
private void processKeyboardEvents() {
// TODO Auto-generated method stub
SequentialEventData seDKB = new SequentialEventData("KeyBoardClickEvent", this.KeyBoardClickEvents.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
public class MouseClickListener implements MouseListener, Listener{

IWorkbenchWindow window;
KeyBoardClickListener keyBoardClickListener;
List<SequentialEventData> mouseClickData;
public MouseClickListener(IWorkbenchWindow window) {
//Get keyboard buffer and create a local variable
public MouseClickListener(IWorkbenchWindow window, KeyBoardClickListener keyBoardClickListener) {
this.mouseClickData = new ArrayList<>();
this.keyBoardClickListener = keyBoardClickListener;
this.window = window;
}

Expand Down Expand Up @@ -103,6 +106,7 @@ public void mouseExited(MouseEvent e) {
@Override
public void handleEvent(Event event) {
// TODO Auto-generated method stub
keyBoardClickListener.immediateSave(); //Immediate save keyboard buffer after mouse click
if(window.getActivePage()!=null) {
if(window.getActivePage().getActivePart()!=null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
public class WindowClickListener implements IPartListener {

List<SequentialEventData> activeWindow;
public WindowClickListener(List<SequentialEventData> activeWindowList, IWorkbenchWindow window) {
KeyBoardClickListener keyBoardClickListener; //Create a local variable for keyboard buffer
public WindowClickListener(List<SequentialEventData> activeWindowList, IWorkbenchWindow window, KeyBoardClickListener keyBoardClickListener) {
this.activeWindow = activeWindowList;
this.keyBoardClickListener = keyBoardClickListener; //Save keyboard buffer to a local variable
System.out.println("inside the menubar listener!");
System.out.println("Current Active Window is: "+window.getPartService().getActivePart().getTitle());
}
Expand All @@ -50,6 +52,7 @@ public void partActivated(IWorkbenchPart part) {
GlobalVars.lastOpenFile = path.toFile().toString();
}
}
keyBoardClickListener.immediateSave(); //Immediate save after window switch


this.activeWindow.add(new SequentialEventData("WindowClickEvent",part.getTitle()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public MouseClickData(int X,int Y,String fileName,int Line, int charOffset) {
this.fileName = fileName;
this.time = dateFormat.format(new Date());
this.Line = Line;
this.CharOffset = CharOffset;
// Variable name was causing issue of offset not registering
this.CharOffset = charOffset;

this.username = Utils.getUsernameFromPref();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class EventDataJsonObject {
private String IPAddress;
private String MACAddress;
private String PluginVersion;
//Get additional info about OS, Java and Eclipse
private String osName;
private String osVersion;
private String osArch;
private String javaVersion;
private String javaVendor;
private String eclipseVersion;

public EventDataJsonObject(List<SequentialEventData> sequentialEventData,List<WorkSpaceLog> errorLogList) {
this.errorLogList = errorLogList;
Expand Down Expand Up @@ -76,6 +83,24 @@ public String getMACAddress() {
public void setMACAddress(String mACAddress) {
MACAddress = mACAddress;
}

//OS info
public void setOSInfo(String osName, String osVersion, String osArch) {
this.osName = osName;
this.osVersion = osVersion;
this.osArch = osArch;
}

//Java info
public void setJavaInfo(String javaVersion, String javaVendor) {
this.javaVersion = javaVersion;
this.javaVendor = javaVendor;
}

//Eclipse info
public void setEclipseInfo(String eclipseVersion) {
this.eclipseVersion = eclipseVersion;
}


@Override
Expand Down
6 changes: 5 additions & 1 deletion TestPluginProject/src/testpluginproject/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
public class Utils {

public static String getUsernameFromPref() {
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("csc216.plugin.prefs.page");
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("csc.plugin.prefs.page");
//deal with ill formatted usernames
String username = preferences.get("USERNAME", "default").toLowerCase();
String email = preferences.get("EMAIL", "default").toLowerCase();
String semester = preferences.get("SEMESTER", "default");
String course = preferences.get("COURSE", "default");
String section = preferences.get("SECTION", "default");
System.out.print(semester+" "+course+" "+section);
if(email.contains("@ncsu.edu")) {
if(email.replace("@ncsu.edu", "").equals(username)) {
// They match, we can just move on
Expand Down