tuleap #836 clean-up code in EGerrit dashboard core
Change-Id: I204f3e02d643ab19a6adfa29d0467f84473c9d1a
Signed-off-by: Jacques Bouthillier <lmcbout@gmail.com>
diff --git a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/GerritPlugin.java b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/GerritPlugin.java
index 6da2b7d..2eae168 100644
--- a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/GerritPlugin.java
+++ b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/GerritPlugin.java
@@ -27,26 +27,11 @@
public class GerritPlugin extends Plugin {
// ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /**
- * Field PLUGIN_ID. (value is ""org.eclipse.egerrit.dashboard.core"")
- */
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.egerrit.dashboard.core"; //$NON-NLS-1$
-
- /**
- * Field DASHBOARD_VERSION_QUALIFIER. (value is ""qualifier"")
- */
- private static final String DASHBOARD_VERSION_QUALIFIER = "qualifier"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
// Member variables
// ------------------------------------------------------------------------
// The shared instance
- private static GerritPlugin Fplugin;
+ private static GerritPlugin fPlugin;
// ------------------------------------------------------------------------
// Constructors
@@ -73,7 +58,7 @@
@Override
public void start(BundleContext aContext) throws Exception {
super.start(aContext);
- Fplugin = this;
+ fPlugin = this;
}
/**
@@ -86,7 +71,7 @@
*/
@Override
public void stop(BundleContext aContext) throws Exception {
- Fplugin = null;
+ fPlugin = null;
super.stop(aContext);
}
@@ -96,6 +81,6 @@
* @return the shared instance
*/
public static GerritPlugin getDefault() {
- return Fplugin;
+ return fPlugin;
}
}
diff --git a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQuery.java b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQuery.java
index 5be202e..3b2f2eb 100644
--- a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQuery.java
+++ b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQuery.java
@@ -29,37 +29,9 @@
public static final String MY_RECENTLY_CLOSED_CHANGES = "is:closed AND (owner:self OR reviewer:self) AND limit:10"; //$NON-NLS-1$
/**
- * Query type: my watched changes
+ * The default constructor. Do not allow to build an object of this class
*/
- public static final String MY_WATCHED_CHANGES = "is:watched status:open"; //$NON-NLS-1$
+ private GerritQuery() {
+ }
- /**
- * Query : my starred changes
- */
- public static final String QUERY_MY_STARRED_CHANGES = "is:starred status:open"; //$NON-NLS-1$
-
- /**
- * Query : my drafts changes
- */
- public static final String QUERY_MY_DRAFTS_CHANGES = "is:draft"; //$NON-NLS-1$
-
- /**
- * Query : my drafts comment changes
- */
- public static final String QUERY_MY_DRAFTS_COMMENTS_CHANGES = "has:draft"; //$NON-NLS-1$
-
- /**
- * Query type: all open changes
- */
- public static final String ALL_OPEN_CHANGES = "status:open"; //$NON-NLS-1$
-
- /**
- * Query : all merged changes
- */
- public static final String QUERY_ALL_MERGED_CHANGES = "status:merged"; //$NON-NLS-1$
-
- /**
- * Query : all abandoned changes
- */
- public static final String QUERY_ALL_ABANDONED_CHANGES = "status:abandoned"; //$NON-NLS-1$
}
diff --git a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQueryException.java b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQueryException.java
index 917995e..f856a2f 100644
--- a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQueryException.java
+++ b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/core/GerritQueryException.java
@@ -23,7 +23,7 @@
private static final long serialVersionUID = 1L;
- private final IStatus fStatus;
+ private final transient IStatus fStatus;
public GerritQueryException(IStatus status, String message) {
super(message);
diff --git a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/messages.properties b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/messages.properties
deleted file mode 100644
index 1671a63..0000000
--- a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/messages.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-###############################################################################
-# Copyright (c) 2014 Ericsson
-#
-# All rights reserved. This program and the accompanying materials are
-# made available under the terms of the Eclipse Public License v1.0 which
-# accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Jacques Bouthillier - Initial implementation
-# Marc-Andre Laperle - Add Topic to dashboard
-# Marc-Andre Laperle - Add Status to dashboard
-###############################################################################
-GerritPlugin_started=plugin started
-GerritPlugin_stopped=plugin stopped
-GerritPlugin_Version=runtime environment for {0} \t Version: {1}
-GerritTask_branch=Branch =
-GerritTask_topic=Topic =
-GerritTask_changeID=ChangeID=
-GerritTask_owner=Owner =
-GerritTask_project=Project =
-GerritTask_shortID=ShortID =
-GerritTask_star=STAR =
-GerritTask_subject=Subject =
-GerritTask_subject=Status =
-GerritTask_taskID=TaskID =
-GerritTask_updated=Updated =
diff --git a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/utils/GerritServerUtility.java b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/utils/GerritServerUtility.java
index b48a92a..84f6f65 100644
--- a/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/utils/GerritServerUtility.java
+++ b/org.eclipse.egerrit.dashboard.core/src/org/eclipse/egerrit/internal/dashboard/utils/GerritServerUtility.java
@@ -61,12 +61,12 @@
/**
* Field ECLIPSE_GERRIT_DEFAULT. (value is ""https://git.eclipse.org/r/"")
*/
- private final String ECLIPSE_GERRIT_DEFAULT = "https://git.eclipse.org/r/"; //$NON-NLS-1$
+ private static final String ECLIPSE_GERRIT_DEFAULT = "https://git.eclipse.org/r/"; //$NON-NLS-1$
/**
* Field SLASH. (value is ""/"")
*/
- private final char SLASH = '/';
+ private static final char SLASH = '/';
// ------------------------------------------------------------------------
// Variables
@@ -96,8 +96,7 @@
private File getLastGerritFile(String aFile) {
IPath ipath = GerritPlugin.getDefault().getStateLocation();
String fileName = ipath.append(aFile).toPortableString();
- File file = new File(fileName);
- return file;
+ return new File(fileName);
}
/**
@@ -166,8 +165,9 @@
BufferedWriter out = new BufferedWriter(fw);
out.write(Integer.toString(server.hashCode()));
out.close();
+ fw.close();
} catch (IOException e1) {
- e1.printStackTrace();
+ logger.debug("Saved last Gerrit server " + e1); //$NON-NLS-1$
ok = false;
}
@@ -192,6 +192,7 @@
BufferedReader in = new BufferedReader(fr);
lastServerId = in.readLine();
in.close();
+ fr.close();
} catch (IOException e1) {
//When there is no file,
//e1.printStackTrace();
@@ -210,7 +211,6 @@
try {
saveLastGerritServer(new GerritServerInformation("", "")); //$NON-NLS-1$ //$NON-NLS-2$
} catch (URISyntaxException e) {
- // TODO Auto-generated catch block
//e.printStackTrace();
}
}
@@ -237,10 +237,10 @@
String id = getEditorId(url);
workBenchSupport.createBrowser(id).openURL(url);
} catch (PartInitException e) {
- e.printStackTrace();
+ logger.debug("PartInitException openWebBrowser for " + e); //$NON-NLS-1$
}
} catch (MalformedURLException e1) {
- e1.printStackTrace();
+ logger.debug("MalformedURLException openWebBrowser for " + e1); //$NON-NLS-1$
}
logger.debug("openWebBrowser for " + url); //$NON-NLS-1$
}
@@ -265,8 +265,9 @@
out.newLine();
}
out.close();
+ fw.close();
} catch (IOException e1) {
- e1.printStackTrace();
+ logger.debug("Saved last command IOException " + e1); //$NON-NLS-1$
ok = false;
}
@@ -279,7 +280,7 @@
* @return Set
*/
public Set<String> getListLastCommands() {
- LinkedHashSet<String> lastCommands = new LinkedHashSet<String>();
+ LinkedHashSet<String> lastCommands = new LinkedHashSet<>();
File file = getLastGerritFile(LAST_COMMANDS_FILE);
if (file != null) {
try {
@@ -290,6 +291,7 @@
lastCommands.add(line);
}
in.close();
+ fr.close();
} catch (IOException e1) {
//When there is no file,
//e1.printStackTrace();