fix some warning and comments for the dashboard table.
Change-Id: Id95eb4642b7516c4127904e065bcd539b6691629
Signed-off-by: Jacques Bouthillier <lmcbout@gmail.com>
diff --git a/org.eclipse.egerrit.core/src/org/eclipse/egerrit/internal/core/utils/Utils.java b/org.eclipse.egerrit.core/src/org/eclipse/egerrit/internal/core/utils/Utils.java
index 452cf12..563bb2b 100644
--- a/org.eclipse.egerrit.core/src/org/eclipse/egerrit/internal/core/utils/Utils.java
+++ b/org.eclipse.egerrit.core/src/org/eclipse/egerrit/internal/core/utils/Utils.java
@@ -24,7 +24,7 @@
* @author lmcbout
* @since 1.0
*/
-public class Utils {
+public final class Utils {
private static final SimpleDateFormat formatTimeOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
diff --git a/org.eclipse.egerrit.dashboard.ui/META-INF/MANIFEST.MF b/org.eclipse.egerrit.dashboard.ui/META-INF/MANIFEST.MF
index 0e6fecf..20ce54d 100644
--- a/org.eclipse.egerrit.dashboard.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egerrit.dashboard.ui/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@
org.osgi.framework,
org.eclipse.ui.part,
org.eclipse.swt.widgets"
-Import-Package: org.eclipse.compare.internal,
+Import-Package: org.apache.http;version="4.3.3",
+ org.eclipse.compare.internal,
org.eclipse.egerrit.internal.dashboard.core,
org.eclipse.egerrit.internal.dashboard.utils
diff --git a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
index 007399c..8598729 100644
--- a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
+++ b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
@@ -23,6 +23,7 @@
import java.util.TreeSet;
import java.util.concurrent.CompletableFuture;
+import org.apache.http.HttpStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -282,8 +283,11 @@
}
private void createReviewList(String[] voteColumns) {
+ String[] reviewVoteColumns;
if (voteColumns == null) {
- voteColumns = new String[0];
+ reviewVoteColumns = new String[0];
+ } else {
+ reviewVoteColumns = voteColumns.clone();
}
removeExistingWidgets();
fTopComposite = new Composite(parentComposite, SWT.NONE);
@@ -291,7 +295,7 @@
searchSection = createSearchSection(fTopComposite);
searchSection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createTable(voteColumns);
+ createTable(reviewVoteColumns);
}
private void createTable(String[] voteColumns) {
@@ -607,7 +611,7 @@
public void processCommands(String aQuery) {
logger.debug("Process command : " + aQuery); //$NON-NLS-1$
defaultServerInfo = null;
- aQuery = handleHttpInQuery(aQuery);
+ String httpQuery = handleHttpInQuery(aQuery);
initializeDefaultServer();
//We should have a Gerrit Server here, otherwise, the user need to define one
@@ -628,8 +632,8 @@
}
//At this point we have a server, execute the query if we can
- if (aQuery != null && !"".equals(aQuery)) { //$NON-NLS-1$
- updateTable(defaultServerInfo, aQuery);
+ if (httpQuery != null && !"".equals(httpQuery)) { //$NON-NLS-1$
+ updateTable(defaultServerInfo, httpQuery);
}
}
@@ -793,9 +797,8 @@
/**
* @param server
* @param aQueryType
- * @return
*/
- private Object updateTable(final GerritServerInformation server, final String aQueryType) {
+ private void updateTable(final GerritServerInformation server, final String aQueryType) {
createReviewList(null);
String cmdMessage = NLS.bind(Messages.GerritTableView_commandMessage, server.getServerURI(), aQueryType);
final Job job = new Job(cmdMessage) {
@@ -833,7 +836,6 @@
job.setUser(true);
job.schedule();
- return null;
}
//Display a query string in the search text.
@@ -1009,21 +1011,8 @@
boolean connect = gerritRepository.connect();
if (connect) {
- Version version = gerritRepository.getVersion();
-
- if (version == null) {
- UIUtils.showErrorDialog(Messages.Invalid_Credentials, "Server " + defaultServerInfo.getServerURI()); //$NON-NLS-1$
- return false;
- } else if (version.equals(GerritRepository.NO_VERSION)) {
- UIUtils.showErrorDialog(Messages.Unsupported_server_version_title,
- NLS.bind(Messages.Unsupported_server_version, GerritFactory.MINIMAL_VERSION));
- return false;
- } else if (version.compareTo(GerritFactory.MINIMAL_VERSION) < 0) {
- UIUtils.showErrorDialog(Messages.Unsupported_Server_Version,
- NLS.bind(Messages.Unsupported_server_version, GerritFactory.MINIMAL_VERSION));
- return false;
- }
- } else if (gerritRepository.getStatus() == 401) {
+ return showVersionError(gerritRepository);
+ } else if (gerritRepository.getStatus() == HttpStatus.SC_UNAUTHORIZED) {
UIUtils.showErrorDialog(Messages.Server_connection_401_title,
NLS.bind(Messages.Server_connection_401, gerritRepository.getPath()));
return false;
@@ -1033,6 +1022,27 @@
return false;
}
+ /**
+ * @param gerritRepository
+ */
+ private boolean showVersionError(GerritRepository gerritRepository) {
+ Version version = gerritRepository.getVersion();
+
+ if (version == null) {
+ UIUtils.showErrorDialog(Messages.Invalid_Credentials, "Server " + defaultServerInfo.getServerURI()); //$NON-NLS-1$
+ return false;
+ } else if (version.equals(GerritRepository.NO_VERSION)) {
+ UIUtils.showErrorDialog(Messages.Unsupported_server_version_title,
+ NLS.bind(Messages.Unsupported_server_version, GerritFactory.MINIMAL_VERSION));
+ return false;
+ } else if (version.compareTo(GerritFactory.MINIMAL_VERSION) < 0) {
+ UIUtils.showErrorDialog(Messages.Unsupported_Server_Version,
+ NLS.bind(Messages.Unsupported_server_version, GerritFactory.MINIMAL_VERSION));
+ return false;
+ }
+ return true;
+ }
+
private ChangeInfo[] getReviewList(String aQuery) throws GerritQueryException {
ChangeInfo[] reviews = null;
try {
@@ -1139,10 +1149,6 @@
}
defaultServerInfo = serverInfo; //Set the default server with the latest value
- if (defaultServerInfo == null) {
- logger.debug("No new server entered by the user."); //$NON-NLS-1$
- return;
- }
if (fSearchTextBox == null || fSearchTextBox.getText().isEmpty()) {
processCommands(ChangeStatus.OPEN.getValue());
} else {
@@ -1151,6 +1157,9 @@
}
}
+ /**
+ * Process a query to update the dashboard table.
+ */
public void update() {
rtv.processCommands(fSearchTextBox.getText());
}
diff --git a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/compare/CommentPrettyPrinter.java b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/compare/CommentPrettyPrinter.java
index efa4277..b394f38 100644
--- a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/compare/CommentPrettyPrinter.java
+++ b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/compare/CommentPrettyPrinter.java
@@ -17,6 +17,12 @@
//Helper class to pretty print a comment
public class CommentPrettyPrinter {
+ /**
+ * The default constructor. Do not allow to build an object of this class
+ */
+ private CommentPrettyPrinter() {
+ }
+
static String printComment(CommentInfo comment) {
return CommentPrettyPrinter.printName(comment) + '\t' + comment.getMessage() + '\t' + printDate(comment);
}