Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util')
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java122
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java60
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java598
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java47
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java123
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java626
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java127
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java173
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java208
9 files changed, 0 insertions, 2084 deletions
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java
deleted file mode 100644
index 6fc767b6db4..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java
+++ /dev/null
@@ -1,122 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.epf.common.utils.FileUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.HTMLTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.framework.Bundle;
-
-/**
- * Utility class for retrieving data from the clipboard.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class ClipboardUtil {
-
- /**
- * The current clipboard.
- */
- private static Clipboard clipboard;
-
- private static final String SOURCE_URL = "SourceURL:"; //$NON-NLS-1$
-
- private static Transfer htmlTransfer = null;
-
- static {
- if (SWT.getPlatform().equals("win32")) { //$NON-NLS-1$
- try {
- boolean is64bit = (System.getProperty("os.arch").indexOf("64") != -1);
- Bundle bundle = null;
- if (is64bit) {
- bundle = Platform
- .getBundle("org.eclipse.epf.common.win32.win32.x86_64"); //$NON-NLS-1$
- } else {
- bundle = Platform
- .getBundle("org.eclipse.epf.common.win32.win32.x86"); //$NON-NLS-1$
- }
- if (bundle != null) {
- Class<?> c = bundle
- .loadClass("org.eclipse.epf.common.win32.Win32HTMLTransfer"); //$NON-NLS-1$
- if (c != null) {
- htmlTransfer = (Transfer) c.newInstance();
- }
- }
- } catch (Exception e) {
- htmlTransfer = null;
- }
- }
- }
-
- /**
- * Gets the HTML source URL from the current clipboard.
- *
- * @return the HTML source URL or <code>null</code>
- */
- public static String getHTMLSourceURL() {
- if (htmlTransfer == null) {
- return null;
- }
-
- Clipboard clipboard = new Clipboard(Display.getCurrent());
- String sourceURL = null;
- try {
- String htmlContent = (String) clipboard.getContents(htmlTransfer);
- if (htmlContent != null && htmlContent.length() > 0) {
- int index = htmlContent.indexOf(SOURCE_URL);
- if (index > 0) {
- sourceURL = htmlContent.substring(index
- + SOURCE_URL.length());
- sourceURL = sourceURL.substring(0, sourceURL
- .indexOf(FileUtil.LINE_SEP));
- }
- }
- if (sourceURL != null && sourceURL.indexOf("\\") != -1) { //$NON-NLS-1$
- // IE provides sourceURL in form "file://C:\foo\bar.htm"
- // but when the hrefs are resolved, files look like "file:///C:/foo/bar.htm"
- URL url = new URL(sourceURL);
- sourceURL = url.toExternalForm();
- if (sourceURL.startsWith("file://") && !sourceURL.startsWith("file:///")) { //$NON-NLS-1$ //$NON-NLS-2$
- // need to add a third / so rte.js can match the sourceURL to hrefs
- sourceURL = "file:///" + sourceURL.substring(7); //$NON-NLS-1$
- }
- }
- return sourceURL;
- } catch (MalformedURLException urlEx) {
- return sourceURL;
- } finally {
- clipboard.dispose();
- }
- }
-
- /**
- * Copy the string to the clipboard.
- */
- public static void copyTextHTMLToClipboard(String string) {
- if (clipboard != null)
- clipboard.dispose();
- clipboard = new Clipboard(null);
- clipboard.setContents(new Object[] { string, string },
- new Transfer[] { TextTransfer.getInstance(), HTMLTransfer.getInstance() });
- if (clipboard != null)
- clipboard.dispose();
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java
deleted file mode 100644
index d20685d3365..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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 implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.epf.common.ui.CommonUIPlugin;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Manages the common preferences.
- *
- * @author Kelvin Low
- * @since 1.2
- */
-public class CommonPreferences {
-
- /**
- * Preference key for storing the preference history size.
- */
- private static final String PREFERENCE_HISTORY_SIZE = "preferenceHistorySize"; //$NON-NLS-1$
-
- // The plug-in specific preference store.
- private static IPreferenceStore prefStore = CommonUIPlugin.getDefault()
- .getPreferenceStore();
-
- static {
- // Initialize the default preference values.
- prefStore.setDefault(PREFERENCE_HISTORY_SIZE,
- getDefaultPreferenceHistorySize());
- }
-
- /**
- * Gets the default preference history size.
- */
- public static int getDefaultPreferenceHistorySize() {
- return 10;
- }
-
- /**
- * Gets the preference history size.
- */
- public static int getPreferenceHistorySize() {
- return prefStore.getInt(PREFERENCE_HISTORY_SIZE);
- }
-
- /**
- * Saves the preference history size.
- */
- public static void setPreferenceHistorySize(int value) {
- prefStore.setValue(PREFERENCE_HISTORY_SIZE, value);
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java
deleted file mode 100644
index 6793260c080..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java
+++ /dev/null
@@ -1,598 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IconAndMessageDialog;
-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.List;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Displays an error dialog without the Details button.
- *
- * @author Bingxue Xu
- * @since 1.0
- */
-public class ErrorDialogNoReason extends IconAndMessageDialog {
-
- /**
- * Static to prevent opening of error dialogs for automated testing.
- */
- public static final boolean AUTOMATED_MODE = false;
-
- /**
- * Reserve room for this many list items.
- */
- private static final int LIST_ITEM_COUNT = 7;
-
- /**
- * The nesting indent.
- */
- private static final String NESTING_INDENT = " "; //$NON-NLS-1$
-
- /**
- * The Details button.
- */
- protected Button detailsButton;
-
- /**
- * The title of the dialog.
- */
- private String title;
-
- /**
- * The SWT list control that displays the error details.
- */
- private List list;
-
- /**
- * Indicates whether the error details viewer is currently created.
- */
- private boolean listCreated = false;
-
- /**
- * Filter mask for determining which status items to display.
- */
- private int displayMask = 0xFFFF;
-
- /**
- * The main status object.
- */
- private IStatus status;
-
- /**
- * The current clipboard. To be disposed when closing the dialog.
- */
- private Clipboard clipboard;
-
- private boolean shouldIncludeTopLevelErrorInDetails = false;
-
- /**
- * Creates an error dialog. Note that the dialog will have no visual
- * representation (no widgets) until it is told to open.
- * <p>
- * Normally one should use <code>openError</code> to create and open one
- * of these. This constructor is useful only if the error object being
- * displayed contains child items <it>and </it> you need to specify a mask
- * which will be used to filter the displaying of these children.
- * </p>
- *
- * @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 message
- * 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 status
- * the error to show to the user
- * @param displayMask
- * the mask to use to filter the displaying of child items, as
- * per <code>IStatus.matches</code>
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- public ErrorDialogNoReason(Shell parentShell, String dialogTitle,
- String message, IStatus status, int displayMask) {
- super(parentShell);
- this.title = dialogTitle == null ? JFaceResources
- .getString("Problem_Occurred") : //$NON-NLS-1$
- dialogTitle;
- this.message = message == null ? status.getMessage() : message;
- this.status = status;
- this.displayMask = displayMask;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog. Handles the pressing of the Ok
- * or Details button in this dialog. If the Ok button was pressed then close
- * this dialog. If the Details button was pressed then toggle the displaying
- * of the error details area. Note that the Details button will only be
- * visible if the error being displayed specifies child details.
- */
- protected void buttonPressed(int id) {
- if (id == IDialogConstants.DETAILS_ID) {
- // was the details button pressed?
- toggleDetailsArea();
- } else {
- super.buttonPressed(id);
- }
- }
-
- /*
- * (non-Javadoc) Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected void createButtonsForButtonBar(Composite parent) {
- // create OK and Details buttons
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
- true);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- if (shouldShowDetailsButton()) {
- detailsButton = createButton(parent, IDialogConstants.DETAILS_ID,
- IDialogConstants.SHOW_DETAILS_LABEL, false);
- }
- }
-
- /**
- * This implementation of the <code>Dialog</code> framework method creates
- * and lays out a composite and calls <code>createMessageArea</code> and
- * <code>createCustomArea</code> to populate it. Subclasses should
- * override <code>createCustomArea</code> to add contents below the
- * message.
- */
- protected Control createDialogArea(Composite parent) {
- createMessageArea(parent);
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parent, SWT.NONE);
- 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;
- composite.setLayoutData(childData);
- composite.setFont(parent.getFont());
- return composite;
- }
-
- /*
- * @see IconAndMessageDialog#createDialogAndButtonArea(Composite)
- */
- 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);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()
- */
- protected Image getImage() {
- if (status != null) {
- if (status.getSeverity() == IStatus.WARNING)
- return getWarningImage();
- if (status.getSeverity() == IStatus.INFO)
- return getInfoImage();
- }
- // If it was not a warning or an error then return the error image
- return getErrorImage();
- }
-
- /**
- * Create this dialog's drop-down list component.
- *
- * @param parent
- * the parent composite
- * @return the drop-down list component
- */
- protected List createDropDownList(Composite parent) {
- // create the list
- list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.MULTI);
- // fill the list
- populateList(list);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
- | GridData.GRAB_VERTICAL);
- data.heightHint = list.getItemHeight() * LIST_ITEM_COUNT;
- data.horizontalSpan = 2;
- list.setLayoutData(data);
- list.setFont(parent.getFont());
- Menu copyMenu = new Menu(list);
- MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
- copyItem.addSelectionListener(new SelectionListener() {
- /*
- * @see SelectionListener.widgetSelected (SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- copyToClipboard();
- }
-
- /*
- * @see SelectionListener.widgetDefaultSelected(SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- copyToClipboard();
- }
- });
- copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
- list.setMenu(copyMenu);
- listCreated = true;
- return list;
- }
-
- /*
- * (non-Javadoc) Method declared on Window.
- */
- /**
- * Extends <code>Window.open()</code>. Opens an error dialog to display
- * the error. If you specified a mask to filter the displaying of these
- * children, the error dialog will only be displayed if there is at least
- * one child status matching the mask.
- */
- public int open() {
- if (!AUTOMATED_MODE && shouldDisplay(status, displayMask)) {
- return super.open();
- }
- setReturnCode(OK);
- return OK;
- }
-
- /**
- * Opens an error dialog to display the given error. Use this method if the
- * error object being displayed does not contain child items, or if you wish
- * to display all such items without filtering.
- *
- * @param parent
- * the parent shell of the dialog, or <code>null</code> if none
- * @param dialogTitle
- * the title to use for this dialog, or <code>null</code> to
- * indicate that the default title should be used
- * @param message
- * 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 status
- * the error to show to the user
- * @return the code of the button that was pressed that resulted in this
- * dialog closing. This will be <code>Dialog.OK</code> if the OK
- * button was pressed, or <code>Dialog.CANCEL</code> if this
- * dialog's close window decoration or the ESC key was used.
- */
- public static int openError(Shell parent, String dialogTitle,
- String message, IStatus status) {
- return openError(parent, dialogTitle, message, status, IStatus.OK
- | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
- }
-
- /**
- * Opens an error dialog to display the given error. Use this method if the
- * error object being displayed contains child items <it>and </it> you wish
- * to specify a mask which will be used to filter the displaying of these
- * children. The error dialog will only be displayed if there is at least
- * one child status matching the mask.
- *
- * @param parentShell
- * the parent shell of the dialog, or <code>null</code> if none
- * @param title
- * the title to use for this dialog, or <code>null</code> to
- * indicate that the default title should be used
- * @param message
- * 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 status
- * the error to show to the user
- * @param displayMask
- * the mask to use to filter the displaying of child items, as
- * per <code>IStatus.matches</code>
- * @return the code of the button that was pressed that resulted in this
- * dialog closing. This will be <code>Dialog.OK</code> if the OK
- * button was pressed, or <code>Dialog.CANCEL</code> if this
- * dialog's close window decoration or the ESC key was used.
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- public static int openError(Shell parentShell, String title,
- String message, IStatus status, int displayMask) {
- ErrorDialogNoReason dialog = new ErrorDialogNoReason(parentShell,
- title, message, status, displayMask);
- return dialog.open();
- }
-
- /**
- * Populates the list using this error dialog's status object. This walks
- * the child static of the status object and displays them in a list. The
- * format for each entry is status_path : status_message If the status's
- * path was null then it (and the colon) are omitted.
- *
- * @param listToPopulate
- * The list to fill.
- */
- private void populateList(List listToPopulate) {
- populateList(listToPopulate, status, 0,
- shouldIncludeTopLevelErrorInDetails);
- }
-
- /**
- * Populate the list with the messages from the given status. Traverse the
- * children of the status deeply and also traverse CoreExceptions that
- * appear in the status.
- *
- * @param listToPopulate
- * the list to populate
- * @param buildingStatus
- * the status being displayed
- * @param nesting
- * the nesting level (increases one level for each level of
- * children)
- * @param includeStatus
- * whether to include the buildingStatus in the display or just
- * its children
- */
- private void populateList(List listToPopulate, IStatus buildingStatus,
- int nesting, boolean includeStatus) {
-
- if (!buildingStatus.matches(displayMask)) {
- return;
- }
-
- Throwable t = buildingStatus.getException();
- boolean isCoreException = t instanceof CoreException;
- boolean incrementNesting = false;
-
- if (includeStatus) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < nesting; i++) {
- sb.append(NESTING_INDENT);
- }
- String message = buildingStatus.getMessage();
- sb.append(message);
- listToPopulate.add(sb.toString());
- incrementNesting = true;
- }
-
- if (!isCoreException && t != null) {
- // Include low-level exception message
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < nesting; i++) {
- sb.append(NESTING_INDENT);
- }
- String message = t.getLocalizedMessage();
- if (message == null)
- message = t.toString();
-
- sb.append(message);
- listToPopulate.add(sb.toString());
- incrementNesting = true;
- }
-
- if (incrementNesting)
- nesting++;
-
- // Look for a nested core exception
- if (isCoreException) {
- CoreException ce = (CoreException) t;
- IStatus eStatus = ce.getStatus();
- // Only print the exception message if it is not contained in the
- // parent message
- if (message == null || message.indexOf(eStatus.getMessage()) == -1) {
- populateList(listToPopulate, eStatus, nesting, true);
- }
- }
-
- // Look for child status
- IStatus[] children = buildingStatus.getChildren();
- for (int i = 0; i < children.length; i++) {
- populateList(listToPopulate, children[i], nesting, true);
- }
- }
-
- /**
- * Returns whether the given status object should be displayed.
- *
- * @param status
- * a status object
- * @param mask
- * a mask as per <code>IStatus.matches</code>
- * @return <code>true</code> if the given status should be displayed, and
- * <code>false</code> otherwise
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- protected static boolean shouldDisplay(IStatus status, int mask) {
- IStatus[] children = status.getChildren();
- if (children == null || children.length == 0) {
- return status.matches(mask);
- }
- for (int i = 0; i < children.length; i++) {
- if (children[i].matches(mask))
- return true;
- }
- return false;
- }
-
- /**
- * Toggles the unfolding of the details area. This is triggered by the user
- * pressing the details button.
- */
- private void toggleDetailsArea() {
- Point windowSize = getShell().getSize();
- Point oldSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- if (listCreated) {
- list.dispose();
- listCreated = false;
- detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);
- } else {
- list = createDropDownList((Composite) getContents());
- detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);
- }
- Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- getShell()
- .setSize(
- new Point(windowSize.x, windowSize.y
- + (newSize.y - oldSize.y)));
- }
-
- /**
- * Put the details of the status of the error onto the stream.
- *
- * @param buildingStatus
- * @param buffer
- * @param nesting
- */
- private void populateCopyBuffer(IStatus buildingStatus,
- StringBuffer buffer, int nesting) {
- if (!buildingStatus.matches(displayMask)) {
- return;
- }
- for (int i = 0; i < nesting; i++) {
- buffer.append(NESTING_INDENT);
- }
- buffer.append(buildingStatus.getMessage());
- buffer.append("\n"); //$NON-NLS-1$
-
- // Look for a nested core exception
- Throwable t = buildingStatus.getException();
- if (t instanceof CoreException) {
- CoreException ce = (CoreException) t;
- populateCopyBuffer(ce.getStatus(), buffer, nesting + 1);
- }
-
- IStatus[] children = buildingStatus.getChildren();
- for (int i = 0; i < children.length; i++) {
- populateCopyBuffer(children[i], buffer, nesting + 1);
- }
- }
-
- /**
- * Copy the contents of the statuses to the clipboard.
- */
- private void copyToClipboard() {
- if (clipboard != null)
- clipboard.dispose();
- StringBuffer statusBuffer = new StringBuffer();
- populateCopyBuffer(status, statusBuffer, 0);
- clipboard = new Clipboard(list.getDisplay());
- clipboard.setContents(new Object[] { statusBuffer.toString() },
- new Transfer[] { TextTransfer.getInstance() });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#close()
- */
- public boolean close() {
- if (clipboard != null)
- clipboard.dispose();
- return super.close();
- }
-
- /**
- * Show the details portion of the dialog if it is not already visible. This
- * method will only work when it is invoked after the control of the dialog
- * has been set. In other words, after the <code>createContents</code>
- * method has been invoked and has returned the control for the content area
- * of the dialog. Invoking the method before the content area has been set
- * or after the dialog has been disposed will have no effect.
- *
- * @since 3.1
- */
- protected final void showDetailsArea() {
- if (!listCreated) {
- Control control = getContents();
- if (control != null && !control.isDisposed())
- toggleDetailsArea();
- }
- }
-
- /**
- * Return whether the Details button should be included. This method is
- * invoked once when the dialog is built. By default, the Details button is
- * only included if the status used when creating the dialog was a
- * multi-status or if the status contains an exception. Subclasses may
- * override.
- *
- * @return whether the Details button should be included
- * @since 3.1
- */
- protected boolean shouldShowDetailsButton() {
- return status.isMultiStatus() || status.getException() != null;
- }
-
- /**
- * Set the status displayed by this error dialog to the given status. This
- * only affects the status displayed by the Details list. The message, image
- * and title should be updated by the subclass, if desired.
- *
- * @param status
- * the status to be displayed in the details list
- * @since 3.1
- */
- protected final void setStatus(IStatus status) {
- if (this.status != status) {
- this.status = status;
- }
- shouldIncludeTopLevelErrorInDetails = true;
- if (listCreated) {
- repopulateList();
- }
- }
-
- /**
- * Repopulate the supplied list widget.
- */
- private void repopulateList() {
- if (list != null && !list.isDisposed()) {
- list.removeAll();
- populateList(list);
- }
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java
deleted file mode 100644
index 52a828d1e80..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.swt.widgets.MenuItem;
-
-/**
- * A helper class for retrieving Eclipse menus.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class MenuUtil {
-
- /**
- * Searches an array of menu items and returns the menu item that matches
- * the given menu text.
- *
- * @param menuItems
- * An array of menu items.
- * @param text
- * The text to look for.
- * @return The menu item if found, <code>null</code> otherwise.
- */
- public static MenuItem getMenuItem(MenuItem[] menuItems, String text) {
- if (menuItems == null || text == null || text.length() == 0) {
- return null;
- }
-
- for (int i = 0; i < menuItems.length; i++) {
- if (menuItems[i].getText().startsWith(text)) {
- return menuItems[i];
- }
- }
-
- return null;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java
deleted file mode 100644
index 1d97b41167a..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java
+++ /dev/null
@@ -1,123 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Helper class to display a message box.
- *
- * @author Phong Nguyen Le
- * @author Kelvin Low
- * @since 1.0
- */
-public final class MsgBox {
- /**
- * Use this method to show error message if you don't want long path to be
- * cut off.
- *
- * @param msg
- */
- public static final void nativeShowError(Shell shell, String msg) {
- if (shell == null) {
- shell = getDefaultShell();
- if (shell == null) {
- return;
- }
- }
- MessageBox msgBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
- msgBox.setMessage(msg);
- msgBox.setText(shell.getText());
- msgBox.open();
- }
-
- public static final void showError(String msg) {
- showError(getDefaultShell(), msg);
- }
-
- public static final void showError(Shell shell, String msg) {
- WrappedMessageDialog.openError(shell, shell == null ? null : shell
- .getText(), msg);
- }
-
- public static final void showWarning(String msg) {
- showWarning(getDefaultShell(), msg);
- }
-
- public static final void showWarning(Shell shell, String msg) {
- WrappedMessageDialog.openWarning(shell, shell == null ? null : shell
- .getText(), msg);
- }
-
- public static final Shell getDefaultShell() {
- try {
- Display d = Display.getCurrent();
- if (d == null) {
- d = Display.getDefault();
- }
-
- Shell s = null;
- if (d != null) {
- s = d.getActiveShell();
- }
-
- return s;
- } catch (RuntimeException e) {
- return null;
- }
- }
-
- public static final Display getDisplay() {
- try {
- Display d = Display.getCurrent();
- if (d == null) {
- d = Display.getDefault();
- }
-
- return d;
- } catch (RuntimeException e) {
- return null;
- }
- }
-
- public static final int prompt(String msg) {
- return prompt(getDefaultShell(), msg);
- }
-
- public static final int prompt(Shell shell, String msg) {
- return prompt(shell, null, msg, SWT.YES | SWT.NO | SWT.CANCEL);
- }
-
- public static final int prompt(String msg, int buttons) {
- return prompt(getDefaultShell(), null, msg, buttons);
- }
-
- public static final int prompt(String title, String msg, int buttons) {
- return prompt(getDefaultShell(), title, msg, buttons);
- }
-
- public static final int prompt(Shell shell, String msg, int buttons) {
- return prompt(shell, null, msg, buttons);
- }
-
- public static final int prompt(Shell shell, String title, String msg,
- int buttons) {
- MessageBox msgBox = new MessageBox(shell, buttons | SWT.ICON_QUESTION);
- msgBox.setText(title != null && title.length() > 0 ? title : shell
- .getText());
- msgBox.setMessage(msg);
- return msgBox.open();
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java
deleted file mode 100644
index e681d33a19d..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java
+++ /dev/null
@@ -1,626 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.epf.common.IActivator;
-import org.eclipse.epf.common.serviceability.Logger;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * A message dialog used for displaying error, warning, confirmation or
- * informational messages.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @author Phong Nguyen Le
- * @since 1.0
- */
-public class MsgDialog {
-
- // The plug-in ID.
- private String pluginId;
-
- // The plug-in logger.
- private Logger logger;
-
- /**
- * Create a new instance given the plug-in instance.
- *
- * @param plugin
- * The plugin instance.
- */
- public MsgDialog(IActivator plugin) {
- this.pluginId = plugin.getId();
- this.logger = plugin.getLogger();
- }
-
- protected Shell getShell() {
- return PlatformUI.getWorkbench().getDisplay().getActiveShell();
- }
-
- /**
- * Displays the given error message in an error dialog without the error
- * reason and Details button.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- */
- public void displayError(String title, String msg) {
- display(IStatus.ERROR, title, msg, null, null, null);
- }
-
- /**
- * Displays the given error message in an error dialog without the error
- * reason and Details button.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, Throwable ex) {
- display(IStatus.ERROR, title, msg, null, null, ex);
- }
-
- /**
- * Displays the given error message in an error dialog without the Details
- * button.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- */
- public void displayError(String title, String msg, String reason) {
- display(IStatus.ERROR, title, msg, reason, null, null);
- }
-
- /**
- * Displays the given error message in an error dialog without the Details
- * button.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, String reason,
- Throwable ex) {
- display(IStatus.ERROR, title, msg, reason, null, ex);
- }
-
- /**
- * Displays the given error message in an error dialog. The Details button
- * will be displayed if the <code>details</code> parameter it not null or
- * empty.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- */
- public void displayError(String title, String msg, String reason,
- String details) {
- display(IStatus.ERROR, title, msg, reason, details, null);
- }
-
- /**
- * Displays the given error message in an error dialog. The Details button
- * will be displayed if the <code>details</code> parameter it not null or
- * empty.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, String reason,
- String details, Throwable ex) {
- display(IStatus.ERROR, title, msg, reason, details, ex);
- }
-
- /**
- * Displays the given error status in an error dialog.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public int displayError(String title, IStatus status) {
- return display(title, null, status);
- }
-
- /**
- * Displays the given error status in an error dialog.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public int displayError(String title, String msg, IStatus status) {
- return display(title, msg, status);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- */
- public void displayWarning(String title, String msg) {
- display(IStatus.WARNING, title, msg, null, null, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, Throwable ex) {
- display(IStatus.WARNING, title, msg, null, null, ex);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- */
- public void displayWarning(String title, String msg, String reason) {
- display(IStatus.WARNING, title, msg, reason, null, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, String reason,
- Throwable ex) {
- display(IStatus.WARNING, title, msg, reason, null, ex);
- }
-
- /**
- * Displays the given warning message in a warning dialog. The Details
- * button will be displayed if the <code>details</code> parameter it not
- * null or empty.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param details
- * The warning details.
- */
- public void displayWarning(String title, String msg, String reason,
- String details) {
- display(IStatus.WARNING, title, msg, reason, details, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog. The Details
- * button will be displayed if the <code>details</code> parameter it not
- * null or empty.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param details
- * The warning details.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, String reason,
- String details, Throwable ex) {
- display(IStatus.WARNING, title, msg, reason, details, ex);
- }
-
- /**
- * Displays the given warning status in an error dialog.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public void displayWarning(String title, IStatus status) {
- display(title, null, status);
- }
-
- /**
- * Displays the given warning status in an error dialog.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public void displayWarning(String title, String msg, IStatus status) {
- display(title, msg, status);
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param severity
- * The severity, either IStatus.ERROR or IStatus.WARNING.
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- * @param ex
- * The exception associated with the error.
- */
- public synchronized void display(int severity, String title, String msg,
- String reason, String details, Throwable ex) {
- if (msg == null && ex != null) {
- msg = ex.getMessage();
- }
-
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
- logger.logMsg(severity, msg, ex);
- } else {
- throw new IllegalArgumentException(
- "severity argument must be IStatus.ERROR or IStatus.WARNING"); //$NON-NLS-1$
- }
-
- Image oldImage = org.eclipse.jface.dialogs.ErrorDialog
- .getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- if (details != null && details.length() > 0) {
- MultiStatus mStatus = new MultiStatus(pluginId, IStatus.OK, reason,
- ex);
- Status status = new Status(severity, pluginId, IStatus.OK, details,
- ex);
- mStatus.add(status);
- org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title, msg,
- mStatus);
- } else if (reason != null && reason.length() > 0) {
- Status status = new Status(severity, pluginId, IStatus.OK, reason,
- ex);
- org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title, msg,
- status);
- } else {
- if (severity == IStatus.ERROR) {
- WrappedMessageDialog.openError(shell, title, msg);
- } else if (severity == IStatus.WARNING) {
- WrappedMessageDialog.openWarning(shell, title, msg);
- }
- }
-
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(oldImage);
- }
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public synchronized int display(String title, IStatus status) {
- return display(title, null, status);
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public synchronized int display(String title, String msg, IStatus status) {
- if (status == null) {
- throw new IllegalArgumentException("status argument cannot be null"); //$NON-NLS-1$
- }
-
- if (msg == null) {
- msg = status.getMessage();
- }
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- int severity = status.getSeverity();
- if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
- logger.logMsg(severity, msg, status.getException());
- }
-
- Image oldImage = org.eclipse.jface.dialogs.ErrorDialog
- .getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- int rc = org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title,
- msg, status);
-
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(oldImage);
- }
-
- return rc;
- }
-
- /**
- * Displays the given message in a informational dialog with an "OK" button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public void displayInfo(String title, String msg) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
- WrappedMessageDialog.openInformation(shell, title, msg);
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
- }
-
- /**
- * Displays the given message in a question dialog with a "Yes" and "No"
- * button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public boolean displayPrompt(String title, String msg) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
- boolean result = WrappedMessageDialog.openQuestion(shell, title, msg);
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
-
- return result;
- }
-
- /**
- * Displays the given message in a confirmation dialog with a "Yes" and
- * "Cancel" button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public boolean displayConfirmation(String title, String msg) {
- return displayConfirmationWithCheckBox(title, msg, null) > 0;
- }
-
- //return: 0 = cancel, 1 = ok with check-box checked, 2 = ok with check box unchecked
- public int displayConfirmationWithCheckBox(String title, String msg, String checkBoxLabel) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
-
- if (checkBoxLabel == null) {
- boolean b = WrappedMessageDialog.openConfirm(shell, title, msg);
- return b ? 1 : 0;
- }
-
- return WrappedMessageDialog.openConfirmWithCheckBox(shell, title, msg, checkBoxLabel);
- }
-
- public int displayConfirmation(String title, String msg, IStatus status) {
- if (status == null) {
- throw new IllegalArgumentException("status argument cannot be null"); //$NON-NLS-1$
- }
-
- if (msg == null) {
- msg = status.getMessage();
- }
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialogNoReason.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- int rc = ErrorDialogNoReason.openError(shell, title, msg, status);
-
- return rc;
-
- }
-
- /**
- * Returns the image for the current shell.
- *
- * @return The current shell image.
- */
- private Image getShellImage() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow workbenchWindow = workbench
- .getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- Shell shell = workbenchWindow.getShell();
- if (shell != null) {
- return shell.getImage();
- }
- }
- }
- return null;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java
deleted file mode 100644
index a928ec798c8..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java
+++ /dev/null
@@ -1,127 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-
-/**
- * Utility class for accessing perspectives.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class PerspectiveUtil {
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private PerspectiveUtil() {
- }
-
- /**
- * Returns the ID of the active perspective.
- *
- * @return The active perspective ID.
- */
- public static String getActivePerspectiveId() {
- if (PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow() == null) {
- return null;
- }
-
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IPerspectiveDescriptor activePerspective = activePage
- .getPerspective();
- return activePerspective.getId();
- }
- return null;
- }
-
- /**
- * Opens a perspective.
- *
- * @param perspectiveId
- * The perspective ID.
- * @return The previously active perspective.
- */
- public static IPerspectiveDescriptor openPerspective(String perspectiveId) {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IPerspectiveRegistry registry = PlatformUI.getWorkbench()
- .getPerspectiveRegistry();
- IPerspectiveDescriptor oldPerspective = activePage.getPerspective();
- if (!oldPerspective.getId().equals(perspectiveId)) {
- IPerspectiveDescriptor perspective = registry
- .findPerspectiveWithId(perspectiveId);
- activePage.setPerspective(perspective);
- }
- return oldPerspective;
- } else {
- IWorkbenchWindow activeWindow = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- try {
- PlatformUI.getWorkbench().showPerspective(
- perspectiveId, activeWindow);
- } catch (WorkbenchException e) {
- }
- }
- return null;
- }
-
- /**
- * Returns true if the given perspective is already active.
- *
- * @param perspectiveId
- * The perspective ID.
- * @return
- */
- public static boolean isActivePerspective(String perspectiveId) {
- String activePerspectiveId = PerspectiveUtil.getActivePerspectiveId();
- if (perspectiveId == null || activePerspectiveId == null) {
- return false;
- }
- return activePerspectiveId.equalsIgnoreCase(perspectiveId);
- }
-
- /**
- * Returns the view part with the given view ID.
- *
- * @param viewId
- * The view ID.
- * @return The view part.
- */
- public static IViewPart getView(String viewId) {
- try {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IViewPart view = activePage.findView(viewId);
- if (view == null) {
- view = activePage.showView(viewId);
- }
- return view;
- }
- } catch (Exception e) {
- }
- return null;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java
deleted file mode 100644
index 158d7d882ec..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java
+++ /dev/null
@@ -1,173 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2007 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import com.ibm.icu.util.StringTokenizer;
-
-/**
- * Utility class for accessing preferences.
- *
- * @author Kelvin Low
- * @since 1.2
- */
-public class PreferenceUtil {
-
- // The multi-string preference delimiter.
- private static final String PREFERENCE_DELIMITER = ";"; //$NON-NLS-1$
-
- /**
- * Gets a list containing string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @return a list of string values
- */
- public static List<String> getList(IPreferenceStore prefStore, String name) {
- List<String> values = new ArrayList<String>();
- if (prefStore != null && name != null) {
- String value = prefStore.getString(name);
- StringTokenizer tokenizer = new StringTokenizer(value,
- PREFERENCE_DELIMITER);
- int tokenCount = tokenizer.countTokens();
- for (int i = 0; i < tokenCount; i++) {
- values.add(tokenizer.nextToken());
- }
- }
- return values;
- }
-
- /**
- * Gets the string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @return a list of string preference values
- */
- public static String[] getStringValues(IPreferenceStore prefStore,
- String name) {
- List<String> list = getList(prefStore, name);
- String[] values = new String[list.size()];
- list.toArray(values);
- return values;
- }
-
- /**
- * Saves a list containing string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param values
- * a list of string values
- */
- public static void setList(IPreferenceStore prefStore, String name,
- List values) {
- if (prefStore != null && name != null && values != null) {
- StringBuffer buffer = new StringBuffer();
- for (Iterator it = values.iterator(); it.hasNext();) {
- String value = (String) it.next();
- buffer.append(value);
- buffer.append(PREFERENCE_DELIMITER);
- }
- prefStore.setValue(name, buffer.toString());
- }
- }
-
- /**
- * Adds a string value to a list containing string values associated with a
- * named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param value
- * a string value
- * @param defaultValue
- * a default string value that will be added to the end of the
- * list
- */
- public static void addToList(IPreferenceStore prefStore, String name,
- String value, String defaultValue) {
- if (prefStore != null && name != null && value != null) {
- List<String> list = getList(prefStore, name);
- list.remove(value);
- list.add(0, value);
-
- //adjust the list according to the history size
- int preferenceHistorySize = CommonPreferences.getPreferenceHistorySize();
- if (list.size() > preferenceHistorySize) {
- list = list.subList(0, preferenceHistorySize - 1);
- }
- if (defaultValue != null && defaultValue.length() > 0) {
- if (!list.contains(defaultValue)) {
- if (list.size() == preferenceHistorySize) {
- list.add(list.size() - 1, defaultValue);
- } else {
- list.add(defaultValue);
- }
- }
- }
-
- setList(prefStore, name, list);
- }
- }
-
- /**
- * Adds a string value to a list containing string values associated with a
- * named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param value
- * a string value
- */
- public static void addToList(IPreferenceStore prefStore, String name,
- String value) {
- addToList(prefStore, name, value, null);
- }
-
- /**
- * Saves an array of string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param values
- * an array of string values
- */
- public static void setStringValues(IPreferenceStore prefStore, String name,
- String[] values) {
- if (prefStore != null && name != null && values != null) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- buffer.append(values[i]);
- buffer.append(PREFERENCE_DELIMITER);
- }
- prefStore.setValue(name, buffer.toString());
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java
deleted file mode 100644
index 926cc5ad791..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java
+++ /dev/null
@@ -1,208 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Displays a message dialog that displays wrapped text.
- *
- * @author Bingxue Xu
- * @since 1.0
- */
-public class WrappedMessageDialog extends MessageDialog {
-
- public WrappedMessageDialog(Shell parentShell, String dialogTitle,
- Image dialogTitleImage, String dialogMessage, int dialogImageType,
- String[] dialogButtonLabels, int defaultIndex) {
- super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
- dialogImageType, dialogButtonLabels, defaultIndex);
- }
-
- protected Control createMessageArea(Composite composite) {
-
- Control rComposite = super.createMessageArea(composite);
-
- int minWidth = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH;// + 300;
- // TO-DO: need to revist the # of dialog display units and margin
- // when in other languages
- int charsPerLine = minWidth / 4 - 15;
- GridData gd = (GridData) messageLabel.getLayoutData();
- gd.minimumWidth = minWidth;
- messageLabel.setText(addLineBreaks(message, charsPerLine));
-
- return rComposite;
- }
-
- String addLineBreaks(String msg, int maxChars) {
- // System.out.println("$$$ DEBUG: original message = " + msg);
-
- if (msg == null)
- return null;
-
- StringBuffer strBuf = new StringBuffer();
- int count = 0;
- for (int i = 0; i < msg.length(); i++) {
- strBuf.append(msg.charAt(i));
- if (Character.isWhitespace(msg.charAt(i)))
- count = 0;
- else
- count++;
-
- if (count >= maxChars) {
- if (!Character.isWhitespace(msg.charAt(i))) {
- strBuf.append("\n"); //$NON-NLS-1$
- }
- count = 0;
- }
- }
-
- // System.out.println("$$$ DEBUG: broken message = " +
- // strBuf.toString());
- return strBuf.toString();
- }
-
- public static boolean openConfirm(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0); // OK is the
- // default
- return dialog.open() == 0;
- }
-
- static class ConfirmWithCheckBoxDialog extends WrappedMessageDialog {
- private String checkBoxLabel;
- private Button checkBox;
- private boolean checkBoxChecked = false;
-
- public ConfirmWithCheckBoxDialog(Shell parentShell, String dialogTitle,
- Image dialogTitleImage, String dialogMessage, int dialogImageType,
- String[] dialogButtonLabels, int defaultIndex, String checkBoxLabel) {
- super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
- dialogImageType, dialogButtonLabels, defaultIndex);
- this.checkBoxLabel = checkBoxLabel;
- }
-
- @Override
- protected Control createMessageArea(Composite composite) {
- Control rComposite = super.createMessageArea(composite);
-
- checkBox = new Button(composite, SWT.CHECK);
- checkBox.setText(checkBoxLabel);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- checkBox.setLayoutData(gd);
-
- return rComposite;
- }
-
- protected void buttonPressed(int buttonId) {
- checkBoxChecked = checkBox.getSelection();
- super.buttonPressed(buttonId);
- }
-
- public boolean isCheckBoxChecked() {
- return checkBoxChecked;
- }
-
- }
-
- //return: 0 = cancel, 1 = ok with check-box checked, 2 = ok with check box unchecked
- public static int openConfirmWithCheckBox(Shell parent, String title, String message, String checkBoxLabel) {
- ConfirmWithCheckBoxDialog dialog = new ConfirmWithCheckBoxDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0, checkBoxLabel); // OK is the default
-
- int ix = dialog.open() ;
- if (ix != 0) {
- return 0;
- }
-
- return dialog.isCheckBoxChecked() ? 1 : 2;
- }
-
- public static void openError(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); // ok
- // is
- // the
- // default
- dialog.open();
- return;
- }
-
- public static void openInformation(Shell parent, String title,
- String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, INFORMATION,
- new String[] { IDialogConstants.OK_LABEL }, 0);
- // ok is the default
- dialog.open();
- return;
- }
-
- public static boolean openQuestion(Shell parent, String title,
- String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.YES_LABEL,
- IDialogConstants.NO_LABEL }, 0); // yes is the
- // default
- return dialog.open() == 0;
- }
-
- public static void openWarning(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); // ok
- // is
- // the
- // default
- dialog.open();
- return;
- }
-}

Back to the top