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 77572 Details for
Bug 202055
[WorkbenchLauncher] Possibility to quit a splash handler with the standard org.eclipse.ui.PlatformUI exit codes.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Interactive Splash Handler Template
InteractiveSplashHandler.java (text/plain), 6.82 KB, created by
Stefan Lötscher
on 2007-09-03 04:43:04 EDT
(
hide
)
Description:
Interactive Splash Handler Template
Filename:
MIME Type:
Creator:
Stefan Lötscher
Created:
2007-09-03 04:43:04 EDT
Size:
6.82 KB
patch
obsolete
> >package org.eclipse.ui.examples.rcp.mail.splashHandlers; > >import org.eclipse.jface.dialogs.MessageDialog; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Text; >import org.eclipse.ui.splash.AbstractSplashHandler; > >/** > * @since 3.3 > * > */ >public class InteractiveSplashHandler extends AbstractSplashHandler { > > private final static int F_LABEL_HORIZONTAL_INDENT = 175; > > private final static int F_BUTTON_WIDTH_HINT = 80; > > private final static int F_TEXT_WIDTH_HINT = 175; > > private final static int F_COLUMN_COUNT = 3; > > private Composite fCompositeLogin; > > private Text fTextUsername; > > private Text fTextPassword; > > private Button fButtonOK; > > private Button fButtonCancel; > > private boolean fAuthenticated; > > /** > * > */ > public InteractiveSplashHandler() { > fCompositeLogin = null; > fTextUsername = null; > fTextPassword = null; > fButtonOK = null; > fButtonCancel = null; > fAuthenticated = false; > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets.Shell) > */ > public void init(final Shell splash) { > // Store the shell > super.init(splash); > // Configure the shell layout > configureUISplash(); > // Create UI > createUI(); > // Create UI listeners > createUIListeners(); > // Force the splash screen to layout > splash.layout(true); > // Keep the splash screen visible and prevent the RCP application from > // loading until the close button is clicked. > doEventLoop(); > } > > /** > * > */ > private void doEventLoop() { > Shell splash = getSplash(); > while (fAuthenticated == false) { > if (splash.getDisplay().readAndDispatch() == false) { > splash.getDisplay().sleep(); > } > } > } > > /** > * > */ > private void createUIListeners() { > // Create the OK button listeners > createUIListenersButtonOK(); > // Create the cancel button listeners > createUIListenersButtonCancel(); > } > > /** > * > */ > private void createUIListenersButtonCancel() { > fButtonCancel.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > handleButtonCancelWidgetSelected(); > } > }); > } > > /** > * > */ > private void handleButtonCancelWidgetSelected() { > // Abort the loading of the RCP application > getSplash().getDisplay().close(); > System.exit(0); > } > > /** > * > */ > private void createUIListenersButtonOK() { > fButtonOK.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > handleButtonOKWidgetSelected(); > } > }); > } > > /** > * > */ > private void handleButtonOKWidgetSelected() { > String username = fTextUsername.getText(); > String password = fTextPassword.getText(); > // Aunthentication is successful if a user provides any username and > // any password > if ((username.length() > 0) && > (password.length() > 0)) { > fAuthenticated = true; > } else { > MessageDialog.openError( > getSplash(), > "Authentication Failed", //NON-NLS-1 > "A username and password must be specified to login."); //NON-NLS-1 > } > } > > /** > * > */ > private void createUI() { > // Create the login panel > createUICompositeLogin(); > // Create the blank spanner > createUICompositeBlank(); > // Create the user name label > createUILabelUserName(); > // Create the user name text widget > createUITextUserName(); > // Create the password label > createUILabelPassword(); > // Create the password text widget > createUITextPassword(); > // Create the blank label > createUILabelBlank(); > // Create the OK button > createUIButtonOK(); > // Create the cancel button > createUIButtonCancel(); > } > > /** > * > */ > private void createUIButtonCancel() { > // Create the button > fButtonCancel = new Button(fCompositeLogin, SWT.PUSH); > fButtonCancel.setText("Cancel"); //NON-NLS-1 > // Configure layout data > GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); > data.widthHint = F_BUTTON_WIDTH_HINT; > data.verticalIndent = 10; > fButtonCancel.setLayoutData(data); > } > > /** > * > */ > private void createUIButtonOK() { > // Create the button > fButtonOK = new Button(fCompositeLogin, SWT.PUSH); > fButtonOK.setText("OK"); //NON-NLS-1 > // Configure layout data > GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); > data.widthHint = F_BUTTON_WIDTH_HINT; > data.verticalIndent = 10; > fButtonOK.setLayoutData(data); > } > > /** > * > */ > private void createUILabelBlank() { > Label label = new Label(fCompositeLogin, SWT.NONE); > label.setVisible(false); > } > > /** > * > */ > private void createUITextPassword() { > // Create the text widget > int style = SWT.PASSWORD | SWT.BORDER; > fTextPassword = new Text(fCompositeLogin, style); > // Configure layout data > GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); > data.widthHint = F_TEXT_WIDTH_HINT; > data.horizontalSpan = 2; > fTextPassword.setLayoutData(data); > } > > /** > * > */ > private void createUILabelPassword() { > // Create the label > Label label = new Label(fCompositeLogin, SWT.NONE); > label.setText("&Password:"); //NON-NLS-1 > // Configure layout data > GridData data = new GridData(); > data.horizontalIndent = F_LABEL_HORIZONTAL_INDENT; > label.setLayoutData(data); > } > > /** > * > */ > private void createUITextUserName() { > // Create the text widget > fTextUsername = new Text(fCompositeLogin, SWT.BORDER); > // Configure layout data > GridData data = new GridData(SWT.NONE, SWT.NONE, false, false); > data.widthHint = F_TEXT_WIDTH_HINT; > data.horizontalSpan = 2; > fTextUsername.setLayoutData(data); > } > > /** > * > */ > private void createUILabelUserName() { > // Create the label > Label label = new Label(fCompositeLogin, SWT.NONE); > label.setText("&User Name:"); //NON-NLS-1 > // Configure layout data > GridData data = new GridData(); > data.horizontalIndent = F_LABEL_HORIZONTAL_INDENT; > label.setLayoutData(data); > } > > /** > * > */ > private void createUICompositeBlank() { > Composite spanner = new Composite(fCompositeLogin, SWT.NONE); > GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); > data.horizontalSpan = F_COLUMN_COUNT; > spanner.setLayoutData(data); > } > > /** > * > */ > private void createUICompositeLogin() { > // Create the composite > fCompositeLogin = new Composite(getSplash(), SWT.BORDER); > GridLayout layout = new GridLayout(F_COLUMN_COUNT, false); > fCompositeLogin.setLayout(layout); > } > > /** > * > */ > private void configureUISplash() { > // Configure layout > FillLayout layout = new FillLayout(); > getSplash().setLayout(layout); > // Force shell to inherit the splash background > getSplash().setBackgroundMode(SWT.INHERIT_DEFAULT); > } > >}
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 Raw
Actions:
View
Attachments on
bug 202055
: 77572