锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产综合AV在线观看,精品亚洲成a人片在线观看,亚洲色一区二区三区四区http://www.tkk7.com/cherishchen/category/23925.htmlThe art of living is to know when to hold fast and when to let gozh-cnWed, 18 Jul 2007 02:31:07 GMTWed, 18 Jul 2007 02:31:07 GMT60Top 10 Eclipse Hotkeyshttp://www.tkk7.com/cherishchen/archive/2007/07/15/130403.html鍑爮瑙傛搗鍑爮瑙傛搗Sun, 15 Jul 2007 09:46:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/07/15/130403.htmlhttp://www.tkk7.com/cherishchen/comments/130403.htmlhttp://www.tkk7.com/cherishchen/archive/2007/07/15/130403.html#Feedback1http://www.tkk7.com/cherishchen/comments/commentRss/130403.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/130403.htmlEclipse has lots and lots of hotkeys, but for daily work you need only a small subset. This are the hotkeys I consider to be the most important time savers:

Moving around

  • Ctrl+J 鈥?Incremental Search
  • Ctrl+Shift+T 鈥?Search a type, with search on typing. You can use only the upcase letters (e.g. type “MIL” to find MouseInputListener)
  • Ctrl+F6 鈥?Switch between last used files
  • F3 鈥?Open declaration
  • F4-- 鏌ョ湅綾諱綋緋?br>
  • Ctrl+Alt+H 鈥?Open Call Hierarchy

Editing

  • Ctrl+1 鈥?Quick Fix: press while cursor is positioned at member variable, parameter, selection, warnings, errors, …
  • Ctrl+Space 鈥?Context Assist: press after a ., or to use macros (for, while, sysout, …). Press in class-scope to automatically create method declarations.
  • Ctrl+Shift+O 鈥?Organize Imports
  • Ctrl+Shift+F 鈥?Reformat source
  • Alt+Shift+T 鈥?Show Refactor Quick Menu

In case these hotkeys are not enough or you have forgotten which hotkey does what, you can always press Ctrl+Shift+L to get a nice list of all the hotkeys.



鍑爮瑙傛搗 2007-07-15 17:46 鍙戣〃璇勮
]]>
Polish up your JFace-Viewer! Sorting a table by Tom Seidel 琛ㄦ牸鎺掑簭http://www.tkk7.com/cherishchen/archive/2007/07/05/128296.html鍑爮瑙傛搗鍑爮瑙傛搗Thu, 05 Jul 2007 03:48:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/07/05/128296.htmlhttp://www.tkk7.com/cherishchen/comments/128296.htmlhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128296.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/128296.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/128296.htmlhttp://www.javawiki.org/2006_01_18/tidy-up-your-jface-viewer-sorting-a-table/

Today I want to show how to add a sorter to your JFace-Table. The requirement is to sort descending und ascending by clicking on the TableColumn-Header.

The Viewer with an inital Sorting (Column ID)
The inital view with sorting

The ascending sorting after a click on the ID-Column header
The ascending sorting after a click on the ID-Column header.

JFace already provides sorting-functionality. We just have to provide something like an alogrithm to arrange the items. For that we implemented the CollectionSorter that uses the default Collator from ViewerSorter. Now look at the Sorter:

Initializing the Sorter with a default column

