Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Loading Perspective Problem(Problem with open SWT MessageBox when loading Perspective)
Loading Perspective Problem [message #646338] Thu, 23 December 2010 12:07
perlos  is currently offline perlos Friend
Messages: 4
Registered: August 2010
Junior Member

Hi everyone.

I have a problem when I showing Yes/No Dialog to user when is loading Perspective. I need show menu Item by perspectiveId. If i dont open messageBox, menu is correctly displayed, but when is showed, somehow perspectiveId is not set to open perspective but stay id parents perspective (perspective from witch is called a handler to open this one). At first i thing its delay or new window problem, but I try show message with Swing and Its fine. Problem is probably in SWT widget logic.

I give you some notes to better understanding.

I'm asking to user if they want to use dynamic grid (its own component to display data in grid from database) in moment when creating configuration of data source for grid, its same moment when showing gridView witch is part of showing perspective.

Hire is part of code where I asking
    @Override
    protected IGridContentSource<Subject> getGridContentSource() {
        final IAdressService adressService = CtxHolder.getService( IAdressService.class );
        max = adressService.getCountSubjekt( null );
 
        if ( max > step ) {
 
            final Shell shell = new Shell(PlatformUI.getWorkbench().getDisplay(), SWT.ON_TOP);
            MessageBox messageBox = new MessageBox( shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO );
 
            messageBox.setMessage( "Record is " + max + ", use dynamic grid?" );
            messageBox.setText( "Warning" );
            int response = messageBox.open();
 
            if ( response == SWT.YES )
                useDynamicGrid = true;
        }


code of my perspective
public class AdressPerspective implements IPerspectiveFactory {
 
    public static final String RCP_ID = "xxx.rcp.app.AdressPerspective";
 
    @Override
    public void createInitialLayout( IPageLayout layout ) {
        String editorArea = layout.getEditorArea();
        layout.setEditorAreaVisible( false );
 
        layout.addStandaloneView( ViewNavigacionTreeAdress.RCP_ID, false, IPageLayout.LEFT, 0.25f, editorArea );
        layout.getViewLayout( ViewNavigacionTreeAdress.RCP_ID ).setCloseable( false );
 
layout.addStandaloneView( SubjectGridView.RCP_ID, false, IPageLayout.TOP, 0.5f, editorArea );
 
layout.addStandaloneViewPlaceholder( AdressGridView.RCP_ID, IPageLayout.TOP, 0.5f, editorArea, false );
...


Hire is part of my plugin.xml
<plugin>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="xxx.adress.rcp.app.AdressPerspective"
            id="xxx.adress.rcp.app.AdressPerspective"
            name="Adress">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            allowMultiple="true"
            class="xxx.adress.rcp.view.ViewNavigacniStromAdress"
            id="xxx.rcp.adress.ViewNavigacniStromAdress"
            name="ViewNavigacniStromAdresar"
            restorable="true">
      </view>
      <view
            class="xxx.adress.rcp.view.SubjectGridView"
            id="xxx.adress.rcp.SubjectGridView"
            name="SubjectGridView"
            restorable="true">
      </view>
      <view
            class="xxx.adress.rcp.form.SubjectForm"
            id="xxx.adress.rcp.SubjectForm"
            name="SubjectForm"
            restorable="true">
      </view>
 
      <view
            class="xxx.adress.rcp.view.AdressGridView"
            id="xxx.adress.rcp.AdressGridView"
            name="AdressGridView"
            restorable="true">
      </view>
      <view
            class="xxx.adress.rcp.form.AdressForm"
            id="xxx.adress.rcp.AdressForm"
            name="AdressForm"
            restorable="true">
      </view>
   </extension>
   <extension
         point="xxx.modules">
      <moduleInformation
            class="xxx.adress.rcp.app.AdressInformation">
      </moduleInformation>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="data"
               label="Data"
               mnemonic="d">
            <command
                  commandId="adress-client.Import"
                  label="Import"
                  mnemonic="i"
                  style="push">
                  <visibleWhen checkEnabled="false">
                     <with variable="activeWorkbenchWindow.activePerspective">
                        <equals
                              value="xxx.adress.rcp.app.AdressPerspective"/>
               		 </with>
            	  </visibleWhen>
            </command>
         </menu>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="adress-client.Import"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="skeleton-client.scheme"
            sequence="M1+M2+I">
      </key>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            id="adress-client.Import"
            name="importDat">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="xxx.rcp.command.ImportDat"
            commandId="adress-client.Import">
         <enabledWhen>
            <with
                  variable="activeWorkbenchWindow.activePerspective">
               <equals
                     value="xxx.adress.rcp.app.AdressPerspective">
               </equals>
            </with>
         </enabledWhen>
      </handler>
   </extension>
</plugin>


If I active other perspective and go back, menu is correctly displayed. So i tried print id of active perspective (immediately after loading) in global handler activated by keys, and its print correct id. So i think problem is when is processing menu. Maybe in plugin.xml. But still I cant understand why it is happening when I show SWT messageBox, maybe its problem of shell when i showing message in new windows in moment when I want redraw other one. maybe some mishmash in focus

PLS someone HELP, if you have experience with it, or just have a tip. I'll be a glad

I'm sorry of my English, but is not my mother Language; sorry of part of code, I'd like give more, but i developing commercial product.

Now i probably have less time (Christmas & Holidays), so be patient and all of you Merry Christmas and New Year
Previous Topic:Flash does not work with 64-bit RCP application
Next Topic:How can i Pass Command parameters in a View before it is opened
Goto Forum:
  


Current Time: Thu Apr 25 15:57:36 GMT 2024

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

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

Back to the top