Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 72863 Details for
Bug 193318
Implement ToolItem.setMenu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Snippets patch v2
swt.snippets patch v2.txt (text/plain), 4.69 KB, created by
Nikolay Botev
on 2007-07-02 06:41:54 EDT
(
hide
)
Description:
Snippets patch v2
Filename:
MIME Type:
Creator:
Nikolay Botev
Created:
2007-07-02 06:41:54 EDT
Size:
4.69 KB
patch
obsolete
>Index: src/org/eclipse/swt/snippets/Snippet67.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet67.java,v >retrieving revision 1.3 >diff -u -r1.3 Snippet67.java >--- src/org/eclipse/swt/snippets/Snippet67.java 16 Sep 2005 19:24:37 -0000 1.3 >+++ src/org/eclipse/swt/snippets/Snippet67.java 2 Jul 2007 10:42:05 -0000 >@@ -32,17 +32,7 @@ > item.setText ("Item " + i); > } > final ToolItem item = new ToolItem (toolBar, SWT.DROP_DOWN); >- item.addListener (SWT.Selection, new Listener () { >- public void handleEvent (Event event) { >- if (event.detail == SWT.ARROW) { >- Rectangle rect = item.getBounds (); >- Point pt = new Point (rect.x, rect.y + rect.height); >- pt = toolBar.toDisplay (pt); >- menu.setLocation (pt.x, pt.y); >- menu.setVisible (true); >- } >- } >- }); >+ item.setMenu(menu); > toolBar.pack (); > shell.pack (); > shell.open (); >Index: src/org/eclipse/swt/snippets/Snippet67x.java >=================================================================== >RCS file: src/org/eclipse/swt/snippets/Snippet67x.java >diff -N src/org/eclipse/swt/snippets/Snippet67x.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/snippets/Snippet67x.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.snippets; >+ >+/* >+ * ToolBar example snippet: place a drop down menu in a tool bar >+ * >+ * For a list of all SWT example snippets see >+ * http://www.eclipse.org/swt/snippets/ >+ */ >+import java.util.Date; >+import java.util.Random; >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.events.MenuDetectEvent; >+import org.eclipse.swt.events.MenuDetectListener; >+import org.eclipse.swt.events.MouseAdapter; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.widgets.*; >+ >+public class Snippet67x { >+ >+public static void main (String [] args) { >+ final Display display = new Display (); >+ final Shell shell = new Shell (display); >+ final ToolBar toolBar = new ToolBar (shell, SWT.FLAT); >+ toolBar.addMouseListener(new MouseAdapter() { >+ >+ @Override >+ public void mouseDown(MouseEvent e) { >+ long time = e.time & 0xFFFFFFFFL; >+ System.out.println("mousedown " + new Date(time)); >+ } >+ >+ @Override >+ public void mouseDoubleClick(MouseEvent e) { >+ long time = e.time & 0xFFFFFFFFL; >+ System.out.println("mousedblclick"); >+ } >+ >+ @Override >+ public void mouseUp(MouseEvent e) { >+ long time = e.time & 0xFFFFFFFFL; >+ System.out.println("mouseup " + new Date(time)); >+ } >+ >+ }); >+ final Menu menu = new Menu (shell, SWT.POP_UP); >+ for (int i=0; i<8; i++) { >+ MenuItem item = new MenuItem (menu, SWT.PUSH); >+ item.setText ("Item " + i); >+ } >+ final ToolItem item = new ToolItem (toolBar, SWT.DROP_DOWN); >+ item.setText("My Item"); >+ item.setMenu(menu); >+ final ToolItem item2 = new ToolItem (toolBar, SWT.PUSH, 0); >+ item2.setText("theone"); >+ item2.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ System.out.println("sel"); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ System.out.println("default sel"); >+ } >+ >+ }); >+ item2.addMenuDetectListener(new MenuDetectListener(){ >+ >+ public void menuDetected(MenuDetectEvent event) { >+ if (false) { >+ event.doit = false; >+ } else { >+ if (item2.getMenu() != null) { >+ item2.getMenu().dispose(); >+ } >+ final Menu menu = new Menu (shell, SWT.POP_UP); >+ for (int i=0; i<8; i++) { >+ MenuItem item = new MenuItem (menu, SWT.PUSH); >+ item.setText ("Item " + new Random().nextInt(10)); >+ } >+ item2.setMenu(menu); >+ } >+ } >+ >+ }); >+ toolBar.pack (); >+ >+ Button btn = new Button(shell, SWT.PUSH); >+ btn.setLocation(120, 00); >+ btn.setText("Hello"); >+ btn.pack(); >+ >+ shell.pack (); >+ shell.open (); >+ while (!shell.isDisposed ()) { >+ if (!display.readAndDispatch ()) display.sleep (); >+ } >+ menu.dispose (); >+ display.dispose (); >+} >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 193318
:
71745
|
71746
|
71747
|
71748
|
71749
|
72862
|
72863
|
72930
|
72931
|
90591
|
90592
|
91606
|
91607