JAVA:
  1.  
  2. public class CollationSorter extends ViewerSorter {
  3.  
  4. private Map sortMap = new HashMap();
  5.  
  6. /**
  7. * Creates an instance of the sorter
  8. * @param tc0 the default sorter-column.
  9. */
  10. public CollationSorter(TableColumn defaultColumn) {
  11. setCurrentColumn(defaultColumn);
  12. }
  13.  
  14. /**
  15. * Pushs the current sortorder in a map which key is the
  16. * table-column.
  17. * @param column
  18. */
  19. public void pushSortCriteria(TableColumn column) {
  20. if (this.sortMap.get(column) == null) {
  21. this.sortMap.put(column,new Boolean(true));
  22. }
  23. else {
  24. boolean newSort = !((Boolean)this.sortMap.get(column)).booleanValue();
  25. this.sortMap.put(column,new Boolean(newSort));
  26. }
  27. }
  28.  
  29. /**
  30. * Asks for the current sort-order and inverts the sort-order
  31. * @param column the requested column
  32. * @return true if the sortIndex is descending, else false.
  33. */
  34. public boolean isDescending(TableColumn column) {
  35. boolean returnValue = true;
  36. if (this.sortMap.get(column) != null) {
  37. returnValue = ((Boolean)this.sortMap.get(column)).booleanValue();
  38. } else {
  39. pushSortCriteria(column);
  40. }
  41. return returnValue;
  42. }
  43.  
  44. private TableColumn currentColumn = null;
  45.  
  46. /* (non-Javadoc)
  47. * @see org.eclipse.jface.viewers.ViewerSorter#getCollator()
  48. */
  49. public int compare(Viewer viewer, Object obj1, Object obj2) {
  50. int rc = -1;
  51. // get the data
  52. AbstractBaseElement data1 = (AbstractBaseElement) obj1;
  53. AbstractBaseElement data2 = (AbstractBaseElement) obj2;
  54.  
  55. CollationKey key1 = null;
  56. CollationKey key2 = null;
  57.  
  58. if (this.currentColumn == ((TableViewer)viewer).getTable().getColumn(0)) {
  59. key1 = getCollator().getCollationKey(data1.getId());
  60. key2 = getCollator().getCollationKey(data2.getId());
  61.  
  62. }
  63. else if (this.currentColumn == ((TableViewer)viewer).getTable().getColumn(1)){
  64. key1 = getCollator().getCollationKey(data1.getName());
  65. key2 = getCollator().getCollationKey(data2.getName());
  66. }
  67. else if (this.currentColumn == ((TableViewer)viewer).getTable().getColumn(2)){
  68. key1 = getCollator().getCollationKey(data1.getDescription());
  69. key2 = getCollator().getCollationKey(data2.getDescription());
  70. }
  71. // replace null-strings with empty-strings
  72. if (key1 == null)
  73. key1 = getCollator().getCollationKey(""); //$NON-NLS-1$
  74.  
  75. if (key2 == null)
  76. key2 = getCollator().getCollationKey(""); //$NON-NLS-1$
  77.  
  78. if (isDescending(this.currentColumn)) {
  79. rc = key1.compareTo(key2);
  80. }
  81. else {
  82. rc = key2.compareTo(key1);
  83. }
  84. return rc;
  85. }
  86.  
  87. /**
  88. * Sets the sort column.
  89. * @param currentColumn The currentColumn to set.
  90. */
  91. public void setCurrentColumn(TableColumn currentColumn) {
  92. this.currentColumn  = currentColumn;
  93. pushSortCriteria(currentColumn);
  94. }
  95. }
  96.  

This sorter you can use everywhere, you just have to modify the Creation of the Collator-Keys.

Direction Indicator
This feature will be aviable in Eclipse 3.2

Download the JFace TableSorter Plugin (Requires Model-Plugin)
Download the JFace TableSorter RCP (source included)




鍑爮瑙傛搗 2007-07-05 11:48 鍙戣〃璇勮
]]>
Creating your own Perspective-Switcher - A first try by Tom Seidelhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128283.html鍑爮瑙傛搗鍑爮瑙傛搗Thu, 05 Jul 2007 03:10:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/07/05/128283.htmlhttp://www.tkk7.com/cherishchen/comments/128283.htmlhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128283.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/128283.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/128283.htmlhttp://www.richclient2.eu/2006_08_29/creating-your-own-perspective-switcher-a-first-try/

Do you know the Perspective-Bar? - And have you ever tried to integrate the perspecitve-bar in your RCP? If yes, did you suceed?

From my experience, perspectives are really useful for representing blocks of funtionality, something like a workflow or a set of requirements that are bundled. The perspective-bar is a very nice feature, necessary in the JDT but has a great disadvantage: The lack of integrity.

In my opinion perspectives have different goals: On the one hand they have to provide different user-roles different presentations of an application and on the other hand they have to bundle different views that are responsible for a special set of functionality.

Unfortunately the Eclipse-Framework doesn’t provide the approach to use this nice bar for different user-roles. Neither it’s possible to contribute to this bar nor to filter or hide perspectives. This is confusing, because everywhere you contribute your items, action, views, etc. to the workbench, but not in this special case. You have to reimplement the perspective-bar if you want to provide special behavior.

The art or reimplementing

The easiest way is to declare some actions, registering a perspective-listener and contributing the actions, depending from your business logic to a coolbar of the workbench-window. But that’s ugly, isn’t it?

