Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 302274
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/resources/ResourceManagerImpl.java (-1 lines)
Lines 295-301 Link Here
295
    ParamCheck.notNull( name, "name" );
295
    ParamCheck.notNull( name, "name" );
296
    String key = createKey( name );
296
    String key = createKey( name );
297
    String fileName = ( String )repository.get( key );
297
    String fileName = ( String )repository.get( key );
298
    Assert.isNotNull( fileName, "No resource registered for key " + name );
299
    return createRequestURL( fileName, findVersion( name ) );
298
    return createRequestURL( fileName, findVersion( name ) );
300
  }
299
  }
301
300
(-)src/org/eclipse/rwt/internal/engine/RWTServletContextListener.java (-1 / +1 lines)
Lines 79-85 Link Here
79
    registerResources( evt.getServletContext() );
79
    registerResources( evt.getServletContext() );
80
    registerUICallBackServiceHandler();
80
    registerUICallBackServiceHandler();
81
    registerJSLibraryServiceHandler();
81
    registerJSLibraryServiceHandler();
82
    BrowserSurvey.configurer = new RWTStartupPageConfigurer();
82
    StartupPage.configurer = new RWTStartupPageConfigurer();
83
    ResourceUtil.startJsConcatenation();
83
    ResourceUtil.startJsConcatenation();
84
  }
84
  }
85
85
(-)src/org/eclipse/rwt/internal/browser/Ie5_5up.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>the implementation for Microsoft Internet Explorer 5.5 and higher.</p>
16
 */
