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 179846 Details for
Bug 326538
Examples Demo: Add Dialog page and category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to add a dialog page to the examples demo
patch_326538.txt (text/plain), 14.40 KB, created by
Artur Kronenberg
on 2010-09-29 09:54:14 EDT
(
hide
)
Description:
Patch to add a dialog page to the examples demo
Filename:
MIME Type:
Creator:
Artur Kronenberg
Created:
2010-09-29 09:54:14 EDT
Size:
14.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.examples.pages >Index: description/dialogs.html >=================================================================== >RCS file: description/dialogs.html >diff -N description/dialogs.html >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ description/dialogs.html 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+<html> >+<head> >+<link rel="stylesheet" type="text/css" href="default.css" media="screen" /> >+</head> >+<body> >+ >+ <h2>Dialogs</h2> >+ >+ <h3>Selection dialogs</h3> >+ <p> >+ RAP provides the user with a series of dialogs that should help selecting things. >+ Dialogs are easy to use and adapt to every object. All the user has to do is provide >+ those objects and the necessary content and label providers. >+ </p> >+ >+ <h3>Message Dialogs</h3> >+ <p> >+ Message dialogs provide a simple way of displaying information to the user as well as getting simple >+ <code>true</code> or <code>false</code> user input. The class <code>MessageDialog</code> provides easy >+ to use static API for the following use cases: >+ <UL> >+ <LI><code>MessageDialog.WARNING</code> >+ <LI><code>MessageDialog.ERROR</code> >+ <LI><code>MessageDialog.INFORMATION</code> >+ <LI><code>MessageDialog.QUESTION</code> >+ <LI><code>MessageDialog.CONFIRM</code> >+ </UL> >+ </p> >+</body> >+</html> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.examples.pages/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 4 May 2010 09:29:14 -0000 1.3 >+++ plugin.xml 29 Sep 2010 13:52:13 -0000 >@@ -86,6 +86,16 @@ > description="description/theming.html" > name="Theming"> > </page> >+ <category >+ id="dialogs" >+ name="Dialogs"> >+ </category> >+ <page >+ category="dialogs" >+ class="org.eclipse.rap.examples.pages.DialogExample" >+ description="description/dialogs.html" >+ name="Selection and Message Dialogs"> >+ </page> > </extension> > <extension > point="org.eclipse.equinox.http.registry.resources"> >Index: src/org/eclipse/rap/examples/pages/DialogExample.java >=================================================================== >RCS file: src/org/eclipse/rap/examples/pages/DialogExample.java >diff -N src/org/eclipse/rap/examples/pages/DialogExample.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rap/examples/pages/DialogExample.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,318 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 EclipseSource 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: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.rap.examples.pages; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.jface.dialogs.*; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.rap.examples.IExamplePage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.dialogs.*; >+ >+public class DialogExample implements IExamplePage { >+ >+ private final ArrayContentProvider arrayContentProvider; >+ private final ITreeContentProvider treeContentProvider; >+ private final LabelProvider labelProvider; >+ private final String[] input; >+ >+ public DialogExample() { >+ this.arrayContentProvider = ArrayContentProvider.getInstance(); >+ this.treeContentProvider = new TreeContenProvider(); >+ this.labelProvider = new LabelProvider(); >+ this.input = new String[]{ >+ "op1", "op2", "op3", "op4", "op5", "op6" >+ }; >+ } >+ >+ public void createControl( final Composite parent ) { >+ parent.setLayout( new GridLayout() ); >+ Composite selectionGroup = createGroup( parent, "Selection Dialogs:" ); >+ createListSelection( selectionGroup ); >+ createListDialog( selectionGroup ); >+ createTreeSelection( selectionGroup ); >+ createCheckedTreeSelection( selectionGroup ); >+ createTwoPaneElementSelector( selectionGroup ); >+ createTypeFilteringDialog( selectionGroup ); >+ Composite messageDialogGroup = createGroup( parent, "Dialogs:" ); >+ createTitleAreaDialog( messageDialogGroup ); >+ createMessageDialogs( messageDialogGroup ); >+ } >+ >+ private void createMessageDialogs( final Composite parent ) { >+ createMessageDialg( parent, >+ MessageDialog.CONFIRM, >+ "Confirm Dialog", >+ "Confirm Dialog Title", >+ "Confirm message" ); >+ createMessageDialg( parent, >+ MessageDialog.ERROR, >+ "Error Dialog", >+ "Error Dialog Title", >+ "Error message" ); >+ createMessageDialg( parent, >+ MessageDialog.INFORMATION, >+ "Information Dialog", >+ "Information Dialog Title", >+ "Information message" ); >+ createMessageDialg( parent, >+ MessageDialog.QUESTION, >+ "Question Dialog", >+ "Question Dialog Title", >+ "Question message" ); >+ createMessageDialg( parent, >+ MessageDialog.QUESTION_WITH_CANCEL, >+ "Question/Cancel Dialog", >+ "Question Dialog Title", >+ "Question message" ); >+ createMessageDialg( parent, >+ MessageDialog.WARNING, >+ "Warning Dialog", >+ "Warning Dialog Title", >+ "Warning message" ); >+ } >+ >+ private void createMessageDialg( final Composite parent, >+ final int type, >+ final String buttonLabel, >+ final String title, >+ final String message ) >+ { >+ Button button = createButton( parent, buttonLabel ); >+ final Text text = createText( parent ); >+ button.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent e ) { >+ boolean result = MessageDialog.open( type, >+ parent.getShell(), >+ title, >+ message, >+ SWT.NONE ); >+ text.setText( result ? "Ok clicked" : "Cancel clicked" ); >+ } >+ } ); >+ } >+ >+ private void createTitleAreaDialog( final Composite parent ) { >+ Button titleAreaDialog = createButton( parent, "Title area dialog" ); >+ final Text text = createText( parent ); >+ titleAreaDialog.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent e ) { >+ TitleAreaDialog dialog = new TitleAreaDialog( parent.getShell() ); >+ dialog.create(); >+ dialog.setTitle( "Title area dialog - Title" ); >+ dialog.setMessage( "Choose from the list - Message" ); >+ Display display = parent.getDisplay(); >+ dialog.setTitleImage( display.getSystemImage( SWT.ICON_QUESTION ) ); >+ if( dialog.open() == Dialog.OK ) { >+ text.setText( "Ok clicked" ); >+ } >+ } >+ } ); >+ } >+ >+ private void createTypeFilteringDialog( final Composite parent ) { >+ TypeFilteringDialog dialog = new TypeFilteringDialog( parent.getShell(), new ArrayList() ); >+ dialog.setTitle( "Type filtering dialog" ); >+ dialog.setMessage( "Choose from the list" ); >+ createSelectionDialog( parent, dialog, "Type Filtering Dialog" ); >+ } >+ >+ private void createTwoPaneElementSelector( final Composite parent ) { >+ TwoPaneElementSelector dialog = new TwoPaneElementSelector( parent.getShell(), >+ labelProvider, >+ labelProvider ); >+ dialog.setElements( input ); >+ dialog.setTitle( "Two Pane Element Selector" ); >+ dialog.setMessage( "Choose from the list" ); >+ createSelectionDialog( parent, dialog, "Two Pane Selector Dialog" ); >+ } >+ >+ private void createListDialog( final Composite parent ) { >+ ListDialog dialog = new ListDialog( parent.getShell() ); >+ dialog.setInput( input ); >+ dialog.setContentProvider( arrayContentProvider ); >+ dialog.setLabelProvider( labelProvider ); >+ dialog.setTitle( "List Dialog" ); >+ dialog.setMessage( "Choose from the list" ); >+ createSelectionDialog( parent, dialog, "List Dialog" ); >+ } >+ >+ private void createSelectionDialog( final Composite parent, >+ final SelectionDialog dialog, >+ final String buttonLabel ) >+ { >+ Button button = createButton( parent, buttonLabel ); >+ final Text text = createText( parent ); >+ button.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( SelectionEvent e ) { >+ if( dialog.open() == Dialog.OK ) { >+ text.setText( getResultString( dialog.getResult() ) ); >+ } else { >+ text.setText( "Cancel clicked" ); >+ } >+ } >+ } ); >+ } >+ >+ private void createTreeSelection( final Composite parent ) { >+ ElementTreeSelectionDialog dialog >+ = new ElementTreeSelectionDialog( parent.getShell(), >+ labelProvider, >+ treeContentProvider ); >+ dialog.setInput( getTreeInput() ); >+ dialog.setTitle( "Tree Selection Dialog" ); >+ dialog.setMessage( "Choose from the tree" ); >+ createSelectionDialog( parent, dialog, "Tree Selection Dialog" ); >+ } >+ >+ private void createCheckedTreeSelection( final Composite parent ) { >+ CheckedTreeSelectionDialog dialog >+ = new CheckedTreeSelectionDialog( parent.getShell(), >+ labelProvider, >+ treeContentProvider ); >+ dialog.setInput( getTreeInput() ); >+ dialog.setTitle( "Checked Tree Selection Dialog" ); >+ dialog.setMessage( "Choose from the tree" ); >+ createSelectionDialog( parent, dialog, "Checked Tree Selection Dialog" ); >+ } >+ >+ private Object getTreeInput() { >+ TreeObject parent = new TreeObject( "Parent" ); >+ TreeObject parent2 = new TreeObject( "Parent 2" ); >+ TreeObject parent3 = new TreeObject( "Parent 3" ); >+ parent.putChild( parent2 ); >+ parent.putChild( parent3 ); >+ for( int i = 0; i < 4; i++ ) { >+ TreeObject childParent2 = new TreeObject( "Child" + i ); >+ parent2.putChild( childParent2 ); >+ TreeObject childParent3 = new TreeObject( "Child" + i ); >+ parent3.putChild( childParent3 ); >+ } >+ return parent; >+ } >+ >+ private void createListSelection( final Composite parent ) { >+ String message = "Select something:"; >+ ListSelectionDialog dialog = new ListSelectionDialog( parent.getShell(), >+ input, >+ arrayContentProvider, >+ labelProvider, >+ message ); >+ dialog.setTitle( "List selection dialog" ); >+ createSelectionDialog( parent, dialog, "List Selection Dialog" ); >+ } >+ >+ private Button createButton( final Composite parent, final String label ) { >+ Button button = new Button( parent, SWT.PUSH ); >+ button.setText( label ); >+ GridData gridData = new GridData( SWT.FILL, SWT.FILL, false, false ); >+ gridData.widthHint = 200; >+ button.setLayoutData( gridData ); >+ return button; >+ } >+ >+ private Text createText( final Composite parent ) { >+ Text text = new Text( parent, SWT.BORDER ); >+ text.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) ); >+ text.setEditable( false ); >+ return text; >+ } >+ >+ private Composite createGroup( final Composite parent, >+ final String groupName ) >+ { >+ Group group = new Group( parent, SWT.NONE ); >+ group.setText( groupName ); >+ GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, false ); >+ group.setLayoutData( gridData ); >+ group.setLayout( new GridLayout( 2, false ) ); >+ return group; >+ } >+ >+ private String getResultString( final Object[] object ) { >+ String result = ""; >+ if( object != null ) { >+ for( int i = 0; i < object.length; i++ ) { >+ result += object[ i ].toString() + " "; >+ } >+ } >+ return result; >+ } >+ >+ private class TreeObject { >+ >+ private final String name; >+ private java.util.List children; >+ private TreeObject parent; >+ >+ public TreeObject( final String name ) { >+ this.name = name; >+ this.children = new ArrayList(); >+ } >+ >+ public String toString() { >+ return name; >+ } >+ >+ public void putChild( final TreeObject treeObject ) { >+ children.add( treeObject ); >+ treeObject.setParent( this ); >+ } >+ >+ public Object[] getChildren() { >+ return children.toArray(); >+ } >+ >+ public void setParent( final TreeObject parent ) { >+ this.parent = parent; >+ } >+ >+ public TreeObject getParent() { >+ return this.parent; >+ } >+ } >+ >+ private class TreeContenProvider implements ITreeContentProvider { >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged( final Viewer viewer, >+ final Object oldInput, >+ final Object newInput ) >+ { >+ } >+ >+ public Object[] getElements( final Object inputElement ) { >+ return ( ( TreeObject )inputElement ).getChildren(); >+ } >+ >+ public Object[] getChildren( final Object parentElement ) { >+ return ( ( TreeObject )parentElement ).getChildren(); >+ } >+ >+ public Object getParent( final Object element ) { >+ return ( ( TreeObject )element ).getParent(); >+ } >+ >+ public boolean hasChildren( final Object element ) { >+ return ( ( TreeObject )element ).getChildren().length > 0; >+ } >+ } >+}
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 326538
: 179846 |
179847