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 281787 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/theme/ThemeManager.java (-4 / +10 lines)
Lines 18-23 Link Here
18
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
18
import org.eclipse.rwt.internal.lifecycle.HtmlResponseWriter;
19
import org.eclipse.rwt.internal.lifecycle.LifeCycleAdapterUtil;
19
import org.eclipse.rwt.internal.lifecycle.LifeCycleAdapterUtil;
20
import org.eclipse.rwt.internal.resources.ResourceManager;
20
import org.eclipse.rwt.internal.resources.ResourceManager;
21
import org.eclipse.rwt.internal.resources.ResourceManagerImpl;
21
import org.eclipse.rwt.internal.service.ContextProvider;
22
import org.eclipse.rwt.internal.service.ContextProvider;
22
import org.eclipse.rwt.internal.service.IServiceStateInfo;
23
import org.eclipse.rwt.internal.service.IServiceStateInfo;
23
import org.eclipse.rwt.internal.theme.css.*;
24
import org.eclipse.rwt.internal.theme.css.*;
Lines 114-123 Link Here
114
  };
115
  };
115
116
116
  /** Where to load the default non-themeable images from */
117
  /** Where to load the default non-themeable images from */
117
  private static final String WIDGET_RESOURCES_SRC = "resource/widget/rap";
118
  private static final String WIDGET_RESOURCES_SRC = "resource/widget/rap/";
118
119
119
  /** Destination path for theme resources */
120
  /** Destination path for theme resources */
120
  private static final String THEME_RESOURCE_DEST = "resource/themes";
121
  private static final String THEME_RESOURCE_DEST = "themes";
121
  private static final String THEME_PREFIX = "org.eclipse.swt.theme.";
122
  private static final String THEME_PREFIX = "org.eclipse.swt.theme.";
122
123
123
  private static final String PREDEFINED_THEME_ID = THEME_PREFIX + "Default";
124
  private static final String PREDEFINED_THEME_ID = THEME_PREFIX + "Default";
Lines 643-649 Link Here
643
    log( " == register non-themeable images for theme " + themeId );
644
    log( " == register non-themeable images for theme " + themeId );
