001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.project.ui.internal.tool.display;
018:
019: import java.util.List;
020:
021: import net.refractions.udig.project.ui.tool.IToolManager;
022:
023: import org.eclipse.core.commands.IHandler;
024: import org.eclipse.core.runtime.IConfigurationElement;
025: import org.eclipse.jface.action.IToolBarManager;
026: import org.eclipse.swt.SWT;
027: import org.eclipse.swt.widgets.ToolBar;
028: import org.eclipse.swt.widgets.ToolItem;
029:
030: /**
031: * All Fire and forget actions are in this category.
032: *
033: * @author jeichar
034: * @since 0.9.0
035: */
036: public class ActionToolCategory extends ToolCategory {
037:
038: /**
039: * Construct <code>ActionCategory</code>.
040: *
041: * @param element
042: * @param manager
043: */
044: public ActionToolCategory(IConfigurationElement element,
045: IToolManager manager) {
046: super (element, manager);
047: }
048:
049: /**
050: * Construct <code>ActionToolCategory2</code>.
051: *
052: * @param manager
053: */
054: public ActionToolCategory(IToolManager manager) {
055: super (manager);
056: }
057:
058: public void contribute(IToolBarManager manager) {
059: for (ModalItem item : items) {
060: ToolProxy toolProxy = ((ToolProxy) item);
061: if (toolProxy.isOnToolbar())
062: manager.add(toolProxy.getAction());
063: }
064: }
065:
066: /**
067: * Contribution class for action tools on the toolbar.
068: *
069: * @author jeichar
070: * @author Vitalus
071: *
072: */
073: protected class ActionToolContribution extends
074: AbstractToolbarContributionItem {
075:
076: /**
077: * @see net.refractions.udig.project.ui.internal.tool.display.CurrentContributionItem#setSelection(boolean)
078: */
079: public void setSelection(boolean checked, ModalItem proxy) {
080: // do nothing.
081: }
082:
083: /**
084: * @see net.refractions.udig.project.ui.internal.tool.display.CurrentContributionItem#isChecked()
085: */
086: protected boolean isChecked() {
087: return false;
088: }
089:
090: /**
091: * @see net.refractions.udig.project.ui.internal.tool.display.AbstractToolbarContributionItem#isDefaultItem()
092: */
093: protected boolean isDefaultItem() {
094: return false;
095: }
096:
097: /**
098: * @see net.refractions.udig.project.ui.internal.tool.display.AbstractToolbarContributionItem#createToolItem(org.eclipse.swt.widgets.ToolBar,
099: * int)
100: */
101: protected ToolItem createToolItem(ToolBar parent, int index) {
102: return toolItem = new ToolItem(parent, SWT.PUSH, index);
103: }
104:
105: /**
106: * @see net.refractions.udig.project.ui.internal.tool.display.AbstractToolbarContributionItem#getTools()
107: */
108: protected List<ModalItem> getTools() {
109: return items;
110: }
111:
112: @Override
113: protected boolean isActiveItem() {
114: return false;
115: }
116:
117: }
118:
119: /**
120: * @see net.refractions.udig.project.ui.internal.tool.display.ToolCategory#getHandlerSubmission(java.lang.String)
121: */
122: protected IHandler getHandler() {
123: return null;
124: }
125:
126: }
|