I want to have a big and colored perspective-switcher (like in Lotus Notes) without implementing a new Presentation using the org.eclipse.ui.themes Extension-Point. But that’s not so easy, because Eclipse doesn’t have a special “Area”, something like a Composite where I can provide something, that’s always present.

A first try

I just had an idea. Using a standalone-View that is in all perspectives on the same place could simulate a fully customizable perspective-bar. Although it’s not a satisfying solution it’s the first step of a better fully controllable perspective-switcher.

persp_header.png

(The Example RCP with two Perspectives)

Download

Download the Perspective-Switcher Example as RCP (Source included - 9,3 Mbyte)
cvs_persp.gif CVS-Checkout (more info)

2 Comments »

  1. Well this could be achieved if you create your own ApplicationWorkbenchWindowAdvisor like I did it to create logo for my RCP application, but you can use it for this task too. You can find what I mean if you look at http://birosoft.zexxo.net/demo/UpdateDemo.htm
    . ApplicationLogo class in my case is a simple composite.

    Source example:

    package com.birosoft.workday.platform.intro;

    import org.eclipse.core.runtime.Preferences;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Point;
    import org.eclipse.swt.layout.FormAttachment;
    import org.eclipse.swt.layout.FormData;
    import org.eclipse.swt.layout.FormLayout;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Control;
    import org.eclipse.swt.widgets.CoolBar;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.ui.PlatformUI;
    import org.eclipse.ui.application.ActionBarAdvisor;
    import org.eclipse.ui.application.IActionBarConfigurer;
    import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
    import org.eclipse.ui.application.WorkbenchWindowAdvisor;
    import org.eclipse.ui.internal.WorkbenchWindow;
    import org.eclipse.ui.internal.progress.ProgressRegion;

    import com.birosoft.workday.platform.Activator;

    public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
    private Control logo;

    private Control toolbar;

    private Control page;

    private Control statusline;

    private ProgressRegion progressRegion;

    public ApplicationWorkbenchWindowAdvisor(
    IWorkbenchWindowConfigurer configurer) {
    super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(
    IActionBarConfigurer configurer) {
    return new ApplicationActionBarAdvisor(configurer);
    }

    public void preWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    Preferences prefs = Activator.getDefault().getPluginPreferences();
    if (prefs.getInt(Application.APP_WIN_WIDTH) == 0
    || prefs.getInt(Application.APP_WIN_HEIGHT) == 0) {
    configurer.setInitialSize(new Point(800, 600));
    } else {
    int width = prefs.getInt(Application.APP_WIN_WIDTH);
    int height = prefs.getInt(Application.APP_WIN_HEIGHT);
    configurer.setInitialSize(new Point(width, height));
    }
    configurer.setShowCoolBar(true);
    configurer.setShowStatusLine(true);
    configurer.setShowProgressIndicator(true);
    configurer.setTitle(”Birosoft Workday Client - ”
    + Application.getCurrentClient().toString() + ” (”
    + Application.getUsername() + “)”);
    }

    public void postWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    Preferences prefs = Activator.getDefault().getPluginPreferences();
    if (prefs.getInt(Application.APP_WIN_POS_X) == 0
    || prefs.getInt(Application.APP_WIN_POS_Y) == 0) {
    configurer.getWindow().getShell().setLocation(0, 0);
    } else {
    int x = prefs.getInt(Application.APP_WIN_POS_X);
    int y = prefs.getInt(Application.APP_WIN_POS_Y);
    configurer.getWindow().getShell().setLocation(x, y);
    }
    }

    @Override
    public void postWindowClose() {
    Preferences prefs = Activator.getDefault().getPluginPreferences();
    Point size = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
    .getShell().getSize();
    prefs.setValue(Application.APP_WIN_WIDTH, size.x);
    prefs.setValue(Application.APP_WIN_HEIGHT, size.y);
    Point position = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
    .getShell().getLocation();
    prefs.setValue(Application.APP_WIN_POS_X, position.x);
    prefs.setValue(Application.APP_WIN_POS_Y, position.y);
    super.postWindowClose();
    }

    public void createWindowContents(Shell shell) {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    Menu menu = configurer.createMenuBar();
    shell.setMenuBar(menu);
    FormLayout layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    shell.setLayout(layout);
    logo = new ApplicationLogo(
    getWindowConfigurer().getWindow().getShell(), SWT.NONE);
    Application.setApplicationLogo(((ApplicationLogo) logo));
    toolbar = configurer.createCoolBarControl(shell);
    ((CoolBar) toolbar).setLocked(true);
    page = configurer.createPageComposite(shell);
    statusline = configurer.createStatusLineControl(shell);
    createProgressIndicator(shell);

    // The layout method does the work of connecting the
    // controls together.
    layoutNormal();
    }

    private void layoutNormal() {
    // APPLOGO
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    logo.setLayoutData(data);
    // TOOLBAR
    data = new FormData();
    data.top = new FormAttachment(logo, 5, SWT.BOTTOM);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(page, 0, SWT.LEFT);
    toolbar.setLayoutData(data);
    // STATUS LINE
    data = new FormData();
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    statusline.setLayoutData(data);
    // PAGE CONTENTS
    data = new FormData();
    data.top = new FormAttachment(logo, 5, SWT.BOTTOM);
    // data.left = new FormAttachment(toolbar, 0, SWT.RIGHT);
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, -5);
    data.bottom = new FormAttachment(statusline);
    page.setLayoutData(data);
    layout();
    }

    private void layout() {
    getWindowConfigurer().getWindow().getShell().layout(true);
    if (page != null) {
    ((Composite) page).layout(true);
    }
    }

    /**
    * Create the progress indicator for the receiver.
    * @param shell the parent shell
    */
    private void createProgressIndicator(Shell shell) {
    if (getWindowConfigurer().getShowProgressIndicator()) {
    WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer()
    .getWindow();
    progressRegion = new ProgressRegion();
    progressRegion.createContents(shell, window);
    }
    }

    }

    Comment by Mickey 鈥?13. March 2007 @ 19:41

  2. Yes, you’re right.
    Thanks for your addition

    Comment by Tom Seidel 鈥?13. March 2007 @ 19:58




