alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>

   <!-- A command with a default handler, effectively global but it can -->
   <!-- be overriden by part contributions -->
   <extension
         point="org.eclipse.ui.commands">
      <category
            name="%contributions.commands.category.name"
            description="%contributions.commands.category.desc"
            id="org.eclipse.ui.examples.contributions.commands.category">
      </category>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            defaultHandler="org.eclipse.ui.examples.contributions.handlers.GlobalMenuHandler"
            id="org.eclipse.ui.examples.contributions.commands.globalCommand"
            name="%contributions.commands.globalCommand.name">
      </command>
   </extension>
   
   <!-- Binding CTRL+6 to the global command -->
   <extension
         point="org.eclipse.ui.bindings">
      <scheme
            id="org.eclipse.ui.examples.contributions.scheme"
            name="%scheme.info.name">
      </scheme>
      <key
            commandId="org.eclipse.ui.examples.contributions.commands.globalCommand"
            contextId="org.eclipse.ui.contexts.window"
            sequence="M1+6"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
      </key>
      <key
            commandId="org.eclipse.ui.file.exit"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+Q">
      </key>
      <key
            commandId="org.eclipse.ui.window.newWindow"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+N">
      </key>
      <key
            commandId="org.eclipse.ui.file.save"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+S">
      </key>
      <key
            commandId="org.eclipse.ui.file.saveAll"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+SHIFT+S">
      </key>
      <key
            commandId="org.eclipse.ui.file.close"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+W">
      </key>
      <key
            commandId="org.eclipse.ui.file.closeAll"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+SHIFT+W">
      </key>
      <key
            commandId="org.eclipse.ui.window.showViewMenu"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+F10">
      </key>
      <key
            commandId="org.eclipse.ui.file.refresh"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="F5">
      </key>
   </extension>
   
   <!-- placing the global command in the main menu and main toolbar with a -->
   <!-- condition.  You can do it without a condition but that's extremely  -->
   <!-- uncommon. You can treat an actionSet like a context within the --> 
   <!-- condition. -->
   <extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            id="org.eclipse.ui.examples.contributions.globalActionSet"
            label="%contributions.globalActionSet.label"
            visible="false">
      </actionSet>
   </extension>
   
   <!-- You can reuse expressions for conditions by defining them once -->
   <extension
         point="org.eclipse.core.expressions.definitions">
      <definition
            id="org.eclipse.ui.examples.contributions.inGlobalActionSet">
         <with
               variable="activeContexts">
            <iterate
                  operator="or">
               <equals
                     value="org.eclipse.ui.examples.contributions.globalActionSet">
               </equals>
            </iterate>
         </with>
      </definition>
      <definition
            id="org.eclipse.ui.examples.contributions.view.inView">
         <with
               variable="activePartId">
            <equals
                  value="org.eclipse.ui.examples.contributions.view">
            </equals>
         </with>
      </definition>
      <definition
            id="org.eclipse.ui.examples.contributions.view.activeEditor">
         <with
               variable="activeEditorId">
            <equals
                  value="org.eclipse.ui.examples.contributions.editor">
            </equals>
         </with>
      </definition>
   </extension>
   
   <!-- menus are defined hierarchically from a root, and separate from -->
   <!-- toolbars. -->
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu?after=additions">
         <menu
               label="%contributions.menus.globalMenu.label"
               mnemonic="%contributions.menus.globalMenu.label"
               id="org.eclipse.ui.examples.contributions.menus.globalMenu">
            <command
                  commandId="org.eclipse.ui.examples.contributions.commands.globalCommand"
                  mnemonic="%contributions.menus.globalCommand.mnemonic"
                  id="org.eclipse.ui.examples.contributions.menus.globalCommand">
               <visibleWhen>
                  <reference
                        definitionId="org.eclipse.ui.examples.contributions.inGlobalActionSet">
                  </reference>
               </visibleWhen>
            </command>
            <separator
                  name="additions"
                  visible="false">
            </separator>
         </menu>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="org.eclipse.ui.examples.contributions.toolbars.sampleToolbar">
            <command
                  commandId="org.eclipse.ui.examples.contributions.commands.globalCommand"
                  icon="icons/sample.gif"
                  tooltip="%contributions.toolbars.globalCommand.tooltip"
                  id="org.eclipse.ui.examples.contributions.toolbars.globalCommand">
               <visibleWhen>
                  <reference
                        definitionId="org.eclipse.ui.examples.contributions.inGlobalActionSet">
                  </reference>
               </visibleWhen>
            </command>
            <separator
                  name="additions"
                  visible="false">
            </separator>
         </toolbar>
      </menuContribution>
   </extension>
   
   <!-- Create a view and some view commands -->
   <extension
         point="org.eclipse.ui.views">
      <category
            id="org.eclipse.ui.examples.contributions.viewCategory"
            name="%contributions.viewCategory.name">
      </category>
      <view
            category="org.eclipse.ui.examples.contributions.viewCategory"
            class="org.eclipse.ui.examples.contributions.view.InfoView"
            id="org.eclipse.ui.examples.contributions.view"
            name="%contributions.view.name">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.view.count"
            description="%contributions.view.count.desc"
            name="%contributions.view.count.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.view.swap"
            name="%contributions.view.swap.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.view.edit"
            name="%contributions.view.edit.name">
      </command>
      <command
            id="org.eclipse.ui.examples.contributions.editor.infoAbout"
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            name="%contributions.editor.about.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.view.adminRights"
            name="%command.adminRights.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            defaultHandler="org.eclipse.ui.examples.contributions.view.LoginHandler"
            id="org.eclipse.ui.examples.contributions.view.login"
            name="%command.login.name">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.examples.contributions.view?after=additions">
         <command
               commandId="org.eclipse.ui.examples.contributions.view.count"
               mnemonic="%contributions.view.count.mnemonic">
         </command>
         <command
               commandId="org.eclipse.ui.examples.contributions.view.edit"
               mnemonic="%contributions.view.edit.mnemonic">
         </command>
         <command
               commandId="org.eclipse.ui.file.refresh"
               mnemonic="%contributions.view.refresh.mnemonic">
         </command>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.examples.contributions.view?after=additions">
         <command
               commandId="org.eclipse.ui.newWizard"
               icon="icons/new_wiz.gif"
               style="push"
               tooltip="%command.new.tooltip">
            <parameter
                  name="newWizardId"
                  value="org.eclipse.ui.examples.contributions.wizard.newPerson">
            </parameter>
         </command>
         <command
               commandId="org.eclipse.ui.examples.contributions.view.swap"
               label="%contributions.view.swap.name"
               tooltip="%contributions.view.swap.tooltip">
         </command>
      </menuContribution>
      <menuContribution
            locationURI="popup:org.eclipse.ui.examples.contributions.view?after=additions">
         <command
               commandId="org.eclipse.ui.file.refresh"
               mnemonic="%contributions.view.refresh.mnemonic">
         </command>
         <command
               commandId="org.eclipse.ui.examples.contributions.view.login"
               mnemonic="%command.login.mnemonic"
               style="push">
         </command>
         <command
               commandId="org.eclipse.ui.examples.contributions.view.adminRights"
               mnemonic="%command.adminRights.mnemonic"
               style="toggle">
            <visibleWhen
                  checkEnabled="true">
            </visibleWhen>
         </command>
      </menuContribution>
      <menuContribution
            locationURI="popup:org.eclipse.ui.popup.any?after=additions">
         <command
               commandId="org.eclipse.ui.examples.contributions.view.edit"
               mnemonic="%contributions.view.edit.mnemonic">
            <visibleWhen>
               <with
                     variable="activeMenuSelection">
                  <iterate>
                     <adapt
                           type="org.eclipse.ui.examples.contributions.model.Person">
                     </adapt>
                  </iterate>
               </with>
            </visibleWhen>
         </command>
      </menuContribution>
      <menuContribution
            locationURI="menu:help?after=additions">
         <command
               commandId="org.eclipse.ui.examples.contributions.editor.infoAbout"
               style="push">
            <visibleWhen
                  checkEnabled="true">
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="org.eclipse.ui.examples.contributions.view.RefreshInfoHandler"
            commandId="org.eclipse.ui.file.refresh">
         <activeWhen>
            <reference
                  definitionId="org.eclipse.ui.examples.contributions.view.inView">
            </reference>
         </activeWhen>
      </handler>
      <handler
            class="org.eclipse.ui.examples.contributions.view.SwapInfoHandler"
            commandId="org.eclipse.ui.examples.contributions.view.swap">
         <activeWhen>
            <reference
                  definitionId="org.eclipse.ui.examples.contributions.view.inView">
            </reference>
         </activeWhen>
         <enabledWhen>
            <with
                  variable="selection">
               <count
                     value="2">
               </count>
            </with>
         </enabledWhen>
      </handler>
      <handler
            class="org.eclipse.ui.examples.contributions.view.EditInfoHandler"
            commandId="org.eclipse.ui.examples.contributions.view.edit">
         <activeWhen>
            <reference
                  definitionId="org.eclipse.ui.examples.contributions.view.inView">
            </reference>
         </activeWhen>
         <enabledWhen>
            <with
                  variable="selection">
               <count
                     value="1">
               </count>
            </with>
         </enabledWhen>
      </handler>
      <handler
            class="org.eclipse.ui.examples.contributions.handlers.InfoAboutHandler"
            commandId="org.eclipse.ui.examples.contributions.editor.infoAbout">
         <enabledWhen>
            <with
                  variable="activePart">
               <instanceof
                     value="org.eclipse.ui.examples.contributions.view.InfoView">
               </instanceof>
            </with>
         </enabledWhen>
      </handler>
      <handler
            class="org.eclipse.ui.examples.contributions.view.AdminHandler"
            commandId="org.eclipse.ui.examples.contributions.view.adminRights">
         <enabledWhen>
            <and>
               <count
                     value="1">
               </count>
               <iterate>
                  <instanceof
                        value="org.eclipse.ui.examples.contributions.model.Person">
                  </instanceof>
               </iterate>
               <with
                     variable="org.eclipse.ui.examples.contributions.user">
                  <test
                        property="org.eclipse.ui.examples.contributions.user.isAdmin"
                        value="true">
                  </test>
               </with>
            </and>
         </enabledWhen>
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.contexts">
      <context
            id="org.eclipse.ui.examples.contributions.view.context"
            name="%contributions.view.context.name"
            parentId="org.eclipse.ui.contexts.window">
      </context>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="org.eclipse.ui.examples.contributions.view.edit"
            contextId="org.eclipse.ui.examples.contributions.view.context"
            sequence="M1+O"
            schemeId="org.eclipse.ui.examples.contributions.scheme">
      </key>
      <key
            commandId="org.eclipse.ui.newWizard"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.examples.contributions.scheme"
            sequence="CTRL+SHIFT+P">
            <parameter
                  id="newWizardId"
                  value="org.eclipse.ui.examples.contributions.wizard.newPerson">
            </parameter>
      </key>
   </extension>
   
   <!-- Add an editor for the Person model and some commands -->
   <extension
         point="org.eclipse.ui.editors">
      <editor
            class="org.eclipse.ui.examples.contributions.editor.InfoEditor"
            icon="icons/editor.gif"
            id="org.eclipse.ui.examples.contributions.editor"
            name="%contributions.editor.name">
      </editor>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.editor.reset"
            name="%contributions.editor.reset.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.editor.delta"
            name="%contributions.editor.delta.name">
      </command>
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            defaultHandler="org.eclipse.ui.examples.contributions.editor.ActivateEditorHandler"
            id="org.eclipse.ui.examples.contributions.editor.activate"
            name="%command.activate.name">
         <commandParameter
               id="org.eclipse.ui.examples.contributions.editor.activate.index"
               name="%commandParameter.activate.index.name"
               optional="false"
               typeId="org.eclipse.ui.examples.contributions.IntegerType">
         </commandParameter>
      </command>
      <commandParameterType
            converter="org.eclipse.ui.examples.contributions.editor.IntegerTypeConverter"
            id="org.eclipse.ui.examples.contributions.IntegerType"
            type="java.lang.Integer">
      </commandParameterType>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu?after=additions">
         <menu
               id="org.eclipse.ui.examples.contributions.editor.menu"
               label="%contributions.editor.menu.label"
               mnemonic="%contributions.editor.menu.mnemonic">
            <command
                  commandId="org.eclipse.ui.examples.contributions.editor.reset"
                  mnemonic="%contributions.editor.reset.mnemonic">
               <visibleWhen>
                  <reference
                        definitionId="org.eclipse.ui.examples.contributions.view.activeEditor">
                  </reference>
               </visibleWhen>
            </command>
         </menu>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="org.eclipse.ui.examples.contributions.editor.toolbar">
            <command
                  commandId="org.eclipse.ui.examples.contributions.editor.delta"
                  icon="icons/change_obj.gif"
                  tooltip="%contributions.editor.delta.tooltip">
               <visibleWhen>
                  <reference
                        definitionId="org.eclipse.ui.examples.contributions.view.activeEditor">
                  </reference>
               </visibleWhen>
            </command>
         </toolbar>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="org.eclipse.ui.examples.contributions.editor.DeltaInfoHandler"
            commandId="org.eclipse.ui.examples.contributions.editor.delta">
         <activeWhen>
            <reference
                  definitionId="org.eclipse.ui.examples.contributions.view.activeEditor">
            </reference>
         </activeWhen>
      </handler>
   </extension>
   
   <!-- adding a control and commands to the trim -->
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.trim.status">
         <toolbar
               id="org.eclipse.ui.examples.contributions.verticalTrim">
            <command
                  commandId="org.eclipse.ui.examples.contributions.item2"
                  icon="icons/editor.gif"
                  id="contributions.trimItem"
                  label="%Trim.item"
                  tooltip="%TrimItem.toolTip">
            </command>
            <control
                  class="org.eclipse.ui.examples.contributions.ExampleControlContribution"
                  id="contributions.controlContrib1">
            </control>
            <command
                  commandId="org.eclipse.ui.examples.contributions.item2"
                  icon="icons/editor.gif"
                  id="contributions.trimItem2"
                  label="%Trim2.item"
                  tooltip="%TrimItem2.toolTip">
            </command>
         </toolbar>
      </menuContribution>
      <!-- this is an example of an object contribution -->
      <menuContribution
            locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
         <command
               commandId="org.eclipse.ui.help.aboutAction"
               label="%command.aboutXml.label"
               style="push">
            <visibleWhen
                  checkEnabled="false">
               <with
                     variable="activeMenuSelection">
                  <count
                        value="1">
                  </count>
                  <iterate>
                     <!-- I know it can't find this, just ignore it -->
                     <adapt
                           type="org.eclipse.core.resources.IFile">
                        <test
                              property="org.eclipse.core.resources.name"
                              value="*.xml">
                        </test>
                        <test
                              property="org.eclipse.core.resources.contentTypeId"
                              value="org.eclipse.ant.core.antBuildFile">
                        </test>
                     </adapt>
                  </iterate>
               </with>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            id="org.eclipse.ui.examples.contributions.item2"
            name="%CmdLabel">
      </command>
   </extension>
   <extension
         id="application"
         name="%application.name"
         point="org.eclipse.core.runtime.applications">
      <application
            cardinality="singleton-global"
            thread="main"
            visible="true">
         <run
               class="org.eclipse.ui.examples.contributions.rcp.ContributionApplication">
         </run>
      </application>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="org.eclipse.ui.examples.contributions.rcp.Perspective"
            fixed="true"
            icon="icons/perspective.gif"
            id="org.eclipse.ui.examples.contributions.perspective"
            name="%info.perspective.name">
      </perspective>
   </extension>
   <extension
         id="product"
         point="org.eclipse.core.runtime.products">
      <product
            application="org.eclipse.ui.examples.contributions.application"
            name="%info.product.name">
         <property
               name="windowImages"
               value="icons/sample2.gif">
         </property>
         <property
               name="aboutText"
               value="RCP Info product modified from the RCP Mail template">
         </property>
         <property
               name="aboutImage"
               value="product_lg.gif">
         </property>
         <property
               name="appName"
               value="%info.product.name">
         </property>
      </product>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="file"
               label="%menu.file.label"
               mnemonic="%menu.file.mnemonic">
            <command
                  commandId="org.eclipse.ui.file.refresh"
                  mnemonic="%command.refresh.mnemonic"
                  style="push">
            </command>
            <separator
                  name="sep1"
                  visible="true">
            </separator>
            <command
                  commandId="org.eclipse.ui.file.exit"
                  mnemonic="%command.exit.mnemonic"
                  style="push">
            </command>
         </menu>
         <separator
               name="additions"
               visible="false">
         </separator>
         <menu
               id="window"
               label="%menu.window.label"
               mnemonic="%menu.window.mnemonic">
            <command
                  commandId="org.eclipse.ui.window.newWindow"
                  mnemonic="%command.newWindow.mnemonic"
                  style="push">
            </command>
            <separator
                  name="sep1"
                  visible="true">
            </separator>
            <dynamic
                  class="org.eclipse.ui.examples.contributions.editor.DynamicEditorList"
                  id="org.eclipse.ui.tutorials.commands.dynamicEditorList">
            </dynamic>
         </menu>
         <menu
               id="help"
               label="%menu.help.label"
               mnemonic="%menu.help.mnemonic">
            <command
                  commandId="org.eclipse.ui.help.aboutAction"
                  mnemonic="%command.aboutAction.mnemonic"
                  style="push">
            </command>
         </menu>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar
               id="org.eclipse.ui.examples.contributions.group.file">
            <command
                  commandId="org.eclipse.ui.file.save"
                  style="push">
            </command>
            <command
                  commandId="org.eclipse.ui.file.saveAll"
                  style="push">
            </command>
         </toolbar>
         <separator
               name="additions"
               visible="false">
         </separator>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.services">
      <serviceFactory
            factoryClass="org.eclipse.ui.examples.contributions.model.PersonServiceFactory">
         <service
               serviceClass="org.eclipse.ui.examples.contributions.model.IPersonService"></service>
      </serviceFactory>
      <sourceProvider
            provider="org.eclipse.ui.examples.contributions.model.UserSourceProvider">
         <variable
               name="org.eclipse.ui.examples.contributions.user"
               priorityLevel="activeSite">
         </variable>
      </sourceProvider>
   </extension>
   <extension
         point="org.eclipse.ui.newWizards">
      <category
            id="org.eclipse.ui.examples.contributions.wizardCategory"
            name="%person.category.name">
      </category>
      <wizard
            category="org.eclipse.ui.examples.contributions.wizardCategory"
            class="org.eclipse.ui.examples.contributions.model.PersonWizard"
            id="org.eclipse.ui.examples.contributions.wizard.newPerson"
            name="%person.wizard.name">
      </wizard>
   </extension>
   <extension
         point="org.eclipse.core.expressions.propertyTesters">
      <propertyTester
            class="org.eclipse.ui.examples.contributions.model.UserPropertyTester"
            id="org.eclipse.ui.examples.contributions.user.propertyTester"
            namespace="org.eclipse.ui.examples.contributions.user"
            properties="isAdmin,id"
            type="org.eclipse.ui.examples.contributions.model.Person">
      </propertyTester>
   </extension>
</plugin>
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.