Changes between Version 3 and Version 4 of Grits_Classes_3_x_to_E4


Ignore:
Timestamp:
06/08/2016 06:44:20 PM (6 years ago)
Author:
shan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Grits_Classes_3_x_to_E4

    v3 v4  
    66==== __Fixing your plugin__ ====
    77===== __3.x plugins__ =====
    8 method ''ProjectExplorerView.getClickedEntry()'' has no counterpart for 3.x plugins but a possible option would be to replace with ''HandlerUtil.getActiveMenuSelection(event)'' in case of commands using project explorer's current selection.
     8''ProjectExplorerView.getClickedEntry()'' returned the last selected entry for the project explorer view , even if this view was not active.
     9- Replace ''ProjectExplorerView.getClickedEntry()'' with using ''DataModelHandler.getLastSelection()'' and getting entry from it
     10 - returns a StructuredSelection which can be used to retrieve the last selected entry from the data model
    911
    10 ''ProjectExplorerView.getClickedEntry()'' returned the last selected entry for the project explorer view , even if this view was not active. So far, e4 ProjectExplorerPart does not provide any such functionality but can be provided if needed. ProjectExplorerPart in e4 sets the current active selection as the selected entry(ies).
     12Example code :
     13{{{
    1114
    12 ===== __e4 plugins__ =====
    13 - should use ESelectionService (or ''@Named(IServiceConstants.ACTIVE_SELECTION)''). Below is an example code
    14 {{{
    15         // example 1
    16         @CanExecute
    17         public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) Object object)
     15        if(selectedEntry == null
     16                        && gritsDataModelService.getLastSelection().getFirstElement() instanceof Entry)
    1817        {
    19                 return object instanceof Entry && ((Entry) object).getProperty().isRenamable();
     18                selectedEntry = (Entry) gritsDataModelService.getLastSelection().getFirstElement();
    2019        }
    21 
    22         // example 2
    23         @CanExecute
    24         public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) Object object)
    25         {
    26                 return object instanceof Entry || object instanceof StructuredSelection;
    27         }
    28 
    2920}}}
    30 __Note__
    31 - When current selection is a single entry
    32  - selection is an object of type ''Entry'' (''org.grits.toolbox.core.datamodel.Entry'')
    33 - When current selection is a list of entries
    34  - selection is an object of type ''StructuredSelection'' (''org.eclipse.jface.viewers.StructuredSelection'')
    35 
    3621
    3722== Deprecated Classes and methods ==
     
    4429
    4530=== EditorHandler ===
    46 ==== __e4 plugins__ ====
    47 - should use '''IGritsUIService''' instead
     31- only for 3.x plugins