Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/HelpWidget.java

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