鍑爮瑙傛搗 2007-07-05 11:10 鍙戣〃璇勮
]]>
Printing with SWT - An Eclipse Editor Example by Tom Seidelhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128277.html鍑爮瑙傛搗鍑爮瑙傛搗Thu, 05 Jul 2007 02:55:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/07/05/128277.htmlhttp://www.tkk7.com/cherishchen/comments/128277.htmlhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128277.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/128277.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/128277.htmlhttp://www.richclient2.eu/2006_11_22/printing-with-swt-an-eclipse-editor-example/
Printing with SWT - An Eclipse Editor Example
22. November 2006
Tom Seidel @ 21:14

print.pngIf you build your own editor in the most cases you have to provide the capability to print its content. In addition you probably also have to print different business-logic that is not presented by an editor or viewpart. SWT gives you the possibility to generate printing jobs, what is a bit complex. With the Open-Source API PaperClips there is a possibility to generate data that can be sent to a printer in a very easy way. In addition it provides cool UI-Elments, e.g. a Print Preview. In this article is explained how to register a Print-Action as GlobalAction Handler, with formatting the data you want to print and a Print-Preview.

Global ActionHandler

At first you have to implement your custom editor. After your editor can be opened you have to set up a GlobalActionHandler and assign this handler with an Action. In the example there is an Action that justs open a wizard.

JAVA:
  1. PrintAction printAction = new PrintAction(this.model);
  2. site.getActionBars().setGlobalActionHandler(ActionFactory.PRINT.getId(),printAction);

print_bar.png
If the editor is activated the Print-button is enabled.

Integrating PaperClips

After you have added the paperclips libraries you can build printer-data with special formatting possibilites that are shipped with the API. In this example a simple list with a header and footer is generated. A big benefit is the runtime-generation of the data you want to print. If you see the Wizard you have the possibility to select special properties of your business-data. The preview will be actualized every time your selection changes.

print_wizard.png

If you click on the "Finish" Button the system-specific print dialog will be opened and a print-job is queued.

JAVA:
  1. PrintDialog dialog = new PrintDialog(Display.getDefault().getActiveShell(), SWT.NONE);
  2. PrinterData printerData = dialog.open ();
  3. if (printerData != null) {
  4.     PaperClips.print(PrintingJob.this.jobDelegate, printerData);
  5. } else {
  6. canceled = true;
  7. }

Download

Download the Print Example as RCP (Source included - 10 Mbyte)
cvs_persp.gif CVS-Checkout (more info)