644
    for( int i = 0; i < WIDGET_NOTHEME_RESOURCES.length; i++ ) {
645
    for( int i = 0; i < WIDGET_NOTHEME_RESOURCES.length; i++ ) {
645
      String imagePath = WIDGET_NOTHEME_RESOURCES[ i ];
646
      String imagePath = WIDGET_NOTHEME_RESOURCES[ i ];
646
      String res = WIDGET_RESOURCES_SRC + "/" + imagePath;
647
      String res = WIDGET_RESOURCES_SRC + imagePath;
647
      InputStream inputStream = classLoader.getResourceAsStream( res );
648
      InputStream inputStream = classLoader.getResourceAsStream( res );
648
      if( inputStream == null ) {
649
      if( inputStream == null ) {
649
        String mesg = "Resource not found: " + res;
650
        String mesg = "Resource not found: " + res;
Lines 767-773 Link Here
767
    }
768
    }
768
    QxTheme qxTheme = new QxTheme( jsId, theme.getName(), type, base );
769
    QxTheme qxTheme = new QxTheme( jsId, theme.getName(), type, base );
769
    if( type == QxTheme.WIDGET || type == QxTheme.ICON ) {
770
    if( type == QxTheme.WIDGET || type == QxTheme.ICON ) {
770
      qxTheme.appendUri( getWidgetDestPath( jsId ) );
771
      // TODO [rh] remove hard-coded resource-manager-path-prefix 
772
      String uri 
773
        = ResourceManagerImpl.RESOURCES 
774
        + "/" 
775
        + getWidgetDestPath( jsId );
776
      qxTheme.appendUri( uri );
771
    } else if( type == QxTheme.APPEARANCE ) {
777
    } else if( type == QxTheme.APPEARANCE ) {
772
      Iterator iterator = customAppearances.iterator();
778
      Iterator iterator = customAppearances.iterator();
773
      while( iterator.hasNext() ) {
779
      while( iterator.hasNext() ) {
(-)src/org/eclipse/rwt/internal/theme/QxImage.java (-9 / +4 lines)
Lines 9-15 Link Here
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing development
10
 *     EclipseSource - ongoing development
11
 ******************************************************************************/
11
 ******************************************************************************/
12
13
package org.eclipse.rwt.internal.theme;
12
package org.eclipse.rwt.internal.theme;
14
13
15
import java.io.IOException;
14
import java.io.IOException;
Lines 23-42 Link Here
23
22
24
  private static final String NONE_INPUT = "none";
23
  private static final String NONE_INPUT = "none";
25
24
26
  public static final QxImage NONE = new QxImage( true, null, null, null, null );
25
  public static final QxImage NONE
26
    = new QxImage( true, null, null, null, null );
27
27
28
  public final boolean none;
28
  public final boolean none;
29
30
  public final String path;
29
  public final String path;
31
32
  public final ResourceLoader loader;
30
  public final ResourceLoader loader;
33
34
  public final String[] gradientColors;
31
  public final String[] gradientColors;
35
36
  public final float[] gradientPercents;
32
  public final float[] gradientPercents;
37
38
  public final int width;
33
  public final int width;
39
40
  public final int height;
34
  public final int height;
41
35
42
  /**
36
  /**
Lines 82-88 Link Here
82
    }
76
    }
83
  }
77
  }
84
78
85
  public static QxImage valueOf( final String input, final ResourceLoader loader )
79
  public static QxImage valueOf( final String input, 
80
                                 final ResourceLoader loader )
86
  {
81
  {
87
    QxImage result;
82
    QxImage result;
88
    if( NONE_INPUT.equals( input ) ) {
83
    if( NONE_INPUT.equals( input ) ) {
(-)src/org/eclipse/rwt/internal/resources/ResourceManagerImpl.java (+6 lines)
Lines 37-42 Link Here
37
  implements IResourceManager, Adaptable
37
  implements IResourceManager, Adaptable
38
{
38
{
39
  
39
  
40
  public static final String RESOURCES = "resources";
41
40
  /** <p>The singleton instance of ResourceManager.</p> */
42
  /** <p>The singleton instance of ResourceManager.</p> */
41
  private static IResourceManager _instance;
43
  private static IResourceManager _instance;
42
  
44
  
Lines 364-369 Link Here
364
      StringBuffer url = new StringBuffer();
366
      StringBuffer url = new StringBuffer();
365
      url.append( URLHelper.getContextURLString() );
367
      url.append( URLHelper.getContextURLString() );
366
      url.append( "/" );
368
      url.append( "/" );
369
      url.append( RESOURCES );
370
      url.append( "/" );
367
      String escapedFilename = escapeFilename( newFileName );
371
      String escapedFilename = escapeFilename( newFileName );
368
      url.append( versionedResourceName( escapedFilename, version ) );
372
      url.append( versionedResourceName( escapedFilename, version ) );
369
      result = url.toString();
373
      result = url.toString();
Lines 504-509 Link Here
504
    StringBuffer filename = new StringBuffer();
508
    StringBuffer filename = new StringBuffer();
505
    filename.append( webAppRoot );
509
    filename.append( webAppRoot );
506
    filename.append( File.separator );
510
    filename.append( File.separator );
511
    filename.append( RESOURCES );
512
    filename.append( File.separator );
507
    filename.append( versionedResourceName( escapeFilename( name ), version ) );
513
    filename.append( versionedResourceName( escapeFilename( name ), version ) );
508
    return new File( filename.toString() );
514
    return new File( filename.toString() );
509
  }
515
  }
(-)src/org/eclipse/swt/internal/graphics/ImageDataCache.java (-15 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2008, 2009 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-12 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.swt.internal.graphics;
12
package org.eclipse.swt.internal.graphics;
12
13
Lines 16-33 Link Here
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Image;
17
18
18
19
19
public class ImageDataCache {
20
final class ImageDataCache {
20
21
21
  /** Maximum size of image data that is being cached */
22
  /** Maximum size of image data that is being cached */
22
  private static final int MAX_DATA_SIZE = 1024;
23
  private static final int MAX_DATA_SIZE = 1024;
23
24
24
  /** Maximum number of elements to hold in the image data cache */
25
  private static final int MAX_FILL_SIZE = 100;
26
27
  private final Map cache;
25
  private final Map cache;
28
26
29
  public ImageDataCache() {
27
  ImageDataCache() {
30
    cache = new HashMap( MAX_FILL_SIZE / 4 );
28
    cache = new HashMap( 25 );
31
  }
29
  }
32
30
33
  /**
31
  /**
Lines 37-43 Link Here
37
   * @return a secure copy of the cached image data, or <code>null</code> if
35
   * @return a secure copy of the cached image data, or <code>null</code> if
38
   *         no image data have been cached for the given image
36
   *         no image data have been cached for the given image
39
   */
37
   */
40
  public ImageData getImageData( final Image image ) {
38
  ImageData getImageData( final Image image ) {
41
    if( image == null ) {
39
    if( image == null ) {
42
      throw new NullPointerException( "null argument" );
40
      throw new NullPointerException( "null argument" );
43
    }
41
    }
Lines 54-71 Link Here
54
   * @param image the image whose image data to store
52
   * @param image the image whose image data to store
55
   * @param imageData the image data to be stored
53
   * @param imageData the image data to be stored
56
   */
54
   */
57
  public synchronized void putImageData( final Image image,
55
  void putImageData( final Image image, final ImageData imageData ) {
58
                                         final ImageData imageData )
59
  {
60
    if( image == null || imageData == null ) {
56
    if( image == null || imageData == null ) {
61
      throw new NullPointerException( "null argument" );
57
      throw new NullPointerException( "null argument" );
62
    }
58
    }
63
    if( imageData.data.length <= MAX_DATA_SIZE ) {
59
    if( imageData.data.length <= MAX_DATA_SIZE ) {
60
      // TODO [rst] Implement replacement strategy (LRU or LFU)
64
      synchronized( cache ) {
61
      synchronized( cache ) {
65
        if( cache.size() > MAX_FILL_SIZE ) {
66
          // TODO [rst] Implement replacement strategy (LRU or LFU)
67
//          cache.remove( key );
68
        }
69
        cache.put( image, imageData.clone() );
62
        cache.put( image, imageData.clone() );
70
      }
63
      }
71
    }
64
    }
(-)src/org/eclipse/swt/internal/graphics/ResourceFactory.java (-5 / +13 lines)
Lines 174-188 Link Here
174
    return result;
174
    return result;
175
  }
175
  }
176
176
177
  public static synchronized String getImagePath( final Image image ) {
177
  public static String getImagePath( final Image image ) {
178
    String result = getImageName( image );
179
    if( result != null ) {
180
      result = ResourceManager.getInstance().getLocation( result );
181
    }
182
    return result;
183
  }
184
  
185
  private static synchronized String getImageName( final Image image ) {
178
    String result = null;
186
    String result = null;
179
    Iterator it = images.entrySet().iterator();
187
    Iterator it = images.entrySet().iterator();
180
    boolean next = true;
188
    boolean found = false;
181
    while( next && it.hasNext() ) {
189
    while( !found && it.hasNext() ) {
182
      Map.Entry entry = ( Map.Entry )it.next();
190
      Map.Entry entry = ( Map.Entry )it.next();
183
      if( entry.getValue().equals( image ) ) {
191
      if( entry.getValue().equals( image ) ) {
184
        result = ( String )entry.getKey();
192
        result = ( String )entry.getKey();
185
        next = false;
193
        found = true;
186
      }
194
      }
187
    }
195
    }
188
    return result;
196
    return result;
Lines 192-198 Link Here
192
    ImageData result = imageDataCache.getImageData( image );
200
    ImageData result = imageDataCache.getImageData( image );
193
    if( result == null ) {
201
    if( result == null ) {
194
      IResourceManager manager = ResourceManager.getInstance();
202
      IResourceManager manager = ResourceManager.getInstance();
195
      String imagePath = getImagePath( image );
203
      String imagePath = getImageName( image );
196
      if( imagePath != null ) {
204
      if( imagePath != null ) {
197
        try {
205
        try {
198
          InputStream inputStream = manager.getRegisteredContent( imagePath );
206
          InputStream inputStream = manager.getRegisteredContent( imagePath );
(-)src/org/eclipse/rwt/internal/service/rwt-index.html (-1 / +1 lines)
Lines 6-12 Link Here
6
    ${headers}
6
    ${headers}
7
  </head>
7
  </head>
8
8
9
  <body background="resource/widget/rap/display/bg.gif">
9
  <body background="resources/resource/widget/rap/display/bg.gif">
10
10
11
    <!-- body of branding -->
11
    <!-- body of branding -->
12
    ${body}
12
    ${body}
(-)src/org/eclipse/rwt/lifecycle/ControlLCAUtil_Test.java (-1 / +2 lines)
Lines 574-582 Link Here
574
    RWTFixture.markInitialized( control );
574
    RWTFixture.markInitialized( control );
575
    control.setBackgroundImage( Graphics.getImage( RWTFixture.IMAGE1 ) );
575
    control.setBackgroundImage( Graphics.getImage( RWTFixture.IMAGE1 ) );
576
    ControlLCAUtil.writeBackgroundImage( control );
576
    ControlLCAUtil.writeBackgroundImage( control );
577
    String imageLocation = "resources/" + RWTFixture.IMAGE1;
577
    String expected =   "var w = wm.findWidgetById( \"w2\" );"
578
    String expected =   "var w = wm.findWidgetById( \"w2\" );"
578
                      + "w.setBackgroundImage( \""
579
                      + "w.setBackgroundImage( \""
579
                      + RWTFixture.IMAGE1
580
                      + imageLocation
580
                      + "\" );";
581
                      + "\" );";
581
    assertEquals( expected, Fixture.getAllMarkup() );
582
    assertEquals( expected, Fixture.getAllMarkup() );
582
583
(-)src/org/eclipse/swt/internal/widgets/buttonkit/ButtonLCA_Test.java (-1 / +2 lines)
Lines 506-512 Link Here
506
    lca.renderChanges( button );
506
    lca.renderChanges( button );
507
    String allMarkup = Fixture.getAllMarkup();
507
    String allMarkup = Fixture.getAllMarkup();
508
    assertTrue( allMarkup.indexOf( "w.setText( \"Test\" );" ) != -1 );
508
    assertTrue( allMarkup.indexOf( "w.setText( \"Test\" );" ) != -1 );
509
    String expected = "w.setImage( \"" + RWTFixture.IMAGE1 + "\", 58, 12 );";
509
    String imageLocation = "resources/" + RWTFixture.IMAGE1;
510
    String expected = "w.setImage( \"" + imageLocation + "\", 58, 12 );";
510
    assertTrue( allMarkup.indexOf( expected ) != -1 );
511
    assertTrue( allMarkup.indexOf( expected ) != -1 );
511
    Fixture.fakeResponseWriter();
512
    Fixture.fakeResponseWriter();
512
    lca.preserveValues( button );
513
    lca.preserveValues( button );
(-)src/org/eclipse/swt/RWTFixture.java (-1 / +1 lines)
Lines 78-84 Link Here
78
    }
78
    }
79
79
80
    public String getLocation( final String name ) {
80
    public String getLocation( final String name ) {
81
      return null;
81
      return "resources/" + name;
82
    }
82
    }
83
83
84
    public URL getResource( final String name ) {
84
    public URL getResource( final String name ) {
(-)js/org/eclipse/swt/theme/ThemeValues.js (-6 / +7 lines)
Lines 108-114 Link Here
108
      var result = values.images[ vkey ];
108
      var result = values.images[ vkey ];
109
      this.__checkDefined( result, element, key );
109
      this.__checkDefined( result, element, key );
110
      if( result != null ) {
110
      if( result != null ) {
111
        result = "resource/themes/images/" + result[ 0 ];
111
        // TODO [rh] remove hard-coded path (first segment is defined by 
112
        //      resource-manager)
113
        result = "resources/themes/images/" + result[ 0 ];
112
      } else {
114
      } else {
113
        // TODO [rst] Handle null values - currently, both null and the string
115
        // TODO [rst] Handle null values - currently, both null and the string
114
        // "undefined" lead to a js error for icon property
116
        // "undefined" lead to a js error for icon property
Lines 119-131 Link Here
119
121
120
    getCssSizedImage : function( element, key ) {
122
    getCssSizedImage : function( element, key ) {
121
      var vkey = this._store.getCssValue( element, this._states, key );
123
      var vkey = this._store.getCssValue( element, this._states, key );
122
      var values = this._store.getThemeValues();
124
      var result = this._store.getThemeValues().images[ vkey ];
123
      var result = values.images[ vkey ];
124
      this.__checkDefined( result, element, key );
125
      this.__checkDefined( result, element, key );
125
      // TODO [tb] : Revise hardcoded path
126
      // TODO [tb] : Revise hardcoded path
126
      return result = [ "resource/themes/images/" + result[ 0 ], 
127
      return [ "resources/themes/images/" + result[ 0 ], 
127
                        result[ 1 ], 
128
               result[ 1 ], 
128
                        result[ 2 ] ];
129
               result[ 2 ] ];
129
    },
130
    },
130
131
131
    getCssGradient : function( element, key ) {
132
    getCssGradient : function( element, key ) {
(-)js/org/eclipse/swt/theme/AppearancesBase.js (-1 / +1 lines)
Lines 72-78 Link Here
72
        textColor : "black",
72
        textColor : "black",
73
        backgroundColor : "white",
73
        backgroundColor : "white",
74
        // TODO [rst] Eliminate absolute references
74
        // TODO [rst] Eliminate absolute references
75
        backgroundImage : "./resource/widget/rap/display/bg.gif"
75
        backgroundImage : "./resources/resource/widget/rap/display/bg.gif"
76
      };
76
      };
77
    }
77
    }
78
  },
78
  },
(-)src/org/eclipse/rwt/internal/lifecycle/JSConst.java (-1 lines)
Lines 145-151 Link Here
145
  public static final String QX_FIELD_FONT = "font";
145
  public static final String QX_FIELD_FONT = "font";
146
  public static final String QX_FIELD_COLOR = "textColor";
146
  public static final String QX_FIELD_COLOR = "textColor";
147
  public static final String QX_FIELD_BG_COLOR = "backgroundColor";
147
  public static final String QX_FIELD_BG_COLOR = "backgroundColor";
148
  public static final String QX_FIELD_BG_IMAGE = "backgroundImage";
149
  public static final String QX_FIELD_ORIENTATION = "orientation";
148
  public static final String QX_FIELD_ORIENTATION = "orientation";
150
  public static final String QX_FIELD_CAPTION = "caption";
149
  public static final String QX_FIELD_CAPTION = "caption";
151
  public static final String QX_FIELD_ENABLED = "enabled";
150
  public static final String QX_FIELD_ENABLED = "enabled";
(-)src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java (-2 / +2 lines)
Lines 431-439 Link Here
431
      JSWriter writer = JSWriter.getWriterFor( control );
431
      JSWriter writer = JSWriter.getWriterFor( control );
432
      if( image != null ) {
432
      if( image != null ) {
433
        String imagePath = ResourceFactory.getImagePath( image );
433
        String imagePath = ResourceFactory.getImagePath( image );
434
        writer.set( JSConst.QX_FIELD_BG_IMAGE, imagePath );
434
        writer.set( "backgroundImage", imagePath );
435
      } else {
435
      } else {
436
        writer.reset( JSConst.QX_FIELD_BG_IMAGE );
436
        writer.reset( "backgroundImage" );
437
      }
437
      }
438
    }
438
    }
439
  }
439
  }
(-)js/org/eclipse/swt/Application.js (-2 / +2 lines)
Lines 95-102 Link Here
95
      qx.ui.basic.ScrollBar.EVENT_DELAY = 125;
95
      qx.ui.basic.ScrollBar.EVENT_DELAY = 125;
96
      // Overwrite the default mapping for internal images. This is necessary
96
      // Overwrite the default mapping for internal images. This is necessary
97
      // if the application is deployed under a root different from "/".
97
      // if the application is deployed under a root different from "/".
98
      qx.io.Alias.getInstance().add( "static", "./resource/static" );
98
      qx.io.Alias.getInstance().add( "static", "./resources/resource/static" );
99
      qx.io.Alias.getInstance().add( "org.eclipse.swt", "./resource" );
99
      qx.io.Alias.getInstance().add( "org.eclipse.swt", "./resources/resource" );
100
      // Observe window size
100
      // Observe window size
101
      var doc = qx.ui.core.ClientDocument.getInstance();
101
      var doc = qx.ui.core.ClientDocument.getInstance();
102
      doc.addEventListener( "windowresize",
102
      doc.addEventListener( "windowresize",
(-)src/org/eclipse/rwt/internal/resources/ResourceManagerImpl_Test.java (-49 / +54 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2009 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-14 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
12
package org.eclipse.rwt.internal.resources;
12
package org.eclipse.rwt.internal.resources;
13
13
14
import java.io.*;
14
import java.io.*;
Lines 50-56 Link Here
50
  private static final int TEST_PORT = 4711;
50
  private static final int TEST_PORT = 4711;
51
  private static final String TEST_SERVER = "TestCase";
51
  private static final String TEST_SERVER = "TestCase";
52
  private static final String TEST_SERVLET_PATH = "/W4TDelegate";
52
  private static final String TEST_SERVLET_PATH = "/W4TDelegate";
53
  private static final String TEST_REQUEST_URI 
53
  private static final String TEST_REQUEST_URI
54
    = TEST_CONTEXT + "/W4TDelegate?anyParam=true";
54
    = TEST_CONTEXT + "/W4TDelegate?anyParam=true";
55
  private static final String TEST_CONTEXT_URL
55
  private static final String TEST_CONTEXT_URL
56
    =   "http://"
56
    =   "http://"
Lines 60-70 Link Here
60
      + TEST_CONTEXT;
60
      + TEST_CONTEXT;
61
  private static final String TEST_LOCATION_DISK
61
  private static final String TEST_LOCATION_DISK
62
    =   TEST_CONTEXT_URL
62
    =   TEST_CONTEXT_URL
63
      + "/"
63
      + "/resources/"
64
      + TEST_RESOURCE_1;
64
      + TEST_RESOURCE_1;
65
  private static final String TEST_LOCATION_VERSIONED_DISK
65
  private static final String TEST_LOCATION_VERSIONED_DISK
66
    =   TEST_CONTEXT_URL
66
    =   TEST_CONTEXT_URL
67
      + "/"
67
      + "/resources/"
68
      + TEST_RESOURCE_1_VERSIONED;
68
      + TEST_RESOURCE_1_VERSIONED;
69
  private static final String TEST_LOCATION_SERVLET
69
  private static final String TEST_LOCATION_SERVLET
70
    =   TEST_CONTEXT_URL
70
    =   TEST_CONTEXT_URL
Lines 84-90 Link Here
84
      + RequestParams.RESOURCE_VERSION
84
      + RequestParams.RESOURCE_VERSION
85
      + "="
85
      + "="
86
      + "1895582734";
86
      + "1895582734";
87
  
87
88
  /////////
88
  /////////
89
  // fields
89
  // fields
90
  private String webAppRoot;
90
  private String webAppRoot;
Lines 181-187 Link Here
181
  }
181
  }
182
182
183
  public void testRegistrationServletTempDir() throws Exception {
183
  public void testRegistrationServletTempDir() throws Exception {
184
    IResourceManager manager 
184
    IResourceManager manager
185
      = getManager( ResourceBase.DELIVER_BY_SERVLET_AND_TEMP_DIR );
185
      = getManager( ResourceBase.DELIVER_BY_SERVLET_AND_TEMP_DIR );
186
    clearTempFile();
186
    clearTempFile();
187
    // register only existing resources
187
    // register only existing resources
Lines 451-457 Link Here
451
      // expected
451
      // expected
452
    }
452
    }
453
  }
453
  }
454
  
454
455
  public void testGetRegisteredContent() throws Exception {
455
  public void testGetRegisteredContent() throws Exception {
456
    IResourceManager manager = getManager( ResourceBase.DELIVER_FROM_DISK );
456
    IResourceManager manager = getManager( ResourceBase.DELIVER_FROM_DISK );
457
    InputStream is = openStream( TEST_RESOURCE_2 );
457
    InputStream is = openStream( TEST_RESOURCE_2 );
Lines 462-468 Link Here
462
    content.close();
462
    content.close();
463
    assertNull( manager.getRegisteredContent( "not-there" ) );
463
    assertNull( manager.getRegisteredContent( "not-there" ) );
464
  }
464
  }
465
  
465
466
  /*
466
  /*
467
   * 280582: resource registration fails when using ImageDescriptor.createFromURL
467
   * 280582: resource registration fails when using ImageDescriptor.createFromURL
468
   * https://bugs.eclipse.org/bugs/show_bug.cgi?id=280582
468
   * https://bugs.eclipse.org/bugs/show_bug.cgi?id=280582
Lines 477-489 Link Here
477
    manager.register( name, inputStream );
477
    manager.register( name, inputStream );
478
    inputStream.close();
478
    inputStream.close();
479
    String location = manager.getLocation( name );
479
    String location = manager.getLocation( name );
480
    assertEquals( "http://TestCase:4711/test/http$1//host$1port/path$$1", 
480
    String expected
481
                  location );
481
      = "http://TestCase:4711/test/resources/http$1//host$1port/path$$1";
482
    assertEquals( expected, location );
482
  }
483
  }
483
484
484
  ///////////////////
485
  ///////////////////
485
  // helping methods
486
  // helping methods
486
  
487
487
  private static int[] read( final InputStream input ) throws IOException {
488
  private static int[] read( final InputStream input ) throws IOException {
488
    int[] result = null;
489
    int[] result = null;
489
    try {
490
    try {
Lines 518-524 Link Here
518
  }
519
  }
519
520
520
  private String getResourceCopyFile( final String resourceName ) {
521
  private String getResourceCopyFile( final String resourceName ) {
521
    return webAppRoot + File.separator + resourceName;
522
    return   webAppRoot
523
           + File.separator
524
           + "resources"
525
           + File.separator
526
           + resourceName;
522
  }
527
  }
523
528
524
  private String getResourceCopyInTempFile( final String resourceName ) {
529
  private String getResourceCopyInTempFile( final String resourceName ) {
Lines 573-587 Link Here
573
      return null;
578
      return null;
574
    }
579
    }
575
580
576
    public long getDateHeader( String arg0 ) {
581
    public long getDateHeader( final String arg0 ) {
577
      return 0;
582
      return 0;
578
    }
583
    }
579
584
580
    public String getHeader( String arg0 ) {
585
    public String getHeader( final String arg0 ) {
581
      return null;
586
      return null;
582
    }
587
    }
583
588
584
    public Enumeration getHeaders( String arg0 ) {
589
    public Enumeration getHeaders( final String arg0 ) {
585
      return null;
590
      return null;
586
    }
591
    }
587
592
Lines 589-595 Link Here
589
      return null;
594
      return null;
590
    }
595
    }
591
596
592
    public int getIntHeader( String arg0 ) {
597
    public int getIntHeader( final String arg0 ) {
593
      return 0;
598
      return 0;
594
    }
599
    }
595
600
Lines 617-623 Link Here
617
      return null;
622
      return null;
618
    }
623
    }
619
624
620
    public boolean isUserInRole( String arg0 ) {
625
    public boolean isUserInRole( final String arg0 ) {
621
      return false;
626
      return false;
622
    }
627
    }
623
628
Lines 641-647 Link Here
641
      return TEST_SERVLET_PATH;
646
      return TEST_SERVLET_PATH;
642
    }
647
    }
643
648
644
    public HttpSession getSession( boolean arg0 ) {
649
    public HttpSession getSession( final boolean arg0 ) {
645
      return null;
650
      return null;
646
    }
651
    }
647
652
Lines 665-671 Link Here
665
      return false;
670
      return false;
666
    }
671
    }
667
672
668
    public Object getAttribute( String arg0 ) {
673
    public Object getAttribute( final String arg0 ) {
669
      return null;
674
      return null;
670
    }
675
    }
671
676
Lines 677-683 Link Here
677
      return null;
682
      return null;
678
    }
683
    }
679
684
680
    public void setCharacterEncoding( String arg0 )
685
    public void setCharacterEncoding( final String arg0 )
681
      throws UnsupportedEncodingException
686
      throws UnsupportedEncodingException
682
    {
687
    {
683
    }
688
    }
Lines 694-700 Link Here
694
      return null;
699
      return null;
695
    }
700
    }
696
701
697
    public String getParameter( String arg0 ) {
702
    public String getParameter( final String arg0 ) {
698
      return null;
703
      return null;
699
    }
704
    }
700
705
Lines 702-708 Link Here
702
      return null;
707
      return null;
703
    }
708
    }
704
709
705
    public String[] getParameterValues( String arg0 ) {
710
    public String[] getParameterValues( final String arg0 ) {
706
      return null;
711
      return null;
707
    }
712
    }
708
713
Lines 738-747 Link Here
738
      return null;
743
      return null;
739
    }
744
    }
740
745
741
    public void setAttribute( String arg0, Object arg1 ) {
746
    public void setAttribute( final String arg0, final Object arg1 ) {
742
    }
747
    }
743
748
744
    public void removeAttribute( String arg0 ) {
749
    public void removeAttribute( final String arg0 ) {
745
    }
750
    }
746
751
747
    public Locale getLocale() {
752
    public Locale getLocale() {
Lines 756-766 Link Here
756
      return false;
761
      return false;
757
    }
762
    }
758
763
759
    public RequestDispatcher getRequestDispatcher( String arg0 ) {
764
    public RequestDispatcher getRequestDispatcher( final String arg0 ) {
760
      return null;
765
      return null;
761
    }
766
    }
762
767
763
    public String getRealPath( String arg0 ) {
768
    public String getRealPath( final String arg0 ) {
764
      return null;
769
      return null;
765
    }
770
    }
766
771
Lines 782-841 Link Here
782
  }
787
  }
783
  private class TestResponse implements HttpServletResponse {
788
  private class TestResponse implements HttpServletResponse {
784
789
785
    public void addCookie( Cookie arg0 ) {
790
    public void addCookie( final Cookie arg0 ) {
786
    }
791
    }
787
792
788
    public boolean containsHeader( String arg0 ) {
793
    public boolean containsHeader( final String arg0 ) {
789
      return false;
794
      return false;
790
    }
795
    }
791
796
792
    public String encodeURL( String arg0 ) {
797
    public String encodeURL( final String arg0 ) {
793
      return arg0;
798
      return arg0;
794
    }
799
    }
795
800
796
    public String encodeRedirectURL( String arg0 ) {
801
    public String encodeRedirectURL( final String arg0 ) {
797
      return null;
802
      return null;
798
    }
803
    }
799
804
800
    public String encodeUrl( String arg0 ) {
805
    public String encodeUrl( final String arg0 ) {
801
      return arg0;
806
      return arg0;
802
    }
807
    }
803
808
804
    public String encodeRedirectUrl( String arg0 ) {
809
    public String encodeRedirectUrl( final String arg0 ) {
805
      return null;
810
      return null;
806
    }
811
    }
807
812
808
    public void sendError( int arg0, String arg1 ) throws IOException {
813
    public void sendError( final int arg0, final String arg1 ) throws IOException {
809
    }
814
    }
810
815
811
    public void sendError( int arg0 ) throws IOException {
816
    public void sendError( final int arg0 ) throws IOException {
812
    }
817
    }
813
818
814
    public void sendRedirect( String arg0 ) throws IOException {
819
    public void sendRedirect( final String arg0 ) throws IOException {
815
    }
820
    }
816
821
817
    public void setDateHeader( String arg0, long arg1 ) {
822
    public void setDateHeader( final String arg0, final long arg1 ) {
818
    }
823
    }
819
824
820
    public void addDateHeader( String arg0, long arg1 ) {
825
    public void addDateHeader( final String arg0, final long arg1 ) {
821
    }
826
    }
822
827
823
    public void setHeader( String arg0, String arg1 ) {
828
    public void setHeader( final String arg0, final String arg1 ) {
824
    }
829
    }
825
830
826
    public void addHeader( String arg0, String arg1 ) {
831
    public void addHeader( final String arg0, final String arg1 ) {
827
    }
832
    }
828
833
829
    public void setIntHeader( String arg0, int arg1 ) {
834
    public void setIntHeader( final String arg0, final int arg1 ) {
830
    }
835
    }
831
836
832
    public void addIntHeader( String arg0, int arg1 ) {
837
    public void addIntHeader( final String arg0, final int arg1 ) {
833
    }
838
    }
834
839
835
    public void setStatus( int arg0 ) {
840
    public void setStatus( final int arg0 ) {
836
    }
841
    }
837
842
838
    public void setStatus( int arg0, String arg1 ) {
843
    public void setStatus( final int arg0, final String arg1 ) {
839
    }
844
    }
840
845
841
    public String getCharacterEncoding() {
846
    public String getCharacterEncoding() {
Lines 850-862 Link Here
850
      return null;
855
      return null;
851
    }
856
    }
852
857
853
    public void setContentLength( int arg0 ) {
858
    public void setContentLength( final int arg0 ) {
854
    }
859
    }
855
860
856
    public void setContentType( String arg0 ) {
861
    public void setContentType( final String arg0 ) {
857
    }
862
    }
858
863
859
    public void setBufferSize( int arg0 ) {
864
    public void setBufferSize( final int arg0 ) {
860
    }
865
    }
861
866
862
    public int getBufferSize() {
867
    public int getBufferSize() {
Lines 876-882 Link Here
876
    public void reset() {
881
    public void reset() {
877
    }
882
    }
878
883
879
    public void setLocale( Locale arg0 ) {
884
    public void setLocale( final Locale arg0 ) {
880
    }
885
    }
881
886
882
    public Locale getLocale() {
887
    public Locale getLocale() {
Lines 887-893 Link Here
887
      throw new UnsupportedOperationException();
892
      throw new UnsupportedOperationException();
888
    }
893
    }
889
894
890
    public void setCharacterEncoding( String charset ) {
895
    public void setCharacterEncoding( final String charset ) {
891
      throw new UnsupportedOperationException();
896
      throw new UnsupportedOperationException();
892
    }
897
    }
893
  }
898
  }
(-)src/org/eclipse/swt/graphics/Image_Test.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2009 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-14 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
12
package org.eclipse.swt.graphics;
12
package org.eclipse.swt.graphics;
13
13
14
import java.io.*;
14
import java.io.*;
Lines 37-44 Link Here
37
//    assertEquals( 0, Image.size() );
37
//    assertEquals( 0, Image.size() );
38
    Image image1 = Graphics.getImage( RWTFixture.IMAGE1 );
38
    Image image1 = Graphics.getImage( RWTFixture.IMAGE1 );
39
    assertTrue( manager.isRegistered( RWTFixture.IMAGE1 ) );
39
    assertTrue( manager.isRegistered( RWTFixture.IMAGE1 ) );
40
    String contextPath = Fixture.CONTEXT_DIR.getPath();
40
    String contextPath = Fixture.CONTEXT_DIR.getPath() + "/resources/";
41
    assertTrue( new File( contextPath + "/" + RWTFixture.IMAGE1 ).exists() );
41
    assertTrue( new File( contextPath + RWTFixture.IMAGE1 ).exists() );
42
//    assertEquals( 1, Image.size() );
42
//    assertEquals( 1, Image.size() );
43
    Image image2 = Graphics.getImage( RWTFixture.IMAGE1 );
43
    Image image2 = Graphics.getImage( RWTFixture.IMAGE1 );
44
    assertTrue( manager.isRegistered( RWTFixture.IMAGE1 ) );
44
    assertTrue( manager.isRegistered( RWTFixture.IMAGE1 ) );

Return to bug 281787