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

<plugin
  id="org.eclipse.ui.ide"
>

<extension
	point="org.eclipse.ui.commands">

	<!-- Define Collapse All as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.collapseAll"
		name="%commands.collapseAll.name"
		description="%commands.collapseAll.description"/>

	<!-- Define Link with Editor as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.linkWithEditor"
		name="%commands.linkWithEditor.name"
		description="%commands.linkWithEditor.description"/>

	<!-- 
		Go Into, Back, Forward, Up commands are already defined in the generic workbench.  
		e.g. org.eclipse.ui.navigate.goInto (see also ActionFactory.GO_INTO)
	    Should they be? 
	-->

	<!-- Define Open as a Navigator command.  Or would it be better to make it a 
	  generic IDE command (see JDT's Open command, bound to F3)? -->
	<command
		id="org.eclipse.ui.ide.navigator.open"
		name="%commands.open.name"
		description="%commands.open.description"/>

	<!-- Define Open in New Window as a generic IDE command, not tied to Navigator.
		See also ActionFactory.OPEN_NEW_WINDOW, which is similar, but does not act on the selection.
		(It's also missing its command id). -->
	<command
		id="org.eclipse.ui.ide.openInNewWindow"
		name="%commands.openInNewWindow.name"
		description="%commands.openInNewWindow.description"/>

	<!-- Define Select Working Set as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.selectWorkingSet"
		name="%commands.selectWorkingSet.name"
		description="%commands.selectWorkingSet.description"/>

	<!-- Define Deselect Working Set as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.deselectWorkingSet"
		name="%commands.deselectWorkingSet.name"
		description="%commands.deselectWorkingSet.description"/>

	<!-- Define Edit Working Set as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.editWorkingSet"
		name="%commands.editWorkingSet.name"
		description="%commands.editWorkingSet.description"/>

	<!-- Sort by Name and Sort by Type are Navigator-specific commands. 
	  Could these be combined into a single parameterized command?-->
	<command
		id="org.eclipse.ui.ide.navigator.sortByName"
		name="%commands.sortByName.name"
		description="%commands.sortByName.description"/>
	<command
		id="org.eclipse.ui.ide.navigator.sortByType"
		name="%commands.sortByType.name"
		description="%commands.sortByType.description"/>

	<!-- Define Filters as a generic IDE command, not tied to Navigator -->
	<command 
		id="org.eclipse.ui.ide.filters"
		name="%commands.filters.name"
		description="%commands.filters.description"/>

</extension>

<extension
	point="org.eclipse.ui.handlers">

	<!-- No enablement logic here, since these are assumed to all be running as code
	  when the Navigator is open -->

	<handlerGroup
		partId="org.eclipse.ui.views.ResourceNavigator">

		<handler
			commandId="org.eclipse.ui.edit.addBookmark"
			class="org.eclipse.ui.views.navigator.AddBookmarkHandler"/>

		<handler
			commandId="org.eclipse.ui.edit.addTask"
			class="org.eclipse.ui.views.navigator.AddTaskHandler"/>

		<handler
			commandId="org.eclipse.ui.file.properties"
			class="org.eclipse.ui.views.navigator.PropertiesHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.collapseAll"
			class="org.eclipse.ui.views.navigator.CollapseAllHandler"/>

		<handler
			commandId="org.eclipse.ui.navigate.goInto"
			class="org.eclipse.ui.views.navigator.GoIntoHandler"/>

		<handler
			commandId="org.eclipse.ui.navigate.back"
			class="org.eclipse.ui.views.navigator.BackHandler"/>

		<handler
			commandId="org.eclipse.ui.navigate.forward"
			class="org.eclipse.ui.views.navigator.ForwardHandler"/>

		<handler
			commandId="org.eclipse.ui.navigate.up"
			class="org.eclipse.ui.views.navigator.UpHandler"/>

		<handler
			commandId="org.eclipse.ui.navigate.goToResource"
			class="org.eclipse.ui.views.navigator.GoToResourceHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.navigator.open"
			class="org.eclipse.ui.views.navigator.OpenHandler"/>

		<!-- How to handle Open With submenu? -->

		<handler
			commandId="org.eclipse.ui.ide.openInNewWindow"
			class="org.eclipse.ui.views.navigator.OpenInNewWindowHandler"/>

		<handler
			commandId="org.eclipse.ui.edit.copy"
			class="org.eclipse.ui.views.navigator.CopyHandler"/>

		<handler
			commandId="org.eclipse.ui.edit.paste"
			class="org.eclipse.ui.views.navigator.PasteHandler"/>

		<!-- Note that the id for Move has "edit" in it, even though it's in the File menu. -->
		<handler
			commandId="org.eclipse.ui.edit.move"
			class="org.eclipse.ui.views.navigator.MoveHandler"/>

		<!-- Note that the id for Rename has "edit" in it, even though it's in the File menu. -->
		<handler
			commandId="org.eclipse.ui.edit.rename"
			class="org.eclipse.ui.views.navigator.RenameHandler"/>

		<handler
			commandId="org.eclipse.ui.edit.delete"
			class="org.eclipse.ui.views.navigator.DeleteHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.selectWorkingSet"
			class="org.eclipse.ui.views.navigator.SelectWorkingSetHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.deselectWorkingSet"
			class="org.eclipse.ui.views.navigator.DeselectWorkingSetHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.editWorkingSet"
			class="org.eclipse.ui.views.navigator.EditWorkingSetHandler"/>

		<!-- How to handle dynamic list of MRU working sets? -->

		<handler
			commandId="org.eclipse.ui.ide.navigator.sortByName"
			class="org.eclipse.ui.views.navigator.SortByNameHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.navigator.sortByType"
			class="org.eclipse.ui.views.navigator.SortByTypeHandler"/>

		<handler
			commandId="org.eclipse.ui.ide.navigator.Filters"
			class="org.eclipse.ui.views.navigator.FiltersHandler"/>

		<handler
			commandId="org.eclipse.ui.project.openProject"
			class="org.eclipse.ui.views.navigator.OpenProjectHandler"/>

		<handler
			commandId="org.eclipse.ui.project.closeProject"
			class="org.eclipse.ui.views.navigator.CloseProjectHandler"/>

		<handler
			commandId="org.eclipse.ui.file.refresh"
			class="org.eclipse.ui.views.navigator.RefreshHandler"/>

		<handler
			commandId="org.eclipse.ui.project.buildProject"
			class="org.eclipse.ui.views.navigator.BuildProjectHandler"/>

		<!-- Rebuild Project no longer used -->

	</handlerGroup>

</extension>

<extension
	point="org.eclipse.ui.menus">

	<!-- Define the context menu for the Navigator -->

	<!-- The repeated  elements. -->

	<group
		id="org.eclipse.ui.views.navigator.contextMenu">
		<location path="popup://org.eclipse.ui.views.navigator.ResourceNavigator"/>

		<!-- submenu: New -->
		<menu
			id="new"
			label="%ResourceNavigator.new"
			mnemonic="w">
		
			<!-- 
			  Is this correct for a dynamic group? 
			  No need to give it an id here, since it can't be added to from outside (though we might want 
			  to allow the same group to be placed in different locations, e.g. File > New).
			  Could break this up into static items for Project..., Other..., Example..., 
			  and a dynamic group for the current wizard shortcuts.
			  This would be more reusable for RCP apps, though it's the larger group you'd want to reuse in the IDE.  
			-->
			<group
				class="org.eclipse.ui.views.navigator.NewWizardGroup">
			</group>

		</menu>

		<!-- Goto items (no explicit group) -->

		<item
			commandId="org.eclipse.ui.navigate.goInto"
			mnemonic="I"
			hideWhenDisabled="true"/>

		<!-- Open items (no explicit group) -->

		<item
			commandId="org.eclipse.ui.ide.navigator.open"
			mnemonic="e"
			hideWhenDisabled="true"/>

		<!-- submenu: Open With -->
		<menu
			id="openWith"
			label="%ResourceNavigator.openWith"
			mnemonic="h">
			<location path="popup://org.eclipse.ui.views.navigator.ResourceNavigator"/>
			<!-- how to express dynamic visibility of the menu (and the following group)? -->
			
			<!-- is this correct for a dynamic group? -->
			<group
				class="org.eclipse.ui.views.navigator.OpenWithGroup"/>

		</menu>

		<item
			commandId="org.eclipse.ui.ide.openInNewWindow"
			mnemonic="N"
			hideWhenDisabled="true"/>
		
		<separator/>

		<!-- Clipboard / refactoring items (no explicit group) -->
		<!-- For UI stability, refactoring items are not hidden when disabled (different than current code for empty selection case). -->

		<item
			commandId="org.eclipse.ui.edit.copy"
			mnemonic="C"/>

		<item
			commandId="org.eclipse.ui.edit.paste"
			mnemonic="P"/>

		<item
			commandId="org.eclipse.ui.edit.delete"
			mnemonic="D"/>

		<item
			commandId="org.eclipse.ui.edit.move"
			mnemonic="v"/>

		<item
			commandId="org.eclipse.ui.edit.rename"
			mnemonic="m"/>

		<separator/>

		<!-- Import / export items (no explicit group).  Items always visible (since always applicable). -->
		
		<item
			commandId="org.eclipse.ui.file.import"
			mnemonic="m"/>

		<item
			commandId="org.eclipse.ui.file.export"
			mnemonic="o"/>

		<separator/>

		<!-- Workspace items (no explicit group).  Dynamic visibility of items. -->

		<item
			commandId="org.eclipse.ui.project.buildProject"
			mnemonic="B"
			hideWhenDisabled="true"/>

		<item
			commandId="org.eclipse.ui.file.refresh"
			mnemonic="f"
			hideWhenDisabled="true"/>

		<item
			commandId="org.eclipse.ui.project.openProject"
			mnemonic="e"
			hideWhenDisabled="true"/>

		<item
			commandId="org.eclipse.ui.project.closeProject"
			mnemonic="s"
			hideWhenDisabled="true"/>

		<!-- OK to define groups as separators like this (like you can now in code)?
		  Could probably simplify this to a single additions group, if we allow explicit positioning of items at the end of a group. -->
		<separator id="additions"/>
		<separator id="additions-end"/>
		<separator/>

		<item
			commandId="org.eclipse.ui.file.properties"
			mnemonic="r"
			hideWhenDisabled="true"/>

	</group>

</extension>

<extension
	point="org.eclipse.ui.menus">

	<!-- Define the view toolbar for the Navigator -->

	<!-- Is this the right way to express the location for the view toolbar? -->
	<group
		id="org.eclipse.ui.views.navigator.viewToolbar">
		<location path="viewToolbar://org.eclipse.ui.views.navigator.ResourceNavigator"/>

		<!-- How to handle dynamic tooltip for back, forward and up? -->

		<item commandId="org.eclipse.ui.navigate.back"/>

		<item commandId="org.eclipse.ui.navigate.forward"/>

		<item commandId="org.eclipse.ui.navigate.up"/>

		<separator/>

		<item commandId="org.eclipse.ui.ide.collapseAll"/>

		<item commandId="org.eclipse.ui.ide.linkWithEditor"/>

	</group>
</extension>

<extension
	point="org.eclipse.ui.menus">

	<!-- Define the view menu for the Navigator -->

	<!-- Is this the right way to express the location for the view menu? -->
	<group
		id="org.eclipse.ui.views.navigator.viewMenu">
		<location path="viewMenu://org.eclipse.ui.views.navigator.ResourceNavigator"/>

		<item 
			commandId="org.eclipse.ui.ide.selectWorkingSet"
			mnemonic="W"/>

		<item 
			commandId="org.eclipse.ui.ide.deselectWorkingSet"
			mnemonic="k"/>

		<item
			commandId="org.eclipse.ui.ide.editWorkingSet"
			mnemonic="E"/>

		<separator/>

		<!-- Is this correct for a dynamic group?  -->
		<group class="org.eclipse.ui.views.navigator.RecentWorkingSetsGroup"/>

		<separator/>

		<!-- Using shortcut syntax for mnemonic. -->
		<menu
			label="&Sort">

			<!-- How to do radio group? Where does the selection state come from (presumably the handler)? -->

			<group
				style="radio">

				<item
					commandId="org.eclipse.ui.ide.navigator.sortByName"
					mnemonic="N"
					style="radio"/>

				<item
					commandId="org.eclipse.ui.ide.navigator.sortByType"
					mnemonic="T"
					style="radio"/>
			</group>

		</menu>

		<item
			commandId="org.eclipse.ui.ide.filters"
			mnemonic="F"/>

		<!-- How to do a toggle item?  Where does the checked state come from (presumably the handler)? -->
		<item
			commandId="org.eclipse.ui.ide.linkWithEditor"
			mnemonic="F"
			style="toggle"/>
		
	</group>

</extension>


<!-- 

Issues:

- Verbosity: Mnemonics will need to be externalized.

- Not sure how best to map item visibility to command enablement.  For now I've added the "hideWhenDisabled" attribute.  This seems to work pretty well.

- What is the context passed to handlers?  E.g. Most actions take a Shell or the view in their constructor, and expect to be passed a selection (or be hooked up as a selection listener).  For now I'm assuming that the handler has no context, and needs to tunnel down: get the active window, page, part, and get its shell, selection, etc. 

- Handler classes (e.g. org.eclipse.ui.views.navigator.AddBookmarkHandler) could delegate to existing action classes (e.g. org.eclipse.ui.actions.AddBookmarkAction), but it would be better to rewrite them.  Should the implementations be API, as some actions are currently?  Or should these become default handlers?  For now, none are default handlers.

- How is F1 help going to be handled?  You can currently set a help context id on an action via WorkbenchHelp.setHelp(IAction, String).
The stub is also there for ICommand, but there's no help context id attribute defined for commands (or their handlers).
Help may also be location-specific

- Rename menus extension point to "commandBars", and allow a <commandBar> element to describe either a menubar or a toolbar?
(This is VS terminology, but it seems to make sense here too.)

- Using a <group> for radio groups combines structural (layout) grouping with logical (radio) grouping.  For example, this wouldn't allow intermingling of two radio groups (admittedly a farfetched case).  In XUL, they have a separate attribute for the radio group ("name") that an item belongs to.

-->

</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.