鍑爮瑙傛搗 2007-07-05 10:55 鍙戣〃璇勮
]]>
Customizing the UI in small RCP Projects by Tom Seidelhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128275.html鍑爮瑙傛搗鍑爮瑙傛搗Thu, 05 Jul 2007 02:52:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/07/05/128275.htmlhttp://www.tkk7.com/cherishchen/comments/128275.htmlhttp://www.tkk7.com/cherishchen/archive/2007/07/05/128275.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/128275.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/128275.htmlhttp://www.richclient2.eu/2007_04_16/customizing-the-ui-in-small-rcp-projects/

The presentation framework provided by Eclipse gives you the possibility to customize the UI and the behavior of graphical elements. A good example for UI-customization is the Lotus Nodes Client “Hannover”. But what do you do If you don’t have the budget, time or the skill set to implement such an excessive UI-customization like the guys from “Hannover”? Especially for small RCP applications with a handful views and the wish that your product should not look like a “typical Eclipse Client” it is probably better to use alternative possibilities to create an individual looking RCP. The following article will give an example how to customize your UI easily without using any special framework or extension-point.

Product branding with Eclipse RCP

Since it is possible to build RCP applications with Eclipse, the possibilities to give your application a more personal touch through the PDE have also increased. Typical elements are for example splash-screens, program-icons or welcome-screens. But in the most cases that is not enough. The customer often has a corporate identity with logos, special colors, fonts,etc. which must be also integrated within the application.

Step 1: Implementing a banner with integrated Toolbar

An often required UI-element is a banner on top of your views with a company logo or the name of your product and a toolbar where the key features of the application are accessible. This is possible if your overwrite the method WorkbenchWindowAdvisor#createWindowContents(Shell shell). Eclipse layouts and creates typical elements of your workbench like the Coolbar, MenuBar and the Statusline. If you overwrite this method you have the freedom to arrange the content of your window but you also have to care for the correct initialization of all UI-elements needed. This step is very effective and your application looks much more personalized (see picture).

A part of the banner with integrated toolbar
Part of the banner with a two-buttons toolbar

Step 2: Implement your own Viewpart-Title Area

The most characteristic element to indicate a “typical Eclipse application” is the look of a viewpart with the curved title and the appended action bar.
With the form enhancements in Eclipse 3.3M5 and the features with custom titles a new and interesting possibility is provided to use this feature also as title in your viewparts. You just have to add the views as standalone views to your perspective layout and implement the title in your viewpart. With the ability to customize the colors (see org.eclipse.ui.forms.FormColors) you can show up views that nobody would associate with a “typical Eclipse application” (see Image).

A customized form title as viewpart-title
Viewparts with Form-Headings and Actionbar (on the right: with Subheader)

Step 3: Move your Progress Indicator

This is an optional step, depending on your requirements. In nearly every application you have jobs for background-processes where you need a progress indicator to give the user a feedback about the job-status. The default-location of the progress indicator is on the bottom of your application window outside the page contents. It doesn’t make sense in small applications, that this little, but important widget needs the whole bottom of your workbench-window, especially if you don’t have a status-bar. So why not place the progress-bar somewhere else, e.g. in a viewpart?- In spite of the “Discouraged Access Warning” you can implement the org.eclipse.ui.internal.progress.ProgressRegion wherever you want (see picture).

Progress region in a viewpart
Progress Region in a viewpart

Example

I have implemented a small RCP application, which uses the mentioned UI-customizations (see picture). Check it out (or download) to see, how easyily an individual UI can be implemented. But remember: The discussed issues can be realized only for a special type of RCPs. If you have to customize your “Next generation IDE” with 100 views and editors, please use the presentation framework.

The Example Application
The example application

Conclusion

There are many ways to customize your Eclipse RCP Application. Based on the special requirements of your personal application you have to choose the best toolkit to reach your goal.
Maybe you also have a simple way to customize your RCP product. Let me know.

Downloads

Download the UI Customization Example as RCP (Source included - 11 Mbyte)
cvs_persp.gif CVS-Checkout (more info)

