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

(-)src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java (-26 / +49 lines)
Lines 88-94 Link Here
88
  private List buttonList = new ArrayList();
88
  private List buttonList = new ArrayList();
89
  private Composite toolbarBg;
89
  private Composite toolbarBg;
90
  private Shell toolBarLayer;
90
  private Shell toolBarLayer;
91
  private int state;
91
  private int activeState;
92
  protected boolean deactivated;
92
  protected boolean deactivated;
93
  private Button viewMenuButton;
93
  private Button viewMenuButton;
94
  private Map dirtyListenerMap = new HashMap();
94
  private Map dirtyListenerMap = new HashMap();
Lines 97-102 Link Here
97
  private Map buttonPartMap = new HashMap();
97
  private Map buttonPartMap = new HashMap();
98
  private IPresentablePart oldPart;
98
  private IPresentablePart oldPart;
99
  private boolean allActionsVisible;
99
  private boolean allActionsVisible;
100
  private int state;
100
101
101
  private class DirtyListener implements IPropertyListener {
102
  private class DirtyListener implements IPropertyListener {
102
103
Lines 148-154 Link Here
148
  };
149
  };
149
150
150
  public ViewStackPresentation() {
151
  public ViewStackPresentation() {
151
    state = AS_INACTIVE;
152
    activeState = AS_INACTIVE;
152
    deactivated = false;
153
    deactivated = false;
153
    allActionsVisible = ConfigAction.allActionsVisible();
154
    allActionsVisible = ConfigAction.allActionsVisible();
154
  }
155
  }
Lines 173-185 Link Here
173
    registry.addViewPartPresentation( this );
174
    registry.addViewPartPresentation( this );
174
  }
175
  }
175
176
176
177
  void catchToolbarChange() {
177
  void catchToolbarChange() {
178
    layoutToolBar();
178
    layoutToolBar();
179
    setBounds( presentationControl.getBounds() );
179
    setBounds( presentationControl.getBounds() );
180
  }
180
  }
181
181
182
183
  private void createToolBarBg() {
182
  private void createToolBarBg() {
184
    Composite tabBar = getTabBar();
183
    Composite tabBar = getTabBar();
185
    toolbarBg = new Composite( tabBar.getParent(), SWT.NONE );
184
    toolbarBg = new Composite( tabBar.getParent(), SWT.NONE );
Lines 204-210 Link Here
204
        setBounds( parent.getBounds() );
203
        setBounds( parent.getBounds() );
205
      };
204
      };
206
    } );
205
    } );
207
208
    parent.setData( WidgetUtil.CUSTOM_VARIANT, "compGray" );
206
    parent.setData( WidgetUtil.CUSTOM_VARIANT, "compGray" );
209
    String setID = ILayoutSetConstants.SET_ID_STACKPRESENTATION;
207
    String setID = ILayoutSetConstants.SET_ID_STACKPRESENTATION;
210
    stackBuilder = new StackPresentationBuider( parent, setID );
208
    stackBuilder = new StackPresentationBuider( parent, setID );
Lines 230-236 Link Here
230
    } else {
228
    } else {
231
      decorateStandaloneView( newPart );
229
      decorateStandaloneView( newPart );
232
    }
230
    }
233
    // add the listener for the dirty state
231
    // add the listener for the dirty activeState
234
    IPropertyListener listener = new DirtyListener( newPart );
232
    IPropertyListener listener = new DirtyListener( newPart );
235
    dirtyListenerMap.put( newPart, listener );
233
    dirtyListenerMap.put( newPart, listener );
236
    newPart.addPropertyListener( listener );    
234
    newPart.addPropertyListener( listener );    
Lines 312-318 Link Here
312
          getToolBarLayer();
310
          getToolBarLayer();
