Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 162242 Details for
Bug 168937
Axis2: Support import of AAR
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for 168937
fix_for_168937_2.txt (text/plain), 27.96 KB, created by
Saminda Wijeratne
on 2010-03-17 04:10:18 EDT
(
hide
)
Description:
patch for 168937
Filename:
MIME Type:
Creator:
Saminda Wijeratne
Created:
2010-03-17 04:10:18 EDT
Size:
27.96 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.ws.axis2.core >Index: src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java,v >retrieving revision 1.7 >diff -u -r1.7 Axis2CoreUtils.java >--- src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java 11 Mar 2010 04:30:01 -0000 1.7 >+++ src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java 17 Mar 2010 08:05:53 -0000 >@@ -17,6 +17,8 @@ > * 20080625 210817 samindaw@wso2.com - Saminda Wijeratne, Setting the proxyBean and proxyEndPoint values - Refactoring > * 20080924 247929 samindaw@wso2.com - Saminda Wijeratne, source folder not correctly set > * 20090307 196954 samindaw@wso2.com - Saminda Wijeratne, Support XMLBeans data binding >+ * 20100317 168937 samindaw@wso2.com - Saminda Wijeratne, Support import of AAR >+ * 20100317 168938 samindaw@wso2.com - Saminda Wijeratne, Support export of AAR > *******************************************************************************/ > package org.eclipse.jst.ws.axis2.core.utils; > >@@ -36,11 +38,15 @@ > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceVisitor; > 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.jdt.core.IClasspathEntry; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IPackageFragmentRoot; >@@ -48,6 +54,7 @@ > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.internal.core.JavaProject; > import org.eclipse.jst.ws.axis2.core.constant.Axis2Constants; >+import org.eclipse.jst.ws.internal.common.J2EEUtils; > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.Node; >@@ -271,4 +278,69 @@ > } > return (String[])paths.toArray(new String[0]); > } >+ >+ >+ public static String[] getWorkspaceWebProjectList(){ >+ List webProjects=new ArrayList(); >+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); >+ for(IProject project:projects){ >+ try{ >+ J2EEUtils.getWebInfPath(project); >+ webProjects.add(project.getName()); >+ }catch(Exception e){ >+ //not a web project >+ } >+ } >+ return (String[])webProjects.toArray(new String[webProjects.size()]); >+ } >+ >+ public static List getServiceFoldersInProject(IProject project){ >+ List services=new ArrayList(); >+ IPath webInfPath = J2EEUtils.getWebInfPath(project); >+ IFolder folder=project.getFolder(webInfPath.removeFirstSegments(1)); >+ IFolder servicesFolder=folder.getFolder(new Path("services")); >+ >+ ServiceFolderVisitor visitor = new ServiceFolderVisitor(false); >+ try { >+ servicesFolder.accept(visitor); >+ } catch (CoreException e1) { >+ e1.printStackTrace(); >+ } >+ for(IResource resource:visitor.getResources()){ >+ Path path = new Path(resource.toString().substring(servicesFolder.toString().length())); >+ if (path.segmentCount()==1 && resource instanceof IFolder){ >+ IFolder folder2=(IFolder)resource; >+ services.add(folder2); >+ } >+ } >+ >+ return services; >+ } >+ >+ public static IFolder getServicesFolderofProject(IProject project){ >+ IPath webInfPath = J2EEUtils.getWebInfPath(project); >+ IFolder folder=project.getFolder(webInfPath.removeFirstSegments(1)); >+ IFolder servicesFolder=folder.getFolder(new Path("services")); >+ return servicesFolder; >+ } >+ >+ private static class ServiceFolderVisitor implements IResourceVisitor{ >+ List<IResource> linkedFolders; >+ boolean isGetOnlyLinkedFolders=false; >+ public ServiceFolderVisitor(boolean isGetOnlyLinkedFolders){ >+ linkedFolders=new ArrayList<IResource>(); >+ this.isGetOnlyLinkedFolders=isGetOnlyLinkedFolders; >+ } >+ public boolean visit(IResource arg0) throws CoreException { >+ if (!isGetOnlyLinkedFolders || arg0.isLinked()){ >+ if (arg0 instanceof IFolder || arg0 instanceof IFile) >+ linkedFolders.add(arg0); >+ } >+ return true; >+ } >+ >+ public IResource[] getResources(){ >+ return linkedFolders.toArray(new IResource[]{}); >+ } >+ } > } >Index: src/org/eclipse/jst/ws/axis2/core/utils/ArchiveManipulator.java >=================================================================== >RCS file: src/org/eclipse/jst/ws/axis2/core/utils/ArchiveManipulator.java >diff -N src/org/eclipse/jst/ws/axis2/core/utils/ArchiveManipulator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/ws/axis2/core/utils/ArchiveManipulator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,221 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 WSO2 Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * WSO2 Inc. - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20100317 168938 samindaw@wso2.com - Saminda Wijeratne, Initial code to introduce aar export >+ * 20100317 168937 samindaw@wso2.com - Saminda Wijeratne, Initial code to introduce aar import >+ *******************************************************************************/ >+ >+package org.eclipse.jst.ws.axis2.core.utils; >+ >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.OutputStream; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipInputStream; >+import java.util.zip.ZipOutputStream; >+ >+public class ArchiveManipulator { >+ protected String archiveSourceDir; >+ >+ /** >+ * Utility method to archive the given directory >+ * @param destArchiveName >+ * @param sourceDir >+ * @throws IOException >+ */ >+ public void archiveDir(String destArchiveName, String sourceDir) throws IOException { >+ File zipDir = new File(sourceDir); >+ if (!zipDir.isDirectory()) { >+ throw new RuntimeException(sourceDir + " is not a directory"); >+ } >+ >+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(destArchiveName)); >+ this.archiveSourceDir = sourceDir; >+ zipDir(zipDir, zos); >+ zos.close(); >+ } >+ >+ /** >+ * Utility method to archive the given file >+ * @param from >+ * @param to >+ * @throws IOException >+ */ >+ public void archiveFile(String from, String to) throws IOException { >+ FileInputStream in = new FileInputStream(from); >+ ZipOutputStream out = new ZipOutputStream(new FileOutputStream(to)); >+ byte[] buffer = new byte[40960]; >+ int bytesRead; >+ while ((bytesRead = in.read(buffer)) != -1) { >+ out.write(buffer, 0, bytesRead); >+ } >+ in.close(); >+ out.close(); >+ } >+ >+ /** >+ * List the contents of an archive >+ * @param archive >+ * @return List of Zip Entries >+ * @throws IOException >+ */ >+ public String[] check(String archive) throws IOException { >+ ZipInputStream zin = null; >+ InputStream in = null; >+ Collection entries = new ArrayList(); >+ try { >+ in = new FileInputStream(archive); >+ zin = new ZipInputStream(in); >+ ZipEntry entry; >+ while ((entry = zin.getNextEntry()) != null) { >+ entries.add(entry.getName()); >+ } >+ return (String[]) entries.toArray(new String[entries.size()]); >+ } finally { >+ try { >+ if (zin != null) { >+ zin.close(); >+ } >+ if (in != null) { >+ in.close(); >+ } >+ } catch (IOException e) { >+ System.err.println("Could not close InputStream " + e); >+ } >+ } >+ } >+ >+ /** >+ * Utility method to extract an archive >+ * @param archive >+ * @param extractDir >+ * @throws IOException >+ */ >+ public void extract(String archive, String extractDir) throws IOException { >+ FileInputStream inputStream = new FileInputStream(archive); >+ extractFromStream(inputStream, extractDir); >+ } >+ >+ /** >+ * Utility method to extract form a stream to a given directory >+ * @param inputStream >+ * @param extractDir >+ * @throws IOException >+ */ >+ public void extractFromStream(InputStream inputStream, String extractDir) throws IOException { >+ ZipInputStream zin = null; >+ try { >+ File unzipped = new File(extractDir); >+ // Open the ZIP file >+ zin = new ZipInputStream(inputStream); >+ unzipped.mkdirs(); >+ ZipEntry entry; >+ while ((entry = zin.getNextEntry()) != null) { >+ String entryName = entry.getName(); >+ File f = new File(extractDir + File.separator + entryName); >+ >+ if (entryName.endsWith("/") && !f.exists()) { // this is a >+ // directory >+ f.mkdirs(); >+ continue; >+ } >+ >+ // This is a file. Carry out File processing >+ int lastIndexOfSlash = entryName.lastIndexOf("/"); >+ String dirPath = ""; >+ if (lastIndexOfSlash != -1) { >+ dirPath = entryName.substring(0, lastIndexOfSlash); >+ File dir = new File(extractDir + File.separator + dirPath); >+ if (!dir.exists()) { >+ dir.mkdirs(); >+ } >+ } >+ >+ if (!f.isDirectory()) { >+ OutputStream out = new FileOutputStream(f); >+ byte[] buf = new byte[40960]; >+ >+ // Transfer bytes from the ZIP file to the output file >+ int len; >+ while ((len = zin.read(buf)) > 0) { >+ out.write(buf, 0, len); >+ } >+ } >+ } >+ } catch (IOException e) { >+ String msg = "Cannot unzip archive. It is probably corrupt"; >+ System.err.println(msg); >+ e.printStackTrace(); >+ throw e; >+ } finally { >+ try { >+ if (zin != null) { >+ zin.close(); >+ } >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ >+ /** >+ * Utility method used by archive methods >+ * @param zipDir >+ * @param zos >+ * @throws IOException >+ */ >+ private void zipDir(File zipDir, ZipOutputStream zos) throws IOException { >+ //get a listing of the directory content >+ String[] dirList = zipDir.list(); >+ byte[] readBuffer = new byte[40960]; >+ int bytesIn = 0; >+ //loop through dirList, and zip the files >+ for (int i = 0; i < dirList.length; i++) { >+ File f = new File(zipDir, dirList[i]); >+ //place the zip entry in the ZipOutputStream object >+ zos.putNextEntry(new ZipEntry(getZipEntryPath(f))); >+ if (f.isDirectory()) { >+ //if the File object is a directory, call this >+ //function again to add its content recursively >+ zipDir(f, zos); >+ //loop again >+ continue; >+ } >+ //if we reached here, the File object f was not a directory >+ //create a FileInputStream on top of f >+ FileInputStream fis = new FileInputStream(f); >+ >+ //now write the content of the file to the ZipOutputStream >+ while ((bytesIn = fis.read(readBuffer)) != -1) { >+ zos.write(readBuffer, 0, bytesIn); >+ } >+ //close the Stream >+ fis.close(); >+ } >+ } >+ >+ private String getZipEntryPath(File f) { >+ String entryPath = f.getPath(); >+ entryPath = entryPath.substring(archiveSourceDir.length() + 1); >+ if (File.separatorChar == '\\') { >+ entryPath = entryPath.replace(File.separatorChar, '/'); >+ } >+ if (f.isDirectory()) { >+ entryPath += "/"; >+ } >+ return entryPath; >+ } >+} >#P org.eclipse.jst.ws.axis2.consumption.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.axis2.consumption.ui/plugin.xml,v >retrieving revision 1.1 >diff -u -r1.1 plugin.xml >--- plugin.xml 24 Apr 2007 16:51:46 -0000 1.1 >+++ plugin.xml 17 Mar 2010 08:05:56 -0000 >@@ -16,5 +16,15 @@ > property="ClientProject" > transform="org.eclipse.jst.ws.internal.common.StringToIProjectTransformer"/> > </extension> >- >+ <extension point="org.eclipse.ui.importWizards"> >+ <wizard id="org.eclipse.jst.ws.axis2.importaar" name="AAR file" >+ category="org.eclipse.jst.ws.consumption.ui.wsimport.category" >+ class="org.eclipse.jst.ws.internal.axis2.consumption.ui.widgets.imports.AARImportWizard" >+ icon="./icons/aar.ico"> >+ <description> >+ Import axis2 archive to workspace. >+ </description> >+ <selection class="org.eclipse.core.resources.IProject"/> >+ </wizard> >+ </extension> > </plugin> >\ No newline at end of file >Index: build.properties >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.axis2.consumption.ui/build.properties,v >retrieving revision 1.3 >diff -u -r1.3 build.properties >--- build.properties 11 Jun 2007 17:34:31 -0000 1.3 >+++ build.properties 17 Mar 2010 08:05:56 -0000 >@@ -12,6 +12,7 @@ > # 20070130 168762 sandakith@wso2.com - Lahiru Sandakith, Initial code to introduse the > # Axis2 runtime to the framework for 168762 > # 20070502 184302 sandakith@wso2.com - Lahiru Sandakith, Fix copyright for Axis2 plugins >+# 20090305 168937 samindaw@wso2.com - Saminda Wijeratne, Initial code to introduce aar import > ############################################################################### > source.. = src/ > output.. = bin/ >@@ -20,4 +21,5 @@ > META-INF/,\ > .,\ > plugin.properties,\ >- about.html >+ about.html,\ >+ icons/ >Index: src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/Axis2ProxyWidget.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.axis2.consumption.ui/src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/Axis2ProxyWidget.java,v >retrieving revision 1.11 >diff -u -r1.11 Axis2ProxyWidget.java >--- src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/Axis2ProxyWidget.java 11 Mar 2010 04:30:09 -0000 1.11 >+++ src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/Axis2ProxyWidget.java 17 Mar 2010 08:05:57 -0000 >@@ -22,6 +22,7 @@ > * 20080621 200069 samindaw@wso2.com - Saminda Wijeratne, saving the retrieved WSDL so no need to retrieve it again > * 20090307 196954 samindaw@wso2.com - Saminda Wijeratne, Support XMLBeans data binding > * 20091207 193996 samindaw@wso2.com - Saminda Wijeratne, selecting a specific service/portname >+ * 20100317 168937 samindaw@wso2.com - Saminda Wijeratne, Support import of AAR > *******************************************************************************/ > package org.eclipse.jst.ws.internal.axis2.consumption.ui.widgets; > >Index: src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizard.java >=================================================================== >RCS file: src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizard.java >diff -N src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 WSO2 Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * WSO2 Inc. - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20100317 168937 samindaw@wso2.com - Saminda Wijeratne, Initial code to introduce aar import >+ *******************************************************************************/ >+ >+package org.eclipse.jst.ws.internal.axis2.consumption.ui.widgets.imports; >+ >+import java.io.File; >+import java.io.IOException; >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.internal.resources.Resource; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.jst.ws.axis2.core.utils.ArchiveManipulator; >+import org.eclipse.ui.IImportWizard; >+import org.eclipse.ui.IWorkbench; >+ >+public class AARImportWizard extends Wizard implements IImportWizard{ >+ private AARImportWizardPage mainPage; >+ private IStructuredSelection selection; >+ private IProject selectedProject; >+ >+ @Override >+ public boolean performFinish() { >+ IRunnableWithProgress op = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException { >+ try { >+ doFinish(monitor); >+ } catch (Exception e) { >+ throw new InvocationTargetException(e); >+ } finally { >+ monitor.done(); >+ } >+ } >+ }; >+ try { >+ getContainer().run(true, false, op); >+ } catch (InterruptedException e) { >+ return false; >+ } catch (InvocationTargetException e) { >+ Throwable realException = e.getTargetException(); >+ realException.printStackTrace(); >+ if (realException.getMessage().trim().equalsIgnoreCase("")) >+ MessageDialog.openError(getShell(), "Error", "Error occured while importing the service archive."); >+ else >+ MessageDialog.openError(getShell(), "Error", realException.getMessage()); >+ return false; >+ } >+ MessageDialog.openInformation(getShell(), "Axis2 Archive", "Axis2 archive imported successfully."); >+ >+ return true; >+ } >+ >+ public void init(IWorkbench arg0, IStructuredSelection arg1) { >+ this.selection=arg1; >+ if (selection.getFirstElement() instanceof IProject){ >+ selectedProject=(IProject)selection.getFirstElement(); >+ } >+ } >+ public void addPages() { >+ super .addPages(); >+ >+ mainPage = new AARImportWizardPage("AAR Export Wizard",selectedProject); >+ addPage(mainPage); >+ } >+ >+ private void doFinish(IProgressMonitor monitor) throws Exception { >+ >+ IFolder selectedServicesPath = mainPage.getSelectedServicesPath(); >+ >+ IPath selectedServicePath = selectedServicesPath.getLocation(); >+ >+ try { >+ >+ IPath serviceArchiveLocation = new Path(mainPage.getArchiveFileName()); >+ ArchiveManipulator archiveManipulator = new ArchiveManipulator(); >+ Path path = new Path(selectedServicePath.toOSString()); >+ String filename = serviceArchiveLocation.segments()[serviceArchiveLocation.segmentCount()-1]; >+ String fileExtension = serviceArchiveLocation.getFileExtension(); >+ filename=filename.substring(0,filename.length()-fileExtension.length()-1); >+ IPath newServiceIPath = path.append(filename); >+ String newServicePath = newServiceIPath.toOSString(); >+ File file = new File(newServicePath); >+ int i=1; >+ while(file.exists()){ >+ path.removeLastSegments(1); >+ newServiceIPath=path.append(filename+"_"+i); >+ newServicePath = newServiceIPath.toOSString(); >+ file = new File(newServicePath); >+ i=i+1; >+ } >+ file.mkdirs(); >+ archiveManipulator.extract(serviceArchiveLocation.toOSString(), newServicePath); >+ mainPage.getSelectedProject().refreshLocal(Resource.DEPTH_INFINITE, new NullProgressMonitor()); >+ } catch (IOException e) { >+ throw e; >+ } >+ } >+ >+} >+ >Index: src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizardPage.java >=================================================================== >RCS file: src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizardPage.java >diff -N src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizardPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/ws/internal/axis2/consumption/ui/widgets/imports/AARImportWizardPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,208 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 WSO2 Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * WSO2 Inc. - initial API and implementation >+ * yyyymmdd bug Email and other contact information >+ * -------- -------- ----------------------------------------------------------- >+ * 20100317 168937 samindaw@wso2.com - Saminda Wijeratne, Initial code to introduce aar import >+ *******************************************************************************/ >+ >+package org.eclipse.jst.ws.internal.axis2.consumption.ui.widgets.imports; >+ >+import java.io.File; >+ >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.jst.ws.axis2.core.utils.Axis2CoreUtils; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+ >+public class AARImportWizardPage extends WizardPage { >+ private String archiveFileName=""; >+ private Text deployInWorkspaceText; >+ private Combo projectSelectionCombo; >+ private String serviceToArchive; >+ private IProject selectedProject; >+ >+ protected AARImportWizardPage(String pageName, IProject selectedProject) { >+ super(pageName); >+ if (selectedProject!=null) >+ this.selectedProject=selectedProject; >+ setTitle("Axis2 Service Archive Importer"); >+ setDescription("Import axis2 service archive"); >+ } >+ >+ public void createControl(Composite parent) { >+ Composite container = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(); >+ container.setLayout(layout); >+ layout.numColumns = 3; >+ layout.verticalSpacing = 5; >+ GridData gd; >+ Label label; >+ >+ >+ label=new Label(container,SWT.NULL); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ label.setLayoutData(gd); >+ label.setText("Import AAR"); >+ >+ >+ deployInWorkspaceText = new Text(container, SWT.BORDER | SWT.SINGLE); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ deployInWorkspaceText.setLayoutData(gd); >+ deployInWorkspaceText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ handleDeployInWorkspaceText(); >+ } >+ }); >+ >+ Button deployInWorkspaceBrowseButton = new Button(container, SWT.PUSH); >+ deployInWorkspaceBrowseButton.setText("Browse"); >+ deployInWorkspaceBrowseButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ handledeployInWorkspaceBrowseButton(); >+ } >+ }); >+ >+ label=new Label(container,SWT.NULL); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ label.setLayoutData(gd); >+ gd.horizontalSpan=3; >+ >+ label=new Label(container,SWT.NULL); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ label.setLayoutData(gd); >+ gd.horizontalSpan=1; >+ label.setText("Web project"); >+ >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan=2; >+ projectSelectionCombo = new Combo(container,SWT.NONE | SWT.READ_ONLY); >+ projectSelectionCombo.setLayoutData(gd); >+ projectSelectionCombo.addModifyListener(new ModifyListener(){ >+ public void modifyText(ModifyEvent arg0) { >+ fillServiceSelectionCombo(); >+ } >+ >+ }); >+ >+ fillProjectSelectionCombo(); >+ >+ >+ >+ >+ deployInWorkspaceText.setText(""); >+ handleDeployInWorkspaceText(); >+ setControl(container); >+ } >+ >+ private void fillServiceSelectionCombo(){ >+ if (projectSelectionCombo.getSelectionIndex()==-1) return; >+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectSelectionCombo.getText()); >+ selectedProject=project; >+ } >+ >+ private void fillProjectSelectionCombo(){ >+ String[] webProjects=Axis2CoreUtils.getWorkspaceWebProjectList(); >+ projectSelectionCombo.removeAll(); >+ >+ for(String project:webProjects){ >+ projectSelectionCombo.add(project); >+ if (selectedProject!=null && project.equals(selectedProject.getName())) >+ projectSelectionCombo.select(projectSelectionCombo.getItemCount()-1); >+ } >+ >+ if (projectSelectionCombo.getSelectionIndex()==-1 && projectSelectionCombo.getItemCount()>0) >+ projectSelectionCombo.select(0); >+ } >+ >+ protected void handledeployInWorkspaceBrowseButton() { >+ String fileName=getImportFile(); >+ if (fileName!=null){ >+ deployInWorkspaceText.setText(fileName); >+ } >+ } >+ >+ protected void handleDeployInWorkspaceText() { >+ this.setArchiveFileName(deployInWorkspaceText.getText()); >+ setImportLocationStatusMsg(); >+ } >+ >+ private void setImportLocationStatusMsg(){ >+ String msg=null; >+ File file = new File(getArchiveFileName()); >+ if (getArchiveFileName().equalsIgnoreCase("") || !file.exists()) >+ msg="Specified path to the file should be valid"; >+ else if (!file.getName().toLowerCase().endsWith(".aar")) >+ msg="The selected file should have .aar extension"; >+ else >+ setDescription("Export axis2 service archive"); >+ updateStatus(msg); >+ } >+ >+ private void updateStatus(String msg){ >+ if (projectSelectionCombo.getSelectionIndex()==-1) >+ msg="No Web Project available in the workspace to import the Axis2 Archive"; >+ setErrorMessage(msg); >+ setPageComplete(msg==null); >+ } >+ >+ private String getImportFile(){ >+ String fileName = null; >+ FileDialog dlg = new FileDialog(getShell()); >+ fileName = dlg.open(); >+ return fileName; >+ } >+ >+ public void setArchiveFileName(String archiveFileName) { >+ this.archiveFileName = archiveFileName; >+ } >+ >+ public String getArchiveFileName() { >+ return archiveFileName; >+ } >+ >+ >+ /** >+ * @param serviceToArchive the serviceToArchive to set >+ */ >+ public void setServiceToArchive(String serviceToArchive) { >+ this.serviceToArchive = serviceToArchive; >+ } >+ >+ /** >+ * @return the serviceToArchive >+ */ >+ public String getServiceToArchive() { >+ return serviceToArchive; >+ } >+ >+ public IFolder getSelectedServicesPath(){ >+ return Axis2CoreUtils.getServicesFolderofProject(selectedProject); >+ >+ } >+ >+ public IProject getSelectedProject(){ >+ return selectedProject; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168937
:
127637
|
127638
|
128248
| 162242