Commits

Sebastian Sdorra committed bf2264c

added code snippet 002 - repository tab

Comments (0)

Files changed (3)

002-repository-tab/pom.xml

+<?xml version="1.0"?>
+<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>
+    <artifactId>scm-plugins</artifactId>
+    <groupId>sonia.scm.plugins</groupId>
+    <version>1.8</version>
+  </parent>
+
+  <groupId>sonia.scm.snippets</groupId>
+  <artifactId>002-repository-tab</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>002-repository-tab</name>
+  <url>https://bitbucket.org/sdorra/scm-code-snippets</url>
+  <description>Add tab to repository configuration</description>
+  
+  <scm>
+    <connection>scm:hg:https://bitbucket.org/sdorra/scm-code-snippets</connection>
+    <developerConnection>scm:hg:https://bitbucket.org/sdorra/scm-code-snippets</developerConnection>
+    <url>https://bitbucket.org/sdorra/scm-code-snippets</url>
+  </scm>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>${servlet.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+  </dependencies>
+  
+  <repositories>
+    
+    <repository>
+      <id>maven.scm-manager.org</id>
+      <name>scm-manager release repository</name>
+      <url>http://maven.scm-manager.org/nexus/content/groups/public</url>
+    </repository>
+  
+  </repositories>
+
+</project>

002-repository-tab/src/main/resources/META-INF/scm/plugin.xml

+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    Copyright (c) 2010, Sebastian Sdorra
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright notice,
+       this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright notice,
+       this list of conditions and the following disclaimer in the documentation
+       and/or other materials provided with the distribution.
+    3. Neither the name of SCM-Manager; nor the names of its
+       contributors may be used to endorse or promote products derived from this
+       software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    http://bitbucket.org/sdorra/scm-manager
+
+
+-->
+
+<plugin>
+
+  <information>
+    <author>Sebastian Sdorra</author>
+    <category>Code-Snippet</category>
+  </information>
+
+  <conditions>
+    <min-version>${project.parent.version}</min-version>
+  </conditions>
+
+  <resources>
+    <script>/sonia/scm/snippets/002-repository-tab.js</script>
+  </resources>
+
+</plugin>

002-repository-tab/src/main/resources/sonia/scm/snippets/002-repository-tab.js

+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * http://bitbucket.org/sdorra/scm-manager
+ * 
+ */
+
+
+/** 
+ * Register extjs namespace for the plugin.
+ * http://docs.sencha.com/ext-js/3-4/#!/api/Ext-method-ns
+ */
+Ext.ns('Sonia.snippets');
+
+Sonia.snippets.MyPanel = Ext.extend(Ext.Panel, {
+
+  initComponent: function(){
+    var config = {
+      // Title of the panel
+      title: 'My Panel'
+    }
+
+    /**
+     * The apply method merges the initialConfig object with the config object.
+     * The initialConfig object is the config object from the parent panel 
+     * (in this case Ext.Panel).
+     * http://docs.sencha.com/ext-js/3-4/#!/api/Ext-method-apply
+     */
+    Ext.apply(this, Ext.apply(this.initialConfig, config));
+    Sonia.snippets.MyPanel.superclass.initComponent.apply(this, arguments);
+  }
+
+});
+
+/**
+ * Register xtype of the panel for later use and lazy initialization.
+ * http://docs.sencha.com/ext-js/3-4/#!/api/Ext-method-reg
+ */
+Ext.reg("myPanel", Sonia.snippets.MyPanel);
+
+/**
+ * Register a listener which is called, after repository is selected in the 
+ * web interface. The listener passes the selected repository and an array
+ * of panels as argument.
+ */ 
+Sonia.repository.openListeners.push(function(repository, panels){
+  
+  /**
+   * Append the new panel to the panels array
+   */
+  panels.push({
+    // registerd xtype for the panel
+    xtype: 'myPanel'
+  });
+});