313
          if( toolBarLayer != null ) {
311
          if( toolBarLayer != null ) {
314
            toolBarLayer.setVisible( false );
312
            toolBarLayer.setVisible( false );
315
            if( state != AS_ACTIVE_FOCUS ) {
313
            if( activeState != AS_ACTIVE_FOCUS ) {
316
              Display display = toolBarLayer.getDisplay();
314
              Display display = toolBarLayer.getDisplay();
317
              Point newLocation = display.map( toolbarBg, null, 0, 0 );
315
              Point newLocation = display.map( toolbarBg, null, 0, 0 );
318
              toolBarLayer.setBounds( newLocation.x,
316
              toolBarLayer.setBounds( newLocation.x,
Lines 401-407 Link Here
401
    fdPartButton.top = new FormAttachment( 0, 4 );
399
    fdPartButton.top = new FormAttachment( 0, 4 );
402
    fdPartButton.bottom = new FormAttachment( 100 );
400
    fdPartButton.bottom = new FormAttachment( 100 );
403
    partButton.addSelectionListener( new SelectionAdapter() {
401
    partButton.addSelectionListener( new SelectionAdapter() {
404
      public void widgetSelected( SelectionEvent e ) {
402
      public void widgetSelected( final SelectionEvent e ) {
405
        if( !currentPart.equals( part ) ) {
403
        if( !currentPart.equals( part ) ) {
406
          selectPart( part );
404
          selectPart( part );
407
        }
405
        }
Lines 418-439 Link Here
418
      };
416
      };
419
    } );
417
    } );
420
    partButton.addListener( SWT.MouseDoubleClick, new Listener() {
418
    partButton.addListener( SWT.MouseDoubleClick, new Listener() {
421
      public void handleEvent( Event event ) {
419
      public void handleEvent( final Event event ) {
422
        IWorkbench workbench = PlatformUI.getWorkbench();
420
        handleToggleZoom( part );        
423
        IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
424
        IWorkbenchPage page = window.getActivePage();
425
        page.toggleZoom( getReference( part ) );
426
        if( toolBarLayer != null ) {
427
          toolBarLayer.setVisible( false );
428
        }
429
        if( currentPart != null ) {
430
          currentPart.getControl().moveAbove( null );
431
          Control toolBar = currentPart.getToolBar();
432
          if( toolBar != null ) {
433
            toolBar.moveAbove( null );
434
          }
435
        }
436
437
      }
421
      }
438
    } );
422
    } );
439
    Composite corner = new Composite( buttonArea, SWT.NONE );
423
    Composite corner = new Composite( buttonArea, SWT.NONE );
Lines 454-459 Link Here
454
    buttonPartMap.put( buttonArea, part );
438
    buttonPartMap.put( buttonArea, part );
455
    buttonList.add( buttonArea );
439
    buttonList.add( buttonArea );
456
  }
440
  }
441
  
442
  private void handleToggleZoom( final IPresentablePart part ) {
443
    IWorkbench workbench = PlatformUI.getWorkbench();
444
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
445
    IWorkbenchPage page = window.getActivePage();
446
    page.toggleZoom( getReference( part ) );
447
    handleToolbarsOnToggleZoom();       
448
  }
449
450
  private void handleToolbarsOnToggleZoom() {
451
    ViewToolBarRegistry registry = ViewToolBarRegistry.getInstance();
452
    if( state == IStackPresentationSite.STATE_MAXIMIZED ) {
453
      registry.moveAllToolbarsBellow( null );
454
    } else if( state == IStackPresentationSite.STATE_RESTORED ) {
455
      registry.fireToolBarChanged();
456
    }
457
    if( toolBarLayer != null ) {
458
      toolBarLayer.setVisible( false );
459
    }
460
    if( currentPart != null ) {
461
      currentPart.getControl().moveAbove( null );
462
      Control toolBar = currentPart.getToolBar();
463
      if( toolBar != null ) {
464
        toolBar.moveAbove( null );
465
      }
466
    }
467
  }
468
469
  public void hideAllToolBars( final Control control ) {
470
    for( int i = 0; i < partList.size(); i++ ) {
471
      IPresentablePart part = ( IPresentablePart )partList.get( i );
472
      Control toolBar = part.getToolBar();
473
      if( toolBar != null ) {
474
        toolBar.moveBelow( control );
475
      }
476
    }
477
  }
457
478
458
  protected void activatePart( final IPresentablePart part ) {
479
  protected void activatePart( final IPresentablePart part ) {
459
    IWorkbench workbench = PlatformUI.getWorkbench();
480
    IWorkbench workbench = PlatformUI.getWorkbench();
Lines 695-701 Link Here
695
      fdOverflowButton.height = icon.getBounds().height;
716
      fdOverflowButton.height = icon.getBounds().height;
696
      fdOverflowButton.width = icon.getBounds().width;
717
      fdOverflowButton.width = icon.getBounds().width;
697
      String variant = "tabOverflowInactive";
718
      String variant = "tabOverflowInactive";
698
      if( state == AS_ACTIVE_FOCUS ) {
719
      if( activeState == AS_ACTIVE_FOCUS ) {
699
        variant = "tabOverflowActive";
720
        variant = "tabOverflowActive";
700
      }
721
      }
701
      overflowButton.setData( WidgetUtil.CUSTOM_VARIANT, variant );
722
      overflowButton.setData( WidgetUtil.CUSTOM_VARIANT, variant );
Lines 997-1003 Link Here
997
  }
1018
  }
998
1019
999
  public void setActive( final int newState ) {
1020
  public void setActive( final int newState ) {
1000
    state = newState;
1021
    activeState = newState;
1001
    Image confBg = null;
1022
    Image confBg = null;
1002
    Image cornerImage = null;
1023
    Image cornerImage = null;
1003
    Image confImage = null;
1024
    Image confImage = null;
Lines 1240-1245 Link Here
1240
  }
1261
  }
1241
1262
1242
  public void setState( final int state ) {
1263
  public void setState( final int state ) {
1264
    this.state = state;
1243
  }
1265
  }
1244
1266
1245
  public void setVisible( final boolean isVisible ) {
1267
  public void setVisible( final boolean isVisible ) {
Lines 1313-1316 Link Here
1313
    }
1335
    }
1314
    return result + WIDTH_SPACING;
1336
    return result + WIDTH_SPACING;
1315
  }
1337
  }
1338
  
1316
}
1339
}
(-)src/org/eclipse/rap/internal/design/example/stacks/ViewToolBarRegistry.java (-2 / +15 lines)
Lines 13-25 Link Here
13
import java.util.List;
13
import java.util.List;
14
14
15
import org.eclipse.rwt.SessionSingletonBase;
15
import org.eclipse.rwt.SessionSingletonBase;
16
import org.eclipse.swt.widgets.Control;
16
17
17
/**
18
/**
18
 * This class acts as a registry for ViewStackPresentations. This is necessary
19
 * This class acts as a registry for ViewStackPresentations. This is necessary
19
 * because the same view can be in different parts. If a toolbar for one part 
20
 * because the same view can be in different parts. If a toolbar for one part 
20
 * change the others should be notified.
21
 * change the others should be notified.
21
 */
