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 438023
Collapse All | Expand All

(-)a/examples/org.eclipse.rap.demo/plugin.xml (+22 lines)
Added Link Here
318
      </page>
318
      </page>
319
   </extension>
319
   </extension>
320
320
321
   <extension
322
         point="org.eclipse.ui.menus">
323
      <menuContribution
324
             locationURI="toolbar:org.eclipse.rap.demo.DemoTreeViewPartII?after=additions">
325
          <command
326
                commandId="command.refresh"
327
                icon="icons/refresh.gif"
328
                label="refresh"
329
                style="push"
330
                tooltip="erfresh">
331
          </command>
332
      </menuContribution>
333
    </extension>
334
335
    <extension
336
         point="org.eclipse.ui.commands">
337
      <command
338
            defaultHandler="org.eclipse.rap.demo.RefreshViewHandler"
339
            id="command.refresh"
340
            name="refresh">
341
      </command>
342
    </extension>
321
</plugin>
343
</plugin>
(-)a/examples/org.eclipse.rap.demo/src/org/eclipse/rap/demo/DemoTreeViewPart.java (-32 / +45 lines)
Lines 14-25 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.jface.action.GroupMarker;
18
import org.eclipse.jface.action.MenuManager;
17
import org.eclipse.jface.dialogs.MessageDialog;
19
import org.eclipse.jface.dialogs.MessageDialog;
18
import org.eclipse.jface.viewers.*;
20
import org.eclipse.jface.viewers.*;
19
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.*;
22
import org.eclipse.swt.widgets.Shell;
23
import org.eclipse.ui.*;
24
import org.eclipse.ui.*;
24
import org.eclipse.ui.part.ViewPart;
25
import org.eclipse.ui.part.ViewPart;
25
import org.eclipse.ui.views.properties.*;
26
import org.eclipse.ui.views.properties.*;
Lines 30-53 Link Here
30
  private TreeViewer viewer;
31
  private TreeViewer viewer;
31
  private IPropertySheetPage propertyPage;
32
  private IPropertySheetPage propertyPage;
32
33
33
//  TODO [rst] Add via extension
34
// TODO [rst] Add via extension
34
//  private final class LeafStarLabelDecorator extends LabelProvider
35
// private final class LeafStarLabelDecorator extends LabelProvider
35
//    implements ILabelDecorator
36
// implements ILabelDecorator
36
//  {
37
// {
37
//
38
//
38
//    public String decorateText( String text, Object element ) {
39
// public String decorateText( String text, Object element ) {
39
//      if( text.startsWith( "Leaf" ) ) {
40
// if( text.startsWith( "Leaf" ) ) {
40
//        return text + "*";
41
// return text + "*";
41
//      }
42
// }
42
//      return text;
43
// return text;
43
//    }
44
// }
44
//
45
//
45
//    public Image decorateImage( Image image, Object element ) {
46
// public Image decorateImage( Image image, Object element ) {
46
//      return null;
47
// return null;
47
//    }
48
// }
48
//  }
49
// }
49
50
  private static final class ViewLabelProvider extends LabelProvider {
50
  private static final class ViewLabelProvider extends LabelProvider {
51
51
    @Override
52
    @Override
52
    public Image getImage( Object element ) {
53
    public Image getImage( Object element ) {
53
      IWorkbench workbench = PlatformUI.getWorkbench();
54
      IWorkbench workbench = PlatformUI.getWorkbench();
Lines 55-62 Link Here
55
      return sharedImages.getImage( ISharedImages.IMG_OBJ_ELEMENT );
56
      return sharedImages.getImage( ISharedImages.IMG_OBJ_ELEMENT );
56
    }
57
    }
57
  }
58
  }
58
59
  class TreeObject implements IPropertySource {
59
  class TreeObject implements IPropertySource {
60
60
    private static final String PROP_ID_LOCATION = "location";
61
    private static final String PROP_ID_LOCATION = "location";
61
    private static final String PROP_ID_NAME = "name";
62
    private static final String PROP_ID_NAME = "name";
62
    private String name;
63
    private String name;
Lines 141-156 Link Here
141
      update( this );
142
      update( this );
142
    }
143
    }
143
  }
144
  }
144
145
  /**
145
  /**
146
   * Instances of this type are decorated with an error marker
146
   * Instances of this type are decorated with an error marker
147
   */
147
   */
148
  private class BrokenTreeObject extends TreeObject {
148
  private class BrokenTreeObject extends TreeObject {
149
149
    public BrokenTreeObject( String name ) {
150
    public BrokenTreeObject( String name ) {
150
      super( name );
151
      super( name );
151
    }
152
    }
152
  }
153
  }