2 Comments »

  1. Note that overriding the WorkbenchWindowAdvisor#createWindowContents(Shell shell) method has some disadvantages, as discussed in this bug[1].

    [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=73821

    Comment by Kris 鈥?16. April 2007 @ 17:13

  2. And overriding the WorkbenchWindowAdvisor#createWindowContents(Shell shell) does not allow to use “Welcome” view because your banner will be always on top. In this case you should to hide banner manually because eclipse api hides only coolbar.

    Comment by MByte 鈥?17. April 2007 @ 08:37




鍑爮瑙傛搗 2007-07-05 10:52 鍙戣〃璇勮
]]>
Swt jface 鎻愪緵浜唙irtual table 鍜?virtual treehttp://www.tkk7.com/cherishchen/archive/2007/06/26/126271.html鍑爮瑙傛搗鍑爮瑙傛搗Tue, 26 Jun 2007 02:13:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/06/26/126271.htmlhttp://www.tkk7.com/cherishchen/comments/126271.htmlhttp://www.tkk7.com/cherishchen/archive/2007/06/26/126271.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/126271.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/126271.htmlTableViewer浣跨敤virtual table

浣跨敤铏氭嫙琛ㄥ拰铏氭嫙鏍戠殑紜彲浠ュ緢澶х▼搴﹀湴鎻愪緵UI鐣岄潰鐨勬ц兘,灝ゅ叾鏄湪澶ф暟鎹噺鐨勬儏鍐典笅錛屽浜嶵ableViewer浣跨敤铏氭嫙琛ㄥ緢綆鍗曪紝鍙鍦ㄥ垱寤篢ableViewer鐨勬椂鍊欐寚瀹歋WT.VIRTUAL鍗沖彲
tableViewer = new TableViewer(container, SWT.FULL_SELECTION
| SWT.BORDER | SWT.HIDE_SELECTION|SWT.VIRTUAL);

鍦ㄤ互鍓嶇殑鐗堟湰錛?span style="color: #000000;">TableViewer瑕佷嬌鐢?/span>virtual table鐨勬椂鍊欙紝闇瑕佸疄鐜癐LazyContentProvider鎺ュ彛錛屼絾鏄洰鍓嶅ソ鍍忔槸涓嶇敤浜嗭紝涓嬮潰闄勪笂涓や釜eclipse紺懼尯鎻愪緵鐨勪緥瀛?br>
Snippet030VirtualLazyTableViewer.java,浣跨敤鐨勬槸瀹炵幇ILazyContentProvider鎺ュ彛
import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* A simple TableViewer to demonstrate usage of an ILazyContentProvider. You can compare this snippet to the Snippet029VirtualTableViewer
* to see the small but needed difference.
*
*
@author Tom Schindl <tom.schindl@bestsolution.at>
*
*/
public class Snippet030VirtualLazyTableViewer {
private class MyContentProvider implements IStructuredContentProvider, ILazyContentProvider {
private TableViewer viewer;
private MyModel[] elements;

public MyContentProvider(TableViewer viewer) {
this.viewer = viewer;
}

/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return elements;
}

/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {

}

/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.elements = (MyModel[])newInput;
}

public void updateElement(int index) {
viewer.replace(elements[index], index);
}

}

public class MyModel {
public int counter;

public MyModel(int counter) {
this.counter = counter;
}

public String toString() {
return "Item " + this.counter;
}
}

public Snippet030VirtualLazyTableViewer(Shell shell) {
final TableViewer v = new TableViewer(shell,SWT.VIRTUAL);
v.setLabelProvider(
new LabelProvider());
v.setContentProvider(
new MyContentProvider(v));
v.setUseHashlookup(
true);
MyModel[] model
= createModel();
v.setInput(model);
v.setItemCount(model.length);
// This is the difference when using a ILazyContentProvider

v.getTable().setLinesVisible(
true);
}

private MyModel[] createModel() {
MyModel[] elements
= new MyModel[10000];

for( int i = 0; i < 10000; i++ ) {
elements[i]
= new MyModel(i);
}

return elements;
}

/**
*
@param args
*/
public static void main(String[] args) {
Display display
= new Display ();
Shell shell
= new Shell(display);
shell.setLayout(
new FillLayout());
new Snippet030VirtualLazyTableViewer(shell);
shell.open ();

while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}

display.dispose ();

}

}

Snippet029VirtualTableViewer.java 鏇村姞鏂逛究錛岀洿鎺ユ寚瀹歋WT.VIRTUAL鍗沖彲
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* A simple TableViewer to demonstrate the usage of a standard content provider
* with a virtual table
*
*
@author Tom Schindl <tom.schindl@bestsolution.at>
*
*/
public class Snippet029VirtualTableViewer {
private class MyContentProvider implements IStructuredContentProvider {
private MyModel[] elements;

/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return elements;
}

/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {

}

/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.elements = (MyModel[]) newInput;
}
}

