[ 
https://issues.apache.org/jira/browse/SYNCOPE-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15615686#comment-15615686
 ] 

ASF GitHub Bot commented on SYNCOPE-808:
----------------------------------------

Github user ilgrosso commented on a diff in the pull request:

    https://github.com/apache/syncope/pull/38#discussion_r85551221
  
    --- Diff: 
ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.java
 ---
    @@ -0,0 +1,561 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.syncope.netbeans.plugin.view;
    +
    +//import java.awt.Image;
    +import java.awt.event.ActionEvent;
    +import java.awt.event.ActionListener;
    +import java.awt.event.MouseEvent;
    +import java.beans.PropertyChangeListener;
    +import java.io.BufferedReader;
    +import java.io.File;
    +import java.io.FileNotFoundException;
    +import java.io.FileReader;
    +import java.io.FileWriter;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.nio.charset.Charset;
    +import java.util.List;
    +import javax.swing.Action;
    +import javax.swing.JMenuItem;
    +import javax.swing.JOptionPane;
    +import javax.swing.JPopupMenu;
    +import javax.swing.text.BadLocationException;
    +import javax.swing.text.Document;
    +import javax.swing.text.JTextComponent;
    +import javax.swing.tree.DefaultMutableTreeNode;
    +import javax.swing.tree.DefaultTreeModel;
    +import org.apache.commons.io.IOUtils;
    +import org.apache.syncope.common.lib.to.MailTemplateTO;
    +import org.apache.syncope.common.lib.to.ReportTemplateTO;
    +import org.apache.syncope.common.lib.types.MailTemplateFormat;
    +import org.apache.syncope.common.lib.types.ReportTemplateFormat;
    +import org.apache.syncope.netbeans.plugin.connector.ResourceConnector;
    +import org.apache.syncope.netbeans.plugin.constants.PluginConstants;
    +import 
org.apache.syncope.netbeans.plugin.service.MailTemplateManagerService;
    +import 
