diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/LICENSE b/Plugins/Aspose.Slides Java (Maven) for NetBeans/LICENSE new file mode 100644 index 00000000..5d8a0415 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/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. \ No newline at end of file diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/README.md b/Plugins/Aspose.Slides Java (Maven) for NetBeans/README.md new file mode 100644 index 00000000..4ed927cd --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/README.md @@ -0,0 +1,44 @@ +## Aspose.Slides Java (Maven) for NetBeans + +This project is **NetBeans IDE plugin** which lets developers use [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) in their Maven based Java projects. + +## Who is supposed to use this **Plugin?** + +This plugin is intended for developers using Maven platform for Java developments and want to use [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) in their projects. + +**NOTE:** [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) is Java API developed by [Aspose](http://aspose.com) that enables Java applications to read, write and manipulate PowerPoint documents (PPT, PPTX, POS, PPS, POTX, PPSX) PDF, HTML and image file formats without using Microsoft PowerPoint. For the API detailed features list check the [link](http://www.aspose.com/java/powerpoint-component.aspx). + +## **Features** + +The plugin provides following features to work with [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) API within **NetBeans IDE** comfortably: + +### Aspose.Slides Maven Project (wizard) +![plugin title shot](http://i.imgur.com/WgqE1lT.png) + +* By using this wizard plugin creates Maven project for using [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) from **New Project -> Maven-> Aspose.Slides Maven Project** +* The wizard will also give option for downloading latest available Code Examples for using the API. + +### Aspose.Slides Code Example (wizard) +![plugin title shot](http://i.imgur.com/IFie2Rq.png) +* By using this wizard plugin lets you copy the downloaded Code Examples into your project for using [Aspose.Slides for Java](http://www.aspose.com/java/powerpoint-component.aspx) from **New File -> Java -> Aspose.Slides Code Example** +* The wizard will also look for and updates for newly available Code Examples from [Aspose.Slides for Java examples repository.](https://github.com/aspose-slides/Aspose.Slides-for-Java/tree/master/Examples) + **NOTE:** Selected Code Examples (category) source codes will be copied under **"com.aspose.slides.examples"** package. Resources needed for running examples will be copied to the corresponding directory (package) within **"src/main/resources"**. + +### Other Features + +* Supports latest **NetBeans 8.1** version +* Compatible with **Mac**, **Linux Flavors** and **Windows** +* Native IDE user experience +* Open Source + +## What is Aspose.Slides Java API? + +**Aspose.Slides for Java** is a unique PowerPoint management component that enables Java applications to read, write and manipulate PowerPoint documents (PPT, PPTX, POS, PPS, POTX, PPSX) PDF, HTML and image file formats without using Microsoft PowerPoint. + +**Aspose.Slides for Java** is the first and only Java component that provides functionality to manage PowerPoint documents within your own applications. As with all Aspose Java components, Aspose.Slides for Java is written in pure Java, incredibly priced and lightning fast. + +For more info about the **Aspose.Slides for Java API**, [please check the api documentation - click here](http://www.aspose.com/java/powerpoint-component.aspx) + +## Plugin Documentation + +For the most complete documentation, [Please check Aspose Docs](http://www.aspose.com/docs/display/slidesjava/Aspose.Slides+Java+for+NetBeans+-+Maven) \ No newline at end of file diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/Release Notes.html b/Plugins/Aspose.Slides Java (Maven) for NetBeans/Release Notes.html new file mode 100644 index 00000000..15a396a0 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/Release Notes.html @@ -0,0 +1,17 @@ + + + +Aspose.Slides Java (Maven) for NetBeans - Release Notes + + + + +Aspose.Slides Java (Maven) for NetBeans - v1.0 +

This is new Plugin for NetBeans IDE by Aspose. This plugin is intended for developers using Maven platform for Java developments and want to use Aspose.Slides for Java in their projects.

+

NOTE: Aspose.Slides for Java is Java API developed by Aspose that enables Java applications to read, write and manipulate PowerPoint documents (PPT, PPTX, POS, PPS, POTX, PPSX) PDF, HTML and image file formats without using Microsoft PowerPoint. For the API detailed features list check the link. +

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

