<?xml version="1.0" encoding="UTF-8"?>
<!--

    openHAB, the open Home Automation Bus.
    Copyright (C) 2011, openHAB.org <admin@openhab.org>

    See the contributors.txt file in the distribution for a
    full listing of individual contributors.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses>.

    Additional permission under GNU GPL version 3 section 7

    If you modify this Program, or any covered work, by linking or
    combining it with Eclipse (or a modified version of that library),
    containing parts covered by the terms of the Eclipse Public License
    (EPL), the licensors of this Program grant you additional permission
    to convey the resulting work.

-->

<?eclipse version="3.0"?>

<plugin>

    <extension
            point="org.eclipse.ui.editors">
        <editor
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
            contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
            default="true"
            icon="icons/sitemap.png"
            extensions="sitemap"
            id="org.openhab.model.Sitemap"
            name="Sitemap Editor">
        </editor>
    </extension>
    <extension
        point="org.eclipse.ui.handlers">
        <handler
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
            commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
            <activeWhen>
                <reference
                    definitionId="org.openhab.model.Sitemap.Editor.opened">
                </reference>
            </activeWhen>
        </handler>
        <handler
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
            commandId="org.openhab.model.Sitemap.validate">
         <activeWhen>
            <reference
                    definitionId="org.openhab.model.Sitemap.Editor.opened">
            </reference>
         </activeWhen>
      </handler>
    </extension>
    <extension point="org.eclipse.core.expressions.definitions">
        <definition id="org.openhab.model.Sitemap.Editor.opened">
            <and>
                <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
                <with variable="activeEditor">
                    <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" 
                        value="org.openhab.model.Sitemap" 
                        forcePluginActivation="true"/>
                </with>        
            </and>
        </definition>
    </extension>
    <extension
            point="org.eclipse.ui.preferencePages">
        <page
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
            id="org.openhab.model.Sitemap"
            name="Sitemap">
            <keywordReference id="org.openhab.model.ui.keyword_Sitemap"/>
        </page>
        <page
            category="org.openhab.model.Sitemap"
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
            id="org.openhab.model.Sitemap.coloring"
            name="Syntax Coloring">
            <keywordReference id="org.openhab.model.ui.keyword_Sitemap"/>
        </page>
        <page
            category="org.openhab.model.Sitemap"
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
            id="org.openhab.model.Sitemap.templates"
            name="Templates">
            <keywordReference id="org.openhab.model.ui.keyword_Sitemap"/>
        </page>
    </extension>
    <extension
        point="org.eclipse.ui.keywords">
        <keyword
            id="org.openhab.model.ui.keyword_Sitemap"
            label="Sitemap"/>
    </extension>
    <extension
         point="org.eclipse.ui.commands">
      <command
            description="Trigger expensive validation"
            id="org.openhab.model.Sitemap.validate"
            name="Validate">
      </command>
    </extension>
    <extension point="org.eclipse.ui.menus">
        <menuContribution
            locationURI="popup:#TextEditorContext?after=group.edit">
             <command
                 commandId="org.openhab.model.Sitemap.validate"
                 style="push"
                 tooltip="Trigger expensive validation">
            <visibleWhen checkEnabled="false">
                <reference
                    definitionId="org.openhab.model.Sitemap.Editor.opened">
                </reference>
            </visibleWhen>
         </command>  
         </menuContribution>
    </extension>
    <extension point="org.eclipse.ui.menus">
		<menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
			<command commandId="org.eclipse.xtext.ui.editor.FindReferences">
				<visibleWhen checkEnabled="false">
                	<reference definitionId="org.openhab.model.Sitemap.Editor.opened">
                	</reference>
            	</visibleWhen>
			</command>
		</menuContribution>
	</extension>
<!--	<extension point="org.eclipse.ui.handlers">
	    <handler
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
            commandId="org.eclipse.xtext.ui.editor.FindReferences">
            <activeWhen>
                <reference
                    definitionId="org.openhab.model.Sitemap.Editor.opened">
                </reference>
            </activeWhen>
        </handler>
    </extension>   
-->
<!-- adding resource factories -->
<!--
	<extension
		point="org.eclipse.emf.ecore.extension_parser">
		<parser
			class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
			type="sitemap">
		</parser>
	</extension>
	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
        <resourceServiceProvider
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
            uriExtension="sitemap">
        </resourceServiceProvider>
    </extension>
-->



	<!-- Quick Outline -->
	<extension
		point="org.eclipse.ui.handlers">
		<handler 
			class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
			commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
			<activeWhen>
				<reference
					definitionId="org.openhab.model.Sitemap.Editor.opened">
				</reference>
			</activeWhen>
		</handler>
	</extension>
	<extension
		point="org.eclipse.ui.commands">
		<command
			description="Open the quick outline."
			id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
			name="Quick Outline">
		</command>
	</extension>
	<extension point="org.eclipse.ui.menus">
		<menuContribution
			locationURI="popup:#TextEditorContext?after=group.open">
			<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
				style="push"
				tooltip="Open Quick Outline">
				<visibleWhen checkEnabled="false">
					<reference definitionId="org.openhab.model.Sitemap.Editor.opened"/>
				</visibleWhen>
			</command>
		</menuContribution>
	</extension>
   <!-- quickfix marker resolution generator -->
   <extension
         point="org.eclipse.ui.ide.markerResolution">
      <markerResolutionGenerator
            class="org.openhab.model.ui.SitemapExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator">
      </markerResolutionGenerator>
   </extension>

</plugin>
