1. To add Action
in Menu, we need to create Action as well as Menu for this View. To do that, we
need to modify the SampleView.java
file. Open the SampleView.java file and add the given code in "createPartControl" method:
2. Then create these four private method in the same java file and modify it with the give below code.
3. Add two icon image files named as : " fields_co.gif
" and " alphab_sort_co.gif
" in "icons" folder.
private Action filterAction;
private SampleFilter vFilter;
private Action sortAction;
4. Create a new Java class named as
"SampleFilter" in "samplecode.source.view" package folder
with extends "org.eclipse.jface.viewers.ViewerFilter" super class.
5. Modify this
java file with the following below code snippet:
6. Create another
java class named as "SampleViwerSorter" within "samplecode.source.view"
package and extends "org.eclipse.jface.viewers.ViewerSorter" super
class.
7. Modify this
class with the following code snippet:
8. Modify the constructor
of the SampleView class with below given code snippet:
9. Run the project
and see the effect of the newly created two buttons in view toolbar.
- Sort button
sorting all folders in alphabetical order.
No comments:
Post a Comment