Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Open perspective
Open perspective [message #1081715] Wed, 07 August 2013 15:41 Go to next message
anthony palmieri is currently offline anthony palmieriFriend
Messages: 20
Registered: July 2013
Junior Member
Hello ,
I have created a processor which show perspective avaible in toolbar an it would change perspective . But i have 2 problems , my handler is not called despite my toolbar is avaible , i have created my processor like:

  @Execute
	  public void execute() {
		  
		  MToolBar toolbar = MMenuFactory.INSTANCE.createToolBar();
		  topTrimbar.getChildren().add(toolbar);
		  
		  
		  for(MPerspective perspective:stack.getChildren()){
			  MHandledToolItem perspectiveItem = MMenuFactory.INSTANCE.createHandledToolItem();
			  perspectiveItem.setLabel(perspective.getLabel());
			  perspectiveItem.setIconURI(perspective.getIconURI());
			  for(MCommand command :app.getCommands()){
				  if(command.getElementId().equals("com.itf.tvt.tool.datastore.gui.command.swich.perspective")){
					  System.out.println("on lui associe une commande");
					
					  perspectiveItem.setCommand(command);
					  System.out.println(command);
				  }
			  }	 
			 
			  toolbar.getChildren().add(perspectiveItem);
			  
		  }
		  
		 
	} 


and my handlers:
	@Inject
	EPartService partService;
	
	@Execute
	public void execute( MHandledToolItem perspectiveItem,@Named("com.itf.tvt.tool.datastore.gui.perspectivestack")
	MPerspectiveStack perspectivestack){
		System.out.println("switch perspective hander");
		for(MPerspective perspective: perspectivestack.getChildren()){
			if(perspective.getLabel().equals(perspectiveItem.getLabel())){
				System.out.println("on switch perspective");
				partService.switchPerspective(perspective);
			}
		}
		
	}


Another small question , how can put my toolbar in the right corner?

Thanks
Re: Open perspective [message #1082189 is a reply to message #1081715] Thu, 08 August 2013 07:53 Go to previous messageGo to next message
anthony palmieri is currently offline anthony palmieriFriend
Messages: 20
Registered: July 2013
Junior Member
My handler not execute because i can't inject MHandledToolITem but what is the correct way to have the MHandledITem Select ?
I have try to inject IServiceConstants with the active selection (@Named(IServiceConstants.ACTIVE_SELECTION)MHandledToolItem selection) but it was null.
Re: Open perspective [message #1082426 is a reply to message #1082189] Thu, 08 August 2013 14:52 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph CarrollFriend
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

How are you associating the handler with the command?

If you are trying to get the perspective id from the tool item, you should be using command parameters instead.

JD
Re: Open perspective [message #1082450 is a reply to message #1082426] Thu, 08 August 2013 15:22 Go to previous messageGo to next message
anthony palmieri is currently offline anthony palmieriFriend
Messages: 20
Registered: July 2013
Junior Member
Actually i create toolItem for all perspectives , their label are perspective label .
In my processor i'd try to inject ESelection service to change selection but ESelection was null :/ .
How use command parameters what ID shoud be correspond ? Is the same as processor ?
Thanks for your help
Re: Open perspective [message #1082600 is a reply to message #1082450] Thu, 08 August 2013 20:21 Go to previous messageGo to next message
Mateusz Malinowski is currently offline Mateusz MalinowskiFriend
Messages: 36
Registered: March 2013
Location: Bristol
Member
Why don't you add parameters to those items (btw, I think you should use MHandledToolItem when adding items to toolbar), which would be the perspectives' id? Then, when you execute the handler, you can inject command parameter and display a proper perspective.
Re: Open perspective [message #1082960 is a reply to message #1082600] Fri, 09 August 2013 09:10 Go to previous message
anthony palmieri is currently offline anthony palmieriFriend
Messages: 20
Registered: July 2013
Junior Member
Very very thanks you,I begin to understand the logic of e4 framwork .
So I've added my toolItem in parameter and it's work Very Happy
Previous Topic:Using e4 workbench model as basis for a web application
Next Topic:Reload application model at runtime
Goto Forum:
  


Current Time: Fri Mar 29 10:12:57 GMT 2024

Powered by FUDForum. Page generated in 0.04046 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top