litesoft
@ 948
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / HelpWidget.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
package com.temp.client.foundation.widget; import com.google.gwt.dom.client.*; import com.google.gwt.event.dom.client.*; import com.google.gwt.user.client.ui.*; import com.temp.client.foundation.util.*; import com.temp.shared.utils.*; /** * HelpWidget supports opening a new Browser Page for a specific section w/ an * optional context. * <p/> * It uses a an Image, as opposed to an Anchor, so that NO browser will be * tempted to make it a Tab Stop. * * @author georgs (updated from Anchor to Clickable Image) */ public class HelpWidget extends Composite implements IsWidget, HasName { private Image helpImage = new Image( "images/inPageQuestion.png" ); private String section = ""; private String context = ""; private String name = null; public HelpWidget() { initWidget( helpImage ); helpImage.setStyleName( "help-question-mark" ); helpImage.getElement().getStyle().setVisibility( Style.Visibility.HIDDEN ); } public HelpWidget( String section, String context ) { this(); setSection( section ); setContext( context ); } public HelpWidget( String section, String context, String name ) { this( section, context ); setName( name ); } @Override public String getName() { return name; } @Override public void setName( String name ) { this.name = name; } /** * Set both the Section and the Context with a '#' as a separator. * <p/> * If no '#' found, then the context is empty * * @param sectionAndContext section[#context] */ public void setSectionContext( String sectionAndContext ) { sectionAndContext = StringUtils.deNull( sectionAndContext ).trim(); int sepAt = sectionAndContext.indexOf( '#' ); if ( sepAt == -1 ) { setSectionContext( sectionAndContext, null ); } else { setSectionContext( sectionAndContext.substring( 0, sepAt ), sectionAndContext.substring( sepAt + 1 ) ); } } public void setSectionContext( String section, String context ) { setSection( section ); setContext( context ); } public HelpWidget link( String sectionAndContext ) { setSectionContext( sectionAndContext ); return this; } public String getSection() { return section; } public String getContext() { return context; } public void setSection( String section ) { this.section = StringUtils.deNull( section ).trim(); } public void setContext( String context ) { this.context = StringUtils.deNull( context ).trim(); } // <g:Anchor tabIndex='-1' ui:field = 'helpurl' href='' text="?" // target='simple EDI - help'/> @Override protected void onAttach() { super.onAttach(); if ( section.length() != 0 ) { helpImage.setTitle( "Click for Help" ); helpImage.addClickHandler( new ClickHandler() { @Override public void onClick( ClickEvent event ) { UtilsGwt.openWithFocus( "/help/" + section + ".jsp#" + context, "SEDIhelp", "directories=0,location=0,menubar=0,status=1,toolbar=0,resizable=1" ); } } ); helpImage.getElement().getStyle().setVisibility( Style.Visibility.VISIBLE ); } } } |