22
 */
22
public class ViewToolBarRegistry extends SessionSingletonBase {
23
public class ViewToolBarRegistry {
23
  
24
  
24
  private List presentationList = new ArrayList();
25
  private List presentationList = new ArrayList();
25
  
26
  
Lines 28-34 Link Here
28
  }
29
  }
29
  
30
  
30
  public static ViewToolBarRegistry getInstance() {
31
  public static ViewToolBarRegistry getInstance() {
31
    return ( ViewToolBarRegistry ) getInstance( ViewToolBarRegistry.class );
32
    Object instance 
33
      = SessionSingletonBase.getInstance( ViewToolBarRegistry.class );
34
    return ( ViewToolBarRegistry )instance;
32
  }
35
  }
33
  
36
  
34
  public void addViewPartPresentation( 
37
  public void addViewPartPresentation( 
Lines 52-55 Link Here
52
    }
55
    }
53
  }
56
  }
54
  
57
  
58
  public void moveAllToolbarsBellow( final Control control ) {
59
    for( int i = 0; i < presentationList.size(); i++ ) {
60
      if( presentationList.get( i ) != null ) {
61
        ViewStackPresentation presentation 
62
          = ( ViewStackPresentation ) presentationList.get( i );
63
        presentation.hideAllToolBars( control );
64
      }
65
    }
66
  }
67
  
55
}
68
}

Return to bug 313544