Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
some toolbar improvements
Browse files Browse the repository at this point in the history
  - now a perspective can define that it doesn't have toolbar
  - experimental: expand/collapse toolbar
  • Loading branch information
porcelli committed Apr 10, 2013
1 parent 3ac1528 commit 11ad6b8
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,43 @@ public interface PerspectiveDefinition {

/**
* Get whether the Perspective is transient, i.e. will not be persisted.
*
* @return True if the Perspective is transient and is not to be persisted.
*/
public boolean isTransient();

/**
* Set whether the Perspective is transient, i.e. will not be persisted.
*
* @param isTransient
* True if the Perspective is not to be persisted.
* @param isTransient True if the Perspective is not to be persisted.
*/
public void setTransient(final boolean isTransient);
public void setTransient( final boolean isTransient );

/**
* Get the name of the Perspective.
*
* @return The name of the Perspective.
*/
public String getName();

/**
* Set the name of the Perspective.
*
* @param name
* The name of the Perspective.
* @param name The name of the Perspective.
*/
public void setName(final String name);
public void setName( final String name );

/**
* Get whether the Perspective has a visible toolbar.
* @return True if the Perspective has a visible toolbar.
*/
public boolean isToolbarVisible();

/**
* Set whether the Perspective has a visible toolbar or not..
* @param isVisible True if the Perspective has a visible toolbar.
*/
public void setToolbarVisible( boolean isVisible );

/**
* Get the root Panel for this Perspective. The root Panel contains all
* child Panels. A Perspective is based on a single root Panel.
*
* @return The root Panel.
*/
public PanelDefinition getRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@
*/
@Portable
public class PerspectiveDefinitionImpl
implements
PerspectiveDefinition {
implements
PerspectiveDefinition {

private String name;
private String name;

private boolean isTransient = false;
private boolean isTransient = false;

private PanelDefinition root = new PanelDefinitionImpl( true );
private boolean isToolbarVisible = true;

private PanelDefinition root = new PanelDefinitionImpl( true );

@Override
public boolean isTransient() {
return isTransient;
}

@Override
public void setTransient(boolean isTransient) {
public void setTransient( boolean isTransient ) {
this.isTransient = isTransient;
}

Expand All @@ -49,10 +51,20 @@ public String getName() {
}

@Override
public void setName(final String name) {
public void setName( final String name ) {
this.name = name;
}

@Override
public boolean isToolbarVisible() {
return isToolbarVisible;
}

@Override
public void setToolbarVisible( boolean isVisible ) {
this.isToolbarVisible = isVisible;
}

@Override
public PanelDefinition getRoot() {
return root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class HomePerspective {
@Perspective
public PerspectiveDefinition buildPerspective() {
final PerspectiveDefinition p = new PerspectiveDefinitionImpl();
p.setToolbarVisible( false );
p.setName( "Home" );

final PanelDefinition west = new PanelDefinitionImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,16 @@ private void initialisePerspective( final PerspectiveDefinition perspective ) {
//Set up Menu Bar for perspective
menuBar.aggregatePerspectiveMenus( getMenus() );

//Set up Tool Bar for perspective
final ToolBar toolBar = getToolBar();
if ( toolBar != null ) {
toolBarPresenter.addWorkbenchPerspective( toolBar );
if ( perspective.isToolbarVisible() ) {
toolBarPresenter.show();

//Set up Tool Bar for perspective
final ToolBar toolBar = getToolBar();
if ( toolBar != null ) {
toolBarPresenter.addWorkbenchPerspective( toolBar );
}
} else {
toolBarPresenter.hide();
}

onReveal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public interface WorkbenchConstants

String minimizePanel();

String expandToolbar();

String collapseToolbar();

}
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,10 @@ public void onResize() {
private void doResizeWorkbenchContainer( final int width,
final int height ) {
final int menuBarHeight = menuBarPresenter.getView().asWidget().getOffsetHeight();
final int toolBarHeight = toolBarPresenter.getView().asWidget().getOffsetHeight();
final int toolBarHeight = toolBarPresenter.getHeight();
// final int statusBarHeight = statusBarPresenter.getView().asWidget().getOffsetHeight();
final int availableHeight = height - menuBarHeight - toolBarHeight;// - statusBarHeight;
workbenchContainer.setPixelSize( width,
availableHeight );
workbenchContainer.setPixelSize( width, availableHeight );
workbench.setPixelSize( width,
availableHeight );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface View
void addToolBar( final ToolBar toolBar );

void removeToolBar( final ToolBar toolBar );

int getHeight();

void hide();

void show();
}

private PlaceRequest activePlace;
Expand All @@ -72,6 +78,18 @@ public IsWidget getView() {
return this.view;
}

public int getHeight() {
return this.view.getHeight();
}

public void hide() {
this.view.hide();
}

public void show() {
this.view.show();
}

//Handle removing the WorkbenchPart Tool Bar items
void onWorkbenchPartClose( @Observes ClosePlaceEvent event ) {
if ( event.getPlace().equals( activePlace ) ) {
Expand Down
Loading

0 comments on commit 11ad6b8

Please sign in to comment.