153
154
  private class TreeParent extends TreeObject {
154
  private class TreeParent extends TreeObject {
155
155
156
    private final List<TreeObject> children;
156
    private final List<TreeObject> children;
Lines 182-187 Link Here
182
    private TreeParent invisibleRoot;
182
    private TreeParent invisibleRoot;
183
183
184
    public void inputChanged( Viewer v, Object oldInput, Object newInput ) {
184
    public void inputChanged( Viewer v, Object oldInput, Object newInput ) {
185
      try {
186
        Thread.sleep( 3000 );
187
        initialize();
188
      } catch( InterruptedException e ) {
189
        e.printStackTrace();
190
      }
185
    }
191
    }
186
192
187
    public void dispose() {
193
    public void dispose() {
Lines 219-234 Link Here
219
    }
225
    }
220
226
221
    /*
227
    /*
222
     * We will set up a dummy model to initialize tree heararchy. In a real
228
     * We will set up a dummy model to initialize tree heararchy. In a real code, you will connect
223
     * code, you will connect to a real model and expose its hierarchy.
229
     * to a real model and expose its hierarchy.
224
     */
230
     */
225
    private void initialize() {
231
    private void initialize() {
232
      invisibleRoot = new TreeParent( "" );
233
      invisibleRoot.addChild( createContent() );
234
    }
235
236
    private TreeParent createContent() {
226
      TreeObject to1 = new TreeObject( "EclipseCon location",
237
      TreeObject to1 = new TreeObject( "EclipseCon location",
227
                                       "http://maps.google.com/maps?q=5001%20Great%20America%20Pkwy%20Santa%20Clara%20CA%2095054" );
238
                                       "http://maps.google.com/maps?q=5001%20Great%20America%20Pkwy%20Santa%20Clara%20CA%2095054" );
228
      TreeObject to2 = new TreeObject( "Eclipse Foundation",
239
      TreeObject to2 = new TreeObject( "Eclipse Foundation", "http://maps.google.com/maps?q=Ottawa" );
229
                                       "http://maps.google.com/maps?q=Ottawa" );
240
      TreeObject to3 = new TreeObject( "Innoopract Inc", "http://maps.google.com/maps?q=Portland" );
230
      TreeObject to3 = new TreeObject( "Innoopract Inc",
231
                                       "http://maps.google.com/maps?q=Portland" );
232
      TreeParent p1 = new TreeParent( "Locate in browser view" );
241
      TreeParent p1 = new TreeParent( "Locate in browser view" );
233
      p1.addChild( to1 );
242
      p1.addChild( to1 );
234
      p1.addChild( to2 );
243
      p1.addChild( to2 );
Lines 241-248 Link Here
241
      root.addChild( p1 );
250
      root.addChild( p1 );
242
      root.addChild( p2 );
251
      root.addChild( p2 );
243
      root.addChild( p3 );
252
      root.addChild( p3 );
244
      invisibleRoot = new TreeParent( "" );
253
      return root;
245
      invisibleRoot.addChild( root );
246
    }
254
    }
247
  }
255
  }
248
256
Lines 250-259 Link Here
250
  public void createPartControl( Composite parent ) {
258
  public void createPartControl( Composite parent ) {
251
    viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
259
    viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
252
    viewer.setContentProvider( new TreeViewerContentProvider() );
260
    viewer.setContentProvider( new TreeViewerContentProvider() );
253
    ILabelDecorator labelDecorator
261
    ILabelDecorator labelDecorator = PlatformUI.getWorkbench()
254
      = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
262
      .getDecoratorManager()
255
    ILabelProvider labelProvider
263
      .getLabelDecorator();
256
      = new DecoratingLabelProvider( new ViewLabelProvider(), labelDecorator );
264
    ILabelProvider labelProvider = new DecoratingLabelProvider( new ViewLabelProvider(),
265
                                                                labelDecorator );
257
    viewer.setLabelProvider( labelProvider );
266
    viewer.setLabelProvider( labelProvider );
258
    viewer.setInput( this );
267
    viewer.setInput( this );
259
    viewer.addDoubleClickListener( this );
268
    viewer.addDoubleClickListener( this );
Lines 290-293 Link Here
290
  public TreeViewer getViewer() {
299
  public TreeViewer getViewer() {
291
    return viewer;
300
    return viewer;
292
  }
301
  }
302
303
  public void refresh() {
304
    viewer.setInput( this );
305
  }
293
}
306
}
(-)a/examples/org.eclipse.rap.demo/src/org/eclipse/rap/demo/RefreshViewHandler.java (+17 lines)
Added Link Here
1
package org.eclipse.rap.demo;
2
3
import org.eclipse.core.commands.*;
4
import org.eclipse.ui.IWorkbenchPart;
5
import org.eclipse.ui.handlers.HandlerUtil;
6
7
8
public class RefreshViewHandler extends AbstractHandler {
9
10
  public Object execute( final ExecutionEvent event ) throws ExecutionException {
11
    final IWorkbenchPart part = HandlerUtil.getActivePartChecked( event );
12
    if( part instanceof DemoTreeViewPart ) {
13
      ( ( DemoTreeViewPart )part ).refresh();
14
    }
15
    return null;
16
  }
17
}

Return to bug 438023