Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-02-23 22:06:01 -0500
committerWilliam Chen2012-02-23 22:06:01 -0500
commitd2944a8ce75ce970f72abac36fc9d6e3ac22f215 (patch)
tree1277dd5fec230773403c246181501309cc123ae3
parentddd891e468879efa8ea45848dafba6e2ff83286b (diff)
downloadorg.eclipse.tcf-d2944a8ce75ce970f72abac36fc9d6e3ac22f215.tar.gz
org.eclipse.tcf-d2944a8ce75ce970f72abac36fc9d6e3ac22f215.tar.xz
org.eclipse.tcf-d2944a8ce75ce970f72abac36fc9d6e3ac22f215.zip
Target Explorer: Fix more warnings from FindBugs.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/BlockingCallProxy.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenFileHandler.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenWithMenu.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSOperation.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/CacheManager.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerStateManager.java12
11 files changed, 36 insertions, 27 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/BlockingCallProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/BlockingCallProxy.java
index 86aee910d..200932f0c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/BlockingCallProxy.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/concurrent/BlockingCallProxy.java
@@ -165,7 +165,7 @@ public class BlockingCallProxy implements InvocationHandler {
* The invocation handler of the callback proxy. Used to delegate the callback invocation
* and unblock the rendezvous object.
*/
- private class DoneHandler implements InvocationHandler {
+ static private class DoneHandler implements InvocationHandler {
// The callback handler that delegates the invocation.
private Object done;
// The rendezvous that unblocks the invocation.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenFileHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenFileHandler.java
index 7cbd3ed2c..bba203c86 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenFileHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenFileHandler.java
@@ -71,8 +71,7 @@ public class OpenFileHandler extends AbstractHandler {
File file = CacheManager.getInstance().getCacheFile(node);
if (!file.exists()) {
// If the file node's local cache does not exist yet, download it.
- boolean successful = CacheManager.getInstance().download(node);
- if (!successful) {
+ if (!CacheManager.getInstance().download(node)) {
return;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenWithMenu.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenWithMenu.java
index 38143e4ae..e7ef2c6e9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenWithMenu.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/handlers/OpenWithMenu.java
@@ -375,8 +375,7 @@ public class OpenWithMenu extends ContributionItem {
File file = CacheManager.getInstance().getCacheFile(node);
if (!file.exists()) {
// If the file node's local cache does not exist yet, download it.
- boolean successful = CacheManager.getInstance().download(node);
- if (!successful) {
+ if (!CacheManager.getInstance().download(node)) {
return;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSOperation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSOperation.java
index 593db7ec1..bf7c0a19e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSOperation.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSOperation.java
@@ -134,8 +134,7 @@ public class FSOperation implements IRunnableWithProgress{
SafeRunner.run(new SafeRunnable(){
@Override
public void run() throws Exception {
- boolean successful = file.delete();
- if (!successful) {
+ if (!file.delete()) {
throw new Exception(NLS.bind(Messages.FSOperation_DeletingFileFailed, file.getAbsolutePath()));
}
}});
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/CacheManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/CacheManager.java
index 001cf0f9d..b0c9d92b2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/CacheManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/CacheManager.java
@@ -111,8 +111,7 @@ public class CacheManager {
SafeRunner.run(new SafeRunnable(){
@Override
public void run() throws Exception {
- boolean successful = dir.mkdir();
- if (!successful) {
+ if (!dir.mkdir()) {
throw new Exception(NLS.bind(Messages.CacheManager_MkdirFailed, dir.getAbsolutePath()));
}
}});
@@ -130,8 +129,7 @@ public class CacheManager {
SafeRunner.run(new SafeRunnable(){
@Override
public void run() throws Exception {
- boolean successful = file.delete();
- if (!successful) {
+ if (!file.delete()) {
throw new Exception(NLS.bind(Messages.FSOperation_DeletingFileFailed, file.getAbsolutePath()));
}
}});
@@ -150,8 +148,7 @@ public class CacheManager {
SafeRunner.run(new SafeRunnable(){
@Override
public void run() throws Exception {
- boolean successful = file.setLastModified(lastModified);
- if (!successful) {
+ if (!file.setLastModified(lastModified)) {
throw new Exception(NLS.bind(Messages.CacheManager_SetLastModifiedFailed, file.getAbsolutePath()));
}
}});
@@ -169,8 +166,7 @@ public class CacheManager {
SafeRunner.run(new SafeRunnable(){
@Override
public void run() throws Exception {
- boolean successful = file.setReadOnly();
- if (!successful) {
+ if (!file.setReadOnly()) {
throw new Exception(NLS.bind(Messages.CacheManager_SetReadOnlyFailed, file.getAbsolutePath()));
}
}});
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
index 8038ff931..ceb15f0f7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
@@ -36,7 +36,7 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
private CustomFormToolkit toolkit = null;
// The default help action class definition
- protected class HelpAction extends Action {
+ static protected class HelpAction extends Action {
/* default */ final String helpID;
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
index 9e98f0c10..53e386cfb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
@@ -84,11 +84,13 @@ public class TreeViewerExplorerEditorPage extends AbstractCustomFormToolkitEdito
String title = titleText == null ? getTitle() :titleText;
// Stretch to a length of 40 characters to make sure the title can be changed
// to hold and show text up to this length
- while (title.length() < 40) {
- title += " "; //$NON-NLS-1$
+ StringBuilder builder = new StringBuilder();
+ builder.append(title);
+ while (builder.length() < 40) {
+ builder.append(" "); //$NON-NLS-1$
}
// Set the title to the section
- section.setText(title);
+ section.setText(builder.toString());
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 0;
data.heightHint = 0;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
index 991f59cf6..e67151edd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.java
@@ -64,4 +64,5 @@ public class Messages extends NLS {
public static String NameValuePairDialog_usedOrIllegalName_error;
public static String PreferencePage_label;
+ public static String ViewerStateManager_MkdirFailed;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
index 111ac5afe..397e04f5a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
@@ -46,3 +46,4 @@ NameValuePairDialog_usedOrIllegalName_error=The name ''{0}'' is reserved or alre
# ***** Preference Pages *****
PreferencePage_label=General settings for Target Explorer:
+ViewerStateManager_MkdirFailed=Making the directory for viewerstate.xml failed\!
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java
index a1c3ad557..b4ce35058 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java
@@ -704,11 +704,9 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement
// If the parent composite is a forms section, set the toolbar
// as text client to the section header
- if (parent instanceof Section) {
- Section section = (Section)parent;
- // Set the toolbar as text client
- section.setTextClient(toolbar);
- }
+ Section section = (Section)parent;
+ // Set the toolbar as text client
+ section.setTextClient(toolbar);
}
/**
@@ -741,7 +739,9 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement
* @return The filter descriptors of this viewer.
*/
public FilterDescriptor[] getFilterDescriptors() {
- return filterDescriptors;
+ FilterDescriptor[] descriptors = new FilterDescriptor[filterDescriptors.length];
+ System.arraycopy(filterDescriptors, 0, descriptors, 0, filterDescriptors.length);
+ return descriptors;
}
/**
@@ -750,7 +750,9 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement
* @return The current viewer columns.
*/
public ColumnDescriptor[] getViewerColumns() {
- return columns;
+ ColumnDescriptor[] columnDescriptors = new ColumnDescriptor[columns.length];
+ System.arraycopy(columns, 0, columnDescriptors, 0, columns.length);
+ return columnDescriptors;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerStateManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerStateManager.java
index e9e4e56ec..3fa39c12a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerStateManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerStateManager.java
@@ -30,6 +30,7 @@ import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.interfaces.IViewerInput;
+import org.eclipse.tcf.te.ui.nls.Messages;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;
@@ -210,7 +211,16 @@ public class ViewerStateManager {
location = new File(System.getProperty("user.home"), ".tcf"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Create the location if it not exist
- if (!location.exists()) location.mkdir();
+ if (!location.exists()) {
+ final File dir = location;
+ SafeRunner.run(new SafeRunnable(){
+ @Override
+ public void run() throws Exception {
+ if (!dir.mkdir()) {
+ throw new Exception(Messages.ViewerStateManager_MkdirFailed);
+ }
+ }});
+ }
location = new File(location, "viewerstates.xml"); //$NON-NLS-1$
return location;
}

Back to the top