Skip to content

Commit

Permalink
fixed issue 11 #11 , when switching to an (initially) inactive perspe…
Browse files Browse the repository at this point in the history
…ctive than button management in toolbar now removes correct the button from first perspective
  • Loading branch information
JacpFX committed Jan 26, 2015
1 parent afb9aa0 commit 909d28e
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,20 @@ public final void initComponent(final Message<Event, Object> message,
final Thread t = Thread.currentThread();
try {
this.log("3.4.3: perspective handle init");

FXUtil.performResourceInjection(perspective.getPerspective(), perspective.getContext());

this.handlePerspectiveInitMethod(message, perspective);
this.log("3.4.5: perspective init bar entries");
final PerspectiveLayoutInterface<? extends Node, Node> perspectiveLayout = perspective
.getIPerspectiveLayout();
this.initPerspectiveUI(perspectiveLayout);
PerspectiveRegistry.getAndSetCurrentVisiblePerspective(perspective.getContext().getId());

final String currentPerspectiveId = perspective.getContext().getId();
final String previousPerspectiveId = PerspectiveRegistry.getAndSetCurrentVisiblePerspective(perspective.getContext().getId());

this.updateToolbarButtons(currentPerspectiveId,previousPerspectiveId);

this.log("3.4.4: perspective init subcomponents");
perspective.initComponents(message);
} catch (Exception e) {
Expand All @@ -184,6 +190,20 @@ public final void initComponent(final Message<Event, Object> message,

}


/**
* check if switch from active to inactive perspective
* @param currentPerspectiveId
* @param previousPerspectiveId
*/
private void updateToolbarButtons(final String currentPerspectiveId,final String previousPerspectiveId) {
if(previousPerspectiveId!=null && !previousPerspectiveId.equals(currentPerspectiveId)){
final Perspective<Node, EventHandler<Event>, Event, Object> previousPerspective = PerspectiveRegistry.findPerspectiveById(previousPerspectiveId);
// hide all buttons of the previous perspective
GlobalMediator.getInstance().handleToolBarButtons(previousPerspective, false);
}
}

/**
* reassignment can only be done in FX main thread;
*/
Expand Down

0 comments on commit 909d28e

Please sign in to comment.