Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-06-01 13:55:04 +0000
committerUwe Stieber2012-06-01 13:55:04 +0000
commit0a7fc28da4ba46ca5d62660c7a9bd31c75c1f068 (patch)
treeaa32e0ca355e7f073ca440d556fd1705f7eec99b /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui
parent3968410db7f1f712726b219f3f6fc90c9f0663da (diff)
downloadorg.eclipse.tcf-0a7fc28da4ba46ca5d62660c7a9bd31c75c1f068.tar.gz
org.eclipse.tcf-0a7fc28da4ba46ca5d62660c7a9bd31c75c1f068.tar.xz
org.eclipse.tcf-0a7fc28da4ba46ca5d62660c7a9bd31c75c1f068.zip
Target Explorer: Fix FindBugs warnings
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java2
9 files changed, 45 insertions, 40 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java
index 3a7321352..733f0501d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java
@@ -52,7 +52,6 @@ public abstract class NavigatorContentProvider extends TreeContentProvider {
return getChildren(model.getRoot());
} else if (parentElement instanceof AbstractTreeNode) {
AbstractTreeNode node = (AbstractTreeNode)parentElement;
- Object[] children = NO_ELEMENTS;
List<Object> current = new ArrayList<Object>(node.getChildren());
if (!node.childrenQueried) {
current.add(getPending(node));
@@ -60,16 +59,15 @@ public abstract class NavigatorContentProvider extends TreeContentProvider {
node.queryChildren();
}
}
- children = current.toArray();
- return children;
+ return current.toArray();
}
return NO_ELEMENTS;
}
-
+
/**
* Get the tree node model for this peer node.
- *
+ *
* @param peerNode The peer node from where to get the model.
* @return The tree node model.
*/
@@ -105,7 +103,7 @@ public abstract class NavigatorContentProvider extends TreeContentProvider {
/**
* If the root node of the tree is visible.
- *
+ *
* @return true if it is visible.
*/
protected boolean isRootNodeVisible() {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
index 582b8091e..fab4f4261 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
@@ -64,8 +64,9 @@ public class SaveListener implements IExecutionListener {
}
@Override
public void run() throws Exception {
- dirtyNode.refresh();
- }});
+ if (dirtyNode != null) dirtyNode.refresh();
+ }
+ });
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java
index ba89a1bde..bbc5055dc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java
@@ -12,13 +12,14 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.tabbed;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
/**
* The section that displays the basic information of a file.
*/
public class BasicFileSection extends BasicFolderSection {
-
+
// The text field for the size of the file.
protected Text sizeText;
// The text field for the access time of the file.
@@ -34,15 +35,15 @@ public class BasicFileSection extends BasicFolderSection {
sizeText = createTextField(null, Messages.GeneralInformationPage_Size);
accessedText = createTextField(sizeText, Messages.GeneralInformationPage_Accessed);
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.filesystem.internal.tabbed.BasicFolderSection#refresh()
*/
@Override
public void refresh() {
- sizeText.setText(getSizeText(clone.attr.size));
- accessedText.setText(getDateText(clone.attr.atime));
+ SWTControlUtil.setText(sizeText, clone != null ? getSizeText(clone.attr.size) : ""); //$NON-NLS-1$
+ SWTControlUtil.setText(accessedText, clone != null ? getDateText(clone.attr.atime) : ""); //$NON-NLS-1$
super.refresh();
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java
index 0944275b2..165af9d80 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java
@@ -21,6 +21,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
/**
@@ -34,7 +35,7 @@ public class BasicFolderSection extends BaseTitledSection {
protected FSTreeNode node;
// The copy used to be edited.
protected FSTreeNode clone;
-
+
// The text for the name of the node.
protected Text nameText;
// The text for the type of the node.
@@ -74,17 +75,17 @@ public class BasicFolderSection extends BaseTitledSection {
*/
@Override
public void refresh() {
- nameText.setText(clone.name);
- typeText.setText(clone.getFileType());
- String location = clone.isRoot() ? Messages.GeneralInformationPage_Computer : clone.getLocation();
- locationText.setText(location);
- modifiedText.setText(getDateText(clone.attr.mtime));
+ SWTControlUtil.setText(nameText, clone != null ? clone.name : ""); //$NON-NLS-1$
+ SWTControlUtil.setText(typeText, clone != null ? clone.getFileType() : ""); //$NON-NLS-1$
+ String location = clone == null || clone.isRoot() ? Messages.GeneralInformationPage_Computer : clone.getLocation();
+ SWTControlUtil.setText(locationText, location);
+ SWTControlUtil.setText(modifiedText, clone != null ? getDateText(clone.attr.mtime) : ""); //$NON-NLS-1$
super.refresh();
}
/**
* Get the string of the specific time using the formatter, DATE_FORMAT.
- *
+ *
* @param time The time to be formatted.
* @return The string in the format of DATE_FORMAT.
*/
@@ -111,5 +112,5 @@ public class BasicFolderSection extends BaseTitledSection {
@Override
protected String getText() {
return Messages.BasicFolderSection_BasicInfoText;
- }
+ }
} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java
index 87bde05f3..8ad782fa3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java
@@ -21,6 +21,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
@@ -50,7 +51,7 @@ public class LinuxPermissionsSection extends BaseTitledSection {
/**
* Create a permission group for a role, such as a user, a group or others.
- *
+ *
* @param prev The previous permission group to align with.
* @param parent The parent composite.
* @param bit The permission bit index.
@@ -86,7 +87,7 @@ public class LinuxPermissionsSection extends BaseTitledSection {
/**
* Create a check-box field for a single permission item.
- *
+ *
* @param label The label of the permission.
* @param index The index of current permission bit mask index.
* @param parent The parent to hold the check-box field.
@@ -121,8 +122,8 @@ public class LinuxPermissionsSection extends BaseTitledSection {
public void refresh() {
for (int i = 0; i < 9; i++) {
final int bit = 1 << (8 - i);
- final boolean on = (clone.attr.permissions & bit) != 0;
- btnPermissions[i].setSelection(on);
+ final boolean on = clone != null ? (clone.attr.permissions & bit) != 0 : false;
+ SWTControlUtil.setSelection(btnPermissions[i], on);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java
index a95481b7d..7694cb8cf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java
@@ -20,6 +20,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
@@ -75,10 +76,10 @@ public class WindowsAttributesCESection extends BaseTitledSection {
*/
@Override
public void refresh() {
- boolean on = node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_COMPRESSED);
- compressButton.setSelection(on);
- on = node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_ENCRYPTED);
- encryptButton.setSelection(on);
+ boolean on = node != null ? node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_COMPRESSED) : false;
+ SWTControlUtil.setSelection(compressButton, on);
+ on = node != null ? node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_ENCRYPTED) : false;
+ SWTControlUtil.setSelection(encryptButton, on);
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java
index 025954b4b..c1fed35b2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java
@@ -19,6 +19,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
@@ -34,7 +35,7 @@ public class WindowsAttributesSection extends BaseTitledSection {
protected Button readOnlyButton;
// The check box for "Hidden" attribute.
protected Button hiddenButton;
-
+
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
@@ -42,7 +43,7 @@ public class WindowsAttributesSection extends BaseTitledSection {
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
-
+
readOnlyButton = getWidgetFactory().createButton(composite, Messages.GeneralInformationPage_ReadOnly, SWT.CHECK);
FormData data = new FormData();
data.left = new FormAttachment(0, ITabbedPropertyConstants.HMARGIN );
@@ -75,8 +76,8 @@ public class WindowsAttributesSection extends BaseTitledSection {
*/
@Override
public void refresh() {
- readOnlyButton.setSelection(clone.isReadOnly());
- hiddenButton.setSelection(clone.isHidden());
+ SWTControlUtil.setSelection(readOnlyButton, clone != null ? clone.isReadOnly() : false);
+ SWTControlUtil.setSelection(hiddenButton, clone != null ? clone.isHidden(): false);
}
/*
@@ -85,6 +86,6 @@ public class WindowsAttributesSection extends BaseTitledSection {
*/
@Override
protected String getText() {
- return Messages.WindowsAttributesSection_Attributes;
+ return Messages.WindowsAttributesSection_Attributes;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java
index dc3d57d98..3af375165 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java
@@ -20,6 +20,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
@@ -63,7 +64,7 @@ public class WindowsFolderAISection extends BaseTitledSection {
/**
* Get the archive's label text.
- *
+ *
* @return The archive's label text.
*/
protected String getAchiveText() {
@@ -72,7 +73,7 @@ public class WindowsFolderAISection extends BaseTitledSection {
/**
* Get the index's label text.
- *
+ *
* @return The index's label text.
*/
protected String getIndexText() {
@@ -95,10 +96,10 @@ public class WindowsFolderAISection extends BaseTitledSection {
*/
@Override
public void refresh() {
- boolean on = node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_ARCHIVE);
- archiveButton.setSelection(on);
- on = !node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
- indexButton.setSelection(on);
+ boolean on = node != null ? node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_ARCHIVE) : false;
+ SWTControlUtil.setSelection(archiveButton, on);
+ on = node != null ? !node.isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) : false;
+ SWTControlUtil.setSelection(indexButton, on);
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java
index 521111e6b..a1825f1b3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java
@@ -137,7 +137,7 @@ public abstract class NewNodeWizardPage extends AbstractValidatingWizardPage {
Assert.isNotNull(parent);
// Create the client composite
- Composite client = toolkit.createComposite(parent);
+ Composite client = toolkit != null ? toolkit.createComposite(parent) : new Composite(parent, SWT.NONE);
client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
client.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
client.setBackground(parent.getBackground());

Back to the top