You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/07/22 10:18:24 UTC
[4/4] syncope git commit: [SYNCOPE-809] GSoC Project (Eclipse Plugin
for Apache Syncope) - This closes #28
[SYNCOPE-809] GSoC Project (Eclipse Plugin for Apache Syncope) - This closes #28
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/6fee50d7
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/6fee50d7
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/6fee50d7
Branch: refs/heads/master
Commit: 6fee50d752f655c6fbef22ecdf24b27025e661af
Parents: 12d481a
Author: Tushar <tu...@gmail.com>
Authored: Wed Jul 20 19:37:04 2016 +0530
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Fri Jul 22 12:17:37 2016 +0200
----------------------------------------------------------------------
.gitignore | 2 +
.../META-INF/MANIFEST.MF | 48 +
.../build.properties | 57 +
.../plugin.xml | 63 +
.../pom.xml | 99 ++
.../syncope/ide/eclipse/plugin/Activator.java | 47 +
.../plugin/dialogs/AddTemplateDialog.java | 97 ++
.../ide/eclipse/plugin/dialogs/LoginDialog.java | 186 ++
.../ide/eclipse/plugin/editors/HTMLEditor.java | 36 +
.../plugin/editors/HTMLSourceConfiguration.java | 251 +++
.../eclipse/plugin/editors/TemplateEditor.java | 199 +++
.../plugin/editors/TemplateEditorInput.java | 122 ++
.../plugin/editors/htmlhelpers/AssistInfo.java | 117 ++
.../editors/htmlhelpers/AttributeInfo.java | 88 +
.../editors/htmlhelpers/CSSBlockScanner.java | 47 +
.../plugin/editors/htmlhelpers/CSSRule.java | 110 ++
.../plugin/editors/htmlhelpers/DocTypeRule.java | 65 +
.../htmlhelpers/HTMLAutoEditStrategy.java | 77 +
.../htmlhelpers/HTMLCompletionProcessor.java | 331 ++++
.../editors/htmlhelpers/HTMLContextType.java | 36 +
.../htmlhelpers/HTMLFileDocumentProvider.java | 50 +
.../htmlhelpers/HTMLPartitionScanner.java | 76 +
.../plugin/editors/htmlhelpers/HTMLScanner.java | 33 +
.../htmlhelpers/HTMLTagDamagerRepairer.java | 61 +
.../editors/htmlhelpers/HTMLTagScanner.java | 51 +
.../HTMLTemplateAssistProcessor.java | 87 +
.../htmlhelpers/HTMLTemplateManager.java | 68 +
.../htmlhelpers/HTMLWhitespaceDetector.java | 27 +
.../htmlhelpers/IHTMLColorConstants.java | 42 +
.../editors/htmlhelpers/InnerCSSScanner.java | 54 +
.../htmlhelpers/InnerJavaScriptScanner.java | 54 +
.../htmlhelpers/JavaScriptDamagerRepairer.java | 57 +
.../editors/htmlhelpers/JavaScriptScanner.java | 88 +
.../editors/htmlhelpers/JavaWordDetector.java | 33 +
.../editors/htmlhelpers/SyncopeTagRule.java | 119 ++
.../editors/htmlhelpers/SyncopeTagScanner.java | 51 +
.../editors/htmlhelpers/TagDefinition.java | 1582 ++++++++++++++++++
.../plugin/editors/htmlhelpers/TagInfo.java | 128 ++
.../plugin/editors/htmlhelpers/TagRule.java | 119 ++
.../plugin/editors/htmlhelpers/TextInfo.java | 50 +
.../ide/eclipse/plugin/views/SyncopeView.java | 534 ++++++
.../ide/eclipse/plugin/views/TreeObject.java | 44 +
.../ide/eclipse/plugin/views/TreeParent.java | 49 +
.../src/main/resources/icons/syncope.png | Bin 0 -> 1184 bytes
ide/eclipse/pom.xml | 120 ++
.../category.xml | 29 +
.../org.apache.syncope.ide.eclipse.site/pom.xml | 66 +
ide/pom.xml | 69 +
pom.xml | 25 +
49 files changed, 5844 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index a23cd5b..0059895 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ target
maven-eclipse.xml
.externalToolBuilders
archetype/src/main/resources/archetype-resources/pom.xml
+ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/bin/
+ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/lib/
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/META-INF/MANIFEST.MF b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8bce572
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/META-INF/MANIFEST.MF
@@ -0,0 +1,48 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Syncope Eclipse Plugin
+Bundle-SymbolicName: org.apache.syncope.ide.eclipse.plugin;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.apache.syncope.ide.eclipse.plugin.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.sse.ui;bundle-version="1.3.401"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: lib/asm.jar,
+ lib/commons-codec.jar,
+ lib/commons-collections4.jar,
+ lib/commons-lang3.jar,
+ lib/cxf-core.jar,
+ lib/cxf-rt-databinding-jaxb.jar,
+ lib/cxf-rt-frontend-jaxrs.jar,
+ lib/cxf-rt-rs-client.jar,
+ lib/cxf-rt-rs-extension-search.jar,
+ lib/cxf-rt-transports-http.jar,
+ lib/cxf-rt-wsdl.jar,
+ lib/jackson-annotations.jar,
+ lib/jackson-core.jar,
+ lib/jackson-databind.jar,
+ lib/jackson-datatype-joda.jar,
+ lib/jackson-jaxrs-base.jar,
+ lib/jackson-jaxrs-json-provider.jar,
+ lib/jackson-module-jaxb-annotations.jar,
+ lib/javax.annotation-api.jar,
+ lib/javax.ws.rs-api.jar,
+ lib/jaxb-core.jar,
+ lib/jaxb-impl.jar,
+ lib/joda-time.jar,
+ lib/log4j-api.jar,
+ lib/slf4j-api.jar,
+ lib/stax2-api.jar,
+ lib/syncope-client-lib.jar,
+ lib/syncope-common-lib.jar,
+ lib/syncope-common-rest-api.jar,
+ lib/validation-api.jar,
+ lib/woodstox-core-asl.jar,
+ lib/wsdl4j.jar,
+ lib/xmlschema-core.jar,
+ .
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/build.properties
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/build.properties b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/build.properties
new file mode 100644
index 0000000..759669b
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/build.properties
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+source.. = src/main/java/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ src/main/resources/icons/,\
+ lib/asm.jar,\
+ lib/commons-codec.jar,\
+ lib/commons-collections4.jar,\
+ lib/commons-lang3.jar,\
+ lib/cxf-core.jar,\
+ lib/cxf-rt-databinding-jaxb.jar,\
+ lib/cxf-rt-frontend-jaxrs.jar,\
+ lib/cxf-rt-rs-client.jar,\
+ lib/cxf-rt-rs-extension-search.jar,\
+ lib/cxf-rt-transports-http.jar,\
+ lib/cxf-rt-wsdl.jar,\
+ lib/jackson-annotations.jar,\
+ lib/jackson-core.jar,\
+ lib/jackson-databind.jar,\
+ lib/jackson-datatype-joda.jar,\
+ lib/jackson-jaxrs-base.jar,\
+ lib/jackson-jaxrs-json-provider.jar,\
+ lib/jackson-module-jaxb-annotations.jar,\
+ lib/javax.annotation-api.jar,\
+ lib/javax.ws.rs-api.jar,\
+ lib/jaxb-core.jar,\
+ lib/jaxb-impl.jar,\
+ lib/joda-time.jar,\
+ lib/log4j-api.jar,\
+ lib/slf4j-api.jar,\
+ lib/stax2-api.jar,\
+ lib/syncope-client-lib.jar,\
+ lib/syncope-common-lib.jar,\
+ lib/syncope-common-rest-api.jar,\
+ lib/validation-api.jar,\
+ lib/woodstox-core-asl.jar,\
+ lib/wsdl4j.jar,\
+ lib/xmlschema-core.jar
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/plugin.xml
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/plugin.xml b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/plugin.xml
new file mode 100644
index 0000000..2737d91
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/plugin.xml
@@ -0,0 +1,63 @@
+<?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.
+-->
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ name="Apache Syncope"
+ id="org.apache.syncope.ide.eclipse.plugin">
+ </category>
+ <view
+ name="Apache Syncope Templates"
+ icon="src/main/resources/icons/syncope.png"
+ category="org.apache.syncope.ide.eclipse.plugin"
+ class="org.apache.syncope.ide.eclipse.plugin.views.SyncopeView"
+ id="org.apache.syncope.ide.eclipse.plugin.views.SyncopeView">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <view
+ ratio="0.5"
+ relative="org.eclipse.ui.views.ProblemView"
+ relationship="right"
+ id="org.apache.syncope.ide.eclipse.plugin.views.SyncopeView">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.help.contexts">
+ <contexts
+ file="contexts.xml">
+ </contexts>
+ </extension>
+ <extension point="org.eclipse.ui.editors">
+ <editor id="org.apache.syncope.ide.eclipse.plugin.editors.TemplateEditor"
+ name="Template Editor"
+ icon="src/main/resources/icons/syncope.png"
+ class="org.apache.syncope.ide.eclipse.plugin.editors.TemplateEditor"
+ />
+ </extension>
+
+</plugin>
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/pom.xml
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/pom.xml b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/pom.xml
new file mode 100644
index 0000000..dc22daa
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/pom.xml
@@ -0,0 +1,99 @@
+<?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 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.ide</groupId>
+ <artifactId>syncope-ide-eclipse</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../../</relativePath>
+ </parent>
+
+ <name>Apache Syncope IDE Eclipse Plugin</name>
+ <description>Apache Syncope IDE Eclipse Plugin</description>
+ <groupId>org.apache.syncope.ide.eclipse</groupId>
+ <artifactId>org.apache.syncope.ide.eclipse.plugin</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.syncope.client</groupId>
+ <artifactId>syncope-client-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <rootpom.basedir>${basedir}/../../../..</rootpom.basedir>
+ </properties>
+
+ <build>
+ <outputDirectory>./bin</outputDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-libraries</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>lib</outputDirectory>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>apache-release</id>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <inherited>false</inherited>
+ <configuration>
+ <skipSource>true</skipSource>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/Activator.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/Activator.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/Activator.java
new file mode 100644
index 0000000..3c78737
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/Activator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ide.eclipse.plugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.apache.syncope.ide.eclipse.plugin";
+ private static Activator PLUGIN;
+
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ PLUGIN = this;
+ }
+
+ public void stop(final BundleContext context) throws Exception {
+ PLUGIN = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return PLUGIN;
+ }
+
+ public static ImageDescriptor getImageDescriptor(final String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/AddTemplateDialog.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/AddTemplateDialog.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/AddTemplateDialog.java
new file mode 100644
index 0000000..9bedcfd
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/AddTemplateDialog.java
@@ -0,0 +1,97 @@
+/*
+ * 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.ide.eclipse.plugin.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class AddTemplateDialog extends TitleAreaDialog {
+
+ private Text key;
+ private String keyString;
+
+ public AddTemplateDialog(final Shell parentShell) {
+ super(parentShell);
+ keyString = "";
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ setTitle("Add Template");
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(final Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "Add", true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ Composite area = (Composite) super.createDialogArea(parent);
+ Composite container = new Composite(area, SWT.NONE);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(2, false);
+ container.setLayout(layout);
+ createKeyField(container);
+ return area;
+ }
+
+ private void createKeyField(final Composite container) {
+ Label keyLabel = new Label(container, SWT.NONE);
+ keyLabel.setText("Key");
+ GridData keyGD = new GridData();
+ keyGD.grabExcessHorizontalSpace = true;
+ keyGD.horizontalAlignment = GridData.FILL;
+ key = new Text(container, SWT.BORDER);
+ key.setLayoutData(keyGD);
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ // save content of the Text fields because they get disposed
+ // as soon as the Dialog closes
+ private void saveInput() {
+ keyString = key.getText();
+ }
+
+ @Override
+ protected void okPressed() {
+ saveInput();
+ setReturnCode(200);
+ super.okPressed();
+ }
+
+ public String getKey() {
+ return keyString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/LoginDialog.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/LoginDialog.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/LoginDialog.java
new file mode 100644
index 0000000..f59bf11
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/dialogs/LoginDialog.java
@@ -0,0 +1,186 @@
+/*
+ * 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.ide.eclipse.plugin.dialogs;
+
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+public class LoginDialog extends TitleAreaDialog {
+ private Text deploymentUrlInp;
+ private Text usernameInp;
+ private Text passwordInp;
+ private String deploymentUrl;
+ private String username;
+ private String password;
+ private Button resetbutton;
+ private Preferences instancePreferences = InstanceScope.INSTANCE
+ .getNode("org.apache.syncope.ide.eclipse.plugin.dialogs.prefs");
+ private Preferences configPreferences = ConfigurationScope.INSTANCE
+ .getNode("org.apache.syncope.ide.eclipse.plugin.dialogs.prefs");
+ private Preferences sub1 = configPreferences.node("depPref");
+ private Preferences sub2 = instancePreferences.node("userPref");
+
+ public LoginDialog(final Shell parentShell) {
+ super(parentShell);
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ setTitle("Login to Apache Syncope");
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(final Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "Login", true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ resetbutton = createButton(parent, IDialogConstants.NO_ID, "Reset Fields", false);
+ resetbutton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ deploymentUrlInp.setText("");
+ usernameInp.setText("");
+ passwordInp.setText("");
+
+ // add to preferences
+ saveInput();
+ }
+ });
+ }
+
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ Composite area = (Composite) super.createDialogArea(parent);
+ Composite container = new Composite(area, SWT.NONE);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(2, false);
+ container.setLayout(layout);
+
+ createDeploymentUrl(container);
+ createUsername(container);
+ createPassword(container);
+
+ return area;
+ }
+
+ private void createDeploymentUrl(final Composite container) {
+ Label lbtDeploymentUrl = new Label(container, SWT.NONE);
+ lbtDeploymentUrl.setText("Deployment Url");
+
+ GridData dataDeploymentUrl = new GridData();
+ dataDeploymentUrl.grabExcessHorizontalSpace = true;
+ dataDeploymentUrl.horizontalAlignment = GridData.FILL;
+ deploymentUrlInp = new Text(container, SWT.BORDER);
+ deploymentUrlInp.setLayoutData(dataDeploymentUrl);
+ String depurl = sub1.get("deploymentUrl", "http://");
+ if (depurl != null) {
+ deploymentUrlInp.setText(depurl);
+ }
+ }
+
+ private void createUsername(final Composite container) {
+ Label lbtUsername = new Label(container, SWT.NONE);
+ lbtUsername.setText("Username");
+
+ GridData dataUsername = new GridData();
+ dataUsername.grabExcessHorizontalSpace = true;
+ dataUsername.horizontalAlignment = GridData.FILL;
+ usernameInp = new Text(container, SWT.BORDER);
+ usernameInp.setLayoutData(dataUsername);
+ String usernameString = sub2.get("username", "");
+ if (usernameString != null) {
+ usernameInp.setText(usernameString);
+ }
+ }
+
+ private void createPassword(final Composite container) {
+ Label lbtPassword = new Label(container, SWT.NONE);
+ lbtPassword.setText("Password");
+
+ GridData dataPassword = new GridData();
+ dataPassword.grabExcessHorizontalSpace = true;
+ dataPassword.horizontalAlignment = GridData.FILL;
+ passwordInp = new Text(container, SWT.BORDER | SWT.PASSWORD);
+ passwordInp.setLayoutData(dataPassword);
+ String passwordString = sub2.get("password", "");
+ if (passwordString != null) {
+ passwordInp.setText(passwordString);
+ }
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ // save content of the Text fields because they get disposed
+ // as soon as the Dialog closes
+ private void saveInput() {
+ deploymentUrl = deploymentUrlInp.getText();
+ username = usernameInp.getText();
+ password = passwordInp.getText();
+
+ // add data to preferences for repopulation later
+ sub1.put("deploymentUrl", deploymentUrl);
+ sub2.put("username", username);
+ sub2.put("password", password);
+
+ try {
+ instancePreferences.flush();
+ configPreferences.flush();
+ } catch (final BackingStoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void okPressed() {
+ saveInput();
+ setReturnCode(200);
+ super.okPressed();
+ }
+
+ public String getDeploymentUrl() {
+ return deploymentUrl;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLEditor.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLEditor.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLEditor.java
new file mode 100644
index 0000000..89f2a2e
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLEditor.java
@@ -0,0 +1,36 @@
+/*
+ * 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.ide.eclipse.plugin.editors;
+
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLFileDocumentProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.editors.text.TextEditor;
+
+public class HTMLEditor extends TextEditor {
+ public HTMLEditor() {
+ super();
+ setSourceViewerConfiguration(new HTMLSourceConfiguration());
+ }
+
+ protected final void doSetInput(final IEditorInput input) throws CoreException {
+ setDocumentProvider(new HTMLFileDocumentProvider());
+ super.doSetInput(input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLSourceConfiguration.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLSourceConfiguration.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLSourceConfiguration.java
new file mode 100644
index 0000000..32bfde7
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/HTMLSourceConfiguration.java
@@ -0,0 +1,251 @@
+/*
+ * 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.ide.eclipse.plugin.editors;
+
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLAutoEditStrategy;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLCompletionProcessor;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLPartitionScanner;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLScanner;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLTagDamagerRepairer;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.HTMLTagScanner;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.IHTMLColorConstants;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.InnerCSSScanner;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.InnerJavaScriptScanner;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.JavaScriptDamagerRepairer;
+import org.apache.syncope.ide.eclipse.plugin.editors.htmlhelpers.SyncopeTagScanner;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+
+public class HTMLSourceConfiguration extends TextSourceViewerConfiguration {
+
+ private HTMLTagScanner tagScanner;
+ private SyncopeTagScanner syncopeTagScanner;
+ private HTMLScanner scanner;
+ private RuleBasedScanner commentScanner;
+ private RuleBasedScanner scriptScanner;
+ private RuleBasedScanner doctypeScanner;
+ private RuleBasedScanner directiveScanner;
+ private RuleBasedScanner javaScriptScanner;
+ private RuleBasedScanner cssScanner;
+ private ContentAssistant contentAssistant;
+ private HTMLAutoEditStrategy autoEditStrategy;
+
+ public HTMLSourceConfiguration() {
+ contentAssistant = new ContentAssistant();
+ HTMLCompletionProcessor proc = new HTMLCompletionProcessor();
+ proc.setAutoAssistChars("</\"".toCharArray());
+ proc.setAssistCloseTag(true);
+
+ contentAssistant.setContentAssistProcessor(proc, IDocument.DEFAULT_CONTENT_TYPE);
+ contentAssistant.setContentAssistProcessor(proc, IDocument.DEFAULT_CONTENT_TYPE);
+ contentAssistant.setContentAssistProcessor(proc, HTMLPartitionScanner.HTML_TAG);
+ contentAssistant.setContentAssistProcessor(proc, HTMLPartitionScanner.PREFIX_TAG);
+
+ contentAssistant.enableAutoActivation(true);
+ contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+ }
+
+ protected HTMLAutoEditStrategy createAutoEditStrategy() {
+ return new HTMLAutoEditStrategy();
+ }
+
+ public final HTMLAutoEditStrategy getAutoEditStrategy() {
+ if (this.autoEditStrategy == null) {
+ this.autoEditStrategy = createAutoEditStrategy();
+ }
+ return this.autoEditStrategy;
+ }
+
+ public final IAutoEditStrategy[] getAutoEditStrategies(final ISourceViewer sourceViewer,
+ final String contentType) {
+ return new IAutoEditStrategy[]{ getAutoEditStrategy() };
+ }
+
+ @Override
+ public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) {
+
+ contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
+ return contentAssistant;
+ }
+
+ protected HTMLTagScanner getTagScanner() {
+ if (tagScanner == null) {
+ tagScanner = new HTMLTagScanner(false);
+ RGB rgb = IHTMLColorConstants.TAG;
+ Color color = new Color(Display.getCurrent(), rgb);
+ tagScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return tagScanner;
+ }
+
+ protected SyncopeTagScanner getSyncopeTagScanner() {
+ if (syncopeTagScanner == null) {
+ syncopeTagScanner = new SyncopeTagScanner(false);
+ RGB rgb = IHTMLColorConstants.HTML_COMMENT;
+ Color color = new Color(Display.getCurrent(), rgb);
+ syncopeTagScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return syncopeTagScanner;
+ }
+
+ protected HTMLScanner getHTMLScanner() {
+ if (scanner == null) {
+ scanner = new HTMLScanner();
+ RGB rgb = IHTMLColorConstants.FOREGROUND;
+ Color color = new Color(Display.getCurrent(), rgb);
+ scanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return scanner;
+ }
+
+ protected RuleBasedScanner getCommentScanner() {
+ if (commentScanner == null) {
+ commentScanner = new RuleBasedScanner();
+ RGB rgb = IHTMLColorConstants.HTML_COMMENT;
+ Color color = new Color(Display.getCurrent(), rgb);
+ commentScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return commentScanner;
+ }
+
+ protected RuleBasedScanner getScriptScanner() {
+ if (scriptScanner == null) {
+ scriptScanner = new RuleBasedScanner();
+ RGB rgb = IHTMLColorConstants.SCRIPT;
+ Color color = new Color(Display.getCurrent(), rgb);
+ scriptScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return scriptScanner;
+ }
+
+ protected RuleBasedScanner getDoctypeScanner() {
+ if (doctypeScanner == null) {
+ doctypeScanner = new RuleBasedScanner();
+ RGB rgb = IHTMLColorConstants.PROC_INSTR;
+ Color color = new Color(Display.getCurrent(), rgb);
+ doctypeScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return doctypeScanner;
+ }
+
+ protected RuleBasedScanner getDirectiveScanner() {
+ if (directiveScanner == null) {
+ directiveScanner = new RuleBasedScanner();
+ RGB rgb = IHTMLColorConstants.SCRIPT;
+ Color color = new Color(Display.getCurrent(), rgb);
+ directiveScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return directiveScanner;
+ }
+
+ protected RuleBasedScanner getJavaScriptScanner() {
+ if (javaScriptScanner == null) {
+ javaScriptScanner = new InnerJavaScriptScanner();
+ RGB rgb = IHTMLColorConstants.FOREGROUND;
+ Color color = new Color(Display.getCurrent(), rgb);
+ javaScriptScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return javaScriptScanner;
+ }
+
+ protected RuleBasedScanner getCSSScanner() {
+ if (cssScanner == null) {
+ cssScanner = new InnerCSSScanner();
+ RGB rgb = IHTMLColorConstants.FOREGROUND;
+ Color color = new Color(Display.getCurrent(), rgb);
+ cssScanner.setDefaultReturnToken(new Token(new TextAttribute(color)));
+ }
+ return cssScanner;
+ }
+
+ @Override
+ public IPresentationReconciler getPresentationReconciler(final ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+ DefaultDamagerRepairer dr = null;
+
+ dr = new HTMLTagDamagerRepairer(getTagScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_TAG);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_TAG);
+
+ dr = new HTMLTagDamagerRepairer(getTagScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.PREFIX_TAG);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.PREFIX_TAG);
+
+ dr = new HTMLTagDamagerRepairer(getSyncopeTagScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.SYNCOPE_TAG);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.SYNCOPE_TAG);
+
+ dr = new HTMLTagDamagerRepairer(getHTMLScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ dr = new HTMLTagDamagerRepairer(getCommentScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_COMMENT);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_COMMENT);
+
+ dr = new DefaultDamagerRepairer(getScriptScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_SCRIPT);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_SCRIPT);
+
+ dr = new DefaultDamagerRepairer(getDoctypeScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_DOCTYPE);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_DOCTYPE);
+
+ dr = new DefaultDamagerRepairer(getDirectiveScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_DIRECTIVE);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_DIRECTIVE);
+
+ dr = new JavaScriptDamagerRepairer(getJavaScriptScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.JAVASCRIPT);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.JAVASCRIPT);
+
+ dr = new JavaScriptDamagerRepairer(getCSSScanner());
+ reconciler.setDamager(dr, HTMLPartitionScanner.HTML_CSS);
+ reconciler.setRepairer(dr, HTMLPartitionScanner.HTML_CSS);
+
+ return reconciler;
+ }
+
+ public String[] getConfiguredContentTypes(final ISourceViewer sourceViewer) {
+ return new String[] {
+ IDocument.DEFAULT_CONTENT_TYPE,
+ HTMLPartitionScanner.HTML_COMMENT,
+ HTMLPartitionScanner.HTML_TAG,
+ HTMLPartitionScanner.PREFIX_TAG,
+ HTMLPartitionScanner.HTML_SCRIPT,
+ HTMLPartitionScanner.HTML_DOCTYPE,
+ HTMLPartitionScanner.HTML_DIRECTIVE,
+ HTMLPartitionScanner.JAVASCRIPT,
+ HTMLPartitionScanner.HTML_CSS,
+ HTMLPartitionScanner.SYNCOPE_TAG};
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditor.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditor.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditor.java
new file mode 100644
index 0000000..7a1468f
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditor.java
@@ -0,0 +1,199 @@
+/*
+ * 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.ide.eclipse.plugin.editors;
+
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.common.lib.types.MailTemplateFormat;
+import org.apache.syncope.common.lib.types.ReportTemplateFormat;
+import org.apache.syncope.ide.eclipse.plugin.Activator;
+import org.apache.syncope.ide.eclipse.plugin.views.SyncopeView;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+public class TemplateEditor extends MultiPageEditorPart implements IResourceChangeListener {
+
+ public static final String ID = "org.apache.syncope.ide.eclipse.plugin.editors.TemplateEditor";
+ private static final String SAVE_TEMPLATE_LABEL = "Saving Template";
+ private static final String ERROR_NESTED_EDITOR = "Error creating nested text editor";
+ private static final String ERROR_INCORRECT_INPUT = "Wrong Input";
+ private TextEditor editor;
+ private TemplateEditorInput input;
+ private String[] inputStringList;
+ private String[] titleList;
+ private String[] tooltipList;
+
+ void createPage(final String inputString, final String title, final String tooltip) {
+ try {
+ if (title.equals(SyncopeView.TEMPLATE_FORMAT_HTML)) {
+ editor = new HTMLEditor();
+ } else {
+ editor = new StructuredTextEditor();
+ }
+ int index = addPage(editor, (IEditorInput) new TemplateEditorInput(inputString, title, tooltip));
+ setPageText(index, editor.getTitle());
+ } catch (final PartInitException e) {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ ERROR_NESTED_EDITOR,
+ null,
+ e.getStatus());
+ }
+ }
+
+ protected void createPages() {
+ for (int i = 0; i < inputStringList.length; i++) {
+ createPage(inputStringList[i], titleList[i], tooltipList[i]);
+ }
+ }
+
+ public void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ super.dispose();
+ }
+
+ public void doSave(final IProgressMonitor monitor) {
+ final ITextEditor ite = (ITextEditor) getActiveEditor();
+ final String content = ite.getDocumentProvider().getDocument(ite.getEditorInput()).get();
+ Job saveJob = new Job(SAVE_TEMPLATE_LABEL) {
+ @Override
+ protected IStatus run(final IProgressMonitor arg0) {
+ try {
+ if (ite.getTitle().equals(SyncopeView.TEMPLATE_FORMAT_HTML)) {
+ SyncopeView.setMailTemplateContent(ite.getTitleToolTip(),
+ MailTemplateFormat.HTML, content);
+ } else if (ite.getTitle().equals(SyncopeView.TEMPLATE_FORMAT_TEXT)) {
+ SyncopeView.setMailTemplateContent(ite.getTitleToolTip(),
+ MailTemplateFormat.TEXT, content);
+ } else if (ite.getTitle().equals(SyncopeView.TEMPLATE_FORMAT_CSV)) {
+ SyncopeView.setReportTemplateContent(ite.getTitleToolTip(),
+ ReportTemplateFormat.CSV, content);
+ } else if (ite.getTitle().equals(SyncopeView.TEMPLATE_FORMAT_XSL_FO)) {
+ SyncopeView.setReportTemplateContent(ite.getTitleToolTip(),
+ ReportTemplateFormat.FO, content);
+ } else if (ite.getTitle().equals(SyncopeView.TEMPLATE_FORMAT_XSL_HTML)) {
+ SyncopeView.setReportTemplateContent(ite.getTitleToolTip(),
+ ReportTemplateFormat.HTML, content);
+ } else {
+ throw new Exception("Not a valid editor title");
+ }
+ } catch (final SyncopeClientException e) {
+ e.printStackTrace();
+ if (ClientExceptionType.NotFound.equals(e.getType())) {
+ /*
+ * If a deleted template is being edited
+ * close editor and display error
+ */
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ TemplateEditor.this.getSite().getPage().closeEditor(
+ TemplateEditor.this, false);
+ }
+ });
+ return new org.eclipse.core.runtime.Status(
+ org.eclipse.core.runtime.Status.ERROR, Activator.PLUGIN_ID,
+ "Template No longer exists");
+ }
+ } catch (final Exception e) {
+ e.printStackTrace();
+ } finally {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ite.doSave(monitor);
+ }
+ });
+ }
+ if (monitor.isCanceled()) {
+ return org.eclipse.core.runtime.Status.CANCEL_STATUS;
+ }
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ }
+ };
+ saveJob.setUser(true);
+ saveJob.schedule();
+ }
+
+ public void doSaveAs() {
+ getActiveEditor().doSaveAs();
+ }
+ public void gotoMarker(final IMarker marker) {
+ setActivePage(0);
+ IDE.gotoMarker(getEditor(0), marker);
+ }
+ public void init(final IEditorSite site, final IEditorInput editorInput)
+ throws PartInitException {
+ if (!(editorInput instanceof TemplateEditorInput)) {
+ throw new RuntimeException(ERROR_INCORRECT_INPUT);
+ }
+ this.input = (TemplateEditorInput) editorInput;
+
+ this.inputStringList = this.input.getInputStringList();
+ this.titleList = this.input.getTitleList();
+ this.tooltipList = this.input.getTooltipList();
+
+ setSite(site);
+ setInput(input);
+ setPartName(this.tooltipList[0]);
+ }
+
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ protected void pageChange(final int newPageIndex) {
+ super.pageChange(newPageIndex);
+ }
+
+ public void resourceChanged(final IResourceChangeEvent event) {
+ if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+ for (int i = 0; i < pages.length; i++) {
+ if (((FileEditorInput) editor.getEditorInput()).getFile().getProject()
+ .equals(event.getResource())) {
+ IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
+ pages[i].closeEditor(editorPart, true);
+ }
+ }
+ }
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditorInput.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditorInput.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditorInput.java
new file mode 100644
index 0000000..e677596
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/TemplateEditorInput.java
@@ -0,0 +1,122 @@
+/*
+ * 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.ide.eclipse.plugin.editors;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+
+public class TemplateEditorInput implements IStorageEditorInput {
+
+ private final String inputString;
+ private final String title;
+ private final String tooltip;
+
+ private String[] inputStringList;
+ private String[] titleList;
+ private String[] tooltipList;
+
+ public String[] getInputStringList() {
+ return inputStringList;
+ }
+
+ public String[] getTitleList() {
+ return titleList;
+ }
+
+ public String[] getTooltipList() {
+ return tooltipList;
+ }
+
+ public String getInputString() {
+ return inputString;
+ }
+
+ public TemplateEditorInput(final String inputString, final String title, final String tooltip) {
+ this.inputString = inputString;
+ this.title = title;
+ this.tooltip = tooltip;
+ }
+
+ public TemplateEditorInput(final String[] inputStringList, final String[] titleList,
+ final String[] tooltipList) {
+ this.inputString = null;
+ this.title = null;
+ this.tooltip = null;
+
+ this.inputStringList = inputStringList;
+ this.titleList = titleList;
+ this.tooltipList = tooltipList;
+ }
+
+ public boolean exists() {
+ return false;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ public <T> T getAdapter(final Class<T> adapter) {
+ return null;
+ }
+
+ public String getName() {
+ return title;
+ }
+
+ public String getToolTipText() {
+ return tooltip;
+ }
+
+ public IStorage getStorage() throws CoreException {
+ return new IStorage() {
+ public InputStream getContents() throws CoreException {
+ return new ByteArrayInputStream(inputString.getBytes(
+ java.nio.charset.Charset.defaultCharset()));
+ }
+
+ public IPath getFullPath() {
+ return null;
+ }
+
+ public String getName() {
+ return TemplateEditorInput.this.getName();
+ }
+
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ public <T> T getAdapter(final Class<T> adapter) {
+ return null;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AssistInfo.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AssistInfo.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AssistInfo.java
new file mode 100644
index 0000000..4006830
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AssistInfo.java
@@ -0,0 +1,117 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+
+public class AssistInfo {
+
+ private String displayString;
+ private String replaceString;
+ private Image image;
+ private String additionalInfo;
+
+ public AssistInfo(final String displayString) {
+ this.displayString = displayString;
+ this.replaceString = displayString;
+ }
+
+ public AssistInfo(final String displayString, final Image image) {
+ this.displayString = displayString;
+ this.replaceString = displayString;
+ this.image = image;
+ }
+
+ public AssistInfo(final String replaceString, final String displayString) {
+ this.displayString = displayString;
+ this.replaceString = replaceString;
+ }
+
+ public AssistInfo(final String replaceString, final String displayString, final Image image) {
+ this.displayString = displayString;
+ this.replaceString = replaceString;
+ this.image = image;
+ }
+
+ public AssistInfo(final String replaceString, final String displayString, final Image image,
+ final String additionalInfo) {
+ this.displayString = displayString;
+ this.replaceString = replaceString;
+ this.image = image;
+ this.additionalInfo = additionalInfo;
+ }
+
+ public String getDisplayString() {
+ return displayString;
+ }
+
+ public String getReplaceString() {
+ return replaceString;
+ }
+
+ public String getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public Image getImage() {
+ return this.image;
+ }
+
+ public ICompletionProposal toCompletionProposal(final int offset, final String matchString,
+ final Image defaultImage) {
+ return new CompletionProposal(
+ getReplaceString(),
+ offset - matchString.length(), matchString.length(),
+ getReplaceString().length(),
+ getImage() == null ? defaultImage : getImage(),
+ getDisplayString(), null, getAdditionalInfo());
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof AssistInfo) {
+ AssistInfo info = (AssistInfo) obj;
+ if (compareString(info.getReplaceString(), getReplaceString())
+ && compareString(info.getDisplayString(), getDisplayString())
+ && compareString(info.getAdditionalInfo(), getAdditionalInfo())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override public int hashCode() {
+ return (this.getReplaceString().hashCode()
+ + this.getDisplayString().hashCode()
+ + this.getAdditionalInfo().hashCode());
+ }
+
+ public static boolean compareString(final String value1, final String value2) {
+ if (value1 == null && value2 == null) {
+ return true;
+ }
+ if (value1 != null && value1.equals(value2)) {
+ return true;
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AttributeInfo.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AttributeInfo.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AttributeInfo.java
new file mode 100644
index 0000000..dcae15a
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/AttributeInfo.java
@@ -0,0 +1,88 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AttributeInfo {
+
+ private String attributeName;
+ private boolean hasValue;
+ private boolean required = false;
+ private String description;
+ private List<String> values = new ArrayList<String>();
+ public enum AttributeTypeOptions {
+ NONE, ALIGN, VALIGN, INPUT_TYPE, CSS, FILE, ID, IDREF, IDREFS, TARGET
+ }
+ private AttributeTypeOptions attributeType;
+
+ public AttributeInfo(final String attributeName, final boolean hasValue) {
+ this(attributeName, hasValue, AttributeTypeOptions.NONE);
+ }
+
+ public AttributeInfo(final String attributeName, final boolean hasValue,
+ final AttributeTypeOptions attributeType) {
+ this(attributeName, hasValue, attributeType, false);
+ }
+
+ public AttributeInfo(final String attributeName, final boolean hasValue,
+ final AttributeTypeOptions attributeType, final boolean required) {
+ this.attributeName = attributeName;
+ this.hasValue = hasValue;
+ this.attributeType = attributeType;
+ this.required = required;
+ }
+
+ public AttributeTypeOptions getAttributeType() {
+ return this.attributeType;
+ }
+
+ public void setAttributeType(final AttributeTypeOptions type) {
+ this.attributeType = type;
+ }
+
+ public String getAttributeName() {
+ return this.attributeName;
+ }
+
+ public boolean hasValue() {
+ return this.hasValue;
+ }
+
+ public boolean isRequired() {
+ return this.required;
+ }
+
+ public void addValue(final String value) {
+ this.values.add(value);
+ }
+
+ public String[] getValues() {
+ return this.values.toArray(new String[this.values.size()]);
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSBlockScanner.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSBlockScanner.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSBlockScanner.java
new file mode 100644
index 0000000..0306827
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSBlockScanner.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+public class CSSBlockScanner extends RuleBasedScanner {
+
+ public CSSBlockScanner() {
+ List<IRule> rules = createRules();
+ setRules(rules.toArray(new IRule[rules.size()]));
+ }
+
+ protected List<IRule> createRules() {
+ List<IRule> rules = new ArrayList<IRule>();
+ rules.add(new CSSRule(
+ new Token(new TextAttribute(new Color(Display.getCurrent(),
+ IHTMLColorConstants.CSS_PROP))),
+ new Token(new TextAttribute(new Color(Display.getCurrent(),
+ IHTMLColorConstants.CSS_VALUE)))));
+ return rules;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSRule.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSRule.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSRule.java
new file mode 100644
index 0000000..f8c79cd
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/CSSRule.java
@@ -0,0 +1,110 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+public class CSSRule implements IPredicateRule {
+
+ private IToken propToken;
+ private IToken valueToken;
+
+ public CSSRule(final IToken propToken, final IToken valueToken) {
+ this.propToken = propToken;
+ this.valueToken = valueToken;
+ }
+
+ private boolean sequenceDetected(final ICharacterScanner scanner, final char[] sequence,
+ final boolean eofAllowed) {
+ for (int i = 1; i < sequence.length; i++) {
+ int c = scanner.read();
+ if (c == ICharacterScanner.EOF && eofAllowed) {
+ return true;
+ } else if (c != sequence[i]) {
+ // Non-matching character detected, rewind the scanner back to the start.
+ // Do not unread the first character.
+ scanner.unread();
+ for (int j = i - 1; j > 0; j--) {
+ scanner.unread();
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private IToken getToken(final ICharacterScanner scanner) {
+ int c;
+ char[][] delimiters = scanner.getLegalLineDelimiters();
+ while ((c = scanner.read()) != ICharacterScanner.EOF) {
+ if (c == ':') {
+ return propToken;
+ } else if (c == ';') {
+ return valueToken;
+ } else {
+ // Check for end of line since it can be used to terminate the pattern.
+ for (int i = 0; i < delimiters.length; i++) {
+ if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], true)) {
+ return null;
+ }
+ }
+ }
+ }
+ scanner.unread();
+ return null;
+ }
+
+ public IToken evaluate(final ICharacterScanner scanner, final boolean resume) {
+ return doEvaluate(scanner, resume);
+ }
+
+ private IToken doEvaluate(final ICharacterScanner scanner, final boolean resume) {
+ if (resume) {
+ IToken token = getToken(scanner);
+ if (token != null) {
+ return token;
+ }
+ } else {
+
+ int c = scanner.read();
+ if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
+ IToken token = getToken(scanner);
+ if (token != null) {
+ return token;
+ }
+ }
+ }
+
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+
+
+ public IToken getSuccessToken() {
+ return null;
+ }
+
+ public IToken evaluate(final ICharacterScanner scanner) {
+ return evaluate(scanner, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/DocTypeRule.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/DocTypeRule.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/DocTypeRule.java
new file mode 100644
index 0000000..0695a74
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/DocTypeRule.java
@@ -0,0 +1,65 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.MultiLineRule;
+
+public class DocTypeRule extends MultiLineRule {
+
+ public DocTypeRule(final IToken token) {
+ super("<!DOCTYPE", ">", token);
+ }
+
+ protected boolean endSequenceDetected(final ICharacterScanner scanner) {
+ int c;
+ boolean quoted = false;
+ char[][] delimiters = scanner.getLegalLineDelimiters();
+ boolean previousWasEscapeCharacter = false;
+ while ((c = scanner.read()) != ICharacterScanner.EOF) {
+ if (c == fEscapeCharacter) {
+ // Skip the escaped character.
+ scanner.read();
+ } else if (c == '[') {
+ quoted = true;
+ } else if (c == ']') {
+ quoted = false;
+ } else if (fEndSequence.length > 0 && c == fEndSequence[0]
+ && !quoted && sequenceDetected(scanner, fEndSequence, true)) {
+ return true;
+ } else if (fBreaksOnEOL) {
+ // Check for end of line since it can be used to terminate the pattern.
+ for (int i = 0; i < delimiters.length; i++) {
+ if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], true)) {
+ if (!fEscapeContinuesLine || !previousWasEscapeCharacter) {
+ return true;
+ }
+ }
+ }
+ }
+ previousWasEscapeCharacter = (c == fEscapeCharacter);
+ }
+ if (fBreaksOnEOF) {
+ return true;
+ }
+ scanner.unread();
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/6fee50d7/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/HTMLAutoEditStrategy.java
----------------------------------------------------------------------
diff --git a/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/HTMLAutoEditStrategy.java b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/HTMLAutoEditStrategy.java
new file mode 100644
index 0000000..3c7842b
--- /dev/null
+++ b/ide/eclipse/bundles/org.apache.syncope.ide.eclipse.plugin/src/main/java/org/apache/syncope/ide/eclipse/plugin/editors/htmlhelpers/HTMLAutoEditStrategy.java
@@ -0,0 +1,77 @@
+/*
+ * 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.ide.eclipse.plugin.editors.htmlhelpers;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+
+public class HTMLAutoEditStrategy extends DefaultIndentLineAutoEditStrategy {
+
+ private String charset = System.getProperty("file.encoding");
+ protected boolean enable;
+
+ public HTMLAutoEditStrategy() {
+ this.enable = true;
+ }
+
+ public void setEnabled(final boolean enable) {
+ this.enable = enable;
+ }
+
+ public void setFile(final IFile file) {
+ try {
+ this.charset = file.getCharset();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void customizeDocumentCommand(final IDocument d, final DocumentCommand c) {
+ if (enable) {
+ try {
+ if ("-".equals(c.text) && c.offset >= 3 && d.get(c.offset - 3, 3).equals("<!-")) {
+ c.text = "- -->";
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + 2;
+ c.doit = false;
+ return;
+ }
+ if ("[".equals(c.text) && c.offset >= 2 && d.get(c.offset - 2, 2).equals("<!")) {
+ c.text = "[CDATA[]]>";
+ c.shiftsCaret = false;
+ c.caretOffset = c.offset + 7;
+ c.doit = false;
+ return;
+ }
+ if ("l".equals(c.text) && c.offset >= 4 && d.get(c.offset - 4, 4).equals("<?xm")) {
+ c.text = "l version = \"1.0\" encoding = \"" + charset + "\"?>";
+ return;
+ }
+ } catch (final BadLocationException e) {
+ e.printStackTrace();
+ }
+ }
+ super.customizeDocumentCommand(d, c);
+ }
+
+}