# HG changeset patch # User Eugene Ostroukhov # Date 1283449838 25200 # Node ID 109da596fa9d243993cb690d952e536e1029dec5 # Parent 2973198ae2a957a4539a3c960520ece021040ad0 Fixed relevant FindBug messages diff -r 2973198ae2a9 -r 109da596fa9d features/org.symbian.tools.wrttools.feature/feature.xml --- a/features/org.symbian.tools.wrttools.feature/feature.xml Wed Sep 01 16:59:08 2010 -0700 +++ b/features/org.symbian.tools.wrttools.feature/feature.xml Thu Sep 02 10:50:38 2010 -0700 @@ -34,20 +34,6 @@ unpack="false"/> - - - - { + @Override + public String createVersionNotFoundErrMsg(String verstr) { + return "Version not found"; + } + + @Override + public String getPluginId() { + return TMWCore.PLUGIN_ID; + } + } + private static final class VersionedEntry { + protected final T entry; protected final IVersionExpr versionExpression; - protected final T entry; public VersionedEntry(String versionExpression, T entry) { if (versionExpression == null) { @@ -77,63 +130,27 @@ } } - private static final class VersionableObject extends Versionable { - @Override - public String getPluginId() { - return TMWCore.PLUGIN_ID; - } - - @Override - public String createVersionNotFoundErrMsg(String verstr) { - return "Version not found"; - } - } - - private static final class Version implements IVersion { - private final String version; - - public Version(String version) { - this.version = version; - } - - public int compareTo(Object o) { - return version.compareTo(((IVersion) o).getVersionString()); - } - - public String getVersionString() { - return version; - } - } + private final Map>>>>> providers = new HashMap>>>>>(); + private boolean ready = false; - private final Map>>>>> providers = new HashMap>>>>>(); - private final boolean ready = false; - - public IIncludePathEntry[] getProjectClasspathEntries(IFacetedProject project) { - collectProviders(); - final ITMWProject p = TMWCore.create(project.getProject()); - if (p != null) { - final IMobileWebRuntime runtime = p.getTargetRuntime(); - final Map>> facetToEntry; - if (runtime != null) { - facetToEntry = join(getMatchingEntries(runtime.getId(), runtime.getVersion(), providers)); - } else { - facetToEntry = join(getMatchingEntries(null, null, providers)); + public Map>> collectFaceletEntries( + IConfigurationElement[] elements) { + final Map>> faceletsToProviders = new HashMap>>(); + for (IConfigurationElement element : elements) { + if ("facet-include-path".equals(element.getName())) { + final IFacetIncludePathProvider[] providers = collectProviders(element.getChildren()); + final VersionedEntry versionedEntry = new VersionedEntry( + element.getAttribute("version"), providers); + final String id = element.getAttribute("facelet-id"); + Collection> provs = faceletsToProviders.get(id); + if (provs == null) { + provs = new LinkedList>(); + faceletsToProviders.put(id, provs); + } + provs.add(versionedEntry); } - final Collection entries = getMatchingEntries(null, null, facetToEntry); - final Set facets = project.getProjectFacets(); - for (IProjectFacetVersion facet : facets) { - entries.addAll(getMatchingEntries(facet.getProjectFacet().getId(), facet.getVersionString(), - facetToEntry)); - } - final Collection pathEntries = new HashSet(); - for (IFacetIncludePathProvider[] providers : entries) { - for (IFacetIncludePathProvider provider : providers) { - pathEntries.addAll(Arrays.asList(provider.getEntries(p))); - } - } - return pathEntries.toArray(new IIncludePathEntry[pathEntries.size()]); } - return new IIncludePathEntry[0]; + return faceletsToProviders; } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -164,6 +181,7 @@ versions.add(ver); } } + ready = true; } } @@ -179,40 +197,6 @@ return providers.toArray(new IFacetIncludePathProvider[providers.size()]); } - public Map>> collectFaceletEntries( - IConfigurationElement[] elements) { - final Map>> faceletsToProviders = new HashMap>>(); - for (IConfigurationElement element : elements) { - if ("facet-include-path".equals(element.getName())) { - final IFacetIncludePathProvider[] providers = collectProviders(element.getChildren()); - final VersionedEntry versionedEntry = new VersionedEntry( - element.getAttribute("version"), providers); - final String id = element.getAttribute("facelet-id"); - Collection> provs = faceletsToProviders.get(id); - if (provs == null) { - provs = new LinkedList>(); - faceletsToProviders.put(id, provs); - } - provs.add(versionedEntry); - } - } - return faceletsToProviders; - } - - private Map> join(Collection>> maps) { - final Map> res = new HashMap>(); - for (Map> map : maps) { - for (Map.Entry> entry : map.entrySet()) { - if (res.containsKey(entry.getKey())) { - res.get(entry.getKey()).addAll(entry.getValue()); - } else { - res.put(entry.getKey(), new LinkedList(entry.getValue())); - } - } - } - return res; - } - private Collection getMatchingEntries(String id, String version, Map>> map) { final Collection> entries = new LinkedList>(); @@ -234,4 +218,46 @@ } return res; } + + public IIncludePathEntry[] getProjectClasspathEntries(IFacetedProject project) { + collectProviders(); + final ITMWProject p = TMWCore.create(project.getProject()); + if (p != null) { + final IMobileWebRuntime runtime = p.getTargetRuntime(); + final Map>> facetToEntry; + if (runtime != null) { + facetToEntry = join(getMatchingEntries(runtime.getId(), runtime.getVersion(), providers)); + } else { + facetToEntry = join(getMatchingEntries(null, null, providers)); + } + final Collection entries = getMatchingEntries(null, null, facetToEntry); + final Set facets = project.getProjectFacets(); + for (IProjectFacetVersion facet : facets) { + entries.addAll(getMatchingEntries(facet.getProjectFacet().getId(), facet.getVersionString(), + facetToEntry)); + } + final Collection pathEntries = new HashSet(); + for (IFacetIncludePathProvider[] providers : entries) { + for (IFacetIncludePathProvider provider : providers) { + pathEntries.addAll(Arrays.asList(provider.getEntries(p))); + } + } + return pathEntries.toArray(new IIncludePathEntry[pathEntries.size()]); + } + return new IIncludePathEntry[0]; + } + + private Map> join(Collection>> maps) { + final Map> res = new HashMap>(); + for (Map> map : maps) { + for (Map.Entry> entry : map.entrySet()) { + if (res.containsKey(entry.getKey())) { + res.get(entry.getKey()).addAll(entry.getValue()); + } else { + res.put(entry.getKey(), new LinkedList(entry.getValue())); + } + } + } + return res; + } } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.debug/plugin.xml --- a/plugins/org.symbian.tools.tmw.debug/plugin.xml Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.debug/plugin.xml Thu Sep 02 10:50:38 2010 -0700 @@ -91,7 +91,7 @@ parameters, - String sessionId) - throws IOException, CoreException { + String sessionId) throws IOException, CoreException { synchronized (this) { if (WRT10 == null || PreviewerPlugin.DONT_CACHE_SCRIPT) { loadCoreAPI(); @@ -67,16 +66,21 @@ final IPath path = new Path(base).append(jsfile); InputStream stream = FileLocator.openStream(PreviewerPlugin.getDefault().getBundle(), path, false); if (stream != null) { + BufferedReader reader = null; try { builder.append(String.format("// Start \"%s\"\n", path.toOSString())); - BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "utf8")); + reader = new BufferedReader(new InputStreamReader(stream, "utf8")); String sz; while ((sz = reader.readLine()) != null) { builder.append(sz).append('\n'); } builder.append(String.format("// End \"%s\"\n", path.toOSString())); } finally { - stream.close(); + if (reader == null) { + stream.close(); + } else { + reader.close(); + } } } else { PreviewerPlugin.log("Missing JS file " + path.toOSString(), null); @@ -113,8 +117,7 @@ } public void post(IProject project, IPath resource, Map parameterMap, JSONObject object, - String sessionId) - throws IOException, CoreException { + String sessionId) throws IOException, CoreException { // Nothing to do } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/preview/AbstractPreviewPage.java --- a/plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/preview/AbstractPreviewPage.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/preview/AbstractPreviewPage.java Thu Sep 02 10:50:38 2010 -0700 @@ -48,7 +48,7 @@ this.previewView = previewView; } - protected void toggleRefresh() { + protected synchronized void toggleRefresh() { toggleState = !toggleState; toggleRefresh.setChecked(toggleState); previewView.setProjectAutorefresh(project, toggleState); diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetTypeDescriptor.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetTypeDescriptor.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetTypeDescriptor.java Thu Sep 02 10:50:38 2010 -0700 @@ -32,7 +32,7 @@ import org.symbian.tools.tmw.ui.deployment.IDeploymentTargetType; public final class DeploymentTargetTypeDescriptor implements IDeploymentTargetType { - public class NullProvider implements IDeploymentTargetType { + public static class NullProvider implements IDeploymentTargetType { public IDeploymentTarget[] getTargets(ITMWProject project) { return null; } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetWrapper.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetWrapper.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/DeploymentTargetWrapper.java Thu Sep 02 10:50:38 2010 -0700 @@ -32,7 +32,7 @@ import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget; public class DeploymentTargetWrapper implements IDeploymentTarget { - public class WorkbenchAdapter2Wrapper implements IWorkbenchAdapter2 { + public static final class WorkbenchAdapter2Wrapper implements IWorkbenchAdapter2 { private final IWorkbenchAdapter2 adapter; public WorkbenchAdapter2Wrapper(IWorkbenchAdapter2 adapter) { @@ -52,7 +52,7 @@ } } - public class WorkbenchAdapterWrapper implements IWorkbenchAdapter { + public static final class WorkbenchAdapterWrapper implements IWorkbenchAdapter { private final IWorkbenchAdapter adapter; public WorkbenchAdapterWrapper(IWorkbenchAdapter adapter) { diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/targets/FilesystemDeploymentTarget.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/targets/FilesystemDeploymentTarget.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/deployment/targets/FilesystemDeploymentTarget.java Thu Sep 02 10:50:38 2010 -0700 @@ -65,7 +65,9 @@ throw new CoreException( new Status(IStatus.ERROR, TMWCoreUI.PLUGIN_ID, "Failed to copy application file", e)); } finally { - file.delete(); + if (!file.delete()) { + TMWCoreUI.log("Can't delete %s", file); + } } return Status.OK_STATUS; } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizard.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizard.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizard.java Thu Sep 02 10:50:38 2010 -0700 @@ -175,7 +175,7 @@ public void init(IWorkbench workbench, IStructuredSelection selection) { file = null; - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { + if (!selection.isEmpty()) { Object element = (selection).getFirstElement(); if (element instanceof IAdaptable) { IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizardPage.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizardPage.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/importwizard/ApplicationImportWizardPage.java Thu Sep 02 10:50:38 2010 -0700 @@ -51,7 +51,7 @@ @SuppressWarnings("restriction") public class ApplicationImportWizardPage extends WizardPage { - public class MapContentProvider implements IStructuredContentProvider { + private static final class MapContentProvider implements IStructuredContentProvider { public void dispose() { // Do nothing diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/CompoundInstaller.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/CompoundInstaller.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/CompoundInstaller.java Thu Sep 02 10:50:38 2010 -0700 @@ -37,7 +37,7 @@ import org.symbian.tools.tmw.ui.project.ITemplateInstaller; public class CompoundInstaller implements ITemplateInstaller { - private final class InstallerFiles { + private static final class InstallerFiles { private final ITemplateInstaller installer; private final Collection paths; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/LazyInstaller.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/LazyInstaller.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/LazyInstaller.java Thu Sep 02 10:50:38 2010 -0700 @@ -29,7 +29,7 @@ import org.symbian.tools.tmw.ui.project.ITemplateInstaller; public final class LazyInstaller implements ITemplateInstaller { - private final class NullInstaller implements ITemplateInstaller { + private static final class NullInstaller implements ITemplateInstaller { public void cleanup() { // Do nothing } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/PrepareProjectJob.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/PrepareProjectJob.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/PrepareProjectJob.java Thu Sep 02 10:50:38 2010 -0700 @@ -40,7 +40,7 @@ private final IRunnableWithProgress action; public PrepareProjectJob(IProject project, IRunnableWithProgress action) { - super(String.format("Preparing project", project.getName())); + super(String.format("Preparing project %s", project.getName())); this.project = project; this.action = action; setUser(false); diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Thu Sep 02 10:50:38 2010 -0700 @@ -18,6 +18,7 @@ */ package org.symbian.tools.tmw.internal.ui.project; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -36,7 +37,9 @@ import org.symbian.tools.tmw.ui.project.ITemplateInstaller; public class ProjectTemplateManagerImpl implements IProjectTemplateManager { - public class TemplateComparator implements Comparator { + private static final class TemplateComparator implements Comparator, Serializable { + private static final long serialVersionUID = -6418798170300850625L; + public int compare(IProjectTemplate o1, IProjectTemplate o2) { if (o1 == o2) { return 0; @@ -52,6 +55,7 @@ } } } + private Map emptyProjects; private Map> runtimeTemplateParameters; private Map templates; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/FacetsSelectionPanel.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/FacetsSelectionPanel.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/FacetsSelectionPanel.java Thu Sep 02 10:50:38 2010 -0700 @@ -637,7 +637,7 @@ } } - private final class FixedFacetToolTip extends ToolTip { + private static final class FixedFacetToolTip extends ToolTip { private static final int FAKE_EVENT_TYPE = -9999; private String message = ""; //$NON-NLS-1$ @@ -707,7 +707,7 @@ } } - private final class ProblemsLabelProvider implements ITableLabelProvider { + private static final class ProblemsLabelProvider implements ITableLabelProvider { public String getColumnText(final Object element, final int column) { return ((IStatus) element).getMessage(); } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NewApplicationTemplateWizardPage.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NewApplicationTemplateWizardPage.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/NewApplicationTemplateWizardPage.java Thu Sep 02 10:50:38 2010 -0700 @@ -29,7 +29,7 @@ import org.symbian.tools.tmw.ui.project.IProjectTemplate; public class NewApplicationTemplateWizardPage extends WizardPage { - public class ProjectTemplateLabelProvider extends LabelProvider { + private static final class ProjectTemplateLabelProvider extends LabelProvider { @Override public Image getImage(Object element) { diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Thu Sep 02 10:50:38 2010 -0700 @@ -240,7 +240,7 @@ this.runtime = runtime; propertySupport.firePropertyChange(RUNTIME, prev, runtime); propertySupport.firePropertyChange(TEMPLATES, prevTemplates, getTemplates()); - if (prevTemplate == null) { + if (template == null) { propertySupport.firePropertyChange(TEMPLATE, prevTemplate, getTemplate()); } } @@ -263,7 +263,7 @@ public void setWidgetName(String widgetName) { String prevId = getWidgetId(); String prev = getWidgetName(); - if (widgetName == getProjectName()) { + if (widgetName == null || widgetName.equals(getProjectName())) { this.widgetName = null; } else { this.widgetName = widgetName; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/Images.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/Images.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/Images.java Thu Sep 02 10:50:38 2010 -0700 @@ -23,9 +23,9 @@ import org.eclipse.swt.graphics.Image; public final class Images { - private final String DISCOVER_ICON = "icons/full/obj16/discover.gif"; - private final String EXCLUDED_ICON = "icons/full/obj16/excluded.gif"; - private final String BLUETOOTH_ICON = "icons/full/obj16/bluetooth.gif"; + private static final String DISCOVER_ICON = "icons/full/obj16/discover.gif"; + private static final String EXCLUDED_ICON = "icons/full/obj16/excluded.gif"; + private static final String BLUETOOTH_ICON = "icons/full/obj16/bluetooth.gif"; private final ImageRegistry registry; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java Thu Sep 02 10:50:38 2010 -0700 @@ -53,10 +53,12 @@ import org.symbian.tools.tmw.core.TMWCore; import org.symbian.tools.tmw.core.projects.ITMWProject; import org.symbian.tools.tmw.core.runtimes.IPackager; +import org.symbian.tools.tmw.ui.TMWCoreUI; import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget; public class BluetoothTarget extends PlatformObject implements IDeploymentTarget { private static final UUID OBEX_OBJECT_PUSH = new UUID(0x1105); + public static final long BLUETOOTH_TIMEOUT = 5 * 60 * 1000; // 5 min private String serviceURL; private RemoteDevice device; protected String[] exceptionCodes = new String[] { "OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN" }; @@ -84,7 +86,9 @@ try { deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10)); } finally { - application.delete(); + if (!application.delete()) { + TMWCoreUI.log("Can't delete %s", application); + } } monitor.done(); MultiStatus multiStatus = new MultiStatus(TMWCore.PLUGIN_ID, 0, message, null); @@ -151,7 +155,7 @@ hsOperation.setHeader(HeaderSet.TYPE, fileType); int size = (int) inputWidget.length(); byte file[] = new byte[size]; - hsOperation.setHeader(HeaderSet.LENGTH, new Long(file.length)); + hsOperation.setHeader(HeaderSet.LENGTH, Long.valueOf(file.length)); // Create PUT Operation putOperation = clientSession.put(hsOperation); @@ -291,7 +295,7 @@ synchronized (serviceSearchCompletedEvent) { LocalDevice.getLocalDevice().getDiscoveryAgent() .searchServices(attrIDs, searchUuidSet, device, listener); - serviceSearchCompletedEvent.wait(); + serviceSearchCompletedEvent.wait(BLUETOOTH_TIMEOUT); } } catch (IOException e) { diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTargetType.java --- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTargetType.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTargetType.java Thu Sep 02 10:50:38 2010 -0700 @@ -19,7 +19,6 @@ package org.symbian.tools.tmw.ui.deployment.bluetooth; import java.io.IOException; -import java.io.PrintStream; import java.util.Collection; import java.util.Map; import java.util.TreeMap; @@ -38,7 +37,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.symbian.tools.tmw.core.projects.ITMWProject; -import org.symbian.tools.tmw.ui.ConsoleFactory; import org.symbian.tools.tmw.ui.TMWCoreUI; import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget; import org.symbian.tools.tmw.ui.deployment.IDeploymentTargetType; @@ -111,7 +109,6 @@ } } - private static PrintStream savedSysOut; private boolean discovered = false; private TargetDiscoveryListener listener; private Map targets = new TreeMap(); @@ -139,7 +136,7 @@ try { started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.GIAC, listener); if (started) { - inquiryCompletedEvent.wait(); + inquiryCompletedEvent.wait(BluetoothTarget.BLUETOOTH_TIMEOUT); discovered = true; } } catch (BluetoothStateException e) { @@ -151,18 +148,6 @@ monitor.done(); } - /** Toggle BlueCove logging - */ - public void enableBlueCoveDiagnostics(boolean enable) { - System.setProperty("bluecove.debug", Boolean.valueOf(enable).toString()); - BlueCoveImpl.instance().enableNativeDebug(enable); - if (enable) { - System.setOut(new PrintStream(ConsoleFactory.createStream())); - } else { - System.setOut(savedSysOut); - } - } - public IDeploymentTarget findTarget(ITMWProject project, String id) { if (!isBloothToothConnected()) { return null; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java Thu Sep 02 10:50:38 2010 -0700 @@ -90,16 +90,16 @@ return result; } - public enum plistElements { + private static enum PListElements { plist, array, data, date, dict, real, integer, string, FALSE, TRUE, key, xml }; private void validateElement(IDOMElement element, ValidationResult result, IResource resource) { // showData(""); - plistElements[] values = plistElements.values(); + PListElements[] values = PListElements.values(); boolean isValidElement = false; - for (plistElements validElement : values) { + for (PListElements validElement : values) { if (validElement.toString().equalsIgnoreCase( element.getNodeName().trim())) { isValidElement = true; diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/project/WRT11ApplicationLayout.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/project/WRT11ApplicationLayout.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/project/WRT11ApplicationLayout.java Thu Sep 02 10:50:38 2010 -0700 @@ -93,7 +93,7 @@ public IPath getResourcePath(IFile file) { try { - if (file != null && file.getProjectRelativePath().equals(CoreUtil.getIndexFile(file.getProject()))) { + if (file != null && file.equals(CoreUtil.getIndexFile(file.getProject()))) { return new Path(INDEX); } } catch (CoreException e) { diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/Util.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/Util.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/Util.java Thu Sep 02 10:50:38 2010 -0700 @@ -18,9 +18,6 @@ */ package org.symbian.tools.wrttools.util; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; public class Util { @@ -28,74 +25,6 @@ return widgetName != null ? widgetName.replace(" ", "") : ""; } - public static String removeNonAlphaNum(String projectName) { - return projectName != null ? projectName - .replaceAll("[^a-zA-Z0-9 ]", "") : null; - } - - public static void logEvent(Logger log, Level level, Throwable throwable) { - if (level == Level.SEVERE) { - log.severe(throwable.getLocalizedMessage()); - if (throwable.getCause() != null) { - log.severe(throwable.getCause().toString()); - } - log.severe(throwable.getStackTrace().toString()); - } - if (level == Level.WARNING) { - log.warning(throwable.getLocalizedMessage()); - if (throwable.getCause() != null) { - log.warning(throwable.getCause().toString()); - } - log.warning(throwable.getStackTrace().toString()); - } - if (level == Level.INFO) { - log.info(throwable.getLocalizedMessage()); - if (throwable.getCause() != null) { - log.info(throwable.getCause().toString()); - } - log.info(throwable.getStackTrace().toString()); - } - - } - - public static String replaceChar(String input, char asciiOutChar, - char asciiInChar) { - char x; - int ascii; - String outString = ""; - int outCharAscii = (asciiOutChar > 127) ? '?' - : (char) (asciiOutChar & 0x7F); - - for (int i = 0; i < input.length(); i++) { - x = input.charAt(i); - ascii = (x > 127) ? '?' : (char) (x & 0x7F); - - if (ascii == outCharAscii) { - outString = outString + asciiInChar; - } else { - outString = outString + x; - } - - } - return outString; - } - - public static void showData(String s) { - System.out.println(s); - } - - public static void showData(List listString, String header) { - - if (listString != null && listString.size() > 0) { - System.out.println("--------" + header + "------"); - for (String s : listString) { - System.out.println(s); - } - } else { - System.out.println("--------Empty/Null " + header + "------"); - } - } - /* Validation tests for both Windows & Mac OS */ private static String commonValidate(String argName) { if (argName.length() == 0) { @@ -126,8 +55,7 @@ } final char lastChar = widgetName.charAt(widgetName.length() - 1); // trailing or beginning space is not valid in filenames for Widget name - if ((Character.isWhitespace(widgetName.charAt(0)) || Character - .isWhitespace(lastChar))) { + if ((Character.isWhitespace(widgetName.charAt(0)) || Character.isWhitespace(lastChar))) { return ("Invalid Widget name. Beginning or trailing spaces are not allowed"); } @@ -168,19 +96,4 @@ return null; } - - public static String toProjectName(String widgetId) { - if (widgetId == null || widgetId.trim().length() == 0) { - return ""; - } - StringBuilder builder = new StringBuilder(); - for (char c : widgetId.trim().toCharArray()) { - if (Character.isJavaIdentifierPart(c)) { - builder.append(c); - } else { - builder.append("_"); - } - } - return builder.toString(); - } } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/ArchivedProject.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/ArchivedProject.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/ArchivedProject.java Thu Sep 02 10:50:38 2010 -0700 @@ -24,19 +24,15 @@ import java.io.InputStreamReader; import java.net.URI; import java.util.List; -import java.util.zip.ZipEntry; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages; import org.eclipse.ui.internal.wizards.datatransfer.ILeveledImportStructureProvider; -import org.eclipse.ui.internal.wizards.datatransfer.TarEntry; import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.symbian.tools.wrttools.util.CoreUtil; import org.symbian.tools.wrttools.util.ProjectUtils; @@ -102,15 +98,7 @@ } } else { InputStream stream = provider.getContents(infoPlist); - if (stream == null) { - if (dotProject instanceof ZipEntry) { - IPath path = new Path(((ZipEntry) dotProject).getName()); - projectName = path.segment(path.segmentCount() - 2); - } else if (dotProject instanceof TarEntry) { - IPath path = new Path(((TarEntry) dotProject).getName()); - projectName = path.segment(path.segmentCount() - 2); - } - } else { + if (stream != null) { String manifest = CoreUtil.read(new BufferedReader(new InputStreamReader(stream))); projectName = CoreUtil.getApplicationName(manifest); } diff -r 2973198ae2a9 -r 109da596fa9d plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/WrtProjectLocationWizardPage.java --- a/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/WrtProjectLocationWizardPage.java Wed Sep 01 16:59:08 2010 -0700 +++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/projectimport/WrtProjectLocationWizardPage.java Thu Sep 02 10:50:38 2010 -0700 @@ -52,7 +52,6 @@ import org.eclipse.jface.viewers.CheckboxTreeViewer; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; @@ -74,12 +73,8 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.dialogs.IOverwriteQuery; -import org.eclipse.ui.dialogs.WorkingSetGroup; import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; import org.eclipse.ui.internal.ide.StatusUtil; import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileManipulations; @@ -96,223 +91,191 @@ import org.symbian.tools.wrttools.util.ProjectUtils; @SuppressWarnings({ "restriction", "unchecked", "rawtypes" }) -public class WrtProjectLocationWizardPage extends WizardPage implements - IOverwriteQuery { +public class WrtProjectLocationWizardPage extends WizardPage implements IOverwriteQuery { - /** - * @since 3.5 - * - */ - private final class ProjectLabelProvider extends LabelProvider implements - IColorProvider { + /** + * @since 3.5 + * + */ + private final class ProjectLabelProvider extends LabelProvider implements IColorProvider { - public Color getBackground(Object element) { - return null; - } + public Color getBackground(Object element) { + return null; + } - public Color getForeground(Object element) { - ProjectRecord projectRecord = (ProjectRecord) element; + public Color getForeground(Object element) { + ProjectRecord projectRecord = (ProjectRecord) element; if (projectRecord.hasConflicts()) { return getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY); } - return null; - } + return null; + } - public String getText(Object element) { - return ((ProjectRecord) element).getProjectLabel(); - } - } + public String getText(Object element) { + return ((ProjectRecord) element).getProjectLabel(); + } + } // constant from WizardArchiveFileResourceImportPage1 private static final String[] FILE_IMPORT_MASK = { "*.zip;*.tar;*.tar.gz;*.tgz;*.wgz", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$ - /** - * The name of the folder containing metadata information for the workspace. - */ - public static final String METADATA_FOLDER = ".metadata"; //$NON-NLS-1$ + /** + * The name of the folder containing metadata information for the workspace. + */ + public static final String METADATA_FOLDER = ".metadata"; //$NON-NLS-1$ - // Keep track of the archive that we browsed to last time - // the wizard was invoked. - private static String previouslyBrowsedArchive = ""; //$NON-NLS-1$ + // Keep track of the archive that we browsed to last time + // the wizard was invoked. + private static String previouslyBrowsedArchive = ""; //$NON-NLS-1$ - // Keep track of the directory that we browsed to last time - // the wizard was invoked. - private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$ + // Keep track of the directory that we browsed to last time + // the wizard was invoked. + private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$ - private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$ + private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$ - private Text archivePathField; + private Text archivePathField; - private Button browseArchivesButton; + private Button browseArchivesButton; - private Button browseDirectoriesButton; + private Button browseDirectoriesButton; List createdProjects; - private IStructuredSelection currentSelection; - - private Text directoryPathField; - - // The initial path to set - private String initialPath; + private Text directoryPathField; - // The last time that the file or folder at the selected path was modified - // to mimize searches - private long lastModified; + // The last time that the file or folder at the selected path was modified + // to mimize searches + private long lastModified; - // The last selected path to minimize searches - private String lastPath; + // The last selected path to minimize searches + private String lastPath; - private Button projectFromArchiveRadio; + private Button projectFromArchiveRadio; - private Button projectFromDirectoryRadio; + private Button projectFromDirectoryRadio; - private CheckboxTreeViewer projectsList; - private ProjectRecord[] selectedProjects = new ProjectRecord[0]; + private CheckboxTreeViewer projectsList; + private ProjectRecord[] selectedProjects = new ProjectRecord[0]; - /** - * The import structure provider. - * - * @since 3.4 - */ - private ILeveledImportStructureProvider structureProvider; + /** + * The import structure provider. + * + * @since 3.4 + */ + private ILeveledImportStructureProvider structureProvider; - private WorkingSetGroup workingSetGroup; - - private IProject[] wsProjects; + private IProject[] wsProjects; public WrtProjectLocationWizardPage() { super("projectlocation", "Import WRT Projects", null); setDescription("Import existing WRT project created in any IDEs"); - } - - private void addToWorkingSets() { + } - IWorkingSet[] selectedWorkingSets = workingSetGroup - .getSelectedWorkingSets(); - if (selectedWorkingSets == null || selectedWorkingSets.length == 0) { - return; // no Working set is selected + private void archiveRadioSelected() { + if (projectFromArchiveRadio.getSelection()) { + directoryPathField.setEnabled(false); + browseDirectoriesButton.setEnabled(false); + archivePathField.setEnabled(true); + browseArchivesButton.setEnabled(true); + updateProjectsList(archivePathField.getText()); + archivePathField.setFocus(); } - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() - .getWorkingSetManager(); - for (Iterator i = createdProjects.iterator(); i.hasNext();) { - IProject project = (IProject) i.next(); - workingSetManager.addToWorkingSets(project, selectedWorkingSets); - } - } + } + + public List getCreatedProjects() { + return createdProjects; + } - private void archiveRadioSelected() { - if (projectFromArchiveRadio.getSelection()) { - directoryPathField.setEnabled(false); - browseDirectoriesButton.setEnabled(false); - archivePathField.setEnabled(true); - browseArchivesButton.setEnabled(true); - updateProjectsList(archivePathField.getText()); - archivePathField.setFocus(); - } - } + /** + * Collect the list of .project files that are under directory into files. + * + * @param files + * @param directory + * @param directoriesVisited + * Set of canonical paths of directories, used as recursion guard + * @param monitor + * The monitor to report to + * @return boolean true if the operation was completed. + */ + private boolean collectProjectFilesFromDirectory(Collection files, File directory, Set directoriesVisited, + IProgressMonitor monitor) { - public List getCreatedProjects() { - return createdProjects; - } - - /** - * Collect the list of .project files that are under directory into files. - * - * @param files - * @param directory - * @param directoriesVisited - * Set of canonical paths of directories, used as recursion guard - * @param monitor - * The monitor to report to - * @return boolean true if the operation was completed. - */ - private boolean collectProjectFilesFromDirectory(Collection files, - File directory, Set directoriesVisited, IProgressMonitor monitor) { - - if (monitor.isCanceled()) { - return false; - } - monitor.subTask(NLS.bind( - DataTransferMessages.WizardProjectsImportPage_CheckingMessage, - directory.getPath())); - File[] contents = directory.listFiles(); - if (contents == null) { + if (monitor.isCanceled()) { + return false; + } + monitor.subTask(NLS.bind(DataTransferMessages.WizardProjectsImportPage_CheckingMessage, directory.getPath())); + File[] contents = directory.listFiles(); + if (contents == null) { return false; } - // Initialize recursion guard for recursive symbolic links - if (directoriesVisited == null) { - directoriesVisited = new HashSet(); - try { - directoriesVisited.add(directory.getCanonicalPath()); - } catch (IOException exception) { - StatusManager.getManager().handle( - StatusUtil.newStatus(IStatus.ERROR, exception - .getLocalizedMessage(), exception)); - } - } + // Initialize recursion guard for recursive symbolic links + if (directoriesVisited == null) { + directoriesVisited = new HashSet(); + try { + directoriesVisited.add(directory.getCanonicalPath()); + } catch (IOException exception) { + StatusManager.getManager().handle( + StatusUtil.newStatus(IStatus.ERROR, exception.getLocalizedMessage(), exception)); + } + } + + File dotProjectFile = ProjectUtils.isWrtProject(contents); - - File dotProjectFile = ProjectUtils.isWrtProject(contents); - - if (dotProjectFile != null) { - files.add(dotProjectFile); - // don't search sub-directories since we can't have nested - // projects - return true; - } - // no project description found, so recurse into sub-directories - for (int i = 0; i < contents.length; i++) { - if (contents[i].isDirectory()) { - if (!contents[i].getName().equals(METADATA_FOLDER)) { - try { - String canonicalPath = contents[i].getCanonicalPath(); - if (!directoriesVisited.add(canonicalPath)) { - // already been here --> do not recurse - continue; - } - } catch (IOException exception) { - StatusManager.getManager().handle( - StatusUtil.newStatus(IStatus.ERROR, exception - .getLocalizedMessage(), exception)); + if (dotProjectFile != null) { + files.add(dotProjectFile); + // don't search sub-directories since we can't have nested + // projects + return true; + } + // no project description found, so recurse into sub-directories + for (int i = 0; i < contents.length; i++) { + if (contents[i].isDirectory()) { + if (!contents[i].getName().equals(METADATA_FOLDER)) { + try { + String canonicalPath = contents[i].getCanonicalPath(); + if (!directoriesVisited.add(canonicalPath)) { + // already been here --> do not recurse + continue; + } + } catch (IOException exception) { + StatusManager.getManager().handle( + StatusUtil.newStatus(IStatus.ERROR, exception.getLocalizedMessage(), exception)); - } - collectProjectFilesFromDirectory(files, contents[i], - directoriesVisited, monitor); - } - } - } - return true; - } + } + collectProjectFilesFromDirectory(files, contents[i], directoriesVisited, monitor); + } + } + } + return true; + } - /** - * Collect the list of .project files that are under directory into files. - * - * @param files - * @param monitor - * The monitor to report to - * @return boolean true if the operation was completed. - */ - private boolean collectProjectFilesFromProvider(Collection files, - Object entry, int level, IProgressMonitor monitor) { + /** + * Collect the list of .project files that are under directory into files. + * + * @param files + * @param monitor + * The monitor to report to + * @return boolean true if the operation was completed. + */ + private boolean collectProjectFilesFromProvider(Collection files, Object entry, int level, IProgressMonitor monitor) { - if (monitor.isCanceled()) { - return false; - } - monitor.subTask(NLS.bind( - DataTransferMessages.WizardProjectsImportPage_CheckingMessage, - structureProvider.getLabel(entry))); - List children = structureProvider.getChildren(entry); - if (children == null) { - children = new ArrayList(1); - } - Iterator childrenEnum = children.iterator(); - ProjectRecord projectRecord = null; + if (monitor.isCanceled()) { + return false; + } + monitor.subTask(NLS.bind(DataTransferMessages.WizardProjectsImportPage_CheckingMessage, + structureProvider.getLabel(entry))); + List children = structureProvider.getChildren(entry); + if (children == null) { + children = new ArrayList(1); + } + Iterator childrenEnum = children.iterator(); + ProjectRecord projectRecord = null; Object infoPlist = null; Object dotProject = null; - while (childrenEnum.hasNext()) { - Object child = childrenEnum.next(); + while (childrenEnum.hasNext()) { + Object child = childrenEnum.next(); String elementLabel = structureProvider.getLabel(child); if (structureProvider.isFolder(child)) { collectProjectFilesFromProvider(files, child, level + 1, monitor); @@ -321,1025 +284,929 @@ } else if (elementLabel.equalsIgnoreCase(CoreUtil.METADATA_FILE)) { infoPlist = child; } - } + } if (infoPlist != null) { projectRecord = new ArchivedProject(infoPlist, dotProject, entry, level, structureProvider); files.add(projectRecord); } - return true; - } + return true; + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets - * .Composite) - */ - public void createControl(Composite parent) { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets + * .Composite) + */ + public void createControl(Composite parent) { - initializeDialogUnits(parent); + initializeDialogUnits(parent); - Composite workArea = new Composite(parent, SWT.NONE); - setControl(workArea); + Composite workArea = new Composite(parent, SWT.NONE); + setControl(workArea); - workArea.setLayout(new GridLayout()); - workArea.setLayoutData(new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); + workArea.setLayout(new GridLayout()); + workArea.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); - createProjectsRoot(workArea); - createProjectsList(workArea); - createWorkingSetGroup(workArea); - restoreWidgetValues(); - Dialog.applyDialogFont(workArea); - - updateProjectsList(directoryPathField.getText().trim()); - } + createProjectsRoot(workArea); + createProjectsList(workArea); + restoreWidgetValues(); + Dialog.applyDialogFont(workArea); + + updateProjectsList(directoryPathField.getText().trim()); + } - /** - * Create the project described in record. If it is successful return true. - * - * @param record - * @return boolean true if successful - * @throws InterruptedException - */ - private boolean createExistingProject(final ProjectRecord record, - IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask(MessageFormat.format("Creating {0}", record - .getProjectName()), IProgressMonitor.UNKNOWN); + /** + * Create the project described in record. If it is successful return true. + * + * @param record + * @return boolean true if successful + * @throws InterruptedException + */ + private boolean createExistingProject(final ProjectRecord record, IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + monitor.beginTask(MessageFormat.format("Creating {0}", record.getProjectName()), IProgressMonitor.UNKNOWN); - try { - IProject project = ProjectUtils.createWrtProject(record - .getProjectName(), null, - new SubProgressMonitor(monitor, 10)); - createdProjects.add(project); + try { + IProject project = ProjectUtils.createWrtProject(record.getProjectName(), null, new SubProgressMonitor( + monitor, 10)); + createdProjects.add(project); ImportOperation operation = record.getImportOperation(project, structureProvider, this); if (operation != null) { operation.setContext(getShell()); operation.run(monitor); } - return true; - } catch (CoreException e) { - Activator.log(e); - return false; - } finally { - monitor.done(); - } - } + return true; + } catch (CoreException e) { + Activator.log(e); + return false; + } finally { + monitor.done(); + } + } - /** - * Create the selected projects - * - * @return boolean true if all project creations were - * successful. - */ - public boolean createProjects() { - saveWidgetValues(); + /** + * Create the selected projects + * + * @return boolean true if all project creations were + * successful. + */ + public boolean createProjects() { + saveWidgetValues(); - final Object[] selected = projectsList.getCheckedElements(); - createdProjects = new ArrayList(); - WorkspaceModifyOperation op = new WorkspaceModifyOperation() { - protected void execute(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask("", selected.length); - if (monitor.isCanceled()) { - throw new OperationCanceledException(); - } - for (int i = 0; i < selected.length; i++) { - createExistingProject((ProjectRecord) selected[i], - new SubProgressMonitor(monitor, 1)); - } - } finally { - monitor.done(); - } - } - }; - // run the new project creation operation - try { - getContainer().run(true, true, op); - } catch (InterruptedException e) { - return false; - } catch (InvocationTargetException e) { - // one of the steps resulted in a core exception - Throwable t = e.getTargetException(); - String message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage; - IStatus status; - if (t instanceof CoreException) { - status = ((CoreException) t).getStatus(); - } else { - status = new Status(IStatus.ERROR, - Activator.PLUGIN_ID, 1, message, t); - } - ErrorDialog.openError(getShell(), message, null, status); - return false; - } - ArchiveFileManipulations.closeStructureProvider(structureProvider, - getShell()); + final Object[] selected = projectsList.getCheckedElements(); + createdProjects = new ArrayList(); + WorkspaceModifyOperation op = new WorkspaceModifyOperation() { + protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + monitor.beginTask("", selected.length); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + for (int i = 0; i < selected.length; i++) { + createExistingProject((ProjectRecord) selected[i], new SubProgressMonitor(monitor, 1)); + } + } finally { + monitor.done(); + } + } + }; + // run the new project creation operation + try { + getContainer().run(true, true, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + // one of the steps resulted in a core exception + Throwable t = e.getTargetException(); + String message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage; + IStatus status; + if (t instanceof CoreException) { + status = ((CoreException) t).getStatus(); + } else { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, message, t); + } + ErrorDialog.openError(getShell(), message, null, status); + return false; + } + ArchiveFileManipulations.closeStructureProvider(structureProvider, getShell()); - // Adds the projects to the working sets - addToWorkingSets(); - - return true; - } + return true; + } - /** - * Create the checkbox list for the found projects. - * - * @param workArea - */ - private void createProjectsList(Composite workArea) { + /** + * Create the checkbox list for the found projects. + * + * @param workArea + */ + private void createProjectsList(Composite workArea) { + + Label title = new Label(workArea, SWT.NONE); + title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle); - Label title = new Label(workArea, SWT.NONE); - title - .setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle); + Composite listComposite = new Composite(workArea, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginWidth = 0; + layout.makeColumnsEqualWidth = false; + listComposite.setLayout(layout); - Composite listComposite = new Composite(workArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - layout.makeColumnsEqualWidth = false; - listComposite.setLayout(layout); + listComposite + .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); - listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); + projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25); + gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10); + projectsList.getControl().setLayoutData(gridData); + projectsList.setContentProvider(new ITreeContentProvider() { - projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - gridData.widthHint = new PixelConverter(projectsList.getControl()) - .convertWidthInCharsToPixels(25); - gridData.heightHint = new PixelConverter(projectsList.getControl()) - .convertHeightInCharsToPixels(10); - projectsList.getControl().setLayoutData(gridData); - projectsList.setContentProvider(new ITreeContentProvider() { + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + + } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java + * .lang.Object) + */ + public Object[] getChildren(Object parentElement) { + return null; + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java - * .lang.Object) - */ - public Object[] getChildren(Object parentElement) { - return null; - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.IStructuredContentProvider#getElements + * (java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + return getProjectRecords(); + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.IStructuredContentProvider#getElements - * (java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - return getProjectRecords(); - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java + * .lang.Object) + */ + public Object getParent(Object element) { + return null; + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java - * .lang.Object) - */ - public Object getParent(Object element) { - return null; - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java + * .lang.Object) + */ + public boolean hasChildren(Object element) { + return false; + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java - * .lang.Object) - */ - public boolean hasChildren(Object element) { - return false; - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse + * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + }); + + projectsList.setLabelProvider(new ProjectLabelProvider()); - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse - * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, - Object newInput) { - } - - }); - - projectsList.setLabelProvider(new ProjectLabelProvider()); + projectsList.addCheckStateListener(new ICheckStateListener() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged + * (org.eclipse.jface.viewers.CheckStateChangedEvent) + */ + public void checkStateChanged(CheckStateChangedEvent event) { + ProjectRecord element = (ProjectRecord) event.getElement(); + if (element.hasConflicts()) { + projectsList.setChecked(element, false); + } + setPageComplete(projectsList.getCheckedElements().length > 0); + } + }); - projectsList.addCheckStateListener(new ICheckStateListener() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged - * (org.eclipse.jface.viewers.CheckStateChangedEvent) - */ - public void checkStateChanged(CheckStateChangedEvent event) { - ProjectRecord element = (ProjectRecord) event.getElement(); - if (element.hasConflicts()) { - projectsList.setChecked(element, false); - } - setPageComplete(projectsList.getCheckedElements().length > 0); - } - }); + projectsList.setInput(this); + projectsList.setComparator(new ViewerComparator()); + createSelectionButtons(listComposite); + } - projectsList.setInput(this); - projectsList.setComparator(new ViewerComparator()); - createSelectionButtons(listComposite); - } + /** + * Create the area where you select the root directory for the projects. + * + * @param workArea + * Composite + */ + private void createProjectsRoot(Composite workArea) { - /** - * Create the area where you select the root directory for the projects. - * - * @param workArea - * Composite - */ - private void createProjectsRoot(Composite workArea) { + // project specification group + Composite projectGroup = new Composite(workArea, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + layout.makeColumnsEqualWidth = false; + layout.marginWidth = 0; + projectGroup.setLayout(layout); + projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // project specification group - Composite projectGroup = new Composite(workArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - projectGroup.setLayout(layout); - projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // new project from directory radio button + projectFromDirectoryRadio = new Button(projectGroup, SWT.RADIO); + projectFromDirectoryRadio.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle); - // new project from directory radio button - projectFromDirectoryRadio = new Button(projectGroup, SWT.RADIO); - projectFromDirectoryRadio - .setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle); + // project location entry field + this.directoryPathField = new Text(projectGroup, SWT.BORDER); + + GridData directoryPathData = new GridData(SWT.FILL, SWT.NONE, true, false); + directoryPathData.widthHint = new PixelConverter(directoryPathField).convertWidthInCharsToPixels(25); + directoryPathField.setLayoutData(directoryPathData); + + directoryPathField.setText(ProjectUtils.getDefaultAptanaLocation()); - // project location entry field - this.directoryPathField = new Text(projectGroup, SWT.BORDER); + // browse button + browseDirectoriesButton = new Button(projectGroup, SWT.PUSH); + browseDirectoriesButton.setText(DataTransferMessages.DataTransfer_browse); + setButtonLayoutData(browseDirectoriesButton); - GridData directoryPathData = new GridData(SWT.FILL, SWT.NONE, true, - false); - directoryPathData.widthHint = new PixelConverter(directoryPathField) - .convertWidthInCharsToPixels(25); - directoryPathField.setLayoutData(directoryPathData); + // new project from archive radio button + projectFromArchiveRadio = new Button(projectGroup, SWT.RADIO); + projectFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle); - directoryPathField.setText(ProjectUtils.getDefaultAptanaLocation()); - - // browse button - browseDirectoriesButton = new Button(projectGroup, SWT.PUSH); - browseDirectoriesButton - .setText(DataTransferMessages.DataTransfer_browse); - setButtonLayoutData(browseDirectoriesButton); + // project location entry field + archivePathField = new Text(projectGroup, SWT.BORDER); - // new project from archive radio button - projectFromArchiveRadio = new Button(projectGroup, SWT.RADIO); - projectFromArchiveRadio - .setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle); + GridData archivePathData = new GridData(SWT.FILL, SWT.NONE, true, false); + archivePathData.widthHint = new PixelConverter(archivePathField).convertWidthInCharsToPixels(25); + archivePathField.setLayoutData(archivePathData); // browse button + browseArchivesButton = new Button(projectGroup, SWT.PUSH); + browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse); + setButtonLayoutData(browseArchivesButton); + + projectFromDirectoryRadio.setSelection(true); + archivePathField.setEnabled(false); + browseArchivesButton.setEnabled(false); - // project location entry field - archivePathField = new Text(projectGroup, SWT.BORDER); + browseDirectoriesButton.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.SelectionAdapter#widgetS + * elected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + handleLocationDirectoryButtonPressed(); + } - GridData archivePathData = new GridData(SWT.FILL, SWT.NONE, true, false); - archivePathData.widthHint = new PixelConverter(archivePathField) - .convertWidthInCharsToPixels(25); - archivePathField.setLayoutData(archivePathData); // browse button - browseArchivesButton = new Button(projectGroup, SWT.PUSH); - browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse); - setButtonLayoutData(browseArchivesButton); - - projectFromDirectoryRadio.setSelection(true); - archivePathField.setEnabled(false); - browseArchivesButton.setEnabled(false); + }); - browseDirectoriesButton.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.SelectionAdapter#widgetS - * elected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - handleLocationDirectoryButtonPressed(); - } + browseArchivesButton.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + handleLocationArchiveButtonPressed(); + } - }); + }); + + directoryPathField.addTraverseListener(new TraverseListener() { - browseArchivesButton.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - handleLocationArchiveButtonPressed(); - } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse + * .swt.events.TraverseEvent) + */ + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_RETURN) { + e.doit = false; + updateProjectsList(directoryPathField.getText().trim()); + } + } - }); - - directoryPathField.addTraverseListener(new TraverseListener() { + }); - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse - * .swt.events.TraverseEvent) - */ - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_RETURN) { - e.doit = false; - updateProjectsList(directoryPathField.getText().trim()); - } - } + directoryPathField.addFocusListener(new FocusAdapter() { - }); + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt + * .events.FocusEvent) + */ + public void focusLost(org.eclipse.swt.events.FocusEvent e) { + updateProjectsList(directoryPathField.getText().trim()); + } - directoryPathField.addFocusListener(new FocusAdapter() { + }); + + archivePathField.addTraverseListener(new TraverseListener() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt - * .events.FocusEvent) - */ - public void focusLost(org.eclipse.swt.events.FocusEvent e) { - updateProjectsList(directoryPathField.getText().trim()); - } - - }); - - archivePathField.addTraverseListener(new TraverseListener() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse + * .swt.events.TraverseEvent) + */ + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_RETURN) { + e.doit = false; + updateProjectsList(archivePathField.getText().trim()); + } + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse - * .swt.events.TraverseEvent) - */ - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_RETURN) { - e.doit = false; - updateProjectsList(archivePathField.getText().trim()); - } - } + }); - }); + archivePathField.addFocusListener(new FocusAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt + * .events.FocusEvent) + */ + public void focusLost(org.eclipse.swt.events.FocusEvent e) { + updateProjectsList(archivePathField.getText().trim()); + } + }); - archivePathField.addFocusListener(new FocusAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt - * .events.FocusEvent) - */ - public void focusLost(org.eclipse.swt.events.FocusEvent e) { - updateProjectsList(archivePathField.getText().trim()); - } - }); - - projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - directoryRadioSelected(); - } - }); + projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + directoryRadioSelected(); + } + }); - projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - archiveRadioSelected(); - } - }); - } + projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + archiveRadioSelected(); + } + }); + } - /** - * Create the selection buttons in the listComposite. - * - * @param listComposite - */ - private void createSelectionButtons(Composite listComposite) { - Composite buttonsComposite = new Composite(listComposite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - buttonsComposite.setLayout(layout); + /** + * Create the selection buttons in the listComposite. + * + * @param listComposite + */ + private void createSelectionButtons(Composite listComposite) { + Composite buttonsComposite = new Composite(listComposite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + buttonsComposite.setLayout(layout); - buttonsComposite.setLayoutData(new GridData( - GridData.VERTICAL_ALIGN_BEGINNING)); + buttonsComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - Button selectAll = new Button(buttonsComposite, SWT.PUSH); - selectAll.setText(DataTransferMessages.DataTransfer_selectAll); - selectAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - for (int i = 0; i < selectedProjects.length; i++) { + Button selectAll = new Button(buttonsComposite, SWT.PUSH); + selectAll.setText(DataTransferMessages.DataTransfer_selectAll); + selectAll.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + for (int i = 0; i < selectedProjects.length; i++) { if (selectedProjects[i].hasConflicts()) { projectsList.setChecked(selectedProjects[i], false); } else { projectsList.setChecked(selectedProjects[i], true); } - } - setPageComplete(projectsList.getCheckedElements().length > 0); - } - }); - Dialog.applyDialogFont(selectAll); - setButtonLayoutData(selectAll); + } + setPageComplete(projectsList.getCheckedElements().length > 0); + } + }); + Dialog.applyDialogFont(selectAll); + setButtonLayoutData(selectAll); - Button deselectAll = new Button(buttonsComposite, SWT.PUSH); - deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll); - deselectAll.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { + Button deselectAll = new Button(buttonsComposite, SWT.PUSH); + deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll); + deselectAll.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { - projectsList.setCheckedElements(new Object[0]); - setPageComplete(false); - } - }); - Dialog.applyDialogFont(deselectAll); - setButtonLayoutData(deselectAll); + projectsList.setCheckedElements(new Object[0]); + setPageComplete(false); + } + }); + Dialog.applyDialogFont(deselectAll); + setButtonLayoutData(deselectAll); - Button refresh = new Button(buttonsComposite, SWT.PUSH); - refresh.setText(DataTransferMessages.DataTransfer_refresh); - refresh.addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - if (projectFromDirectoryRadio.getSelection()) { - updateProjectsList(directoryPathField.getText().trim()); - } else { - updateProjectsList(archivePathField.getText().trim()); - } - } - }); - Dialog.applyDialogFont(refresh); - setButtonLayoutData(refresh); - } + Button refresh = new Button(buttonsComposite, SWT.PUSH); + refresh.setText(DataTransferMessages.DataTransfer_refresh); + refresh.addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + if (projectFromDirectoryRadio.getSelection()) { + updateProjectsList(directoryPathField.getText().trim()); + } else { + updateProjectsList(archivePathField.getText().trim()); + } + } + }); + Dialog.applyDialogFont(refresh); + setButtonLayoutData(refresh); + } - /** - * @param workArea - */ - private void createWorkingSetGroup(Composite workArea) { - String[] workingSetIds = new String[] { - "org.eclipse.ui.resourceWorkingSetPage", //$NON-NLS-1$ - "org.eclipse.jdt.ui.JavaWorkingSetPage" }; //$NON-NLS-1$ - workingSetGroup = new WorkingSetGroup(workArea, currentSelection, - workingSetIds); - } + private void directoryRadioSelected() { + if (projectFromDirectoryRadio.getSelection()) { + directoryPathField.setEnabled(true); + browseDirectoriesButton.setEnabled(true); + archivePathField.setEnabled(false); + browseArchivesButton.setEnabled(false); + updateProjectsList(directoryPathField.getText()); + directoryPathField.setFocus(); + } + } - private void directoryRadioSelected() { - if (projectFromDirectoryRadio.getSelection()) { - directoryPathField.setEnabled(true); - browseDirectoriesButton.setEnabled(true); - archivePathField.setEnabled(false); - browseArchivesButton.setEnabled(false); - updateProjectsList(directoryPathField.getText()); - directoryPathField.setFocus(); - } - } + /** + * Display an error dialog with the specified message. + * + * @param message + * the error message + */ + protected void displayErrorDialog(String message) { + MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message, SWT.SHEET); + } - /** - * Display an error dialog with the specified message. - * - * @param message - * the error message - */ - protected void displayErrorDialog(String message) { - MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), - getErrorDialogTitle(), message, SWT.SHEET); - } - - /** - * Get the title for an error dialog. Subclasses should override. - */ - protected String getErrorDialogTitle() { - return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle; - } + /** + * Get the title for an error dialog. Subclasses should override. + */ + protected String getErrorDialogTitle() { + return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle; + } - /** - * Method used for test suite. - * - * @return Button the Import from Directory RadioButton - */ - public Button getProjectFromDirectoryRadio() { - return projectFromDirectoryRadio; - } + /** + * Method used for test suite. + * + * @return Button the Import from Directory RadioButton + */ + public Button getProjectFromDirectoryRadio() { + return projectFromDirectoryRadio; + } - /** - * Get the array of project records that can be imported from the source - * workspace or archive, selected by the user. If a project with the same - * name exists in both the source workspace and the current workspace, then - * the hasConflicts flag would be set on that project record. - * - * Method declared public for test suite. - * - * @return ProjectRecord[] array of projects that can be imported into the - * workspace - */ - public ProjectRecord[] getProjectRecords() { - List projectRecords = new ArrayList(); - for (int i = 0; i < selectedProjects.length; i++) { + /** + * Get the array of project records that can be imported from the source + * workspace or archive, selected by the user. If a project with the same + * name exists in both the source workspace and the current workspace, then + * the hasConflicts flag would be set on that project record. + * + * Method declared public for test suite. + * + * @return ProjectRecord[] array of projects that can be imported into the + * workspace + */ + public ProjectRecord[] getProjectRecords() { + List projectRecords = new ArrayList(); + for (int i = 0; i < selectedProjects.length; i++) { if (isProjectInWorkspace(selectedProjects[i].getProjectName())) { selectedProjects[i].setHasConflicts(true); - } - projectRecords.add(selectedProjects[i]); - } - return (ProjectRecord[]) projectRecords - .toArray(new ProjectRecord[projectRecords.size()]); - } + } + projectRecords.add(selectedProjects[i]); + } + return (ProjectRecord[]) projectRecords.toArray(new ProjectRecord[projectRecords.size()]); + } + + /** + * Retrieve all the projects in the current workspace. + * + * @return IProject[] array of IProject in the current workspace + */ + private IProject[] getProjectsInWorkspace() { + if (wsProjects == null) { + wsProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + } + return wsProjects; + } - /** - * Retrieve all the projects in the current workspace. - * - * @return IProject[] array of IProject in the current workspace - */ - private IProject[] getProjectsInWorkspace() { - if (wsProjects == null) { - wsProjects = ResourcesPlugin.getWorkspace().getRoot() - .getProjects(); - } - return wsProjects; - } + /** + * Method used for test suite. + * + * @return CheckboxTreeViewer the viewer containing all the projects found + */ + public CheckboxTreeViewer getProjectsList() { + return projectsList; + } - /** - * Method used for test suite. - * - * @return CheckboxTreeViewer the viewer containing all the projects found - */ - public CheckboxTreeViewer getProjectsList() { - return projectsList; - } - - /** - * Answer a handle to the zip file currently specified as being the source. - * Return null if this file does not exist or is not of valid format. - */ - private TarFile getSpecifiedTarSourceFile(String fileName) { - if (fileName.length() == 0) { - return null; - } + /** + * Answer a handle to the zip file currently specified as being the source. + * Return null if this file does not exist or is not of valid format. + */ + private TarFile getSpecifiedTarSourceFile(String fileName) { + if (fileName.length() == 0) { + return null; + } - try { - return new TarFile(fileName); - } catch (TarException e) { - displayErrorDialog(DataTransferMessages.TarImport_badFormat); - } catch (IOException e) { - displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead); - } + try { + return new TarFile(fileName); + } catch (TarException e) { + displayErrorDialog(DataTransferMessages.TarImport_badFormat); + } catch (IOException e) { + displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead); + } - archivePathField.setFocus(); - return null; - } + archivePathField.setFocus(); + return null; + } - /** - * Answer a handle to the zip file currently specified as being the source. - * Return null if this file does not exist or is not of valid format. - */ - private ZipFile getSpecifiedZipSourceFile(String fileName) { - if (fileName.length() == 0) { - return null; - } + /** + * Answer a handle to the zip file currently specified as being the source. + * Return null if this file does not exist or is not of valid format. + */ + private ZipFile getSpecifiedZipSourceFile(String fileName) { + if (fileName.length() == 0) { + return null; + } - try { - return new ZipFile(fileName); - } catch (ZipException e) { - displayErrorDialog(DataTransferMessages.ZipImport_badFormat); - } catch (IOException e) { - displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead); - } + try { + return new ZipFile(fileName); + } catch (ZipException e) { + displayErrorDialog(DataTransferMessages.ZipImport_badFormat); + } catch (IOException e) { + displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead); + } - archivePathField.setFocus(); - return null; - } + archivePathField.setFocus(); + return null; + } - /** - * The browse button has been selected. Select the location. - */ - protected void handleLocationArchiveButtonPressed() { + /** + * The browse button has been selected. Select the location. + */ + protected void handleLocationArchiveButtonPressed() { - FileDialog dialog = new FileDialog(archivePathField.getShell(), - SWT.SHEET); - dialog.setFilterExtensions(FILE_IMPORT_MASK); - dialog - .setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle); + FileDialog dialog = new FileDialog(archivePathField.getShell(), SWT.SHEET); + dialog.setFilterExtensions(FILE_IMPORT_MASK); + dialog.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle); - String fileName = archivePathField.getText().trim(); - if (fileName.length() == 0) { - fileName = previouslyBrowsedArchive; - } + String fileName = archivePathField.getText().trim(); + if (fileName.length() == 0) { + fileName = previouslyBrowsedArchive; + } - if (fileName.length() == 0) { - dialog.setFilterPath(ResourcesPlugin.getWorkspace() - .getRoot().getLocation().toOSString()); - } else { - File path = new File(fileName).getParentFile(); - if (path != null && path.exists()) { - dialog.setFilterPath(path.toString()); - } - } + if (fileName.length() == 0) { + dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); + } else { + File path = new File(fileName).getParentFile(); + if (path != null && path.exists()) { + dialog.setFilterPath(path.toString()); + } + } - String selectedArchive = dialog.open(); - if (selectedArchive != null) { - previouslyBrowsedArchive = selectedArchive; - archivePathField.setText(previouslyBrowsedArchive); - updateProjectsList(selectedArchive); - } + String selectedArchive = dialog.open(); + if (selectedArchive != null) { + previouslyBrowsedArchive = selectedArchive; + archivePathField.setText(previouslyBrowsedArchive); + updateProjectsList(selectedArchive); + } - } + } - /** - * The browse button has been selected. Select the location. - */ - protected void handleLocationDirectoryButtonPressed() { + /** + * The browse button has been selected. Select the location. + */ + protected void handleLocationDirectoryButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(directoryPathField - .getShell(), SWT.SHEET); - dialog - .setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle); + DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell(), SWT.SHEET); + dialog.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle); - String dirName = directoryPathField.getText().trim(); - if (dirName.length() == 0) { - dirName = previouslyBrowsedDirectory; - } + String dirName = directoryPathField.getText().trim(); + if (dirName.length() == 0) { + dirName = previouslyBrowsedDirectory; + } - if (dirName.length() == 0) { - dialog.setFilterPath(ResourcesPlugin.getWorkspace() - .getRoot().getLocation().toOSString()); - } else { - File path = new File(dirName); - if (path.exists()) { - dialog.setFilterPath(new Path(dirName).toOSString()); - } - } + if (dirName.length() == 0) { + dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); + } else { + File path = new File(dirName); + if (path.exists()) { + dialog.setFilterPath(new Path(dirName).toOSString()); + } + } - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - previouslyBrowsedDirectory = selectedDirectory; - directoryPathField.setText(previouslyBrowsedDirectory); - updateProjectsList(selectedDirectory); - } + String selectedDirectory = dialog.open(); + if (selectedDirectory != null) { + previouslyBrowsedDirectory = selectedDirectory; + directoryPathField.setText(previouslyBrowsedDirectory); + updateProjectsList(selectedDirectory); + } - } + } - /** - * Determine if the project with the given name is in the current workspace. - * - * @param projectName - * String the project name to check - * @return boolean true if the project with the given name is in this - * workspace - */ - private boolean isProjectInWorkspace(String projectName) { - if (projectName == null) { - return false; - } - IProject[] workspaceProjects = getProjectsInWorkspace(); - for (int i = 0; i < workspaceProjects.length; i++) { - if (projectName.equals(workspaceProjects[i].getName())) { - return true; - } - } - return false; - } + /** + * Determine if the project with the given name is in the current workspace. + * + * @param projectName + * String the project name to check + * @return boolean true if the project with the given name is in this + * workspace + */ + private boolean isProjectInWorkspace(String projectName) { + if (projectName == null) { + return false; + } + IProject[] workspaceProjects = getProjectsInWorkspace(); + for (int i = 0; i < workspaceProjects.length; i++) { + if (projectName.equals(workspaceProjects[i].getName())) { + return true; + } + } + return false; + } - /** - * Performs clean-up if the user cancels the wizard without doing anything - */ - public void performCancel() { - ArchiveFileManipulations.closeStructureProvider(structureProvider, - getShell()); - } + /** + * Performs clean-up if the user cancels the wizard without doing anything + */ + public void performCancel() { + ArchiveFileManipulations.closeStructureProvider(structureProvider, getShell()); + } - /** - * The WizardDataTransfer implementation of this - * IOverwriteQuery method asks the user whether the existing - * resource at the given path should be overwritten. - * - * @param pathString - * @return the user's reply: one of "YES", "NO", - * "ALL", or "CANCEL" - */ - public String queryOverwrite(String pathString) { + /** + * The WizardDataTransfer implementation of this + * IOverwriteQuery method asks the user whether the existing + * resource at the given path should be overwritten. + * + * @param pathString + * @return the user's reply: one of "YES", "NO", + * "ALL", or "CANCEL" + */ + public String queryOverwrite(String pathString) { - Path path = new Path(pathString); + Path path = new Path(pathString); if (path.segmentCount() > 1 && ".settings".equals(path.segment(1))) { return NO; } - String messageString; - // Break the message up if there is a file name and a directory - // and there are at least 2 segments. - if (path.getFileExtension() == null || path.segmentCount() < 2) { - messageString = NLS.bind( - IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, - pathString); - } else { - messageString = NLS - .bind( - IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, - path.lastSegment(), path.removeLastSegments(1) - .toOSString()); - } + String messageString; + // Break the message up if there is a file name and a directory + // and there are at least 2 segments. + if (path.getFileExtension() == null || path.segmentCount() < 2) { + messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); + } else { + messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, + path.lastSegment(), path.removeLastSegments(1).toOSString()); + } - final MessageDialog dialog = new MessageDialog(getContainer() - .getShell(), IDEWorkbenchMessages.Question, null, - messageString, MessageDialog.QUESTION, new String[] { - IDialogConstants.YES_LABEL, - IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.NO_LABEL, - IDialogConstants.NO_TO_ALL_LABEL, - IDialogConstants.CANCEL_LABEL }, 0) { - protected int getShellStyle() { - return super.getShellStyle() | SWT.SHEET; - } - }; - String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; - // run in syncExec because callback is from an operation, - // which is probably not running in the UI thread. - getControl().getDisplay().syncExec(new Runnable() { - public void run() { - dialog.open(); - } - }); - return dialog.getReturnCode() < 0 ? CANCEL : response[dialog - .getReturnCode()]; - } + final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, + messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, + IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, + IDialogConstants.CANCEL_LABEL }, 0) { + protected int getShellStyle() { + return super.getShellStyle() | SWT.SHEET; + } + }; + String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; + // run in syncExec because callback is from an operation, + // which is probably not running in the UI thread. + getControl().getDisplay().syncExec(new Runnable() { + public void run() { + dialog.open(); + } + }); + return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; + } - /** - * Use the dialog store to restore widget values to the values that they - * held last time this wizard was used to completion, or alternatively, if - * an initial path is specified, use it to select values. - * - * Method declared public only for use of tests. - */ - public void restoreWidgetValues() { + /** + * Use the dialog store to restore widget values to the values that they + * held last time this wizard was used to completion, or alternatively, if + * an initial path is specified, use it to select values. + * + * Method declared public only for use of tests. + */ + public void restoreWidgetValues() { - // First, check to see if we have resore settings, and - // take care of the checkbox - IDialogSettings settings = getDialogSettings(); + // First, check to see if we have resore settings, and + // take care of the checkbox + IDialogSettings settings = getDialogSettings(); - // Second, check to see if we don't have an initial path, - // and if we do have restore settings. If so, set the - // radio selection properly to restore settings + // Second, check to see if we don't have an initial path, + // and if we do have restore settings. If so, set the + // radio selection properly to restore settings - if (initialPath == null && settings != null) { - // radio selection - boolean archiveSelected = settings - .getBoolean(STORE_ARCHIVE_SELECTED); - projectFromDirectoryRadio.setSelection(!archiveSelected); - projectFromArchiveRadio.setSelection(archiveSelected); - if (archiveSelected) { - archiveRadioSelected(); - } else { - directoryRadioSelected(); - } - } - // Third, if we do have an initial path, set the proper - // path and radio buttons to the initial value. Move - // cursor to the end of the path so user can see the - // most relevant part (directory / archive name) - else if (initialPath != null) { - boolean dir = new File(initialPath).isDirectory(); + if (settings != null) { + // radio selection + boolean archiveSelected = settings.getBoolean(STORE_ARCHIVE_SELECTED); + projectFromDirectoryRadio.setSelection(!archiveSelected); + projectFromArchiveRadio.setSelection(archiveSelected); + if (archiveSelected) { + archiveRadioSelected(); + } else { + directoryRadioSelected(); + } + } + } - projectFromDirectoryRadio.setSelection(dir); - projectFromArchiveRadio.setSelection(!dir); - - if (dir) { - directoryPathField.setText(initialPath); - directoryPathField.setSelection(initialPath.length()); - directoryRadioSelected(); - } else { - archivePathField.setText(initialPath); - archivePathField.setSelection(initialPath.length()); - archiveRadioSelected(); - } - } - } + /** + * Since Finish was pressed, write widget values to the dialog store so that + * they will persist into the next invocation of this wizard page. + * + * Method declared public only for use of tests. + */ + public void saveWidgetValues() { + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio.getSelection()); + } + } - /** - * Since Finish was pressed, write widget values to the dialog store so that - * they will persist into the next invocation of this wizard page. - * - * Method declared public only for use of tests. - */ - public void saveWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio - .getSelection()); - } - } + /* + * (non-Javadoc) Method declared on IDialogPage. Set the focus on path + * fields when page becomes visible. + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible && this.projectFromDirectoryRadio.getSelection()) { + this.directoryPathField.setFocus(); + } + if (visible && this.projectFromArchiveRadio.getSelection()) { + this.archivePathField.setFocus(); + } + } - /* - * (non-Javadoc) Method declared on IDialogPage. Set the focus on path - * fields when page becomes visible. - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible && this.projectFromDirectoryRadio.getSelection()) { - this.directoryPathField.setFocus(); - } - if (visible && this.projectFromArchiveRadio.getSelection()) { - this.archivePathField.setFocus(); - } - } + /** + * Update the list of projects based on path. Method declared public only + * for test suite. + * + * @param path + */ + public void updateProjectsList(final String path) { + // on an empty path empty selectedProjects + if (path == null || path.length() == 0) { + setMessage("Select a directory to search for existing WRT projects."); + selectedProjects = new ProjectRecord[0]; + projectsList.refresh(true); + projectsList.setCheckedElements(selectedProjects); + setPageComplete(projectsList.getCheckedElements().length > 0); + lastPath = path; + return; + } - /** - * Update the list of projects based on path. Method declared public only - * for test suite. - * - * @param path - */ - public void updateProjectsList(final String path) { - // on an empty path empty selectedProjects - if (path == null || path.length() == 0) { - setMessage("Select a directory to search for existing WRT projects."); - selectedProjects = new ProjectRecord[0]; - projectsList.refresh(true); - projectsList.setCheckedElements(selectedProjects); - setPageComplete(projectsList.getCheckedElements().length > 0); - lastPath = path; - return; - } + final File directory = new File(path); + long modified = directory.lastModified(); + if (path.equals(lastPath) && lastModified == modified) { + // since the file/folder was not modified and the path did not + // change, no refreshing is required + return; + } - final File directory = new File(path); - long modified = directory.lastModified(); - if (path.equals(lastPath) && lastModified == modified) { - // since the file/folder was not modified and the path did not - // change, no refreshing is required - return; - } + lastPath = path; + lastModified = modified; - lastPath = path; - lastModified = modified; + // We can't access the radio button from the inner class so get the + // status beforehand + final boolean dirSelected = this.projectFromDirectoryRadio.getSelection(); + try { + getContainer().run(true, true, new IRunnableWithProgress() { - // We can't access the radio button from the inner class so get the - // status beforehand - final boolean dirSelected = this.projectFromDirectoryRadio - .getSelection(); - try { - getContainer().run(true, true, new IRunnableWithProgress() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.operation.IRunnableWithProgress#run(org - * .eclipse.core.runtime.IProgressMonitor) - */ - public void run(IProgressMonitor monitor) { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.operation.IRunnableWithProgress#run(org + * .eclipse.core.runtime.IProgressMonitor) + */ + public void run(IProgressMonitor monitor) { - monitor - .beginTask( - DataTransferMessages.WizardProjectsImportPage_SearchingMessage, - 100); - selectedProjects = new ProjectRecord[0]; - Collection files = new ArrayList(); - monitor.worked(10); - if (!dirSelected - && ArchiveFileManipulations.isTarFile(path)) { - TarFile sourceTarFile = getSpecifiedTarSourceFile(path); - if (sourceTarFile == null) { - return; - } + monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100); + selectedProjects = new ProjectRecord[0]; + Collection files = new ArrayList(); + monitor.worked(10); + if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) { + TarFile sourceTarFile = getSpecifiedTarSourceFile(path); + if (sourceTarFile == null) { + return; + } - structureProvider = new TarLeveledStructureProvider( - sourceTarFile); - Object child = structureProvider.getRoot(); + structureProvider = new TarLeveledStructureProvider(sourceTarFile); + Object child = structureProvider.getRoot(); - if (!collectProjectFilesFromProvider(files, child, 0, - monitor)) { - return; - } - Iterator filesIterator = files.iterator(); - selectedProjects = new ProjectRecord[files.size()]; - int index = 0; - monitor.worked(50); - monitor - .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); - while (filesIterator.hasNext()) { - selectedProjects[index++] = (ProjectRecord) filesIterator - .next(); - } - } else if (!dirSelected - && ArchiveFileManipulations.isZipFile(path)) { - ZipFile sourceFile = getSpecifiedZipSourceFile(path); - if (sourceFile == null) { - return; - } - structureProvider = new ZipLeveledStructureProvider( - sourceFile); - Object child = structureProvider.getRoot(); + if (!collectProjectFilesFromProvider(files, child, 0, monitor)) { + return; + } + Iterator filesIterator = files.iterator(); + selectedProjects = new ProjectRecord[files.size()]; + int index = 0; + monitor.worked(50); + monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); + while (filesIterator.hasNext()) { + selectedProjects[index++] = (ProjectRecord) filesIterator.next(); + } + } else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) { + ZipFile sourceFile = getSpecifiedZipSourceFile(path); + if (sourceFile == null) { + return; + } + structureProvider = new ZipLeveledStructureProvider(sourceFile); + Object child = structureProvider.getRoot(); - if (!collectProjectFilesFromProvider(files, child, 0, - monitor)) { - return; - } - Iterator filesIterator = files.iterator(); - selectedProjects = new ProjectRecord[files.size()]; - int index = 0; - monitor.worked(50); - monitor - .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); - while (filesIterator.hasNext()) { - selectedProjects[index++] = (ProjectRecord) filesIterator - .next(); - } - } + if (!collectProjectFilesFromProvider(files, child, 0, monitor)) { + return; + } + Iterator filesIterator = files.iterator(); + selectedProjects = new ProjectRecord[files.size()]; + int index = 0; + monitor.worked(50); + monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); + while (filesIterator.hasNext()) { + selectedProjects[index++] = (ProjectRecord) filesIterator.next(); + } + } - else if (dirSelected && directory.isDirectory()) { + else if (dirSelected && directory.isDirectory()) { - if (!collectProjectFilesFromDirectory(files, directory, - null, monitor)) { - return; - } - Iterator filesIterator = files.iterator(); - selectedProjects = new ProjectRecord[files.size()]; - int index = 0; - monitor.worked(50); - monitor - .subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); - while (filesIterator.hasNext()) { - File file = (File) filesIterator.next(); + if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) { + return; + } + Iterator filesIterator = files.iterator(); + selectedProjects = new ProjectRecord[files.size()]; + int index = 0; + monitor.worked(50); + monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); + while (filesIterator.hasNext()) { + File file = (File) filesIterator.next(); selectedProjects[index] = new FileSystemProject(file); - index++; - } - } else { - monitor.worked(60); - } - monitor.done(); - } + index++; + } + } else { + monitor.worked(60); + } + monitor.done(); + } - }); - } catch (InvocationTargetException e) { + }); + } catch (InvocationTargetException e) { Activator.log(e.getMessage(), e); - } catch (InterruptedException e) { - // Nothing to do if the user interrupts. - } + } catch (InterruptedException e) { + // Nothing to do if the user interrupts. + } - projectsList.refresh(true); - ProjectRecord[] projects = getProjectRecords(); - boolean displayWarning = false; - for (int i = 0; i < projects.length; i++) { + projectsList.refresh(true); + ProjectRecord[] projects = getProjectRecords(); + boolean displayWarning = false; + for (int i = 0; i < projects.length; i++) { if (projects[i].hasConflicts()) { - displayWarning = true; - projectsList.setGrayed(projects[i], true); - } else { - projectsList.setChecked(projects[i], true); - } - } + displayWarning = true; + projectsList.setGrayed(projects[i], true); + } else { + projectsList.setChecked(projects[i], true); + } + } - if (displayWarning) { - setMessage( - DataTransferMessages.WizardProjectsImportPage_projectsInWorkspace, - WARNING); - } else { + if (displayWarning) { + setMessage(DataTransferMessages.WizardProjectsImportPage_projectsInWorkspace, WARNING); + } else { setMessage("Select a directory to search for existing WRT projects."); - } - setPageComplete(projectsList.getCheckedElements().length > 0); - if (selectedProjects.length == 0) { - setMessage( - DataTransferMessages.WizardProjectsImportPage_noProjectsToImport, - WARNING); - } - } + } + setPageComplete(projectsList.getCheckedElements().length > 0); + if (selectedProjects.length == 0) { + setMessage(DataTransferMessages.WizardProjectsImportPage_noProjectsToImport, WARNING); + } + } }