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 177994 Details for
Bug 324233
[Dialogs] new IconAndMessageAndDetailsDialog implementation extends IconAndMessageDialog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
IconAndMessageAndDetailsDialog.java (extends IconAndMessageDialog.java)
IconAndMessageAndDetailsDialog.java (text/plain), 10.21 KB, created by
Kirk Beitz
on 2010-09-01 14:32:10 EDT
(
hide
)
Description:
IconAndMessageAndDetailsDialog.java (extends IconAndMessageDialog.java)
Filename:
MIME Type:
Creator:
Kirk Beitz
Created:
2010-09-01 14:32:10 EDT
Size:
10.21 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2010 Nokia 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: > * Nokia - Initial API and implementation > *******************************************************************************/ >package org.eclipse.jface.dialogs; > >import org.eclipse.cdt.debug.ui.CDebugUIPlugin; >import org.eclipse.core.runtime.IStatus; >import org.eclipse.jface.resource.JFaceResources; >import org.eclipse.swt.SWT; >import org.eclipse.swt.dnd.Clipboard; >import org.eclipse.swt.dnd.TextTransfer; >import org.eclipse.swt.dnd.Transfer; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.events.SelectionListener; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.graphics.Point; >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.Control; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Menu; >import org.eclipse.swt.widgets.MenuItem; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Text; > >/** > * copied mostly verbatim from org.eclipse.jface.dialogsErrorDialog, then > * changed out occurrences of {@link org.eclipse.swt.widgets.List} with > * {@link org.eclipse.swt.widgets.Text} so that one large details > * String could be passed and displayed > * <p><i> > * (ideally could have extended from ErrorDialog, except > * </i><code>ErrorDialog#showDetailsArea</code><i> was made final, > * and it calls</i> <code>private ErrorDialog#toggleDetailsArea</code>, > * which uses the</i> <code>SWT.List</code> <i>that the override > * would be replacing.) > * </i> > * > * @see org.eclipse.jface.dialogs.ErrorDialog > */ >public class IconAndMessageAndDetailsDialog extends IconAndMessageDialog { > > /** Reserve room for this many text items in the details text-box. */ > private static final int TEXT_LINE_COUNT = 7; > > /** @see org.eclipse.jface.dialogs.ErrorDialog#detailsButton */ > private Button detailsButton; > > /** @see org.eclipse.jface.dialogs.ErrorDialog#title */ > private String title; > > /** The SWT text control that displays the error details. */ > private Text text; > > /** Indicates whether the error details viewer is currently created. */ > private boolean textCreated = false; > > /** The severity of the dialog. */ > private int severity; > > /** The details to display in the details text-box */ > private String details; > > /** @see org.eclipse.jface.dialogs.ErrorDialog#clipboard */ > private Clipboard clipboard; > > /** > * Creates a dialog with an icon representing severity and details. > * Note that the dialog will have no visual representation > * (no widgets) until it is told to open. > * > * @param parentShell > * the shell under which to create this dialog > * @param dialogTitle > * the title to use for this dialog, or <code>null</code> to > * indicate that the default title should be used > * @param severity > * the icon to show the user (and level of error in the final log) > * @param summary > * the message to show in this dialog, or <code>null</code> to > * indicate that the error's message should be shown as the > * primary message > * @param details > * in-depth details to display with button (could be a full log) > * @see org.eclipse.jface.dialogs.IconAndMessageDialog > */ > public IconAndMessageAndDetailsDialog(Shell shell, String dialogTitle, int severity, > String summary, String details) { > super(shell); > this.title > = dialogTitle != null ? dialogTitle : JFaceResources.getString("Problem_Occurred") : //$NON-NLS-1$ > this.message > = message == null ? summary > : JFaceResources.format("Reason", new Object[] { message, summary }); //$NON-NLS-1$ > this.details = details; > this.severity = severity; > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed */ > protected void buttonPressed(int id) { > if (id == IDialogConstants.DETAILS_ID) { > // was the details button pressed? > toggleDetailsArea(); > } else { > super.buttonPressed(id); > } > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#configureShell */ > protected void configureShell(Shell shell) { > super.configureShell(shell); > shell.setText(title); > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#createButtonsForButtonBar */ > protected void createButtonsForButtonBar(Composite parent) { > // create OK and Details buttons > createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, > true); > createDetailsButton(parent); > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#createDetailsButton */ > protected void createDetailsButton(Composite parent) { > if (shouldShowDetailsButton()) { > detailsButton = createButton(parent, IDialogConstants.DETAILS_ID, > IDialogConstants.SHOW_DETAILS_LABEL, false); > } > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#createDialogArea */ > protected Control createDialogArea(Composite parent) { > // Create a composite with standard margins and spacing > // Add the messageArea to this composite so that as subclasses add widgets to the messageArea > // and dialogArea, the number of children of parent remains fixed and with consistent layout. > // Fixes bug #240135 > Composite composite = new Composite(parent, SWT.NONE); > createMessageArea(composite); > GridLayout layout = new GridLayout(); > layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); > layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); > layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); > layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); > layout.numColumns = 2; > composite.setLayout(layout); > GridData childData = new GridData(GridData.FILL_BOTH); > childData.horizontalSpan = 2; > childData.grabExcessVerticalSpace = false; > composite.setLayoutData(childData); > composite.setFont(parent.getFont()); > > return composite; > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#createDialogAndButtonArea */ > protected void createDialogAndButtonArea(Composite parent) { > super.createDialogAndButtonArea(parent); > if (this.dialogArea instanceof Composite) { > // Create a label if there are no children to force a smaller layout > Composite dialogComposite = (Composite) dialogArea; > if (dialogComposite.getChildren().length == 0) { > new Label(dialogComposite, SWT.NULL); > } > } > } > > protected Image getImage() { > switch (severity) > { > case IStatus.WARNING: return getWarningImage(); > case IStatus.INFO: return getInfoImage(); > } > > // If it was not info or warning then return the error image > return getErrorImage(); > } > > /** > * Creates a the drop-down area for when the user hits the > * [Details>>] button. This is intended to act the same as > * the details button in ErrorDialog, except using > * {@link org.eclipse.swt.widgets.Text} instead of > * {@link org.eclipse.swt.widgets.List} > * > * @param parent the parent composite > * @return the drop-down text component > * @see org.eclipse.jface.dialogs.ErrorDialog#createDropDownList > */ > protected Text createDropDownText(Composite parent) { > // create the text > text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL > | SWT.MULTI | SWT.WRAP); > // fill the text > text.setText(details); > GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL > | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL > | GridData.GRAB_VERTICAL); > data.heightHint = text.getLineHeight() * TEXT_LINE_COUNT; > data.horizontalSpan = 2; > text.setLayoutData(data); > text.setFont(parent.getFont()); > Menu copyMenu = new Menu(text); > MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE); > copyItem.addSelectionListener(new SelectionListener() { > public void widgetSelected(SelectionEvent e) { > copyToClipboard(); > } > public void widgetDefaultSelected(SelectionEvent e) { > copyToClipboard(); > } > }); > copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$ > text.setMenu(copyMenu); > textCreated = true; > return text; > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#toggleDetailsArea */ > private void toggleDetailsArea() { > Point windowSize = getShell().getSize(); > Point oldSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); > if (textCreated) { > text.dispose(); > textCreated = false; > detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL); > } else { > text = createDropDownText((Composite) getContents()); > detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL); > getContents().getShell().layout(); > } > Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); > getShell() > .setSize( > new Point(windowSize.x, windowSize.y > + (newSize.y - oldSize.y))); > } > > /** Copy the contents of the drop-down details to the clipboard. */ > private void copyToClipboard() { > if (clipboard != null) { > clipboard.dispose(); > } > clipboard = new Clipboard(text.getDisplay()); > clipboard.setContents(new Object[] { details + "\n" },//$NON-NLS-1$ > new Transfer[] { TextTransfer.getInstance() }); > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#close */ > public boolean close() { > if (clipboard != null) { > clipboard.dispose(); > } > return super.close(); > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#showDetailsArea */ > protected final void showDetailsArea() { > if (!textCreated) { > Control control = getContents(); > if (control != null && !control.isDisposed()) { > toggleDetailsArea(); > } > } > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#shouldShowDetailsButton */ > protected boolean shouldShowDetailsButton() { > return (details != null) && (0 < details.length()); > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#setStatus */ > protected final void setStatus(IStatus status) { > if (textCreated) { > if (text != null && !text.isDisposed()) { > text.setText(status.getMessage()); > } > } > } > > /** @see org.eclipse.jface.dialogs.ErrorDialog#isResizable */ > protected boolean isResizable() { > return true; > } > >}
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
Flags:
kirk.beitz
:
review?
Actions:
View
Attachments on
bug 324233
: 177994