Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.wst.common.ui/src')
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/Messages.java176
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/UIPlugin.java175
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SaveDirtyFilesDialog.java157
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SelectSingleFileDialog.java135
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DefaultDragAndDropCommand.java110
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropCommand.java29
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropManager.java19
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ObjectTransfer.java117
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDragAdapter.java86
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDropAdapter.java768
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/NavigableTableViewer.java46
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/ResourceFilter.java101
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectMultiFilePage.java388
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFilePage.java95
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFileView.java450
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/TableNavigator.java407
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageEditorSite.java103
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageSelectionProvider.java52
-rw-r--r--plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostSelectionMultiPageEditorPart.java46
19 files changed, 0 insertions, 3460 deletions
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/Messages.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/Messages.java
deleted file mode 100644
index ce13bb881..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/Messages.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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 API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages {
- private static final String BUNDLE_NAME = "plugin"; //$NON-NLS-1$
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, Messages.class); //$NON-NLS-1$
- }
-
-// SelectSingleFilePage and SelectMultiFilePage
- public static String _UI_LABEL_SOURCE_FILES;
- public static String _UI_LABEL_SELECTED_FILES;
-
- public static String _UI_POPUP_EXPAND_ALL;
- public static String _UI_POPUP_COLLAPSE_ALL;
-
- public static String _UI_IMPORT_BUTTON;
- public static String _UI_IMPORT_BUTTON_TOOL_TIP;
-
-// SelectMultiFilePage
- public static String _UI_ADD_BUTTON_TOOL_TIP;
- public static String _UI_REMOVE_BUTTON_TOOL_TIP;
- public static String _UI_REMOVE_ALL_BUTTON_TOOL_TIP;
-
- public static String _UI_ADD_BUTTON;
- public static String _UI_REMOVE_BUTTON;
- public static String _UI_REMOVE_ALL_BUTTON;
-
-// SelectJavaProjectView
- public static String _UI_LABEL_CHOOSE_FOLDER;
-
-// SelectJavaProjectDialog
- public static String _UI_LABEL_FOLDER_SELECTION;
-
-// TextViewerOperationAction
- public static String _UI_MENU_COPY;
- public static String _UI_MENU_CUT;
- public static String _UI_MENU_DELETE;
- public static String _UI_MENU_PASTE;
- public static String _UI_MENU_PREFIX;
- public static String _UI_MENU_REDO;
- public static String _UI_MENU_SELECT_ALL;
- public static String _UI_MENU_SHIFT_LEFT;
- public static String _UI_MENU_SHIFT_RIGHT;
- public static String _UI_MENU_STRIP_PREFIX;
- public static String _UI_MENU_UNDO;
-
-// SourceViewerGotoLineAction
- public static String _UI_MENU_GOTO_LINE;
- public static String _UI_GOTO_LINE_DIALOG_TITLE;
- public static String _UI_GOTO_LINE_DIALOG_TEXT;
-
- public static String _UI_FILE_CHANGED_TITLE;
- public static String _UI_FILE_DELETED_SAVE_CHANGES;
- public static String _UI_FILE_DELETED_EDITOR_CLOSED;
- public static String _UI_FILE_CHANGED_LOAD_CHANGES;
- public static String _UI_SAVE_BUTTON;
- public static String _UI_CLOSE_BUTTON;
-
-
-// XSL Prefererence
- public static String _UI_XSLT_SELECT;
- public static String _UI_XSLT_STYLESHEET;
- public static String _UI_XSLT_TRANSFORM;
-
-// XSL Debug Prefererence
- public static String _UI_XSL_DEBUG_SELECT_LAUNCHER;
- public static String _UI_XSL_DEBUG_LOCAL;
- public static String _UI_XSL_DEBUG_REMOTE;
- public static String _UI_XSL_TILE_EDITOR;
- public static String _UI_XSL_DEBUG_AND_TRANSFORM;
- public static String _UI_XSL_CONTEXT_URI;
- public static String _UI_XSL_CONTEXT;
-
-
- public static String _UI_OVERRIDE_FILE;
- public static String _UI_JAVA_EXIST_FILE1;
- public static String _UI_JAVA_EXIST_FILE2;
-
-// some options strings common to several plugins
- public static String _UI_ERROR_CREATING_FILE_TITLE;
- public static String _UI_ERROR_CREATING_FILE_SHORT_DESC;
- public static String _UI_ERROR_CREATING_FILE_LONG_DESC;
- public static String _UI_PARENT_FOLDER_IS_READ_ONLY;
- public static String _UI_UNKNOWN_ERROR_WITH_HINT;
- public static String _UI_UNKNOWN_ERROR;
-
-// usage - this label is followed by two radio button options for the file location
- public static String _UI_LABEL_INCLUDE_URL_FILE;
- public static String _UI_RADIO_FILE;
- public static String _UI_RADIO_URL;
-
- public static String _UI_LABEL_COMPONENTS;
- public static String _UI_LABEL_QUALIFIER;
-
-// - component selection dialogs
- public static String _UI_LABEL_COMPONENT_NAME;
- public static String _UI_LABEL_MATCHING_COMPONENTS;
- public static String _UI_LABEL_SPECIFIED_FILE;
- public static String _UI_LABEL_ENCLOSING_PROJECT;
- public static String _UI_LABEL_WORKSPACE;
- public static String _UI_LABEL_CURRENT_RESOURCE;
- public static String _UI_LABEL_SEARCH_SCOPE;
- public static String _UI_LABEL_NARROW_SEARCH_SCOPE_RESOURCE;
- public static String _UI_LABEL_AVAILABLE_TYPES;
- public static String _UI_LABEL_WORKING_SETS;
-
- public static String _UI_LABEL_New;
- public static String _UI_LABEL_DECLARATION_LOCATION;
- public static String _UI_LABEL_CHOOSE;
-
-
-
-
-
-
- /*======================================================================================
- !
- ! Here is the list of Error string that have message IDs - make sure they are unique
- ! Range for b2bgui messageIDs: IWAX1201 - IWAX1400
- !
- !======================================================================================*/
- public static String _ERROR_THE_CONTAINER_NAME;
-
- public static String _ERROR_LOCAL_LOCATION;
- public static String _ERROR_NOT_JAVA_PROJECT;
-
-// NOTE TO TRANSLATOR: this error message text is followed by a message from another plugin
- public static String _ERROR_INVALID_JAVA_PACKAGE;
-
-// NOTE TO TRANSLATOR: (_ERROR_BAD_FILENAME_EXTENSION + string + _UI_LABEL_OR + string) or (_ERROR_BAD_FILENAME_EXTENSION)
- public static String _ERROR_BAD_FILENAME_EXTENSION;
- public static String _ERROR_FILE_ALREADY_EXISTS;
-
- public static String _ERROR_CONTAINER_NOT_JAVA_BUILDPATH;
- public static String _ERROR_USE_PROJECT_JAVA_SOURCE_FOLDER;
-
- public static String _UI_ERROR;
-
- public static String _ERROR_ROOT_ELEMENT;
- public static String _ERROR_SAVING_FILE;
-
-// File Validator
- public static String _UI_ERROR_VALIDATE_FAIL_TITLE;
- public static String _UI_ERROR_VALIDATE_FAIL_MESSAGE;
-
-// PropertyDirtyChangeListener and PropertyResourceChangeListener
- public static String _UI_ERROR_VALIDATE_EDIT_FAIL_ONE_FILE;
-
-// public static String ExampleProjectCreationWizard.title;
-// public static String ExampleProjectCreationWizard.op_error.title;
-// public static String ExampleProjectCreationWizard.op_error.message;
-//
-// public static String ExampleProjectCreationWizard.overwritequery.title;
-// public static String ExampleProjectCreationWizard.overwritequery.message;
-//
-//
-// public static String ExampleProjectCreationOperation.op_desc;
-// public static String ExampleProjectCreationOperation.op_desc_proj;
-//
-// public static String ExampleProjectCreationWizardPage.error.alreadyexists;
- public static String SaveFilesDialog_save_all_resources;
- public static String SaveFilesDialog_must_save;
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/UIPlugin.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/UIPlugin.java
deleted file mode 100644
index fafc278b8..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/UIPlugin.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class UIPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static UIPlugin plugin;
-
- /**
- * The constructor.
- */
- public UIPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static UIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle aResourceBundle = getDefault().getResourceBundle();
- try {
- return (aResourceBundle != null) ? aResourceBundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- public static String getString(String key)
- {
- return getResourceString(key);
- }
- /**
- * This gets the string resource and does one substitution.
- */
- public static String getString(String key, Object s1)
- {
- return MessageFormat.format(getResourceString(key), new Object [] { s1 });
- }
-
- /**
- * This gets the string resource and does two substitutions.
- */
- public static String getString(String key, Object s1, Object s2)
- {
- return MessageFormat.format(getResourceString(key), new Object [] { s1, s2 });
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- try {
- return Platform.getResourceBundle(plugin.getBundle());
- } catch (MissingResourceException x) {
- log(x);
- }
- return null;
- }
-
- public ImageDescriptor getImageDescriptor(String name) {
- try {
- URL url= new URL(getBundle().getEntry("/"), name);
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-
- public Image getImage(String iconName)
- {
- ImageRegistry imageRegistry = getImageRegistry();
-
- if (imageRegistry.get(iconName) != null)
- {
- return imageRegistry.get(iconName);
- }
- else
- {
- imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName));
- return imageRegistry.get(iconName);
- }
- }
-
- public static String getPluginId() {
- return getDefault().getBundle().getSymbolicName();
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(String message, Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e));
- }
-
- public static void log(String message) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null));
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getLocalizedMessage(), e));
- }
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- // TODO Auto-generated method stub
- super.start(context);
- }
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- // TODO Auto-generated method stub
- super.stop(context);
- }
-
- public static IWorkbenchPage getActivePage() {
- return getDefault().internalGetActivePage();
- }
-
- private IWorkbenchPage internalGetActivePage() {
- IWorkbenchWindow window= getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return null;
- return getWorkbench().getActiveWorkbenchWindow().getActivePage();
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SaveDirtyFilesDialog.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SaveDirtyFilesDialog.java
deleted file mode 100644
index ae180fdd3..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SaveDirtyFilesDialog.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.wst.common.ui.internal.dialogs;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ListDialog;
-import org.eclipse.wst.common.ui.internal.Messages;
-/**
- * A generic save files dialog. The bulk of the code for this dialog was taken
- * from the JDT refactoring support in
- * org.eclipse.jdt.internal.ui.refactoring.RefactoringSaveHelper. This class is
- * a good candidate for reuse amoung components.
- */
-public class SaveDirtyFilesDialog extends ListDialog
-{
- public static boolean saveDirtyFiles()
- {
- boolean result = true;
- // TODO (cs) add support for save automatically
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- IEditorPart[] dirtyEditors = getDirtyEditors();
- if (dirtyEditors.length > 0)
- {
- result = false;
- SaveDirtyFilesDialog saveDirtyFilesDialog = new SaveDirtyFilesDialog(shell);
- saveDirtyFilesDialog.setInput(Arrays.asList(dirtyEditors));
- // Save all open editors.
- if (saveDirtyFilesDialog.open() == Window.OK)
- {
- result = true;
- int numDirtyEditors = dirtyEditors.length;
- for (int i = 0; i < numDirtyEditors; i++)
- {
- dirtyEditors[i].doSave(null);
- }
- }
- }
- return result;
- }
-
- private static IEditorPart[] getDirtyEditors()
- {
- List result = new ArrayList(0);
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
- for (int i = 0; i < windows.length; i++)
- {
- IWorkbenchPage[] pages = windows[i].getPages();
- for (int x = 0; x < pages.length; x++)
- {
- IEditorPart[] editors = pages[x].getDirtyEditors();
- for (int z = 0; z < editors.length; z++)
- {
- IEditorPart ep = editors[z];
- result.add(ep);
- }
- }
- }
- return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]);
- }
-
- public SaveDirtyFilesDialog(Shell parent)
- {
- super(parent);
- setTitle(Messages.SaveFilesDialog_save_all_resources);
- setAddCancelButton(true);
- setLabelProvider(createDialogLabelProvider());
- setMessage(Messages.SaveFilesDialog_must_save);
- setContentProvider(new ListContentProvider());
- }
-
- protected Control createDialogArea(Composite container)
- {
- Composite result = (Composite) super.createDialogArea(container);
- // TODO... provide preference that supports 'always save'
- return result;
- }
-
-
- private ILabelProvider createDialogLabelProvider()
- {
- return new LabelProvider()
- {
- public Image getImage(Object element)
- {
- return ((IEditorPart) element).getTitleImage();
- }
-
- public String getText(Object element)
- {
- return ((IEditorPart) element).getTitle();
- }
- };
- }
-
- /**
- * A specialized content provider to show a list of editor parts.
- * This class has been copied from org.eclipse.jdt.internal.ui.viewsupport.ListContentProvider
- * This class should be removed once a generic solution is made available.
- */
- private static class ListContentProvider implements IStructuredContentProvider
- {
- List fContents;
-
- public ListContentProvider()
- {
- }
-
- public Object[] getElements(Object input)
- {
- if (fContents != null && fContents == input)
- return fContents.toArray();
- return new Object[0];
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- if (newInput instanceof List)
- fContents = (List) newInput;
- else
- fContents = null;
- // we use a fixed set.
- }
-
- public void dispose()
- {
- }
-
- public boolean isDeleted(Object o)
- {
- return fContents != null && !fContents.contains(o);
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SelectSingleFileDialog.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SelectSingleFileDialog.java
deleted file mode 100644
index 03503e873..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dialogs/SelectSingleFileDialog.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.resource.DeviceResourceException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-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.Shell;
-import org.eclipse.wst.common.ui.internal.UIPlugin;
-import org.eclipse.wst.common.ui.internal.viewers.SelectSingleFileView;
-
-
-
-public class SelectSingleFileDialog extends TitleAreaDialog {
- protected SelectSingleFileView selectSingleFileView;
- protected Button okButton;
- protected Image image;
- private ImageDescriptor imageDescriptor;
-
- public SelectSingleFileDialog(Shell parentShell, IStructuredSelection selection, boolean isFileMandatory) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- if (selection == null) {
- selection = new StructuredSelection();
- }
- selectSingleFileView = new SelectSingleFileView(selection, isFileMandatory) {
- public void createFilterControl(Composite composite) {
- SelectSingleFileDialog.this.createFilterControl(composite);
- }
- };
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
-
- // TODO.. enable context help
- // WorkbenchHelp.setHelp(dialogArea,
- // B2BGUIContextIds.BTBG_SELECT_SINGLE_FILE_DIALOG);
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- composite.setLayout(new GridLayout());
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = 350;
- gd.heightHint = 350;
- composite.setLayoutData(gd);
-
- SelectSingleFileView.Listener listener = new SelectSingleFileView.Listener() {
- public void setControlComplete(boolean isComplete) {
- okButton.setEnabled(isComplete);
- }
- };
- selectSingleFileView.setListener(listener);
- selectSingleFileView.createControl(composite);
- return dialogArea;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- public void create() {
- super.create();
- selectSingleFileView.setVisibleHelper(true);
- image = getSaveAsImage();
- setTitleImage(image);
- }
-
- /**
- * this image was copied from org.eclipse.ui.ide/icons/full/wizban/ where
- * it is a non-API image, denoted by
- * IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG.
- */
- private Image getSaveAsImage() {
- Image localimage = null;
- try {
- if (imageDescriptor == null) {
- imageDescriptor = UIPlugin.getDefault().getImageDescriptor("icons/saveas_wiz.png");
- }
- localimage = (Image) imageDescriptor.createResource(getContents().getDisplay());
- }
- catch (DeviceResourceException e) {
- // if image not found
- localimage = (ImageDescriptor.getMissingImageDescriptor()).createImage();
- }
- return localimage;
- }
-
- public void createFilterCombo(Composite composite) {
- }
-
- public IFile getFile() {
- return selectSingleFileView.getFile();
- }
-
- public void addFilterExtensions(String[] filterExtensions) {
- selectSingleFileView.addFilterExtensions(filterExtensions);
- }
-
- public void addFilterExtensions(String[] filterExtensions, IFile[] excludedFiles) {
- selectSingleFileView.addFilterExtensions(filterExtensions, excludedFiles);
- }
-
- public void createFilterControl(Composite composite) {
- }
-
- public boolean close() {
- if (image != null && imageDescriptor != null) {
- imageDescriptor.destroyResource(image);
- image = null;
- }
- return super.close();
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DefaultDragAndDropCommand.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DefaultDragAndDropCommand.java
deleted file mode 100644
index 9631e6a7e..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DefaultDragAndDropCommand.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.swt.dnd.DND;
-
-
-abstract public class DefaultDragAndDropCommand implements DragAndDropCommand
-{
- /**
- * This keeps track of the owner that is the target of the drag and drop.
- */
- protected Object target;
-
- /**
- * This keeps track of the location of the drag and drop.
- */
- protected float location;
-
- /**
- * This keeps track of the lower range of locations in which the effect of this command remains unchanged.
- */
- protected float lowerLocationBound;
-
- /**
- * This keeps track of the upper range of locations in which the effect of this command remains unchanged.
- */
- protected float upperLocationBound;
-
- /**
- * This keeps track of the permitted operations.
- */
- protected int operations;
-
- /**
- * This keeps track of the current operation that will be returned by {@link #getOperation}.
- */
- protected int operation;
-
- /**
- * This keeps track of the feedback that will be returned by {@link #getFeedback}.
- */
- protected int feedback;
-
- /**
- * This keeps track of the collection of dragged sources.
- */
- protected Collection sources;
-
- public DefaultDragAndDropCommand(Object target, float location, int operations, int operation, Collection sources)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.sources = new ArrayList(sources);
- if (!canExecute())
- {
- this.operation = DND.DROP_NONE;
- }
-
- }
-
- public int getFeedback()
- {
- if (isAfter())
- {
- return DND.FEEDBACK_INSERT_AFTER;
- }
- else
- {
- return DND.FEEDBACK_INSERT_BEFORE;
- }
- }
-
- public boolean isAfter()
- {
- return location > 0.5;
- }
-
- public int getOperation()
- {
- return operation;
- }
-
- public void reinitialize(Object target, float location, int operations, int operation, Collection sources)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.sources = new ArrayList(sources);
- if (!canExecute())
- {
- this.operation = DND.DROP_NONE;
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropCommand.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropCommand.java
deleted file mode 100644
index 0ceb41448..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropCommand.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-import java.util.Collection;
-
-public interface DragAndDropCommand
-{
- // public DragAndDropCommand(Object target, float location, int operations, int operation, Collection sources);
-
- public boolean canExecute();
-
- public void execute();
-
- public int getFeedback();
-
- public int getOperation();
-
- public void reinitialize(Object target, float location, int operations, int operation, Collection sources);
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropManager.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropManager.java
deleted file mode 100644
index 013a5b24d..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/DragAndDropManager.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-import java.util.Collection;
-
-public interface DragAndDropManager
-{
- public DragAndDropCommand createCommand(Object target, float location, int operations, int operation, Collection source);
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ObjectTransfer.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ObjectTransfer.java
deleted file mode 100644
index 684eafa68..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ObjectTransfer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.TransferData;
-
-
-/**
- * This derived implementation of a byte array transfer short circuits the transfer process
- * so that a local transfer does not serialize the object
- * and hence can and will return the original object, not just a clone.
- * You only really need ever know about {@link #getInstance ObjectTransfer.getInstance()},
- * so that you can include it in when adding drag support to a viewer.
- * See {@link EditingDomainViewerDropAdapter} and {@link ViewerDragAdapter} for more details.
- * <p>
- * As an addded guard, the time is recorded and serialized in javaToNative
- * to that navive to java can ensure that it's returns the value that was really to have been transferred.
- */
-public class ObjectTransfer extends ByteArrayTransfer
-{
- /**
- * This is the register transfer type name.
- */
- protected static final String TYPE_NAME = "local-transfer-format";
-
- /**
- * This is the ID that is registered to the name.
- */
- protected static final int TYPE_ID = registerType(TYPE_NAME);
-
- /**
- * This is initialized and returned by {@link #getInstance}.
- */
- protected static ObjectTransfer instance;
-
- /**
- * This returns the one instance of this transfer agent.
- */
- public static ObjectTransfer getInstance()
- {
- if (instance == null)
- {
- instance = new ObjectTransfer();
- }
-
- return instance;
- }
-
- /**
- * This records the time at which the transfer data was recorded.
- */
- protected long startTime;
-
- /**
- * This records the data being transferred.
- */
- protected Object object;
-
- /**
- * This creates an instance; typically you get one from {@link #getInstance}.
- */
- protected ObjectTransfer()
- {
- }
-
- /**
- * This returns the transfer ids that this agent supports.
- */
- protected int[] getTypeIds()
- {
- return new int[] { TYPE_ID };
- }
-
- /**
- * This returns the transfer names that this agent supports.
- */
- public String[] getTypeNames()
- {
- return new String[] { TYPE_NAME };
- }
-
- /**
- * This records the object and current time and encodes only the current time into the transfer data.
- */
- public void javaToNative(Object object, TransferData transferData)
- {
- startTime = System.currentTimeMillis();
- this.object = object;
- if (transferData != null)
- {
- super.javaToNative(String.valueOf(startTime).getBytes(), transferData);
- }
- }
-
- /**
- * This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.
- */
- public Object nativeToJava(TransferData transferData)
- {
- long startTime = Long.valueOf(new String((byte[])super.nativeToJava(transferData))).longValue();
- return
- this.startTime == startTime ?
- object :
- null;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDragAdapter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDragAdapter.java
deleted file mode 100644
index d3aa343de..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDragAdapter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-
-
-/**
- * This is an implemention of {@link DragSourceListener}.
- * It allows the selection in effect at the start of the drag and drop interaction to be recorded,
- * which is especially important for a drag and drop interaction within a single view.
- * This is how one of these adapters is typically hooked up:
- * <pre>
- * viewer.addDragSupport
- * (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK,
- * new Transfer [] { LocalTransfer.getInstance() },
- * ViewerDragAdapter(viewer));
- * </pre>
- * Doing so simply allows a drag operation to be initiated from the viewer
- * such that the viewer's selection is transferred to the drop target.
- * See {@link EditingDomainViewerDropAdapter} and {@link LocalTransfer} for more details.
- */
-public class ViewerDragAdapter implements DragSourceListener
-{
- /**
- * This keeps track of the viewer to which we are listening.
- */
- protected Viewer viewer;
-
- /**
- * This keeps track of the selection that is in effect at the start of the drag operation
- */
- protected ISelection selection;
-
- /**
- * This creates an instance for the given viewer.
- */
- public ViewerDragAdapter(Viewer viewer)
- {
- super();
-
- // Remember the viewer and listen to SWT.DragDetect to alert the start of the drag operation.
- //
- this.viewer = viewer;
- }
-
- /**
- * This is called when dragging is initiated; it records the {@link #selection} of {@link #viewer}.
- */
- public void dragStart(DragSourceEvent event)
- {
- selection = viewer.getSelection();
- }
-
- /**
- * This is called when dragging is completed; it forgets the {@link #selection}.
- */
- public void dragFinished(DragSourceEvent event)
- {
- selection = null;
- }
-
- /**
- * This is called to transfer the data.
- */
- public void dragSetData(DragSourceEvent event)
- {
- if (ObjectTransfer.getInstance().isSupportedType(event.dataType))
- {
- event.data = selection;
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDropAdapter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDropAdapter.java
deleted file mode 100644
index 3bd03f24c..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/dnd/ViewerDropAdapter.java
+++ /dev/null
@@ -1,768 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.dnd;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * This implementation of a drop target listener
- * is designed to turn a drag and drop operation into a {@link Command} based on the model objects of an {@link EditingDomain}
- * and created by {@link DragAndDropManager#create}.
- * It is designed to do early data transfer so the the enablement and feedback of the drag and drop interaction
- * can intimately depend on the state of the model objects involed.
- * <p>
- * The base implementation of this class should be sufficient for most applications.
- * Any change in behaviour is typically accomplished by overriding
- * {@link ItemProviderAdapter}.createDragAndDropCommand
- * to return a derived implementation of {@link DragAndDropCommand}.
- * This is how one these adapters is typically hooked up:
- * <pre>
- * viewer.addDropSupport
- * (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK,
- * new Transfer [] { ObjectTransfer.getInstance() },
- * EditingDomainViewerDropAdapter(viewer));
- * </pre>
- * <p>
- * This implementation prefers to use a {@link ObjectTransfer},
- * which short-circuits the transfer process for simple transfers within the workbench,
- * the method {@link #getDragSource} can be overriden to change the behaviour.
- * The implementation also only handles an {@link IStructuredSelection},
- * but the method {@link #extractDragSource} can be overriden to change the behaviour.
- * <p>
- * You can call {@link #setHoverThreshold} to set the amount of time, in milliseconds,
- * to hover over an item before {@link #hover} is called;
- * the default is 1500 milliseconds.
- */
-public class ViewerDropAdapter extends DropTargetAdapter
-{
- /**
- * This is the viewer for which this is a drop target listener.
- */
- protected Viewer viewer;
-
- /**
- * This is the collection of source objects being dragged.
- */
- protected Collection source;
-
- /**
- * This is the command created during dragging which provides the feedback and will carry out the action upon completion.
- */
- // protected Command command;
- protected DragAndDropCommand command;
-
- /**
- * This records the object for which the {@link #command} was created.
- */
- protected Object commandTarget;
-
- /**
- * The amount of time to hover over a tree item before expanding it
- */
- protected int hoverThreshold = 1500;
-
- /**
- * The is the time the mouse first started hovering over the current item.
- */
- protected long hoverStart = 0;
-
- /**
- * This keeps track of the most recent item for the {@link #hoverStart}.
- */
- protected Widget previousItem;
-
- /**
- * This keeps track of the original operation that was in effect before we set the event.detail in here.
- */
- protected int originalOperation;
-
- /**
- * This keeps track of the information used to create the current command.
- */
- protected DragAndDropCommandInformation dragAndDropCommandInformation;
-
- protected DragAndDropManager dragAndDropManager;
-
- /**
- * This creates and instance of the given domain and viewer.
- */
- public ViewerDropAdapter(Viewer viewer, DragAndDropManager dragAndDropManager)
- {
- this.viewer = viewer;
- this.dragAndDropManager = dragAndDropManager;
- }
-
- /**
- * This is called when the mouse first enters or starts dragging in the viewer.
- */
- public void dragEnter(DropTargetEvent event)
- {
- originalOperation = event.detail;
- helper(event);
- }
-
- /**
- * This is called when the mouse leaves or stops dragging in the viewer
- */
- public void dragLeave(DropTargetEvent event)
- {
- // Clean up the command if there is one.
- //
- if (command != null)
- {
-// command.dispose();
- command = null;
- commandTarget = null;
- }
-
- // Reset the other values.
- //
- previousItem = null;
- hoverStart = 0;
- source = null;
- }
-
- /**
- * This is called when the operation has changed in some way, typically because the user changes keyboard modifiers.
- */
- public void dragOperationChanged(DropTargetEvent event)
- {
- originalOperation = event.detail;
- helper(event);
- }
-
- /**
- * This is called repeated when the mouse over the viewer.
- */
- public void dragOver(DropTargetEvent event)
- {
- helper(event);
- }
-
- /**
- * This is called just as the mouse is released over the viewer to initiate a drop.
- */
- public void dropAccept(DropTargetEvent event)
- {
- // There seems to be a bug in SWT that the view may have scrolled.
- // helper(event);
- }
-
- /**
- * This is called to indate that the drop action should be invoked.
- */
- public void drop(DropTargetEvent event)
- {
- // There seems to be a bug in SWT that the view may have scrolled.
- // helper(event);
- if (dragAndDropCommandInformation != null)
- {
- command = dragAndDropCommandInformation.createCommand();
-
- // Execute the command
- command.execute();
-
- // Clean up the state.
- //
- command = null;
- commandTarget = null;
- previousItem = null;
- hoverStart = 0;
- source = null;
- }
- }
-
- /**
- * This method is called the same way for each of the {@link org.eclipse.swt.dnd.DropTargetListener} methods, except during leave.
- */
- protected void helper(DropTargetEvent event)
- {
- // Try to get the source if there isn't one.
- //
- if (source == null)
- {
- source = getDragSource(event);
- }
- else if (event.currentDataType == null)
- {
- setCurrentDataType(event);
- }
-
- // If there's still no source, wait until the next time to try again.
- //
- if (source == null)
- {
- event.detail = DND.DROP_NONE;
- event.feedback = DND.FEEDBACK_SELECT;
- }
- // Otherwise, if we need to scroll...
- //
- else if (scrollIfNeeded(event))
- {
- // In the case that we scroll, we just do all the work on the next event and only just scroll now.
- //
- event.feedback = DND.FEEDBACK_SELECT;
- }
- else
- {
- // Get the data from the item, if there is one.
- //
- Object target = event.item == null ? null : event.item.getData();
- if (target instanceof TableTreeItem)
- {
- target = ((TableTreeItem)target).getData();
- }
-
- // Do the logic to determine the hover information.
- // If we're over a new item from before.
- //
- if (event.item != previousItem)
- {
- // Remember the item and the time.
- //
- previousItem = event.item;
- hoverStart = event.time;
- }
- else if (target != null)
- {
- if (event.time - hoverStart > hoverThreshold)
- {
- hover(target);
-
- // We don't need to hover over this guy again.
- //
- hoverStart = Integer.MAX_VALUE;
- }
- }
-
- // Determine if we can create a valid command at the current mouse location.
- //
- boolean valid = false;
-
- // If we don't have a previous cached command...
- //
- if (command == null)
- {
- // Create the command and test if it is executable.
- //
- commandTarget = target;
- command = dragAndDropManager.createCommand(target, getLocation(event), event.operations, event.detail, source);
- if (command != null)
- {
- valid = command.canExecute();
- }
- }
- else
- {
- int operation = originalOperation != event.detail ? originalOperation : event.detail;
-
- // Check if the cached command is able to provide drag and drop feedback.
- //
- if (target == commandTarget)// && command instanceof DragAndDropFeedback)
- {
- float location = getLocation(event);
-
- dragAndDropCommandInformation =
- new DragAndDropCommandInformation(target, location, event.operations, operation, source);
-
- // If so, revalidate the command.
- //
- command.reinitialize(target, location, event.operations, operation, source);
- if (command != null)
- {
- valid = command.canExecute();
- }
- }
- else
- {
- // If not, dispose the current command and create a new one.
- //
- // command.dispose();
- commandTarget = target;
-
- dragAndDropCommandInformation =
- new DragAndDropCommandInformation(target, getLocation(event), event.operations, operation, source);
-
- // DragAndDropManager.create(domain, target, getLocation(event), event.operations, operation, source);
- //
- command = dragAndDropCommandInformation.createCommand();
-
- if (command != null)
- {
- valid = command.canExecute();
- }
- }
- }
-
- // If this command can provide detailed drag and drop feedback...
- //
- //if (command instanceof DragAndDropCommand)
- if (command != null)
- {
- // Use the feedback for the operation and mouse point from the command.
- //
- event.detail = command.getOperation();
- event.feedback = command.getFeedback();
- }
- else if (valid)
- {
- // All we can know is to provide selection feedback.
- //
- event.feedback = DND.FEEDBACK_SELECT;
- }
- else
- {
- // There is no executable command, so we'd better nix the whole deal.
- //
- event.detail = DND.DROP_NONE;
- event.feedback = DND.FEEDBACK_SELECT;
- }
- }
- }
-
-
- protected void setCurrentDataType(DropTargetEvent event)
- {
- ObjectTransfer objectTransfer = ObjectTransfer.getInstance();
- TransferData [] dataTypes = event.dataTypes;
- for (int i = 0; i < dataTypes.length; ++i)
- {
- TransferData transferData = dataTypes[i];
- // If the local tansfer supports this datatype, switch to that data type
- //
- if (objectTransfer.isSupportedType(transferData))
- {
- event.currentDataType = transferData;
- }
- }
- }
-
- /**
- * This attempts to extract the drag source from the event early, i.e., before the drop method.
- * This implementation tries to use a {@link org.eclipse.wst.common.ui.internal.dnd.ObjectTransfer}.
- */
- protected Collection getDragSource(DropTargetEvent event)
- {
- // Check whether the current data type can be transfered locally.
- //
- ObjectTransfer objectTransfer = ObjectTransfer.getInstance();
- if (!objectTransfer.isSupportedType(event.currentDataType))
- {
- // Iterate over the data types to see if there is a datatype that supports a local transfer.
- //
- setCurrentDataType(event);
- return null;
- }
- else
- {
- // Transfer the data and extract it.
- //
- Object object = objectTransfer.nativeToJava(event.currentDataType);
- if (object == null)
- {
- return null;
- }
- else
- {
- return extractDragSource(object);
- }
- }
- }
-
- /**
- * This extracts a collection of dragged source objects from the given object retrieved from the transfer agent.
- * This default implementation converts a structured selection into a collection of elements.
- */
- protected Collection extractDragSource(Object object)
- {
- // Transfer the data and convert the structured selection to a collection of objects.
- //
- if (object instanceof IStructuredSelection)
- {
- Collection result = new ArrayList();
- for (Iterator elements = ((IStructuredSelection)object).iterator(); elements.hasNext(); )
- {
- result.add(elements.next());
- }
- return result;
- }
- else
- {
- return Collections.EMPTY_LIST;
- }
- }
-
- /**
- * This gets the amount of time, in milliseconds, to hover over an item before {@link #hover} is called.
- */
- public int getHoverThreshold()
- {
- return hoverThreshold;
- }
-
- /**
- * This set the amount of time, in milliseconds, to hover over an item before {@link #hover} is called.
- */
- public void setHoverThreshold(int hoverThreshold)
- {
- this.hoverThreshold = hoverThreshold;
- }
-
- /**
- * This is called when the cursor has hovered over the given target for longer than {@link #hoverThreshold}.
- */
- protected void hover(Object target)
- {
- if (viewer instanceof AbstractTreeViewer)
- {
- ((AbstractTreeViewer)viewer).expandToLevel(target, 1);
- }
- }
-
- /**
- * This returns whether a scroll was performed based on the given drag coordinates.
- */
- protected boolean scrollIfNeeded(DropTargetEvent event)
- {
- // By default we'll not scroll
- //
- boolean result = false;
-
- // We only handle a tree item right now.
- //
- if (event.item instanceof TreeItem)
- {
- // Tree items have special data that will help.
- //
- TreeItem treeItem = (TreeItem)event.item;
-
- // We need need the point in the coordinates of the control and the control's bounds.
- //
- Tree tree = treeItem.getParent();
- Point point = tree.toControl(new Point(event.x, event.y));
- Rectangle bounds = tree.getClientArea();
-
- // This is the distance in pixels from the top or bottom that will cause scrolling.
- //
- int scrollEpsilon = Math.min(treeItem.getBounds().height, bounds.height / 3);
-
- // This will be the item that should be scrolled into the view.
- //
- TreeItem scrollTreeItem = null;
-
- // If we should scroll up.
- //
- if (point.y < scrollEpsilon)
- {
- // Determine the parent to find the sibling.
- //
- TreeItem parent = treeItem.getParentItem();
- // Walk through the siblings.
- //
- TreeItem [] children = parent == null ? tree.getItems() : parent.getItems();
- for (int i = 0; i < children.length; ++i)
- {
- // Is this a match.
- //
- if (children[i] == treeItem)
- {
- // If there is a previous sibling...
- //
- if (i > 0)
- {
- scrollTreeItem = children[i - 1];
-
- // Get the last deepest descendent of this previous sibling.
- //
- for (;;)
- {
- children = scrollTreeItem.getItems();
- if (children != null && children.length != 0 && scrollTreeItem.getExpanded())
- {
- scrollTreeItem = children[children.length - 1];
- }
- else
- {
- break;
- }
- }
- }
- else
- {
- // The parent must be the previous.
- //
- scrollTreeItem = parent;
- }
-
- // We're done after the match.
- //
- break;
- }
- }
- }
- // If we should scroll down...
- //
- else if (bounds.height - point.y < scrollEpsilon)
- {
- // If this thing has visible children, then the first child must be next.
- //
- TreeItem [] children = treeItem.getItems();
- if (children != null && children.length != 0 && treeItem.getExpanded())
- {
- scrollTreeItem = children[0];
- }
- else
- {
- // We need the parent to determine siblings and will walk up the tree if we are the last sibling.
- //
- while (scrollTreeItem == null)
- {
- // If there's no parent, we're done.
- //
- TreeItem parent = treeItem.getParentItem();
- // Walk the children.
- //
- children = parent == null ? tree.getItems() : parent.getItems();
- for (int i = 0; i < children.length; ++i)
- {
- // When we find the child.
- //
- if (children[i] == treeItem)
- {
- // If the next index is a valid index...
- //
- if (++i < children.length)
- {
- // We've found the item.
- //
- scrollTreeItem = children[i];
- }
-
- // We're done with this parent.
- //
- break;
- }
- }
-
- if (parent == null)
- {
- break;
- }
-
- // Walk up.
- //
- treeItem = parent;
- }
- }
- }
-
- // If we should scroll.
- //
- if (scrollTreeItem != null)
- {
- // Only scroll if we're on an item for a while.
- //
- if (previousItem != null && event.time - hoverStart > 200)
- {
- ScrollBar verticalScrollBar = tree.getVerticalBar();
- if (verticalScrollBar != null)
- {
- int before = verticalScrollBar.getSelection();
-
- // Make sure the item is scrolled in place.
- //
- tree.showItem(scrollTreeItem);
-
- // Make sure we don't scroll again quickly.
- //
- previousItem = null;
-
- // Indicate that we've done a scroll and nothing else should be done.
- //
- result = before != verticalScrollBar.getSelection();
- }
- }
- else
- {
- // If the item changes, reset the timer information.
- //
- if (event.item != previousItem)
- {
- previousItem = event.item;
- hoverStart = event.time;
- }
- }
- }
- }
- else if (event.item instanceof TableItem)
- {
- // Table items have special data that will help.
- //
- TableItem tableItem = (TableItem)event.item;
-
- // We need need the point in the coordinates of the control and the control's bounds.
- //
- Table table = tableItem.getParent();
- Point point = table.toControl(new Point(event.x, event.y));
- Rectangle bounds = table.getClientArea();
- if (table.getHeaderVisible())
- {
- int offset = table.getItemHeight();
- bounds.y += offset;
- bounds.height -= offset;
- point.y -= offset;
- }
-
- // The position of this item.
- //
- int index = table.indexOf(tableItem);
-
- // This is the distance in pixels from the top or bottom that will cause scrolling.
- //
- int scrollEpsilon = Math.min(tableItem.getBounds(0).height, bounds.height / 3);
-
- // This will be the item that should be scrolled into the view.
- //
- TableItem scrollTableItem = null;
-
- // If we should scroll up.
- //
- if (point.y < scrollEpsilon)
- {
- if (index > 0)
- {
- scrollTableItem = table.getItems()[index - 1];
- }
- }
- // If we should scroll down...
- //
- else if (bounds.height - point.y < scrollEpsilon)
- {
- if (index + 1 < table.getItems().length)
- {
- scrollTableItem = table.getItems()[index + 1];
- }
- }
-
- // If we should scroll.
- //
- if (scrollTableItem != null)
- {
- // Only scroll if we're on an item for a while.
- //
- if (previousItem != null && event.time - hoverStart > 200)
- {
- ScrollBar verticalScrollBar = table.getVerticalBar();
- if (verticalScrollBar != null)
- {
- int before = verticalScrollBar.getSelection();
-
- // Make sure the item is scrolled in place.
- //
- table.showItem(scrollTableItem);
-
- // Make sure we don't scroll again quickly.
- //
- previousItem = null;
-
- // Indicate that we've done a scroll and nothing else should be done.
- //
- result = before != verticalScrollBar.getSelection();
- }
- }
- else
- {
- // If the item changes, reset the timer information.
- //
- if (event.item != previousItem)
- {
- previousItem = event.item;
- hoverStart = event.time;
- }
- }
- }
- }
-
- return result;
- }
-
- protected static float getLocation(DropTargetEvent event)
- {
- if (event.item instanceof TreeItem)
- {
- TreeItem treeItem = (TreeItem)event.item;
- Control control = treeItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = treeItem.getBounds();
- return (float)(point.y - bounds.y) / (float)bounds.height;
- }
- else if (event.item instanceof TableItem)
- {
- TableItem tableItem = (TableItem)event.item;
- Control control = tableItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = tableItem.getBounds(0);
- return (float)(point.y - bounds.y) / (float)bounds.height;
- }
- else
- {
- return 0.0F;
- }
- }
-
- protected class DragAndDropCommandInformation
- {
- // protected EditingDomain domain;
- protected Object target;
- protected float location;
- protected int operations;
- protected int operation;
- protected Collection source;
- public DragAndDropCommandInformation
- (Object target, float location, int operations, int operation, Collection source)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.source = new ArrayList(source);
- }
-
- public DragAndDropCommand createCommand()
- {
- return dragAndDropManager.createCommand(target, location, operations, operation, source);
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/NavigableTableViewer.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/NavigableTableViewer.java
deleted file mode 100644
index 9f03d3be2..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/NavigableTableViewer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Table;
-
-public class NavigableTableViewer extends TableViewer
-{
- TableNavigator navigator;
-
- public NavigableTableViewer(Table parent)
- {
- super(parent);
- navigator = new TableNavigator(getTable(), this);
- }
-
- //override setCellEditors to put in call to moveAboveCellEditors for TableNavigator
- public void setCellEditors(CellEditor[] editors)
- {
- super.setCellEditors(editors);
- navigator.moveCellEditorsAbove(editors);
-
- }
-
- //override refresh so that TableNavigator is refreshed for all model changes
- public void refresh()
- {
- if( !this.getTable().isDisposed() )
- {
- super.refresh();
- navigator.refresh();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/ResourceFilter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/ResourceFilter.java
deleted file mode 100644
index aaa3f5d20..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/ResourceFilter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import java.util.Collection;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-public class ResourceFilter extends ViewerFilter
-{
- protected String[] fExtensions;
- protected IFile[] fExcludedFiles;
- protected Collection fExcludes;
-
- public ResourceFilter(String[] extensions, Collection exclude)
- {
- fExtensions= extensions;
- fExcludes= exclude;
- fExcludedFiles = null;
- }
-
- public ResourceFilter(String[] extensions, IFile[] excludedFiles, Collection exclude)
- {
- fExtensions= extensions;
- fExcludes= exclude;
- fExcludedFiles = excludedFiles;
- }
-
- public boolean isFilterProperty(Object element, Object property)
- {
- return false;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element)
- {
- if (element instanceof IFile)
- {
- if (fExcludes != null && fExcludes.contains(element))
- {
- return false;
- }
- String name= ((IFile)element).getName();
- if (fExcludedFiles != null)
- {
- for (int j= 0; j < fExcludedFiles.length; j++)
- {
- if ( ((IFile)element).getLocation().
- toOSString().compareTo((fExcludedFiles[j]).getLocation().toOSString()) == 0 )
- return false;
- }
- }
- if (fExtensions.length == 0)
- {
- // assume that we don't want to filter any files based on
- // extension
- return true;
- }
- for (int i= 0; i < fExtensions.length; i++)
- {
- if (name.endsWith(fExtensions[i]))
- {
- return true;
- }
- }
- return false;
- }
- else if (element instanceof IContainer)
- { // IProject, IFolder
- try
- {
- IResource[] resources= ((IContainer)element).members();
- for (int i= 0; i < resources.length; i++)
- {
- // recursive!
- if (select(viewer, parent, resources[i]))
- {
- return true;
- }
- }
- }
- catch (CoreException e)
- {
- }
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectMultiFilePage.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectMultiFilePage.java
deleted file mode 100644
index d8a9083eb..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectMultiFilePage.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import java.util.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.wizard.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.core.resources.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.model.*;
-import org.eclipse.ui.wizards.datatransfer.*;
-import org.eclipse.wst.common.ui.internal.Messages;
-
-
-// Page to specify the source files
-public class SelectMultiFilePage extends WizardPage {
- IWorkbench workbench;
- IStructuredSelection selection;
- boolean isFileMandatory;
- TreeViewer sourceFileViewer;
- Button addButton;
- Button removeButton;
- Button removeAllButton;
- org.eclipse.swt.widgets.List selectedListBox;
- Button importButton;
- private Vector fFilters;
- protected IFile[] fileNames;
- IWorkspaceRoot workspaceRoot;
-
- private final static int SIZING_LISTS_HEIGHT = 200;
- private final static int SIZING_LISTS_WIDTH = 150;
-
- // parameter isFileMandatory is used to determine if at least one file must be selected
- // before being able to proceed to the next page
- public SelectMultiFilePage(
- IWorkbench workbench,
- IStructuredSelection selection,
- boolean isFileMandatory) {
- super("SelectMultiFilePage");
- this.workbench = workbench;
- this.selection = selection;
- this.isFileMandatory = isFileMandatory;
- this.workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- this.fileNames = null;
- }
-
- public void createControl(Composite parent) {
-
- Composite pageContent = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- pageContent.setLayout(layout);
- pageContent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // variable never used ... is pageContent.getLayoutData() needed?
- //GridData outerFrameGridData = (GridData)
- pageContent.getLayoutData();
-
- // outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
- // outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;
-
- // WorkbenchHelp.setHelp(
- // pageContent,
- // B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE);
-
- createLabels(pageContent);
- createSourceViewer(pageContent);
- createButtonPanel(pageContent);
- createSelectedListBox(pageContent);
- createImportButton(pageContent);
-
- setControl(pageContent);
- if (isFileMandatory)
- setPageComplete(false);
-
- }
-
- public IFile[] getFiles() {
- return fileNames;
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions) {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions =
- new String[filterExtensions.length];
- for (int i = 0; i < filterExtensions.length; i++) {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- correctedFilterExtensions[i] = filterExtensions[i];
- else
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
-
- ViewerFilter filter =
- new ResourceFilter(correctedFilterExtensions, null);
- addFilter(filter);
- }
-
- public boolean isValidSourceFileViewerSelection(ISelection selection) {
- return true;
- }
-
- public void setVisible(boolean visible) {
- if (visible == true) {
- if (fFilters != null) {
- sourceFileViewer.resetFilters();
- for (Iterator i = fFilters.iterator(); i.hasNext();)
- sourceFileViewer.addFilter((ViewerFilter) i.next());
- }
- sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
- }
- super.setVisible(visible);
- }
-
- public void setFiles(String[] fileNames) {
- int size = Arrays.asList(fileNames).size();
- Vector iFileNames = new Vector();
- for (int i = 0; i < size; i++) {
- IResource resource = workspaceRoot.findMember(fileNames[i]);
- if (resource instanceof IFile)
- iFileNames.addElement(resource);
- }
- IFile[] dummyArray = new IFile[iFileNames.size()];
- this.fileNames = (IFile[]) (iFileNames.toArray(dummyArray));
- }
-
- public void resetFilters() {
- fFilters = null;
- }
-
- public void addFilter(ViewerFilter filter) {
- if (fFilters == null)
- fFilters = new Vector();
- fFilters.add(filter);
- }
-
- public void setAddButtonEnabled(boolean isEnabled) {
- addButton.setEnabled(isEnabled);
- }
-
- public void setRemoveButtonEnabled(boolean isEnabled) {
- removeButton.setEnabled(isEnabled);
- }
-
- private void createLabels(Composite pageContent) {
- Label label = new Label(pageContent, SWT.LEFT);
- label.setText(Messages._UI_LABEL_SOURCE_FILES);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- label = new Label(pageContent, SWT.LEFT);
- label.setText(Messages._UI_LABEL_SELECTED_FILES);
- }
-
- public boolean checkIfFileInTarget(IFile fileToCheck) {
- String[] strings = selectedListBox.getItems();
- int size = selectedListBox.getItemCount();
- for (int i = 0; i < size; i++) {
- if (strings[i].compareTo(fileToCheck.getFullPath().toString())
- == 0)
- return true;
- }
- return false;
- }
-
- private void createSourceViewer(Composite parent) {
- sourceFileViewer =
- new TreeViewer(
- new Tree(
- parent,
- SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER));
- sourceFileViewer.setContentProvider(new WorkbenchContentProvider());
- sourceFileViewer.setLabelProvider(new WorkbenchLabelProvider());
- sourceFileViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- java.util.List list;
- ISelection selection = event.getSelection();
- boolean newFilesSelected = false;
-
- if (selection instanceof IStructuredSelection) {
- list = ((IStructuredSelection) selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();) {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile) {
- if (checkIfFileInTarget((IFile) resource) == false)
- newFilesSelected = true;
- }
- }
- setAddButtonEnabled(newFilesSelected);
- }
- }
- });
- sourceFileViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- addSelectedFilesToTargetList();
- }
- });
-
- Control treeWidget = sourceFileViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = SIZING_LISTS_WIDTH;
- gd.heightHint = SIZING_LISTS_HEIGHT;
- treeWidget.setLayoutData(gd);
- }
-
- private void createButtonPanel(Composite pageContent) {
- Composite buttonPanel = new Composite(pageContent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- buttonPanel.setLayout(layout);
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.grabExcessVerticalSpace = true;
- gridData.verticalAlignment = GridData.CENTER;
- gridData.horizontalAlignment = GridData.CENTER;
- buttonPanel.setLayoutData(gridData);
-
- addButton = new Button(buttonPanel, SWT.PUSH);
- addButton.setText(Messages._UI_ADD_BUTTON);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- addButton.setLayoutData(gridData);
- addButton.addSelectionListener(new ButtonSelectListener());
- addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP);
- addButton.setEnabled(false);
-
- removeButton = new Button(buttonPanel, SWT.PUSH);
- removeButton.setText(Messages._UI_REMOVE_BUTTON);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- removeButton.setLayoutData(gridData);
- removeButton.addSelectionListener(new ButtonSelectListener());
- removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP);
- removeButton.setEnabled(false);
-
- removeAllButton = new Button(buttonPanel, SWT.PUSH);
- removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- removeAllButton.setLayoutData(gridData);
- removeAllButton.addSelectionListener(new ButtonSelectListener());
- removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP);
- removeAllButton.setEnabled(false);
- }
-
- private void createSelectedListBox(Composite parent) {
- selectedListBox = new List(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- selectedListBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent event) {
- }
-
- public void widgetSelected(SelectionEvent event) {
-
- if (selectedListBox.getSelectionCount() > 0)
- setRemoveButtonEnabled(true);
- else
- setRemoveButtonEnabled(false);
- return;
- }
- });
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = SIZING_LISTS_WIDTH;
- gd.heightHint = SIZING_LISTS_HEIGHT;
- selectedListBox.setLayoutData(gd);
- }
-
- void createImportButton(Composite parent) {
- importButton = new Button(parent, SWT.PUSH);
- importButton.setText(Messages._UI_IMPORT_BUTTON);
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.CENTER;
- importButton.setLayoutData(gridData);
- importButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- FileSystemImportWizard importWizard =
- new FileSystemImportWizard();
- importWizard.init(workbench, selection);
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog =
- new WizardDialog(shell, importWizard);
- wizardDialog.create();
- wizardDialog.open();
- sourceFileViewer.refresh();
- }
- });
- importButton.setToolTipText(Messages._UI_IMPORT_BUTTON_TOOL_TIP);
- }
-
- public void addSelectedFilesToTargetList() {
- ISelection selection = sourceFileViewer.getSelection();
-
- if (isValidSourceFileViewerSelection(selection)) {
- java.util.List list = null;
- if (selection instanceof IStructuredSelection) {
- list = ((IStructuredSelection) selection).toList();
-
- if (list != null) {
- list = ((IStructuredSelection) selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();) {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile) {
- // Check if its in the list. Don't add it if it is.
- String resourceName =
- resource.getFullPath().toString();
- if (selectedListBox.indexOf(resourceName) == -1)
- selectedListBox.add(resourceName);
- }
- }
- setFiles(selectedListBox.getItems());
- }
-
- setAddButtonEnabled(false);
-
- if (selectedListBox.getItemCount() > 0) {
- removeAllButton.setEnabled(true);
- if (isFileMandatory)
- setPageComplete(true);
- if (selectedListBox.getSelectionCount() > 0)
- setRemoveButtonEnabled(true);
- else
- setRemoveButtonEnabled(false);
- }
- }
- }
- }
-
- class ButtonSelectListener implements SelectionListener {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == addButton) {
- addSelectedFilesToTargetList();
- } else if (e.widget == removeButton) {
- String[] strings = selectedListBox.getSelection();
- int size = selectedListBox.getSelectionCount();
- for (int i = 0; i < size; i++) {
- selectedListBox.remove(strings[i]);
- }
- removeButton.setEnabled(false);
- if (selectedListBox.getItemCount() == 0) {
- removeAllButton.setEnabled(false);
- if (isFileMandatory)
- setPageComplete(false);
- }
- setFiles(selectedListBox.getItems());
- } else if (e.widget == removeAllButton) {
- selectedListBox.removeAll();
- removeButton.setEnabled(false);
- removeAllButton.setEnabled(false);
- if (isFileMandatory)
- setPageComplete(false);
- setFiles(selectedListBox.getItems());
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFilePage.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFilePage.java
deleted file mode 100644
index 78af295c3..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFilePage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-//import org.eclipse.ui.help.WorkbenchHelp;
-
-public class SelectSingleFilePage extends WizardPage
-{
- protected IWorkbench workbench;
- protected SelectSingleFileView selectSingleFileView;
-
- // parameter isFileMandatory is used to determine if a file must be selected
- // before being able to proceed to the next page
- public SelectSingleFilePage(IWorkbench workbench, IStructuredSelection selection, boolean isFileMandatory)
- {
- super("SelectSingleFilePage");
- this.workbench = workbench;
- selectSingleFileView = new SelectSingleFileView(selection, isFileMandatory);
- }
-
- public void setVisible(boolean visible)
- {
- selectSingleFileView.setVisibleHelper(visible);
- super.setVisible(visible);
- }
-
- public void createControl(Composite parent)
- {
- SelectSingleFileView.Listener listener = new SelectSingleFileView.Listener()
- {
- public void setControlComplete(boolean isComplete)
- {
- setPageComplete(isComplete);
- }
- };
- selectSingleFileView.setListener(listener);
- Control control = selectSingleFileView.createControl(parent);
-// WorkbenchHelp.setHelp(control, B2BGUIContextIds.BTBG_SELECT_SINGLE_FILE_PAGE);
- setControl(control);
- }
-
- public void addFilter(ViewerFilter filter)
- {
- selectSingleFileView.addFilter(filter);
- }
-
- public void addFilterExtensions(String[] filterExtensions)
- {
- selectSingleFileView.addFilterExtensions(filterExtensions);
- }
-
- public void resetFilters()
- {
- selectSingleFileView.resetFilters();
- }
-
- public IFile getFile()
- {
- return selectSingleFileView.getFile();
- }
-
-
- /**
- * Returns the selectSingleFileView.
- * @return SelectSingleFileView
- */
- public TreeViewer getSourceFileViewer() {
- return selectSingleFileView.sourceFileViewer;
- }
-
- /**
- * Returns the selectSingleFileView.
- * @return SelectSingleFileView
- */
- public SelectSingleFileView getSelectSingleFileView() {
- return selectSingleFileView;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFileView.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFileView.java
deleted file mode 100644
index 70533c7cc..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/SelectSingleFileView.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.wizards.datatransfer.FileSystemImportWizard;
-import org.eclipse.wst.common.ui.internal.Messages;
-import org.eclipse.wst.common.ui.internal.UIPlugin;
-
-
-
-public class SelectSingleFileView
-{
- protected Composite composite;
- protected IStructuredSelection selection;
- protected boolean isFileMandatory;
- protected TreeViewer sourceFileViewer;
- protected Button importButton;
- protected Vector fFilters;
- protected IFile selectedFile;
- protected ISelection defaultSelection;
- protected Listener listener;
-
- public static interface Listener
- {
- public void setControlComplete(boolean isComplete);
- }
-
- public SelectSingleFileView(IStructuredSelection selection, boolean isFileMandatory)
- {
- this.selection = selection;
- this.isFileMandatory = isFileMandatory;
- this.selectedFile= null;
- this.defaultSelection = null;
- }
-
- public Composite createControl(Composite parent)
- {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Composite smallComposite = new Composite(composite, SWT.NONE);
- smallComposite.setLayoutData(new GridData(GridData.FILL, GridData.HORIZONTAL_ALIGN_FILL, true, false));
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginHeight = 0;
- smallComposite.setLayout(gridLayout);
-
- Label label = new Label(smallComposite, SWT.NONE);
- label.setText(Messages._UI_LABEL_SOURCE_FILES);
- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.END, false, false));
-
- //Collapse and Expand all buttons
- ToolBar toolBar = new ToolBar(smallComposite, SWT.FLAT);
- toolBar.setLayoutData(new GridData(GridData.END, GridData.END, true, false));
-
- ToolItem toolItem = new ToolItem(toolBar, SWT.NONE);
- ImageDescriptor imageDescriptor = UIPlugin.getDefault().getImageDescriptor("icons/expandAll.gif");
- Image image = imageDescriptor.createImage();
- toolItem.setImage(image);
- toolItem.setToolTipText(Messages._UI_POPUP_EXPAND_ALL);
- toolItem.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- sourceFileViewer.expandAll();
-
- }});
-
-
- toolItem = new ToolItem(toolBar, SWT.NONE);
- imageDescriptor = UIPlugin.getDefault().getImageDescriptor("icons/collapseAll.gif");
- image = imageDescriptor.createImage();
- toolItem.setImage(image);
- toolItem.setToolTipText(Messages._UI_POPUP_COLLAPSE_ALL);
- toolItem.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- sourceFileViewer.collapseAll();
-
- }});
-
- createSourceViewer(composite);
- createFilterControl(composite);
- createImportButton(composite);
- sourceFileViewer.getTree().setFocus();
- return composite;
- }
-
-
- protected void createFilterControl(Composite composite)
- {
- }
-
-public void setListener(Listener listener)
- {
- this.listener = listener;
- }
-
- protected void createSourceViewer(Composite parent)
- {
- sourceFileViewer = new TreeViewer(new Tree(parent, SWT.SINGLE | SWT.BORDER));
- sourceFileViewer.setContentProvider(new WorkbenchContentProvider());
- sourceFileViewer.setLabelProvider(new WorkbenchLabelProvider());
- sourceFileViewer.addSelectionChangedListener(new ISelectionChangedListener()
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- boolean isComplete = true;
- java.util.List list;
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection)
- {
- list = ((IStructuredSelection)selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();)
- {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile)
- {
- selectedFile = (IFile) resource;
- if (isFileMandatory)
- {
- isComplete = true;
- break;
- }
- }
- else
- {
- selectedFile = null;
- if (isFileMandatory)
- {
- isComplete = false;
- }
- }
- }
-
- if (listener != null)
- {
- listener.setControlComplete(isComplete);
- }
- }
- }
- });
- Control treeWidget = sourceFileViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- treeWidget.setLayoutData(gd);
- }
-
-
- protected void createImportButton(Composite parent)
- {
- importButton = new Button(parent, SWT.NONE);
- importButton.setText(Messages._UI_IMPORT_BUTTON);
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.CENTER;
- importButton.setLayoutData(gridData);
- importButton.addSelectionListener(new SelectionListener()
- {
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- // This listener is if the Import Wizard adds a new few, we want
- // it to be selected when we come back from it
- ImportAddResourceListener importAddResourceListener= new ImportAddResourceListener();
-
- ResourcesPlugin.getWorkspace().addResourceChangeListener(importAddResourceListener);
-
- FileSystemImportWizard importWizard = new FileSystemImportWizard();
- IWorkbench workbench = UIPlugin.getDefault().getWorkbench();
- selection = (IStructuredSelection) sourceFileViewer.getSelection();
- importWizard.init(workbench, selection != null ? selection : new StructuredSelection());
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog = new WizardDialog(shell, importWizard);
- wizardDialog.create();
- wizardDialog.open();
- sourceFileViewer.refresh();
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(importAddResourceListener);
- IFile importedFile = importAddResourceListener.getImportedFile();
- if (importedFile != null)
- {
- StructuredSelection structuredSelection = new StructuredSelection(importedFile);
- sourceFileViewer.setSelection(structuredSelection);
- }
- }
- });
- importButton.setToolTipText(Messages._UI_IMPORT_BUTTON_TOOL_TIP);
- }
-
- public IFile getFile()
- {
- return selectedFile;
- }
-
- public void setDefaultSelection(ISelection selection)
- {
- this.defaultSelection = selection;
- }
-
- public void resetFilters()
- {
- fFilters=null;
- }
-
- public void addFilter(ViewerFilter filter)
- {
- if (fFilters == null)
- {
- fFilters= new Vector();
- }
- fFilters.add(filter);
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
-
- ViewerFilter filter = new ResourceFilter(correctedFilterExtensions, null);
- addFilter(filter);
- }
-
-// This is a convenience method that allows filtering of the given file
-// exensions. It internally creates a ResourceFilter so that users of this
-// class don't have to construct one.
-// If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions, IFile [] excludedFiles)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
- ViewerFilter filter;
- if (excludedFiles != null)
- {
- filter = new ResourceFilter(correctedFilterExtensions, excludedFiles, null);
- }
- else
- {
- filter = new ResourceFilter(correctedFilterExtensions, null);
- }
- addFilter(filter);
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void setFilterExtensions(String[] filterExtensions)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
- ViewerFilter filter = new ResourceFilter(correctedFilterExtensions, null);
- fFilters= new Vector();
- fFilters.add(filter);
- if (sourceFileViewer != null)
- {
- sourceFileViewer.getTree().setRedraw(false);
- sourceFileViewer.resetFilters();
- for (Iterator i=fFilters.iterator(); i.hasNext();)
- {
- sourceFileViewer.addFilter((ViewerFilter)i.next());
- }
- sourceFileViewer.getTree().setRedraw(true);
- sourceFileViewer.getTree().redraw();
- }
- }
-
- // this method should be called by a Wizard page or Dialog when it becomes visible
- public void setVisibleHelper(boolean visible)
- {
- if (visible == true)
- {
- if (fFilters != null)
- {
- sourceFileViewer.resetFilters();
- for (Iterator i=fFilters.iterator(); i.hasNext();)
- sourceFileViewer.addFilter((ViewerFilter)i.next());
- }
- sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
- sourceFileViewer.expandToLevel(1);
-
- if (defaultSelection != null)
- {
- sourceFileViewer.setSelection(defaultSelection, true);
- }
- else if (!sourceFileViewer.getSelection().isEmpty())
- {
- sourceFileViewer.setSelection(sourceFileViewer.getSelection());
- }
- else
- {
- if (isFileMandatory && listener != null)
- {
- listener.setControlComplete(false);
- }
- }
- }
- }
-
- class ImportAddResourceListener implements IResourceChangeListener, IResourceDeltaVisitor
- {
- Vector importedFiles;
-
- ImportAddResourceListener()
- {
- importedFiles = new Vector();
- }
-
- public void resourceChanged(IResourceChangeEvent event)
- {
- IResourceDelta resourceDelta = event.getDelta();
-
- try
- {
- if (resourceDelta != null)
- {
- resourceDelta.accept(this);
- }
- }
- catch (Exception e)
- {
- //TODO... log exception
- //UIPlugin.getMsgLogger().write("Exception caught during resource change" + e);
- //UIPlugin.getMsgLogger().writeCurrentThread();
- }
- }
-
- public boolean visit(IResourceDelta delta)
- {
- if (delta.getKind() == IResourceDelta.ADDED)
- {
- if (delta.getResource() instanceof IFile)
- importedFiles.add(delta.getResource());
- }
- return true;
- }
-
- public Collection getImportedFiles()
- {
- return importedFiles;
- }
-
- // This returns the first imported file in the list of imported files
- public IFile getImportedFile()
- {
- if (importedFiles.isEmpty() == false)
- return (IFile)importedFiles.firstElement();
-
- return null;
- }
- }
-
- public void addSelectionChangedTreeListener(ISelectionChangedListener treeListener) {
- sourceFileViewer.addSelectionChangedListener(treeListener);
- }
-}
-
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/TableNavigator.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/TableNavigator.java
deleted file mode 100644
index 1d037a007..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/viewers/TableNavigator.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.common.ui.internal.viewers;
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.swt.custom.TableCursor;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.jface.viewers.*;
-
-
- /**
- * Adds a TableCursor to a StructuredViewer - for keyboard navigation of the table
- * The intent of this class is to provide the standard listeners for using F2 to
- * activate cell editors.
- *
- * Due to a current bug in the TableCursor, TableViewers using this class must make
- * a call similar to the TableNavigator method moveCellEditorsAbove(cellEditors)
- * whenever a setCellEditors call is made in the StructuredViewer. This is so that the
- * cell editor control shows up above the table cursor control.
- */
-
-public class TableNavigator extends TableCursor
-{
- private static final String TABLETREEITEM_ID = "TableTreeItemID";
-
- final Table table;
-
- public TableNavigator(Table table, StructuredViewer viewer)
- {
- super(table, SWT.NONE);
- this.table = table;
- final Table currentTable = table;
- final StructuredViewer sViewer = viewer;
-
- // Linux index out of bounds fix. See defect 253429, 253433, and more
- setVisible(false);
-
- addPaintListener(viewer);
- addKeyListeners(viewer);
- addMouseListeners(viewer);
- addSelectionListener(new SelectionAdapter()
- {
- /**
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- if (sViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)getRow().getData(TABLETREEITEM_ID);
- StructuredSelection selection = new StructuredSelection(tableTreeItem.getData());
- sViewer.setSelection(selection, true);
- }
- }
-
-
- });
- addFocusListener(new FocusAdapter(){
- public void focusGained(FocusEvent e)
- {
- // if e.source is not a child of the table then set selection - this is for tab into viewer
- Object eventSource = e.getSource();
- if (eventSource instanceof Control)
- {
- if (!isChild(currentTable, (Control)eventSource))
- {
- if (currentTable.getItemCount() > 0 && currentTable.getSelectionCount() <= 0)
- {
- if (sViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)getRow().getData(TABLETREEITEM_ID);
- StructuredSelection selection = new StructuredSelection(tableTreeItem.getData());
- sViewer.setSelection(selection, true);
- }
- else
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- }
- }
- else
- {
- if (currentTable.getItems().length > 0)
- {
- // cursor can end up on a non-existent table row
- // currently no way to get the current table cursor row
- // so for now just catch the exception since it doesn't
- // cause any side effects.
- try
- {
- setVisible(true);
- }
- catch (Exception ee)
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- }
- else // do not show table cursor if there are no elements in the table - avoid repaint
- {
- setVisible(false);
- }
- }
- }
- }
-
- protected boolean isChild(Control parent, Control child)
- {
- Control tempChild = child;
- while (tempChild != null)
- {
- if (tempChild == parent)
- {
- return true;
- }
- tempChild = tempChild.getParent();
- }
- return false;
- }
-
- /**
- * @see org.eclipse.swt.events.FocusAdapter#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e)
- {
- // Set the table navigator to be not visible if the the table
- // is not in focus and a child of the table is not in focus
- // note that we do this asynchronously so we don't mess up the
- // current focus handling.
- Display.getDefault().asyncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- if (currentTable != null && !currentTable.isDisposed() && !currentTable.isFocusControl() &&
- !isChild(currentTable, Display.getDefault().getFocusControl()))
- {
- setVisible(false);
- }
- }
- });
- }
-
- });
-
-
-
-
- table.addFocusListener(new FocusAdapter()
- {
- /**
- * @see org.eclipse.swt.events.FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e)
- {
- // only display navigator if there are items in the table
- // and if the focus wasn't gained from our own table navigator
- // (ie focus came from outside)
- if (currentTable.getItemCount() > 0 &&
- (Display.getDefault().getFocusControl() != null) &&
- !Display.getDefault().getFocusControl().equals(TableNavigator.this))
- {
- // note that we do this asynchronously so we don't mess up the
- // current focus handling.
- Display.getDefault().asyncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- if (!isVisible())
- {
- try
- {
- setVisible(true);
- setFocus();
- }
- catch (Exception e)
- {
- // catch IllegalArgumentExceptions here - index out of bounds on tableviewer
- if (currentTable.getItemCount() > 0)
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- else // do not show table cursor if there are no elements in the table - avoid repaint
- {
- setVisible(false);
- }
- }
- }
- }
- });
- }
- }
- });
- }
-
- public Table getTable()
- {
- return table;
- }
-
- public void addPaintListener(StructuredViewer viewer)
- {
-
- addPaintListener(new PaintListener()
- {
- public void paintControl(PaintEvent e)
- {
- TableItem[] selection = table.getSelection();
- final TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
- final String cellText = row.getText(getColumn());
- final Image cellImage = row.getImage(getColumn());
- final int col = getColumn();
-
- Display.getCurrent().asyncExec(new Runnable()
- {
- public void run()
- {
- if (!row.isDisposed())
- {
- String newText = row.getText(getColumn());
- if (!newText.equals(cellText) || !(row.getImage(col) == cellImage))
- {
- redraw();
- }
- }
- }
- });
- }
- });
- }
-
-
- public SelectionKeyAdapter getKeyAdapter(StructuredViewer viewer)
- {
- if (keyAdapter == null)
- {
- return new SelectionKeyAdapter(viewer);
- }
- else return keyAdapter;
- }
-
- public void setKeyAdapter(SelectionKeyAdapter kAdapter)
- {
- keyAdapter = kAdapter;
- }
-
- protected SelectionKeyAdapter keyAdapter = null;
-
- public class SelectionKeyAdapter extends KeyAdapter
- {
- StructuredViewer structuredViewer;
-
- public SelectionKeyAdapter(StructuredViewer viewer)
- {
- super();
- this.structuredViewer = viewer;
- }
-
- int lastKeyPressed = -1; // used to cache the last key for key combos
-
- public void keyPressed(KeyEvent e)
- {
- TableItem row = getRow();
- int column = getColumn();
-
- // hack to emulate SHIFT+F10 popup menu - otherwise table cursor
- // obscures the table popup mechanism and it doesn't work.
- if (lastKeyPressed == SWT.SHIFT && e.keyCode == SWT.F10)
- {
- Menu popup = getTable().getMenu();
- popup.setVisible(true);
- }
- lastKeyPressed = e.keyCode;
-
- //jvh - look for + or - key
- // column == 0
- if (row.getData(TABLETREEITEM_ID) instanceof TableTreeItem)
- {
- if (column == 0 && e.character == '+')
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), true);
- refresh();
- }
- else if (column == 0 && e.character == '-')
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), false);
- refresh();
- }
- }
- // use F2 to invoke editing for a cell
- if (e.keyCode == SWT.F2)
- {
- if (structuredViewer instanceof TableViewer)
- {
- ((TableViewer)structuredViewer).editElement(row.getData(), column);
- }
- else if (structuredViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).editElement(tableTreeItem.getData(), column);
- }
- }
- }
- }
-
- public void addKeyListeners(StructuredViewer viewer)
- {
- final StructuredViewer structuredViewer = viewer;
-
- addKeyListener(getKeyAdapter(structuredViewer));
- }
-
- public void addMouseListeners(StructuredViewer viewer)
- {
- final StructuredViewer structuredViewer = viewer;
-
- addMouseListener(new MouseAdapter()
- {
-
- public void mouseUp(MouseEvent e)
- {
- TableItem row = getRow();
- int column = getColumn();
-
- // use mouse button 1 to invoke editing for a cell
- if (e.button == 1)
- {
- if (structuredViewer instanceof TableViewer)
- {
- ((TableViewer)structuredViewer).editElement(row.getData(), column);
- }
- else if (structuredViewer instanceof TableTreeViewer && column == 1)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).editElement(tableTreeItem.getData(), column);
- }
-
- if (structuredViewer instanceof TableTreeViewer && row.getData(TABLETREEITEM_ID) instanceof TableTreeItem)
- {
- if (column == 0)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- boolean expandState = tableTreeItem.getExpanded();
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), !expandState);
- refresh();
- }
- }
- }
- }
- });
- }
-
-
- /**
- * Ensure that cell editor control shows up above the table cursor control.
- * Should be called whenever the table viewer makes a new call to setCellEditors
- * i.e. in constructor and in refreshCellEditors
- *
- * @param - array of cell editors for the StructuredViewer
- */
-
- public void moveCellEditorsAbove(CellEditor[] editorArray)
- {
- for (int i = 0; i < editorArray.length ; i++)
- {
- CellEditor cEd = editorArray[i];
- if (cEd != null && cEd.getControl() != null)
- {
- cEd.getControl().moveAbove(null);
- }
- }
- }
-
- public void refresh()
- {
- Display.getCurrent().asyncExec(new Runnable()
- {
- public void run()
- {
- if (!isDisposed() && isVisible())
- redraw();
- }
- });
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageEditorSite.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageEditorSite.java
deleted file mode 100644
index ee280ca40..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageEditorSite.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.ui.provisional.editors;
-
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.part.MultiPageEditorPart;
-import org.eclipse.ui.part.MultiPageEditorSite;
-
-/**
- * @deprecated - No longer necessary as of 3.2M3.
- */
-public class PostMultiPageEditorSite extends MultiPageEditorSite {
- /**
- * The post selection change listener, initialized lazily;
- * <code>null</code> if not yet created.
- */
- private ISelectionChangedListener postSelectionChangedListener = null;
-
- public PostMultiPageEditorSite(MultiPageEditorPart multiPageEditor, IEditorPart editor) {
- super(multiPageEditor, editor);
- }
-
- /**
- * Returns the selection changed listener which listens to the nested
- * editor's post selection changes, and calls
- * <code>handlePostSelectionChanged</code>.
- *
- * @return the selection changed listener
- */
- private ISelectionChangedListener getPostSelectionChangedListener() {
- if (postSelectionChangedListener == null) {
- postSelectionChangedListener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- PostMultiPageEditorSite.this.handlePostSelectionChanged(event);
- }
- };
- }
- return postSelectionChangedListener;
- }
-
- /**
- * Handles a post selection changed event from the nested editor. The
- * default implementation gets the selection provider from the multi-page
- * editor's site, and calls <code>firePostSelectionChanged</code> on it
- * (only if it is an instance of <code>MultiPageSelectionProvider</code>),
- * passing a new event object.
- * <p>
- * Subclasses may extend or reimplement this method.
- * </p>
- *
- * @param event
- * the event
- */
- protected void handlePostSelectionChanged(SelectionChangedEvent event) {
- ISelectionProvider parentProvider = getMultiPageEditor().getSite().getSelectionProvider();
- if (parentProvider instanceof PostMultiPageSelectionProvider) {
- SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection());
- ((PostMultiPageSelectionProvider) parentProvider).firePostSelectionChanged(newEvent);
- }
- }
-
- /**
- * The <code>MultiPageEditorSite</code> implementation of this
- * <code>IWorkbenchPartSite</code> method remembers the selection
- * provider, and also hooks a listener on it, which calls
- * <code>handleSelectionChanged</code> when a selection changed event
- * occurs and <code>handlePostSelectionChanged</code> when a post
- * selection changed event occurs.
- *
- * @param provider
- * The selection provider.
- * @see PostMultiPageEditorSite#handleSelectionChanged(SelectionChangedEvent)
- */
- public void setSelectionProvider(ISelectionProvider provider) {
- ISelectionProvider oldSelectionProvider = getSelectionProvider();
- if (oldSelectionProvider != null) {
- if (oldSelectionProvider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) oldSelectionProvider).removePostSelectionChangedListener(getPostSelectionChangedListener());
- }
- }
-
- super.setSelectionProvider(provider);
-
- if (provider != null) {
- if (provider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) provider).addPostSelectionChangedListener(getPostSelectionChangedListener());
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageSelectionProvider.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageSelectionProvider.java
deleted file mode 100644
index 3a4f90829..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostMultiPageSelectionProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.ui.provisional.editors;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.ui.part.MultiPageEditorPart;
-import org.eclipse.ui.part.MultiPageSelectionProvider;
-
-/**
- * @deprecated - No longer necessary as of 3.2M3.
- */
-public class PostMultiPageSelectionProvider extends MultiPageSelectionProvider implements IPostSelectionProvider {
- private ListenerList postListeners;
-
- public PostMultiPageSelectionProvider(MultiPageEditorPart multiPageEditor) {
- super(multiPageEditor);
- postListeners = new ListenerList();
- }
-
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- postListeners.add(listener);
- }
-
- public void firePostSelectionChanged(final SelectionChangedEvent event) {
- Object[] listeners = postListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- final ISelectionChangedListener pl = (ISelectionChangedListener) listeners[i];
- Platform.run(new SafeRunnable() {
- public void run() {
- pl.selectionChanged(event);
- }
- });
- }
- }
-
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- postListeners.remove(listener);
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostSelectionMultiPageEditorPart.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostSelectionMultiPageEditorPart.java
deleted file mode 100644
index bcd2f0751..000000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/provisional/editors/PostSelectionMultiPageEditorPart.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.ui.provisional.editors;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.MultiPageEditorPart;
-
-/**
- * Adds posts selection notifications from contained editor parts to
- * listeners. This part was created as a workaround for
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=108324 and will be removed
- * once WTP is building on a platform milestone that includes a fix.
- *
- * @deprecated - No longer necessary as of 3.2M3.
- */
-public abstract class PostSelectionMultiPageEditorPart extends MultiPageEditorPart {
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- site.setSelectionProvider(new PostMultiPageSelectionProvider(this));
- }
-
- protected void pageChange(int newPageIndex) {
- super.pageChange(newPageIndex);
- IEditorPart activeEditor = getEditor(newPageIndex);
- if (activeEditor != null) {
- ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider();
- if (selectionProvider != null) {
- SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection());
- ((PostMultiPageSelectionProvider) getSite().getSelectionProvider()).firePostSelectionChanged(event);
- }
- }
- }
-}

Back to the top