org.apache.syncope.netbeans.plugin.service.ReportTemplateManagerService;
    +import org.netbeans.api.editor.EditorRegistry;
    +import org.netbeans.api.progress.ProgressHandle;
    +import org.netbeans.api.progress.ProgressHandleFactory;
    +import org.netbeans.api.settings.ConvertAsProperties;
    +//import org.netbeans.core.spi.multiview.MultiViewDescription;
    +//import org.netbeans.core.spi.multiview.MultiViewElement;
    +//import org.netbeans.core.spi.multiview.MultiViewFactory;
    +//import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
    +import org.openide.awt.ActionID;
    +import org.openide.awt.ActionReference;
    +import org.openide.cookies.OpenCookie;
    +import org.openide.filesystems.FileObject;
    +import org.openide.filesystems.FileUtil;
    +import org.openide.loaders.DataObject;
    +import org.openide.util.Cancellable;
    +import org.openide.util.Exceptions;
    +//import org.openide.util.HelpCtx;
    +//import org.openide.util.Lookup;
    +import org.openide.util.RequestProcessor;
    +import org.openide.windows.TopComponent;
    +
    +/**
    + * Top component which displays something.
    + */
    +@ConvertAsProperties(
    +        dtd = 
"-//org.apache.syncope.netbeans.plugin//ResourceExplorer//EN",
    +        autostore = false
    +)
    +@TopComponent.Description(
    +        preferredID = "ResourceExplorerTopComponent",
    +        iconBase = "images/syncope.png",
    +        persistenceType = TopComponent.PERSISTENCE_ALWAYS
    +)
    +@TopComponent.Registration(mode = "explorer", openAtStartup = false)
    +@ActionID(category = "Window", id = 
"org.apache.syncope.netbeans.plugin.ResourceExplorerTopComponent")
    +@ActionReference(path = "Menu/Window" /*, position = 333 */)
    +@TopComponent.OpenActionRegistration(
    +        displayName = "Apache Syncope",
    +        preferredID = "ResourceExplorerTopComponent"
    +)
    +
    +public final class ResourceExplorerTopComponent extends TopComponent {
    +
    +    private DefaultTreeModel treeModel;
    +    private DefaultMutableTreeNode root;
    +    private DefaultMutableTreeNode mailTemplates;
    +    private DefaultMutableTreeNode reportXslts;
    +    private MailTemplateManagerService mailTemplateManagerService;
    +    private ReportTemplateManagerService reportTemplateManagerService;
    +    private Charset encodingPattern;
    +
    +    public ResourceExplorerTopComponent() {
    +
    +        initComponents();
    +        setName(PluginConstants.DISPLAY_NAME);
    +        setToolTipText(PluginConstants.TOOL_TIP_TEXT);
    +
    +        treeModel = (DefaultTreeModel) resourceExplorerTree.getModel();
    +        root = (DefaultMutableTreeNode) treeModel.getRoot();
    +        DefaultMutableTreeNode visibleRoot
    +                = new DefaultMutableTreeNode(PluginConstants.DISPLAY_NAME);
    +        mailTemplates = new 
DefaultMutableTreeNode(PluginConstants.MAIL_TEMPLTAE_CONSTANT);
    +        reportXslts = new 
DefaultMutableTreeNode(PluginConstants.REPORT_XSLTS_CONSTANT);
    +        root.add(visibleRoot);
    +        visibleRoot.add(mailTemplates);
    +        visibleRoot.add(reportXslts);
    +        treeModel.reload();
    +
    +    }
    +
    +    /**
    +     * 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.
    +     */
    +    // <editor-fold defaultstate="collapsed" desc="Generated 
Code">//GEN-BEGIN:initComponents
    +    private void initComponents() {
    +
    +        jScrollPane1 = new javax.swing.JScrollPane();
    +        resourceExplorerTree = new javax.swing.JTree();
    +
    +        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new 
javax.swing.tree.DefaultMutableTreeNode("root");
    +        resourceExplorerTree.setModel(new 
javax.swing.tree.DefaultTreeModel(treeNode1));
    +        resourceExplorerTree.setRootVisible(false);
    +        resourceExplorerTree.setScrollsOnExpand(true);
    +        resourceExplorerTree.addMouseListener(new 
java.awt.event.MouseAdapter() {
    +            public void mouseClicked(final java.awt.event.MouseEvent evt) {
    +                resourceExplorerTreeMouseClicked(evt);
    +            }
    +        });
    +        jScrollPane1.setViewportView(resourceExplorerTree);
    +
    +        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    +        this.setLayout(layout);
    +        layout.setHorizontalGroup(
    +            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    +            .addComponent(jScrollPane1, 
javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
    +        );
    +        layout.setVerticalGroup(
    +            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    +            .addComponent(jScrollPane1, 
javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
    +        );
    +    }
    +    // </editor-fold>//GEN-END:initComponents
    +
    +    private void resourceExplorerTreeMouseClicked(final 
java.awt.event.MouseEvent evt) {
    +        if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() 
== 2) {
    +            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) 
resourceExplorerTree.
    +                    getLastSelectedPathComponent();
    +            DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) 
selectedNode.getParent();
    +            if (selectedNode.isLeaf()) {
    +                String name = (String) selectedNode.getUserObject();
    +                if 
(parentNode.getUserObject().equals(PluginConstants.MAIL_TEMPLTAE_CONSTANT)) {
    +                    try {
    +                        openMailEditor(name);
    +                    } catch (IOException ex) {
    +                        Exceptions.printStackTrace(ex);
    +                    }
    +                } else {
    +                    try {
    +                        openReportEditor(name);
    +                    } catch (IOException ex) {
    +                        Exceptions.printStackTrace(ex);
    +                    }
    +                }
    +            }
    +        } else if (evt.getButton() == MouseEvent.BUTTON3 && 
evt.getClickCount() == 1) {
    +            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) 
resourceExplorerTree.
    +                    getLastSelectedPathComponent();
    +            String selectedNodeName = (String) 
selectedNode.getUserObject();
    +            if (selectedNode.isLeaf()) {
    +                leafRightClickAction(evt, selectedNode);
    +            } else if 
(selectedNodeName.equals(PluginConstants.MAIL_TEMPLTAE_CONSTANT)) {
    +                folderRightClickAction(evt, mailTemplates);
    +            } else if 
(selectedNodeName.equals(PluginConstants.REPORT_XSLTS_CONSTANT)) {
    +                folderRightClickAction(evt, reportXslts);
    +            } else if 
(selectedNodeName.equals(PluginConstants.DISPLAY_NAME)) {
    +                rootRightClickAction(evt);
    +            }
    +        }
    +    }
    +
    +    // Variables declaration - do not modify//GEN-BEGIN:variables
    +    private javax.swing.JScrollPane jScrollPane1;
    +    private javax.swing.JTree resourceExplorerTree;
    +    // End of variables declaration//GEN-END:variables
    +
    +    @Override
    +    public void componentOpened() {
    +        File file = new File("UserData.txt");
    +        if (!file.exists()) {
    +            new ServerDetailsView(null, true).setVisible(true);
    +        }
    +        try {
    +            mailTemplateManagerService = 
ResourceConnector.getMailTemplateManagerService();
    +        } catch (IOException ex) {
    +            JOptionPane.showMessageDialog(null, "Error Occured.", "Error",
    +                    JOptionPane.ERROR_MESSAGE);
    +            new ServerDetailsView(null, true).setVisible(true);
    +        }
    +        try {
    +            reportTemplateManagerService
    +                    = ResourceConnector.getReportTemplateManagerService();
    +        } catch (IOException ex) {
    +            new ServerDetailsView(null, true).setVisible(true);
    +        }
    +
    +        Runnable tsk = new Runnable() {
    +            @Override
    +            public void run() {
    +                final ProgressHandle progr = 
ProgressHandleFactory.createHandle("Loading Templates", new Cancellable() {
    +                    @Override
    +                    public boolean cancel() {
    +                        return true;
    +                    }
    +                }, new Action() {
    +                    @Override
    +                    public Object getValue(final String key) {
    +                        return null;
    +                    }
    +
    +                    @Override
    +                    public void putValue(final String key, final Object 
value) {
    +                    }
    +
    +                    @Override
    +                    public void setEnabled(final boolean b) {
    +                    }
    +
    +                    @Override
    +                    public boolean isEnabled() {
    +                        return false;
    +                    }
    +
    +                    @Override
    +                    public void addPropertyChangeListener(final 
PropertyChangeListener listener) {
    +                    }
    +
    +                    @Override
    +                    public void removePropertyChangeListener(final 
PropertyChangeListener listener) {
    +                    }
    +
    +                    @Override
    +                    public void actionPerformed(final ActionEvent e) {
    +                    }
    +                });
    +
    +                progr.start();
    +                progr.progress("Loading Templates.");
    +                addMailTemplates();
    +                addReportXslts();
    +                progr.finish();
    +            }
    +
    +        };
    +        RequestProcessor.getDefault().post(tsk);
    +    }
    +
    +    @Override
    +    public void componentClosed() {
    +        // TODO add custom code on component closing
    +    }
    +
    +    void writeProperties(final java.util.Properties p) {
    +        // better to version settings since initial version as advocated at
    +        // http://wiki.apidesign.org/wiki/PropertyFiles
    +        p.setProperty("version", "1.0");
    +        // TODO store your settings
    +    }
    +
    +    void readProperties(final java.util.Properties p) {
    +        String version = p.getProperty("version");
    +        // TODO read your settings according to their version
    --- End diff --
    
    TODO?


> Netbeans plugin
> ---------------
>
>                 Key: SYNCOPE-808
>                 URL: https://issues.apache.org/jira/browse/SYNCOPE-808
>             Project: Syncope
>          Issue Type: Sub-task
>          Components: ide
>         Environment: Netbeans IDE
>            Reporter: Francesco Chicchiriccò
>            Assignee: Tushar Mishra
>              Labels: gsoc2016, netbeans
>             Fix For: 2.0.2, 2.1.0
>
>
> Develop a plug-in, according to what reported in SYNCOPE-770, working with 
> latest Netbeans version.
> See Google Summer of Code project proposal at 
> https://summerofcode.withgoogle.com/projects/#5722525799546880



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to