public class MyModel {
public int counter;

public MyModel(int counter) {
this.counter = counter;
}

public String toString() {
return "Item " + this.counter;
}
}

public Snippet029VirtualTableViewer(Shell shell) {
long time1=System.currentTimeMillis();
final TableViewer v = new TableViewer(shell,SWT.VIRTUAL);
v.setLabelProvider(
new LabelProvider());
v.setContentProvider(
new MyContentProvider());
v.setUseHashlookup(
true);
MyModel[] model
= createModel();
v.setInput(model);

v.getTable().setLinesVisible(
true);
System.out.println(System.currentTimeMillis()
-time1);
}

private MyModel[] createModel() {
MyModel[] elements
= new MyModel[10000];

for (int i = 0; i < 10000; i++) {
elements[i]
= new MyModel(i);
}

return elements;
}

/**
*
@param args
*/
public static void main(String[] args) {
Display display
= new Display();
Shell shell
= new Shell(display);
shell.setLayout(
new FillLayout());
new Snippet029VirtualTableViewer(shell);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();

}

}




鍑爮瑙傛搗 2007-06-26 10:13 鍙戣〃璇勮
]]>
eclipse rcp 鐩稿叧鐨勮祫鏂?/title><link>http://www.tkk7.com/cherishchen/archive/2007/06/25/126149.html</link><dc:creator>鍑爮瑙傛搗</dc:creator><author>鍑爮瑙傛搗</author><pubDate>Mon, 25 Jun 2007 08:41:00 GMT</pubDate><guid>http://www.tkk7.com/cherishchen/archive/2007/06/25/126149.html</guid><wfw:comment>http://www.tkk7.com/cherishchen/comments/126149.html</wfw:comment><comments>http://www.tkk7.com/cherishchen/archive/2007/06/25/126149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/cherishchen/comments/commentRss/126149.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/cherishchen/services/trackbacks/126149.html</trackback:ping><description><![CDATA[<div style="margin-left: 15px; margin-top: 1px;"> <h2><a title="姘鎬箙閾炬帴錛歟clipse rcp 鐩稿叧鐨勮祫鏂?> eclipse rcp 鐩稿叧鐨勮祫鏂?/a> </h2> </div> 鏉冨▉浠嬬粛RCP浣撶郴緇撴瀯鐨勬枃绔?br> <span> <a >http://www.eclipse.org/articles/Article-Plug-in-architecture/plugin_architecture.html</a></span><br> <br> 鍏充簬eclipse鎻掍歡寮鍙戠被瑁呰澆鐨勮В鍐蟲柟娉曪紝涓瀹氳濂藉ソ鐞嗚В鐨?br> <span> <a >http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements</a></span><br> <br> 鍏充簬Progress Monitors鍜宩ob鐨勬枃绔? <p>FAQ Can I make a job run in the UI thread?<br> </p> <span> <a >http://wiki.eclipse.org/index.php/FAQ_Can_I_make_a_job_run_in_the_UI_thread%3F</a></span><br> <br> <br> <p>How to Correctly and Uniformly Use Progress Monitors<br> </p> <span> <a >http://www.eclipse.org/articles/Article-Progress-Monitors/article.html</a></span><br> <br> <p>FAQ Why do I get an invalid thread access exception?</p> <span> <a >http://wiki.eclipse.org/index.php/FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F</a></span><br> <br> <br> <br> <p>FAQ Why should I use the new progress service?</p> <span> <a >http://wiki.eclipse.org/index.php/FAQ_Why_should_I_use_the_new_progress_service%3F</a><br> <br> <br> </span> <p>FAQ How do I switch from using a Progress dialog to the Progress view?</p> <br> <span><span><a >http://wiki.eclipse.org/index.php/FAQ_How_do_I_switch_from_using_a_Progress_dialog_to_the_Progress_view%3F</a></span></span> <img src ="http://www.tkk7.com/cherishchen/aggbug/126149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/cherishchen/" target="_blank">鍑爮瑙傛搗</a> 2007-06-25 16:41 <a href="http://www.tkk7.com/cherishchen/archive/2007/06/25/126149.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>eclipse 鐨刡uddy-registerhttp://www.tkk7.com/cherishchen/archive/2007/06/25/126138.html鍑爮瑙傛搗鍑爮瑙傛搗Mon, 25 Jun 2007 08:29:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/06/25/126138.htmlhttp://www.tkk7.com/cherishchen/comments/126138.htmlhttp://www.tkk7.com/cherishchen/archive/2007/06/25/126138.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/126138.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/126138.html錛?錛夊湪鎻掍歡A鐨凪ANIFEST.MF鏂囦歡鍐呮坊鍔?br>
Eclipse-BuddyPolicy: registered

