From a0124fa4721a4afc454b46607aa7500955cae686 Mon Sep 17 00:00:00 2001 From: jonas Date: Sun, 7 Dec 2014 14:39:33 +0100 Subject: Bug 444692 - Remove Warnings --- .../TargetPlatformContributionCollector.java | 197 +++++++++++---------- .../TargetPlatformIconContributionCollector.java | 10 +- .../resourcelocator/dialogs/DynamicWizard.java | 25 ++- .../dialogs/NonReferencedActionPage.java | 5 +- .../dialogs/NonReferencedResourceDialog.java | 145 ++++++++------- .../dialogs/NonReferencedResourceWizard.java | 20 +-- .../resourcelocator/dialogs/PickProjectPage.java | 23 ++- 7 files changed, 222 insertions(+), 203 deletions(-) (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator') diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java index e18e2b53..b6b17902 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java @@ -6,8 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation, Bug 424730, Bug 435625, Bug 436133, Bug 436132, Bug 436283, Bug 436281, Bug 443510 - * Fabian Miehe - Bug 440327 + * Steven Spungin - initial API and implementation, Bug 424730, Bug 435625, Bug 436133, Bug 436132, + * Bug 436283, Bug 436281, Bug 443510 + * Fabian Miehe - Bug 440327 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator; @@ -31,10 +32,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; + import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; + import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IPath; @@ -112,7 +115,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut @Override public void findContribution(Filter filter, ContributionResultHandler handler) { - Pattern patternName = Pattern.compile(filter.namePattern, Pattern.CASE_INSENSITIVE); + final Pattern patternName = Pattern.compile(filter.namePattern, Pattern.CASE_INSENSITIVE); reloadCache(false, filter.getProviderStatusCallback()); @@ -125,18 +128,18 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut boolean more = false; stopFiltering = false; - for (Entry e : cacheEntry) { + for (final Entry e : cacheEntry) { if (stopFiltering) { break; } - IProgressMonitor monitor = filter.getProgressMonitor(); + final IProgressMonitor monitor = filter.getProgressMonitor(); if (monitor != null) { if (monitor.isCanceled()) { stopFiltering = true; break; - } else { - monitor.subTask(Messages.TargetPlatformContributionCollector_Searching + " " + e.installLocation); //$NON-NLS-1$ } + monitor.subTask(Messages.TargetPlatformContributionCollector_Searching + + " " + e.installLocation); //$NON-NLS-1$ } if (E.notEmpty(filter.getBundles())) { @@ -151,7 +154,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut } if (E.notEmpty(filter.getLocations())) { boolean locationFound = false; - for (String location : filter.getLocations()) { + for (final String location : filter.getLocations()) { if (e.installLocation.startsWith(location)) { locationFound = true; break; @@ -168,12 +171,12 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut } if (filter.getSearchScope().contains(ResourceSearchScope.WORKSPACE)) { if (filter.project != null) { - IWorkspace workspace = filter.project.getWorkspace(); + final IWorkspace workspace = filter.project.getWorkspace(); boolean fnd = false; - for (IProject project : workspace.getRoot().getProjects()) { + for (final IProject project : workspace.getRoot().getProjects()) { // String path = // project.getLocationURI().getPath(); - String path = project.getName(); + final String path = project.getName(); if (e.installLocation.contains(path)) { fnd = true; break; @@ -185,16 +188,15 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut } } - Matcher m = patternName.matcher(e.name); + final Matcher m = patternName.matcher(e.name); if (m.find()) { found++; if (found > maxResults) { more = true; handler.moreResults(ContributionResultHandler.MORE_UNKNOWN, filter); break; - } else { - handler.result(makeData(e)); } + handler.result(makeData(e)); } } @@ -234,8 +236,8 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut IPath ip = Path.fromOSString(e.path); ip = ip.addTrailingSeparator().makeRelative(); ip = ip.append(e.name); - String className = ip.toOSString().replace(File.separatorChar, '.'); - ContributionData data = new ContributionData(e.bundleSymName, className, "Java", e.installLocation); //$NON-NLS-1$ + final String className = ip.toOSString().replace(File.separatorChar, '.'); + final ContributionData data = new ContributionData(e.bundleSymName, className, "Java", e.installLocation); //$NON-NLS-1$ data.installLocation = e.installLocation; data.resourceRelativePath = e.relativePath; return data; @@ -292,95 +294,97 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut @Override protected IStatus run(IProgressMonitor monitor) { // load workspace projects - IProject[] projects = PDECore.getWorkspace().getRoot().getProjects(); - IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels(); - int total = projects.length + models.length; - monitor.beginTask(Messages.TargetPlatformContributionCollector_updatingTargetPlatformCache + cacheName + ")", total); //$NON-NLS-1$ + final IProject[] projects = PDECore.getWorkspace().getRoot().getProjects(); + final IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels(); + final int total = projects.length + models.length; + monitor.beginTask(Messages.TargetPlatformContributionCollector_updatingTargetPlatformCache + + cacheName + ")", total); //$NON-NLS-1$ for (final IProject pj : projects) { if (monitor.isCanceled()) { break; } - String rootDirectory = pj.getLocation().toOSString(); + final String rootDirectory = pj.getLocation().toOSString(); monitor.subTask(rootDirectory); monitor.worked(1); - TargetPlatformContributionCollector.this.visit(monitor, FilteredContributionDialog.getBundle(rootDirectory), rootDirectory, new File(rootDirectory)); + TargetPlatformContributionCollector.this + .visit(monitor, FilteredContributionDialog.getBundle(rootDirectory), rootDirectory, + new File(rootDirectory)); } // load target platform bundles - for (IPluginModelBase pluginModelBase : models) { + for (final IPluginModelBase pluginModelBase : models) { monitor.subTask(pluginModelBase.getPluginBase().getId()); monitor.worked(1); if (monitor.isCanceled()) { break; } - IPluginBase pluginBase = pluginModelBase.getPluginBase(); + final IPluginBase pluginBase = pluginModelBase.getPluginBase(); if (pluginBase == null) { // bundle = getBundle(new File()) continue; } URL url; try { - String installLocation = pluginModelBase.getInstallLocation(); + final String installLocation = pluginModelBase.getInstallLocation(); if (installLocation.endsWith(".jar")) { //$NON-NLS-1$ url = new URL("file://" + installLocation); //$NON-NLS-1$ - ZipInputStream zis = new ZipInputStream(url.openStream()); + final ZipInputStream zis = new ZipInputStream(url.openStream()); while (true) { - ZipEntry entry = zis.getNextEntry(); + final ZipEntry entry = zis.getNextEntry(); if (entry == null) { break; - } else { - String name2 = entry.getName(); - if (shouldIgnore(name2)) { - continue; - } - Matcher m = patternFile.matcher(name2); - if (m.matches()) { - Entry e = new Entry(); - e.installLocation = installLocation; - cacheLocation.add(installLocation); - e.name = m.group(2); - e.path = m.group(1); - if (e.path != null) { - e.pakage = e.path.replace("/", "."); //$NON-NLS-1$ //$NON-NLS-2$ - if (e.pakage.startsWith(".")) { //$NON-NLS-1$ - e.pakage = e.pakage.substring(1); - } - if (e.pakage.endsWith(".")) { //$NON-NLS-1$ - e.pakage = e.pakage.substring(0, e.pakage.length() - 1); - } - } else { - e.pakage = ""; //$NON-NLS-1$ + } + final String name2 = entry.getName(); + if (shouldIgnore(name2)) { + continue; + } + final Matcher m = patternFile.matcher(name2); + if (m.matches()) { + final Entry e = new Entry(); + e.installLocation = installLocation; + cacheLocation.add(installLocation); + e.name = m.group(2); + e.path = m.group(1); + if (e.path != null) { + e.pakage = e.path.replace("/", "."); //$NON-NLS-1$ //$NON-NLS-2$ + if (e.pakage.startsWith(".")) { //$NON-NLS-1$ + e.pakage = e.pakage.substring(1); } - cachePackage.add(e.pakage); - - e.bundleSymName = pluginBase.getId(); - if (e.path == null) { - e.path = ""; //$NON-NLS-1$ + if (e.pakage.endsWith(".")) { //$NON-NLS-1$ + e.pakage = e.pakage.substring(0, e.pakage.length() - 1); } - cacheEntry.add(e); - cacheBundleId.add(pluginBase.getId()); - - // - // System.out.println(group - // + " -> " - // + - // m.group(2)); + } else { + e.pakage = ""; //$NON-NLS-1$ } + cachePackage.add(e.pakage); + + e.bundleSymName = pluginBase.getId(); + if (e.path == null) { + e.path = ""; //$NON-NLS-1$ + } + cacheEntry.add(e); + cacheBundleId.add(pluginBase.getId()); + + // + // System.out.println(group + // + " -> " + // + + // m.group(2)); } } } else { // not a jar file - String bundle = getBundle(new File(installLocation)); + final String bundle = getBundle(new File(installLocation)); if (bundle != null) { visit(monitor, bundle, installLocation, new File(installLocation)); } } - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -391,12 +395,11 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut providerStatusCallback.onStatusChanged(ProviderStatus.CANCELLED); } return Status.CANCEL_STATUS; - } else { - if (providerStatusCallback != null) { - providerStatusCallback.onStatusChanged(ProviderStatus.READY); - } - return Status.OK_STATUS; } + if (providerStatusCallback != null) { + providerStatusCallback.onStatusChanged(ProviderStatus.READY); + } + return Status.OK_STATUS; } }; job.schedule(); @@ -409,13 +412,13 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut @Override public void run() { - ProgressMonitorDialog dlg = new ProgressMonitorDialog(Display.getDefault().getActiveShell()) { + final ProgressMonitorDialog dlg = new ProgressMonitorDialog(Display.getDefault().getActiveShell()) { @Override protected Control createContents(Composite parent) { // TODO odd this is not a bean. - Composite ret = (Composite) super.createContents(parent); - Label label = new Label(ret, SWT.NONE); + final Composite ret = (Composite) super.createContents(parent); + final Label label = new Label(ret, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); label.setText(Messages.TargetPlatformContributionCollector_pleaseWait); @@ -424,7 +427,8 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut @Override protected void createButtonsForButtonBar(Composite parent) { - Button button = createButton(parent, 101, Messages.TargetPlatformContributionCollector_RunInBackground, false); + final Button button = createButton(parent, 101, + Messages.TargetPlatformContributionCollector_RunInBackground, false); // TODO JA button.addSelectionListener(new SelectionAdapter() { @Override @@ -449,18 +453,22 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut dlg.run(true, true, new IRunnableWithProgress() { @Override - public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(Messages.TargetPlatformContributionCollector_WaitingForTargetPlatformIndexingToComplete, IProgressMonitor.UNKNOWN); + public void run(final IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor + .beginTask( + Messages.TargetPlatformContributionCollector_WaitingForTargetPlatformIndexingToComplete, + IProgressMonitor.UNKNOWN); while (job.getState() == Job.RUNNING && !runInBackground) { Thread.sleep(100); } monitor.done(); } }); - } catch (InvocationTargetException e1) { + } catch (final InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); - } catch (InterruptedException e1) { + } catch (final InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } @@ -476,17 +484,17 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut return null; } - File f = new File(file, "META-INF/MANIFEST.MF"); //$NON-NLS-1$ + final File f = new File(file, "META-INF/MANIFEST.MF"); //$NON-NLS-1$ if (f.exists() && f.isFile()) { BufferedReader r = null; try { - InputStream s = new FileInputStream(f); + final InputStream s = new FileInputStream(f); r = new BufferedReader(new InputStreamReader(s)); String line; while ((line = r.readLine()) != null) { if (line.startsWith("Bundle-SymbolicName:")) { //$NON-NLS-1$ - int start = line.indexOf(':'); + final int start = line.indexOf(':'); int end = line.indexOf(';'); if (end == -1) { end = line.length(); @@ -494,13 +502,13 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut return line.substring(start + 1, end).trim(); } } - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } finally { if (r != null) { try { r.close(); - } catch (IOException e) { + } catch (final IOException e) { } } } @@ -509,7 +517,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut } protected void visit(IProgressMonitor monitor, String bundleName, String installLocation, File file) { - for (File fChild : file.listFiles()) { + for (final File fChild : file.listFiles()) { if (monitor.isCanceled()) { break; } @@ -521,9 +529,9 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut if (shouldIgnore(name2)) { continue; } - Matcher m = patternFile.matcher(name2); + final Matcher m = patternFile.matcher(name2); if (m.matches()) { - Entry e = new Entry(); + final Entry e = new Entry(); e.installLocation = installLocation; cacheLocation.add(installLocation); e.name = m.group(2); @@ -545,7 +553,8 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut if (e.path == null) { e.path = ""; //$NON-NLS-1$ } - e.relativePath = Path.fromOSString(file.getAbsolutePath().replace(e.installLocation, "")).makeRelative().toOSString(); //$NON-NLS-1$ + e.relativePath = Path + .fromOSString(file.getAbsolutePath().replace(e.installLocation, "")).makeRelative().toOSString(); //$NON-NLS-1$ e.bundleSymName = bundleName; // TODO we need project to strip source paths. @@ -565,7 +574,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut if (installLocation.matches(".*\\.jar")) { //$NON-NLS-1$ return path; } - for (String sourceDirectory : getOutputDirectories(installLocation)) { + for (final String sourceDirectory : getOutputDirectories(installLocation)) { if (path.startsWith(sourceDirectory)) { path = path.substring(sourceDirectory.length()); break; @@ -589,14 +598,16 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut ret = new ArrayList(); outputDirectories.put(installLocation, ret); try { - Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(installLocation + File.separator + ".classpath")); //$NON-NLS-1$ - XPath xp = XPathFactory.newInstance().newXPath(); - NodeList list = (NodeList) xp.evaluate("//classpathentry[@kind='output']/@path", doc, XPathConstants.NODESET); //$NON-NLS-1$ + final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new File(installLocation + File.separator + ".classpath")); //$NON-NLS-1$ + final XPath xp = XPathFactory.newInstance().newXPath(); + final NodeList list = (NodeList) xp.evaluate( + "//classpathentry[@kind='output']/@path", doc, XPathConstants.NODESET); //$NON-NLS-1$ for (int i = 0; i < list.getLength(); i++) { - String value = list.item(i).getNodeValue(); + final String value = list.item(i).getNodeValue(); ret.add(value); } - } catch (Exception e) { + } catch (final Exception e) { } } return ret; diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformIconContributionCollector.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformIconContributionCollector.java index 56eeb909..b50ff3b7 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformIconContributionCollector.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformIconContributionCollector.java @@ -6,12 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation, Bug 424730 + * Steven Spungin - initial API and implementation, Bug 424730 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator; import java.util.regex.Pattern; + import org.eclipse.e4.tools.emf.ui.common.IClassContributionProvider.ContributionData; /** @@ -32,7 +33,8 @@ public class TargetPlatformIconContributionCollector extends TargetPlatformContr static public TargetPlatformIconContributionCollector getInstance() { if (instance == null) { - instance = new TargetPlatformIconContributionCollector(Messages.TargetPlatformIconContributionCollector_images); + instance = new TargetPlatformIconContributionCollector( + Messages.TargetPlatformIconContributionCollector_images); } return instance; } @@ -40,11 +42,11 @@ public class TargetPlatformIconContributionCollector extends TargetPlatformContr @Override protected Pattern getFilePattern() { return pattern; - }; + } @Override protected ContributionData makeData(Entry e) { - ContributionData data = new ContributionData(e.bundleSymName, null, "Java", e.path + e.name); //$NON-NLS-1$ + final ContributionData data = new ContributionData(e.bundleSymName, null, "Java", e.path + e.name); //$NON-NLS-1$ data.installLocation = e.installLocation; data.resourceRelativePath = data.iconPath; return data; diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/DynamicWizard.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/DynamicWizard.java index 1be8e4f3..467b7668 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/DynamicWizard.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/DynamicWizard.java @@ -6,12 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation + * Steven Spungin - initial API and implementation *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.dialogs; import java.util.ArrayList; + import org.eclipse.e4.tools.emf.ui.internal.common.component.tabs.empty.E; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; @@ -41,11 +42,11 @@ public class DynamicWizard extends Wizard { @Override public boolean canFinish() { - IWizardPage cur = getContainer().getCurrentPage(); - IWizardPage nextPage = getNextPage(cur); + final IWizardPage cur = getContainer().getCurrentPage(); + final IWizardPage nextPage = getNextPage(cur); // We need to call get next page first, as that may add or remove pages - for (IWizardPage page : pages) { + for (final IWizardPage page : pages) { if (page.isPageComplete() == false) { return false; } @@ -74,9 +75,9 @@ public class DynamicWizard extends Wizard { private void updateMessage() { if (E.notEmpty(message) && pages.size() > 0) { // TODO file bug: IWizardPage is missing the setMessage method! - IWizardPage page = pages.get(0); + final IWizardPage page = pages.get(0); if (page instanceof WizardPage) { - WizardPage wizPage = (WizardPage) page; + final WizardPage wizPage = (WizardPage) page; wizPage.setMessage(message); } } @@ -84,23 +85,21 @@ public class DynamicWizard extends Wizard { @Override public IWizardPage getPreviousPage(IWizardPage page) { - IWizardPage cur = getContainer().getCurrentPage(); - int index = pages.indexOf(cur); + final IWizardPage cur = getContainer().getCurrentPage(); + final int index = pages.indexOf(cur); if (index > 0) { return pages.get(index - 1); - } else { - return null; } + return null; } @Override public IWizardPage getNextPage(IWizardPage page) { - int index = pages.indexOf(page); + final int index = pages.indexOf(page); if (index < pages.size() - 1) { return pages.get(index + 1); - } else { - return null; } + return null; } public void clearDynamicPages() { 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 d1a55456..f84d3e03 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 @@ -197,7 +197,7 @@ public class NonReferencedActionPage extends WizardPage { 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$ + .setText("platform:/plugin/" + bundle + "/" + file.getFullPath().removeFirstSegments(1).toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -495,9 +495,8 @@ public class NonReferencedActionPage extends WizardPage { final int index = className.lastIndexOf('.'); if (index >= 0) { return className.substring(0, index); - } else { - return ""; //$NON-NLS-1$ } + return ""; //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceDialog.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceDialog.java index 410ed63d..969c9260 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceDialog.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceDialog.java @@ -6,13 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation, Bug 424730, Ongoing Maintenance + * Steven Spungin - initial API and implementation, Bug 424730, 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; @@ -58,14 +58,15 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { private String bundle; private final IFile file; private IFile result; - private IProject project; + private final IProject project; private String className; - private String installLocation; + private final String installLocation; protected Runnable okAction; private BundleImageCache imageCache; - private IEclipseContext context; + private final IEclipseContext context; - public NonReferencedResourceDialog(Shell parentShell, IProject project, String bundle, IFile file, String installLocation, IEclipseContext context) { + public NonReferencedResourceDialog(Shell parentShell, IProject project, String bundle, IFile file, + String installLocation, IEclipseContext context) { super(parentShell); this.project = project; this.bundle = bundle; @@ -77,8 +78,8 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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; } } @@ -88,7 +89,7 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { try { okAction.run(); super.okPressed(); - } catch (Exception e) { + } catch (final Exception e) { } } else { super.okPressed(); @@ -97,34 +98,34 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { @Override protected Control createDialogArea(Composite parent) { - Composite compParent = (Composite) super.createDialogArea(parent); + final Composite compParent = (Composite) super.createDialogArea(parent); - 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); @@ -132,37 +133,37 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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); @@ -170,38 +171,39 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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.NonReferencedResourceDialog_Action); @@ -241,13 +243,13 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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) @@ -257,12 +259,12 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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); result = file; - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -304,18 +306,24 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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); result = new ContributionDataFile(cdConverted); } - } catch (Exception e1) { - MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error, e1.getMessage()); + } catch (final Exception e1) { + MessageDialog.openError(getShell(), Messages.NonReferencedResourceDialog_error, + e1.getMessage()); } } }; @@ -360,10 +368,11 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { @Override public void run() { - ReferencedProjectPickerDialog dlg = new ReferencedProjectPickerDialog(getShell(), project) { + final ReferencedProjectPickerDialog dlg = new ReferencedProjectPickerDialog(getShell(), + project) { @Override protected Control createContents(Composite parent) { - Control ret = super.createContents(parent); + final Control ret = super.createContents(parent); setMessage(Messages.NonReferencedResourceDialog_selectProjectToReceiveCopy); setTitleImage(imageCache.create("/icons/full/wizban/plugin_wiz.gif")); //$NON-NLS-1$ @@ -389,12 +398,11 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { // @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 { - return ""; //$NON-NLS-1$ } + return ""; //$NON-NLS-1$ } @Override @@ -408,15 +416,15 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { } }); - Control ret = super.createContents(parent); + final Control ret = super.createContents(parent); setMessage(Messages.NonReferencedResourceDialog_resourceNotReferenced); - String message = getMessage(); + final String message = getMessage(); setMessage(message); setTitle(Messages.NonReferencedResourceDialog_resourceReferenceWarning); getShell().setText(Messages.NonReferencedResourceDialog_resourceReferenceWarning); try { setTitleImage(imageCache.create(Plugin.ID, "/icons/full/wizban/newefix_wizban.png")); //$NON-NLS-1$ - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } return ret; @@ -428,10 +436,11 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { public void copyResourceToProject(IProject project) { try { - ProjectFolderPickerDialog dlg = new ProjectFolderPickerDialog(getShell(), project, file.getFullPath().toOSString()) { + final ProjectFolderPickerDialog dlg = new ProjectFolderPickerDialog(getShell(), project, file.getFullPath() + .toOSString()) { @Override protected Control createContents(Composite parent) { - Control ret = super.createContents(parent); + final Control ret = super.createContents(parent); setMessage(Messages.NonReferencedResourceDialog_selectTheFolderResourceCopy); setTitleImage(imageCache.create(Plugin.ID, "/icons/full/wizban/add_to_dir_wiz.png")); //$NON-NLS-1$ @@ -449,14 +458,14 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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); result = fileClone; } - } catch (CoreException e1) { + } catch (final CoreException e1) { e1.printStackTrace(); MessageDialog.openError(getShell(), "Error", e1.getMessage()); //$NON-NLS-1$ @@ -471,7 +480,7 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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(); @@ -483,17 +492,17 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { 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()); @@ -507,15 +516,15 @@ public class NonReferencedResourceDialog extends TitleAreaDialog { } 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); result = file; - } catch (IOException e1) { + } catch (final IOException e1) { e1.printStackTrace(); - } catch (CoreException e1) { + } catch (final CoreException e1) { e1.printStackTrace(); } } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceWizard.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceWizard.java index dbb731ca..5868da52 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceWizard.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/NonReferencedResourceWizard.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation, Bug 436848 + * Steven Spungin - initial API and implementation, Bug 436848 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.dialogs; @@ -28,13 +28,14 @@ import org.eclipse.swt.widgets.Shell; */ public class NonReferencedResourceWizard extends DynamicWizard { - private NonReferencedActionPage nonReferencedActionPage; + private final NonReferencedActionPage nonReferencedActionPage; protected IProject project; IEclipseContext wizContext; BundleImageCache imageCache; - public NonReferencedResourceWizard(Shell parentShell, IProject project, String bundle, IFile file, String installLocation, IEclipseContext context) { + public NonReferencedResourceWizard(Shell parentShell, IProject project, String bundle, IFile file, + String installLocation, IEclipseContext context) { this.project = project; wizContext = context.createChild(); @@ -58,7 +59,7 @@ public class NonReferencedResourceWizard extends DynamicWizard { @Override public boolean performFinish() { - Runnable action = wizContext.get(Runnable.class); + final Runnable action = wizContext.get(Runnable.class); if (action != null) { action.run(); } @@ -73,20 +74,20 @@ public class NonReferencedResourceWizard extends DynamicWizard { public IWizardPage getNextPage(IWizardPage page) { if (page instanceof NonReferencedActionPage) { clearDynamicPages(); - NonReferencedAction action = wizContext.get(NonReferencedAction.class); + final NonReferencedAction action = wizContext.get(NonReferencedAction.class); if (action == null) { return null; } switch (action) { case COPY: { - PickProjectFolderPage pickProjectFolderPage = new PickProjectFolderPage(wizContext); + final PickProjectFolderPage pickProjectFolderPage = new PickProjectFolderPage(wizContext); addPage(pickProjectFolderPage); return pickProjectFolderPage; } case COPY_TO_OTHER: - PickProjectPage pickProjectPage = new PickProjectPage(wizContext); + final PickProjectPage pickProjectPage = new PickProjectPage(wizContext); addPage(pickProjectPage); - PickProjectFolderPage pickProjectFolderPage = new PickProjectFolderPage(wizContext); + final PickProjectFolderPage pickProjectFolderPage = new PickProjectFolderPage(wizContext); addPage(pickProjectFolderPage); return pickProjectPage; case USE_ANYWAY: @@ -103,9 +104,8 @@ public class NonReferencedResourceWizard extends DynamicWizard { default: return null; } - } else { - return super.getNextPage(page); } + return super.getNextPage(page); } @Override diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/PickProjectPage.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/PickProjectPage.java index e5dff6b1..572054aa 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/PickProjectPage.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/PickProjectPage.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin - initial API and implementation, Ongoing Maintenance + * Steven Spungin - initial API and implementation, Ongoing Maintenance *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator.dialogs; @@ -23,7 +23,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; @@ -39,20 +38,20 @@ import org.eclipse.swt.widgets.Composite; * @author Steven Spungin * */ -public class PickProjectPage extends WizardPage implements IWizardPage { +public class PickProjectPage extends WizardPage { private TableViewer viewer; private BundleImageCache imageCache; private Image imgProject; private IProject[] projects; - private IEclipseContext context; + private final IEclipseContext context; protected PickProjectPage(IEclipseContext context) { super(Messages.PickProjectPage_SelectReferencedProject); this.context = context; try { - this.projects = context.get(IProject.class).getReferencedProjects(); - } catch (CoreException e) { + projects = context.get(IProject.class).getReferencedProjects(); + } catch (final CoreException e) { setErrorMessage(e.getMessage()); e.printStackTrace(); } @@ -73,7 +72,7 @@ public class PickProjectPage extends WizardPage implements IWizardPage { }); imgProject = imageCache.create("/icons/full/obj16/projects.png"); //$NON-NLS-1$ - Composite comp = new Composite(parent, SWT.NONE); + final Composite comp = new Composite(parent, SWT.NONE); comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); comp.setLayout(new GridLayout(1, false)); @@ -82,7 +81,7 @@ public class PickProjectPage extends WizardPage implements IWizardPage { viewer.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - IProject project = (IProject) element; + final IProject project = (IProject) element; return project.getName(); } @@ -99,19 +98,19 @@ public class PickProjectPage extends WizardPage implements IWizardPage { @Override public void selectionChanged(SelectionChangedEvent event) { - Object firstElement = ((StructuredSelection) event.getSelection()).getFirstElement(); + final Object firstElement = ((StructuredSelection) event.getSelection()).getFirstElement(); context.set("projectToCopyTo", firstElement); //$NON-NLS-1$ setPageComplete(firstElement != null); getContainer().updateButtons(); } }); - String message = Messages.ReferencedProjectPickerDialog_selectReferencedProject; + final String message = Messages.ReferencedProjectPickerDialog_selectReferencedProject; setMessage(message); getShell().setText(message); setTitle(message); - Image image = context.get(BundleImageCache.class).create("/icons/full/obj16/projects.png"); //$NON-NLS-1$ + final Image image = context.get(BundleImageCache.class).create("/icons/full/obj16/projects.png"); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromImage(image)); setControl(comp); @@ -119,7 +118,7 @@ public class PickProjectPage extends WizardPage implements IWizardPage { @Override public void setVisible(boolean visible) { - Object object = context.get("projectToCopyTo"); //$NON-NLS-1$ + final Object object = context.get("projectToCopyTo"); //$NON-NLS-1$ if (visible) { if (object != null) { viewer.setSelection(new StructuredSelection(object)); -- cgit v1.2.3