Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonas2014-12-03 11:01:46 +0000
committerjonas2014-12-03 11:01:46 +0000
commitcefbf79daf5814b142b950bd5947caf6c71acf8e (patch)
tree3a93e18affd53a31a9dbc52243fa8fa008eb96da /bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator
parent46e94e5bd34d29fcd79856605cb82d7bc08828da (diff)
downloadorg.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.tar.gz
org.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.tar.xz
org.eclipse.e4.tools-cefbf79daf5814b142b950bd5947caf6c71acf8e.zip
Bug 444692 - Remove Warnings
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator')
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java146
1 files changed, 77 insertions, 69 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java
index fedab5d7..d1a55456 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedActionPage.java
@@ -6,13 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 437569, Ongoing Maintenance
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 437569, Ongoing Maintenance
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.dialogs;
-import org.eclipse.e4.tools.emf.ui.common.Plugin;
-
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -21,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipFile;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -28,6 +27,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.tools.emf.ui.common.IClassContributionProvider.ContributionData;
+import org.eclipse.e4.tools.emf.ui.common.Plugin;
import org.eclipse.e4.tools.emf.ui.internal.ResourceProvider;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.BundleImageCache;
import org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.ContributionDataFile;
@@ -36,7 +36,6 @@ import org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.BundleConvert
import org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.Messages;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.swt.SWT;
@@ -58,17 +57,18 @@ import org.eclipse.swt.widgets.Text;
* @author Steven Spungin
*
*/
-public class NonReferencedActionPage extends WizardPage implements IWizardPage {
+public class NonReferencedActionPage extends WizardPage {
- private IProject project;
+ private final IProject project;
private String bundle;
- private IFile file;
- private String installLocation;
- private IEclipseContext context;
+ private final IFile file;
+ private final String installLocation;
+ private final IEclipseContext context;
private String className;
- private BundleImageCache imageCache;
+ private final BundleImageCache imageCache;
- protected NonReferencedActionPage(IProject project, String bundle, IFile file, String installLocation, IEclipseContext context) {
+ protected NonReferencedActionPage(IProject project, String bundle, IFile file, String installLocation,
+ IEclipseContext context) {
super(Messages.NonReferencedActionPage_NonreferencedResourceAction);
this.project = project;
@@ -79,14 +79,15 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
imageCache = context.get(BundleImageCache.class);
- setImageDescriptor(ImageDescriptor.createFromImage(imageCache.create(Plugin.ID, "/icons/full/wizban/newefix_wizban.png"))); //$NON-NLS-1$
+ setImageDescriptor(ImageDescriptor.createFromImage(imageCache.create(Plugin.ID,
+ "/icons/full/wizban/newefix_wizban.png"))); //$NON-NLS-1$
if (bundle == null && installLocation != null) {
this.bundle = FilteredContributionDialog.getBundle(installLocation);
}
if (file instanceof ContributionDataFile) {
- ContributionDataFile cdf = (ContributionDataFile) file;
- this.className = cdf.getContributionData().className;
+ final ContributionDataFile cdf = (ContributionDataFile) file;
+ className = cdf.getContributionData().className;
}
setTitle(Messages.NonReferencedActionPage_NonreferencedResourceAction);
@@ -101,32 +102,32 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
@Override
public void createControl(Composite compParent) {
- Composite comp = new Composite(compParent, SWT.NONE);
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ final Composite comp = new Composite(compParent, SWT.NONE);
+ final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.horizontalSpan = 2;
comp.setLayoutData(layoutData);
comp.setLayout(new GridLayout(2, false));
- String message = ""; //$NON-NLS-1$
+ final String message = ""; //$NON-NLS-1$
Button defaultButton = null;
if (installLocation != null) {
- Label label = new Label(comp, SWT.NONE);
+ final Label label = new Label(comp, SWT.NONE);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label.setText(Messages.NonReferencedResourceDialog_installLocation);
- Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label2.setText(installLocation);
}
if (className != null) {
- ContributionData cd = ((ContributionDataFile) file).getContributionData();
- Label label = new Label(comp, SWT.NONE);
+ final ContributionData cd = ((ContributionDataFile) file).getContributionData();
+ final Label label = new Label(comp, SWT.NONE);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label.setText(Messages.NonReferencedResourceDialog_2);
- Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (bundle != null) {
label2.setText(bundle);
@@ -134,37 +135,37 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
label2.setText(Messages.NonReferencedResourceDialog__ast_notInABundle_ast);
}
- Label label3 = new Label(comp, SWT.NONE);
+ final Label label3 = new Label(comp, SWT.NONE);
label3.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label3.setText(Messages.NonReferencedResourceDialog_package);
- Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label4.setText(getPackageFromClassName(className));
- Label label5 = new Label(comp, SWT.NONE);
+ final Label label5 = new Label(comp, SWT.NONE);
label5.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label5.setText(Messages.NonReferencedResourceDialog_class);
- Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label6.setText(cd.className.substring(cd.className.lastIndexOf('.') + 1));
if (bundle != null) {
- Label label7 = new Label(comp, SWT.NONE);
+ final Label label7 = new Label(comp, SWT.NONE);
label7.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label7.setText(Messages.NonReferencedResourceDialog_url);
- Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label8.setText("bundleclass://" + bundle + "/" + className); //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
- Label label = new Label(comp, SWT.NONE);
+ final Label label = new Label(comp, SWT.NONE);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label.setText(Messages.NonReferencedResourceDialog_bundle);
- Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label2 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (bundle != null) {
label2.setText(bundle);
@@ -172,38 +173,39 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
label2.setText(Messages.NonReferencedResourceDialog_ast_notInABundle_ast);
}
- Label label7 = new Label(comp, SWT.NONE);
+ final Label label7 = new Label(comp, SWT.NONE);
label7.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label7.setText(Messages.NonReferencedResourceDialog_directory);
- Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label8 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label8.setText(file.getFullPath().removeFirstSegments(1).removeLastSegments(1).toOSString());
- Label label3 = new Label(comp, SWT.NONE);
+ final Label label3 = new Label(comp, SWT.NONE);
label3.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label3.setText(Messages.NonReferencedResourceDialog_resource);
- Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label4 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
label4.setText(file.getFullPath().lastSegment());
if (bundle != null) {
- Label label5 = new Label(comp, SWT.NONE);
+ final Label label5 = new Label(comp, SWT.NONE);
label5.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
label5.setText(Messages.NonReferencedResourceDialog_url);
- Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
+ final Text label6 = new Text(comp, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY);
label6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- label6.setText("platform:/plugin/" + bundle + "/" + file.getFullPath().removeFirstSegments(1).toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ label6
+ .setText("platform:/plugin/" + bundle + "/" + file.getFullPath().removeFirstSegments(1).toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- Label lblMessage = new Label(comp, SWT.NONE);
+ final Label lblMessage = new Label(comp, SWT.NONE);
lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 0));
lblMessage.setText(message);
- Group group = new Group(comp, SWT.NONE);
+ final Group group = new Group(comp, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0));
group.setLayout(new GridLayout(1, false));
group.setText(Messages.NonReferencedActionPage_Action);
@@ -217,7 +219,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnRequire.getSelection()) {
- Runnable okAction = new Runnable() {
+ final Runnable okAction = new Runnable() {
@Override
public void run() {
@@ -241,16 +243,16 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnImport.getSelection()) {
- Runnable okAction = new Runnable() {
+ final Runnable okAction = new Runnable() {
@Override
public void run() {
- IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
+ final IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
Manifest manifest;
try {
manifest = new Manifest(fileManifest.getContents());
String value = manifest.getMainAttributes().getValue("Import-Package"); //$NON-NLS-1$
- String packageName = getPackageFromClassName(className);
+ final String packageName = getPackageFromClassName(className);
// TODO ensure the packageName is not
// already in the manifest (although it
// should not be if we are here)
@@ -260,12 +262,12 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
value += "," + packageName; //$NON-NLS-1$
}
manifest.getMainAttributes().putValue("Import-Package", value); //$NON-NLS-1$
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
manifest.write(bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
fileManifest.setContents(bis, true, true, null);
context.set("resolvedFile", file); //$NON-NLS-1$
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
@@ -307,24 +309,30 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnConvertToBundle.getSelection()) {
- Runnable okAction = new Runnable() {
+ final Runnable okAction = new Runnable() {
@Override
public void run() {
String bundleId;
try {
- ContributionData contributionData = cdf.getContributionData();
- bundleId = BundleConverter.convertProjectToBundle(contributionData.installLocation, project.getWorkspace());
+ final ContributionData contributionData = cdf.getContributionData();
+ bundleId = BundleConverter.convertProjectToBundle(
+ contributionData.installLocation, project.getWorkspace());
if (bundleId != null) {
- ContributionData cdConverted = new ContributionData(bundleId, contributionData.className, contributionData.sourceType, contributionData.iconPath);
+ final ContributionData cdConverted = new ContributionData(bundleId,
+ contributionData.className, contributionData.sourceType,
+ contributionData.iconPath);
cdConverted.installLocation = installLocation;
- cdConverted.resourceRelativePath = Path.fromOSString(contributionData.iconPath).removeFirstSegments(1).toOSString();
+ cdConverted.resourceRelativePath = Path
+ .fromOSString(contributionData.iconPath).removeFirstSegments(1)
+ .toOSString();
doRequireBundle(bundleId, installLocation);
context.set("resolvedFile", new ContributionDataFile(cdConverted)); //$NON-NLS-1$
}
- } catch (Exception e1) {
- MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error, e1.getMessage());
+ } catch (final Exception e1) {
+ MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error,
+ e1.getMessage());
}
}
};
@@ -345,7 +353,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnCopy.getSelection()) {
- Runnable okAction = new Runnable() {
+ final Runnable okAction = new Runnable() {
@Override
public void run() {
@@ -369,7 +377,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
public void widgetSelected(SelectionEvent e) {
if (btnCopy2.getSelection()) {
- Runnable okAction = new Runnable() {
+ final Runnable okAction = new Runnable() {
@Override
public void run() {
@@ -401,8 +409,8 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
}
public void copyResourceToProject() {
- IProject project = (IProject) context.get("projectToCopyTo"); //$NON-NLS-1$
- String path = (String) context.get("folderToCopyTo"); //$NON-NLS-1$
+ final IProject project = (IProject) context.get("projectToCopyTo"); //$NON-NLS-1$
+ final String path = (String) context.get("folderToCopyTo"); //$NON-NLS-1$
try {
// String filename = ((ContributionDataFile)
// file).getContributionData().className + ".class";
@@ -413,13 +421,13 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
if (className != null) {
newPath.append(className + ".class"); //$NON-NLS-1$
} else {
- String name = file.getFullPath().lastSegment();
+ final String name = file.getFullPath().lastSegment();
newPath = newPath.append(name);
}
- IFile fileClone = project.getFile(newPath);
+ final IFile fileClone = project.getFile(newPath);
fileClone.create(file.getContents(), false, null);
context.set("resolvedFile", fileClone); //$NON-NLS-1$
- } catch (CoreException e1) {
+ } catch (final CoreException e1) {
e1.printStackTrace();
MessageDialog.openError(getShell(), "Error", e1.getMessage()); //$NON-NLS-1$
}
@@ -433,7 +441,7 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
try {
Manifest manifestSource;
if (installLocation.endsWith(".jar")) { //$NON-NLS-1$
- ZipFile zip = new ZipFile(installLocation);
+ final ZipFile zip = new ZipFile(installLocation);
srcStream = zip.getInputStream(zip.getEntry("META-INF/MANIFEST.MF")); //$NON-NLS-1$
manifestSource = new Manifest(srcStream);
zip.close();
@@ -445,17 +453,17 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
if (version != null) {
version = version.replaceFirst("\\.qualifier", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
return;
} finally {
try {
srcStream.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
}
}
- IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
+ final IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
Manifest manifest;
try {
manifest = new Manifest(fileManifest.getContents());
@@ -469,22 +477,22 @@ public class NonReferencedActionPage extends WizardPage implements IWizardPage {
}
manifest.getMainAttributes().putValue("Require-Bundle", value); //$NON-NLS-1$
}
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
manifest.write(bos);
// StringReader reader = new
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
fileManifest.setContents(bis, true, true, null);
context.set("resolvedFile", file); //$NON-NLS-1$
- } catch (IOException e1) {
+ } catch (final IOException e1) {
e1.printStackTrace();
- } catch (CoreException e1) {
+ } catch (final CoreException e1) {
e1.printStackTrace();
}
}
// @Refactor
static public String getPackageFromClassName(String className) {
- int index = className.lastIndexOf('.');
+ final int index = className.lastIndexOf('.');
if (index >= 0) {
return className.substring(0, index);
} else {

Back to the top