錛?錛夊湪鎻掍歡B鐨凪ANIFEST.MF鏂囦歡鍐呮坊鍔?br>
Eclipse-RegisterBuddy: A



鍑爮瑙傛搗 2007-06-25 16:29 鍙戣〃璇勮
]]>
寰楀埌eclipse rcp plugin 鍐呯洰褰曟枃浠剁粷瀵硅礬寰勭殑鏂規硶http://www.tkk7.com/cherishchen/archive/2007/06/25/126129.html鍑爮瑙傛搗鍑爮瑙傛搗Mon, 25 Jun 2007 07:54:00 GMThttp://www.tkk7.com/cherishchen/archive/2007/06/25/126129.htmlhttp://www.tkk7.com/cherishchen/comments/126129.htmlhttp://www.tkk7.com/cherishchen/archive/2007/06/25/126129.html#Feedback0http://www.tkk7.com/cherishchen/comments/commentRss/126129.htmlhttp://www.tkk7.com/cherishchen/services/trackbacks/126129.htmlimport java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;

import com.work.base.exception.DataException;
import com.work.view.Activator;

public class BundlePathUtil {

    
public static String getRealPath(String bundleID, String entry)
            
throws DataException {
        URL urlentry;
        String strEntry;
        
try {
            Bundle bundle 
= Platform.getBundle(bundleID);
            
if (bundle==null)
                
throw new DataException("璇鋒鏌ユ枃浠剁殑璺緞",new NullPointerException());
            
// get path URL
            urlentry = bundle.getEntry(entry);
            
if (urlentry==null)
                
throw new DataException("璇鋒鏌ユ枃浠剁殑璺緞",new NullPointerException());
            strEntry 
= FileLocator.toFileURL(urlentry).getPath();
        } 
catch (IOException e1) {
            
throw new DataException("璇鋒鏌ユ枃浠剁殑璺緞", e1);
        }
        
return strEntry;
    }
    
    
public static String getPluginPath(){        
        
return Activator.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath();
        
    }   
    
}

鍙﹀錛岃幏鍙栨彃浠?rcp 鐨?/span>workspace鐨勮礬寰勶細

Platform.getInstanceLocation().getURL().getPath()

 



鍑爮瑙傛搗 2007-06-25 15:54 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 久久国产亚洲高清观看| 另类专区另类专区亚洲| 天天看免费高清影视| 久久精品亚洲日本波多野结衣 | 免费专区丝袜脚调教视频| 中文有码亚洲制服av片| 精品国产人成亚洲区| 91av视频免费在线观看| 亚洲av无码专区在线观看下载| 久久亚洲国产精品五月天婷| 精品女同一区二区三区免费站| 久久久久亚洲精品无码网址色欲 | 你懂的免费在线观看| 亚洲丝袜中文字幕| 久久久久亚洲AV成人网人人软件| 精品女同一区二区三区免费站| g0g0人体全免费高清大胆视频| 亚洲中文无码线在线观看| 亚洲日本韩国在线| 2021久久精品免费观看| 国产精品高清免费网站| 亚洲欧美自偷自拍另类视| 亚洲成熟xxxxx电影| 亚洲国产精品不卡毛片a在线| 99在线视频免费观看视频| 成人无码精品1区2区3区免费看 | 4399影视免费观看高清直播| 无遮挡免费一区二区三区 | 久草免费福利在线| 亚洲精品乱码久久久久久蜜桃图片| 亚洲av永久无码精品秋霞电影影院 | 国产A∨免费精品视频| 中日韩亚洲人成无码网站| 亚洲视频2020| 亚洲综合无码精品一区二区三区 | 亚洲熟妇av一区二区三区漫画| 最新69国产成人精品免费视频动漫| 久久国产免费一区| 久久久受www免费人成| 处破女第一次亚洲18分钟| 亚洲一级视频在线观看|