17
public class Ie5_5up extends Ie5up {
18
  
19
  public Ie5_5up( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie5_5up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie5_5up( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/DetectorSafari.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
/**
14
 * <p>The Safari Browser Detection Class</p>
15
 */
16
// TODO [rh] distinguish Safari versions: 
17
//      return class Safari for version < 2 and class Safari2 for V2.0 and later  
18
public class DetectorSafari extends DetectorBase {
19
20
  private final static String idString = "safari";
21
22
  public DetectorSafari() {
23
    super();
24
  }
25
26
  public boolean knowsBrowserString( final String userAgent ) {
27
    return contains( userAgent, idString );
28
  }
29
30
  public String getBrowserClassName( final String userAgent ) {
31
    return BROWSER_PACKAGE + "Safari2";
32
  }
33
}
(-)src/org/eclipse/rwt/internal/browser/Default.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** <p>A default implementation for the org.eclipse.rap.Browser class. Subclasses of 
15
  * Browser represent vendor-specific and version-specific
16
  * information about the web browser that is used on the client side to 
17
  * display the pages from the current session.</p>
18
  */
19
public class Default extends Browser {
20
  
21
  public Default( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
  
25
  public Default( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
  
29
  public Default( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/DetectorMozilla.java (-44 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
/**
14
 * <p>The Mozilla Browser Detection Class</p>
15
 */
16
public class DetectorMozilla extends DetectorBase {
17
18
  public boolean knowsBrowserString( final String userAgent ) {
19
    // tricky: all browser contain mozilla string, so
20
    // we have to make sure it is no other browser
21
    return     contains( userAgent, "mozilla/5.0" )
22
           &&  contains( userAgent, "gecko" )
23
           && !contains( userAgent, "mozilla/4" )
24
           && !contains( userAgent, "konqueror" )
25
           && !contains( userAgent, "msie" )
26
           && !contains( userAgent, "safari" );
27
  }
28
29
  public String getBrowserClassName( final String userAgent ) {
30
    return BROWSER_PACKAGE + "Mozilla" + getBrowserVersion( userAgent );
31
  }
32
33
  public String getBrowserVersion( final String userAgent ) {
34
    String result = "1_6";
35
    if( contains( userAgent, "rv:1.7" ) ) {
36
      result = "1_7";
37
    } else if( contains( userAgent, "rv:1.8" ) ) {
38
      result = "1_7";
39
    } else if( contains( userAgent, "rv:1.9" ) ) {
40
      result = "1_7";
41
    }
42
    return result;
43
  }
44
}
(-)src/org/eclipse/rwt/internal/browser/BrowserDetector.java (-180 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
import java.io.IOException;
14
import java.io.InputStream;
15
import java.net.URL;
16
import java.net.URLConnection;
17
import java.util.*;
18
19
import javax.xml.parsers.*;
20
21
import org.eclipse.rwt.internal.resources.ResourceManagerImpl;
22
import org.eclipse.rwt.resources.IResourceManager;
23
import org.w3c.dom.*;
24
import org.xml.sax.SAXException;
25
26
27
/**
28
 * <p>The singleton class that parses browser vendor, version info and 
29
 * and os info of a given userAgent http header string. 
30
 * </p>
31
 * <p>This class is not inteded to be used by clients.</p>
32
 */
33
public class BrowserDetector {
34
  
35
  private static final String BROWSERDETECTION_XML = "browserdetection.xml";
36
  private static final String CLASSNAME_ELEMENT = "classname";
37
  private static final String BROWSER_ELEMENT = "browser";
38
  
39
  private static BrowserDetector _instance;
40
41
  private final List browserDetectors;
42
43
  private BrowserDetector() {
44
    browserDetectors = new ArrayList();
45
    loadBrowserDetectors();
46
  }
47
  
48
  /**
49
   * <p>Returns the singleton instance of the <code>BrowserDetector</code>.</p>
50
   */
51
  public static synchronized BrowserDetector getInstance() {
52
    if( _instance == null ) {
53
      _instance = new BrowserDetector();
54
    }
55
    return _instance;
56
  }
57
  
58
  /**
59
   * <p>Detects browser by parsing the userAgent string and returns the 
60
   * class name of the matching <code>Browser</code> class.</p>
61
   */
62
  public String getBrowserClassName( final String userAgent ) {
63
    return detectBrowser( userAgent );
64
  }
65
66
  public String getBrowserOSName( final String userAgent ) {
67
    return DetectorBase.getBrowserOS( userAgent );
68
  }
69
  
70
  private String detectBrowser( final String theUserAgent ) {
71
    String result = Default.class.getName();
72
    if( theUserAgent != null ) {    
73
      // all comparison is done in lower case
74
      String userAgent = theUserAgent.toLowerCase();
75
      // set default in case no browser is found
76
      Object[] detectors = browserDetectors.toArray();
77
      boolean detected = false;
78
      for( int i = 0; !detected && i < detectors.length; i++ ) {
79
        DetectorBase browserDetector = ( DetectorBase )detectors[ i ];
80
        if( browserDetector.knowsBrowserString( userAgent ) ) {
81
          result = browserDetector.getBrowserClassName( userAgent );
82
          detected = true;
83
        }
84
      }
85
    }
86
    return result;
87
  } 
88
  
89
  private void loadBrowserDetectors() {
90
    try {
91
      // create a special URLLoader to avoid problems with other classloaders
92
      // that do not support getResources.
93
      IResourceManager manager = ResourceManagerImpl.getInstance();
94
      Enumeration browserDetectionFiles;
95
      if( manager == null ) {
96
        ClassLoader loader = getClass().getClassLoader();
97
        browserDetectionFiles = loader.getResources( BROWSERDETECTION_XML );
98
      } else {
99
        browserDetectionFiles = manager.getResources( BROWSERDETECTION_XML );
100
      }
101
      
102
      while( browserDetectionFiles.hasMoreElements() ) {
103
        int nextItem = 0;
104
        URL browserFile = ( URL )browserDetectionFiles.nextElement();
105
        
106
        Document document = parseDocument( browserFile );
107
        
108
        // extract list of browser definition (from current file) 
109
        NodeList nodeList = document.getElementsByTagName( BROWSER_ELEMENT );
110
        Node item = nodeList.item( nextItem );
111
        
112
        // iterate over all browser definitions (in current file)
113
        while( item != null ) {
114
          // extract classname from current browser definition
115
          String detectorClassName = findElementValue( item, CLASSNAME_ELEMENT );
116
          // create instance of the detector and store it in 
117
          // list of browser detectors.
118
          Object detectorInstance 
119
            = Class.forName( detectorClassName ).newInstance();
120
          DetectorBase browserDetector = ( DetectorBase )detectorInstance;
121
          browserDetectors.add( browserDetector );
122
          nextItem++;
123
          item = nodeList.item( nextItem );
124
        } // while (item != null )
125
      } // while (browserDetectionFiles.hasMoreElements() )
126
    } catch( final Throwable thr ) {
127
      // too many different exceptions may occur to handle each, 
128
      // so if something goes wrong just throw an illegal state exception
129
      StringBuffer msg = new StringBuffer();
130
      msg.append( new Date() );
131
      msg.append( " BROWSERDETECTOR error: " );
132
      msg.append( "Unable to load browserdetection classes (caused by " );
133
      msg.append( thr.getClass().getName() );
134
      msg.append( " with message: " );
135
      msg.append( thr.getMessage() );
136
      msg.append( ")." );
137
      System.out.println( msg );
138
      thr.printStackTrace();
139
      // TODO [rh] An exception thrown from here never gets through (I think
140
      // due to the fact that it is called during class initialization)
141
      //      REWORK THIS!
142
    }
143
  }
144
  
145
  /////////////////////////////////
146
  // Helper methods for xml parsing 
147
  
148
  private static String findElementValue( final Node rootNode, 
149
                                          final String elementName ) 
150
  {
151
    String result = null;
152
    if( rootNode instanceof Element ) {
153
      Element rootElement = ( Element )rootNode;
154
      NodeList foundElements = rootElement.getElementsByTagName( elementName );
155
      Node firstNode = foundElements.item( 0 );
156
      if( firstNode != null && firstNode instanceof Element ) {
157
        Element foundElement = ( Element )firstNode;
158
        result = foundElement.getFirstChild().getNodeValue().trim();
159
      }
160
    }
161
    return result;
162
  }
163
  
164
  private static Document parseDocument( final URL browserFile ) 
165
    throws IOException, ParserConfigurationException, SAXException
166
  {
167
    URLConnection con = browserFile.openConnection();
168
    con.setUseCaches( false );
169
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
170
    DocumentBuilder builder = factory.newDocumentBuilder();
171
    Document result;
172
    InputStream is = con.getInputStream();
173
    try {
174
      result = builder.parse( is );
175
    } finally {
176
      is.close();
177
    }
178
    return result;
179
  }
180
}
(-)src/org/eclipse/rwt/internal/browser/Mozilla1_7up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Mozilla 1.7 and higher.
17
 * </p>
18
 */
19
public class Mozilla1_7up extends Mozilla1_6up {
20
21
  public Mozilla1_7up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Mozilla1_7up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Mozilla1_7up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Opera.java (-29 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** <p>the basic implementation for Opera browsers.</p>
15
  */
16
public class Opera extends Default {
17
  
18
  public Opera( final boolean scriptEnabled ) {
19
    super( scriptEnabled );
20
  }
21
  
22
  public Opera( final boolean scriptEnabled, final boolean ajaxEnabled ) {
23
    super( scriptEnabled, ajaxEnabled );
24
  }
25
26
  public Opera( final Browser browser ) {
27
    super( browser );
28
  }
29
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_2.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2.
17
 * </p>
18
 */
19
public class Konqueror3_2 extends Konqueror3_1up {
20
21
  public Konqueror3_2( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_2( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_2( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Opera8.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>The implementation for Opera 8 and higher. No AJaX suppport.</p>
16
 */
17
public class Opera8 extends Opera {
18
  
19
  public Opera8( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Opera8( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, true );
25
  }
26
  
27
  public Opera8( final Browser browser ) {
28
    super( browser );
29
  }
30
  
31
  public boolean isXHTMLCapable() {
32
    return true;
33
  }
34
}
(-)src/org/eclipse/rwt/internal/browser/Mozilla1_6up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Mozilla 1.6 and higher.
17
 * </p>
18
 */
19
public class Mozilla1_6up extends Mozilla {
20
21
  public Mozilla1_6up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Mozilla1_6up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Mozilla1_6up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_4.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2.
17
 * </p>
18
 */
19
public class Konqueror3_4 extends Konqueror3_3up {
20
21
  public Konqueror3_4( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_4( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_4( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/DetectorBase.java (-69 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
/**
14
 * <p>DetectorBase defines the base methods needed for browser detection</p> 
15
 */
16
public abstract class DetectorBase {
17
18
  public static final String OS_LINUX = "linux";
19
  public static final String OS_WINDOWS = "win";
20
  public static final String OS_MAC = "mac";
21
  public static final String OS_UNIX = "unix";
22
  public static final String OS_NONE = "none";
23
  public static final String OS_X11 = "x11";
24
  
25
  protected static final String BROWSER_PACKAGE 
26
    = "org.eclipse.rwt.internal.browser.";
27
28
  /**
29
   * <p>Must return whether the given <code>userAgent</code> known by this
30
   * <code>DetectorBase</code> instance.</p>
31
   * @param userAgent - the user agent string in <strong>lowercase</strong>
32
   */
33
  public abstract boolean knowsBrowserString( final String userAgent );
34
35
  /**
36
   * <p>This method is only called when a former call to 
37
   * <code>knowsBrowserString</code> returned <code>true</code>. 
38
   * This method must then return the fully qualified class name of the 
39
   * <code>Browser</code> class taht represents the given
40
   * <code>userAgent</code>.
41
   * @param userAgent - the user agent string in <strong>lowercase</strong>
42
   */
43
  // TODO [rh] Is there any reason why class name is returned as string?
44
  public abstract String getBrowserClassName( final String userAgent );
45
46
  public static String getBrowserOS( final String userAgent ) {
47
    String result;
48
    if( contains( userAgent, OS_LINUX ) ) {
49
      result = OS_LINUX;
50
    } else if( contains( userAgent, OS_X11 ) ) {
51
      result = OS_UNIX;
52
    } else if( contains( userAgent, OS_MAC ) ) {
53
      result = OS_MAC;
54
    } else if( contains( userAgent, OS_WINDOWS ) ) {
55
      result = OS_WINDOWS;
56
    } else {
57
      result = OS_NONE;
58
    }
59
    return result;
60
  }
61
62
  // helper method for string detection
63
  protected static boolean contains( final String fullString,
64
                                     final String searchString )
65
  {
66
    return fullString.indexOf( searchString ) != -1;
67
  }
68
69
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_4up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2.
17
 * </p>
18
 */
19
public class Konqueror3_4up extends Konqueror3_3up {
20
21
  public Konqueror3_4up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_4up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_4up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Opera9up.java (-29 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** <p>the implementation for Opera 7 and higher.</p>
15
  */
16
public class Opera9up extends Opera8up {
17
  
18
  public Opera9up( final boolean scriptEnabled ) {
19
    super( scriptEnabled );
20
  }
21
  
22
  public Opera9up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
23
    super( scriptEnabled, ajaxEnabled );
24
  }
25
  
26
  public Opera9up( final Browser browser ) {
27
    super( browser );
28
  }
29
}
(-)src/org/eclipse/rwt/internal/browser/Safari2.java (-31 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
15
/**
16
 * <p>The browser class for Safari 2 browsers.</p>
17
 */
18
public class Safari2 extends Safari {
19
20
  public Safari2( final boolean scriptEnabled ) {
21
    super( scriptEnabled );
22
  }
23
24
  public Safari2( final boolean scriptEnabled, final boolean ajaxEnabled ) {
25
    super( scriptEnabled, ajaxEnabled );
26
  }
27
28
  public Safari2( final Browser browser ) {
29
    super( browser );
30
  }
31
}
(-)src/org/eclipse/rwt/internal/browser/Ie5up.java (-35 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** <p>the implementation for Microsoft Internet Explorer 5 and higher.</p>
15
  */
16
public class Ie5up extends Ie {
17
  
18
  public Ie5up( final boolean scriptEnabled ) {
19
    super( scriptEnabled );
20
    this.ajaxCapable = true;
21
  }
22
  
23
  public Ie5up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
    this.ajaxCapable = true;
26
  }
27
28
  public Ie5up( final Browser browser ) {
29
    super( browser );
30
  }
31
  
32
  public boolean isXHTMLCapable() {
33
    return true;
34
  }
35
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_1up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.1 and higher.
17
 * </p>
18
 */
19
public class Konqueror3_1up extends Konqueror {
20
21
  public Konqueror3_1up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_1up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_1up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Mozilla.java (-38 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the basic implementation for Mozilla browsers.
17
 * </p>
18
 */
19
public class Mozilla extends Default {
20
21
  public Mozilla( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
    this.ajaxCapable = true;
24
  }
25
26
  public Mozilla( final boolean scriptEnabled, final boolean ajaxEnabled ) {
27
    super( scriptEnabled, ajaxEnabled );
28
    this.ajaxCapable = true;
29
  }
30
31
  public Mozilla( final Browser browser ) {
32
    super( browser );
33
  }
34
  
35
  public boolean isXHTMLCapable() {
36
    return true;
37
  }
38
}
(-)src/org/eclipse/rwt/internal/browser/Ie6up.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>the implementation for Microsoft Internet Explorer 6 and higher.</p>
16
 */
17
public class Ie6up extends Ie5_5up {
18
  
19
  public Ie6up( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie6up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie6up( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the basic implementation for Konqueror browsers.
17
 * </p>
18
 */
19
public class Konqueror extends Default {
20
21
  public Konqueror( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Mozilla1_6.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Mozilla 1.6.
17
 * </p>
18
 */
19
public class Mozilla1_6 extends Mozilla {
20
21
  public Mozilla1_6( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Mozilla1_6( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Mozilla1_6( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Ie6.java (-31 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>The implementation for Microsoft Internet Explorer 6.</p>
16
 */
17
public class Ie6 extends Ie5_5up {
18
  
19
  public Ie6( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie6( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie6( final Browser browser ) {
28
    super( browser );
29
  }
30
  
31
}
(-)src/org/eclipse/rwt/internal/browser/DetectorKonqueror.java (-82 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
/**
14
 * The Konqueror Browser Detection Class
15
 */
16
public class DetectorKonqueror extends DetectorBase {
17
18
  private static final String VERSION_PREFIX = "konqueror/";
19
  private final static String ID_KONQUEROR = "konqueror";
20
  
21
22
  public DetectorKonqueror() {
23
    super();
24
  }
25
26
  public boolean knowsBrowserString( final String userAgent ) {
27
    return contains( userAgent, ID_KONQUEROR );
28
  }
29
30
  public String getBrowserName( final String userAgent ) {
31
    return "Konqueror";
32
  }
33
34
  public String getBrowserClassName( final String userAgent ) {
35
    String result 
36
      = BROWSER_PACKAGE 
37
      + getBrowserName( userAgent ) 
38
      + getBrowserVersion( userAgent );
39
    return result;
40
  }
41
42
  public String getBrowserVersion( final String userAgent ) {
43
    String result = "";
44
    int[] versions = getVersions( userAgent );
45
    if( versions[ 0 ] == 3 ) {
46
      if( versions[ 1 ] == 1 ) {
47
        result = "3_1";
48
      } else if( versions[ 1 ] == 2 ) {
49
        result = "3_2";
50
      } else if( versions[ 1 ] == 3 ) {
51
        result = "3_3";
52
      } else if( versions[ 1 ] >= 4 ) {
53
        result = "3_4";
54
      }
55
    }
56
    return result;
57
  }
58
59
  private int[] getVersions( final String userAgent ) {
60
    int result[] = new int[]{ -1, -1 };
61
    int startIndex = userAgent.indexOf( VERSION_PREFIX );
62
    if( startIndex != -1 ) {
63
      int endIndex = userAgent.substring( startIndex ).indexOf( ";" );
64
      if( endIndex != -1 ) {
65
        int absoluteStart = startIndex + VERSION_PREFIX.length();
66
        int absoluteEnd = startIndex + endIndex;
67
        String version = userAgent.substring( absoluteStart, absoluteEnd );
68
        String[] parts = version.split( "\\.", 2 );
69
        if( parts.length == 2 ) {
70
          try {
71
            result[ 0 ] = Integer.parseInt( parts[ 0 ] );
72
            result[ 1 ] = Integer.parseInt( parts[ 1 ] );
73
          } catch( NumberFormatException e) {
74
            // ignore
75
          }
76
        }
77
      }
78
    }
79
    return result;
80
  }
81
82
}
(-)src/org/eclipse/rwt/internal/browser/Mozilla1_7.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Mozilla 1.7.
17
 * </p>
18
 */
19
public class Mozilla1_7 extends Mozilla1_6up {
20
21
  public Mozilla1_7( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Mozilla1_7( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Mozilla1_7( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/DetectorIE.java (-83 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
import java.text.NumberFormat;
14
15
/**
16
 * <p>The Internet Explorer Browser Detection Class</p>
17
 */
18
public class DetectorIE extends DetectorBase {
19
20
  private final static String ID_OPERA = "opera";
21
  private final static String ID_MSIE = "msie";
22
  private final static String ID_MSIE5 = "msie 5";
23
  private final static String ID_MSIE5_5 = "msie 5.5";
24
  private final static String ID_MSIE6 = "msie 6";
25
  private final static String ID_MSIE7 = "msie 7";
26
27
  public boolean knowsBrowserString( final String userAgent ) {
28
    return !"".equals( getBrowserVersion( userAgent ) );
29
  }
30
31
  public String getBrowserClassName( final String userAgent ) {
32
    return BROWSER_PACKAGE + "Ie" + getBrowserVersion( userAgent );
33
  }
34
35
  public String getBrowserVersion( final String userAgent ) {
36
    String result = "";
37
    if( contains( userAgent, ID_MSIE ) && !contains( userAgent, ID_OPERA ) ) {
38
      if( contains( userAgent, ID_MSIE5_5 ) ) {
39
        result = "5_5";
40
      } else if( contains( userAgent, ID_MSIE5 ) ) {
41
        result = "5";
42
      } else if( contains( userAgent, ID_MSIE6 ) ) {
43
        result = "6";
44
      } else if( contains( userAgent, ID_MSIE7 ) ) {
45
        result = "7";
46
      } else if( getMajor( userAgent ) > 6 ) {
47
        result = "7";
48
      }
49
    }
50
    return result;
51
  }
52
53
  /**
54
   * helper method to extract the major release number
55
   */
56
  private static int getMajor( final String userAgent ) {
57
    NumberFormat nf = NumberFormat.getInstance();
58
    nf.setParseIntegerOnly( true );
59
    int result = -1;
60
    try {
61
      String appVersion = parseAppVersion( userAgent );
62
      int index = appVersion.indexOf( "." );
63
      if( index != -1 ) {
64
        appVersion = appVersion.substring( 0, index );
65
      }
66
      result = nf.parse( appVersion ).intValue();
67
    } catch( Exception ex ) {
68
      // ignore - can't determine major version number
69
    }
70
    return result;
71
  }
72
73
  /**
74
   * helper method to parse the userAgent String and extract the appVersion
75
   */
76
  private static String parseAppVersion( final String userAgent ) {
77
    String result = "";
78
    int index = userAgent.indexOf( ID_MSIE );
79
    int start = index + ID_MSIE.length() + 1;
80
    result = userAgent.substring( start, start + 3 );
81
    return result;
82
  }
83
}
(-)src/org/eclipse/rwt/internal/browser/DetectorOpera.java (-42 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
/**
14
 * <p>The Opera Browser Detection Class</p>
15
 */
16
public class DetectorOpera extends DetectorBase {
17
18
  private final static String ID_OPERA = "opera";
19
20
  public boolean knowsBrowserString( final String userAgent ) {
21
    return !"".equals( getBrowserVersion( userAgent ) );
22
  }
23
24
  public String getBrowserClassName( final String userAgent ) {
25
    return BROWSER_PACKAGE + "Opera" + getBrowserVersion( userAgent );
26
  }
27
28
  public String getBrowserVersion( final String userAgent ) {
29
    String result = "";
30
    if( contains( userAgent, ID_OPERA ) ) {
31
      if( contains( userAgent, "opera 8" ) || contains( userAgent, "opera/8" ) )
32
      {
33
        result = "8";
34
      } else if(    contains( userAgent, "opera 9" )
35
                 || contains( userAgent, "opera/9" ) )
36
      {
37
        result = "9";
38
      }
39
    }
40
    return result;
41
  }
42
}
(-)src/org/eclipse/rwt/internal/browser/Ie5_5.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 *  <p>The implementation for Microsoft Internet Explorer 5.5.</p>
16
 */
17
public class Ie5_5 extends Ie5up {
18
  
19
  public Ie5_5( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie5_5( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie5_5( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_3.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2.
17
 * </p>
18
 */
19
public class Konqueror3_3 extends Konqueror3_2up {
20
21
  public Konqueror3_3( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_3( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_3( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Ie7.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
15
/** <p>the implementation for Microsoft Internet Explorer 7.</p>
16
  */
17
public class Ie7 extends Ie6up {
18
  
19
  public Ie7( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie7( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie7( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_2up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2 and higher.
17
 * </p>
18
 */
19
public class Konqueror3_2up extends Konqueror3_1up {
20
21
  public Konqueror3_2up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_2up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_2up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Ie7up.java (-31 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
15
/**
16
 *  <p>the implementation for Microsoft Internet Explorer 7 and higher.</p>
17
 */
18
public class Ie7up extends Ie6up {
19
  
20
  public Ie7up( final boolean scriptEnabled ) {
21
    super( scriptEnabled );
22
  }
23
  
24
  public Ie7up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
25
    super( scriptEnabled, ajaxEnabled );
26
  }
27
28
  public Ie7up( final Browser browser ) {
29
    super( browser );
30
  }
31
}
(-)src/org/eclipse/rwt/internal/browser/Opera8up.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>The implementation for Opera 8 and higher.</p>
16
 */
17
public class Opera8up extends Opera {
18
  
19
  public Opera8up( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Opera8up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
  
27
  public Opera8up( final Browser browser ) {
28
    super( browser );
29
  }
30
  
31
  public boolean isXHTMLCapable() {
32
    return true;
33
  }
34
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_3up.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.2.
17
 * </p>
18
 */
19
public class Konqueror3_3up extends Konqueror3_2up {
20
21
  public Konqueror3_3up( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_3up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_3up( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Konqueror3_1.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 * <p>
16
 * the implementation for Konqueror 3.1.
17
 * </p>
18
 */
19
public class Konqueror3_1 extends Konqueror {
20
21
  public Konqueror3_1( final boolean scriptEnabled ) {
22
    super( scriptEnabled );
23
  }
24
25
  public Konqueror3_1( final boolean scriptEnabled, final boolean ajaxEnabled ) {
26
    super( scriptEnabled, ajaxEnabled );
27
  }
28
29
  public Konqueror3_1( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/BrowserLoader.java (-161 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
import java.lang.reflect.Constructor;
14
import java.util.Date;
15
16
import javax.servlet.http.HttpServletRequest;
17
18
import org.eclipse.rwt.internal.service.ContextProvider;
19
import org.eclipse.rwt.internal.service.RequestParams;
20
21
22
23
/** <p>Loads the proper subclass of Browser which represents vendor-specific 
24
 * and version-specific information about the web browser that is used 
25
 * on the client side to display the pages from the current session.</p>
26
 */
27
public final class BrowserLoader {
28
  
29
  public static final String USER_AGENT = "User-Agent";
30
31
  /**
32
   * <p>Loads the browser object matching the browser, script- and
33
   * AJaX-settings extracted from the current context, or a default browser
34
   * with disabled script- and AJaX-settings if no matching browser could 
35
   * be created.</p> 
36
   * @return the Browser object matching the detected browser
37
   */
38
  public static Browser load() {
39
    String browserClassName = detectBrowserClassName();
40
    Browser result;
41
    if( browserClassName.equals( Default.class.getName() ) ) {
42
      result = new Default( false );
43
    } else {
44
      result = loadClassForName( browserClassName, 
45
                                 isScriptEnabled(),
46
                                 isAjaxEnabled() );
47
    }
48
    return result;
49
  }
50
  
51
  /**
52
   * <p>Loads a browser object for a given browser class name and given
53
   * settings for scriptEnabled and ajaxEnabled, or a default browser if 
54
   * matching browser class name can not be found </p>
55
   * 
56
   * @param browserClassName the classname
57
   * @param scriptEnabled boolean true if script should be enabled
58
   * @param ajaxEnabled boolean true if ajax should be enabled
59
   * @return the matching browser object
60
   */
61
  public static Browser loadClassForName( final String browserClassName, 
62
                                          final boolean scriptEnabled,
63
                                          final boolean ajaxEnabled )
64
  {
65
    Browser result;
66
    try {
67
      Class clazz = Class.forName( browserClassName );
68
      Class[] types = new Class[]{ Boolean.TYPE, Boolean.TYPE };
69
      Constructor constructor = clazz.getConstructor( types );
70
      Object[] params = new Object[]{
71
        Boolean.valueOf( scriptEnabled ), Boolean.valueOf( ajaxEnabled )
72
      };
73
      result = ( Browser )constructor.newInstance( params );
74
    } catch( final Exception shouldNotHappen ) {
75
      System.out.println( createMessage( browserClassName ) );
76
      result = new Default( scriptEnabled, ajaxEnabled );
77
    }
78
    return result;
79
  }
80
  
81
  /**
82
   * <p>Loads a browser object for a given browser class name and given
83
   * browser template, or a default browser if matching 
84
   * browser class name can not be found </p>
85
   * 
86
   * @param browserClassName the class to be instantiated
87
   * @param browser
88
   */
89
  public static Browser loadClassForName( final String browserClassName,
90
                                          final Browser browser ) 
91
  {
92
    Browser result = null;
93
    try {
94
      Class clazz = Class.forName( browserClassName );
95
      Class[] types = new Class[]{ Browser.class };
96
      Constructor constructor = clazz.getConstructor( types );
97
      Object[] params = new Object[]{ browser };
98
      result = ( Browser )constructor.newInstance( params );
99
      
100
    } catch( final Exception ex ) {
101
      System.out.println( createMessage( browserClassName ) );                   
102
      result = loadDefaultBrowser( browser );
103
    }
104
    return result;
105
  }
106
107
  private static String createMessage( final String browserClassName ) {
108
    HttpServletRequest request = ContextProvider.getRequest();
109
    String userAgent = request.getHeader( USER_AGENT );
110
    StringBuffer result = new StringBuffer();
111
    result.append( new Date() );
112
    result.append( " BROWSERLOADER: Browser instantiation fault.\n" );
113
    result.append( "Could not load a valid org.eclipse.rap.Browser " );
114
    result.append( "subclass for the received name '" ); 
115
    result.append( browserClassName ); 
116
    result.append( "'. Switch to default Browser.\n" );
117
    result.append( "User-Agent: " );
118
    result.append( userAgent );
119
    return result.toString();
120
  }  
121
  
122
   // Helper methods
123
   /////////////////////////////
124
  
125
  /**
126
   * <p>Determines the classname of the browser matching the userAgent-String
127
   * used in the current context </p>
128
   * @return className of the Browser
129
   */
130
  private static String detectBrowserClassName() {
131
    String userAgent = ContextProvider.getRequest().getHeader( USER_AGENT );
132
    BrowserDetector detector = BrowserDetector.getInstance();
133
    return detector.getBrowserClassName( userAgent );
134
  }
135
  
136
  /**
137
   * <p>Determines if script is enabled in the current context.</p>
138
   * @return true if script is enabled
139
   */
140
  private static boolean isScriptEnabled() {
141
    HttpServletRequest request = ContextProvider.getRequest();
142
    return "true".equals( request.getParameter( RequestParams.SCRIPT ) );
143
  }
144
  
145
  /**
146
   * <p>Determines if AJaX is enabled in the current context.</p>
147
   * @return true if AJaX is enabled
148
   */
149
  private static boolean isAjaxEnabled() {
150
    HttpServletRequest request = ContextProvider.getRequest();
151
    return "true".equals( request.getParameter( RequestParams.AJAX_ENABLED ) );
152
  }
153
  
154
  private static Browser loadDefaultBrowser( final Browser browser ) {
155
    return new Default( browser.isScriptEnabled(), browser.isAjaxEnabled() );
156
  }
157
  
158
  private BrowserLoader() {
159
    // prevent instantiation
160
  }
161
}
(-)src/org/eclipse/rwt/internal/browser/Ie5.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/**
15
 *  <p>the implementation for Microsoft Internet Explorer 5.</p>
16
 */
17
public class Ie5 extends Ie {
18
 
19
  public Ie5( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie5( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie5( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Safari2up.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
15
/** <p>the basic implementation for Safari browsers.</p>
16
*/
17
public class Safari2up extends Safari {
18
19
  public Safari2up( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
23
  public Safari2up( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Safari2up( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Browser.java (-265 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
import java.util.Enumeration;
14
import java.util.Locale;
15
16
import org.eclipse.rwt.internal.service.ContextProvider;
17
18
19
/**
20
 * <p>Subclasses of Browser represent vendor-specific and version-specific
21
 * information about the web browser that is used on the client side to display
22
 * the pages from the current session.</p>
23
 * @see org.eclipse.rwt.W4TContext#getBrowser() W4TContext.getBrowser()
24
 */
25
public abstract class Browser {
26
27
  /**
28
   * <p>
29
   * Default value, if the detected browser vendor and version are unknown.
30
   * </p>
31
   */
32
  public final static String DEFAULT = "Default";
33
  
34
  /**
35
   * <p>
36
   * Netscape Navigator 6 or higher.
37
   * </p>
38
   */
39
  public final static String NAVIGATOR_6_UP = "Nav6up";
40
  /**
41
   * <p>
42
   * Microsoft Internet Explorer 5 or higher.
43
   * </p>
44
   */
45
  public final static String INTERNETEXPLORER_5_UP = "Ie5up";
46
  
47
  private static final String PACKAGE = "org.eclipse.rap.util.browser.";
48
  
49
  /** <p>Whether the browser represented by this Browser has javascript 
50
   * execution enabled.</p> */
51
  private final boolean scriptEnabled;
52
  /** <p>Whether the browser represented by this Browser has AJaX enabled.</p> 
53
   */
54
  private final boolean ajaxEnabled;
55
  
56
  /** <p>Whether AJaX mode is supported for this browser. Requires that the
57
   * browser can handle AJaX requests/responses and that there exist AJaX
58
   * rendering kits.</p> */
59
  protected boolean ajaxCapable = false;
60
  
61
  /**
62
   * The preferred Locale that the client will accept content in, based on the
63
   * Accept-Language header of the first request of the client session. If the
64
   * first client request doesn't provide an Accept-Language header, the the
65
   * default locale for the server is used.
66
   */
67
  private Locale locale;
68
  /**
69
   * an Enumeration of Locale objects indicating, in decreasing order starting
70
   * with the preferred locale, the locales that are acceptable to the client
71
   * based on the Accept-Language header of the first request of the client
72
   * session. If the first client request doesn't provide an Accept-Language
73
   * header, an Enumeration containing one Locale, the default locale for the
74
   * server is used.
75
   */
76
  private Enumeration locales;
77
  /**
78
   * the Internet Protocol (IP) address of the client that sent the requests of
79
   * the current session.
80
   */
81
  private String remoteAddr;
82
  /**
83
   * the fully qualified name of the client that sent the requests of the
84
   * current session. If the underlying engine cannot or chooses not to resolve
85
   * the hostname (to improve performance), this method returns the
86
   * dotted-string form of the IP address.
87
   */
88
  private String remoteHost;
89
90
  /**
91
   * <p>Constructs a new Browser instance.</p>
92
   * <p>This constructor actually calls {@link #Browser(boolean,boolean) 
93
   * Browser(scriptEnabled,false}}.</p>
94
   */
95
  public Browser( final boolean scriptEnabled ) {
96
    this( scriptEnabled, false );
97
  }
98
  
99
  /**
100
   * <p>Constructs a new Browser instance.</p>
101
   * <p>Note: you will probably not need to create Browser objects. Use
102
   * W4TContext.getBrowser() to retrieve the Browser object which represents
103
   * the browser that is used on the client side to display the pages from the
104
   * current session.</p>
105
   * @param scriptEnabled whether this browser supports execution of JavaScript.
106
   * @param ajaxEnabled whether this browser supports AJaX. If this argument
107
   * is set to <code>true</code>, the scriptEnabled argumentmust also be 
108
   * set to <code>true</code>. 
109
   */
110
  // TODO [rh] these two args should be replaced by enum (NoScript, Script, Ajax), must preserve api-compatibility?
111
  public Browser( final boolean scriptEnabled, final boolean ajaxEnabled ) {
112
    this.scriptEnabled = scriptEnabled;
113
    this.ajaxEnabled = ajaxEnabled;
114
    locale = ContextProvider.getRequest().getLocale();
115
    locales = ContextProvider.getRequest().getLocales();
116
    remoteAddr = ContextProvider.getRequest().getRemoteAddr();
117
    remoteHost = ContextProvider.getRequest().getRemoteHost();
118
  }
119
120
  /**
121
   * <p>Constructs a new Browser instance.</p>
122
   * <p>Note: you will probably not need to create Browser objects. Use
123
   * W4TContext.getBrowser() to retrieve the Browser object which represents
124
   * the browser that is used on the client side to display the pages from the
125
   * current session.</p>
126
   * <p>This constructor may be used to create e.g. the predecessor of the
127
   * currently set browser without loosing its session depending attributes in
128
   * the newly created Browser object.</p>
129
   */
130
  public Browser( final Browser browser ) {
131
    this.scriptEnabled = browser.scriptEnabled;
132
    this.ajaxEnabled = browser.ajaxEnabled;
133
    // keep the ajaxCapable flag from the given browser; the RendererCache needs
134
    // this to work 
135
    this.ajaxCapable = browser.ajaxCapable;
136
    locale = browser.getLocale();
137
    locales = browser.getLocales();
138
    remoteAddr = browser.getRemoteAddr();
139
    remoteHost = browser.getRemoteHost();
140
  }
141
142
  /**
143
   * <p>
144
   * returns whether this browser is either the same or a later version than
145
   * the browser represented by the passed browser identifier.
146
   * </p>
147
   * 
148
   * <p>
149
   * <b>Example: </b> use the following code to find out whether the browser of
150
   * the current session is Netscape Navigator 4 or higher:
151
   * 
152
   * <pre>
153
   *   Browser browser = W4TContext.getBrowser();
154
   *   boolean isNetscape4up = browser.isCompatible( Browser.NAVIGATOR_4_UP );
155
   * </pre>
156
   * 
157
   * <p>
158
   * Note that a later browser is not necessarily compatible to an older
159
   * version. This method tells you only whether this Browser is the same or a
160
   * later version, nothing about actual compatibility.
161
   * </p>
162
   * 
163
   * @param anotherBrowser
164
   *          denotes a browser version as specified in the public field
165
   *          definitions in {@link org.eclipse.rwt.internal.browser.Browser Browser}
166
   */
167
  // TODO [rh] method never used, remove it? 
168
  public boolean isCompatible( final String anotherBrowser ) {
169
    boolean result = false;
170
    String thisBrowser = toString();
171
    if( thisBrowser.equals( anotherBrowser ) ) {
172
      result = true;
173
    }
174
    if( !result ) {
175
      try {
176
        Class anotherClass = Class.forName( PACKAGE + anotherBrowser );
177
        if( this.getClass().isAssignableFrom( anotherClass ) ) {
178
          result = true;
179
        }
180
        if( !result && !thisBrowser.endsWith( "up" ) ) {
181
          String name = this.getClass().getName() + "up";
182
          if( Class.forName( name ).isAssignableFrom( anotherClass ) ) {
183
            result = true;
184
          }
185
        }
186
      } catch( ClassNotFoundException cnfe ) {
187
        // this means nothing more than that there is no compatibility at all
188
      }
189
    }
190
    return result;
191
  }
192
193
  // attribute setters and getters
194
  ////////////////////////////////
195
  
196
  /**
197
   * <p>Whether the browser represented by this Browser has JavasSript 
198
   * execution enabled.</p>
199
   */
200
  public boolean isScriptEnabled() {
201
    return scriptEnabled;
202
  }
203
  
204
  /**
205
   * <p>Returns whether the browser represented by this Browser object has
206
   * <em>AJaX</em> enabled.</p>
207
   */
208
  public boolean isAjaxEnabled() {
209
    return ajaxCapable && ajaxEnabled;
210
  }
211
212
  public String toString() {
213
    String result = this.getClass().getName();
214
    int index = result.lastIndexOf( '.' ) + 1;
215
    return result.substring( index );
216
  }
217
218
  /**
219
   * <p>Returns the preferred Locale that the client will accept content in, 
220
   * based on the Accept-Language header of the first request of the client 
221
   * session. If the first client request doesn't provide an Accept-Language 
222
   * header, the the default locale for the server is returned.</p>
223
   */
224
  public Locale getLocale() {
225
    return locale;
226
  }
227
228
  /**
229
   * <p>Returns an Enumeration of Locale objects indicating, in decreasing order
230
   * starting with the preferred locale, the locales that are acceptable to the
231
   * client based on the Accept-Language header of the first request of the
232
   * client session. If the first client request doesn't provide an
233
   * Accept-Language header, an Enumeration containing one Locale, the default
234
   * locale for the server is returned.</p>
235
   */
236
  public Enumeration getLocales() {
237
    return locales;
238
  }
239
240
  /**
241
   * <p>Returns the Internet Protocol (IP) address of the client that sends the
242
   * requests of the current session.</p>
243
   */
244
  public String getRemoteAddr() {
245
    return remoteAddr;
246
  }
247
248
  /**
249
   * <p>Returns the fully qualified name of the client that sents the requests 
250
   * of the current session. If the underlying engine cannot or chooses not to
251
   * resolve the hostname (to improve performance), this method returns the
252
   * dotted-string form of the IP address.</p>
253
   */
254
  public String getRemoteHost() {
255
    return remoteHost;
256
  }
257
258
  /**
259
   * <p>Returns whether the browser represented by this Browser object 
260
   * understands XHTML.</p>
261
   */
262
  public boolean isXHTMLCapable() {
263
    return false;
264
  }
265
}
(-)src/org/eclipse/rwt/internal/browser/Ie.java (-30 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>the basic implementation for Microsoft browsers.</p>
16
 */
17
public class Ie extends Default {
18
  
19
  public Ie( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
  }
22
  
23
  public Ie( final boolean scriptEnabled, final boolean ajaxEnabled ) {
24
    super( scriptEnabled, ajaxEnabled );
25
  }
26
27
  public Ie( final Browser browser ) {
28
    super( browser );
29
  }
30
}
(-)src/org/eclipse/rwt/internal/browser/Opera9.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
/** 
15
 * <p>The implementation for Opera 8 and higher.</p>
16
 */
17
public class Opera9 extends Opera8up {
18
  
19
  public Opera9( final boolean scriptEnabled ) {
20
    super( scriptEnabled );
21
    this.ajaxCapable = true;
22
  }
23
  
24
  public Opera9( final boolean scriptEnabled, final boolean ajaxEnabled ) {
25
    super( scriptEnabled, ajaxEnabled );
26
    this.ajaxCapable = true;
27
  }
28
  
29
  public Opera9( final Browser browser ) {
30
    super( browser );
31
  }
32
}
(-)src/org/eclipse/rwt/internal/browser/Safari.java (-35 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.browser;
12
13
14
15
/** 
16
 * <p>The base class for Safari browsers. No AJaX support.</p>
17
 */
18
public class Safari extends Default {
19
20
  public Safari( final boolean scriptEnabled ) {
21
    super( scriptEnabled );
22
  }
23
24
  public Safari( final boolean scriptEnabled, final boolean ajaxEnabled ) {
25
    super( scriptEnabled, false );
26
  }
27
28
  public Safari( final Browser browser ) {
29
    super( browser );
30
  }
31
  
32
  public boolean isXHTMLCapable() {
33
    return true;
34
  }
35
}
(-)src/org/eclipse/rwt/internal/util/HTML.java (-125 / +1 lines)
Lines 17-168 Link Here
17
 * </p> 
17
 * </p> 
18
 */
18
 */
19
public final class HTML {
19
public final class HTML {
20
  public final static String AJAX_RESPONSE = "ajax-response";
20
21
  public final static String START_AJAX_RESPONSE = "<ajax-response>";
22
  public final static String END_AJAX_RESPONSE = "</ajax-response>";
23
  
24
  public final static String NBSP_STRING = "\u00A0";
25
  public final static char NBSP_CHAR = '\u00A0';
26
  
27
  public final static String A = "a";
28
  public final static String ACCEPT_CHARSET = "accept-charset";
29
  public final static String ACTION = "action";
30
  public final static String ALIGN = "align";
31
  public final static String ALT = "alt";
32
  public final static String BACKGROUND = "background";
33
  public final static String BGCOLOR = "bgcolor";
34
  public final static String BODY = "body";
21
  public final static String BODY = "body";
35
  public final static String BOLD = "b";
36
  public final static String BORDER = "border";
37
  public final static String BR = "br";
38
  public final static String BUTTON = "button";
39
  public final static String CELLPADDING = "cellpadding";
40
  public final static String CELLSPACING = "cellspacing";
41
  public final static String CHARSET = "charset";
22
  public final static String CHARSET = "charset";
42
  public final static String CHECKBOX = "checkbox";
43
  public final static String CHECKED = "checked";
44
  public final static String CENTER = "center";
45
  public final static String COLOR = "color";
46
  public final static String COLS = "cols";
47
  public final static String COLSPAN = "colspan";
48
  public final static String CONTENT = "content";
23
  public final static String CONTENT = "content";
49
  public final static String CONTENT_TYPE = "Content-Type";
24
  public final static String CONTENT_TYPE = "Content-Type";
50
  public final static String CLASS = "class";
51
  public final static String DIR = "dir";
52
  public final static String DISABLED = "disabled";
53
  public final static String DIV = "div";
54
  public final static String ENCTYPE = "enctype";
55
  public final static String FACE = "face";
56
  public final static String FILE = "file";
57
  public final static String FONT = "font";
58
  public final static String FORM = "form";
59
  public final static String H3 = "h3";
60
  public final static String HEAD = "head";
25
  public final static String HEAD = "head";
61
  public final static String HEIGHT = "height";
62
  public final static String HIDDEN = "hidden";
63
  public final static String HIDE = "hide";
64
  public final static String HREF = "href";
65
  public final static String HTML = "html";
26
  public final static String HTML = "html";
66
  public final static String HTTP_EQUIV = "http-equiv";
27
  public final static String HTTP_EQUIV = "http-equiv";
67
  public final static String ID = "id";
68
  public final static String IMG = "img";
69
  public final static String IMAGE = "image";
70
  public final static String INPUT = "input";
71
  public final static String LABEL = "label";
72
  public final static String LANGUAGE = "language";
73
  public final static String LANG = "lang";
74
  public final static String LAYER = "layer";
75
  public final static String LEFT = "left";
76
  public final static String LEFTMARGIN = "leftmargin";
77
  public final static String LI = "li";
78
  public final static String LINK = "link";
79
  public final static String MARGINHEIGHT = "marginheight";
80
  public final static String MARGINWIDTH = "marginwidth";
81
  public final static String MAXLENGTH = "maxlength";
82
  public final static String META = "meta";
28
  public final static String META = "meta";
83
  public final static String METHOD = "method";
84
  public final static String MIDDLE = "middle";
85
  public final static String NAME = "name";
86
  public final static String NBSP = "&nbsp;";
87
  public final static String NOWRAP = "nowrap";
88
  public final static String OL = "ol";
89
  public final static String ON_CHANGE = "onchange";
90
  public final static String ON_CLICK = "onclick";
91
  public final static String ON_DBL_CLICK = "ondblclick";
92
  public final static String ON_FOCUS = "onfocus";
93
  public final static String ON_KEY_DOWN = "onkeydown";
94
  public final static String ON_KEY_UP = "onkeyup";
95
  public final static String ON_KEY_PRESS = "onkeypress";
96
  public final static String ON_MOUSE_DOWN = "onmousedown";
97
  public final static String ON_MOUSE_MOVE = "onmousemove";
98
  public final static String ON_MOUSE_OVER = "onmouseover";
99
  public final static String ON_MOUSE_OUT = "onmouseout";
100
  public final static String ON_MOUSE_UP = "onmouseup";
101
  public final static String ON_RESIZE = "onresize";
102
  public final static String ON_UNLOAD = "onunload";
103
  public final static String OPTION = "option";
104
  public final static String OVERFLOW = "overflow";
105
  public final static String P = "p";
106
  public final static String PASSWORD = "password";
107
  public final static String POST = "post";
108
  public final static String POSITION = "position";
109
  public final static String RADIO = "radio";
110
  public final static String READONLY = "readonly";
111
  public final static String REL = "rel";
112
  public final static String RESET = "reset";
113
  public final static String ROWS = "rows";
114
  public final static String ROWSPAN = "rowspan";
115
  public final static String SCRIPT = "script";
29
  public final static String SCRIPT = "script";
116
  public final static String SELECT = "select";
117
  public final static String SELECTED = "selected";
118
  public final static String SIZE = "size";
119
  public final static String SPAN = "span";
120
  public final static String SRC = "src";
30
  public final static String SRC = "src";
121
  public final static String START = "start";
122
  public final static String STYLE = "style";
31
  public final static String STYLE = "style";
123
  public final static String STYLESHEET = "stylesheet";
124
  public final static String SUBMIT = "submit";
125
  public final static String TABINDEX = "tabindex";
126
  public final static String TABLE = "table";
127
  public final static String TARGET = "target";
128
  public final static String TD = "td";
129
  public final static String TEXT = "text";
130
  public final static String TEXTAREA = "textarea";
131
  public final static String TITLE = "title";
32
  public final static String TITLE = "title";
132
  public final static String TOP = "top";
133
  public final static String TOPMARGIN = "topmargin";
134
  public final static String TR = "tr";
135
  public final static String TYPE = "type";
33
  public final static String TYPE = "type";
136
  public final static String UL = "ul";
137
  public final static String VALIGN = "valign";
138
  public final static String VALUE = "value";
139
  public final static String WIDTH = "width";
140
  public final static String VISIBILITY = "visibility";
141
  public final static String WRAP = "wrap";
142
  
143
  public final static String TAG_BEGIN_OPEN = "<";
144
  public final static String TAG_END_OPEN = "</";
145
  public final static String TAG_CLOSE = ">";
146
147
  public final static String DOCTYPE_4_0_TRANSITIONAL
148
    = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
149
  public final static String DOCTYPE_4_01_TRANSITIONAL 
150
    = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
151
34
152
  public final static String CONTENT_TEXT_HTML_UTF_8 
35
  public final static String CONTENT_TEXT_HTML_UTF_8 
153
    = "text/html; charset=UTF-8";
36
    = "text/html; charset=UTF-8";
154
  public final static String CONTENT_TEXT_HTML = "text/html";
37
  public final static String CONTENT_TEXT_HTML = "text/html";
155
  public final static String CONTENT_TEXT_XML = "text/xml";
156
  public final static String CONTENT_TEXT_CSS = "text/css";
38
  public final static String CONTENT_TEXT_CSS = "text/css";
157
  public final static String CONTENT_TEXT_JAVASCRIPT = "text/javascript";
39
  public final static String CONTENT_TEXT_JAVASCRIPT = "text/javascript";
158
  public final static String CONTENT_TEXT_JAVASCRIPT_UTF_8 
40
  public final static String CONTENT_TEXT_JAVASCRIPT_UTF_8 
159
    = "text/javascript; charset=UTF-8";
41
    = "text/javascript; charset=UTF-8";
160
  public final static String CONTENT_IMAGE_ICO = "image/ico";
161
  public final static String CONTENT_IMAGE_GIF = "image/gif";
162
163
  public final static String ENCTYPE_FORM_URLENCODED 
164
    = "application/x-www-form-urlencoded";
165
  public final static String ENCTYPE_FORM_DATA = "multipart/form-data";
166
42
167
  public final static String CHARSET_NAME_UTF_8 = "UTF-8";
43
  public final static String CHARSET_NAME_UTF_8 = "UTF-8";
168
  public final static String CHARSET_NAME_ISO_8859_1 = "ISO-8859-1";
44
  public final static String CHARSET_NAME_ISO_8859_1 = "ISO-8859-1";
(-)src/org/eclipse/rwt/internal/util/Assert.java (-55 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.util;
12
13
14
/** <p>Provides some simple assertion facility that sends runtime 
15
  * exceptions on assertion fails.</p>
16
  */
17
public final class Assert {
18
19
  private Assert() {
20
    // prevent instantiation
21
  }
22
23
  /** <p>Fails if obj is null.</p> */
24
  public static void isNotNull( final Object obj ) {
25
    isNotNull( obj, "" );
26
  }
27
  
28
  /** <p>Fails if obj is null, and sends message.</p> */
29
  public static void isNotNull( final Object obj, final String message ) {
30
    if( obj == null ) {
31
      throw new AssertionFailedException( message );
32
    }
33
  }
34
35
  /** <p>Fails if expr is false.</p> */
36
  public static void isTrue( final boolean expr ) {
37
    isTrue( expr, "" );    
38
  }
39
40
  /** <p>Fails if expr is false and sends message.</p> */
41
  public static void isTrue( final boolean expr, final String message ) {
42
    if( !expr ) {
43
      throw new AssertionFailedException( message );      
44
    }
45
  }
46
47
  /** The common exception type (runtime exception) for failed assertions. */ 
48
  private static class AssertionFailedException extends RuntimeException {
49
    private static final long serialVersionUID = 1L;
50
    
51
    AssertionFailedException( final String msg ) {
52
      super( msg );
53
    }
54
  }
55
}
(-)src/org/eclipse/rwt/internal/util/URLHelper.java (+8 lines)
Lines 28-33 Link Here
28
    // no instance creation
28
    // no instance creation
29
  }
29
  }
30
30
31
  public static String getSerlvetName() {
32
    String result = ContextProvider.getRequest().getServletPath();
33
    if( result.startsWith( "/" ) ) {
34
      result = result.substring( 1 );
35
    }
36
    return result;
37
  }
38
31
  /** returns the servlets URL of the current W4Toolkit installation. */
39
  /** returns the servlets URL of the current W4Toolkit installation. */
32
  public static String getURLString( final boolean addEncodingDummy ) {
40
  public static String getURLString( final boolean addEncodingDummy ) {
33
    HttpServletRequest request = ContextProvider.getRequest();
41
    HttpServletRequest request = ContextProvider.getRequest();
(-)src/org/eclipse/rwt/internal/util/HTMLUtil.java (-104 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.util;
12
13
import java.io.IOException;
14
15
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
16
17
/**
18
 * <p>Utility class to create commonly used HTML artefacts.</p>
19
 */
20
public final class HTMLUtil {
21
22
  public static String hiddenInput( final String name, final String value ) {
23
    StringBuffer buffer = new StringBuffer();
24
    hiddenInput( buffer, name, value );
25
    return buffer.toString();
26
  }
27
  
28
  public static void hiddenInput( final StringBuffer buffer, 
29
                                  final String name, 
30
                                  final String value )
31
  {
32
    String id = name == null 
33
              ? null 
34
              : EntitiesUtil.encodeHTMLEntities( name );
35
    String encodedValue = value == null
36
                        ? null
37
                        : EntitiesUtil.encodeHTMLEntities( value );
38
    buffer.append( "<input type=\"hidden\" id=\"" );
39
    buffer.append( id );
40
    buffer.append( "\" name=\"" );
41
    buffer.append( id );
42
    buffer.append( "\" value=\"" );
43
    buffer.append( encodedValue );
44
    buffer.append( "\" />" );
45
  }
46
47
  public static void hiddenInput( final HtmlResponseWriter writer,
48
                                  final String name,
49
                                  final String value )
50
    throws IOException
51
  {
52
    writer.startElement( HTML.INPUT, null );
53
    writer.writeAttribute( HTML.TYPE, HTML.HIDDEN, null );
54
    writer.writeAttribute( HTML.ID, name, null );
55
    writer.writeAttribute( HTML.NAME, name, null );
56
    writer.writeAttribute( HTML.VALUE, value, null );
57
    writer.endElement( HTML.INPUT );
58
  }
59
  
60
  public static void attribute( final StringBuffer buffer, 
61
                                final String name, 
62
                                final String value  ) 
63
  {
64
    buffer.append( " " );
65
    buffer.append( name );
66
    buffer.append( "=\"" );
67
    String encodedValue = value == null 
68
                        ? value 
69
                        : EntitiesUtil.encodeHTMLEntities( value );
70
    buffer.append( encodedValue );
71
    buffer.append( "\"" );
72
  }
73
  
74
  public static String attribute( final String name, final String value ) {
75
    StringBuffer buffer = new StringBuffer();
76
    attribute( buffer, name, value );
77
    return buffer.toString();
78
  }
79
80
  // TODO [w4t] moved here from RenderUtil in favor of moving RenderUtil to RWT
81
  //      (which in turn depends on WebComponent)
82
  public static String createXmlProcessingInstruction() {
83
    StringBuffer result = new StringBuffer();
84
    result.append( "<?xml" );
85
    HTMLUtil.attribute( result, "version", "1.0" );
86
    HTMLUtil.attribute( result, "encoding", HTML.CHARSET_NAME_UTF_8 );
87
    result.append( " ?>" );
88
    return result.toString();
89
  }
90
91
  // TODO [w4t] moved here from RenderUtil in favor of moving RenderUtil to RWT 
92
  //      (which in turn depends on WebComponent)
93
  public static String createJavaScriptInline( final String javaScriptCode ) {
94
    StringBuffer result = new StringBuffer();
95
    if( javaScriptCode != null && !"".equals( javaScriptCode ) ) {
96
      result.append( "<script" );
97
      HTMLUtil.attribute( result, HTML.TYPE, HTML.CONTENT_TEXT_JAVASCRIPT );
98
      result.append( ">" );
99
      result.append( EntitiesUtil.encodeHTMLEntities( javaScriptCode ) );
100
      result.append( "</script>" );
101
    }
102
    return result.toString();
103
  }
104
}
(-)src/org/eclipse/rwt/internal/service/AbstractServiceHandler.java (-24 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-46 Link Here
12
package org.eclipse.rwt.internal.service;
12
package org.eclipse.rwt.internal.service;
13
13
14
import java.io.*;
14
import java.io.*;
15
import java.text.SimpleDateFormat;
16
import java.util.*;
17
import java.util.zip.GZIPOutputStream;
15
import java.util.zip.GZIPOutputStream;
18
16
19
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletRequest;
20
import javax.servlet.http.HttpServletResponse;
18
import javax.servlet.http.HttpServletResponse;
21
19
22
import org.eclipse.rwt.Adaptable;
23
import org.eclipse.rwt.internal.*;
20
import org.eclipse.rwt.internal.*;
24
import org.eclipse.rwt.internal.util.HTML;
21
import org.eclipse.rwt.internal.util.HTML;
25
import org.eclipse.rwt.service.IServiceHandler;
22
import org.eclipse.rwt.service.IServiceHandler;
26
23
27
public abstract class AbstractServiceHandler implements IServiceHandler {
24
public abstract class AbstractServiceHandler implements IServiceHandler {
28
25
29
  private static final int TIMEOUT = 600000;
30
  private static final String EXPIRATION_TIME_FORMAT
31
    = "EEE, dd MMM yyyy HH:mm:ss zzz";
32
  private static final SimpleDateFormat FORMATTER
33
    = new SimpleDateFormat( EXPIRATION_TIME_FORMAT, Locale.US );
34
  private static final String EXPIRES = "Expires";
35
  private static final String ACCEPT_ENCODING = "Accept-Encoding";
26
  private static final String ACCEPT_ENCODING = "Accept-Encoding";
36
  private static final String CONTENT_ENCODING = "Content-Encoding";
27
  private static final String CONTENT_ENCODING = "Content-Encoding";
37
  private static final String ENCODING_GZIP = "gzip";
28
  private static final String ENCODING_GZIP = "gzip";
38
29
39
30
40
  IServiceAdapter getServiceAdapter( final Adaptable model ) {
41
    return ( IServiceAdapter )model.getAdapter( IServiceAdapter.class );
42
  }
43
44
  static boolean isAcceptEncoding() {
31
  static boolean isAcceptEncoding() {
45
    String encodings = getRequest().getHeader( ACCEPT_ENCODING );
32
    String encodings = getRequest().getHeader( ACCEPT_ENCODING );
46
    return encodings != null && encodings.indexOf( ENCODING_GZIP ) != -1;
33
    return encodings != null && encodings.indexOf( ENCODING_GZIP ) != -1;
Lines 59-74 Link Here
59
    return new PrintWriter( utf8Writer, false );
46
    return new PrintWriter( utf8Writer, false );
60
  }
47
  }
61
48
62
  protected void setExpirationHeader() {
63
    // set an expiration date for the js-library to avoid reloading it
64
    // on every page request!
65
    // TODO: configuration of the expiration time
66
    FORMATTER.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
67
    Date date = new Date( System.currentTimeMillis() + TIMEOUT );
68
    String expirationTime = FORMATTER.format( date );
69
    getResponse().setHeader( EXPIRES, expirationTime );
70
  }
71
72
  static IInitialization getInitProps() {
49
  static IInitialization getInitProps() {
73
    IConfiguration configuration = ConfigurationReader.getConfiguration();
50
    IConfiguration configuration = ConfigurationReader.getConfiguration();
74
    return configuration.getInitialization();
51
    return configuration.getInitialization();
(-)src/org/eclipse/rwt/internal/service/IServiceStateInfo.java (-36 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-58 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
package org.eclipse.rwt.internal.service;
12
13
13
import org.eclipse.rwt.internal.browser.Browser;
14
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
14
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
15
import org.eclipse.rwt.service.IServiceStore;
15
import org.eclipse.rwt.service.IServiceStore;
16
16
17
17
18
public interface IServiceStateInfo extends IServiceStore {
18
public interface IServiceStateInfo extends IServiceStore {
19
  
19
  
20
  void setExpired( boolean expired );
21
22
  boolean isExpired();
23
24
  void setExceptionOccured( boolean exceptionOcc );
25
26
  boolean isExceptionOccured();
27
  
28
  void setInvalidated( boolean invalidated );
29
  
30
  boolean isInvalidated();
31
32
  void setResponseWriter( final HtmlResponseWriter reponseWriter );
20
  void setResponseWriter( final HtmlResponseWriter reponseWriter );
33
21
34
  HtmlResponseWriter getResponseWriter();
22
  HtmlResponseWriter getResponseWriter();
35
  
23
  
36
  void setDetectedBrowser( Browser browser );
37
  Browser getDetectedBrowser();
38
39
  /** <p>returns the event queue of this ServiceStateInfo.</p>
40
   *
41
   * <p>The event queue for a request contains all WebDataEvents, i.e. 
42
   * events which are fired from a component when its value changes.</p>
43
   */
44
  Object getEventQueue();
45
  void setEventQueue( Object eventQueue );
46
47
  /** <p>returns whether the startup request parameter should be ignored
48
   * during the render phase of the requests lifecycle.</p> 
49
   */
50
  boolean isIgnoreStartup();
51
52
  /** <p>sets whether the startup request parameter should be ignored
53
   * during the render phase of the requests lifecycle.</p>
54
   */
55
  void setIgnoreStartup( boolean ignoreStartup );
56
57
  boolean isFirstAccess();
58
}
24
}
(-)src/org/eclipse/rwt/internal/service/LifeCycleServiceHandler.java (-33 / +19 lines)
Lines 21-37 Link Here
21
21
22
import org.eclipse.rwt.SessionSingletonBase;
22
import org.eclipse.rwt.SessionSingletonBase;
23
import org.eclipse.rwt.internal.RWTMessages;
23
import org.eclipse.rwt.internal.RWTMessages;
24
import org.eclipse.rwt.internal.browser.Browser;
25
import org.eclipse.rwt.internal.browser.BrowserLoader;
26
import org.eclipse.rwt.internal.lifecycle.*;
24
import org.eclipse.rwt.internal.lifecycle.*;
27
import org.eclipse.rwt.internal.util.HTML;
25
import org.eclipse.rwt.internal.util.HTML;
26
import org.eclipse.rwt.service.ISessionStore;
28
27
29
28
30
public class LifeCycleServiceHandler extends AbstractServiceHandler {
29
public class LifeCycleServiceHandler extends AbstractServiceHandler {
31
30
31
  public static final String RWT_INITIALIZE = "rwt_initialize";
32
32
  // TODO [if]: Move this code to a fragment
33
  // TODO [if]: Move this code to a fragment
33
  private static final String PATTERN_RELOAD
34
  private static final String PATTERN_RELOAD
34
    = "qx.core.Init.getInstance().getApplication().reload( \"{0}\" )";
35
    = "qx.core.Init.getInstance().getApplication().reload( \"{0}\" )";
36
  
37
  private final static String SESSION_INITIALIZED
38
    = LifeCycleServiceHandler.class.getName() + "#isSessionInitialized";
35
39
36
  public void service() throws IOException, ServletException {
40
  public void service() throws IOException, ServletException {
37
    synchronized( ContextProvider.getSession() ) {
41
    synchronized( ContextProvider.getSession() ) {
Lines 40-46 Link Here
40
  }
44
  }
41
45
42
  void synchronizedService() throws ServletException, IOException {
46
  void synchronizedService() throws ServletException, IOException {
43
    LifeCycleServiceHandler.initializeStateInfo();
47
    initializeStateInfo();
44
    RWTRequestVersionControl.beforeService();
48
    RWTRequestVersionControl.beforeService();
45
    try {
49
    try {
46
      if(    RWTRequestVersionControl.isValid()
50
      if(    RWTRequestVersionControl.isValid()
Lines 58-72 Link Here
58
62
59
  private static void runLifeCycle() throws ServletException, IOException {
63
  private static void runLifeCycle() throws ServletException, IOException {
60
    checkRequest();
64
    checkRequest();
61
    detectBrowser();
65
    initializeSession();
62
    if( isBrowserDetected() ) {
66
    if( isSessionInitialized() ) {
63
      RequestParameterBuffer.merge();
67
      RequestParameterBuffer.merge();
64
      LifeCycle lifeCycle = ( LifeCycle )LifeCycleFactory.getLifeCycle();
68
      LifeCycle lifeCycle = ( LifeCycle )LifeCycleFactory.getLifeCycle();
65
      lifeCycle.execute();
69
      lifeCycle.execute();
66
    } else {
70
    } else {
67
      Map parameters = ContextProvider.getRequest().getParameterMap();
71
      Map parameters = ContextProvider.getRequest().getParameterMap();
68
      RequestParameterBuffer.store( parameters );
72
      RequestParameterBuffer.store( parameters );
69
      BrowserSurvey.sendBrowserSurvey();
73
      StartupPage.send();
70
    }
74
    }
71
    writeOutput();
75
    writeOutput();
72
  }
76
  }
Lines 81-87 Link Here
81
    String uiRoot = request.getParameter( RequestParams.UIROOT );
85
    String uiRoot = request.getParameter( RequestParams.UIROOT );
82
    HttpSession session = request.getSession();
86
    HttpSession session = request.getSession();
83
    return    !session.isNew() && !startup && uiRoot == null 
87
    return    !session.isNew() && !startup && uiRoot == null 
84
           || startup && isBrowserDetected();
88
           || startup && isSessionInitialized();
85
  }
89
  }
86
  
90
  
87
  private static void initializeStateInfo() {
91
  private static void initializeStateInfo() {
Lines 109-136 Link Here
109
    LifeCycleServiceHandler.writeOutput();
113
    LifeCycleServiceHandler.writeOutput();
110
  }
114
  }
111
115
112
  private static boolean isBrowserDetected() {
116
  private static boolean isSessionInitialized() {
113
    return getBrowser() != null;
117
    ISessionStore session = ContextProvider.getSession();
118
    return Boolean.TRUE.equals( session.getAttribute( SESSION_INITIALIZED ) );
114
  }
119
  }
115
120
116
  private static Browser getBrowser() {
121
  public static void initializeSession() {
117
    String id = ServiceContext.DETECTED_SESSION_BROWSER;
122
    if( !isSessionInitialized() ) {
118
    return ( Browser )ContextProvider.getSession().getAttribute( id );
123
      if(  getRequest().getParameter( RWT_INITIALIZE ) != null ) {
119
  }
124
        ISessionStore session = ContextProvider.getSession();
120
  
125
        session.setAttribute( SESSION_INITIALIZED, Boolean.TRUE );
121
  private static void detectBrowser() {
122
    if( !isBrowserDetected() ) {
123
      if(    getRequest().getParameter( RequestParams.SCRIPT ) != null 
124
          && getRequest().getParameter( RequestParams.AJAX_ENABLED ) != null )
125
      {
126
        Browser browser = BrowserLoader.load();
127
        String id = ServiceContext.DETECTED_SESSION_BROWSER;
128
        ContextProvider.getSession().setAttribute( id, browser );
129
      }
126
      }
130
    }
127
    }
131
    if ( isBrowserDetected() ) {
132
      ContextProvider.getStateInfo().setDetectedBrowser( getBrowser() );
133
    }
134
  }
128
  }
135
  
129
  
136
  private static void checkRequest() {
130
  private static void checkRequest() {
Lines 170-187 Link Here
170
        = ContextProvider.getStateInfo().getResponseWriter();
164
        = ContextProvider.getStateInfo().getResponseWriter();
171
      PrintWriter out = getOutputWriter();
165
      PrintWriter out = getOutputWriter();
172
      try {
166
      try {
173
        // send the head to the client
174
        for( int i = 0; i < content.getHeadSize(); i++ ) {
175
          out.print( content.getHeadToken( i ) );
176
        }
177
        // send the body to the client
167
        // send the body to the client
178
        for( int i = 0; i < content.getBodySize(); i++ ) {
168
        for( int i = 0; i < content.getBodySize(); i++ ) {
179
          out.print( content.getBodyToken( i ) );
169
          out.print( content.getBodyToken( i ) );
180
        }
170
        }
181
        // send the foot to the client
182
        for( int i = 0; i < content.getFootSize(); i++ ) {
183
          out.print( content.getFootToken( i ) );
184
        }
185
      } finally {
171
      } finally {
186
        out.close();
172
        out.close();
187
      }
173
      }
(-)src/org/eclipse/rwt/internal/service/ServiceStateInfo.java (-80 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-21 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
package org.eclipse.rwt.internal.service;
12
13
13
import java.util.HashMap;
14
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.Map;
15
16
16
import javax.servlet.http.HttpServletRequest;
17
18
import org.eclipse.rwt.internal.browser.Browser;
19
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
17
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
20
18
21
19
Lines 25-75 Link Here
25
 */
23
 */
26
public final class ServiceStateInfo implements IServiceStateInfo {
24
public final class ServiceStateInfo implements IServiceStateInfo {
27
25
28
  /** the WebForm posted in the request has expired */
29
  private boolean expired = false;
30
  /** the WebForm processed in the model caused an exception */
31
  private boolean exceptionOccured = false;
32
  /** whether the startup request parameter should be ignored
33
    * during the render phase of the requests lifecycle. */
34
  private boolean ignoreStartup = false;
35
  /** <p>The browser as it was detected at session startup.</p> */
36
  private Browser detectedBrowser;
37
  /** <p>contains the rendered page for the request for which this 
38
    * ServiceStateInfo collects data.</p> */
39
  private HtmlResponseWriter responseWriter;
26
  private HtmlResponseWriter responseWriter;
40
  /** <p>The event queue for a request contains all WebDataEvents, i.e. 
41
    * events which are fired from a component when its value changes.</p> */
42
  private Object eventQueue;
43
  
27
  
44
  private boolean invalidated;
45
  private final Map attributes = new HashMap();
28
  private final Map attributes = new HashMap();
46
  
29
  
47
  public void setExpired( final boolean expired ) {
48
    this.expired = expired;
49
  }
50
51
  public boolean isExpired() {
52
    return expired;
53
  }
54
55
  public void setExceptionOccured( final boolean exceptionOcc ) {
56
    this.exceptionOccured = exceptionOcc;
57
  }
58
59
  public boolean isExceptionOccured() {
60
    return exceptionOccured;
61
  }
62
  
63
  /** <p>Marks the current session as invalidated.</p> */
64
  public void setInvalidated( final boolean invalidated ) {
65
    this.invalidated = invalidated;
66
  }
67
68
  /** <p>Returns whether the current session is marked as invalidated..</p> */
69
  public boolean isInvalidated() {
70
    return this.invalidated;
71
  }
72
  
73
  /** <p>Sets the given <code>responseWriter</code> for the current request.
30
  /** <p>Sets the given <code>responseWriter</code> for the current request.
74
   * </p> */
31
   * </p> */
75
  public void setResponseWriter( final HtmlResponseWriter responseWriter ) {
32
  public void setResponseWriter( final HtmlResponseWriter responseWriter ) {
Lines 81-121 Link Here
81
    return responseWriter;
38
    return responseWriter;
82
  }
39
  }
83
  
40
  
84
  public void setDetectedBrowser( final Browser detectedBrowser ) {
85
    this.detectedBrowser = detectedBrowser;
86
  }
87
88
  public Browser getDetectedBrowser() {
89
    return detectedBrowser;
90
  }
91
  
92
  
93
  /** <p>Returns the event queue of this ServiceStateInfo.</p>
94
    * <p>The event queue for a request contains all WebDataEvents, i.e. 
95
    * events which are fired from a component when its value changes.</p>
96
    */
97
  public Object getEventQueue() {
98
    return eventQueue;
99
  }
100
  
101
  public void setEventQueue( final Object eventQueue ) {
102
    this.eventQueue = eventQueue;
103
  }
104
  
105
  public boolean isIgnoreStartup() {
106
    return ignoreStartup;
107
  }
108
109
  public void setIgnoreStartup( final boolean ignoreStartup ) {
110
    this.ignoreStartup = ignoreStartup;
111
  }
112
113
  public boolean isFirstAccess() {
114
    HttpServletRequest request = ContextProvider.getRequest();
115
    return    request.getSession( true ).isNew()
116
           || request.getParameter( RequestParams.STARTUP ) != null;
117
  }
118
119
  public Object getAttribute( final String key ) {
41
  public Object getAttribute( final String key ) {
120
    return attributes.get( key );
42
    return attributes.get( key );
121
  }
43
  }
(-)src/org/eclipse/rwt/internal/service/ServiceManager.java (-2 lines)
Lines 30-37 Link Here
30
/** <p>provides the appropriate HttpServlet request service handler for the
30
/** <p>provides the appropriate HttpServlet request service handler for the
31
 *  given runtime mode.</p> 
31
 *  given runtime mode.</p> 
32
 */
32
 */
33
// TODO [rh] Could implement resource/timestamp request handler as regular
34
//      IServiceHandler
35
// TODO [rh] access to customHandlers Map is unsynchronized and may cause
33
// TODO [rh] access to customHandlers Map is unsynchronized and may cause
36
//      trouble in case of unproper use
34
//      trouble in case of unproper use
37
public final class ServiceManager {
35
public final class ServiceManager {
(-)src/org/eclipse/rwt/internal/service/rwt-index.html (-2 / +1 lines)
Lines 61-68 Link Here
61
      
61
      
62
      function appendInitParameters() {
62
      function appendInitParameters() {
63
        var req = org.eclipse.swt.Request.getInstance();
63
        var req = org.eclipse.swt.Request.getInstance();
64
        req.addParameter( "w4t_scriptEnabled", "true" );
64
        req.addParameter( "rwt_initialize", "true" );
65
        req.addParameter( "w4t_ajaxEnabled", "true" );
66
        req.addParameter( "startup", "${startup}" );
65
        req.addParameter( "startup", "${startup}" );
67
        var size = discoverSize();
66
        var size = discoverSize();
68
        req.addParameter( "w4t_width", size.width );
67
        req.addParameter( "w4t_width", size.width );
(-)src/org/eclipse/rwt/internal/service/RWTStartupPageConfigurer.java (-12 / +12 lines)
Lines 31-37 Link Here
31
import org.eclipse.swt.internal.graphics.TextSizeDetermination;
31
import org.eclipse.swt.internal.graphics.TextSizeDetermination;
32
32
33
public final class RWTStartupPageConfigurer
33
public final class RWTStartupPageConfigurer
34
  implements BrowserSurvey.IStartupPageConfigurer
34
  implements StartupPage.IStartupPageConfigurer
35
{
35
{
36
36
37
  private static final String PACKAGE_NAME 
37
  private static final String PACKAGE_NAME 
Lines 44-60 Link Here
44
  private static int probeCount;
44
  private static int probeCount;
45
  private static long lastModified = System.currentTimeMillis();
45
  private static long lastModified = System.currentTimeMillis();
46
46
47
  private static TemplateHolder template;
47
  private static StartupPageTemplateHolder template;
48
  private static final List registeredBrandings = new ArrayList();
48
  private static final List registeredBrandings = new ArrayList();
49
  
49
  
50
  ////////////////////////////////////////////////////
50
  ////////////////////////////////////////////////////
51
  // ILifeCycleServiceHandlerConfigurer implementation 
51
  // ILifeCycleServiceHandlerConfigurer implementation 
52
  
52
  
53
  public TemplateHolder getTemplate() throws IOException {
53
  public StartupPageTemplateHolder getTemplate() throws IOException {
54
    readContent();
54
    readContent();
55
    template.reset();
55
    template.reset();
56
    template.replace( TemplateHolder.VAR_LIBRARIES, getLibraries() );
56
    template.replace( StartupPageTemplateHolder.VAR_LIBRARIES, getLibraries() );
57
    template.replace( TemplateHolder.VAR_APPSCRIPT, getAppScript() );
57
    template.replace( StartupPageTemplateHolder.VAR_APPSCRIPT, getAppScript() );
58
    applyBranding();
58
    applyBranding();
59
    return template;
59
    return template;
60
  }
60
  }
Lines 111-117 Link Here
111
          buffer.append( "\n" );
111
          buffer.append( "\n" );
112
          line = reader.readLine();
112
          line = reader.readLine();
113
        }
113
        }
114
        template = new TemplateHolder( buffer.toString() );
114
        template = new StartupPageTemplateHolder( buffer.toString() );
115
      } finally {
115
      } finally {
116
        reader.close();
116
        reader.close();
117
      }
117
      }
Lines 212-237 Link Here
212
      ThemeUtil.setCurrentThemeId( branding.getThemeId() );
212
      ThemeUtil.setCurrentThemeId( branding.getThemeId() );
213
    }
213
    }
214
    BrandingUtil.replacePlaceholder( template,
214
    BrandingUtil.replacePlaceholder( template,
215
                                     TemplateHolder.VAR_BODY,
215
                                     StartupPageTemplateHolder.VAR_BODY,
216
                                     branding.getBody() );
216
                                     branding.getBody() );
217
    BrandingUtil.replacePlaceholder( template,
217
    BrandingUtil.replacePlaceholder( template,
218
                                     TemplateHolder.VAR_TITLE,
218
                                     StartupPageTemplateHolder.VAR_TITLE,
219
                                     branding.getTitle() );
219
                                     branding.getTitle() );
220
    String headers = BrandingUtil.headerMarkup( branding );
220
    String headers = BrandingUtil.headerMarkup( branding );
221
    BrandingUtil.replacePlaceholder( template,
221
    BrandingUtil.replacePlaceholder( template,
222
                                     TemplateHolder.VAR_HEADERS,
222
                                     StartupPageTemplateHolder.VAR_HEADERS,
223
                                     headers );
223
                                     headers );
224
    String encodedEntryPoint = EntitiesUtil.encodeHTMLEntities( entryPoint );
224
    String encodedEntryPoint = EntitiesUtil.encodeHTMLEntities( entryPoint );
225
    BrandingUtil.replacePlaceholder( template,
225
    BrandingUtil.replacePlaceholder( template,
226
                                     TemplateHolder.VAR_STARTUP,
226
                                     StartupPageTemplateHolder.VAR_STARTUP,
227
                                     encodedEntryPoint );
227
                                     encodedEntryPoint );
228
    String script = BrandingUtil.exitMessageScript( branding );
228
    String script = BrandingUtil.exitMessageScript( branding );
229
    BrandingUtil.replacePlaceholder( template,
229
    BrandingUtil.replacePlaceholder( template,
230
                                     TemplateHolder.VAR_EXIT_CONFIRMATION,
230
                                     StartupPageTemplateHolder.VAR_EXIT_CONFIRMATION,
231
                                     script );
231
                                     script );
232
    String noScriptWarning = RWTMessages.getMessage( "RWT_NoScriptWarning" );
232
    String noScriptWarning = RWTMessages.getMessage( "RWT_NoScriptWarning" );
233
    BrandingUtil.replacePlaceholder( template, 
233
    BrandingUtil.replacePlaceholder( template, 
234
                                     TemplateHolder.VAR_NO_SCRIPT_MESSAGE, 
234
                                     StartupPageTemplateHolder.VAR_NO_SCRIPT_MESSAGE, 
235
                                     noScriptWarning );
235
                                     noScriptWarning );
236
  }
236
  }
237
237
(-)src/org/eclipse/rwt/internal/service/BrowserSurvey.java (-112 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal.service;
13
14
import java.io.IOException;
15
16
import javax.servlet.http.HttpServletRequest;
17
18
import org.eclipse.rwt.RWT;
19
import org.eclipse.rwt.branding.AbstractBranding;
20
import org.eclipse.rwt.internal.branding.BrandingUtil;
21
import org.eclipse.rwt.internal.lifecycle.EntryPointManager;
22
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
23
import org.eclipse.rwt.internal.theme.*;
24
import org.eclipse.rwt.internal.util.EntitiesUtil;
25
import org.eclipse.rwt.internal.util.HTML;
26
27
28
/** 
29
 * <p>A helping class that loads a special html page in order to
30
 * determine which browser has originated the request.</p>
31
 */
32
public final class BrowserSurvey {
33
34
  public interface IStartupPageConfigurer {
35
    TemplateHolder getTemplate() throws IOException;
36
    boolean isModifiedSince();
37
  }
38
  
39
  public static IStartupPageConfigurer configurer
40
    = new RWTStartupPageConfigurer();
41
42
  /** 
43
   * <p>Writes a special html page into the passed HtmlResponseWriter,
44
   * in order to  determine which browser has originated the request.</p> 
45
   */
46
  static void sendBrowserSurvey() throws IOException {
47
    if( configurer.isModifiedSince() ) {
48
      // send out the survey
49
      render();
50
    } else {
51
      AbstractBranding branding = BrandingUtil.findBranding();
52
      if( branding.getThemeId() != null ) {
53
        ThemeUtil.setCurrentThemeId( branding.getThemeId() );
54
      }
55
    }
56
  }
57
58
  private static String getBgImage() {
59
    String result = "";
60
    QxType cssValue = ThemeUtil.getCssValue( "Display", 
61
                                             "background-image", 
62
                                             SimpleSelector.DEFAULT );
63
    if( cssValue instanceof QxImage ) {
64
      QxImage image = ( QxImage )cssValue;
65
      // path is null if non-existing image was specified in css file
66
      String resourceName = image.getResourceName();
67
      if( resourceName != null ) {
68
        result = RWT.getResourceManager().getLocation( resourceName );
69
      }
70
    }
71
    return result;
72
  }
73
74
  public static String getSerlvetName() {
75
    String result = ContextProvider.getRequest().getServletPath();
76
    if( result.startsWith( "/" ) ) {
77
      result = result.substring( 1 );
78
    }
79
    return result;
80
  }
81
82
  private static void render() throws IOException {
83
    ContextProvider.getResponse().setContentType( HTML.CONTENT_TEXT_HTML );
84
    TemplateHolder template = configurer.getTemplate();
85
    template.replace( TemplateHolder.VAR_BACKGROUND_IMAGE, getBgImage() );
86
    // TODO [fappel]: check whether servletName has to be url encoded
87
    //                in case the client has switched of cookies
88
    template.replace( TemplateHolder.VAR_SERVLET, getSerlvetName() );
89
    template.replace( TemplateHolder.VAR_ENTRY_POINT,
90
                      EntitiesUtil.encodeHTMLEntities( getEntryPoint() ) );
91
    String[] tokens = template.getTokens();
92
    for( int i = 0; i < tokens.length; i++ ) {
93
      if( tokens[ i ] != null ) {
94
        getResponseWriter().append( tokens[ i ] );
95
      }
96
    }
97
  }
98
99
  private static String getEntryPoint() {
100
    HttpServletRequest request = ContextProvider.getRequest();
101
    String result = request.getParameter( RequestParams.STARTUP );
102
    if( result == null ) {
103
      result = EntryPointManager.DEFAULT;
104
    }
105
    return result;
106
  }
107
108
  private static HtmlResponseWriter getResponseWriter() {
109
    IServiceStateInfo stateInfo = ContextProvider.getStateInfo();
110
    return stateInfo.getResponseWriter();
111
  }
112
}
(-)src/org/eclipse/rwt/internal/service/IServiceAdapter.java (-20 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
13
import java.io.IOException;
14
import javax.servlet.ServletException;
15
16
public interface IServiceAdapter {
17
18
  void execute() throws ServletException, IOException;
19
  
20
}
(-)src/org/eclipse/rwt/internal/service/ContextProvider.java (-6 lines)
Lines 18-24 Link Here
18
import org.eclipse.rwt.SessionSingletonBase;
18
import org.eclipse.rwt.SessionSingletonBase;
19
import org.eclipse.rwt.internal.ConfigurationReader;
19
import org.eclipse.rwt.internal.ConfigurationReader;
20
import org.eclipse.rwt.internal.IEngineConfig;
20
import org.eclipse.rwt.internal.IEngineConfig;
21
import org.eclipse.rwt.internal.browser.Browser;
22
import org.eclipse.rwt.internal.util.ParamCheck;
21
import org.eclipse.rwt.internal.util.ParamCheck;
23
import org.eclipse.rwt.service.ISessionStore;
22
import org.eclipse.rwt.service.ISessionStore;
24
23
Lines 110-120 Link Here
110
    return result;
109
    return result;
111
  }
110
  }
112
  
111
  
113
  public static Browser getBrowser() {
114
    String id = ServiceContext.DETECTED_SESSION_BROWSER;
115
    return ( Browser )getSession().getAttribute( id );
116
  }
117
118
  public static String getWebAppBase() {
112
  public static String getWebAppBase() {
119
    IEngineConfig engineConfig = ConfigurationReader.getEngineConfig();
113
    IEngineConfig engineConfig = ConfigurationReader.getEngineConfig();
120
    return engineConfig.getServerContextDir().toString();
114
    return engineConfig.getServerContextDir().toString();
(-)src/org/eclipse/rwt/internal/service/TemplateHolder.java (-165 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal.service;
13
14
import java.util.*;
15
16
import org.eclipse.rwt.internal.util.ParamCheck;
17
18
19
public final class TemplateHolder {
20
  
21
  private static final int[] EMPTY_INDICES = new int[ 0 ];
22
  private final static String TOKEN_BACKGROUND_IMAGE = "backgroundImage";
23
  private final static String TOKEN_LIBRARIES = "libraries";
24
  private final static String TOKEN_APPSCRIPT = "appScript";
25
  private final static String TOKEN_SERVLET = "servlet";
26
  private final static String TOKEN_ENTRY_POINT = "entrypoint";
27
  private final static String TOKEN_BODY = "body";
28
  private final static String TOKEN_TITLE = "title";
29
  private final static String TOKEN_HEADERS = "headers";
30
  private final static String TOKEN_STARTUP = "startup";
31
  private final static String TOKEN_EXIT_CONFIRMATION = "exitConfirmation";
32
  private final static String TOKEN_NO_SCRIPT_MESSAGE = "noScriptMessage";
33
34
  public final static Variable VAR_BACKGROUND_IMAGE
35
    = new Variable( TOKEN_BACKGROUND_IMAGE );
36
  public final static Variable VAR_LIBRARIES
37
    = new Variable( TOKEN_LIBRARIES );
38
  public final static Variable VAR_APPSCRIPT
39
    = new Variable( TOKEN_APPSCRIPT );
40
  public final static Variable VAR_SERVLET
41
    = new Variable( TOKEN_SERVLET );
42
  public final static Variable VAR_ENTRY_POINT
43
    = new Variable( TOKEN_ENTRY_POINT );
44
  public final static Variable VAR_BODY
45
    = new Variable( TOKEN_BODY );
46
  public final static Variable VAR_TITLE
47
    = new Variable( TOKEN_TITLE );
48
  public final static Variable VAR_HEADERS
49
    = new Variable( TOKEN_HEADERS );
50
  public final static Variable VAR_STARTUP
51
    = new Variable( TOKEN_STARTUP );
52
  public final static Variable VAR_EXIT_CONFIRMATION
53
    = new Variable( TOKEN_EXIT_CONFIRMATION );
54
  public final static Variable VAR_NO_SCRIPT_MESSAGE
55
    = new Variable( TOKEN_NO_SCRIPT_MESSAGE );
56
57
58
  public static final class Variable {
59
    
60
    private final static Map NAMES = new HashMap();
61
    private final String name;
62
63
    private Variable( final String varName ) {
64
      this.name = varName;
65
      NAMES.put( varName, this );
66
    }
67
68
    private static Variable lookup( final String name ) {
69
      return ( Variable )NAMES.get( name );
70
    }
71
72
    public String toString() {
73
      return "${" + name + "}";
74
    }
75
  }
76
77
78
  private final String[] tokens;
79
  private final Map replacementIndices;
80
81
82
  public TemplateHolder( final String template ) {
83
    ParamCheck.notNull( template, "template" );
84
    replacementIndices = new HashMap();
85
    StringTokenizer tokenizer = new StringTokenizer( template, "${}", true );
86
    int countTokens = tokenizer.countTokens();
87
    tokens = new String[ countTokens ];
88
    boolean ignoreNextToken = false;
89
    for( int i = 0; i < tokens.length; i++ ) {
90
      String nextToken = tokenizer.nextToken();
91
      if( ignoreNextToken ) {
92
        ignoreNextToken = false;
93
      } else if( !isVariableToken( nextToken ) ) {
94
        tokens[ i ] = nextToken;
95
      } else {
96
        Variable variable = Variable.lookup( nextToken );
97
        addReplacementIndex( variable, i );
98
        tokens[ i - 1 ] = "";
99
        tokens[ i - 2 ] = "";
100
        tokens[ i + 1 ] = "";
101
        ignoreNextToken = true;
102
      }
103
    }
104
  }
105
106
  private boolean isVariableToken( final String nextToken ) {
107
    return    nextToken.equals( TOKEN_BACKGROUND_IMAGE.toString() )
108
           || nextToken.equals( TOKEN_LIBRARIES.toString() )
109
           || nextToken.equals( TOKEN_APPSCRIPT.toString() )
110
           || nextToken.equals( TOKEN_SERVLET.toString() )
111
           || nextToken.equals( TOKEN_ENTRY_POINT.toString() )
112
           || nextToken.equals( TOKEN_BODY.toString() )
113
           || nextToken.equals( TOKEN_TITLE.toString() )
114
           || nextToken.equals( TOKEN_HEADERS.toString() )
115
           || nextToken.equals( TOKEN_STARTUP.toString() )
116
           || nextToken.equals( TOKEN_EXIT_CONFIRMATION.toString() )
117
           || nextToken.equals( TOKEN_NO_SCRIPT_MESSAGE.toString() );
118
  }
119
120
  private void addReplacementIndex( final Variable variable, final int index ) {
121
    List indices = ( List )replacementIndices.get( variable );
122
    if( indices == null ) {
123
      indices = new ArrayList();
124
      replacementIndices.put( variable, indices );
125
    }
126
    indices.add( new Integer( index ) );
127
  }
128
129
  private int[] getReplacementIndices( final Variable variable ) {
130
    List indices = ( List )replacementIndices.get( variable );
131
    int[] result = null;
132
    if( indices == null ) {
133
      result = EMPTY_INDICES;
134
    } else {
135
      Object[] buffer = indices.toArray();
136
      result = new int[ buffer.length ];
137
      for( int i = 0; i < result.length; i++ ) {
138
        result[ i ] = ( ( Integer )buffer[ i ] ).intValue();
139
      }
140
    }
141
    return result;
142
  }
143
  public String[] getTokens() {
144
    // no secure copy due to performance reasons...
145
    return tokens;
146
  }
147
148
  public void replace( final Variable toReplace, final String replacement ) {
149
    int[] indices = getReplacementIndices( toReplace );
150
    for( int i = 0; i < indices.length; i++ ) {
151
      tokens[ indices[ i ] ] = replacement;
152
    }
153
  }
154
155
  public void reset() {
156
    Iterator iterator = Variable.NAMES.values().iterator();
157
    while( iterator.hasNext() ) {
158
      Variable variable = ( Variable )iterator.next();
159
      int[] indices = getReplacementIndices( variable );
160
      for( int i = 0; i < indices.length; i++ ) {
161
        tokens[ indices[ i ] ] = null;
162
      }
163
    }
164
  }
165
}
(-)src/org/eclipse/rwt/internal/service/ServiceContext.java (-7 lines)
Lines 26-38 Link Here
26
 */
26
 */
27
public final class ServiceContext {
27
public final class ServiceContext {
28
  
28
  
29
  /** 
30
   * The key which is used to store the {@link org.eclipse.rwt.internal.browser.Browser} instance
31
   * of the current session. 
32
   */
33
  public final static String DETECTED_SESSION_BROWSER 
34
    = "com_w4t_detected_session_browser";
35
  
36
  private HttpServletRequest request;
29
  private HttpServletRequest request;
37
  private HttpServletResponse response;
30
  private HttpServletResponse response;
38
  private IServiceStateInfo stateInfo;
31
  private IServiceStateInfo stateInfo;
(-)src/org/eclipse/rwt/service/IServiceStore.java (-1 lines)
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
10
 ******************************************************************************/
11
12
package org.eclipse.rwt.service;
11
package org.eclipse.rwt.service;
13
12
14
13
(-)src/browserdetection.xml (-27 lines)
Removed Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<browserdef>
3
  <browser>
4
    <name>Safari</name>
5
    <classname>org.eclipse.rwt.internal.browser.DetectorSafari</classname>
6
  </browser>
7
  
8
  <browser>
9
    <name>Konqueror</name>
10
    <classname>org.eclipse.rwt.internal.browser.DetectorKonqueror</classname>
11
  </browser>
12
  
13
  <browser>
14
    <name>Opera</name>
15
    <classname>org.eclipse.rwt.internal.browser.DetectorOpera</classname>
16
  </browser>
17
  
18
  <browser>
19
    <name>Internet Explorer</name>
20
    <classname>org.eclipse.rwt.internal.browser.DetectorIE</classname>
21
  </browser>
22
  
23
  <browser>
24
    <name>Mozilla</name>
25
    <classname>org.eclipse.rwt.internal.browser.DetectorMozilla</classname>
26
  </browser>
27
</browserdef>
(-)META-INF/MANIFEST.MF (-5 lines)
Lines 26-36 Link Here
26
   org.eclipse.rap.rwt.test,
26
   org.eclipse.rap.rwt.test,
27
   org.eclipse.rap.ui.workbench",
27
   org.eclipse.rap.ui.workbench",
28
 org.eclipse.rwt.internal.branding;x-friends:="org.eclipse.rap.rwt.test,org.eclipse.rap.ui.workbench",
28
 org.eclipse.rwt.internal.branding;x-friends:="org.eclipse.rap.rwt.test,org.eclipse.rap.ui.workbench",
29
 org.eclipse.rwt.internal.browser;
30
  x-friends:="org.eclipse.rap.w4t,
31
   org.eclipse.rap.w4t.test,
32
   org.eclipse.rap.rwt.test,
33
   org.eclipse.rap.ui.workbench",
34
 org.eclipse.rwt.internal.engine;
29
 org.eclipse.rwt.internal.engine;
35
  x-friends:="org.eclipse.rap.w4t,
30
  x-friends:="org.eclipse.rap.w4t,
36
   org.eclipse.rap.w4t.test,
31
   org.eclipse.rap.w4t.test,
(-)src/org/eclipse/rwt/internal/branding/BrandingUtil.java (-3 / +4 lines)
Lines 17-22 Link Here
17
import org.eclipse.rwt.branding.Header;
17
import org.eclipse.rwt.branding.Header;
18
import org.eclipse.rwt.internal.lifecycle.CommonPatterns;
18
import org.eclipse.rwt.internal.lifecycle.CommonPatterns;
19
import org.eclipse.rwt.internal.service.*;
19
import org.eclipse.rwt.internal.service.*;
20
import org.eclipse.rwt.internal.util.URLHelper;
20
21
21
22
22
public final class BrandingUtil {
23
public final class BrandingUtil {
Lines 24-31 Link Here
24
  private static final String ATTR_BRANDING_ID 
25
  private static final String ATTR_BRANDING_ID 
25
    = BrandingUtil.class.getName() + "#brandingId";
26
    = BrandingUtil.class.getName() + "#brandingId";
26
27
27
  public static void replacePlaceholder( final TemplateHolder template, 
28
  public static void replacePlaceholder( final StartupPageTemplateHolder template, 
28
                                         final TemplateHolder.Variable variable, 
29
                                         final StartupPageTemplateHolder.Variable variable, 
29
                                         final String replacement ) 
30
                                         final String replacement ) 
30
  {
31
  {
31
    String safeReplacement = replacement == null ? "" : replacement;
32
    String safeReplacement = replacement == null ? "" : replacement;
Lines 60-66 Link Here
60
61
61
  public static AbstractBranding findBranding() {
62
  public static AbstractBranding findBranding() {
62
    HttpServletRequest request = ContextProvider.getRequest();
63
    HttpServletRequest request = ContextProvider.getRequest();
63
    String servletName = BrowserSurvey.getSerlvetName();
64
    String servletName = URLHelper.getSerlvetName();
64
    String entryPoint = request.getParameter( RequestParams.STARTUP );
65
    String entryPoint = request.getParameter( RequestParams.STARTUP );
65
    AbstractBranding branding = BrandingManager.get( servletName, entryPoint );
66
    AbstractBranding branding = BrandingManager.get( servletName, entryPoint );
66
    RWT.getSessionStore().setAttribute( ATTR_BRANDING_ID, branding.getId() );
67
    RWT.getSessionStore().setAttribute( ATTR_BRANDING_ID, branding.getId() );
(-)src/org/eclipse/rwt/internal/lifecycle/HtmlResponseWriter.java (-272 / +4 lines)
Lines 45-100 Link Here
45
  public static final String CLASS_PREFIX = "w4tCss";
45
  public static final String CLASS_PREFIX = "w4tCss";
46
46
47
47
48
  private List head   = new ArrayList();
48
  private List body = new ArrayList();
49
  private List body   = new ArrayList();
50
  private List layers = new ArrayList();
51
  private List foot   = new ArrayList();
52
  
49
  
53
  private String elementStarted;
50
  private String elementStarted;
54
  private boolean closed;
51
  private boolean closed;
55
  private boolean avoidEscape;
52
  private boolean avoidEscape;
56
53
57
54
58
  /** contains css classes that have been collected from style settings on 
59
    * components. Every style content (keys) gets assigned a generated
60
    * class name (elements).
61
    * 
62
    * It is assured that for every content there is exactly one class name, 
63
    * and the latter is used when the style declaration
64
    */
65
  private Hashtable registeredCssClasses = new Hashtable();
66
  /** contains css classes that have been set and named programmatically,
67
    * that is which have been set with class name and content (keys).
68
    * The elements are ArrayLists with all the class names assigned to 
69
    * the content that is the key.
70
    * 
71
    * This means that, as opposed to managedCssClasses, there can be more than
72
    * one class name for the same content. In this case a content gets a name
73
    * of the form ".someName, .someOtherName"
74
    */
75
  private Hashtable namedCssClasses = new Hashtable();
76
  /** contains the names of the javascript libraries that are needed for
55
  /** contains the names of the javascript libraries that are needed for
77
    * the content which was rendered into this HtmlResponseWriter. */
56
    * the content which was rendered into this HtmlResponseWriter. */
78
  private List jsLibraries = new ArrayList();
57
  private List jsLibraries = new ArrayList();
79
  
58
  
80
  
59
  
81
  /**
82
   * <p>Append a token to the token list of the header's token</p>
83
   * <p>This method is not inteded to be used by clients.</p>
84
   */
85
  public void appendHead( final StringBuffer token ) {
86
    head.add( token.toString() );
87
  }
88
  
89
  /** 
90
   * <p>Append the given <code>token</code> to the token list of the header's 
91
   * token</p>
92
   * <p>This method is not inteded to be used by clients.</p>
93
   */
94
  public void appendHead( final String token ) {
95
    head.add( token );
96
  }
97
98
  /** 
60
  /** 
99
   * <p>Append a token to the token list of the body's token</p>
61
   * <p>Append a token to the token list of the body's token</p>
100
   * <p>This method is not inteded to be used by clients.</p>
62
   * <p>This method is not inteded to be used by clients.</p>
Lines 114-171 Link Here
114
    }
76
    }
115
  }
77
  }
116
78
117
  /** 
118
   * <p>Append a token to the list of footer tokens</p>
119
   * <p>This method is not inteded to be used by clients.</p>
120
   */
121
  public void appendFoot( final StringBuffer token ) {
122
    foot.add( token.toString() );
123
  }
124
125
  /** 
126
   * <p>Append the given <code>token</code> to the list of footer tokens.</p> 
127
   * <p>This method is not inteded to be used by clients.</p>
128
   */
129
  public void appendFoot( final String token ) {
130
    foot.add( token );
131
  }
132
133
  /** 
134
   * <p>Append a token to the list of layer tokens</p>
135
   * <p>This method is not inteded to be used by clients.</p>
136
   */
137
  public void appendLayer( final StringBuffer token ) {
138
    appendLayer( token.toString() );
139
  }
140
  
141
  /**
142
   * <p>Append a token to the list of layer tokens</p> 
143
   * <p>This method is not inteded to be used by clients.</p>
144
   */  
145
  public void appendLayer( final String token ) {
146
    layers.add( token );
147
  }
148
 
149
  /** <p>Concatenates this HtmlResponseWriter's layers to its body token list.
150
   * </p>
151
   * <p>This method is not inteded to be used by clients.</p>
152
   */
153
  public void concatLayers() {
154
    for( int i = 0; i < layers.size(); i++ ) {
155
      append( layers.get( i ).toString() );
156
    }
157
    layers.clear();
158
  }
159
  
160
  /**
161
   * <p>Removes all of the tokens from the head list. The head list will be
162
   * empty after this call returns.</p>
163
   * <p>This method is not inteded to be used by clients.</p>
164
   */
165
  public void clearHead() {
166
    head.clear();
167
  }
168
169
  /**
79
  /**
170
   * <p>Removes all of the tokens from the body list. The body list will be
80
   * <p>Removes all of the tokens from the body list. The body list will be
171
   * empty after this call returns</p>
81
   * empty after this call returns</p>
Lines 175-197 Link Here
175
    body.clear();
85
    body.clear();
176
  }
86
  }
177
87
178
  /**
179
   * </p>Removes all of the tokens from the foot list. The foot list will be
180
   * empty after this call returns.</p>
181
   * <p>This method is not inteded to be used by clients.</p>
182
   */
183
  public void clearFoot() {
184
    foot.clear();
185
  }
186
187
  /**
188
   * <p>Returns the number of tokens in the head list.</p>
189
   * <p>This method is not inteded to be used by clients.</p>
190
   */
191
  public int getHeadSize() {
192
    return head.size();
193
  }
194
195
 /**
88
 /**
196
   * <p>Returns the number of tokens in the body list.</p>
89
   * <p>Returns the number of tokens in the body list.</p>
197
   * <p>This method is not inteded to be used by clients.</p>
90
   * <p>This method is not inteded to be used by clients.</p>
Lines 200-221 Link Here
200
    return body.size();
93
    return body.size();
201
  }
94
  }
202
95
203
 /**
204
   * <p>Returns the number of tokens in the foot list.</p>
205
   * <p>This method is not inteded to be used by clients.</p>
206
   */
207
  public int getFootSize() {
208
    return foot.size();
209
  }
210
211
  /**
212
   * <p>Returns the token at the specified position in the head list.</p>
213
   * <p>This method is not inteded to be used by clients.</p>
214
   */
215
  public String getHeadToken( final int index ) {
216
    return head.get( index ).toString();
217
  }
218
219
  /**
96
  /**
220
   * <p>Returns the token at the specified position in the body list.</p>
97
   * <p>Returns the token at the specified position in the body list.</p>
221
   * <p>This method is not inteded to be used by clients.</p>
98
   * <p>This method is not inteded to be used by clients.</p>
Lines 232-268 Link Here
232
    return body.iterator();
109
    return body.iterator();
233
  }
110
  }
234
111
235
  /**
236
   * <p>Returns the token at the specified position in the foot list.</p>
237
   * <p>This method is not inteded to be used by clients.</p>
238
   */
239
  public String getFootToken( final int index ) {
240
    return foot.get( index ).toString();
241
  }
242
243
  /**
244
   * <p>Equalizes the head, body and foot list of this HtmlResponseWriter with
245
   * the lists of the parameter HtmlResponseWriter.</p>
246
   * <p>This method is not inteded to be used by clients.</p>
247
   */
248
  public void equalize( final HtmlResponseWriter tokenBuffer ) {
249
    this.foot.clear();
250
    this.body.clear();
251
    this.layers.clear();
252
    this.head.clear();
253
    this.jsLibraries.clear();
254
    this.foot   = tokenBuffer.foot;
255
    this.body   = tokenBuffer.body;
256
    this.layers = tokenBuffer.layers;
257
    this.head   = tokenBuffer.head;
258
    this.jsLibraries = tokenBuffer.jsLibraries;
259
    this.registeredCssClasses = tokenBuffer.registeredCssClasses;
260
    this.namedCssClasses = tokenBuffer.namedCssClasses;
261
  }
262
  
263
  
264
  // control methods for javascript library rendering
265
  ///////////////////////////////////////////////////
112
  ///////////////////////////////////////////////////
113
  // control methods for javascript library rendering
266
114
267
  /** <p>Returns the names of the JavaScript libraries that the components
115
  /** <p>Returns the names of the JavaScript libraries that the components
268
    * which were rendered into this HtmlResponseWriter need.</p> */
116
    * which were rendered into this HtmlResponseWriter need.</p> */
Lines 316-421 Link Here
316
  }
164
  }
317
165
318
166
319
  /** <p>Returns a unique identifier for a css class that is contained in this
320
    * HtmlResponseWriter's cache and contains exactly the settings in the passed
321
    * <code>style</code>.</p>
322
    * 
323
    * <p>If no entry for the passed content is contained yet, a name will be
324
    * generated.</p>
325
    * 
326
    * <p>Any renderer that calls this method can be sure that the css class 
327
    * named by the return value of this method is available in the HTML
328
    * document (the corresponding style tag will be rendered into the head
329
    * section of the HTML document).</p>
330
    */ 
331
  public String registerCssClass( final String style ) {
332
    String result = "";
333
    if( registeredCssClasses.containsKey( style ) ) {
334
      result = ( String )registeredCssClasses.get( style );
335
    } else {
336
      result = createClassName( style );
337
      registeredCssClasses.put( style, result );
338
    }
339
    return result;
340
  }
341
342
  /** <p>Adds the passed css class to the classes that are declared on top 
343
    * of the page.</p> */  
344
  public void addNamedCssClass( final CssClass cssClass ) {
345
    Assert.isNotNull( cssClass );
346
    
347
    String content = cssClass.getContent();
348
    List allNames;    
349
    if( namedCssClasses.containsKey( content ) ) {
350
      allNames = ( List )namedCssClasses.get( content );
351
    } else {
352
      allNames = new ArrayList();
353
      namedCssClasses.put( content, allNames );
354
    }
355
    if( !allNames.contains( cssClass.getClassName() ) ) {
356
      allNames.add( cssClass.getClassName() );
357
    }
358
  }
359
360
  /** <p>Adds the passed css classes to the classes that are declared on top 
361
    * of the page; they will be regarded as if they had been registered with
362
    * {@link #registerCssClass( String ) registerCssClass()}.</p> */
363
  public void mergeRegisteredCssClasses( final CssClass[] classes ) {
364
    for( int i = 0; i < classes.length; i++ ) {
365
      Assert.isNotNull( classes[ i ] );
366
      registeredCssClasses.put( classes[ i ].getContent(), 
367
                                classes[ i ].getClassName() );
368
    }
369
  }
370
371
  /** <p>Returns the css classes that have been used for rendering 
372
    * into this HtmlResponseWriter, this includes the classes managed by the
373
    * library and the named classes set by the user.</p> */
374
  public CssClass[] getCssClasses() {
375
    ArrayList alResult = new ArrayList();
376
    Enumeration keys = registeredCssClasses.keys();
377
    while( keys.hasMoreElements() ) {
378
      String content = ( String )keys.nextElement(); 
379
      String className = ( String )registeredCssClasses.get( content );
380
      if( !className.startsWith( "." ) ) {
381
        className = "." + className;
382
      }
383
      alResult.add( new CssClass( className, content ) ); 
384
    }
385
    keys = namedCssClasses.keys();
386
    while( keys.hasMoreElements() ) {
387
      String content = ( String )keys.nextElement();
388
      ArrayList alNames = ( ArrayList )namedCssClasses.get( content );
389
      String className = getCompoundName( alNames );
390
      alResult.add( new CssClass( className, content ) );
391
    } 
392
    CssClass[] result = new CssClass[ alResult.size() ];
393
    alResult.toArray( result );
394
    return result;
395
  }
396
  
397
  /**
398
   * <p>Returns the number of css classes that were registered via calls to 
399
   * <code>addNamedCssClass(CssClass)</code> or 
400
   * <code>registerCssClass(String)</code></p>
401
   */
402
  public int getCssClassCount() {
403
    return registeredCssClasses.size() + namedCssClasses.size();
404
  }
405
  
406
  /**
407
   * <p>Removes the css class which contains the given <code>content</code>
408
   * from list of registered css classes.</p>
409
   * <p>Does nothing if there is no css class with the given
410
   * <code>content</code>.</p>
411
   * @param content the content of the css class to be removed.
412
   */
413
  public void removeCssClass( final String content ) {
414
    registeredCssClasses.remove( content );
415
    // Note: do not remove namedCssClasses, since then different styles for the
416
    //       same css classname cannot be dynamically switched in AJAX-mode
417
  }
418
  
419
  //////////////////
167
  //////////////////
420
  // response writer
168
  // response writer
421
  
169
  
Lines 634-641 Link Here
634
   */
382
   */
635
  // TODO [rh] We could check whether 'elementStarted' is null, since comments 
383
  // TODO [rh] We could check whether 'elementStarted' is null, since comments 
636
  //      are not allowed inside element tags in XHTML 'mode'
384
  //      are not allowed inside element tags in XHTML 'mode'
637
  // TODO [rh] calling this method 'inside' an AJaX envelope leads to invalid
638
  //      XML
639
  public void writeComment( final Object comment ) throws IOException {
385
  public void writeComment( final Object comment ) throws IOException {
640
    checkIfWriterClosed();
386
    checkIfWriterClosed();
641
    ParamCheck.notNull( comment, "comment" ); 
387
    ParamCheck.notNull( comment, "comment" ); 
Lines 705-728 Link Here
705
  // helping methods
451
  // helping methods
706
  //////////////////
452
  //////////////////
707
453
708
  private static String getCompoundName( final List allNames ) {
454
  private void checkIfWriterClosed() {
709
    Assert.isTrue( allNames.size() > 0 );
710
    String result = "." + ( String )allNames.get( 0 );
711
    for( int i = 1; i < allNames.size(); i++ ) {
712
      result += ", ." + ( String )allNames.get( i );
713
    }
714
    return result;
715
  }
716
  
717
  private static String createClassName( final String key ) {
718
    return CLASS_PREFIX + Integer.toHexString( key.hashCode() );
719
  }
720
  
721
  private void checkIfWriterClosed() throws IOException {
722
    // TODO [rh] replace by IllegalStateException?
723
    if( closed ) {
455
    if( closed ) {
724
      String msg = "Operation is not allowed since the writer was closed.";
456
      String msg = "Operation is not allowed since the writer was closed.";
725
      throw new IOException( msg );
457
      throw new IllegalStateException( msg );
726
    }
458
    }
727
  }
459
  }
728
}
460
}
(-)src/org/eclipse/rwt/internal/service/StartupPage.java (+101 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal.service;
13
14
import java.io.IOException;
15
16
import javax.servlet.http.HttpServletRequest;
17
18
import org.eclipse.rwt.RWT;
19
import org.eclipse.rwt.branding.AbstractBranding;
20
import org.eclipse.rwt.internal.branding.BrandingUtil;
21
import org.eclipse.rwt.internal.lifecycle.EntryPointManager;
22
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
23
import org.eclipse.rwt.internal.theme.*;
24
import org.eclipse.rwt.internal.util.*;
25
26
27
/**
28
 * <p>A helping class that loads a special html page in order to
29
 * bootstrap the client-side session.</p>
30
 */
31
public final class StartupPage {
32
33
  public interface IStartupPageConfigurer {
34
    StartupPageTemplateHolder getTemplate() throws IOException;
35
    boolean isModifiedSince();
36
  }
37
38
  public static IStartupPageConfigurer configurer
39
    = new RWTStartupPageConfigurer();
40
41
  static void send() throws IOException {
42
    if( configurer.isModifiedSince() ) {
43
      // send out the survey
44
      render();
45
    } else {
46
      AbstractBranding branding = BrandingUtil.findBranding();
47
      if( branding.getThemeId() != null ) {
48
        ThemeUtil.setCurrentThemeId( branding.getThemeId() );
49
      }
50
    }
51
  }
52
53
  private static String getBgImage() {
54
    String result = "";
55
    QxType cssValue = ThemeUtil.getCssValue( "Display",
56
                                             "background-image",
57
                                             SimpleSelector.DEFAULT );
58
    if( cssValue instanceof QxImage ) {
59
      QxImage image = ( QxImage )cssValue;
60
      // path is null if non-existing image was specified in css file
61
      String resourceName = image.getResourceName();
62
      if( resourceName != null ) {
63
        result = RWT.getResourceManager().getLocation( resourceName );
64
      }
65
    }
66
    return result;
67
  }
68
69
  private static void render() throws IOException {
70
    ContextProvider.getResponse().setContentType( HTML.CONTENT_TEXT_HTML );
71
    StartupPageTemplateHolder template = configurer.getTemplate();
72
    template.replace( StartupPageTemplateHolder.VAR_BACKGROUND_IMAGE, 
73
                      getBgImage() );
74
    // TODO [fappel]: check whether servletName has to be url encoded
75
    //                in case the client has switched of cookies
76
    template.replace( StartupPageTemplateHolder.VAR_SERVLET, 
77
                      URLHelper.getSerlvetName() );
78
    template.replace( StartupPageTemplateHolder.VAR_ENTRY_POINT,
79
                      EntitiesUtil.encodeHTMLEntities( getEntryPoint() ) );
80
    String[] tokens = template.getTokens();
81
    for( int i = 0; i < tokens.length; i++ ) {
82
      if( tokens[ i ] != null ) {
83
        getResponseWriter().append( tokens[ i ] );
84
      }
85
    }
86
  }
87
88
  private static String getEntryPoint() {
89
    HttpServletRequest request = ContextProvider.getRequest();
90
    String result = request.getParameter( RequestParams.STARTUP );
91
    if( result == null ) {
92
      result = EntryPointManager.DEFAULT;
93
    }
94
    return result;
95
  }
96
97
  private static HtmlResponseWriter getResponseWriter() {
98
    IServiceStateInfo stateInfo = ContextProvider.getStateInfo();
99
    return stateInfo.getResponseWriter();
100
  }
101
}
(-)src/org/eclipse/rwt/internal/service/StartupPageTemplateHolder.java (+165 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal.service;
13
14
import java.util.*;
15
16
import org.eclipse.rwt.internal.util.ParamCheck;
17
18
19
public final class StartupPageTemplateHolder {
20
  
21
  private static final int[] EMPTY_INDICES = new int[ 0 ];
22
  private final static String TOKEN_BACKGROUND_IMAGE = "backgroundImage";
23
  private final static String TOKEN_LIBRARIES = "libraries";
24
  private final static String TOKEN_APPSCRIPT = "appScript";
25
  private final static String TOKEN_SERVLET = "servlet";
26
  private final static String TOKEN_ENTRY_POINT = "entrypoint";
27
  private final static String TOKEN_BODY = "body";
28
  private final static String TOKEN_TITLE = "title";
29
  private final static String TOKEN_HEADERS = "headers";
30
  private final static String TOKEN_STARTUP = "startup";
31
  private final static String TOKEN_EXIT_CONFIRMATION = "exitConfirmation";
32
  private final static String TOKEN_NO_SCRIPT_MESSAGE = "noScriptMessage";
33
34
  public final static Variable VAR_BACKGROUND_IMAGE
35
    = new Variable( TOKEN_BACKGROUND_IMAGE );
36
  public final static Variable VAR_LIBRARIES
37
    = new Variable( TOKEN_LIBRARIES );
38
  public final static Variable VAR_APPSCRIPT
39
    = new Variable( TOKEN_APPSCRIPT );
40
  public final static Variable VAR_SERVLET
41
    = new Variable( TOKEN_SERVLET );
42
  public final static Variable VAR_ENTRY_POINT
43
    = new Variable( TOKEN_ENTRY_POINT );
44
  public final static Variable VAR_BODY
45
    = new Variable( TOKEN_BODY );
46
  public final static Variable VAR_TITLE
47
    = new Variable( TOKEN_TITLE );
48
  public final static Variable VAR_HEADERS
49
    = new Variable( TOKEN_HEADERS );
50
  public final static Variable VAR_STARTUP
51
    = new Variable( TOKEN_STARTUP );
52
  public final static Variable VAR_EXIT_CONFIRMATION
53
    = new Variable( TOKEN_EXIT_CONFIRMATION );
54
  public final static Variable VAR_NO_SCRIPT_MESSAGE
55
    = new Variable( TOKEN_NO_SCRIPT_MESSAGE );
56
57
58
  public static final class Variable {
59
    
60
    private final static Map NAMES = new HashMap();
61
    private final String name;
62
63
    private Variable( final String varName ) {
64
      this.name = varName;
65
      NAMES.put( varName, this );
66
    }
67
68
    private static Variable lookup( final String name ) {
69
      return ( Variable )NAMES.get( name );
70
    }
71
72
    public String toString() {
73
      return "${" + name + "}";
74
    }
75
  }
76
77
78
  private final String[] tokens;
79
  private final Map replacementIndices;
80
81
82
  public StartupPageTemplateHolder( final String template ) {
83
    ParamCheck.notNull( template, "template" );
84
    replacementIndices = new HashMap();
85
    StringTokenizer tokenizer = new StringTokenizer( template, "${}", true );
86
    int countTokens = tokenizer.countTokens();
87
    tokens = new String[ countTokens ];
88
    boolean ignoreNextToken = false;
89
    for( int i = 0; i < tokens.length; i++ ) {
90
      String nextToken = tokenizer.nextToken();
91
      if( ignoreNextToken ) {
92
        ignoreNextToken = false;
93
      } else if( !isVariableToken( nextToken ) ) {
94
        tokens[ i ] = nextToken;
95
      } else {
96
        Variable variable = Variable.lookup( nextToken );
97
        addReplacementIndex( variable, i );
98
        tokens[ i - 1 ] = "";
99
        tokens[ i - 2 ] = "";
100
        tokens[ i + 1 ] = "";
101
        ignoreNextToken = true;
102
      }
103
    }
104
  }
105
106
  private boolean isVariableToken( final String nextToken ) {
107
    return    nextToken.equals( TOKEN_BACKGROUND_IMAGE.toString() )
108
           || nextToken.equals( TOKEN_LIBRARIES.toString() )
109
           || nextToken.equals( TOKEN_APPSCRIPT.toString() )
110
           || nextToken.equals( TOKEN_SERVLET.toString() )
111
           || nextToken.equals( TOKEN_ENTRY_POINT.toString() )
112
           || nextToken.equals( TOKEN_BODY.toString() )
113
           || nextToken.equals( TOKEN_TITLE.toString() )
114
           || nextToken.equals( TOKEN_HEADERS.toString() )
115
           || nextToken.equals( TOKEN_STARTUP.toString() )
116
           || nextToken.equals( TOKEN_EXIT_CONFIRMATION.toString() )
117
           || nextToken.equals( TOKEN_NO_SCRIPT_MESSAGE.toString() );
118
  }
119
120
  private void addReplacementIndex( final Variable variable, final int index ) {
121
    List indices = ( List )replacementIndices.get( variable );
122
    if( indices == null ) {
123
      indices = new ArrayList();
124
      replacementIndices.put( variable, indices );
125
    }
126
    indices.add( new Integer( index ) );
127
  }
128
129
  private int[] getReplacementIndices( final Variable variable ) {
130
    List indices = ( List )replacementIndices.get( variable );
131
    int[] result = null;
132
    if( indices == null ) {
133
      result = EMPTY_INDICES;
134
    } else {
135
      Object[] buffer = indices.toArray();
136
      result = new int[ buffer.length ];
137
      for( int i = 0; i < result.length; i++ ) {
138
        result[ i ] = ( ( Integer )buffer[ i ] ).intValue();
139
      }
140
    }
141
    return result;
142
  }
143
  public String[] getTokens() {
144
    // no secure copy due to performance reasons...
145
    return tokens;
146
  }
147
148
  public void replace( final Variable toReplace, final String replacement ) {
149
    int[] indices = getReplacementIndices( toReplace );
150
    for( int i = 0; i < indices.length; i++ ) {
151
      tokens[ indices[ i ] ] = replacement;
152
    }
153
  }
154
155
  public void reset() {
156
    Iterator iterator = Variable.NAMES.values().iterator();
157
    while( iterator.hasNext() ) {
158
      Variable variable = ( Variable )iterator.next();
159
      int[] indices = getReplacementIndices( variable );
160
      for( int i = 0; i < indices.length; i++ ) {
161
        tokens[ indices[ i ] ] = null;
162
      }
163
    }
164
  }
165
}

Return to bug 302274