diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/.project b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/.project new file mode 100644 index 00000000..d7b1f309 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/.project @@ -0,0 +1,17 @@ + + + AsposeCellsEclipseFeature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/build.properties b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/build.properties new file mode 100644 index 00000000..82ab19c6 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/feature.xml b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/feature.xml new file mode 100644 index 00000000..0203b4f7 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseFeature/feature.xml @@ -0,0 +1,52 @@ + + + + + Aspose.Cells Maven Project wizard creates Maven Project for using +Aspose.Cells for Java API within Eclipse IDE. +"Aspose.Cells for Java is an award-winning Excel Spreadsheet +component that allows Java developers to embed the ability to +read, write and manipulate Excel® spreadsheets (XLS, XLSX, XLSM, +XLSB, XLTX, SpreadsheetML, CSV, ODS), HTML, MHTML, PDF and image +file formats into their own Java applications without needing +to rely on Microsoft Excel®. +With Aspose.Cells for Java developers can export data, format +spreadsheets to the most granular level, import images, create +charts, apply and calculate complex formulas, stream Excel® data" +Aspose.Cells Maven Project wizard fetch and configures the latest +Maven dependency reference of Aspose.Cells for Java from the +Aspose Cloud Maven Repository. +The wizard also gives you option to download the Code Examples +to use Aspose.Cells for Java API. +Once you are finished with this wizard - created Maven project +and downloaded Code Examples. Next you can insert those Code +Examples to use Aspose.Cells for Java API in your Project from +File -> New -> Other -> Aspose.Cells Code Example +The newly created project and the Code Examples you added is +now ready to be enhanced, all required resources and references +are also automatically added. + + + + The MIT License (MIT) +Copyright (c) 2001-2016 Aspose Pty Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.classpath b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.classpath new file mode 100644 index 00000000..b1dabee3 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.project b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.project new file mode 100644 index 00000000..8fe6ea15 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.project @@ -0,0 +1,28 @@ + + + AsposeCellsEclipsePlugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.settings/org.eclipse.jdt.core.prefs b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..11f6e462 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/build.properties b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/build.properties new file mode 100644 index 00000000..bad26144 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + resources/ + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/plugin.xml b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/plugin.xml new file mode 100644 index 00000000..3903da67 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/plugin.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/Aspose.png b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/Aspose.png new file mode 100644 index 00000000..f2f1b4bf Binary files /dev/null and b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/Aspose.png differ diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/classpath-template.txt b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/classpath-template.txt new file mode 100644 index 00000000..fa40bfc1 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/classpath-template.txt @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/long_banner.png b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/long_banner.png new file mode 100644 index 00000000..c62fa705 Binary files /dev/null and b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/long_banner.png differ diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/org-eclipse-jdt-core.txt b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/org-eclipse-jdt-core.txt new file mode 100644 index 00000000..bbcbc934 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/org-eclipse-jdt-core.txt @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/pom-xml-template.txt b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/pom-xml-template.txt new file mode 100644 index 00000000..e5aa7d6b --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/resources/pom-xml-template.txt @@ -0,0 +1,20 @@ + + + 4.0.0 + com.mycompany + mavenproject1 + 2 + jar + + + Aspose-Maven-Repository + Aspose Maven Repository + http://maven.aspose.com/artifactory/simple/ext-release-local/ + + + + UTF-8 + 1.7 + 1.7 + + \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/Activator.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/Activator.java new file mode 100644 index 00000000..977bff68 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/Activator.java @@ -0,0 +1,80 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "AsposeCellsEclipsePlugin"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + public static String getResourceFilePath(String resourceFileName) { + String fileURL = null; + try { + URL url = getDefault().getBundle().getEntry("resources/" + resourceFileName); + fileURL = FileLocator.toFileURL(url).toURI().normalize().getPath(); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + return fileURL; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. + * BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework. + * BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/MavenSettings.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/MavenSettings.java new file mode 100644 index 00000000..86743bf1 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/MavenSettings.java @@ -0,0 +1,85 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; + +/** + * + * @author Adeel + */ +public final class MavenSettings { + + private static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; + private static final String PROP_LAST_ARCHETYPE_VERSION = "lastArchetypeVersion"; + + private IEclipsePreferences getPreferences() { + return InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID); + } + + /** + * + * @return + */ + public String getLastArchetypeGroupId() { + return getPreferences().get(PROP_LAST_ARCHETYPE_GROUPID, "com.mycompany"); + } + + /** + * + * @return + */ + public String getLastArchetypeVersion() { + return getPreferences().get(PROP_LAST_ARCHETYPE_VERSION, "1.0-SNAPSHOT"); + } + + /** + * + * @param version + */ + public void setLastArchetypeVersion(String version) { + putProperty(PROP_LAST_ARCHETYPE_VERSION, version); + } + + /** + * + * @param groupId + */ + public void setLastArchetypeGroupId(String groupId) { + putProperty(PROP_LAST_ARCHETYPE_GROUPID, groupId); + } + + private String putProperty(String key, String value) { + String retval = getProperty(key); + if (value != null) { + getPreferences().put(key, value); + } else { + getPreferences().remove(key); + } + return retval; + } + private static final MavenSettings INSTANCE = new MavenSettings(); + + /** + * + * @return + */ + public static MavenSettings getDefault() { + return INSTANCE; + } + + private String getProperty(String key) { + return getPreferences().get(key, null); + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectSupport.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectSupport.java new file mode 100644 index 00000000..c36a321e --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectSupport.java @@ -0,0 +1,158 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven; + +import java.net.URI; +import java.nio.file.Files; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import com.aspose.cells.Activator; +import com.aspose.cells.maven.utils.AsposeJavaAPI; +import com.aspose.cells.maven.utils.AsposeMavenProjectManager; +import com.aspose.cells.maven.utils.AsposeCellsJavaAPI; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +public class AsposeMavenProjectSupport implements IRunnableWithProgress { + + private String projectName; + private URI location; + private String packageName; + private boolean downloadExamples; + private String version; + private String groupId; + + public AsposeMavenProjectSupport(String projectName, URI location, String packageName, boolean downloadExamples, + String version, String groupId) { + this.projectName = projectName; + this.location = location; + this.packageName = packageName; + this.downloadExamples = downloadExamples; + this.version = version; + this.groupId = groupId; + } + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("Processing...", IProgressMonitor.UNKNOWN); + createProject(monitor); + monitor.done(); + } + + private IProject createProject(IProgressMonitor monitor) { + IProject project = createBaseProject(projectName, location); + try { + monitor.setTaskName("Creating project..."); + String[] paths = { "src/main/java/" + packageName.replace(".", "/"), "src/test/java", "src/main/resources" }; + addToProjectStructure(project, paths); + + Files.copy(new File(Activator.getResourceFilePath("pom-xml-template.txt")).toPath(), + new File(location.getPath() + "/pom.xml").toPath()); + Files.copy(new File(Activator.getResourceFilePath("classpath-template.txt")).toPath(), + new File(location.getPath() + "/.classpath").toPath()); + + Files.createDirectories(new File(location.getPath() + "/.settings").toPath()); + Files.copy(new File(Activator.getResourceFilePath("org-eclipse-jdt-core.txt")).toPath(), + new File(location.getPath() + "/.settings/org.eclipse.jdt.core.prefs").toPath()); + + AsposeMavenProjectManager asposeMavenProjectManager = AsposeMavenProjectManager + .initialize(new File(location)); + asposeMavenProjectManager.configureProjectMavenPOM(groupId, projectName, version); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + if (downloadExamples) { + monitor.setTaskName("Downloading code examples..."); + AsposeMavenProjectManager.initialize(new File(location)); + AsposeJavaAPI component = AsposeCellsJavaAPI.initialize(AsposeMavenProjectManager.getInstance()); + component.checkAndUpdateRepo(); + } + + } catch (CoreException e) { + e.printStackTrace(); + project = null; + } catch (IOException e) { + e.printStackTrace(); + } + + return project; + } + + private IProject createBaseProject(String projectName, URI location) { + IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + String natures[] = { "org.eclipse.jdt.core.javanature", "org.eclipse.m2e.core.maven2Nature" }; + + if (!newProject.exists()) { + URI projectLocation = location; + IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName()); + + ICommand commandJavaBuilder = (ICommand) desc.newCommand(); + ICommand commandMaven2Builder = (ICommand) desc.newCommand(); + commandJavaBuilder.setBuilderName("org.eclipse.jdt.core.javabuilder"); + commandMaven2Builder.setBuilderName("org.eclipse.m2e.core.maven2Builder"); + ICommand buildspecs[] = { commandJavaBuilder, commandMaven2Builder }; + + desc.setBuildSpec(buildspecs); + desc.setNatureIds(natures); + + if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) { + projectLocation = null; + } + + desc.setLocationURI(projectLocation); + try { + newProject.create(desc, null); + if (!newProject.isOpen()) { + newProject.open(null); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + return newProject; + } + + private void createFolder(IFolder folder) throws CoreException { + IContainer parent = folder.getParent(); + if (parent instanceof IFolder) { + createFolder((IFolder) parent); + } + if (!folder.exists()) { + folder.create(false, true, null); + } + } + + /** + * Create a folder structure with a parent root, overlay, and a few child + * folders. + * + * @param newProject + * @param paths + * @throws CoreException + */ + private void addToProjectStructure(IProject newProject, String[] paths) throws CoreException { + for (String path : paths) { + IFolder etcFolders = newProject.getFolder(path); + createFolder(etcFolders); + } + } + +} \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizard.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizard.java new file mode 100644 index 00000000..71a2c149 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizard.java @@ -0,0 +1,54 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven; + +import java.lang.reflect.InvocationTargetException; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +public class AsposeMavenProjectWizard extends Wizard implements INewWizard { + + private AsposeMavenProjectWizardPage wizardPage; + + public AsposeMavenProjectWizard() { + setWindowTitle("Aspose.Cells Maven Project"); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + + } + + @Override + public void addPages() { + super.addPages(); + wizardPage = new AsposeMavenProjectWizardPage(); + addPage(wizardPage); + } + + @Override + public boolean performFinish() { + AsposeMavenProjectSupport asposeMavenProjectSupport = new AsposeMavenProjectSupport(wizardPage.getProjectName(), + wizardPage.getLocationURI(), wizardPage.getPackageName(), wizardPage.isDownloadExamplesChecked(), + wizardPage.getVersion(), wizardPage.getGroupId()); + try { + new ProgressMonitorDialog(this.getShell()).run(true, false, asposeMavenProjectSupport); + } catch (InvocationTargetException | InterruptedException e) { + e.printStackTrace(); + } + return true; + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizardPage.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizardPage.java new file mode 100644 index 00000000..a2247c58 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/AsposeMavenProjectWizardPage.java @@ -0,0 +1,370 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven; + +import java.io.File; +import java.net.URI; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.wb.swt.SWTResourceManager; +import com.aspose.cells.Activator; +import com.aspose.cells.maven.utils.MavenSettings; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; + +public class AsposeMavenProjectWizardPage extends WizardPage { + + public static final String PROP_PROJECT_NAME = "projectName"; + public static final String PROP_GROUP_ID = "groupId"; + + private Text txtProjectLocation; + private Text txtProjectName; + private Text txtProjectFolder; + private Text txtArtifactId; + private Text txtGroupId; + private Text txtVersion; + private Text txtPackage; + private Button chkDownloadExamples; + + private ControlDecoration txtProjectNameDecoration; + private ControlDecoration txtProjectLocationDecoration; + private ControlDecoration txtGroupIdDecoration; + private ControlDecoration txtVersionDecoration; + private ControlDecoration txtProjectFolderDecoration; + private ControlDecoration txtPackageDecoration; + + /** + * Create the wizard. + */ + public AsposeMavenProjectWizardPage() { + super("wizardPage"); + setTitle("New Project"); + setDescription("Name and Location"); + } + + private String getDefaultProjectName() { + String defaultName = "asposemavenproject"; + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + try { + for (int i = 1; i < 100; i++) { + + boolean match = false; + for (IProject project : projects) { + if (project.getDescription().getName().equals(defaultName + i)) { + match = true; + break; + } + + } + if (!match) { + defaultName = defaultName + i; + break; + } + } + } catch (CoreException e) { + e.printStackTrace(); + } + return defaultName; + } + + private void initControls() { + txtGroupId.setText(MavenSettings.getDefault().getLastArchetypeGroupId()); + txtVersion.setText(MavenSettings.getDefault().getLastArchetypeVersion()); + txtProjectName.setText(getDefaultProjectName()); + txtProjectName.setSelection(txtProjectName.getCharCount()); + txtProjectLocation.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); + txtProjectFolder.setText(txtProjectLocation.getText() + File.separator + txtProjectName.getText()); + txtArtifactId.setText(txtProjectName.getText()); + txtPackage.setText(txtGroupId.getText() + "." + txtProjectName.getText()); + } + + private void initDecorators() { + FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); + + txtProjectNameDecoration = new ControlDecoration(txtProjectName, SWT.TOP | SWT.RIGHT); + txtProjectNameDecoration.setImage(fieldDecoration.getImage()); + txtProjectNameDecoration.hide(); + + txtProjectLocationDecoration = new ControlDecoration(txtProjectLocation, SWT.TOP | SWT.RIGHT); + txtProjectLocationDecoration.setImage(fieldDecoration.getImage()); + txtProjectLocationDecoration.hide(); + + txtGroupIdDecoration = new ControlDecoration(txtGroupId, SWT.TOP | SWT.RIGHT); + txtGroupIdDecoration.setImage(fieldDecoration.getImage()); + txtGroupIdDecoration.hide(); + + txtVersionDecoration = new ControlDecoration(txtVersion, SWT.TOP | SWT.RIGHT); + txtVersionDecoration.setImage(fieldDecoration.getImage()); + txtVersionDecoration.hide(); + + txtProjectFolderDecoration = new ControlDecoration(txtProjectFolder, SWT.TOP | SWT.RIGHT); + txtProjectFolderDecoration.setImage(fieldDecoration.getImage()); + txtProjectFolderDecoration.hide(); + + txtPackageDecoration = new ControlDecoration(txtPackage, SWT.TOP | SWT.RIGHT); + txtPackageDecoration.setImage(fieldDecoration.getImage()); + txtPackageDecoration.hide(); + } + + private void onProjectNameChange() { + txtProjectNameDecoration.hide(); + setPageComplete(true); + if (txtProjectName.getText().trim().length() == 0) { + txtProjectNameDecoration.setDescriptionText("Project Name is not a valid folder name"); + txtProjectNameDecoration.show(); + setPageComplete(false); + } + txtProjectFolder.setText(txtProjectLocation.getText() + File.separator + txtProjectName.getText()); + txtArtifactId.setText(txtProjectName.getText()); + txtPackage.setText("com.mycompany." + txtProjectName.getText()); + } + + private void onProjectLocationChange() { + txtProjectLocationDecoration.hide(); + setPageComplete(true); + if (!new File(txtProjectLocation.getText().trim()).isDirectory()) { + txtProjectLocationDecoration.setDescriptionText("Project Folder is not a valid path"); + txtProjectLocationDecoration.show(); + setPageComplete(false); + } + txtProjectFolder.setText(txtProjectLocation.getText() + File.separator + txtProjectName.getText()); + } + + private void onVersionChange() { + txtVersionDecoration.hide(); + setPageComplete(true); + if (txtVersion.getText().trim().length() == 0) { + txtVersionDecoration.setDescriptionText("Version may not be empty"); + txtVersionDecoration.show(); + setPageComplete(false); + } + } + + private void onPackageChange() { + txtPackageDecoration.hide(); + setPageComplete(true); + String packageName = txtPackage.getText().trim(); + if (!(packageName.equals("") + || packageName.matches("([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*"))) { + txtPackageDecoration.setDescriptionText("Package may not be empty"); + txtPackageDecoration.show(); + setPageComplete(false); + } + } + + private void onGroupIdChange() { + txtGroupIdDecoration.hide(); + setPageComplete(true); + if (txtGroupId.getText().trim().length() == 0) { + txtGroupIdDecoration.setDescriptionText("GroupdId may not be empty"); + txtGroupIdDecoration.show(); + setPageComplete(false); + } + txtPackage.setText(txtGroupId.getText() + "." + txtProjectName.getText()); + } + + private void onProjectFolderChange() { + txtProjectFolderDecoration.hide(); + setPageComplete(true); + File projLoc = new File( + (new File(txtProjectLocation.getText()).getAbsoluteFile()).toURI().normalize().getPath()); + File destFolder = new File( + (new File(txtProjectFolder.getText()).getAbsoluteFile()).toURI().normalize().getPath()); + + while (projLoc != null && !projLoc.exists()) { + projLoc = projLoc.getParentFile(); + } + if (projLoc == null || !projLoc.canWrite()) { + txtProjectFolderDecoration.setDescriptionText("Project Folder cannot be created"); + txtProjectFolderDecoration.show(); + setPageComplete(false); + } else { + File[] kids = destFolder.listFiles(); + if (destFolder.exists() && kids != null && kids.length > 0) { + txtProjectFolderDecoration.setDescriptionText("Project Folder already exists and is not empty"); + txtProjectFolderDecoration.show(); + setPageComplete(false); + } + } + } + + public String getProjectName() { + return txtProjectName.getText(); + } + + public String getPackageName() { + return txtPackage.getText(); + } + + public URI getLocationURI() { + return new File(txtProjectFolder.getText()).toURI(); + } + + public String getVersion() { + return txtVersion.getText(); + } + + public String getGroupId() { + return txtGroupId.getText(); + } + + public boolean isDownloadExamplesChecked() { + return chkDownloadExamples.getSelection(); + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + + setControl(container); + + Label lblNewLabel = new Label(container, SWT.NONE); + lblNewLabel.setImage(SWTResourceManager.getImage(Activator.getResourceFilePath("long_banner.png"))); + lblNewLabel.setBounds(10, 0, 500, 80); + + Label lblPleaseEnterProject = new Label(container, SWT.NONE); + lblPleaseEnterProject.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblPleaseEnterProject.setBounds(5, 98, 179, 15); + lblPleaseEnterProject.setText("Please enter project detail:"); + + Label lblPleaseEnterMaven = new Label(container, SWT.NONE); + lblPleaseEnterMaven.setText("Please enter maven artifact detail:"); + lblPleaseEnterMaven.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblPleaseEnterMaven.setBounds(5, 194, 213, 15); + + Label lblProjectName = new Label(container, SWT.NONE); + lblProjectName.setBounds(5, 118, 84, 15); + lblProjectName.setText("Project Name:"); + + Label lblProjectLocation = new Label(container, SWT.NONE); + lblProjectLocation.setBounds(5, 146, 94, 15); + lblProjectLocation.setText("Project Location:"); + + Label lblProjectFolder = new Label(container, SWT.NONE); + lblProjectFolder.setText("Project Folder:"); + lblProjectFolder.setBounds(5, 173, 94, 15); + + Label lblArtifactId = new Label(container, SWT.NONE); + lblArtifactId.setText("Artifact Id:"); + lblArtifactId.setBounds(5, 215, 94, 15); + + Label lblGroupId = new Label(container, SWT.NONE); + lblGroupId.setText("Group Id:"); + lblGroupId.setBounds(5, 242, 94, 15); + + Label lblVersion = new Label(container, SWT.NONE); + lblVersion.setText("Version:"); + lblVersion.setBounds(5, 270, 94, 15); + + Label lblPackage = new Label(container, SWT.NONE); + lblPackage.setText("Package:"); + lblPackage.setBounds(5, 296, 94, 15); + + txtProjectName = new Text(container, SWT.BORDER); + txtProjectName.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onProjectNameChange(); + } + }); + txtProjectName.setBounds(118, 116, 319, 21); + + txtProjectLocation = new Text(container, SWT.BORDER); + txtProjectLocation.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onProjectLocationChange(); + } + }); + txtProjectLocation.setBounds(118, 143, 319, 21); + + Button btnNewButton = new Button(container, SWT.NONE); + btnNewButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + DirectoryDialog dialog = new DirectoryDialog(new Shell(), SWT.NULL); + String path = dialog.open(); + if (path != null) { + txtProjectLocation.setText(path); + } + } + }); + btnNewButton.setBounds(443, 141, 75, 25); + btnNewButton.setText("Browse..."); + + txtProjectFolder = new Text(container, SWT.BORDER); + txtProjectFolder.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onProjectFolderChange(); + } + }); + txtProjectFolder.setEditable(false); + txtProjectFolder.setBounds(118, 170, 319, 21); + + txtArtifactId = new Text(container, SWT.BORDER); + txtArtifactId.setEnabled(false); + txtArtifactId.setEditable(false); + txtArtifactId.setBounds(118, 212, 319, 21); + + txtGroupId = new Text(container, SWT.BORDER); + txtGroupId.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onGroupIdChange(); + } + }); + txtGroupId.setBounds(118, 239, 319, 21); + + txtVersion = new Text(container, SWT.BORDER); + txtVersion.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onVersionChange(); + } + }); + txtVersion.setBounds(118, 266, 319, 21); + + txtPackage = new Text(container, SWT.BORDER); + txtPackage.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onPackageChange(); + } + }); + txtPackage.setBounds(118, 293, 319, 21); + + chkDownloadExamples = new Button(container, SWT.CHECK); + chkDownloadExamples.setBounds(5, 325, 492, 16); + chkDownloadExamples.setText("Also Download Code Examples (for using Aspose.Cells for Java)"); + + Label lblNewLabel_1 = new Label(container, SWT.NONE); + lblNewLabel_1.setBounds(443, 296, 55, 15); + lblNewLabel_1.setText("(Optional)"); + + initDecorators(); + initControls(); + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/Metadata.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/Metadata.java new file mode 100644 index 00000000..5a945712 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/Metadata.java @@ -0,0 +1,362 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.26 at 03:01:37 PM PKT +// +package com.aspose.cells.maven.artifacts; + +import javax.xml.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +/** + *

