Added netbeans to syncope/ide
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b9f59a6d Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b9f59a6d Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b9f59a6d Branch: refs/heads/SYNCOPE-808 Commit: b9f59a6d908b696c8218718196fd5db9a3a3a0a7 Parents: 249793b Author: Tushar <tusharm...@gmail.com> Authored: Tue Jan 3 15:36:07 2017 +0530 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Thu Feb 23 14:12:55 2017 +0100 ---------------------------------------------------------------------- ide/netbeans/nb-configuration.xml | 36 + ide/netbeans/pom.xml | 144 +++ .../plugin/connector/ResourceConnector.java | 76 ++ .../plugin/constants/PluginConstants.java | 33 + .../netbeans/plugin/entity/UserProperties.java | 78 ++ .../service/MailTemplateManagerService.java | 68 ++ .../service/ReportTemplateManagerService.java | 68 ++ .../view/ResourceExplorerTopComponent.form | 68 ++ .../view/ResourceExplorerTopComponent.java | 553 ++++++++++++ .../netbeans/plugin/view/ServerDetailsView.form | 161 ++++ .../netbeans/plugin/view/ServerDetailsView.java | 218 +++++ ide/netbeans/src/main/nbm/MANIFEST.MF | 3 + .../src/main/resources/META-INF/LICENSE | 896 +++++++++++++++++++ ide/netbeans/src/main/resources/META-INF/NOTICE | 80 ++ .../resources/org/apache/syncope/checkstyle.xml | 223 +++++ .../org/apache/syncope/java-formatter.xml | 309 +++++++ .../netbeans/plugin/view/Bundle.properties | 28 + ide/pom.xml | 5 +- pom.xml | 104 ++- 19 files changed, 3147 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/nb-configuration.xml ---------------------------------------------------------------------- diff --git a/ide/netbeans/nb-configuration.xml b/ide/netbeans/nb-configuration.xml new file mode 100644 index 0000000..ec22826 --- /dev/null +++ b/ide/netbeans/nb-configuration.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project-shared-configuration> + <!-- +This file contains additional configuration written by modules in the NetBeans IDE. +The configuration is intended to be shared among all the users of project and +therefore it is assumed to be part of version control checkout. +Without this configuration present, some functionality in the IDE may be limited or fail altogether. +--> + <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> + <!-- +Properties that influence various parts of the IDE, especially code formatting and the like. +You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. +That way multiple projects can share the same settings (useful for formatting rules for example). +Any value defined here will override the pom.xml file value but is only applicable to the current project. +--> + <org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled> + </properties> +</project-shared-configuration> http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/pom.xml ---------------------------------------------------------------------- diff --git a/ide/netbeans/pom.xml b/ide/netbeans/pom.xml new file mode 100644 index 0000000..1afbb88 --- /dev/null +++ b/ide/netbeans/pom.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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 owership. 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope-ide</artifactId> + <version>2.0.2-SNAPSHOT</version> + </parent> + + <name>Apache Syncope IDE Netbeans</name> + <description>Apache Syncope IDE Netbeans</description> + <groupId>org.apache.syncope.ide</groupId> + <artifactId>syncope-ide-netbeans</artifactId> + + <packaging>nbm</packaging> + + <properties> + <rootpom.basedir>${basedir}/../..</rootpom.basedir> + </properties> + + <build> + <resources> + <resource> + <directory>src/main/resources/META-INF/</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>nbm-maven-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <useOSGiDependencies>false</useOSGiDependencies> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-api-annotations-common</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-windows</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-util</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-util-ui</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-util-lookup</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-awt</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-modules-settings</artifactId> + </dependency> + <dependency> + <groupId>org.apache.syncope.common</groupId> + <artifactId>syncope-common-lib</artifactId> + </dependency> + <dependency> + <groupId>org.apache.syncope.client</groupId> + <artifactId>syncope-client-lib</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-io</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-nodes</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-text</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-filesystems</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-openide-loaders</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-core-multiview</artifactId> + <type>jar</type> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-modules-editor-lib2</artifactId> + <type>jar</type> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-api-progress</artifactId> + </dependency> + <dependency> + <groupId>org.netbeans.api</groupId> + <artifactId>org-netbeans-api-progress-nb</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/connector/ResourceConnector.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/connector/ResourceConnector.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/connector/ResourceConnector.java new file mode 100644 index 0000000..f9c4c13 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/connector/ResourceConnector.java @@ -0,0 +1,76 @@ +/* + * 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.connector; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import org.apache.syncope.netbeans.plugin.entity.UserProperties; +import org.apache.syncope.netbeans.plugin.service.MailTemplateManagerService; +import org.apache.syncope.netbeans.plugin.service.ReportTemplateManagerService; + +public final class ResourceConnector { + + private static MailTemplateManagerService MAIL_TEMPLATE_MANAGER_SERVICE; + private static ReportTemplateManagerService REPORT_TEMPLATE_MANAGER_SERVICE; + + private static final Object MAIL_TEMPLATE_MONITOR = new Object(); + private static final Object REPORT_TEMPLATE_MONITOR = new Object(); + + private ResourceConnector() { + } + + public static MailTemplateManagerService getMailTemplateManagerService() throws IOException { + synchronized (MAIL_TEMPLATE_MONITOR) { + if (MAIL_TEMPLATE_MANAGER_SERVICE == null) { + UserProperties userProperties = getUserProperties(); + MAIL_TEMPLATE_MANAGER_SERVICE = new MailTemplateManagerService( + userProperties.getUrl(), userProperties.getUserName(), + userProperties.getPassword()); + } + } + return MAIL_TEMPLATE_MANAGER_SERVICE; + } + + public static ReportTemplateManagerService getReportTemplateManagerService() throws IOException { + synchronized (REPORT_TEMPLATE_MONITOR) { + if (REPORT_TEMPLATE_MANAGER_SERVICE == null) { + UserProperties userProperties = getUserProperties(); + REPORT_TEMPLATE_MANAGER_SERVICE = new ReportTemplateManagerService( + userProperties.getUrl(), userProperties.getUserName(), + userProperties.getPassword()); + } + } + return REPORT_TEMPLATE_MANAGER_SERVICE; + } + + private static UserProperties getUserProperties() throws FileNotFoundException, IOException { + File file = new File("UserData.txt"); + BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); + String url = bufferedReader.readLine(); + String userName = bufferedReader.readLine(); + String password = bufferedReader.readLine(); + + UserProperties userProperties = new UserProperties(url, userName, password); + return userProperties; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/constants/PluginConstants.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/constants/PluginConstants.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/constants/PluginConstants.java new file mode 100644 index 0000000..50976d7 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/constants/PluginConstants.java @@ -0,0 +1,33 @@ +/* + * 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.constants; + +public final class PluginConstants { + + public static final String MAIL_TEMPLTAE_CONSTANT = "Mail Template"; + public static final String REPORT_XSLTS_CONSTANT = "Report XSLTs"; + public static final String[] MAIL_TEMPLATE_FORMATS = {"TEXT", "HTML"}; + public static final String[] REPORT_TEMPLATE_FORMATS = {"HTML", "CSV", "FO"}; + public static final String DISPLAY_NAME = "Apache Syncope"; + public static final String TOOL_TIP_TEXT = "This is a Apache Syncope window"; + + private PluginConstants() { + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/entity/UserProperties.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/entity/UserProperties.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/entity/UserProperties.java new file mode 100644 index 0000000..9bb0845 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/entity/UserProperties.java @@ -0,0 +1,78 @@ +/* + * 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.entity; + +public class UserProperties { + + private String url; + private String userName; + private String password; + + public UserProperties() { + } + + public UserProperties(final String url, final String userName, + final String password) { + this.url = url; + this.userName = userName; + this.password = password; + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * @param url the url to set + */ + public void setUrl(final String url) { + this.url = url; + } + + /** + * @param userName the userName to set + */ + public void setUserName(final String userName) { + this.userName = userName; + } + + /** + * @param password the password to set + */ + public void setPassword(final String password) { + this.password = password; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/MailTemplateManagerService.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/MailTemplateManagerService.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/MailTemplateManagerService.java new file mode 100644 index 0000000..953d081 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/MailTemplateManagerService.java @@ -0,0 +1,68 @@ +/* + * 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.service; + +import java.io.InputStream; +import java.util.List; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; +import org.apache.syncope.common.lib.to.MailTemplateTO; +import org.apache.syncope.common.lib.types.MailTemplateFormat; +import org.apache.syncope.common.rest.api.service.MailTemplateService; + +public class MailTemplateManagerService { + + private MailTemplateService service; + + public MailTemplateManagerService(final String url, final String userName, final String password) { + SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(url).create(userName, password); + service = syncopeClient.getService(MailTemplateService.class); + } + + public List<MailTemplateTO> list() { + return service.list(); + } + + public boolean create(final MailTemplateTO mailTemplateTO) { + return Response.Status.CREATED.getStatusCode() == service.create(mailTemplateTO).getStatus(); + } + + public MailTemplateTO read(final String key) { + return service.read(key); + } + + public boolean delete(final String key) { + service.delete(key); + return true; + } + + public Object getFormat(final String key, final MailTemplateFormat format) { + return service.getFormat(key, format).getEntity(); + } + + public void setFormat(final String key, final MailTemplateFormat format, final InputStream templateIn) { + service.setFormat(key, format, templateIn); + } + + public boolean removeFormat(final String key, final MailTemplateFormat format) { + return false; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/ReportTemplateManagerService.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/ReportTemplateManagerService.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/ReportTemplateManagerService.java new file mode 100644 index 0000000..e56b24b --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/service/ReportTemplateManagerService.java @@ -0,0 +1,68 @@ +/* + * 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.service; + +import java.io.InputStream; +import java.util.List; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; +import org.apache.syncope.common.lib.to.ReportTemplateTO; +import org.apache.syncope.common.lib.types.ReportTemplateFormat; +import org.apache.syncope.common.rest.api.service.ReportTemplateService; + +public class ReportTemplateManagerService { + + private ReportTemplateService service; + + public ReportTemplateManagerService(final String url, final String userName, final String password) { + SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(url).create(userName, password); + service = syncopeClient.getService(ReportTemplateService.class); + } + + public List<ReportTemplateTO> list() { + return service.list(); + } + + public boolean create(final ReportTemplateTO reportTemplateTO) { + return Response.Status.CREATED.getStatusCode() == service.create(reportTemplateTO).getStatus(); + } + + public ReportTemplateTO read(final String key) { + return service.read(key); + } + + public boolean delete(final String key) { + service.delete(key); + return true; + } + + public Object getFormat(final String key, final ReportTemplateFormat format) { + return service.getFormat(key, format).getEntity(); + } + + public void setFormat(final String key, final ReportTemplateFormat format, final InputStream templateIn) { + service.setFormat(key, format, templateIn); + } + + public boolean removeFormat(final String key, final ReportTemplateFormat format) { + return false; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.form ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.form b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.form new file mode 100644 index 0000000..79458db --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.form @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +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 owership. 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. +--> +<Form version="1.7" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane1" alignment="0" pref="258" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane1" alignment="0" pref="445" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTree" name="resourceExplorerTree"> + <Properties> + <Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.editors2.TreeModelEditor"> + <TreeModel code=""/> + </Property> + <Property name="rootVisible" type="boolean" value="false"/> + <Property name="scrollsOnExpand" type="boolean" value="true"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="resourceExplorerTreeMouseClicked"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.java new file mode 100644 index 0000000..4c91ec5 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ResourceExplorerTopComponent.java @@ -0,0 +1,553 @@ +/* + * 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.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.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.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 + } + + private void addMailTemplates() { + List<MailTemplateTO> mailTemplateList = mailTemplateManagerService.list(); + for (MailTemplateTO mailTemplate : mailTemplateList) { + this.mailTemplates.add(new DefaultMutableTreeNode( + mailTemplate.getKey())); + } + treeModel.reload(); + } + + private void addReportXslts() { + List<ReportTemplateTO> reportTemplates = reportTemplateManagerService.list(); + for (ReportTemplateTO reportTemplate : reportTemplates) { + reportXslts.add(new DefaultMutableTreeNode( + reportTemplate.getKey())); + } + treeModel.reload(); + } + + private void rootRightClickAction(final MouseEvent evt) { + JPopupMenu menu = new JPopupMenu(); + JMenuItem saveItem = new JMenuItem("Save"); + JMenuItem resetConnectionItem = new JMenuItem("Reset Connection"); + menu.add(saveItem); + menu.add(resetConnectionItem); + + saveItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent e) { + saveContent(); + } + }); + + resetConnectionItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent e) { + File file = new File("UserData.txt"); + try { + BufferedReader bf = new BufferedReader(new FileReader(file)); + String host = bf.readLine(); + String userName = bf.readLine(); + String password = bf.readLine(); + ServerDetailsView serverDetails = new ServerDetailsView(null, true); + serverDetails.setDetails(host, userName, password); + serverDetails.setVisible(true); + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + }); + + menu.show(evt.getComponent(), evt.getX(), evt.getY()); + } + + private void folderRightClickAction(final MouseEvent evt, + final DefaultMutableTreeNode node) { + JPopupMenu menu = new JPopupMenu(); + JMenuItem addItem = new JMenuItem("New"); + menu.add(addItem); + + addItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent e) { + String name = JOptionPane.showInputDialog("Enter Name"); + boolean added = false; + if (node.getUserObject().equals( + PluginConstants.MAIL_TEMPLTAE_CONSTANT)) { + MailTemplateTO mailTemplate = new MailTemplateTO(); + mailTemplate.setKey(name); + added = mailTemplateManagerService.create(mailTemplate); + mailTemplateManagerService.setFormat(name, + MailTemplateFormat.HTML, + IOUtils.toInputStream("//Enter Content here", encodingPattern)); + mailTemplateManagerService.setFormat(name, + MailTemplateFormat.TEXT, + IOUtils.toInputStream("//Enter Content here", encodingPattern)); + try { + openMailEditor(name); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } else { + ReportTemplateTO reportTemplate = new ReportTemplateTO(); + reportTemplate.setKey(name); + added = reportTemplateManagerService.create(reportTemplate); + reportTemplateManagerService.setFormat(name, + ReportTemplateFormat.FO, + IOUtils.toInputStream("//Enter content here", encodingPattern)); + reportTemplateManagerService.setFormat(name, + ReportTemplateFormat.CSV, + IOUtils.toInputStream("//Enter content here", encodingPattern)); + reportTemplateManagerService.setFormat(name, + ReportTemplateFormat.HTML, + IOUtils.toInputStream("//Enter content here", encodingPattern)); + try { + openReportEditor(name); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + + if (added) { + node.add(new DefaultMutableTreeNode(name)); + treeModel.reload(node); + } else { + JOptionPane.showMessageDialog(null, "Error while creating " + + "new element", "Error", JOptionPane.ERROR_MESSAGE); + } + } + }); + + menu.show(evt.getComponent(), evt.getX(), evt.getY()); + } + + private void leafRightClickAction(final MouseEvent evt, + final DefaultMutableTreeNode node) { + JPopupMenu menu = new JPopupMenu(); + JMenuItem deleteItem = new JMenuItem("Delete"); + menu.add(deleteItem); + + deleteItem.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent e) { + int result = JOptionPane.showConfirmDialog(null, + "Do you want to delete ?"); + if (result == JOptionPane.OK_OPTION) { + DefaultMutableTreeNode parent + = (DefaultMutableTreeNode) node.getParent(); + String name = (String) node.getUserObject(); + boolean deleted; + if (parent.getUserObject().equals( + PluginConstants.MAIL_TEMPLTAE_CONSTANT)) { + deleted = mailTemplateManagerService.delete( + (String) node.getUserObject()); + } else { + deleted = reportTemplateManagerService.delete( + (String) node.getUserObject()); + } + if (deleted) { + node.removeFromParent(); + treeModel.reload(parent); + } else { + + JOptionPane.showMessageDialog(null, + "Error while deleting new element", "Error", + JOptionPane.ERROR_MESSAGE); + } + } + } + }); + + menu.show(evt.getComponent(), evt.getX(), evt.getY()); + } + + private void openMailEditor(final String name) throws IOException { + String type = null; + String content = null; + InputStream is = null; + String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", + "File format", JOptionPane.QUESTION_MESSAGE, null, + PluginConstants.MAIL_TEMPLATE_FORMATS, "TEXT"); + MailTemplateFormat format = MailTemplateFormat.valueOf(formatStr); + + switch (format) { + case HTML: type = "html"; + is = (InputStream) mailTemplateManagerService.getFormat(name, + MailTemplateFormat.HTML); + break; + case TEXT: type = "txt"; + is = (InputStream) mailTemplateManagerService.getFormat(name, + MailTemplateFormat.TEXT); + break; + default: break; + } + content = IOUtils.toString(is, encodingPattern); + + File directory = new File("Template/Mail"); + if (!directory.exists()) { + directory.mkdirs(); + } + File file = new File("Template/Mail/" + name + "." + type); + FileWriter fw = new FileWriter(file); + fw.write(content); + fw.flush(); + FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile()); + fob.setAttribute("description", "TEXT"); + DataObject data = DataObject.find(fob); + OpenCookie cookie = (OpenCookie) data.getCookie(OpenCookie.class); + cookie.open(); + } + + private void openReportEditor(final String name) throws IOException { + String type = null; + String content = null; + InputStream is = null; + String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", + "File format", JOptionPane.QUESTION_MESSAGE, null, + PluginConstants.REPORT_TEMPLATE_FORMATS, "TEXT"); + ReportTemplateFormat format = ReportTemplateFormat.valueOf(formatStr); + + switch (format) { + case HTML: type = "html"; + is = (InputStream) reportTemplateManagerService.getFormat(name, + ReportTemplateFormat.HTML); + break; + case CSV: type = "csv"; + is = (InputStream) reportTemplateManagerService.getFormat(name, + ReportTemplateFormat.CSV); + break; + case FO: type = "fo"; + is = (InputStream) reportTemplateManagerService.getFormat(name, + ReportTemplateFormat.FO); + break; + default: break; + } + content = IOUtils.toString(is, encodingPattern); + + File directory = new File("Template/Report"); + if (!directory.exists()) { + directory.mkdirs(); + } + File file = new File("Template/Report/" + name + "." + type); + FileWriter fw = new FileWriter(file); + fw.write(content); + fw.flush(); + FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile()); + DataObject data = DataObject.find(fob); + OpenCookie cookie = (OpenCookie) data.getCookie(OpenCookie.class); + cookie.open(); + } + + private void saveContent() { + + try { + JTextComponent ed = EditorRegistry.lastFocusedComponent(); + Document document = ed.getDocument(); + String content = document.getText(0, document.getLength()); + String path = (String) document.getProperty(Document.TitleProperty); + String[] temp = path.split(File.separator); + String name = temp[temp.length - 1]; + String templateType = temp[temp.length - 2]; + temp = name.split("\\."); + String format = temp[1]; + String key = temp[0]; + + if (templateType.equals("Mail")) { + if (format.equals("txt")) { + mailTemplateManagerService.setFormat(key, + MailTemplateFormat.TEXT, + IOUtils.toInputStream(content, encodingPattern)); + } else { + mailTemplateManagerService.setFormat(key, + MailTemplateFormat.HTML, + IOUtils.toInputStream(content, encodingPattern)); + } + } else if (format.equals("html")) { + reportTemplateManagerService.setFormat(key, + ReportTemplateFormat.HTML, + IOUtils.toInputStream(content, encodingPattern)); + } else if (format.equals("fo")) { + reportTemplateManagerService.setFormat(key, + ReportTemplateFormat.FO, + IOUtils.toInputStream(content, encodingPattern)); + } else { + reportTemplateManagerService.setFormat(key, + ReportTemplateFormat.CSV, + IOUtils.toInputStream(content, encodingPattern)); + } + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.form ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.form b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.form new file mode 100644 index 0000000..da41034 --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.form @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +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 owership. 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. +--> +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="41" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="okButton" min="-2" pref="74" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="39" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="userNameTxt" max="32767" attributes="0"/> + <Component id="urlTxt" max="32767" attributes="0"/> + <Component id="passwordTxt" alignment="0" min="-2" pref="155" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="101" max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="41" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel4" pref="32" max="32767" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="urlTxt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="userNameTxt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="passwordTxt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="okButton" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="urlTxt"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.urlTxt.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="userNameTxt"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.userNameTxt.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JPasswordField" name="passwordTxt"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.passwordTxt.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="okButton"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.okButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/apache/syncope/netbeans/plugin/view/Bundle.properties" key="ServerDetailsView.jLabel4.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.java ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.java b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.java new file mode 100644 index 0000000..dc03d4d --- /dev/null +++ b/ide/netbeans/src/main/java/org/apache/syncope/netbeans/plugin/view/ServerDetailsView.java @@ -0,0 +1,218 @@ +/* + * 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.io.File; +import java.io.FileWriter; +import java.io.IOException; +import javax.swing.JOptionPane; + +public class ServerDetailsView extends javax.swing.JDialog { + + /** + * Creates new form LoginView + */ + public ServerDetailsView(final java.awt.Frame parent, final boolean modal) { + super(parent, modal); + initComponents(); + setLocationRelativeTo(this); + } + + /** + * 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. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + urlTxt = new javax.swing.JTextField(); + userNameTxt = new javax.swing.JTextField(); + passwordTxt = new javax.swing.JPasswordField(); + okButton = new javax.swing.JButton(); + jLabel4 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage( + ServerDetailsView.class, "ServerDetailsView.jLabel1.text")); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage( + ServerDetailsView.class, "ServerDetailsView.jLabel2.text")); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage( + ServerDetailsView.class, "ServerDetailsView.jLabel3.text")); + + urlTxt.setText(org.openide.util.NbBundle.getMessage(ServerDetailsView.class, "ServerDetailsView.urlTxt.text")); + + userNameTxt.setText(org.openide.util.NbBundle.getMessage(ServerDetailsView.class, + "ServerDetailsView.userNameTxt.text")); + + passwordTxt.setText(org.openide.util.NbBundle.getMessage(ServerDetailsView.class, + "ServerDetailsView.passwordTxt.text")); + + org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage( + ServerDetailsView.class, "ServerDetailsView.okButton.text")); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(final java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage( + ServerDetailsView.class, "ServerDetailsView.jLabel4.text")); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(41, 41, 41) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 74, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2) + .addComponent(jLabel3)) + .addGap(39, 39, 39) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(userNameTxt) + .addComponent(urlTxt) + .addComponent(passwordTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 155, + javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(layout.createSequentialGroup() + .addGap(101, 101, 101) + .addComponent(jLabel4))) + .addContainerGap(41, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(urlTxt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(userNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(passwordTxt, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap()) + ); + + pack(); + } + // </editor-fold>//GEN-END:initComponents + + private void okButtonActionPerformed(final java.awt.event.ActionEvent evt) { + String url = urlTxt.getText(); + String userName = userNameTxt.getText(); + String password = new String(passwordTxt.getPassword()); + File file = new File("UserData.txt"); + try { + FileWriter fileWriter = new FileWriter(file); + fileWriter.write(url + "\n" + userName + "\n" + password); + fileWriter.flush(); + this.dispose(); + } catch (IOException ex) { + JOptionPane.showMessageDialog(this, "Error while saving Data.", "Error", JOptionPane.ERROR_MESSAGE); + } + } + + public void setDetails(final String host, final String userName, + final String password) { + urlTxt.setText(host); + userNameTxt.setText(userName); + passwordTxt.setText(password); + } + + public static void main(final String[] args) { + /* Set the Nimbus look and feel */ + //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(ServerDetailsView.class.getName()).log( + java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(ServerDetailsView.class.getName()).log( + java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(ServerDetailsView.class.getName()).log( + java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(ServerDetailsView.class.getName()).log( + java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + ServerDetailsView dialog = new ServerDetailsView( + new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing( + final java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JButton okButton; + private javax.swing.JPasswordField passwordTxt; + private javax.swing.JTextField urlTxt; + private javax.swing.JTextField userNameTxt; + // End of variables declaration//GEN-END:variables +} http://git-wip-us.apache.org/repos/asf/syncope/blob/b9f59a6d/ide/netbeans/src/main/nbm/MANIFEST.MF ---------------------------------------------------------------------- diff --git a/ide/netbeans/src/main/nbm/MANIFEST.MF b/ide/netbeans/src/main/nbm/MANIFEST.MF new file mode 100644 index 0000000..b147609 --- /dev/null +++ b/ide/netbeans/src/main/nbm/MANIFEST.MF @@ -0,0 +1,3 @@ +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Manifest-Version: 1.0 +OpenIDE-Module-Requires: org.openide.windows.WindowManager