401 lines
19 KiB
Java
401 lines
19 KiB
Java
/*
|
|
* Copyright (c) 2003,2009 Declarative Engineering LLC.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the Declarative Engineering LLC
|
|
* verson 1 which accompanies this distribution, and is available at
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
|
*/
|
|
package com.foundation.view.swt.builder;
|
|
|
|
import com.common.util.*;
|
|
import com.foundation.view.JefImage;
|
|
import com.foundation.view.resource.ResourceReference;
|
|
import com.foundation.view.builder.*;
|
|
import com.foundation.view.definition.*;
|
|
|
|
public class MenuBuilder extends AbstractBuilder {
|
|
protected static final String STYLE_LEFT_TO_RIGHT = "left to right";
|
|
protected static final String STYLE_RIGHT_TO_LEFT = "right to left";
|
|
protected static final String STYLE_NO_RADIO_GROUP = "no radio group";
|
|
protected static final String STYLE_DOWN = "down";
|
|
protected static final String STYLE_UP = "up";
|
|
protected static final String STYLE_CHECK = "check";
|
|
//protected static final String STYLE_PUSH = "push";
|
|
protected static final String STYLE_RADIO = "radio";
|
|
//protected static final String STYLE_SEPARATOR = "separator";
|
|
|
|
protected static final String PROPERTY_NAME = "name";
|
|
protected static final String PROPERTY_TEXT = "text";
|
|
protected static final String PROPERTY_IMAGE = "image";
|
|
protected static final String PROPERTY_X = "x";
|
|
protected static final String PROPERTY_Y = "y";
|
|
protected static final String PROPERTY_DEFAULT_ITEM = "default-item";
|
|
protected static final String PROPERTY_ACCELERATOR = "accelerator";
|
|
protected static final String PROPERTY_IS_VISIBLE = "is-visible";
|
|
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
|
|
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
|
|
protected static final String ASSOCIATION_TEXT = "text";
|
|
protected static final String ASSOCIATION_IMAGE = "image";
|
|
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
|
|
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
|
|
protected static final String ASSOCIATION_SELECTION = "selection";
|
|
protected static final String LINK_SELECTION = "selection";
|
|
protected static final String METHOD_SELECTION = "selection";
|
|
protected static final String COMPONENT_MENU = "menu";
|
|
protected static final String COMPONENT_MENU_CASCADE = "menu-cascade";
|
|
|
|
private static final String LINK_TARGET_SELECTION = "selection";
|
|
private static final String LINK_TARGET_IS_VISIBLE = "is-visible";
|
|
private static final String LINK_TARGET_IS_ENABLED = "is-enabled";
|
|
|
|
private static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
|
|
private static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
|
|
private static final IHashMap acceleratorModifierMap = new LiteHashMap(10);
|
|
private static final IHashMap acceleratorKeyMap = new LiteHashMap(10);
|
|
|
|
public static final String SWT_ALT = "org.eclipse.swt.SWT.ALT";
|
|
public static final String SWT_SHIFT = "org.eclipse.swt.SWT.SHIFT";
|
|
public static final String SWT_CTRL = "org.eclipse.swt.SWT.CTRL";
|
|
public static final String SWT_CONTROL = "org.eclipse.swt.SWT.CONTROL";
|
|
public static final String SWT_COMMAND = "org.eclipse.swt.SWT.COMMAND";
|
|
public static final String SWT_MODIFIER_1 = "org.eclipse.swt.SWT.MOD1";
|
|
public static final String SWT_MODIFIER_2 = "org.eclipse.swt.SWT.MOD2";
|
|
public static final String SWT_MODIFIER_3 = "org.eclipse.swt.SWT.MOD3";
|
|
public static final String SWT_MODIFIER_4 = "org.eclipse.swt.SWT.MOD4";
|
|
|
|
public static final String SWT_BACK_SPACE = "org.eclipse.swt.SWT.BS";
|
|
public static final String SWT_CARRIAGE_RETURN = "org.eclipse.swt.SWT.CR";
|
|
public static final String SWT_DELETE = "org.eclipse.swt.SWT.DEL";
|
|
public static final String SWT_ESCAPE = "org.eclipse.swt.SWT.ESC";
|
|
public static final String SWT_LINE_FEED = "org.eclipse.swt.SWT.LF";
|
|
public static final String SWT_TAB = "org.eclipse.swt.SWT.TAB";
|
|
public static final String SWT_ARROW_UP = "org.eclipse.swt.SWT.ARROW_UP";
|
|
public static final String SWT_ARROW_DOWN = "org.eclipse.swt.SWT.ARROW_DOWN";
|
|
public static final String SWT_ARROW_LEFT = "org.eclipse.swt.SWT.ARROW_LEFT";
|
|
public static final String SWT_ARROW_RIGHT = "org.eclipse.swt.SWT.ARROW_RIGHT";
|
|
public static final String SWT_PAGE_UP = "org.eclipse.swt.SWT.PAGE_UP";
|
|
public static final String SWT_PAGE_DOWN = "org.eclipse.swt.SWT.PAGE_DOWN";
|
|
public static final String SWT_HOME = "org.eclipse.swt.SWT.HOME";
|
|
public static final String SWT_END = "org.eclipse.swt.SWT.END";
|
|
public static final String SWT_INSERT = "org.eclipse.swt.SWT.INSERT";
|
|
public static final String SWT_F1 = "org.eclipse.swt.SWT.F1";
|
|
public static final String SWT_F2 = "org.eclipse.swt.SWT.F2";
|
|
public static final String SWT_F3 = "org.eclipse.swt.SWT.F3";
|
|
public static final String SWT_F4 = "org.eclipse.swt.SWT.F4";
|
|
public static final String SWT_F5 = "org.eclipse.swt.SWT.F5";
|
|
public static final String SWT_F6 = "org.eclipse.swt.SWT.F6";
|
|
public static final String SWT_F7 = "org.eclipse.swt.SWT.F7";
|
|
public static final String SWT_F8 = "org.eclipse.swt.SWT.F8";
|
|
public static final String SWT_F9 = "org.eclipse.swt.SWT.F9";
|
|
public static final String SWT_F10 = "org.eclipse.swt.SWT.F10";
|
|
public static final String SWT_F11 = "org.eclipse.swt.SWT.F11";
|
|
public static final String SWT_F12 = "org.eclipse.swt.SWT.F12";
|
|
|
|
static {
|
|
styleMap.put(STYLE_LEFT_TO_RIGHT, "STYLE_LEFT_TO_RIGHT");
|
|
styleMap.put(STYLE_RIGHT_TO_LEFT, "STYLE_RIGHT_TO_LEFT");
|
|
//styleMap.put(STYLE_PUSH, "STYLE_PUSH");
|
|
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
|
|
styleMap.put(STYLE_RADIO, "STYLE_RADIO");
|
|
//styleMap.put(STYLE_SEPARATOR, "STYLE_SEPARATOR");
|
|
styleMap.put(STYLE_NO_RADIO_GROUP, "NO_RADIO_GROUP");
|
|
styleMap.put(STYLE_DOWN, "STYLE_DOWN");
|
|
styleMap.put(STYLE_UP, "STYLE_UP");
|
|
|
|
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
|
|
linkMap.put(LINK_TARGET_IS_VISIBLE, "LINK_TARGET_IS_VISIBLE");
|
|
linkMap.put(LINK_TARGET_IS_ENABLED, "LINK_TARGET_IS_ENABLED");
|
|
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_ALT, SWT_ALT);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_COMMAND, SWT_COMMAND);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_CONTROL, SWT_CONTROL);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_CTRL, SWT_CTRL);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_1, SWT_MODIFIER_1);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_2, SWT_MODIFIER_2);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_3, SWT_MODIFIER_3);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_4, SWT_MODIFIER_4);
|
|
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_SHIFT, SWT_SHIFT);
|
|
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_BACK_SPACE, SWT_BACK_SPACE);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_CARRIAGE_RETURN, SWT_CARRIAGE_RETURN);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_DELETE, SWT_DELETE);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ESCAPE, SWT_ESCAPE);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_LINE_FEED, SWT_LINE_FEED);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_TAB, SWT_TAB);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_UP, SWT_ARROW_UP);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_DOWN, SWT_ARROW_DOWN);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_LEFT, SWT_ARROW_LEFT);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_RIGHT, SWT_ARROW_RIGHT);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_PAGE_UP, SWT_PAGE_UP);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_PAGE_DOWN, SWT_PAGE_DOWN);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_HOME, SWT_HOME);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_END, SWT_END);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_INSERT, SWT_INSERT);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F1, SWT_F1);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F2, SWT_F2);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F3, SWT_F3);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F4, SWT_F4);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F5, SWT_F5);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F6, SWT_F6);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F7, SWT_F7);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F8, SWT_F8);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F9, SWT_F9);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F10, SWT_F10);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F11, SWT_F11);
|
|
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F12, SWT_F12);
|
|
}//static//
|
|
/**
|
|
* MenuBuilder constructor.
|
|
*/
|
|
public MenuBuilder() {
|
|
}//MenuBuilder()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
|
|
*/
|
|
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
|
|
String variableName = viewBuilder.getComponentAttributeName(data);
|
|
String parentVariableName = viewBuilder.getComponentAttributeName(data.getParent());
|
|
|
|
viewBuilder.addComponentAttribute(data, this);
|
|
buffer.append("\t");
|
|
buffer.append(variableName);
|
|
buffer.append(" = new ");
|
|
buffer.append(getComponentClassName());
|
|
buffer.append("(");
|
|
appendComponentConstructorParameters(viewBuilder, buffer, data, parentVariableName);
|
|
buffer.append(");\r\n");
|
|
buffer.append("\t\r\n");
|
|
|
|
appendInitializationBody(viewBuilder, buffer, data, variableName);
|
|
}//appendInitializationCode()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.swt.builder2.ComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition2.ComponentData, java.lang.String)
|
|
*/
|
|
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
|
|
String typeName = data.getComponentType().getName();
|
|
boolean isBar = typeName.equals("menu-bar");
|
|
boolean isFloating = typeName.equals("menu-floating");
|
|
//boolean isSeparator = typeName.equals("menu-separator");
|
|
boolean isToggle = typeName.equals("menu-toggle");
|
|
boolean isPush = typeName.equals("menu");
|
|
boolean isCascade = typeName.equals("menu-cascade");
|
|
Object text = (Object) data.getPropertyValue(PROPERTY_TEXT);
|
|
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
|
|
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
|
|
String accelerator = null;
|
|
String defaultItem = null;
|
|
Integer x = null;
|
|
Integer y = null;
|
|
Object isVisible = (Object) data.getPropertyValue(PROPERTY_IS_VISIBLE);
|
|
Object isEnabled = (Object) data.getPropertyValue(PROPERTY_IS_ENABLED);
|
|
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
|
|
|
|
if(isBar || isFloating) {
|
|
defaultItem = (String) data.getPropertyValue(PROPERTY_DEFAULT_ITEM);
|
|
x = (Integer) data.getPropertyValue(PROPERTY_X);
|
|
y = (Integer) data.getPropertyValue(PROPERTY_Y);
|
|
}//if//
|
|
else {
|
|
accelerator = (String) data.getPropertyValue(PROPERTY_ACCELERATOR);
|
|
}//else//
|
|
|
|
if(text != null) {
|
|
if(text instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) text).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setText(\"" + text + "\");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(image != null) {
|
|
if(image instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) image).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setImage(new " + JefImage.class.getName() + "(\"" + image + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if((x != null) && (y != null)) {
|
|
buffer.append("\t" + variableName + ".setLocation(" + x + ", " + y + ");\r\n");
|
|
}//if//
|
|
|
|
if((isToggle) && (autoSynchronizeSelection != null)) {
|
|
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(\"" + autoSynchronizeSelection + "\");\r\n");
|
|
}//if//
|
|
|
|
if(defaultItem != null) {
|
|
IComponentData defaultItemComponent = data.searchForComponent(defaultItem, null, IComponentData.SEARCH_FLAG_UP);
|
|
|
|
buffer.append('\t');
|
|
buffer.append(variableName);
|
|
buffer.append(".setDefaultItem(");
|
|
buffer.append(viewBuilder.getComponentAttributeName(defaultItemComponent));
|
|
buffer.append(");\r\n");
|
|
}//if//
|
|
|
|
if(isVisible != null) {
|
|
if(isVisible instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setIsVisible(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isVisible).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setIsVisible(" + ((Boolean) isVisible).booleanValue() + ");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(isEnabled != null) {
|
|
if(isEnabled instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setIsEnabled(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isEnabled).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setIsEnabled(" + ((Boolean) isEnabled).booleanValue() + ");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(accelerator != null) {
|
|
IList options = parseAccelerator(accelerator.trim());
|
|
IIterator iterator = options.iterator();
|
|
|
|
if(options.getSize() > 0) {
|
|
boolean isFirst = true;
|
|
|
|
buffer.append("\t" + variableName + ".setAccelerator(");
|
|
|
|
while(iterator.hasNext()) {
|
|
String next = (String) iterator.next();
|
|
String command = (String) acceleratorModifierMap.get(next);
|
|
|
|
if(isFirst) {
|
|
isFirst = false;
|
|
}//if//
|
|
else {
|
|
buffer.append(" | ");
|
|
}//else//
|
|
|
|
if(command != null) {
|
|
buffer.append(command);
|
|
}//if//
|
|
else if((command = (String) acceleratorKeyMap.get(next)) != null) {
|
|
buffer.append(command);
|
|
|
|
if(iterator.hasNext()) {
|
|
throw new ViewBuilderException("Error: Expected '" + next + "' ended the accelerator sequence: " + accelerator, -1, -1, -1);
|
|
}//if//
|
|
}//else if//
|
|
else {
|
|
if(next.length() > 1) {
|
|
throw new ViewBuilderException("Error: Expecting only one character, not several: " + next, -1, -1, -1);
|
|
}//if//
|
|
|
|
buffer.append('\'');
|
|
buffer.append(next.charAt(0));
|
|
buffer.append('\'');
|
|
|
|
if(iterator.hasNext()) {
|
|
throw new ViewBuilderException("Error: Expected '" + next + "' ended the accelerator sequence: " + accelerator, -1, -1, -1);
|
|
}//if//
|
|
}//else//
|
|
}//while//
|
|
|
|
buffer.append(");\r\n");
|
|
}//if//
|
|
}//if//
|
|
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TEXT, variableName, "setTextAssociation", "ASSOCIATION_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IMAGE, variableName, "setImageAssociation", "ASSOCIATION_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
|
|
if(isPush) {
|
|
if(selectionMethod != null) {
|
|
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_SELECTION);
|
|
|
|
viewBuilder.addDirectMethodHandler(data, associationIdentifier, selectionMethod);
|
|
buffer.append("\t");
|
|
buffer.append(variableName);
|
|
buffer.append(".setSelectionMethod(");
|
|
viewBuilder.appendMethodAssociation(buffer, variableName, selectionMethod, associationIdentifier);
|
|
buffer.append(");\r\n");
|
|
}//if//
|
|
}//if//
|
|
|
|
//Append the child menus.//
|
|
if(isBar || isFloating || isCascade) {
|
|
IIterator iterator = data.getComponents().iterator();
|
|
|
|
while(iterator.hasNext()) {
|
|
IComponentData next = (IComponentData) iterator.next();
|
|
|
|
viewBuilder.getBuilder(next).appendInitializationHead(viewBuilder, buffer, next);
|
|
}//while//
|
|
}//if//
|
|
}//appendInitializationBody()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
|
|
*/
|
|
public void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
|
|
IList selectionLinks = data.getLinks(LINK_SELECTION);
|
|
|
|
if(selectionLinks != null) {
|
|
for(int index = 0; index < selectionLinks.getSize(); index++) {
|
|
ILinkPart part = (ILinkPart) selectionLinks.get(index);
|
|
|
|
buffer.append("\t");
|
|
buffer.append(variableName);
|
|
buffer.append(".addSelectionLink(");
|
|
viewBuilder.appendLink(data, buffer, part);
|
|
buffer.append(");\r\n");
|
|
}//for//
|
|
}//if//
|
|
}//appendLinks()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.swt.builder.AbstractBuilder#getAdditionalStyleSource()
|
|
*/
|
|
protected String getAdditionalStyleSource(IComponentData data) {
|
|
String typeName = data.getComponentType().getName();
|
|
boolean isBar = typeName.equals("menu-bar");
|
|
boolean isFloating = typeName.equals("menu-floating");
|
|
boolean isCascade = typeName.equals("menu-cascade");
|
|
boolean isPush = typeName.equals("menu");
|
|
boolean isSeparator = typeName.equals("menu-separator");
|
|
|
|
return isPush ? getComponentClassName() + '.' + "STYLE_PUSH" : isSeparator ? getComponentClassName() + '.' + "STYLE_SEPARATOR" : isBar ? getComponentClassName() + '.' + "STYLE_BAR" : isFloating ? getComponentClassName() + '.' + "STYLE_POPUP" : isCascade ? getComponentClassName() + '.' + "STYLE_CASCADE" : null;
|
|
}//getAdditionalStyleSource()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
|
|
*/
|
|
public IHashMap getStyleMap() {
|
|
return styleMap;
|
|
}//getStyleMap()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
|
|
*/
|
|
public IHashMap getLinkMap() {
|
|
return linkMap;
|
|
}//getLinkMap()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
|
|
*/
|
|
public String getComponentClassName() {
|
|
return "com.foundation.view.swt.Menu";
|
|
}//getComponentClassName()//
|
|
/**
|
|
* Parses the accelerator options which are space delimited.
|
|
* @param accelerator The string containing space delimited options. Space, control, shift, and the F-keys are all represented by words which will be picked out.
|
|
* @return The set of accelerator options such as 'space', 'control', 'F2', or 's'.
|
|
*/
|
|
private IList parseAccelerator(String accelerator) {
|
|
IList result = new LiteList(5, 10);
|
|
AdvancedTextParser parser = new AdvancedTextParser(accelerator);
|
|
|
|
parser.setDelimiterSet(AdvancedTextParser.addDelimiter(null, " ", false, false, null));
|
|
|
|
while(parser.hasNext()) {
|
|
result.add(parser.next());
|
|
}//while//
|
|
|
|
return result;
|
|
}//parseAccelerator()//
|
|
}//MenuModel// |