Skip to content

Commit 82ce154

Browse files
author
emasliukovas
committed
Fixed warning messages about unused imports.
Created a CyBench preferences tab for the workspace where a user can provide token and email address that will be automatically used when creating a new CyBench run configuration.
1 parent 4741e2f commit 82ce154

File tree

15 files changed

+196
-25
lines changed

15 files changed

+196
-25
lines changed

com.gocypher.cybench.plugin.tools/plugin.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,19 @@
416416
</adapt>
417417
</definition>
418418
</extension>
419+
<extension
420+
point="org.eclipse.ui.preferencePages">
421+
<page
422+
class="com.gocypher.cybench.plugin.tools.preferences.CyBenchPreferencePage"
423+
id="com.gocypher.cybench.plugin.tools.preferences.CyBenchPreferencePage"
424+
name="CyBench">
425+
</page>
426+
</extension>
427+
<extension
428+
point="org.eclipse.core.runtime.preferences">
429+
<initializer
430+
class="com.gocypher.cybench.plugin.tools.preferences.PreferenceInitializer">
431+
</initializer>
432+
</extension>
419433

420434
</plugin>

com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/launcher/CyBenchLauncher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ public static void main(String[] args) throws Exception{
255255
CybenchUtils.storeResultsToFile(pathToReportFile+reportScore+".cyb", reportEncrypted);
256256

257257
if(!response.containsKey("ERROR") && responseWithUrl != null && !responseWithUrl.isEmpty()) {
258-
System.out.println("Benchmark report submitted successfully to "+ Constants.REPORT_URL);
259258
System.out.println("You can find all device benchmarks on "+ deviceReports);
260259
System.out.println("Your report is available at "+ resultURL);
261260
System.out.println("NOTE: It may take a few minutes for your report to appear online");

com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/plugin/CyBenchProjectNature.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
package com.gocypher.cybench.plugin;
2121

2222
import java.io.File;
23-
import java.io.FileOutputStream;
24-
import java.io.FileReader;
2523
import java.io.FileWriter;
2624
import java.nio.file.FileSystems;
2725
import java.nio.file.Files;
@@ -34,9 +32,6 @@
3432
import org.eclipse.buildship.core.GradleCore;
3533
import org.eclipse.buildship.core.GradleWorkspace;
3634
import org.apache.maven.model.Dependency;
37-
import org.apache.maven.model.Model;
38-
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
39-
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
4035
import org.eclipse.core.resources.IProject;
4136
import org.eclipse.core.resources.IProjectNature;
4237
import org.eclipse.core.runtime.CoreException;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
import org.eclipse.jface.preference.*;
4+
import org.eclipse.ui.IWorkbenchPreferencePage;
5+
import org.eclipse.ui.IWorkbench;
6+
import com.gocypher.cybench.plugin.Activator;
7+
8+
/**
9+
* This class represents a preference page that
10+
* is contributed to the Preferences dialog. By
11+
* subclassing <samp>FieldEditorPreferencePage</samp>, we
12+
* can use the field support built into JFace that allows
13+
* us to create a page that is small and knows how to
14+
* save, restore and apply itself.
15+
* <p>
16+
* This page is used to modify preferences only. They
17+
* are stored in the preference store that belongs to
18+
* the main plug-in class. That way, preferences can
19+
* be accessed directly via the preference store.
20+
*/
21+
22+
public class CyBenchPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
23+
24+
public CyBenchPreferencePage() {
25+
super(GRID);
26+
setPreferenceStore(Activator.getDefault().getPreferenceStore());
27+
setDescription("CyBench authentication and identification properties.");
28+
}
29+
30+
/**
31+
* Creates the field editors. Field editors are abstractions of
32+
* the common GUI blocks needed to manipulate various types
33+
* of preferences. Each field editor knows how to save and
34+
* restore itself.
35+
*/
36+
public void createFieldEditors() {
37+
addField(new StringFieldEditor(PreferenceConstants.P_AUTH_TOKEN, "A &repository token:", getFieldEditorParent()));
38+
addField(new StringFieldEditor(PreferenceConstants.P_EMAIL, "&Email address:", getFieldEditorParent()));
39+
}
40+
41+
public void init(IWorkbench workbench) {
42+
}
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
/**
4+
* Constant definitions for plug-in preferences
5+
*/
6+
public class PreferenceConstants {
7+
8+
public static final String P_AUTH_TOKEN = "cybench.benchSendToken";
9+
public static final String P_EMAIL = "cybench.userIdentifyTag";
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
4+
import org.eclipse.jface.preference.IPreferenceStore;
5+
6+
import com.gocypher.cybench.plugin.Activator;
7+
8+
/**
9+
* Class used to initialize default preference values.
10+
*/
11+
public class PreferenceInitializer extends AbstractPreferenceInitializer {
12+
13+
public void initializeDefaultPreferences() {
14+
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
15+
store.setDefault(PreferenceConstants.P_AUTH_TOKEN,"");
16+
store.setDefault(PreferenceConstants.P_EMAIL,"");
17+
}
18+
19+
}

com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/plugin/views/CybenchTabView.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.eclipse.jdt.core.JavaCore;
4141
import org.eclipse.jface.layout.GridDataFactory;
4242
import org.eclipse.jface.layout.GridLayoutFactory;
43+
import org.eclipse.jface.preference.IPreferenceStore;
4344
import org.eclipse.jface.window.Window;
4445
import org.eclipse.swt.SWT;
4546
import org.eclipse.swt.events.ModifyEvent;
@@ -54,7 +55,6 @@
5455
import org.eclipse.swt.widgets.Button;
5556
import org.eclipse.swt.widgets.Combo;
5657
import org.eclipse.swt.widgets.Composite;
57-
import org.eclipse.swt.widgets.Control;
5858
import org.eclipse.swt.widgets.DirectoryDialog;
5959
import org.eclipse.swt.widgets.Display;
6060
import org.eclipse.swt.widgets.Group;
@@ -63,7 +63,9 @@
6363
import org.eclipse.swt.widgets.Shell;
6464
import org.eclipse.swt.widgets.Text;
6565

66+
import com.gocypher.cybench.plugin.Activator;
6667
import com.gocypher.cybench.plugin.model.LaunchConfiguration;
68+
import com.gocypher.cybench.plugin.tools.preferences.PreferenceConstants;
6769
import com.gocypher.cybench.plugin.utils.GuiUtils;
6870
import com.gocypher.cybench.plugin.utils.LauncherUtils;
6971

@@ -278,12 +280,17 @@ public void initializeFrom(ILaunchConfiguration configuration) {
278280
scanElements(launchPathDef);
279281

280282
}
283+
284+
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
285+
String token = store.getString(PreferenceConstants.P_AUTH_TOKEN);
286+
String email = store.getString(PreferenceConstants.P_EMAIL);
287+
281288
String reportNameDef = configuration.getAttribute(LaunchConfiguration.REPORT_NAME, "");
282289
String pathToSourceSelectedDef = configuration.getAttribute(LaunchConfiguration.LAUNCH_SELECTED_PATH, "");
283290
String pathToSourceNotSelectedDef = configuration.getAttribute(LaunchConfiguration.LAUNCH_NOT_SELECTED_PATH, "");
284291

285-
String accessTokenDef = configuration.getAttribute(LaunchConfiguration.REMOTE_CYBENCH_ACCESS_TOKEN, "");
286-
String userEmailDef = configuration.getAttribute(LaunchConfiguration.USER_EMAIL_ADDRESS, "");
292+
String accessTokenDef = configuration.getAttribute(LaunchConfiguration.REMOTE_CYBENCH_ACCESS_TOKEN, token);
293+
String userEmailDef = configuration.getAttribute(LaunchConfiguration.USER_EMAIL_ADDRESS, email);
287294
boolean sendReportCybnech = configuration.getAttribute(LaunchConfiguration.SHOULD_SEND_REPORT_CYBENCH, true);
288295
boolean includehardwarePropeties = configuration.getAttribute(LaunchConfiguration.INCLUDE_HARDWARE_PROPERTIES, true);
289296

eclipse-mars/com.gocypher.cybench.plugin.tools/plugin.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,18 @@
416416
</adapt>
417417
</definition>
418418
</extension>
419-
419+
<extension
420+
point="org.eclipse.ui.preferencePages">
421+
<page
422+
class="com.gocypher.cybench.plugin.tools.preferences.CyBenchPreferencePage"
423+
id="com.gocypher.cybench.plugin.tools.preferences.CyBenchPreferencePage"
424+
name="CyBench">
425+
</page>
426+
</extension>
427+
<extension
428+
point="org.eclipse.core.runtime.preferences">
429+
<initializer
430+
class="com.gocypher.cybench.plugin.tools.preferences.PreferenceInitializer">
431+
</initializer>
432+
</extension>
420433
</plugin>

eclipse-mars/com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/launcher/CyBenchLauncher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ public static void main(String[] args) throws Exception{
255255
CybenchUtils.storeResultsToFile(pathToReportFile+reportScore+".cyb", reportEncrypted);
256256

257257
if(!response.containsKey("ERROR") && responseWithUrl != null && !responseWithUrl.isEmpty()) {
258-
System.out.println("Benchmark report submitted successfully to "+ Constants.REPORT_URL);
259258
System.out.println("You can find all device benchmarks on "+ deviceReports);
260259
System.out.println("Your report is available at "+ resultURL);
261260
System.out.println("NOTE: It may take a few minutes for your report to appear online");

eclipse-mars/com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/plugin/CyBenchProjectNature.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
package com.gocypher.cybench.plugin;
2121

2222
import java.io.File;
23-
import java.io.FileOutputStream;
24-
import java.io.FileReader;
2523
import java.io.FileWriter;
2624
import java.nio.file.FileSystems;
2725
import java.nio.file.Files;
@@ -30,9 +28,6 @@
3028
import java.util.Scanner;
3129

3230
import org.apache.maven.model.Dependency;
33-
import org.apache.maven.model.Model;
34-
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
35-
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
3631
//import org.eclipse.buildship.core.BuildConfiguration;
3732
//import org.eclipse.buildship.core.GradleBuild;
3833
//import org.eclipse.buildship.core.GradleCore;

eclipse-mars/com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/plugin/handlers/LaunchShortcut.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@
1919

2020
package com.gocypher.cybench.plugin.handlers;
2121

22-
import java.io.File;
23-
import java.io.IOException;
24-
import java.nio.file.Files;
25-
import java.nio.file.Path;
26-
import java.nio.file.Paths;
2722
import java.util.ArrayList;
2823
import java.util.Arrays;
2924
import java.util.List;
3025

31-
import org.codehaus.plexus.util.StringUtils;
3226
import org.eclipse.debug.core.DebugPlugin;
3327
import org.eclipse.debug.core.ILaunch;
3428
import org.eclipse.debug.core.ILaunchConfiguration;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
import org.eclipse.jface.preference.*;
4+
import org.eclipse.ui.IWorkbenchPreferencePage;
5+
import org.eclipse.ui.IWorkbench;
6+
import com.gocypher.cybench.plugin.Activator;
7+
8+
/**
9+
* This class represents a preference page that
10+
* is contributed to the Preferences dialog. By
11+
* subclassing <samp>FieldEditorPreferencePage</samp>, we
12+
* can use the field support built into JFace that allows
13+
* us to create a page that is small and knows how to
14+
* save, restore and apply itself.
15+
* <p>
16+
* This page is used to modify preferences only. They
17+
* are stored in the preference store that belongs to
18+
* the main plug-in class. That way, preferences can
19+
* be accessed directly via the preference store.
20+
*/
21+
22+
public class CyBenchPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
23+
24+
public CyBenchPreferencePage() {
25+
super(GRID);
26+
setPreferenceStore(Activator.getDefault().getPreferenceStore());
27+
setDescription("CyBench authentication and identification properties.");
28+
}
29+
30+
/**
31+
* Creates the field editors. Field editors are abstractions of
32+
* the common GUI blocks needed to manipulate various types
33+
* of preferences. Each field editor knows how to save and
34+
* restore itself.
35+
*/
36+
public void createFieldEditors() {
37+
addField(new StringFieldEditor(PreferenceConstants.P_AUTH_TOKEN, "A &repository token:", getFieldEditorParent()));
38+
addField(new StringFieldEditor(PreferenceConstants.P_EMAIL, "&Email address:", getFieldEditorParent()));
39+
}
40+
41+
public void init(IWorkbench workbench) {
42+
}
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
/**
4+
* Constant definitions for plug-in preferences
5+
*/
6+
public class PreferenceConstants {
7+
8+
public static final String P_AUTH_TOKEN = "cybench.benchSendToken";
9+
public static final String P_EMAIL = "cybench.userIdentifyTag";
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.gocypher.cybench.plugin.tools.preferences;
2+
3+
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
4+
import org.eclipse.jface.preference.IPreferenceStore;
5+
6+
import com.gocypher.cybench.plugin.Activator;
7+
8+
/**
9+
* Class used to initialize default preference values.
10+
*/
11+
public class PreferenceInitializer extends AbstractPreferenceInitializer {
12+
13+
public void initializeDefaultPreferences() {
14+
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
15+
store.setDefault(PreferenceConstants.P_AUTH_TOKEN,"");
16+
store.setDefault(PreferenceConstants.P_EMAIL,"");
17+
}
18+
19+
}

eclipse-mars/com.gocypher.cybench.plugin.tools/src/com/gocypher/cybench/plugin/views/CybenchTabView.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.eclipse.jdt.core.JavaCore;
4141
import org.eclipse.jface.layout.GridDataFactory;
4242
import org.eclipse.jface.layout.GridLayoutFactory;
43+
import org.eclipse.jface.preference.IPreferenceStore;
4344
import org.eclipse.jface.window.Window;
4445
import org.eclipse.swt.SWT;
4546
import org.eclipse.swt.events.ModifyEvent;
@@ -54,7 +55,6 @@
5455
import org.eclipse.swt.widgets.Button;
5556
import org.eclipse.swt.widgets.Combo;
5657
import org.eclipse.swt.widgets.Composite;
57-
import org.eclipse.swt.widgets.Control;
5858
import org.eclipse.swt.widgets.DirectoryDialog;
5959
import org.eclipse.swt.widgets.Display;
6060
import org.eclipse.swt.widgets.Group;
@@ -63,7 +63,9 @@
6363
import org.eclipse.swt.widgets.Shell;
6464
import org.eclipse.swt.widgets.Text;
6565

66+
import com.gocypher.cybench.plugin.Activator;
6667
import com.gocypher.cybench.plugin.model.LaunchConfiguration;
68+
import com.gocypher.cybench.plugin.tools.preferences.PreferenceConstants;
6769
import com.gocypher.cybench.plugin.utils.GuiUtils;
6870
import com.gocypher.cybench.plugin.utils.LauncherUtils;
6971

@@ -278,12 +280,17 @@ public void initializeFrom(ILaunchConfiguration configuration) {
278280
scanElements(launchPathDef);
279281

280282
}
283+
284+
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
285+
String token = store.getString(PreferenceConstants.P_AUTH_TOKEN);
286+
String email = store.getString(PreferenceConstants.P_EMAIL);
287+
281288
String reportNameDef = configuration.getAttribute(LaunchConfiguration.REPORT_NAME, "");
282289
String pathToSourceSelectedDef = configuration.getAttribute(LaunchConfiguration.LAUNCH_SELECTED_PATH, "");
283290
String pathToSourceNotSelectedDef = configuration.getAttribute(LaunchConfiguration.LAUNCH_NOT_SELECTED_PATH, "");
284291

285-
String accessTokenDef = configuration.getAttribute(LaunchConfiguration.REMOTE_CYBENCH_ACCESS_TOKEN, "");
286-
String userEmailDef = configuration.getAttribute(LaunchConfiguration.USER_EMAIL_ADDRESS, "");
292+
String accessTokenDef = configuration.getAttribute(LaunchConfiguration.REMOTE_CYBENCH_ACCESS_TOKEN, token);
293+
String userEmailDef = configuration.getAttribute(LaunchConfiguration.USER_EMAIL_ADDRESS, email);
287294
boolean sendReportCybnech = configuration.getAttribute(LaunchConfiguration.SHOULD_SEND_REPORT_CYBENCH, true);
288295
boolean includehardwarePropeties = configuration.getAttribute(LaunchConfiguration.INCLUDE_HARDWARE_PROPERTIES, true);
289296

0 commit comments

Comments
 (0)