+ + \ No newline at end of file diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Aspose.png b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Aspose.png new file mode 100644 index 00000000..b4031271 Binary files /dev/null and b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Aspose.png differ diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.form b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.form new file mode 100644 index 00000000..66296a6d --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.form @@ -0,0 +1,347 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.java new file mode 100644 index 00000000..3ec560e0 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicPanelVisual.java @@ -0,0 +1,600 @@ +package com.aspose.slides.maven; + +import static com.aspose.slides.maven.Bundle.TXT_MavenProjectName; +import java.awt.Image; +import java.io.File; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.Document; +import org.netbeans.spi.project.ui.support.ProjectChooser; +import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; +import org.openide.filesystems.FileUtil; +import org.openide.util.NbBundle; + +/** + * @author Adeel Ilyas + */ +public class AsposeMavenBasicPanelVisual extends JPanel implements DocumentListener { + + /** + * + */ + public static final String PROP_PROJECT_NAME = "projectName"; + + /** + * + */ + public static final String PROP_GROUP_ID = "groupId"; + + private AsposeMavenBasicWizardPanel panel; + private boolean txtPackageCustom = false; + + /** + * + * @param panel + */ + public AsposeMavenBasicPanelVisual(AsposeMavenBasicWizardPanel panel) { + initComponents(); + this.panel = panel; + // Register listener on the textFields to make the automatic updates + projectNameTextField.getDocument().addDocumentListener(this); + projectLocationTextField.getDocument().addDocumentListener(this); + txtGroupId.getDocument().addDocumentListener(this); + txtPackage.getDocument().addDocumentListener(this); + txtVersion.getDocument().addDocumentListener(this); + txtGroupId.setText(MavenSettings.getDefault().getLastArchetypeGroupId()); + txtVersion.setText(MavenSettings.getDefault().getLastArchetypeVersion()); + } + + /** + * + * @return + */ + public String getProjectName() { + return this.projectNameTextField.getText(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + projectNameLabel = new javax.swing.JLabel(); + projectNameTextField = new javax.swing.JTextField(); + projectLocationLabel = new javax.swing.JLabel(); + projectLocationTextField = new javax.swing.JTextField(); + browseButton = new javax.swing.JButton(); + createdFolderLabel = new javax.swing.JLabel(); + createdFolderTextField = new javax.swing.JTextField(); + lblPackage = new javax.swing.JLabel(); + txtVersion = new javax.swing.JTextField(); + lblVersion = new javax.swing.JLabel(); + txtGroupId = new javax.swing.JTextField(); + lblGroupId = new javax.swing.JLabel(); + lblArtifactId = new javax.swing.JLabel(); + txtArtifactId = new javax.swing.JTextField(); + txtPackage = new javax.swing.JTextField(); + lblPackage1 = new javax.swing.JLabel(); + jCheckBox1 = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + + projectNameLabel.setLabelFor(projectNameTextField); + org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.projectNameLabel.text")); // NOI18N + + projectNameTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + projectNameTextFieldActionPerformed(evt); + } + }); + + projectLocationLabel.setLabelFor(projectLocationTextField); + org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.projectLocationLabel.text")); // NOI18N + + projectLocationTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + projectLocationTextFieldActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.browseButton.text")); // NOI18N + browseButton.setActionCommand(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.browseButton.actionCommand")); // NOI18N + browseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + browseButtonActionPerformed(evt); + } + }); + + createdFolderLabel.setLabelFor(createdFolderTextField); + org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.createdFolderLabel.text")); // NOI18N + + createdFolderTextField.setEditable(false); + createdFolderTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + createdFolderTextFieldActionPerformed(evt); + } + }); + + lblPackage.setLabelFor(txtPackage); + org.openide.awt.Mnemonics.setLocalizedText(lblPackage, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.lblPackage.text")); // NOI18N + + txtVersion.setText(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.txtVersion.text")); // NOI18N + txtVersion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtVersionActionPerformed(evt); + } + }); + + lblVersion.setLabelFor(txtVersion); + org.openide.awt.Mnemonics.setLocalizedText(lblVersion, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.lblVersion.text")); // NOI18N + + txtGroupId.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtGroupIdActionPerformed(evt); + } + }); + + lblGroupId.setLabelFor(txtGroupId); + org.openide.awt.Mnemonics.setLocalizedText(lblGroupId, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.lblGroupId.text")); // NOI18N + + lblArtifactId.setLabelFor(txtArtifactId); + org.openide.awt.Mnemonics.setLocalizedText(lblArtifactId, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.lblArtifactId.text")); // NOI18N + + txtArtifactId.setEditable(false); + txtArtifactId.setEnabled(false); + txtArtifactId.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtArtifactIdActionPerformed(evt); + } + }); + + txtPackage.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtPackageActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(lblPackage1, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.lblPackage1.text")); // NOI18N + + jCheckBox1.setLabel(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.jCheckBox1.label")); // NOI18N + jCheckBox1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox1ActionPerformed(evt); + } + }); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/long-banner.png"))); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.text")); // NOI18N + jLabel1.setAlignmentY(0.0F); + jLabel1.setDoubleBuffered(true); + jLabel1.setIconTextGap(0); + jLabel1.setMaximumSize(new java.awt.Dimension(32767, 32767)); + jLabel1.setName(""); // NOI18N + jLabel1.setOpaque(true); + jLabel1.addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentResized(java.awt.event.ComponentEvent evt) { + jLabel1ComponentResized(evt); + } + }); + + jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.jLabel2.text")); // NOI18N + + jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.jLabel3.text")); // NOI18N + jLabel3.setToolTipText(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.jLabel3.toolTipText")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(lblVersion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lblGroupId, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lblArtifactId, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE) + .addComponent(lblPackage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(createdFolderLabel) + .addComponent(projectLocationLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtArtifactId) + .addComponent(txtGroupId) + .addComponent(txtVersion) + .addComponent(txtPackage) + .addComponent(createdFolderTextField, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(projectLocationTextField)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPackage1) + .addGap(31, 31, 31)) + .addComponent(browseButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addComponent(projectNameLabel) + .addGap(18, 18, 18) + .addComponent(projectNameTextField) + .addGap(84, 84, 84)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jCheckBox1)) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(projectNameLabel) + .addComponent(projectNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(6, 6, 6) + .addComponent(projectLocationLabel)) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(projectLocationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(browseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(createdFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(createdFolderLabel)) + .addGap(10, 10, 10) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtArtifactId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblArtifactId)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtGroupId, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblGroupId)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblVersion) + .addComponent(txtVersion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lblPackage) + .addComponent(lblPackage1)) + .addComponent(txtPackage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jCheckBox1) + .addGap(21, 21, 21)) + ); + + txtVersion.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.txtVersion.AccessibleContext.accessibleName")); // NOI18N + txtGroupId.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.txtGroupId.AccessibleContext.accessibleName")); // NOI18N + txtPackage.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(AsposeMavenBasicPanelVisual.class, "AsposeMavenBasicPanelVisual.txtPackage.AccessibleContext.accessibleName")); // NOI18N + }// //GEN-END:initComponents + + private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed + String command = evt.getActionCommand(); + if ("BROWSE".equals(command)) { + JFileChooser chooser = new JFileChooser(); + FileUtil.preventFileChooserSymlinkTraversal(chooser, null); + chooser.setDialogTitle("Select Project Location"); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + String path = this.projectLocationTextField.getText(); + if (path.length() > 0) { + File f = new File(path); + if (f.exists()) { + chooser.setSelectedFile(f); + } + } + if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { + File projectDir = chooser.getSelectedFile(); + projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath()); + } + panel.fireChangeEvent(); + } + + }//GEN-LAST:event_browseButtonActionPerformed + + private void projectNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectNameTextFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_projectNameTextFieldActionPerformed + + private void projectLocationTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_projectLocationTextFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_projectLocationTextFieldActionPerformed + + private void createdFolderTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createdFolderTextFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_createdFolderTextFieldActionPerformed + + private void txtArtifactIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtArtifactIdActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txtArtifactIdActionPerformed + + private void txtGroupIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtGroupIdActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txtGroupIdActionPerformed + + private void txtPackageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPackageActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txtPackageActionPerformed + + private void txtVersionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtVersionActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txtVersionActionPerformed + + private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jCheckBox1ActionPerformed + private final ImageIcon icon = new ImageIcon(getClass().getResource("/resources/long-banner.png")); + private void jLabel1ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jLabel1ComponentResized + int labelwidth = jLabel1.getWidth(); + int labelheight = jLabel1.getHeight(); + Image img = icon.getImage(); + jLabel1.setIcon(new ImageIcon(img.getScaledInstance(labelwidth, labelheight, Image.SCALE_FAST))); + }//GEN-LAST:event_jLabel1ComponentResized + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton browseButton; + private javax.swing.JLabel createdFolderLabel; + private javax.swing.JTextField createdFolderTextField; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel lblArtifactId; + private javax.swing.JLabel lblGroupId; + private javax.swing.JLabel lblPackage; + private javax.swing.JLabel lblPackage1; + private javax.swing.JLabel lblVersion; + private javax.swing.JLabel projectLocationLabel; + private javax.swing.JTextField projectLocationTextField; + private javax.swing.JLabel projectNameLabel; + private javax.swing.JTextField projectNameTextField; + private javax.swing.JTextField txtArtifactId; + private javax.swing.JTextField txtGroupId; + private javax.swing.JTextField txtPackage; + private javax.swing.JTextField txtVersion; + // End of variables declaration//GEN-END:variables + + @Override + public void addNotify() { + super.addNotify(); + //same problem as in 31086, initial focus on Cancel button + projectNameTextField.requestFocus(); + } + + boolean valid(WizardDescriptor wizardDescriptor) { + + if (projectNameTextField.getText().length() == 0) { + // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_ERROR_MESSAGE: + wizardDescriptor.putProperty("WizardPanel_errorMessage", + "Project Name is not a valid folder name"); + return false; // Display name not specified + } + File f = FileUtil.normalizeFile(new File(projectLocationTextField.getText()).getAbsoluteFile()); + if (projectLocationTextField.getText().trim().length() == 0 || !f.isDirectory()) { + String message = "Project Folder is not a valid path"; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + if (txtVersion.getText().isEmpty()) { + String message = "Version may not be empty"; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + if (txtGroupId.getText().isEmpty()) { + String message = "GroupdId may not be empty"; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + + final File destFolder = FileUtil.normalizeFile(new File(createdFolderTextField.getText()).getAbsoluteFile()); + + File projLoc = destFolder; + while (projLoc != null && !projLoc.exists()) { + projLoc = projLoc.getParentFile(); + } + if (projLoc == null || !projLoc.canWrite()) { + wizardDescriptor.putProperty("WizardPanel_errorMessage", + "Project Folder cannot be created"); + return false; + } + + if (FileUtil.toFileObject(projLoc) == null) { + String message = "Project Folder is not a valid path"; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + + File[] kids = destFolder.listFiles(); + if (destFolder.exists() && kids != null && kids.length > 0) { + // Folder exists and is not empty + wizardDescriptor.putProperty("WizardPanel_errorMessage", + "Project Folder already exists and is not empty"); + return false; + } + + String packageName = txtPackage.getText().trim(); + if (!(packageName.equals("") + || packageName.matches("([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*"))) { + String message = "Package name is invalid"; + wizardDescriptor.putProperty("WizardPanel_errorMessage", message); + return false; + } + + wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); + return true; + } + + void store(WizardDescriptor d) { + String name = projectNameTextField.getText().trim(); + String folder = createdFolderTextField.getText().trim(); + String location = projectLocationTextField.getText().trim(); + + String groupId = txtGroupId.getText().trim(); + MavenSettings.getDefault().setLastArchetypeGroupId(txtGroupId.getText().trim()); + String artifactId = txtArtifactId.getText().trim(); + String version = txtVersion.getText().trim(); + MavenSettings.getDefault().setLastArchetypeVersion(txtVersion.getText().trim()); + String startjupPackage = txtPackage.getText().trim(); + + boolean downloadExamples = jCheckBox1.isSelected(); + + d.putProperty("projdir", new File(folder)); + d.putProperty("projdirName", folder); + d.putProperty("projLocation", location); + d.putProperty("name", name); + + d.putProperty("groupId", groupId); + d.putProperty("artifactId", artifactId); + d.putProperty("version", version); + d.putProperty("package", startjupPackage); + + d.putProperty("downloadExamples", downloadExamples); + + } + + @NbBundle.Messages({"# {0} - project count", "TXT_MavenProjectName=asposemavenproject{0}"}) + void read(WizardDescriptor settings) { + + File projectLocation = (File) settings.getProperty("projdir"); + if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) { + projectLocation = ProjectChooser.getProjectsFolder(); + } else { + projectLocation = projectLocation.getParentFile(); + } + this.projectLocationTextField.setText(projectLocation.getAbsolutePath()); + + String projectName = (String) settings.getProperty("name"); + + if (projectName == null) { + int baseCount = 1; + while ((projectName = validFreeProjectName(projectLocation, TXT_MavenProjectName(baseCount))) == null) { + baseCount++; + } + } + + this.projectNameTextField.setText(projectName); + this.projectNameTextField.selectAll(); + + String gr = (String) settings.getProperty("groupId"); + if (gr != null) { + txtGroupId.setText(gr); + } + String ver = (String) settings.getProperty("version"); + if (ver != null) { + txtVersion.setText(ver); + } + } + + private String validFreeProjectName(File parentFolder, String name) { + File file = new File(parentFolder, name); + return file.exists() ? null : name; + } + + void validate(WizardDescriptor d) throws WizardValidationException { + // nothing to validate + } + + @Override + public void changedUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText()); + } + + if (this.txtGroupId.getDocument() == e.getDocument()) { + firePropertyChange(PROP_GROUP_ID, null, this.txtGroupId.getText()); + } + + } + + @Override + public void insertUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText()); + } + if (this.txtGroupId.getDocument() == e.getDocument()) { + firePropertyChange(PROP_GROUP_ID, null, this.txtGroupId.getText()); + } + } + + @Override + public void removeUpdate(DocumentEvent e) { + updateTexts(e); + if (this.projectNameTextField.getDocument() == e.getDocument()) { + firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText()); + } + if (this.txtGroupId.getDocument() == e.getDocument()) { + firePropertyChange(PROP_GROUP_ID, null, this.txtGroupId.getText()); + } + } + + private void updateTexts(DocumentEvent e) { + + Document doc = e.getDocument(); + String projectName = projectNameTextField.getText(); + if (doc == txtPackage.getDocument()) { + // Looking for a custom change in package name by the user + txtPackageCustom = txtPackage.getText().trim().length() != 0; + } + if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) { + // Change in the project name + + String projectFolder = projectLocationTextField.getText(); + txtArtifactId.setText(projectName); + + createdFolderTextField.setText(projectFolder + File.separatorChar + projectName); + + } + if (!txtPackageCustom && (doc == txtGroupId.getDocument() || doc == projectNameTextField.getDocument())) { + txtPackage.getDocument().removeDocumentListener(this); + txtPackage.setText(getPackageName(txtGroupId.getText() + "." + txtArtifactId.getText().replace("-", "."))); //NOI18N + txtPackage.getDocument().addDocumentListener(this); + } + panel.fireChangeEvent(); // Notify that the panel changed + } + + static String getPackageName(String displayName) { + StringBuilder builder = new StringBuilder(); + boolean firstLetter = true; + for (int i = 0; i < displayName.length(); i++) { + char c = displayName.charAt(i); + if ((!firstLetter && Character.isJavaIdentifierPart(c)) + || (firstLetter && Character.isJavaIdentifierStart(c))) { + firstLetter = false; + if (Character.isUpperCase(c)) { + c = Character.toLowerCase(c); + } + builder.append(c); + continue; + } + if (!firstLetter && c == '.') { + firstLetter = true; + builder.append(c); + } + } + String toRet = builder.length() == 0 ? "pkg" : builder.toString(); //NOI18N + return toRet; + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicWizardPanel.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicWizardPanel.java new file mode 100644 index 00000000..28481c96 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenBasicWizardPanel.java @@ -0,0 +1,146 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.slides.maven; + +import java.awt.Component; +import java.util.HashSet; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; + +/** + * @author Adeel Ilyas + */ +public class AsposeMavenBasicWizardPanel implements WizardDescriptor.Panel, + WizardDescriptor.ValidatingPanel { + + private WizardDescriptor wizardDescriptor; + private AsposeMavenBasicPanelVisual component; + + /** + * + */ + public AsposeMavenBasicWizardPanel() { + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + if (component == null) { + component = new AsposeMavenBasicPanelVisual(this); + component.setName(NbBundle.getMessage(AsposeMavenBasicWizardPanel.class, "LBL_CreateProjectStep")); + } + return component; + } + + /** + * + * @return + */ + @Override + public HelpCtx getHelp() { + // Show no Help button for this panel: + return HelpCtx.DEFAULT_HELP; + + } + + /** + * + * @return + */ + @Override + public boolean isValid() { + getComponent(); + return component.valid(wizardDescriptor); + } + + private final Set listeners = new HashSet(1); // or can use ChangeSupport in NB 6.0 + + /** + * + * @param l + */ + @Override + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + + /** + * + * @param l + */ + @Override + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + + /** + * + */ + protected final void fireChangeEvent() { + Set ls; + synchronized (listeners) { + ls = new HashSet<>(listeners); + } + ChangeEvent ev = new ChangeEvent(this); + for (ChangeListener l : ls) { + l.stateChanged(ev); + } + } + + /** + * + * @param settings + */ + @Override + public void readSettings(Object settings) { + + wizardDescriptor = (WizardDescriptor) settings; + component.read(wizardDescriptor); + } + + /** + * + * @param settings + */ + @Override + public void storeSettings(Object settings) { + + WizardDescriptor d = (WizardDescriptor) settings; + component.store(d); + } + + /** + * + * @return + */ + public boolean isFinishPanel() { + return true; + } + + /** + * + * @throws WizardValidationException + */ + @Override + public void validate() throws WizardValidationException { + + getComponent(); + component.validate(wizardDescriptor); + } + +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProject.zip b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProject.zip new file mode 100644 index 00000000..002b84f0 Binary files /dev/null and b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProject.zip differ diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProjectWizardIterator.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProjectWizardIterator.java new file mode 100644 index 00000000..e33c7077 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProjectWizardIterator.java @@ -0,0 +1,399 @@ +package com.aspose.slides.maven; + +import com.aspose.slides.maven.artifacts.Metadata; +import com.aspose.slides.maven.utils.AsposeConstants; +import com.aspose.slides.maven.utils.AsposeJavaAPI; +import com.aspose.slides.maven.utils.AsposeMavenProjectManager; +import static com.aspose.slides.maven.utils.AsposeMavenProjectManager.getAsposeProjectMavenDependencies; +import com.aspose.slides.maven.utils.AsposeSlidesJavaAPI; +import com.aspose.slides.maven.utils.TasksExecutor; +import java.awt.Component; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.api.templates.TemplateRegistration; +import org.netbeans.spi.project.ui.support.ProjectChooser; +import org.netbeans.spi.project.ui.templates.support.Templates; +import org.openide.WizardDescriptor; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; +import org.openide.xml.XMLUtil; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * @author Adeel Ilyas + */ +@TemplateRegistration( + folder = "Project/Maven2", + displayName = "#Aspose_displayName", + description = "AsposeSlidesMavenDescription.html", + iconBase = "com/aspose/slides/maven/Aspose.png", + position = 1, + content = "AsposeMavenProject.zip") +@Messages("Aspose_displayName=Aspose.Slides Maven Project") + +public class AsposeMavenProjectWizardIterator implements WizardDescriptor.ProgressInstantiatingIterator { + + private int index; + private WizardDescriptor.Panel[] panels; + private WizardDescriptor wiz; + List list = new ArrayList<>(); + + /** + * + */ + public AsposeMavenProjectWizardIterator() { + } + + /** + * + * @return + */ + public static AsposeMavenProjectWizardIterator createIterator() { + return new AsposeMavenProjectWizardIterator(); + } + + private WizardDescriptor.Panel[] createPanels() { + + return new WizardDescriptor.Panel[]{ + new AsposeMavenBasicWizardPanel() + }; + } + + /** + * + * @return + */ + private String[] createSteps() { + return new String[]{ + NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "LBL_CreateProjectStep"), + }; + } + + /** + * + * @return + * @throws IOException + */ + @Override + public Set instantiate() throws IOException { + throw new AssertionError("instantiate(ProgressHandle) " //NOI18N + + "should have been called"); //NOI18N + } + + /** + * + * @param ph + * @return + * @throws IOException + */ + @Override + public Set instantiate(ProgressHandle ph) throws IOException { + ph.start(); + ph.switchToIndeterminate(); + ph.progress("Processing..."); + final AsposeMavenProjectManager asposeMavenProjectManager = AsposeMavenProjectManager.initialize(wiz); + final AsposeJavaAPI asposeSlidesJavaAPI = AsposeSlidesJavaAPI.initialize(asposeMavenProjectManager); + + boolean isDownloadExamplesSelected = (boolean) wiz.getProperty("downloadExamples"); + + // Downloading Aspose.Slides Java (mvn based) examples... + if (isDownloadExamplesSelected) { + TasksExecutor tasksExecutionDownloadExamples = new TasksExecutor(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressExamplesTitle")); + // Downloading Aspose API mvn based examples + tasksExecutionDownloadExamples.addNewTask(asposeMavenProjectManager.createDownloadExamplesTask(asposeSlidesJavaAPI)); + // Execute the tasks + tasksExecutionDownloadExamples.processTasks(); + } + TasksExecutor tasksExecutionRetrieve = new TasksExecutor(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressTitle")); + + // Retrieving Aspose.Slides Java Maven artifact... + tasksExecutionRetrieve.addNewTask(asposeMavenProjectManager.retrieveAsposeAPIMavenTask(asposeSlidesJavaAPI)); + + // Execute the tasks + tasksExecutionRetrieve.processTasks(); + + // Creating Maven project + ph.progress(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.projectMessage")); + + Set resultSet = new LinkedHashSet<>(); + + File projectDir = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); + projectDir.mkdirs(); + + FileObject template = Templates.getTemplate(wiz); + FileObject projectRoot = FileUtil.toFileObject(projectDir); + createAsposeMavenProject(template.getInputStream(), projectRoot); + + createStartupPackage(projectRoot); + + resultSet.add(projectRoot); + // Look for nested projects to open as well: + Enumeration e = projectRoot.getFolders(true); + while (e.hasMoreElements()) { + FileObject subfolder = e.nextElement(); + if (ProjectManager.getDefault().isProject(subfolder)) { + resultSet.add(subfolder); + } + } + + File parent = projectDir.getParentFile(); + if (parent != null && parent.exists()) { + ProjectChooser.setProjectsFolder(parent); + } + ph.finish(); + return resultSet; + } + + /** + * + * @param wiz + */ + @Override + public void initialize(WizardDescriptor wiz) { + this.wiz = wiz; + index = 0; + panels = createPanels(); + // Make sure list of steps is accurate. + String[] steps = createSteps(); + for (int i = 0; i < panels.length; i++) { + Component c = panels[i].getComponent(); + if (steps[i] == null) { + // Default step name to component name of panel. + // Mainly useful for getting the name of the target + // chooser to appear in the list of steps. + steps[i] = c.getName(); + } + if (c instanceof JComponent) { // assume Swing components + JComponent jc = (JComponent) c; + // Step #. + // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*: + jc.putClientProperty("WizardPanel_contentSelectedIndex", i); + // Step name (actually the whole list for reference). + jc.putClientProperty("WizardPanel_contentData", steps); + } + } + } + + /** + * + * @param wiz + */ + @Override + public void uninitialize(WizardDescriptor wiz) { + this.wiz.putProperty("projdir", null); + this.wiz.putProperty("name", null); + this.wiz = null; + panels = null; + } + + /** + * + * @return + */ + @Override + public String name() { + return MessageFormat.format("{0} of {1}", + new Object[]{ + index + 1, panels.length + }); + } + + /** + * + * @return + */ + @Override + public boolean hasNext() { + return index < panels.length - 1; + } + + /** + * + * @return + */ + @Override + public boolean hasPrevious() { + return index > 0; + } + + /** + * + */ + @Override + public void nextPanel() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + index++; + } + + /** + * + */ + @Override + public void previousPanel() { + if (!hasPrevious()) { + throw new NoSuchElementException(); + } + index--; + } + + /** + * + * @return + */ + @Override + public WizardDescriptor.Panel current() { + return panels[index]; + } + + /** + * + * @param l + */ + @Override + public final void addChangeListener(ChangeListener l) { + } + + /** + * + * @param l + */ + @Override + public final void removeChangeListener(ChangeListener l) { + } + + private void createAsposeMavenProject(InputStream source, FileObject projectRoot) throws IOException { + try { + ZipInputStream str = new ZipInputStream(source); + ZipEntry entry; + while ((entry = str.getNextEntry()) != null) { + if (entry.isDirectory()) { + FileUtil.createFolder(projectRoot, entry.getName()); + } else { + FileObject fo = FileUtil.createData(projectRoot, entry.getName()); + if (AsposeConstants.MAVEN_POM_XML.equals(entry.getName())) { + /* + Special handling for maven pom.xml: + 1. Defining / creating project artifacts + 2. Adding latest Aspose.Slides Maven Dependency reference into pom.xml + */ + configureProjectMavenPOM(fo, str); + } else { + writeFile(str, fo); + } + } + } + } finally { + source.close(); + } + } + + private void createStartupPackage(FileObject projectRoot) throws IOException { + String startupPackage = wiz.getProperty("package").toString().replace(".", File.separator); + + FileUtil.createFolder(projectRoot, "src" + File.separator + "main" + File.separator + "java" + File.separator + startupPackage); + } + + private static void writeFile(ZipInputStream str, FileObject fo) throws IOException { + try (OutputStream out = fo.getOutputStream()) { + FileUtil.copy(str, out); + } + } + + private void configureProjectMavenPOM(FileObject fo, ZipInputStream str) throws IOException { + + String groupId = (String) wiz.getProperty("groupId"); + String artifactId = (String) wiz.getProperty("artifactId"); + String version = (String) wiz.getProperty("version"); + + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + FileUtil.copy(str, baos); + Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null); + 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); + + try (OutputStream out = fo.getOutputStream()) { + XMLUtil.write(doc, out, "UTF-8"); + } + } catch (IOException | SAXException | DOMException ex) { + Exceptions.printStackTrace(ex); + writeFile(str, fo); + } + + } + + 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); + } + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeSlidesMavenDescription.html b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeSlidesMavenDescription.html new file mode 100644 index 00000000..9add9e45 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeSlidesMavenDescription.html @@ -0,0 +1,13 @@ + + + + + + + Aspose.Slides Maven Project wizard creates Maven Project for using Aspose.Slides for Java API within NetBeans IDE.

Aspose.Slides for Java is a unique PowerPoint management component that enables Java applications to read, write and manipulate PowerPoint documents (PPT, PPTX, POS, PPS, POTX, PPSX) PDF, HTML and image file formats without using Microsoft PowerPoint.

Aspose.Slides for Java is the first and only Java component that provides functionality to manage PowerPoint documents within your own applications. As with all Aspose Java components, Aspose.Slides for Java is written in pure Java, incredibly priced and lightning fast.

Aspose.Slides Maven Project wizard fetch and configures the latest Maven dependency reference of Aspose.Slides for Java from the Aspose Cloud Maven Repository.

The wizard also gives you option to download the Code Examples to use Aspose.Slides 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.Slides for Java API in your Project from New File -> Java -> Aspose.Slides 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.

+ + diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Bundle.properties b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Bundle.properties new file mode 100644 index 00000000..549d65ae --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/Bundle.properties @@ -0,0 +1,43 @@ +OpenIDE-Module-Name=Aspose.Slides Java (Maven) for NetBeans +LBL_CreateProjectStep=Name and Location +OpenIDE-Module-Display-Category=Base IDE +OpenIDE-Module-Long-Description=\ + Aspose.Slides Maven Project wizard creates Maven Project for using Aspose.Slides for Java API within NetBeans IDE.\ +

Aspose.Slides for Java is a unique PowerPoint management component that enables Java applications to read, write and manipulate PowerPoint documents (PPT, PPTX, POS, PPS, POTX, PPSX) PDF, HTML and image file formats without using Microsoft PowerPoint.\ +

Aspose.Slides for Java is the first and only Java component that provides functionality to manage PowerPoint documents within your own applications. \ + As with all Aspose Java components, Aspose.Slides for Java is written in pure Java, incredibly priced and lightning fast.\ +

Aspose.Slides Maven Project wizard fetch and configures the latest Maven dependency reference of Aspose.Slides for Java from the Aspose Cloud Maven Repository.\ +

The wizard also gives you option to download the Code Examples to use Aspose.Slides 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.Slides for Java API in your Project from New File -> Java -> Aspose.Slides 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.\ +

+OpenIDE-Module-Name=Aspose.Slides Java (Maven) for NetBeans +AsposeMavenPanel.createdFolderLabel.text=Project &Folder: +OpenIDE-Module-Short-Description=This plugins helps you to create Aspose.Slides Maven based project and tryout samples provided by Aspose. +AsposeMavenPanel.jLabelCommonUses.toolTipText= +AsposeMavenBasicPanelVisual.projectLocationLabel.text=Project &Location: +AsposeMavenBasicPanelVisual.browseButton.actionCommand=BROWSE +AsposeMavenBasicPanelVisual.browseButton.text=Br&owse... +AsposeMavenBasicPanelVisual.createdFolderLabel.text=Project &Folder: +AsposeMavenBasicPanelVisual.projectNameLabel.text=Project &Name: +AsposeMavenBasicPanelVisual.lblArtifactId.text=Artifact Id: +AsposeMavenBasicPanelVisual.lblGroupId.text=Group Id: +AsposeMavenBasicPanelVisual.lblVersion.text=Version: +AsposeMavenBasicPanelVisual.txtVersion.text= +AsposeMavenBasicPanelVisual.txtGroupId.AccessibleContext.accessibleName= +AsposeMavenBasicPanelVisual.txtVersion.AccessibleContext.accessibleName= +AsposeMavenBasicPanelVisual.lblPackage.text=Package: +AsposeMavenBasicPanelVisual.txtPackage.AccessibleContext.accessibleName= +AsposeMavenBasicPanelVisual.lblPackage1.text=(Optional) +AsposeMavenBasicPanelVisual.lblArtifactId.toolTipText= +AsposeManager.progressMessage=Retrieving Aspose.Slides for java - Maven Dependency... +AsposeManager.projectMessage=Creating Aspose.Slides maven project... +AsposeManager.progressTitle=Retrieving Latest Maven artifact... +AsposeManager.progressExamplesTitle=Downloading Code Examples... +AsposeManager.downloadExamplesMessage=Downloading Aspose.Slides for java - Example Source Codes... +AsposeMavenBasicPanelVisual.toolTipText=Aspose.Slides for Java API - Helps to create and manipulate Microsoft slides documents. +AsposeMavenBasicPanelVisual.text= +AsposeMavenBasicPanelVisual.jCheckBox1.label=Also Download Code Examples (for using Aspose.Slides for Java) +AsposeMavenBasicPanelVisual.jLabel2.text=Please enter project detail: +AsposeMavenBasicPanelVisual.jLabel3.text=Please enter maven artifact detail: +AsposeMavenBasicPanelVisual.jLabel3.toolTipText= diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/MavenSettings.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/MavenSettings.java new file mode 100644 index 00000000..64b2cd73 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/MavenSettings.java @@ -0,0 +1,74 @@ +package com.aspose.slides.maven; + +import java.util.prefs.Preferences; +import org.openide.util.NbPreferences; + +/** + * + * @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 Preferences getPreferences() { + return NbPreferences.forModule(MavenSettings.class); + } + + /** + * + * @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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/Metadata.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/Metadata.java new file mode 100644 index 00000000..55f29e0d --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/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.slides.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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/ObjectFactory.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/ObjectFactory.java new file mode 100644 index 00000000..fcff5376 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/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.slides.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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metada.xml b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metada.xml new file mode 100644 index 00000000..aea2fcb4 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metada.xml @@ -0,0 +1,17 @@ + + + com.aspose + aspose-slides + 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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metadata.xsd b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metadata.xsd new file mode 100644 index 00000000..6e3d358e --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/artifacts/maven-metadata.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExamplePanel.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExamplePanel.java new file mode 100644 index 00000000..e3be4dd4 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExamplePanel.java @@ -0,0 +1,322 @@ +/* + * 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.slides.maven.examples; + +import com.aspose.slides.maven.utils.AbstractTask; +import com.aspose.slides.maven.utils.AsposeConstants; +import com.aspose.slides.maven.utils.AsposeMavenProjectManager; +import com.aspose.slides.maven.utils.AsposeSlidesJavaAPI; +import javax.swing.*; +import javax.swing.tree.TreePath; +import java.awt.*; +import javax.swing.tree.DefaultTreeModel; +import org.netbeans.api.progress.BaseProgressUtils; +import org.openide.WizardDescriptor; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; + +public final class AsposeExamplePanel extends JPanel { + + AsposeExampleWizardPanel panel; + + /** + * Creates new form AsposeExamplePanel + * + * @param panel + */ + public AsposeExamplePanel(AsposeExampleWizardPanel panel) { + initComponents(); + initComponentsUser(); + this.panel = panel; + + } + + private void initComponentsUser() { + + CustomMutableTreeNode top = new CustomMutableTreeNode(""); + + DefaultTreeModel model = (DefaultTreeModel) getExamplesTree().getModel(); + model.setRoot(top); + model.reload(top); + + validateDialog(); + } + + @Override + public String getName() { + return AsposeConstants.API_NAME + " for Java API - Code Examples"; + } + + private void initComponents() { + + jPanel1 = new JPanel(); + jLabel2 = new JLabel(); + componentSelection = new JComboBox(); + + jLabel1 = new JLabel(); + jLabelMessage = new JLabel(); + jLabelMessage.setOpaque(true); + jScrollPane1 = new JScrollPane(); + + examplesTree = new JTree(); + + jPanel1.setBackground(new Color(255, 255, 255)); + jPanel1.setBorder(BorderFactory.createEtchedBorder()); + jPanel1.setForeground(new Color(255, 255, 255)); + + jLabel2.setIcon(icon); // NOI18N + jLabel2.setText(""); + jLabel2.setHorizontalAlignment(SwingConstants.CENTER); + jLabel2.setDoubleBuffered(true); + jLabel2.setOpaque(true); + jLabel2.addComponentListener(new java.awt.event.ComponentAdapter() { + @Override + public void componentResized(java.awt.event.ComponentEvent evt) { + jLabel2ComponentResized(evt); + } + }); + + GroupLayout jPanel1Layout = new GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup() + .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 390, Short.MAX_VALUE) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup() + .addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2) + .addGap(0, 0, Short.MAX_VALUE)) + ); + componentSelection.setModel(new DefaultComboBoxModel()); + + componentSelection.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + @Override + public void propertyChange(java.beans.PropertyChangeEvent evt) { + componentSelection_Propertychanged(evt); + } + }); + jLabel1.setText(NbBundle.getMessage(AsposeExamplePanel.class, "AsposeExample.jLabel1_text")); + jLabelMessage.setText(""); + examplesTree.addMouseListener(new java.awt.event.MouseAdapter() { + @Override + //public void mouseClicked(java.awt.event.MouseEvent evt) { //here + public void mousePressed(java.awt.event.MouseEvent evt) { + examplesTree_clicked(evt); + } + }); + jScrollPane1.setViewportView(examplesTree); + + GroupLayout layout = new GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(componentSelection, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabelMessage, GroupLayout.PREFERRED_SIZE, 361, GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(componentSelection, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 229, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelMessage, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + ); + } + + + private void jLabel2ComponentResized(java.awt.event.ComponentEvent evt) { + int labelwidth = jLabel2.getWidth(); + int labelheight = jLabel2.getHeight(); + Image img = icon.getImage(); + jLabel2.setIcon(new ImageIcon(img.getScaledInstance(labelwidth, labelheight, Image.SCALE_FAST))); + } + + /** + * + * @return + */ + public String getSelectedProjectRootPath() { + return AsposeMavenProjectManager.getInstance().getProjectDir().getPath(); + } + + void read() { + retrieveAPIDependency(); + retrieveAPIExamples(); + } + + /** + * + * @return + */ + private boolean retrieveAPIDependency() { + getComponentSelection().removeAllItems(); + String versionNo = AsposeMavenProjectManager.getInstance().getDependencyVersionFromPOM(AsposeConstants.API_MAVEN_DEPENDENCY); + if (versionNo == null) { + getComponentSelection().addItem(AsposeConstants.API_DEPENDENCY_NOT_FOUND); + } else { + getComponentSelection().addItem(versionNo); + } + return true; + } + + private void retrieveAPIExamples() { + + final String item = (String) getComponentSelection().getSelectedItem(); + + if (item != null && !item.equals(AsposeConstants.API_DEPENDENCY_NOT_FOUND)) { + + // Downloading Aspose API mvn based examples + AbstractTask downloadExamples = AsposeMavenProjectManager.getInstance().createDownloadExamplesTask(AsposeSlidesJavaAPI.getInstance()); + // Execute the tasks + BaseProgressUtils.showProgressDialogAndRun(downloadExamples, NbBundle.getMessage(AsposeExamplePanel.class, "AsposeManager.updateExamplesMessage")); + + // Populating Aspose API mvn based examples + Runnable popuplateExamples = AsposeMavenProjectManager.getInstance().populateExamplesTask(AsposeSlidesJavaAPI.getInstance(), this); + // Execute the tasks + BaseProgressUtils.showProgressDialogAndRun(popuplateExamples, NbBundle.getMessage(AsposeExamplePanel.class, "AsposeManager.populateExamplesMessage")); + + validateDialog(); + + } + + } + + boolean valid(WizardDescriptor wizardDescriptor) { + + return validateDialog(); + } + + @Override + public void validate() { + + } + + /** + * + * @return + */ + public boolean validateDialog() { + if (isExampleSelected()) { + clearMessage(); + return true; + } + final String item = (String) getComponentSelection().getSelectedItem(); + if (item == null || item.equals(AsposeConstants.API_DEPENDENCY_NOT_FOUND)) { + diplayMessage("Please first add maven dependency of " + AsposeConstants.API_NAME + " for java API", true); + return false; + } else if (!isExampleSelected()) { + diplayMessage(AsposeConstants.ASPOSE_SELECT_EXAMPLE, true); + return false; + } + clearMessage(); + return true; + } + + /** + * + * @return + */ + private boolean isExampleSelected() { + CustomMutableTreeNode comp = (CustomMutableTreeNode) getExamplesTree().getLastSelectedPathComponent(); + if (comp == null) { + return false; + } + try { + + if (!comp.isFolder()) { + return false; + } + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + return false; + } + return true; + } + + /** + * + * @param message + * @param error + */ + public void diplayMessage(String message, boolean error) { + + if (error) { + jLabelMessage.setForeground(Color.RED); + } else { + jLabelMessage.setForeground(Color.GREEN); + } + jLabelMessage.setText(message); + } + + private void clearMessage() { + jLabelMessage.setText(""); + + } + + /** + * + * @param title + * @param message + * @param buttons + * @param icon + * @return + */ + public int showMessage(String title, String message, int buttons, int icon) { + int result = JOptionPane.showConfirmDialog(null, message, title, buttons, icon); + return result; + } + + private void componentSelection_Propertychanged(java.beans.PropertyChangeEvent evt) { + + } + + private void examplesTree_clicked(java.awt.event.MouseEvent evt) { + TreePath path = getExamplesTree().getSelectionPath(); + panel.fireChangeEvent(); + } + + // Variables declaration + private JComboBox componentSelection; + private JTree examplesTree; + private JLabel jLabel1; + private JLabel jLabel2; + private JLabel jLabelMessage; + private JPanel jPanel1; + private JScrollPane jScrollPane1; + private ImageIcon icon = new ImageIcon(getClass().getResource("/resources/long-banner.png")); + // End of variables declaration + + /** + * @return the examplesTree + */ + public JTree getExamplesTree() { + return examplesTree; + } + + /** + * @return the componentSelection + */ + public JComboBox getComponentSelection() { + return componentSelection; + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizard.html b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizard.html new file mode 100644 index 00000000..e2bb0a78 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizard.html @@ -0,0 +1,13 @@ + + + + + + + Aspose.Slides Code Example wizard allows you to insert Code Examples (to use Aspose.Slides for Java API) in your Java Project.

Code Examples demonstrate Aspose.Slides for Java API uses. New Code Examples are coming out all the time!

Available Code Examples are displayed in tree format from where you can select categorically.

Selected Code Examples are added to the selected project along with their sources and required data files.

Newly added Code Examples are ready to be enhanced, all references are automatically added.

+ + diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardIterator.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardIterator.java new file mode 100644 index 00000000..f7f8f70c --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardIterator.java @@ -0,0 +1,184 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.slides.maven.examples; + +import java.awt.Component; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.templates.TemplateRegistration; +import org.openide.WizardDescriptor; +import org.openide.util.NbBundle.Messages; + +/** + * @author Adeel Ilyas + */ +@TemplateRegistration( + folder = "Classes", + displayName = "#AsposeNewFileWizardIterator_displayName", + iconBase = "com/aspose/slides/maven/Aspose.png", + position = 10, + description = "AsposeExampleWizard.html") +@Messages("AsposeNewFileWizardIterator_displayName=Aspose.Slides Code Example") +public final class AsposeExampleWizardIterator implements WizardDescriptor.InstantiatingIterator { + + private int index; + + private WizardDescriptor wizard; + private List> panels; + + private List> getPanels() { + if (panels == null) { + panels = new ArrayList<>(); + + panels.add(new AsposeExampleWizardPanel()); + String[] steps = createSteps(); + + for (int i = 0; i < panels.size(); i++) { + Component c = panels.get(i).getComponent(); + if (steps[i] == null) { + // Default step name to component name of panel. Mainly + // useful for getting the name of the target chooser to + // appear in the list of steps. + steps[i] = c.getName(); + } + if (c instanceof JComponent) { // assume Swing components + JComponent jc = (JComponent) c; + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i); + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); + jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true); + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true); + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true); + } + } + } + return panels; + } + + /** + * + * @return + * @throws IOException + */ + @Override + public Set instantiate() throws IOException { + // TODO return set of FileObject (or DataObject) you have created + return Collections.emptySet(); + } + + /** + * + * @param wizard + */ + @Override + public void initialize(WizardDescriptor wizard) { + this.wizard = wizard; + } + + /** + * + * @param wizard + */ + @Override + public void uninitialize(WizardDescriptor wizard) { + panels = null; + } + + /** + * + * @return + */ + @Override + public WizardDescriptor.Panel current() { + return getPanels().get(index); + } + + /** + * + * @return + */ + @Override + public String name() { + return index + 1 + ". from " + getPanels().size(); + } + + /** + * + * @return + */ + @Override + public boolean hasNext() { + return index < getPanels().size() - 1; + } + + /** + * + * @return + */ + @Override + public boolean hasPrevious() { + return index > 0; + } + + /** + * + */ + @Override + public void nextPanel() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + index++; + } + + /** + * + */ + @Override + public void previousPanel() { + if (!hasPrevious()) { + throw new NoSuchElementException(); + } + index--; + } + + // If nothing unusual changes in the middle of the wizard, simply: + + /** + * + * @param l + */ + @Override + public void addChangeListener(ChangeListener l) { + } + + /** + * + * @param l + */ + @Override + public void removeChangeListener(ChangeListener l) { + } + + private String[] createSteps() { + String[] beforeSteps = (String[]) wizard.getProperty("WizardPanel_contentData"); + assert beforeSteps != null : "This wizard may only be used embedded in the template wizard"; + String[] res = new String[(beforeSteps.length - 1) + panels.size()]; + for (int i = 0; i < res.length; i++) { + if (i < (beforeSteps.length - 1)) { + res[i] = beforeSteps[i]; + } else { + res[i] = panels.get(i - beforeSteps.length + 1).getComponent().getName(); + } + } + return res; + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardPanel.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardPanel.java new file mode 100644 index 00000000..63cab39a --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/AsposeExampleWizardPanel.java @@ -0,0 +1,201 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.slides.maven.examples; + +import com.aspose.slides.maven.utils.AsposeConstants; +import com.aspose.slides.maven.utils.AsposeMavenProjectManager; +import com.aspose.slides.maven.utils.AsposeSlidesJavaAPI; +import java.io.File; +import java.io.IOException; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.project.Project; +import org.netbeans.spi.project.ui.templates.support.Templates; +import org.openide.WizardDescriptor; +import org.openide.util.Exceptions; +import org.openide.util.HelpCtx; +import org.w3c.dom.NodeList; + +/** + * @author Adeel Ilyas + */ +public class AsposeExampleWizardPanel implements WizardDescriptor.Panel { + + private AsposeExamplePanel component; + private static boolean storeSettingsCalled = false; + + /** + * + * @return + */ + @Override + public AsposeExamplePanel getComponent() { + if (component == null) { + component = new AsposeExamplePanel(this); + } + return component; + } + + /** + * + * @return + */ + @Override + public HelpCtx getHelp() { + + return HelpCtx.DEFAULT_HELP; + + } + + /** + * + * @return + */ + @Override + public boolean isValid() { + // Enables Finish / OK /Next button + return component.validateDialog(); + + } + + private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 + + /** + * + * @param l + */ + @Override + public void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + + /** + * + * @param l + */ + @Override + public void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + + /** + * + */ + protected final void fireChangeEvent() { + + Iterator it; + synchronized (listeners) { + it = new HashSet<>(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + it.next().stateChanged(ev); + } + } + + /** + * + * @param wiz + */ + @Override + public void readSettings(WizardDescriptor wiz) { + Project selectedProject = Templates.getProject(wiz); + + File projdir = new File(selectedProject.getProjectDirectory().getPath()); + + wiz.putProperty("projdir", projdir); + AsposeMavenProjectManager asposeMavenProjectManager = AsposeMavenProjectManager.initialize(wiz); + AsposeSlidesJavaAPI.initialize(asposeMavenProjectManager); + component.read(); + } + + /** + * + * @param wiz + */ + @Override + public void storeSettings(WizardDescriptor wiz) { + + boolean cancelled = wiz.getValue() != WizardDescriptor.FINISH_OPTION; + if (!cancelled) { + if (!storeSettingsCalled) { + storeSettingsCalled = true; + createExample(); + } else { + storeSettingsCalled = false; + + } + } + } + + private boolean createExample() { + String projectPath = component.getSelectedProjectRootPath(); + CustomMutableTreeNode comp = getSelectedNode(); + if (comp == null || !comp.isFolder()) { + return false; + } + try { + + String sourceRepositoryExamplePath = comp.getExPath(); + if (sourceRepositoryExamplePath == null) { + return false; + } + String repositorylocation = AsposeSlidesJavaAPI.getInstance().getLocalRepositoryPath(); + String repositoryPOM_XML = repositorylocation + File.separator + "Examples" + File.separator + AsposeConstants.MAVEN_POM_XML; + + 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); + + String sourceExamplesUtilsPath = repositorylocation + File.separator + AsposeConstants.EXAMPLES_UTIL; + String destinationExamplesUtilsPath = projectPath + File.separator + sourceExamplesUtilsPath.replace(repositorylocation + File.separator + AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION, AsposeConstants.PROJECT_EXAMPLES_SOURCE_LOCATION); + + String destinationExamplePath = projectPath + File.separator + sourceRepositoryExamplePath.replace(repositorylocation + File.separator + AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION, AsposeConstants.PROJECT_EXAMPLES_SOURCE_LOCATION); + + String destinationResourcePath = projectPath + File.separator + sourceRepositoryExamplePath.replace(repositorylocation + File.separator + AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION, AsposeConstants.PROJECT_EXAMPLES_RESOURCES_LOCATION); + + String sourceRepositoryExampleResourcesPath = sourceRepositoryExamplePath.replace(AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION, AsposeConstants.GITHUB_EXAMPLES_RESOURCES_LOCATION); + + //Copying Example Category + copyExample(sourceRepositoryExamplePath, destinationExamplePath); + + //Copying Example Resoureces + copyExample(sourceRepositoryExampleResourcesPath, destinationResourcePath); + + //Copying Utils.java + AsposeMavenProjectManager.copyDirectory(new File(sourceExamplesUtilsPath + File.separator), new File(destinationExamplesUtilsPath + File.separator)); + + + + } catch (Exception ex) { + return false; + } + return true; + } + + private CustomMutableTreeNode getSelectedNode() { + return (CustomMutableTreeNode) component.getExamplesTree().getLastSelectedPathComponent(); + } + + private void copyExample(String sourcePath, String destinationPath) { + try { + AsposeMavenProjectManager.copyDirectory(sourcePath, destinationPath); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/Bundle.properties b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/Bundle.properties new file mode 100644 index 00000000..e61f0bf2 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/Bundle.properties @@ -0,0 +1,8 @@ +# To change this license header, choose License Headers in Project Properties. +# To change this template file, choose Tools | Templates +# and open the template in the editor. + +AsposeExample.jLabel1_text=Aspose.Slides for Java (version): +AsposeManager.populateExamplesMessage=Populating Aspose.Slides for Java API examples... +AsposeManager.updateExamplesMessage=Updating Aspose.Slides for Java API examples... +AsposeManager.populateExamplesTitle=Populating Example code list... \ No newline at end of file diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/CustomMutableTreeNode.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/CustomMutableTreeNode.java new file mode 100644 index 00000000..5092f81e --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/examples/CustomMutableTreeNode.java @@ -0,0 +1,70 @@ +/* + * 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.slides.maven.examples; + +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * + * @author Adeel Ilyas + */ +public final class CustomMutableTreeNode extends DefaultMutableTreeNode { + + private boolean folder; + private String _ExPath; + + /** + * + * @param data + */ + public void setTopTreeNodeText(String data) { + this.userObject = data; + } + + /** + * + * @param data + */ + public CustomMutableTreeNode(String data) { + this.userObject = data; + } + + /** + * @return the _ExPath + */ + public String getExPath() { + return _ExPath; + } + + /** + * @param ExPath the _ExPath to set + */ + public void setExPath(String ExPath) { + this._ExPath = ExPath; + } + + /** + * + * @return + */ + public boolean isFolder() { + return folder; + } + + /** + * + * @param folder + */ + public void setFolder(boolean folder) { + this.folder = folder; + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AbstractTask.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AbstractTask.java new file mode 100644 index 00000000..13147805 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AbstractTask.java @@ -0,0 +1,31 @@ +package com.aspose.slides.maven.utils; + +import org.netbeans.api.progress.aggregate.AggregateProgressFactory; +import org.netbeans.api.progress.aggregate.ProgressContributor; + +/** + * @author Adeel Ilyas + */ +public abstract class AbstractTask extends Thread { + + /** + * + */ + protected ProgressContributor p = null; + + /** + * + * @param id + */ + public AbstractTask(String id) { + p = AggregateProgressFactory.createProgressContributor(id); + } + + /** + * + * @return + */ + public ProgressContributor getProgressContributor() { + return p; + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeConstants.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeConstants.java new file mode 100644 index 00000000..4bbc4bf0 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeConstants.java @@ -0,0 +1,144 @@ +/* + * 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.slides.maven.utils; + +/* + * @author Adeel Ilyas + */ +import java.io.File; + +/** + * + * @author Adeel + */ +public class AsposeConstants { + + /** + * + */ + public static final String API_NAME = "Aspose.Slides"; + + /** + * + */ + public static final String API_MAVEN_DEPENDENCY = "aspose-slides"; + + /** + * + */ + 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 MAVEN_POM_XML = "pom.xml"; + + /** + * + */ + public static final String WIZARD_NAME = "Aspose.Slides 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.Slides 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.Slides Maven Artifact!"; + + /** + * + */ + public static final String EXAMPLES_DOWNLOAD_FAIL = "Unknown Error!\nCould not download Aspose.Slides 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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeJavaAPI.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeJavaAPI.java new file mode 100644 index 00000000..1aeb7ddc --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeJavaAPI.java @@ -0,0 +1,168 @@ +/* + * 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.slides.maven.utils; + +import javax.swing.*; +import java.io.File; +import org.netbeans.api.progress.aggregate.ProgressContributor; +import org.openide.util.Exceptions; + + +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(ProgressContributor p) { + + 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(p); + p.progress(60); + } catch (Exception e) { + } + } else { + updateRepository(p); + if (isExamplesDefinitionsPresent()) { + examplesDefinitionAvailable = true; + + } + + } + p.progress(70); + } + + /** + * + * @param p + * @return + */ + public boolean downloadExamples(ProgressContributor p) { + try { + checkAndUpdateRepo(p); + } catch (Exception rex) { + Exceptions.printStackTrace(rex); + return false; + } + + return true; + + } + + /** + * + * @param p + */ + public void updateRepository(ProgressContributor p) { + AsposeMavenProjectManager.checkAndCreateFolder(getLocalRepositoryPath()); + + try { + + GitHelper.updateRepository(getLocalRepositoryPath(), get_remoteExamplesRepository()); + p.progress(55); + + } catch (Exception e) { + Exceptions.printStackTrace(e); + } + } + + /** + * + * @param p + */ + public void syncRepository(ProgressContributor p) { + try { + + GitHelper.syncRepository(getLocalRepositoryPath(), get_remoteExamplesRepository()); + p.progress(55); + + } catch (Exception e) { + Exceptions.printStackTrace(e); + } + } + + /** + * + * @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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeMavenProjectManager.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeMavenProjectManager.java new file mode 100644 index 00000000..49958aa2 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeMavenProjectManager.java @@ -0,0 +1,623 @@ +/* + * 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.slides.maven.utils; + +import com.aspose.slides.maven.AsposeMavenProjectWizardIterator; +import com.aspose.slides.maven.artifacts.Metadata; +import com.aspose.slides.maven.artifacts.ObjectFactory; +import com.aspose.slides.maven.examples.AsposeExamplePanel; +import com.aspose.slides.maven.examples.CustomMutableTreeNode; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import java.util.List; +import javax.swing.*; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.stream.StreamSource; +import javax.xml.xpath.*; +import java.io.*; +import java.net.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Queue; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import javax.xml.bind.JAXBException; +import org.openide.WizardDescriptor; +import org.openide.awt.StatusDisplayer; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.openide.xml.XMLUtil; +import org.w3c.dom.Node; + +public class AsposeMavenProjectManager { + + private boolean examplesNotAvailable; + private File projectDir = null; + + /** + * + * @return + */ + public File getProjectDir() { + return projectDir; + } + private boolean examplesDefinitionAvailable; + + /** + * + * @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) { + Exceptions.printStackTrace(ex); + data = null; + } + return data; + } + + /** + * + * @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 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) { + Exceptions.printStackTrace(e); + return false; + } + } + + /** + * + * @param asposeAPI + * @return + */ + public AbstractTask retrieveAsposeAPIMavenTask(final AsposeJavaAPI asposeAPI) { + return new AbstractTask(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressTitle")) { + @Override + public void run() { + String progressMsg = NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressMessage"); + + p.progress(progressMsg); + StatusDisplayer.getDefault().setStatusText(progressMsg); + + p.start(100); + p.progress(50); + retrieveAsposeMavenDependencies(); + StatusDisplayer.getDefault().setStatusText(progressMsg); + p.progress(100); + p.finish(); + } + }; + } + + /** + * + * @param asposeAPI + * @return + */ + public AbstractTask createDownloadExamplesTask(final AsposeJavaAPI asposeAPI) { + return new AbstractTask(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressExamplesTitle")) { + @Override + public void run() { + String downloadExamplesMessage = NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.downloadExamplesMessage"); + + p.progress(downloadExamplesMessage); + StatusDisplayer.getDefault().setStatusText(downloadExamplesMessage); + p.start(100); + p.progress(50); + asposeAPI.downloadExamples(p); + p.progress(downloadExamplesMessage); + p.progress(100); + p.finish(); + } + }; + } + + /** + * + * @param asposeAPI + * @param panel + * @return + */ + public Runnable populateExamplesTask(final AsposeJavaAPI asposeAPI, final AsposeExamplePanel panel) { + + return new Runnable() { + @Override + public void run() { + final CustomMutableTreeNode top = new CustomMutableTreeNode(""); + DefaultTreeModel model = (DefaultTreeModel) panel.getExamplesTree().getModel(); + model.setRoot(top); + model.reload(top); + AsposeJavaAPI component = AsposeSlidesJavaAPI.getInstance(); + if (component.isExamplesDefinitionAvailable()) { + populateExamplesTree(component, top, panel); + } + top.setTopTreeNodeText(AsposeConstants.API_NAME); + model.setRoot(top); + model.reload(top); + panel.getExamplesTree().expandPath(new TreePath(top.getPath())); + } + }; + + } + + /** + * + * @return + */ + public boolean retrieveAsposeMavenDependencies() { + try { + getAsposeProjectMavenDependencies().clear(); + AsposeJavaAPI component = AsposeSlidesJavaAPI.getInstance(); + Metadata productMavenDependency = getProductMavenDependency(component.get_mavenRepositoryURL()); + if (productMavenDependency != null) { + getAsposeProjectMavenDependencies().add(productMavenDependency); + } + + } catch (Exception rex) { + Exceptions.printStackTrace(rex); + return false; + } + return !getAsposeProjectMavenDependencies().isEmpty(); + } + + /** + * + * @return + */ + public static boolean isInternetConnected() { + try { + InetAddress address = InetAddress.getByName(AsposeConstants.INTERNET_CONNNECTIVITY_PING_URL); + if (address == null) { + return false; + } + } catch (UnknownHostException e) { + Exceptions.printStackTrace(e); + return false; + } + + return true; + } + + /** + * + * @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; + } + + private Document getXmlDocument(String mavenPomXmlfile) throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document pomDocument = docBuilder.parse(mavenPomXmlfile); + + return pomDocument; + } + + /** + * + * @param dependencyName + * @return + */ + public String getDependencyVersionFromPOM(String dependencyName) { + try { + String mavenPomXmlfile = projectDir.getPath() + File.separator + AsposeConstants.MAVEN_POM_XML; + + 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 (IOException | ParserConfigurationException | SAXException | XPathExpressionException e) { + Exceptions.printStackTrace(e); + } + return null; + } + + /** + * + * @return + */ + public String getAsposeHomePath() { + + return System.getProperty("user.home") + File.separator + "aspose" + File.separator; + + } + + /** + * + * @param sourceLocation + * @param targetLocation + * @throws IOException + */ + public static void copyDirectory(String sourceLocation, String targetLocation) throws IOException { + + checkAndCreateFolder(targetLocation); + copyDirectory(new File(sourceLocation + File.separator), new File(targetLocation + File.separator)); + } + + /** + * + * @param sourceLocation + * @param targetLocation + * @throws IOException + */ + public static void copyDirectory(File sourceLocation, File targetLocation) throws IOException { + if (sourceLocation.isDirectory()) { + if (!targetLocation.exists()) { + targetLocation.mkdir(); + } + + String[] children = sourceLocation.list(); + for (String children1 : children) { + copyDirectory(new File(sourceLocation, children1), new File(targetLocation, children1)); + } + } else { + + OutputStream out; + try (InputStream in = new FileInputStream(sourceLocation)) { + out = new FileOutputStream(targetLocation); + // Copy the bits from instream to outstream + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + } + out.close(); + } + } + + /** + * + * @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 wiz + * @return + */ + public static AsposeMavenProjectManager initialize(WizardDescriptor wiz) { + asposeMavenProjectManager = new AsposeMavenProjectManager(); + asposeMavenProjectManager.projectDir = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); + return asposeMavenProjectManager; + } + + private AsposeMavenProjectManager() { + } + + /** + * + * @return + */ + public static List getAsposeProjectMavenDependencies() { + return asposeProjectMavenDependencies; + } + + /** + * + */ + public static void clearAsposeProjectMavenDependencies() { + asposeProjectMavenDependencies.clear(); + } + + private static final List asposeProjectMavenDependencies = new ArrayList(); + + /** + * + * @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) { + Exceptions.printStackTrace(ex); + } + } + + /** + * + * @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) { + Exceptions.printStackTrace(ex); + } + } + + /** + * + * @param pomDocument + * @throws IOException + */ + public void writeToPOM(Document pomDocument) throws IOException { + + FileObject projectRoot = FileUtil.toFileObject(projectDir); + FileObject fo = FileUtil.createData(projectRoot, AsposeConstants.MAVEN_POM_XML); + try (OutputStream out = fo.getOutputStream()) { + XMLUtil.write(pomDocument, out, "UTF-8"); + } + } + + /** + * + * @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) { + Exceptions.printStackTrace(e); + } + return null; + } + + /** + * + * @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) { + Exceptions.printStackTrace(e); + } + return null; + } + + 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 asposeComponent + * @param top + * @param panel + */ + public void populateExamplesTree(AsposeJavaAPI asposeComponent, CustomMutableTreeNode top, AsposeExamplePanel panel) { + String examplesFullPath = asposeComponent.getLocalRepositoryPath() + File.separator + AsposeConstants.GITHUB_EXAMPLES_SOURCE_LOCATION; + File directory = new File(examplesFullPath); + panel.getExamplesTree().removeAll(); + top.setExPath(examplesFullPath); + Queue queue = new LinkedList<>(); + queue.add(new Object[]{null, directory}); + + while (!queue.isEmpty()) { + Object[] _entry = queue.remove(); + File childFile = ((File) _entry[1]); + CustomMutableTreeNode parentItem = ((CustomMutableTreeNode) _entry[0]); + if (childFile.isDirectory()) { + if (parentItem != null) { + CustomMutableTreeNode child = new CustomMutableTreeNode(FormatExamples.formatTitle(childFile.getName())); + child.setExPath(childFile.getAbsolutePath()); + child.setFolder(true); + parentItem.add(child); + parentItem = child; + } else { + parentItem = top; + } + for (File f : childFile.listFiles()) { + queue.add(new Object[]{parentItem, f}); + } + } else if (childFile.isFile()) { + + String title = FormatExamples.formatTitle(childFile.getName()); + CustomMutableTreeNode child = new CustomMutableTreeNode(title); + child.setFolder(false); + parentItem.add(child); + + } + } + + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeSlidesJavaAPI.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeSlidesJavaAPI.java new file mode 100644 index 00000000..33de4960 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/AsposeSlidesJavaAPI.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.slides.maven.utils; + +/* + * @author Adeel Ilyas + * + */ +// Singleton Class + +/** + * + * @author Adeel + */ +public class AsposeSlidesJavaAPI extends AsposeJavaAPI { + + private final String _name = AsposeConstants.API_NAME; + private final String _mavenRepositoryURL = "http://maven.aspose.com/repository/ext-release-local/com/aspose/aspose-slides/"; + private final String _remoteExamplesRepository = "https://github.com/asposeslides/Aspose_Slides_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 asposeSlidesAPI; + + /** + * + * @return + */ + public static AsposeJavaAPI getInstance() { + return asposeSlidesAPI; + } + + /** + * + * @param asposeMavenProjectManager + * @return + */ + public static AsposeJavaAPI initialize(AsposeMavenProjectManager asposeMavenProjectManager) { + asposeSlidesAPI = new AsposeSlidesJavaAPI(); + asposeSlidesAPI.asposeMavenProjectManager = asposeMavenProjectManager; + return asposeSlidesAPI; + } + + private AsposeSlidesJavaAPI() { + } +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/FormatExamples.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/FormatExamples.java new file mode 100644 index 00000000..3a338633 --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/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.slides.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.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/GitHelper.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/GitHelper.java new file mode 100644 index 00000000..43435a6a --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/GitHelper.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.slides.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 + } + } + } 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 + } + + } catch (Exception ex) { + throw new Exception("Could not update Repository from Github. Error: " + ex.getMessage()); + } + } + +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/TasksExecutor.java b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/TasksExecutor.java new file mode 100644 index 00000000..7fde9c8f --- /dev/null +++ b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/utils/TasksExecutor.java @@ -0,0 +1,78 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.aspose.slides.maven.utils; + +import java.util.ArrayList; +import java.util.List; +import org.netbeans.api.progress.aggregate.AggregateProgressFactory; +import org.netbeans.api.progress.aggregate.AggregateProgressHandle; +import org.netbeans.api.progress.aggregate.ProgressContributor; + +/** + * @author Adeel Ilyas + */ +public class TasksExecutor { + + private final List tasks = new ArrayList<>(); + private final String tasksName; + + /** + * + * @param tasksName + */ + public TasksExecutor(String tasksName) { + this.tasksName = tasksName; + + } + + /** + * + * @param task + */ + public void addNewTask(AbstractTask task) { + tasks.add(task); + } + + /** + * Clears added tasks + */ + public void clearTasks() { + tasks.clear(); + } + + /** + * + * @return boolean + */ + public boolean areThereTasks() { + return !tasks.isEmpty(); + } + + /** + * Executes Added Abstract Tasks + */ + public void processTasks() { + ProgressContributor cps[] = new ProgressContributor[tasks.size()]; + int i = 0; + for (AbstractTask task : tasks) { + cps[i] = task.getProgressContributor(); + i++; + + } + + AggregateProgressHandle aph = AggregateProgressFactory.createHandle(tasksName, cps, null, null); + aph.start(); + + for (AbstractTask task : tasks) { + task.start(); + try { + task.join(); + } catch (InterruptedException ie) { + } + } + } + +} diff --git a/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/resources/long-banner.png b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/resources/long-banner.png new file mode 100644 index 00000000..821b3197 Binary files /dev/null and b/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/resources/long-banner.png differ