+ * Java class for anonymous complex type. + *

+ *

+ * The following schema fragment specifies the expected content contained within + * this class. + *

+ * < + * pre> + * <complexType> <complexContent> <restriction + * base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> <element + * name="groupId" type="{http://www.w3.org/2001/XMLSchema}string"/> <element + * name="artifactId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="version" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="versioning"> <complexType> <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> <element name="latest" + * type="{http://www.w3.org/2001/XMLSchema}string"/> <element name="release" + * type="{http://www.w3.org/2001/XMLSchema}string"/> <element + * name="versions"> <complexType> <complexContent> <restriction + * base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> <element + * name="version" type="{http://www.w3.org/2001/XMLSchema}string" + * maxOccurs="unbounded" minOccurs="0"/> </sequence> </restriction> + * </complexContent> </complexType> </element> <element + * name="lastUpdated" type="{http://www.w3.org/2001/XMLSchema}long"/> + * </sequence> </restriction> </complexContent> </complexType> + * </element> </sequence> </restriction> </complexContent> + * </complexType> + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "groupId", + "artifactId", + "version", + "versioning", + "classifier" +}) +@XmlRootElement(name = "metadata") +public class Metadata { + + /** + * + */ + @XmlElement(required = true) + protected String groupId; + + /** + * + */ + @XmlElement(required = true) + protected String artifactId; + + /** + * + */ + @XmlElement(required = true) + protected String version; + + /** + * + */ + @XmlElement(required = true) + protected Metadata.Versioning versioning; + + /** + * + */ + protected String classifier; + + /** + * Gets the value of the groupId property. + * + * @return possible object is {@link String } + */ + public String getGroupId() { + return groupId; + } + + /** + * Sets the value of the groupId property. + * + * @param value allowed object is {@link String } + */ + public void setGroupId(String value) { + this.groupId = value; + } + + /** + * Gets the value of the artifactId property. + * + * @return possible object is {@link String } + */ + public String getArtifactId() { + return artifactId; + } + + /** + * Sets the value of the artifactId property. + * + * @param value allowed object is {@link String } + */ + public void setArtifactId(String value) { + this.artifactId = value; + } + + /** + * Gets the value of the version property. + * + * @return possible object is {@link String } + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value allowed object is {@link String } + */ + public void setVersion(String value) { + this.version = value; + } + + /** + * Gets the value of the versioning property. + * + * @return possible object is {@link Metadata.Versioning } + */ + public Metadata.Versioning getVersioning() { + return versioning; + } + + /** + * Sets the value of the versioning property. + * + * @param value allowed object is {@link Metadata.Versioning } + */ + public void setVersioning(Metadata.Versioning value) { + this.versioning = value; + } + + /** + *

+ * Java class for anonymous complex type. + *

+ *

+ * The following schema fragment specifies the expected content contained + * within this class. + *

+ * < + * pre> + * <complexType> <complexContent> <restriction + * base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> + * <element name="latest" + * type="{http://www.w3.org/2001/XMLSchema}string"/> <element + * name="release" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="versions"> <complexType> <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> <element name="version" + * type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" + * minOccurs="0"/> </sequence> </restriction> </complexContent> + * </complexType> </element> <element name="lastUpdated" + * type="{http://www.w3.org/2001/XMLSchema}long"/> </sequence> + * </restriction> </complexContent> </complexType> + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "latest", + "release", + "versions", + "lastUpdated" + }) + public static class Versioning { + + /** + * + */ + @XmlElement(required = true) + protected String latest; + + /** + * + */ + @XmlElement(required = true) + protected String release; + + /** + * + */ + @XmlElement(required = true) + protected Metadata.Versioning.Versions versions; + + /** + * + */ + protected long lastUpdated; + + /** + * Gets the value of the latest property. + * + * @return possible object is {@link String } + */ + public String getLatest() { + return latest; + } + + /** + * Sets the value of the latest property. + * + * @param value allowed object is {@link String } + */ + public void setLatest(String value) { + this.latest = value; + } + + /** + * Gets the value of the release property. + * + * @return possible object is {@link String } + */ + public String getRelease() { + return release; + } + + /** + * Sets the value of the release property. + * + * @param value allowed object is {@link String } + */ + public void setRelease(String value) { + this.release = value; + } + + /** + * Gets the value of the versions property. + * + * @return possible object is {@link Metadata.Versioning.Versions } + */ + public Metadata.Versioning.Versions getVersions() { + return versions; + } + + /** + * Sets the value of the versions property. + * + * @param value allowed object is {@link Metadata.Versioning.Versions } + */ + public void setVersions(Metadata.Versioning.Versions value) { + this.versions = value; + } + + /** + * Gets the value of the lastUpdated property. + * @return + */ + public long getLastUpdated() { + return lastUpdated; + } + + /** + * Sets the value of the lastUpdated property. + * @param value + */ + public void setLastUpdated(long value) { + this.lastUpdated = value; + } + + /** + *

+ * Java class for anonymous complex type. + *

+ *

+ * The following schema fragment specifies the expected content + * contained within this class. + *

+ * < + * pre> + * <complexType> <complexContent> <restriction + * base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> + * <element name="version" + * type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" + * minOccurs="0"/> </sequence> </restriction> </complexContent> + * </complexType> + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "version" + }) + public static class Versions { + + /** + * + */ + protected List version; + + /** + * Gets the value of the version property. + *

+ *

+ * This accessor method returns a reference to the live list, not a + * snapshot. Therefore any modification you make to the returned + * list will be present inside the JAXB object. This is why there is + * not a set method for the version property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+             *    getVersion().add(newItem);
+             * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * @return + */ + public List getVersion() { + if (version == null) { + version = new ArrayList(); + } + return this.version; + } + + } + + } + + /** + * Gets the value of the classifier property. + * + * @return possible object is {@link String } + */ + public String getClassifier() { + return classifier; + } + + /** + * Sets the value of the version property. + * + * @param value allowed object is {@link String } + */ + public void setClassifier(String value) { + this.classifier = value; + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/ObjectFactory.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/ObjectFactory.java new file mode 100644 index 00000000..6788b329 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/ObjectFactory.java @@ -0,0 +1,55 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.26 at 03:01:37 PM PKT +// +package com.aspose.cells.maven.artifacts; + +import javax.xml.bind.annotation.XmlRegistry; + +/** + * This object contains factory methods for each Java content interface and Java + * element interface generated in the com.aspose.maven.artifacts package. + *

+ * An ObjectFactory allows you to programatically construct new instances of the + * Java representation for XML content. The Java representation of XML content + * can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory + * methods for each of these are provided in this class. + */ +@XmlRegistry +public class ObjectFactory { + + /** + * Create a new ObjectFactory that can be used to create new instances of + * schema derived classes for package: com.aspose.maven.apis.artifacts + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Metadata.Versioning.Versions } + * @return + */ + public Metadata.Versioning.Versions createMetadataVersioningVersions() { + return new Metadata.Versioning.Versions(); + } + + /** + * Create an instance of {@link Metadata } + * @return + */ + public Metadata createMetadata() { + return new Metadata(); + } + + /** + * Create an instance of {@link Metadata.Versioning } + * @return + */ + public Metadata.Versioning createMetadataVersioning() { + return new Metadata.Versioning(); + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metada.xml b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metada.xml new file mode 100644 index 00000000..1df59945 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metada.xml @@ -0,0 +1,17 @@ + + + com.aspose + aspose-cells + 14.5.0 + + 14.8.0 + 14.8.0 + + 14.5.0 + 14.6.0 + 14.7.0 + 14.8.0 + + 20140924084136 + + \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metadata.xsd b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metadata.xsd new file mode 100644 index 00000000..6e3d358e --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/artifacts/maven-metadata.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleSupport.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleSupport.java new file mode 100644 index 00000000..06a75343 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleSupport.java @@ -0,0 +1,96 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.examples; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; + +import org.apache.commons.io.FileUtils; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.w3c.dom.NodeList; +import com.aspose.cells.maven.utils.AsposeConstants; +import com.aspose.cells.maven.utils.AsposeMavenProjectManager; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +public class AsposeExampleSupport implements IRunnableWithProgress { + + private String selectedProjectPath; + private String exampleCategory; + private IProject project; + + final private static String localExampleFolder = "aspose/GitConsRepos/Aspose.Cells/Examples"; + final private static String localExampleSourceFolder = "src/main/java/com/aspose/cells/examples"; + final private static String localExampleResourceFolder = "src/main/resources/com/aspose/cells/examples"; + + public AsposeExampleSupport(String selectedProjectPath, String exampleCategory, IProject project) { + this.selectedProjectPath = selectedProjectPath; + this.exampleCategory = exampleCategory; + this.project = project; + } + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("Adding example code in project " + project.getName() + "...", IProgressMonitor.UNKNOWN); + createExample(); + monitor.done(); + } + + public void createExample() { + String srcExamplePath = System.getProperty("user.home") + File.separator + localExampleFolder + File.separator + + localExampleSourceFolder; + String srcExampleResourcePath = System.getProperty("user.home") + File.separator + localExampleFolder + + File.separator + localExampleResourceFolder; + + String destProjectExamplePath = selectedProjectPath + File.separator + localExampleSourceFolder; + String destProjectExampleResourcePath = selectedProjectPath + File.separator + localExampleResourceFolder; + + File srcExampleCategoryPath = new File(srcExamplePath + File.separator + exampleCategory); + File destExampleCategoryPath = new File(destProjectExamplePath + File.separator + exampleCategory); + + Path srcUtil = new File(srcExamplePath + File.separator + "Utils.java").toPath(); + Path destUtil = new File(destProjectExamplePath + File.separator + "Utils.java").toPath(); + + File srcExampleResourceCategoryPath = new File(srcExampleResourcePath + File.separator + exampleCategory); + File destExampleResourceCategoryPath = new File( + destProjectExampleResourcePath + File.separator + exampleCategory); + + String repositoryPOM_XML = System.getProperty("user.home") + File.separator + localExampleFolder + + File.separator + AsposeConstants.MAVEN_POM_XML; + + try { + FileUtils.copyDirectory(srcExampleCategoryPath, destExampleCategoryPath); + Files.copy(srcUtil, destUtil, StandardCopyOption.REPLACE_EXISTING); + FileUtils.copyDirectory(srcExampleResourceCategoryPath, destExampleResourceCategoryPath); + + NodeList examplesNoneAsposeDependencies = AsposeMavenProjectManager.getInstance() + .getDependenciesFromPOM(repositoryPOM_XML, AsposeConstants.ASPOSE_GROUP_ID); + AsposeMavenProjectManager.getInstance().addMavenDependenciesInProject(examplesNoneAsposeDependencies); + + NodeList examplesNoneAsposeRepositories = AsposeMavenProjectManager.getInstance() + .getRepositoriesFromPOM(repositoryPOM_XML, AsposeConstants.ASPOSE_MAVEN_REPOSITORY); + AsposeMavenProjectManager.getInstance().addMavenRepositoriesInProject(examplesNoneAsposeRepositories); + + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + } catch (IOException | CoreException e) { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizard.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizard.java new file mode 100644 index 00000000..513161a6 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizard.java @@ -0,0 +1,61 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.examples; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +public class AsposeExampleWizard extends Wizard implements INewWizard { + + private AsposeExampleWizardPage wizardPage; + + public AsposeExampleWizard() { + setWindowTitle("Aspose.Cells Code Example"); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + + } + + @Override + public void addPages() { + super.addPages(); + wizardPage = new AsposeExampleWizardPage(); + addPage(wizardPage); + } + + @Override + public boolean performFinish() { + + String selectedProjectPath = wizardPage.getSelectedProjectPath(); + String exampleCategory = wizardPage.getSelectedExampleCategory(); + IProject project = wizardPage.getIProject(); + + AsposeExampleSupport asposeExampleSupport = new AsposeExampleSupport(selectedProjectPath, exampleCategory, + project); + try { + new ProgressMonitorDialog(this.getShell()).run(true, false, asposeExampleSupport); + } catch (InvocationTargetException | InterruptedException e) { + e.printStackTrace(); + } + + return true; + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizardPage.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizardPage.java new file mode 100644 index 00000000..bd8c7245 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/examples/AsposeExampleWizardPage.java @@ -0,0 +1,307 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.examples; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.util.LinkedList; +import java.util.Queue; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.swt.widgets.Label; +import org.eclipse.wb.swt.SWTResourceManager; +import com.aspose.cells.Activator; +import com.aspose.cells.maven.utils.AsposeConstants; +import com.aspose.cells.maven.utils.AsposeJavaAPI; +import com.aspose.cells.maven.utils.AsposeMavenProjectManager; +import com.aspose.cells.maven.utils.AsposeCellsJavaAPI; +import com.aspose.cells.maven.utils.FormatExamples; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.ModifyEvent; + +public class AsposeExampleWizardPage extends WizardPage { + + private Combo cbProject; + private Combo cbVersion; + private Tree examplesTree; + + private ControlDecoration cbProjectDecoration; + private ControlDecoration cbVersionDecoration; + private ControlDecoration examplesTreeDecoration; + + /** + * Create the wizard. + */ + public AsposeExampleWizardPage() { + super("wizardPage"); + setTitle("New Aspose.Cells Code Example"); + setDescription("Aspose.Cells Java API - Code Examples"); + } + + public IProject getIProject() { + return (IProject) cbProject.getData(cbProject.getText()); + } + + public String getSelectedProjectPath() { + String projectPath = null; + try { + IProject project = (IProject) cbProject.getData(cbProject.getText()); + projectPath = project.getDescription().getLocationURI().getPath(); + + } catch (CoreException e) { + e.printStackTrace(); + } + return projectPath; + } + + public String getSelectedProjectName() { + return cbProject.getText(); + } + + public String getSelectedExampleCategory() { + TreeItem selectedTreeItem = examplesTree.getSelection()[0]; + String selectedCategory = selectedTreeItem.getText().trim().replace(' ', '_').toLowerCase(); + + while (selectedTreeItem.getParentItem().getParentItem() != null) { + selectedTreeItem = selectedTreeItem.getParentItem(); + selectedCategory = selectedTreeItem.getText().trim().replace(' ', '_').toLowerCase() + "/" + + selectedCategory; + } + return selectedCategory; + } + + private void downloadExamplesRepo() { + // download code examples with status progress + try { + new ProgressMonitorDialog(this.getShell()).run(true, false, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("Downloading latest example categories...", IProgressMonitor.UNKNOWN); + + AsposeMavenProjectManager.initialize(null); + AsposeJavaAPI component = AsposeCellsJavaAPI.initialize(AsposeMavenProjectManager.getInstance()); + component.checkAndUpdateRepo(); + + monitor.done(); + } + }); + } catch (InvocationTargetException | InterruptedException e) { + e.printStackTrace(); + } + } + + private void initControls() { + + downloadExamplesRepo(); + + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + URI path = null; + try { + for (IProject project : projects) { + path = project.getDescription().getLocationURI(); + if (path != null) { + cbProject.add(project.getDescription().getName()); + cbProject.setData(project.getDescription().getName(), project); + } + } + cbProjectDecoration.hide(); + setPageComplete(true); + if (cbProject.getItemCount() == 0) { + cbProject.add(AsposeConstants.API_PROJECT_NOT_FOUND); + cbProjectDecoration.show(); + setPageComplete(false); + } + + cbProject.select(0); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + private void initDecorators() { + FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); + + cbProjectDecoration = new ControlDecoration(cbProject, SWT.TOP | SWT.RIGHT); + cbProjectDecoration.setImage(fieldDecoration.getImage()); + cbProjectDecoration.setDescriptionText("Please first create a Maven project"); + cbProjectDecoration.hide(); + + cbVersionDecoration = new ControlDecoration(cbVersion, SWT.TOP | SWT.RIGHT); + cbVersionDecoration.setImage(fieldDecoration.getImage()); + cbVersionDecoration.setDescriptionText( + "Please first add maven dependency of " + AsposeConstants.API_NAME + " for java API"); + cbVersionDecoration.hide(); + + examplesTreeDecoration = new ControlDecoration(examplesTree, SWT.TOP | SWT.RIGHT); + examplesTreeDecoration.setImage(fieldDecoration.getImage()); + examplesTreeDecoration.setDescriptionText("Please select one example category"); + examplesTreeDecoration.hide(); + } + + private void onProjectModify() { + try { + cbVersion.removeAll(); + IProject selectedProject = (IProject) cbProject.getData(cbProject.getText()); + if (selectedProject != null) { + String versionNo = AsposeMavenProjectManager.getInstance().getDependencyVersionFromPOM( + selectedProject.getDescription().getLocationURI(), AsposeConstants.API_MAVEN_DEPENDENCY); + cbVersionDecoration.hide(); + setPageComplete(true); + if (versionNo == null) { + cbVersionDecoration.show(); + setPageComplete(false); + } + if (versionNo == null) { + versionNo = AsposeConstants.API_DEPENDENCY_NOT_FOUND; + } + cbVersion.add(versionNo); + cbVersion.select(0); + } + } catch (CoreException e) { + e.printStackTrace(); + } + + } + + private void onVersionModify() { + try { + examplesTree.removeAll(); + if (!cbVersion.getText().equals(AsposeConstants.API_DEPENDENCY_NOT_FOUND)) { + IProject selectedProject = (IProject) cbProject.getData(cbProject.getText()); + if (selectedProject != null) { + AsposeMavenProjectManager.initialize(new File(selectedProject.getDescription().getLocationURI())); + AsposeJavaAPI component = AsposeCellsJavaAPI.initialize(AsposeMavenProjectManager.getInstance()); + populateExamplesTree(component); + examplesTreeDecoration.show(); + setPageComplete(false); + } + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + private void onTreeSelection() { + examplesTreeDecoration.show(); + setPageComplete(false); + TreeItem[] selectedItems = examplesTree.getSelection(); + if (selectedItems[0].getParentItem() != null && selectedItems[0].getItemCount() > 0) { + examplesTreeDecoration.hide(); + setPageComplete(true); + } + } + + /** + * + * @param asposeComponent + * @param top + * @param panel + */ + public void populateExamplesTree(AsposeJavaAPI asposeComponent) { + String examplesFullPath = asposeComponent.getLocalRepositoryPath() + File.separator + + AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION; + File directory = new File(examplesFullPath); + examplesTree.removeAll(); + Queue queue = new LinkedList<>(); + queue.add(new Object[] { null, directory }); + TreeItem top = new TreeItem(examplesTree, 0); + top.setText("Aspose.Cells"); + + while (!queue.isEmpty()) { + Object[] _entry = queue.remove(); + File childFile = ((File) _entry[1]); + TreeItem parentItem = (TreeItem) _entry[0]; + if (childFile.isDirectory()) { + if (parentItem != null) { + TreeItem child = new TreeItem(parentItem, SWT.NONE); + child.setText(FormatExamples.formatTitle(childFile.getName())); + parentItem = child; + } else { + parentItem = top; + } + for (File f : childFile.listFiles()) { + queue.add(new Object[] { parentItem, f }); + } + } else if (childFile.isFile()) { + TreeItem child = new TreeItem(parentItem, SWT.NONE); + child.setText(FormatExamples.formatTitle(childFile.getName())); + } + } + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + + setControl(container); + + cbProject = new Combo(container, SWT.READ_ONLY); + cbProject.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onProjectModify(); + } + }); + cbProject.setBounds(181, 101, 323, 23); + + examplesTree = new Tree(container, SWT.BORDER); + examplesTree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + onTreeSelection(); + } + }); + examplesTree.setBounds(10, 170, 494, 206); + + Label label = new Label(container, SWT.NONE); + label.setImage(SWTResourceManager.getImage(Activator.getResourceFilePath("long_banner.png"))); + label.setBounds(10, 0, 500, 80); + + Label lblProject = new Label(container, SWT.NONE); + lblProject.setBounds(134, 104, 40, 15); + lblProject.setText("Project:"); + + Label lblAsposecellsForJava = new Label(container, SWT.NONE); + lblAsposecellsForJava.setBounds(5, 131, 170, 15); + lblAsposecellsForJava.setText("Aspose.Cells for Java (version):"); + + cbVersion = new Combo(container, SWT.READ_ONLY); + cbVersion.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + onVersionModify(); + } + }); + cbVersion.setBounds(181, 128, 323, 23); + + initDecorators(); + initControls(); + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeCellsJavaAPI.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeCellsJavaAPI.java new file mode 100644 index 00000000..6d6c269c --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeCellsJavaAPI.java @@ -0,0 +1,78 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +/* + * @author Adeel Ilyas + * + */ +// Singleton Class + +/** + * + * @author Adeel + */ +public class AsposeCellsJavaAPI extends AsposeJavaAPI { + + private final String _name = AsposeConstants.API_NAME; + private final String _mavenRepositoryURL = "http://maven.aspose.com/repository/ext-release-local/com/aspose/aspose-cells/"; + private final String _remoteExamplesRepository = "https://github.com/asposecells/Aspose_Cells_Java"; + + /** + * @return the _name + */ + @Override + public String get_name() { + return _name; + } + + /** + * @return the _mavenRepositoryURL + */ + @Override + public String get_mavenRepositoryURL() { + return _mavenRepositoryURL; + } + + /** + * @return the _remoteExamplesRepository + */ + @Override + public String get_remoteExamplesRepository() { + return _remoteExamplesRepository; + } + + // Singleton instance + private static AsposeJavaAPI asposeCellsAPI; + + /** + * + * @return + */ + public static AsposeJavaAPI getInstance() { + return asposeCellsAPI; + } + + /** + * + * @param asposeMavenProjectManager + * @return + */ + public static AsposeJavaAPI initialize(AsposeMavenProjectManager asposeMavenProjectManager) { + asposeCellsAPI = new AsposeCellsJavaAPI(); + asposeCellsAPI.asposeMavenProjectManager = asposeMavenProjectManager; + return asposeCellsAPI; + } + + private AsposeCellsJavaAPI() { + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeConstants.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeConstants.java new file mode 100644 index 00000000..b0166254 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeConstants.java @@ -0,0 +1,146 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +/* + * @author Adeel Ilyas + */ +import java.io.File; + +/** + * + * @author Adeel + */ +public class AsposeConstants { + + /** + * + */ + public static final String API_NAME = "Aspose.Cells"; + + /** + * + */ + public static final String API_MAVEN_DEPENDENCY = "aspose-cells"; + + /** + * + */ + public static final String API_EXAMPLES_PACKAGE = "com" + File.separator + API_MAVEN_DEPENDENCY.replace("-", File.separator) + File.separator + "examples"; + + /** + * + */ + public static final String GITHUB_EXAMPLES_SOURCE_LOCATION = "Examples" + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator + API_EXAMPLES_PACKAGE; + + /** + * + */ + public static final String GITHUB_EXAMPLES_RESOURCES_LOCATION = "Examples" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + API_EXAMPLES_PACKAGE; + + /** + * + */ + public static final String PROJECT_EXAMPLES_SOURCE_LOCATION = "src" + File.separator + "main" + File.separator + "java" + File.separator + API_EXAMPLES_PACKAGE; + + /** + * + */ + public static final String PROJECT_EXAMPLES_RESOURCES_LOCATION = "src" + File.separator + "main" + File.separator + "resources" + File.separator + API_EXAMPLES_PACKAGE; + + /** + * + */ + public static final String EXAMPLES_UTIL = GITHUB_EXAMPLES_SOURCE_LOCATION + File.separator + "Utils.java"; + + /** + * + */ + public static final String API_DEPENDENCY_NOT_FOUND = "Dependency not found!"; + + public static final String API_PROJECT_NOT_FOUND = "No projects found!"; + + /** + * + */ + public static final String MAVEN_POM_XML = "pom.xml"; + + /** + * + */ + public static final String WIZARD_NAME = "Aspose.Cells Maven Project"; + + /** + * + */ + public static final String ASPOSE_SELECT_EXAMPLE = "Please just select one examples category"; + + /** + * + */ + public static final String INTERNET_CONNNECTIVITY_PING_URL = "java.sun.com"; + + /** + * + */ + public static final String ASPOSE_MAVEN_REPOSITORY = "http://maven.aspose.com"; + + /** + * + */ + public static final String ASPOSE_GROUP_ID = "com.aspose"; + + /** + * + */ + public static final String INTERNET_REQUIRED_MSG = "Internet connectivity is not available!\nInternet connectivity is required to retrieve latest Aspose.Cells Maven Artifact"; + + /** + * + */ + public static final String EXAMPLES_INTERNET_REQUIRED_MSG = "Internet connectivity is required to download examples"; + + /** + * + */ + public static final String MAVEN_ARTIFACTS_RETRIEVE_FAIL = "Unknown Error!\nCould not retrieve latest Aspose.Cells Maven Artifact!"; + + /** + * + */ + public static final String EXAMPLES_DOWNLOAD_FAIL = "Unknown Error!\nCould not download Aspose.Cells for Java API example Source codes!"; + + /** + * + */ + public static final String EXAMPLES_NOT_AVAILABLE_MSG = "This component does not have examples yet, We will add examples soon"; + + /** + * + */ + public static final String EXAMPLES_NOT_AVAILABLE_TITLE = "Examples not available"; + + /** + * + */ + public static boolean printingAllowed = false; + + /** + * + * @param message + */ + public static final void println(String message) { + if (printingAllowed) { + System.out.println(message); + } + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeJavaAPI.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeJavaAPI.java new file mode 100644 index 00000000..5bd689ea --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeJavaAPI.java @@ -0,0 +1,159 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +import javax.swing.*; +import java.io.File; + + +public abstract class AsposeJavaAPI { + + /** + * + * @return + */ + public abstract String get_name(); + + /** + * + * @return + */ + public abstract String get_mavenRepositoryURL(); + + /** + * + * @return + */ + public abstract String get_remoteExamplesRepository(); + + /** + * + * @return + */ + public boolean isExamplesNotAvailable() { + return examplesNotAvailable; + } + + /** + * + */ + public boolean examplesNotAvailable; + + /** + * + * @return + */ + public boolean isExamplesDefinitionAvailable() { + return examplesDefinitionAvailable; + } + + /** + * + */ + public boolean examplesDefinitionAvailable; + + /** + * + */ + public AsposeMavenProjectManager asposeMavenProjectManager; + + /** + * + * @param p + */ + public void checkAndUpdateRepo() { + + if (null == get_remoteExamplesRepository()) { + AsposeMavenProjectManager.showMessage(AsposeConstants.EXAMPLES_NOT_AVAILABLE_TITLE, get_name() + " - " + AsposeConstants.EXAMPLES_NOT_AVAILABLE_MSG, JOptionPane.CLOSED_OPTION, JOptionPane.INFORMATION_MESSAGE); + examplesNotAvailable = true; + examplesDefinitionAvailable = false; + return; + } else { + examplesNotAvailable = false; + } + + if (isExamplesDefinitionsPresent()) { + try { + examplesDefinitionAvailable = true; + syncRepository(); + } catch (Exception e) { + } + } else { + updateRepository(); + if (isExamplesDefinitionsPresent()) { + examplesDefinitionAvailable = true; + + } + } + } + + /** + * + * @param p + * @return + */ + public boolean downloadExamples() { + try { + checkAndUpdateRepo(); + } catch (Exception rex) { + rex.printStackTrace(); + return false; + } + + return true; + + } + + /** + * + * @param p + */ + public void updateRepository() { + AsposeMavenProjectManager.checkAndCreateFolder(getLocalRepositoryPath()); + + try { + GitHelper.updateRepository(getLocalRepositoryPath(), get_remoteExamplesRepository()); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * + * @param p + */ + public void syncRepository() { + try { + GitHelper.syncRepository(getLocalRepositoryPath(), get_remoteExamplesRepository()); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * + * @return boolean + */ + public boolean isExamplesDefinitionsPresent() { + return new File(getLocalRepositoryPath()).exists(); + } + + /** + * + * @return String + */ + public String getLocalRepositoryPath() { + return asposeMavenProjectManager.getAsposeHomePath() + "GitConsRepos" + File.separator + get_name(); + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeMavenProjectManager.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeMavenProjectManager.java new file mode 100644 index 00000000..8a48f411 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/AsposeMavenProjectManager.java @@ -0,0 +1,499 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JOptionPane; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import com.aspose.cells.maven.artifacts.Metadata; +import com.aspose.cells.maven.artifacts.ObjectFactory; + +public class AsposeMavenProjectManager { + + private File projectDir = null; + + private static final List asposeProjectMavenDependencies = new ArrayList(); + + /** + * + * @return + */ + public static List getAsposeProjectMavenDependencies() { + return asposeProjectMavenDependencies; + } + + /** + * + */ + public static void clearAsposeProjectMavenDependencies() { + asposeProjectMavenDependencies.clear(); + } + + /** + * + * @return + */ + public File getProjectDir() { + return projectDir; + } + + public String getDependencyVersionFromPOM(URI projectDir, String dependencyName) { + try { + String mavenPomXmlfile = projectDir.getPath() + File.separator + AsposeConstants.MAVEN_POM_XML; + + if (new File(mavenPomXmlfile).exists()) { + Document pomDocument = getXmlDocument(mavenPomXmlfile); + + XPathFactory xPathfactory = XPathFactory.newInstance(); + XPath xpath = xPathfactory.newXPath(); + String expression = "//version[ancestor::dependency/artifactId[text()='" + dependencyName + "']]"; + XPathExpression xPathExpr = xpath.compile(expression); + NodeList nl = (NodeList) xPathExpr.evaluate(pomDocument, XPathConstants.NODESET); + + if (nl != null && nl.getLength() > 0) { + return nl.item(0).getTextContent(); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return null; + } + + private Document getXmlDocument(String mavenPomXmlfile) + throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document pomDocument = (Document) docBuilder.parse(mavenPomXmlfile); + + return pomDocument; + } + + public String getAsposeHomePath() { + return System.getProperty("user.home") + File.separator + "aspose" + File.separator; + } + + /** + * + * @param folderPath + */ + public static void checkAndCreateFolder(String folderPath) { + File folder = new File(folderPath); + if (!folder.exists()) { + folder.mkdirs(); + } + } + + // Singleton instance + private static AsposeMavenProjectManager asposeMavenProjectManager = new AsposeMavenProjectManager(); + + /** + * + * @return + */ + public static AsposeMavenProjectManager getInstance() { + return asposeMavenProjectManager; + } + + /** + * + * @param mavenPomXmlfile + * @param excludeGroup + * @return + */ + public NodeList getDependenciesFromPOM(String mavenPomXmlfile, String excludeGroup) { + try { + Document pomDocument = getXmlDocument(mavenPomXmlfile); + + XPathFactory xPathfactory = XPathFactory.newInstance(); + XPath xpath = xPathfactory.newXPath(); + String expression = "//dependency[child::groupId[text()!='" + excludeGroup + "']]"; + XPathExpression xPathExpr = xpath.compile(expression); + NodeList nl = (NodeList) xPathExpr.evaluate(pomDocument, XPathConstants.NODESET); + if (nl != null && nl.getLength() > 0) { + return nl; + } + } catch (IOException | ParserConfigurationException | SAXException | XPathExpressionException e) { + e.printStackTrace(); + } + return null; + } + + /** + * + * @param addTheseDependencies + */ + public void addMavenDependenciesInProject(NodeList addTheseDependencies) { + + String mavenPomXmlfile = projectDir.getPath() + File.separator + AsposeConstants.MAVEN_POM_XML; + + try { + Document pomDocument = getXmlDocument(mavenPomXmlfile); + Node dependenciesNode = pomDocument.getElementsByTagName("dependencies").item(0); + + if (addTheseDependencies != null && addTheseDependencies.getLength() > 0) { + for (int n = 0; n < addTheseDependencies.getLength(); n++) { + String artifactId = addTheseDependencies.item(n).getFirstChild().getNextSibling().getNextSibling() + .getNextSibling().getFirstChild().getNodeValue(); + + XPathFactory xPathfactory = XPathFactory.newInstance(); + XPath xpath = xPathfactory.newXPath(); + String expression = "//artifactId[text()='" + artifactId + "']"; + + XPathExpression xPathExpr = xpath.compile(expression); + + Node dependencyAlreadyExist = (Node) xPathExpr.evaluate(pomDocument, XPathConstants.NODE); + + if (dependencyAlreadyExist != null) { + Node dependencies = pomDocument.getElementsByTagName("dependencies").item(0); + dependencies.removeChild(dependencyAlreadyExist.getParentNode()); + } + + Node importedNode = pomDocument.importNode(addTheseDependencies.item(n), true); + dependenciesNode.appendChild(importedNode); + } + } + removeEmptyLinesfromDOM(pomDocument); + writeToPOM(pomDocument); + + } catch (ParserConfigurationException | SAXException | XPathExpressionException | IOException ex) { + ex.printStackTrace(); + } + } + + /** + * + * @return + */ + private boolean retrieveAsposeMavenDependencies() { + try { + getAsposeProjectMavenDependencies().clear(); + AsposeJavaAPI component = AsposeCellsJavaAPI.getInstance(); + Metadata productMavenDependency = getProductMavenDependency(component.get_mavenRepositoryURL()); + if (productMavenDependency != null) { + getAsposeProjectMavenDependencies().add(productMavenDependency); + } + + } catch (Exception rex) { + rex.printStackTrace(); + return false; + } + return !getAsposeProjectMavenDependencies().isEmpty(); + } + + public void configureProjectMavenPOM(String groupId, String artifactId, String version) throws IOException { + + AsposeCellsJavaAPI.initialize(asposeMavenProjectManager); + retrieveAsposeMavenDependencies(); + + try { + String mavenPomXmlfile = projectDir.getPath() + File.separator + AsposeConstants.MAVEN_POM_XML; + Document doc = getXmlDocument(mavenPomXmlfile); + + Element root = doc.getDocumentElement(); + Node node = root.getElementsByTagName("groupId").item(0); + node.setTextContent(groupId); + + node = root.getElementsByTagName("artifactId").item(0); + node.setTextContent(artifactId); + + node = root.getElementsByTagName("version").item(0); + node.setTextContent(version); + + updateProjectPom(doc); + writeToPOM(doc); + + } catch (ParserConfigurationException | SAXException e) { + e.printStackTrace(); + } + + } + + private void updateProjectPom(Document pomDocument) { + + // Get the root element + Node projectNode = pomDocument.getFirstChild(); + + // Adding Dependencies here + Element dependenciesTag = pomDocument.createElement("dependencies"); + projectNode.appendChild(dependenciesTag); + + for (Metadata dependency : getAsposeProjectMavenDependencies()) { + addAsposeMavenDependency(pomDocument, dependenciesTag, dependency); + } + } + + private void addAsposeMavenDependency(Document doc, Element dependenciesTag, Metadata dependency) { + Element dependencyTag = doc.createElement("dependency"); + dependenciesTag.appendChild(dependencyTag); + + Element groupIdTag = doc.createElement("groupId"); + groupIdTag.appendChild(doc.createTextNode(dependency.getGroupId())); + dependencyTag.appendChild(groupIdTag); + + Element artifactId = doc.createElement("artifactId"); + artifactId.appendChild(doc.createTextNode(dependency.getArtifactId())); + dependencyTag.appendChild(artifactId); + Element version = doc.createElement("version"); + version.appendChild(doc.createTextNode(dependency.getVersioning().getLatest())); + dependencyTag.appendChild(version); + if (dependency.getClassifier() != null) { + Element classifer = doc.createElement("classifier"); + classifer.appendChild(doc.createTextNode(dependency.getClassifier())); + dependencyTag.appendChild(classifer); + } + } + + /** + * + * @param Url + * @return + * @throws IOException + */ + public String readURLContents(String Url) throws IOException { + URL url = new URL(Url); + URLConnection con = url.openConnection(); + InputStream in = con.getInputStream(); + String encoding = con.getContentEncoding(); + encoding = encoding == null ? "UTF-8" : encoding; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buf = new byte[8192]; + int len = 0; + while ((len = in.read(buf)) != -1) { + baos.write(buf, 0, len); + } + String body = new String(baos.toByteArray(), encoding); + return body; + } + + /** + * + * @param productMavenRepositoryUrl + * @return + */ + public Metadata getProductMavenDependency(String productMavenRepositoryUrl) { + final String mavenMetaDataFileName = "maven-metadata.xml"; + Metadata data = null; + + try { + String productMavenInfo; + productMavenInfo = readURLContents(productMavenRepositoryUrl + mavenMetaDataFileName); + JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); + Unmarshaller unmarshaller; + unmarshaller = jaxbContext.createUnmarshaller(); + + data = (Metadata) unmarshaller.unmarshal(new StreamSource(new StringReader(productMavenInfo))); + + String remoteArtifactFile = productMavenRepositoryUrl + data.getVersioning().getLatest() + "/" + + data.getArtifactId() + "-" + data.getVersioning().getLatest(); + + if (!remoteFileExists(remoteArtifactFile + ".jar")) { + AsposeConstants.println("Not Exists"); + data.setClassifier(getResolveSupportedJDK(remoteArtifactFile)); + } else { + AsposeConstants.println("Exists"); + } + } catch (IOException | JAXBException ex) { + ex.printStackTrace(); + data = null; + } + return data; + } + + /** + * + * @param URLName + * @return + */ + public boolean remoteFileExists(String URLName) { + try { + HttpURLConnection.setFollowRedirects(false); + // note : you may also need + // HttpURLConnection.setInstanceFollowRedirects(false) + HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection(); + con.setRequestMethod("HEAD"); + return (con.getResponseCode() == HttpURLConnection.HTTP_OK); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * + * @param ProductURL + * @return + */ + public String getResolveSupportedJDK(String ProductURL) { + String supportedJDKs[] = { "jdk17", "jdk16", "jdk15", "jdk14", "jdk18" }; + String classifier = null; + for (String jdkCheck : supportedJDKs) { + if (remoteFileExists(ProductURL + "-" + jdkCheck + ".jar")) { + AsposeConstants.println("Exists"); + classifier = jdkCheck; + break; + } else { + AsposeConstants.println("Not Exists"); + } + } + return classifier; + } + + /** + * + * @param mavenPomXmlfile + * @param excludeURL + * @return + */ + public NodeList getRepositoriesFromPOM(String mavenPomXmlfile, String excludeURL) { + try { + Document pomDocument = getXmlDocument(mavenPomXmlfile); + XPathFactory xPathfactory = XPathFactory.newInstance(); + XPath xpath = xPathfactory.newXPath(); + String expression = "//repository[child::url[not(starts-with(.,'" + excludeURL + "'))]]"; + XPathExpression xPathExpr = xpath.compile(expression); + NodeList nl = (NodeList) xPathExpr.evaluate(pomDocument, XPathConstants.NODESET); + if (nl != null && nl.getLength() > 0) { + return nl; + } + } catch (IOException | ParserConfigurationException | SAXException | XPathExpressionException e) { + e.printStackTrace(); + } + return null; + } + + /** + * + * @param addTheseRepositories + */ + public void addMavenRepositoriesInProject(NodeList addTheseRepositories) { + String mavenPomXmlfile = projectDir.getPath() + File.separator + AsposeConstants.MAVEN_POM_XML; + try { + Document pomDocument = getXmlDocument(mavenPomXmlfile); + + Node repositoriesNode = pomDocument.getElementsByTagName("repositories").item(0); + + if (addTheseRepositories != null && addTheseRepositories.getLength() > 0) { + for (int n = 0; n < addTheseRepositories.getLength(); n++) { + String repositoryId = addTheseRepositories.item(n).getFirstChild().getNextSibling().getFirstChild() + .getNodeValue(); + + XPathFactory xPathfactory = XPathFactory.newInstance(); + XPath xpath = xPathfactory.newXPath(); + String expression = "//id[text()='" + repositoryId + "']"; + + XPathExpression xPathExpr = xpath.compile(expression); + + Boolean repositoryAlreadyExist = (Boolean) xPathExpr.evaluate(pomDocument, XPathConstants.BOOLEAN); + + if (!repositoryAlreadyExist) { + Node importedNode = pomDocument.importNode(addTheseRepositories.item(n), true); + repositoriesNode.appendChild(importedNode); + } + + } + } + removeEmptyLinesfromDOM(pomDocument); + writeToPOM(pomDocument); + + } catch (XPathExpressionException | SAXException | ParserConfigurationException | IOException ex) { + ex.printStackTrace(); + } + } + + /** + * + * @param pomDocument + * @throws IOException + */ + public void writeToPOM(Document pomDocument) throws IOException { + try { + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = tFactory.newTransformer(); + DOMSource source = new DOMSource(pomDocument); + + StreamResult result = new StreamResult( + new File(projectDir + File.separator + AsposeConstants.MAVEN_POM_XML)); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); + + transformer.transform(source, result); + } catch (TransformerException e) { + e.printStackTrace(); + } + } + + private void removeEmptyLinesfromDOM(Document doc) throws XPathExpressionException { + XPath xp = XPathFactory.newInstance().newXPath(); + NodeList nl = (NodeList) xp.evaluate("//text()[normalize-space(.)='']", doc, XPathConstants.NODESET); + + for (int i = 0; i < nl.getLength(); ++i) { + Node node = nl.item(i); + node.getParentNode().removeChild(node); + } + } + + /** + * + * @param title + * @param message + * @param buttons + * @param icon + * @return + */ + public static int showMessage(String title, String message, int buttons, int icon) { + int result = JOptionPane.showConfirmDialog(null, message, title, buttons, icon); + return result; + } + + public static AsposeMavenProjectManager initialize(File prjDir) { + asposeMavenProjectManager = new AsposeMavenProjectManager(); + asposeMavenProjectManager.projectDir = prjDir; + return asposeMavenProjectManager; + } + +} \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/FormatExamples.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/FormatExamples.java new file mode 100644 index 00000000..ad6ac955 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/FormatExamples.java @@ -0,0 +1,30 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +import org.apache.commons.lang.WordUtils; + +public class FormatExamples { + + /** + * + * @param inputStr + * @return + */ + public static String formatTitle(String inputStr) { + String title = inputStr.replaceAll("(_|.java|\\.)", " "); + title = title.replaceAll("([A-Z])", " $1"); + title = WordUtils.capitalize(title); + + return title; + } +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/GitHelper.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/GitHelper.java new file mode 100644 index 00000000..70e0c365 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/GitHelper.java @@ -0,0 +1,80 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.cells.maven.utils; + +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.internal.storage.file.FileRepository; +import org.eclipse.jgit.lib.Repository; + +import java.io.File; + +/** + * @author Adeel Ilyas + * + */ +public class GitHelper { + + /** + * + * @param localPath + * @param remotePath + * @throws Exception + */ + public static void updateRepository(String localPath, String remotePath) throws Exception { + Repository localRepo; + try { + localRepo = new FileRepository(localPath + "/.git"); + + Git git = new Git(localRepo); + + // First try to clone the repository + try { + Git.cloneRepository().setURI(remotePath).setDirectory(new File(localPath)).call(); + } catch (Exception ex) { + // If clone fails, try to pull the changes + try { + git.pull().call(); + } catch (Exception exPull) { + // Pull also failed. Throw this exception to caller + throw exPull; // throw it + } + } finally { + git.close(); + } + } catch (Exception ex) { + throw new Exception("Could not download Repository from Github. Error: " + ex.getMessage()); + } + } + + /** + * + * @param localPath + * @param remotePath + * @throws Exception + */ + public static void syncRepository(String localPath, String remotePath) throws Exception { + Repository localRepo; + try { + localRepo = new FileRepository(localPath + "/.git"); + + Git git = new Git(localRepo); + + // Pull the changes + try { + git.pull().call(); + } catch (Exception exPull) { + // If pull failed. Throw this exception to caller + + throw exPull; // throw it + } finally { + git.close(); + } + + } catch (Exception ex) { + throw new Exception("Could not update Repository from Github. Error: " + ex.getMessage()); + } + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/MavenSettings.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/MavenSettings.java new file mode 100644 index 00000000..c0dd5338 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/com/aspose/cells/maven/utils/MavenSettings.java @@ -0,0 +1,88 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 1998-2016 Aspose Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.aspose.cells.maven.utils; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; + +import com.aspose.cells.Activator; + +/** + * + * @author Adeel + */ +public final class MavenSettings { + + private static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; + private static final String PROP_LAST_ARCHETYPE_VERSION = "lastArchetypeVersion"; + + private IEclipsePreferences getPreferences() { + return InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID); + } + + /** + * + * @return + */ + public String getLastArchetypeGroupId() { + return getPreferences().get(PROP_LAST_ARCHETYPE_GROUPID, "com.mycompany"); + } + + /** + * + * @return + */ + public String getLastArchetypeVersion() { + return getPreferences().get(PROP_LAST_ARCHETYPE_VERSION, "1.0-SNAPSHOT"); + } + + /** + * + * @param version + */ + public void setLastArchetypeVersion(String version) { + putProperty(PROP_LAST_ARCHETYPE_VERSION, version); + } + + /** + * + * @param groupId + */ + public void setLastArchetypeGroupId(String groupId) { + putProperty(PROP_LAST_ARCHETYPE_GROUPID, groupId); + } + + private String putProperty(String key, String value) { + String retval = getProperty(key); + if (value != null) { + getPreferences().put(key, value); + } else { + getPreferences().remove(key); + } + return retval; + } + + private static final MavenSettings INSTANCE = new MavenSettings(); + + /** + * + * @return + */ + public static MavenSettings getDefault() { + return INSTANCE; + } + + private String getProperty(String key) { + return getPreferences().get(key, null); + } + +} diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/org/eclipse/wb/swt/SWTResourceManager.java b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/org/eclipse/wb/swt/SWTResourceManager.java new file mode 100644 index 00000000..8b6d4cc3 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipsePlugin/src/org/eclipse/wb/swt/SWTResourceManager.java @@ -0,0 +1,447 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc. + * 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: + * Google, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.wb.swt; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; + +/** + * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. + *

+ * !!! IMPORTANT !!! Application code must explicitly invoke the dispose() method to release the + * operating system resources managed by cached objects when those objects and OS resources are no longer + * needed (e.g. on application shutdown) + *

+ * This class may be freely distributed as part of any application or plugin. + *

+ * @author scheglov_ke + * @author Dan Rubel + */ +public class SWTResourceManager { + //////////////////////////////////////////////////////////////////////////// + // + // Color + // + //////////////////////////////////////////////////////////////////////////// + private static Map m_colorMap = new HashMap(); + /** + * Returns the system {@link Color} matching the specific ID. + * + * @param systemColorID + * the ID value for the color + * @return the system {@link Color} matching the specific ID + */ + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + /** + * Returns a {@link Color} given its red, green and blue component values. + * + * @param r + * the red component of the color + * @param g + * the green component of the color + * @param b + * the blue component of the color + * @return the {@link Color} matching the given red, green and blue component values + */ + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + /** + * Returns a {@link Color} given its RGB value. + * + * @param rgb + * the {@link RGB} value of the color + * @return the {@link Color} matching the RGB value + */ + public static Color getColor(RGB rgb) { + Color color = m_colorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_colorMap.put(rgb, color); + } + return color; + } + /** + * Dispose of all the cached {@link Color}'s. + */ + public static void disposeColors() { + for (Color color : m_colorMap.values()) { + color.dispose(); + } + m_colorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Image + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps image paths to images. + */ + private static Map m_imageMap = new HashMap(); + /** + * Returns an {@link Image} encoded by the specified {@link InputStream}. + * + * @param stream + * the {@link InputStream} encoding the image data + * @return the {@link Image} encoded by the specified input stream + */ + protected static Image getImage(InputStream stream) throws IOException { + try { + Display display = Display.getCurrent(); + ImageData data = new ImageData(stream); + if (data.transparentPixel > 0) { + return new Image(display, data, data.getTransparencyMask()); + } + return new Image(display, data); + } finally { + stream.close(); + } + } + /** + * Returns an {@link Image} stored in the file at the specified path. + * + * @param path + * the path to the image file + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(String path) { + Image image = m_imageMap.get(path); + if (image == null) { + try { + image = getImage(new FileInputStream(path)); + m_imageMap.put(path, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(path, image); + } + } + return image; + } + /** + * Returns an {@link Image} stored in the file at the specified path relative to the specified class. + * + * @param clazz + * the {@link Class} relative to which to find the image + * @param path + * the path to the image file, if starts with '/' + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(Class clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = m_imageMap.get(key); + if (image == null) { + try { + image = getImage(clazz.getResourceAsStream(path)); + m_imageMap.put(key, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(key, image); + } + } + return image; + } + private static final int MISSING_IMAGE_SIZE = 10; + /** + * @return the small {@link Image} that can be used as placeholder for missing image. + */ + private static Image getMissingImage() { + Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + // + GC gc = new GC(image); + gc.setBackground(getColor(SWT.COLOR_RED)); + gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + gc.dispose(); + // + return image; + } + /** + * Style constant for placing decorator image in top left corner of base image. + */ + public static final int TOP_LEFT = 1; + /** + * Style constant for placing decorator image in top right corner of base image. + */ + public static final int TOP_RIGHT = 2; + /** + * Style constant for placing decorator image in bottom left corner of base image. + */ + public static final int BOTTOM_LEFT = 3; + /** + * Style constant for placing decorator image in bottom right corner of base image. + */ + public static final int BOTTOM_RIGHT = 4; + /** + * Internal value. + */ + protected static final int LAST_CORNER_KEY = 5; + /** + * Maps images to decorated images. + */ + @SuppressWarnings("unchecked") + private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @return {@link Image} The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @param corner + * the corner to place decorator image + * @return the resulting decorated {@link Image} + */ + public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map decoratedMap = cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + // + Image result = decoratedMap.get(decorator); + if (result == null) { + Rectangle bib = baseImage.getBounds(); + Rectangle dib = decorator.getBounds(); + // + result = new Image(Display.getCurrent(), bib.width, bib.height); + // + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + if (corner == TOP_LEFT) { + gc.drawImage(decorator, 0, 0); + } else if (corner == TOP_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, 0); + } else if (corner == BOTTOM_LEFT) { + gc.drawImage(decorator, 0, bib.height - dib.height); + } else if (corner == BOTTOM_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); + } + gc.dispose(); + // + decoratedMap.put(decorator, result); + } + return result; + } + /** + * Dispose all of the cached {@link Image}'s. + */ + public static void disposeImages() { + // dispose loaded images + { + for (Image image : m_imageMap.values()) { + image.dispose(); + } + m_imageMap.clear(); + } + // dispose decorated images + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + } + //////////////////////////////////////////////////////////////////////////// + // + // Font + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps font names to fonts. + */ + private static Map m_fontMap = new HashMap(); + /** + * Maps fonts to their bold versions. + */ + private static Map m_fontToBoldFontMap = new HashMap(); + /** + * Returns a {@link Font} based on its name, height and style. + * + * @param name + * the name of the font + * @param height + * the height of the font + * @param style + * the style of the font + * @return {@link Font} The font matching the name, height and style + */ + public static Font getFont(String name, int height, int style) { + return getFont(name, height, style, false, false); + } + /** + * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline + * flags are also supported. + * + * @param name + * the name of the font + * @param size + * the size of the font + * @param style + * the style of the font + * @param strikeout + * the strikeout flag (warning: Windows only) + * @param underline + * the underline flag (warning: Windows only) + * @return {@link Font} The font matching the name, height, style, strikeout and underline + */ + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; + Font font = m_fontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ + Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + } + } catch (Throwable e) { + System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + font = new Font(Display.getCurrent(), fontData); + m_fontMap.put(fontName, font); + } + return font; + } + /** + * Returns a bold version of the given {@link Font}. + * + * @param baseFont + * the {@link Font} for which a bold version is desired + * @return the bold version of the given {@link Font} + */ + public static Font getBoldFont(Font baseFont) { + Font font = m_fontToBoldFontMap.get(baseFont); + if (font == null) { + FontData fontDatas[] = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); + m_fontToBoldFontMap.put(baseFont, font); + } + return font; + } + /** + * Dispose all of the cached {@link Font}'s. + */ + public static void disposeFonts() { + // clear fonts + for (Font font : m_fontMap.values()) { + font.dispose(); + } + m_fontMap.clear(); + // clear bold fonts + for (Font font : m_fontToBoldFontMap.values()) { + font.dispose(); + } + m_fontToBoldFontMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Cursor + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps IDs to cursors. + */ + private static Map m_idToCursorMap = new HashMap(); + /** + * Returns the system cursor matching the specific ID. + * + * @param id + * int The ID value for the cursor + * @return Cursor The system cursor matching the specific ID + */ + public static Cursor getCursor(int id) { + Integer key = Integer.valueOf(id); + Cursor cursor = m_idToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_idToCursorMap.put(key, cursor); + } + return cursor; + } + /** + * Dispose all of the cached cursors. + */ + public static void disposeCursors() { + for (Cursor cursor : m_idToCursorMap.values()) { + cursor.dispose(); + } + m_idToCursorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // General + // + //////////////////////////////////////////////////////////////////////////// + /** + * Dispose of cached objects and their underlying OS resources. This should only be called when the cached + * objects are no longer needed (e.g. on application shutdown). + */ + public static void dispose() { + disposeColors(); + disposeImages(); + disposeFonts(); + disposeCursors(); + } +} \ No newline at end of file diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/.project b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/.project new file mode 100644 index 00000000..2085d162 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/.project @@ -0,0 +1,17 @@ + + + AsposeCellsEclipseSite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/site.xml b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/site.xml new file mode 100644 index 00000000..f800d3b2 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/AsposeCellsEclipseSite/site.xml @@ -0,0 +1,14 @@ + + + + Aspose.Cells Maven Project wizard creates Maven Project for using Aspose.Cells for Java API within Eclipse IDE. +"Aspose.Cells for Java is an award-winning Excel Spreadsheet component that allows Java developers to embed the ability to read, write and manipulate Excel® spreadsheets (XLS, XLSX, XLSM, XLSB, XLTX, SpreadsheetML, CSV, ODS), HTML, MHTML, PDF and image file formats into their own Java applications without needing to rely on Microsoft Excel®. +With Aspose.Cells for Java developers can export data, format spreadsheets to the most granular level, import images, create charts, apply and calculate complex formulas, stream Excel® data" +Aspose.Cells Maven Project wizard fetch and configures the latest Maven dependency reference of Aspose.Cells for Java from the Aspose Cloud Maven Repository. +The wizard also gives you option to download the Code Examples to use Aspose.Cells for Java API. + + + + + + diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/LICENSE b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/LICENSE new file mode 100644 index 00000000..f83cc4c8 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2001-2016 Aspose Pty Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/README.md b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/README.md new file mode 100644 index 00000000..9f940ac6 --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/README.md @@ -0,0 +1,41 @@ +## Aspose.Cell Java for Eclipse (Maven) + +The project is **Eclipse IDE plugin** which lets developers to use [Aspose.Cells for Java](http://goo.gl/gtvhlQ) in their Maven based Java projects. + +## Who is supposed to use this **Plugin?** + +The Plugin intended for developers using Maven platform for Java developments and want to use [Aspose.Cells for Java](http://goo.gl/gtvhlQ) in their projects. + +**NOTE:** [Aspose.Cells for Java](http://goo.gl/gtvhlQ) is Java API developed by [Aspose](http://aspose.com) that offers easy Microsoft Excel spreadsheets creation and manipulation right from within Java Projects. For the API detailed features list check the [link](http://goo.gl/gtvhlQ). + +## **Features** + +The plugin provides following features to work with [Aspose.Cells for Java](http://goo.gl/gtvhlQ) API within **Eclipse IDE** comfortably: + +### Aspose.Cells Maven Project (wizard) +![plugin title shot](http://i.imgur.com/DRPRN7Q.png) +* By using this wizard plugin creates Maven project for using [Aspose.Cells for Java](http://goo.gl/gtvhlQ) from **New -> Project -> Maven-> Aspose.Cells Maven Project** +* The wizard will also give option for downloading latest available Code Examples for using the API. + +### Aspose.Cells Code Example (wizard) +![plugin title shot](http://i.imgur.com/LyNvq1r.png) +* By using this wizard plugin lets you copy the downloaded Code Examples into your project for using [Aspose.Cells for Java](http://goo.gl/gtvhlQ) from **New -> Other -> Java -> Aspose.Cells Code Example** +* The wizard will also look for and updates for newly available Code Examples from [Aspose.Cells for Java examples repository.](https://goo.gl/uxznrb) + **NOTE:** Selected Code Examples (category) source codes will be copied under **"com.aspose.cells.examples"** package. Resources needed for running examples will be copied to the corresponding directory (package) within **"src/main/resources"**. + +### Other Features + +* Supports latest **Eclipse Mars.1 (4.5.1)** version +* Compatible with **Mac**, **Linux Flavors** and **Windows** +* Native IDE user experience +* Open Source + +## What is Aspose.Cells Java API? + +**Aspose.Cells for Java** is an award-winning Excel Spreadsheet component that allows Java developers to embed the ability to read, write and manipulate Excel® spreadsheets (XLS, XLSX, XLSM, XLSB, XLTX, SpreadsheetML, CSV, ODS), HTML, MHTML, PDF and image file formats into their own Java applications without needing to rely on Microsoft Excel®. + +For more info about the **Aspose.Cells for Java API**, [please check the api documentation - click here](http://goo.gl/gtvhlQ) + +## Plugin Documentation + +For the most complete documentation, [Please check this WIKI](http://www.aspose.com/docs/display/cellsjava/Aspose.Cells+Java+for+Eclipse+%28Maven%29) diff --git a/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/Release Notes.html b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/Release Notes.html new file mode 100644 index 00000000..f6f773ee --- /dev/null +++ b/Plugins/Aspose-Cells-Java-for-Eclipse(Maven)/Release Notes.html @@ -0,0 +1,17 @@ + + + +Aspose.Cells Java for Eclipse (Maven) - Release Notes + + + + +Aspose.Cells Java for Eclipse (Maven) - v1.0.0 +

This is new Plugin for Eclipse IDE by Aspose. The Plugin intended for developers using Maven platform for Java developments and want to use Aspose.Cells for Java in their projects.

+

NOTE: Aspose.Cells for Java is Java API developed by Aspose that offers easy Microsoft Excel spreadsheets creation and manipulation right from within Java Projects. For the API detailed features list check the link. +

The plugin provides following features to work with Aspose.Cells for Java API within Eclipse IDE comfortably: +

+ + \ No newline at end of file