diff options
Diffstat (limited to 'tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse')
12 files changed, 0 insertions, 2038 deletions
diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ActionTestView.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ActionTestView.java deleted file mode 100644 index 1c8c7f796..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ActionTestView.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.TextViewer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - - -/** - * @author nitin - * - * A view to hang actions off of to execute arbitrary code at arbitrary times. - */ -public class ActionTestView extends ViewPart { - - private class ComponentViewer extends Action { - public void run() { - super.run(); - if (fSelection != null && !fSelection.isEmpty() && fSelection instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) fSelection; - if (selection.getFirstElement() instanceof IResource) { - IResource resource = (IResource) selection.getFirstElement(); - IVirtualResource[] virtualResources = ComponentCore.createResources(resource.getProject()); - // Only return results for Flexible projects - if (virtualResources != null) { - for (int i = 0; i < virtualResources.length; i++) { - System.out.println(virtualResources[i].getComponent().getRootFolder().getWorkspaceRelativePath()); - } - } - } - } - } - } - - class EmptyTextSetter extends Action { - public EmptyTextSetter() { - super("Set Text Editor text to empty"); - setToolTipText("Set Text Editor text to empty using set() API"); - } - - public void run() { - super.run(); - IEditorPart editor = getViewSite().getPage().getActiveEditor(); - ITextEditor textEditor = null; - if (editor instanceof ITextEditor) - textEditor = (ITextEditor) editor; - else - textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); - if (textEditor != null) { - IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput()); - document.set(""); - } - else { - print("Error getting IDocument.\n"); - } - } - } - - Control fControl = null; - - ISelection fSelection; - private ISelectionListener fSelectionListener; - - private List createActions() { - List actions = new ArrayList(); - - actions.add(new EmptyTextSetter()); - actions.add(new ComponentViewer()); - return actions; - } - - /** - * @return - */ - private List createContribututions() { - List actions = new ArrayList(); - return actions; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - ITextViewer text = new TextViewer(parent, SWT.READ_ONLY); - text.setDocument(new Document()); - fControl = text.getTextWidget(); - text.getDocument().set("Use either the toolbar or the menu to run your actions\n\n"); - } - - private ISelectionListener getSelectionListener() { - if (fSelectionListener == null) { - fSelectionListener = new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - fSelection = selection; - } - }; - } - return fSelectionListener; - } - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite) - */ - public void init(IViewSite site) throws PartInitException { - super.init(site); - List actions = createActions(); - for (int i = 0; i < actions.size(); i++) { - site.getActionBars().getToolBarManager().add((IAction) actions.get(i)); - site.getActionBars().getMenuManager().add((IAction) actions.get(i)); - } - List contributions = createContribututions(); - for (int i = 0; i < contributions.size(); i++) { - site.getActionBars().getToolBarManager().add((IContributionItem) contributions.get(i)); - site.getActionBars().getMenuManager().add((IContributionItem) contributions.get(i)); - } - site.getWorkbenchWindow().getSelectionService().addPostSelectionListener(getSelectionListener()); - } - - void print(String s) { - ((StyledText) fControl).append(s); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#setFocus() - */ - public void setFocus() { - if (fControl != null && !fControl.isDisposed()) { - fControl.setFocus(); - } - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/CommonEditorPreferencesTest.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/CommonEditorPreferencesTest.java deleted file mode 100644 index a442c0deb..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/CommonEditorPreferencesTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import junit.framework.TestCase; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; -import org.eclipse.wst.sse.ui.internal.provisional.preferences.CommonEditorPreferenceNames; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; - -/** - * The purpose of this test is to verify the validity of the - * StructuredTextEditor's common editor preferences. Tests include - * setting/getting preferences. - * - * NOTE: This test should be preformed on a clean workspace. If performed on - * an existing workspace, this test will manipulate preferences in the - * workspace, though attempts will be made to restore original values after - * testing. - */ -public class CommonEditorPreferencesTest extends TestCase { - /** - * Tests existance of preference values when getting preference values - * through Platform.getPreferencesService() - */ - public void testBundleGetPreferences() { - final String bundleName = "org.eclipse.wst.sse.ui"; - - // need to start up bundle for default values to be loaded - Bundle bundle = Platform.getBundle(bundleName); - try { - if (bundle != null) - bundle.start(); - else - fail("Get preference value failed because could not find bundle: " + bundleName); - } catch (BundleException e) { - fail("Get preference value failed because of exception starting bundle: " + bundleName + " exception: " + e); - } - - bundleGetPreference(bundleName, CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS); - } - - private void bundleGetPreference(String bundleName, String prefKey) { - String defaultValue = Long.toString(System.currentTimeMillis()); // random string - - String value = Platform.getPreferencesService().getString(bundleName, prefKey, defaultValue, null); - assertNotSame("Get preference value failed using Platform.getPreferencesService. Key: "+prefKey, defaultValue, value); - } - - /** - * Tests default values of preferences. - * - * NOTE: Expected default values are hard-coded, so if default values do - * get changed, assertions need to be updated as well - */ - public void testPluginGetDefaultPreferences() { - IPreferenceStore store = SSEUIPlugin.getDefault().getPreferenceStore(); - - pluginGetDefaultPreference(store, CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, Boolean.toString(true)); - } - - private void pluginGetDefaultPreference(IPreferenceStore store, String prefKey, String expected) { - String defaultValue = store.getDefaultString(prefKey); - assertEquals("Get default preference value failed using plugin.getPreferenceStore. Key: "+prefKey, expected, defaultValue); - } - - /** - * Tests setting preference values by setting preference value to be a - * certain value, then getting the preference value to verify it was set. - */ - public void testPluginSetPreferences() { - IPreferenceStore store = SSEUIPlugin.getDefault().getPreferenceStore(); - - pluginSetPreferenceBoolean(store, CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS); - } - - private void pluginSetPreferenceBoolean(IPreferenceStore store, String prefKey) { - boolean originalValue = store.getBoolean(prefKey); - boolean expectedValue = !originalValue; - store.setValue(prefKey, expectedValue); - boolean foundValue = store.getBoolean(prefKey); - assertEquals("Set preference value failed using plugin.getPreferenceStore. Key: "+prefKey+" expected: " + expectedValue + " found: " + foundValue, expectedValue, foundValue); - - // attempt to restore original preference value - store.setValue(prefKey, originalValue); - } -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ExtendedStorageEditorInputView.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ExtendedStorageEditorInputView.java deleted file mode 100644 index 8eab9923e..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/ExtendedStorageEditorInputView.java +++ /dev/null @@ -1,811 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ResourceSelectionDialog; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.IElementStateListener; -import org.eclipse.ui.texteditor.IUpdate; -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; -import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IExtendedStorageEditorInput; - - -/** - * @author nitin - * - * A view to assist in testing out StructuredTextEditor's EditorInput - * handling. - * - * Permanently in-progress. - */ -public class ExtendedStorageEditorInputView extends ViewPart { - class AddFileInputAction extends Action { - public AddFileInputAction() { - super("Add FileEditorInput"); - } - - public void run() { - super.run(); - ResourceSelectionDialog dlg = new ResourceSelectionDialog(fInputList.getControl().getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Choose"); - int retval = dlg.open(); - if (retval == Window.OK) { - Object[] files = dlg.getResult(); - for (int i = 0; i < files.length; i++) { - fInputs.add(new FileEditorInput((IFile) files[i])); - } - fInputList.refresh(true); - } - } - } - - class AddStorageInputAction extends Action { - public AddStorageInputAction() { - super("Add StorageEditorInput"); - } - - public void run() { - super.run(); - FileDialog dlg = new FileDialog(fInputList.getControl().getShell()); - String fileName = dlg.open(); - if (fileName != null) { - fInputs.add(new FileStorageEditorInput(new File(fileName))); - fInputList.refresh(true); - } - } - } - - class DoubleClickListener implements IDoubleClickListener { - public void doubleClick(DoubleClickEvent event) { - new InputOpenAction().run(); - } - } - - class EditorInputLabelProvider implements ITableLabelProvider { - ILabelProvider baseProvider = new WorkbenchLabelProvider(); - - public void addListener(ILabelProviderListener listener) { - // not implemented - } - - public void dispose() { - // no need - } - - public Image getColumnImage(Object element, int columnIndex) { - if (element instanceof IFileEditorInput && columnIndex == 0) { - return baseProvider.getImage(((IFileEditorInput) element).getFile()); - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - IEditorInput input = (IEditorInput) element; - String text = null; - switch (columnIndex) { - case 0 : - try { - if (element instanceof FileStorageEditorInput) { - IPath fullpath = ((FileStorageEditorInput) element).getStorage().getFullPath(); - text = fullpath != null ? fullpath.toString() : ((FileStorageEditorInput) element).getName(); - if (((FileStorageEditorInput) element).isDirty()) { - text = "*" + text; - } - } - else if (element instanceof IFileEditorInput) { - text = ((IFileEditorInput) element).getFile().getFullPath().toString(); - } - } - catch (CoreException e) { - e.printStackTrace(); - } - - break; - case 1 : - if (element instanceof FileStorageEditorInput) { - text = "FileStorageEditorInput"; - } - else if (element instanceof IFileEditorInput) { - text = "FileEditorInput"; - } - else { - text = input.getClass().getName(); - } - break; - } - if (text == null) - text = ""; - return text; - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - // not implemented - } - } - - - class FileBackedStorage implements IStorage { - File fFile = null; - - FileBackedStorage(File file) { - super(); - fFile = file; - } - - boolean exists() { - return fFile.exists(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IStorage#getContents() - */ - public InputStream getContents() throws CoreException { - InputStream contents = null; - try { - contents = new FileInputStream(fFile); - ByteBuffer buffer = ByteBuffer.allocate((int) fFile.length()); - byte[] bytes = new byte[2048]; - while (contents.available() > 0) { - int count = contents.read(bytes); - buffer.put(bytes, 0, count); - } - contents.close(); - - contents = new ByteArrayInputStream(buffer.array()); - } - catch (FileNotFoundException e) { - contents = new ByteArrayInputStream(new byte[0]); - } - catch (IOException e) { - contents = new ByteArrayInputStream(new byte[0]); - } - return contents; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IStorage#getFullPath() - */ - public IPath getFullPath() { - if (provideIStorageFullPath) { - return new Path(fFile.getAbsolutePath()); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IStorage#getName() - */ - public String getName() { - return fFile.getName(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IStorage#isReadOnly() - */ - public boolean isReadOnly() { - return true; - } - } - - class FileStorageEditorInput implements IExtendedStorageEditorInput { - List fElementStateListeners = new Vector(0); - boolean fIsDirty = false; - FileBackedStorage fStorage = null; - - FileStorageEditorInput(File file) { - fStorage = new FileBackedStorage(file); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.extensions.breakpoint.IExtendedStorageEditorInput#addElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) - */ - public void addElementStateListener(IElementStateListener listener) { - fElementStateListeners.add(listener); - } - - void elementContentAboutToBeReplaced() { - for (int i = 0; i < fElementStateListeners.size(); i++) { - ((IElementStateListener) fElementStateListeners.get(i)).elementContentAboutToBeReplaced(FileStorageEditorInput.this); - } - } - - void elementContentReplaced() { - for (int i = 0; i < fElementStateListeners.size(); i++) { - ((IElementStateListener) fElementStateListeners.get(i)).elementContentReplaced(FileStorageEditorInput.this); - } - } - - void elementDeleted() { - for (int i = 0; i < fElementStateListeners.size(); i++) { - ((IElementStateListener) fElementStateListeners.get(i)).elementDeleted(FileStorageEditorInput.this); - } - } - - void elementDirtyStateChanged(boolean dirty) { - setDirty(dirty); - for (int i = 0; i < fElementStateListeners.size(); i++) { - ((IElementStateListener) fElementStateListeners.get(i)).elementDirtyStateChanged(FileStorageEditorInput.this, dirty); - } - } - - void elementMoved(Object oldElement, Object newElement) { - for (int i = 0; i < fElementStateListeners.size(); i++) { - ((IElementStateListener) fElementStateListeners.get(i)).elementMoved(FileStorageEditorInput.this, FileStorageEditorInput.this); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#exists() - */ - public boolean exists() { - return fStorage.exists(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - File getFile() { - return fStorage.fFile; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getName() - */ - public String getName() { - return fStorage.getName(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - public IPersistableElement getPersistable() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IStorageEditorInput#getStorage() - */ - public IStorage getStorage() throws CoreException { - return fStorage; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return fStorage.getFullPath() != null ? fStorage.getFullPath().toString() : fStorage.getName(); - } - - boolean isDirty() { - return fIsDirty; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.extensions.breakpoint.IExtendedStorageEditorInput#removeElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) - */ - public void removeElementStateListener(IElementStateListener listener) { - fElementStateListeners.remove(listener); - } - - void setDirty(boolean dirty) { - fIsDirty = dirty; - } - } - - class InputChangeDirtyStateAction extends Action implements IUpdate { - public InputChangeDirtyStateAction() { - super("Toggle dirty flag"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - if (inputs[i] instanceof FileStorageEditorInput) { - ((FileStorageEditorInput) inputs[i]).elementDirtyStateChanged(!((FileStorageEditorInput) inputs[i]).isDirty()); - } - } - fInputList.refresh(true); - } - - public void update() { - setEnabled(fSelectedElement != null && fSelectedElement instanceof FileStorageEditorInput); - } - } - - class InputDeleteAction extends Action implements IUpdate { - public InputDeleteAction() { - super("Delete Input"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - if (inputs[i] instanceof FileStorageEditorInput) { - ((FileStorageEditorInput) inputs[i]).elementDeleted(); - } - } - for (int i = 0; i < inputs.length; i++) { - fInputs.remove(inputs[i]); - } - fInputList.refresh(); - } - - public void update() { - setEnabled(fSelectedElement != null && fSelectedElement instanceof FileStorageEditorInput); - } - } - - class InputMoveAction extends Action implements IUpdate { - public InputMoveAction() { - super("Move Input"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - if (inputs[i] instanceof FileStorageEditorInput) { - ((FileStorageEditorInput) inputs[i]).elementMoved(inputs[i], inputs[i]); - } - } - } - - public void update() { - setEnabled(fSelectedElement != null && fSelectedElement instanceof FileStorageEditorInput); - } - } - - class InputOpenAction extends Action { - public InputOpenAction() { - super("Open"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - try { - getSite().getWorkbenchWindow().getActivePage().openEditor(inputs[i], getEditorId(inputs[i])); - } - catch (PartInitException e) { - openError(getSite().getWorkbenchWindow().getActivePage().getWorkbenchWindow().getShell(), "OpenSystemEditorAction.dialogTitle", e.getMessage(), e); - } - } - } - } - - class InputReplaceContentsAction extends Action implements IUpdate { - public InputReplaceContentsAction() { - super("Replace Input's Contents"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - ((FileStorageEditorInput) inputs[i]).elementContentAboutToBeReplaced(); - ((FileStorageEditorInput) inputs[i]).elementContentReplaced(); - } - } - - public void update() { - setEnabled(fSelectedElement != null && fSelectedElement instanceof FileStorageEditorInput); - } - } - - class RemoveInputAction extends Action { - public RemoveInputAction() { - super("Remove"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - fInputs.remove(inputs[i]); - } - fInputList.refresh(); - } - } - - class ReuseEditorAction extends Action implements IUpdate { - public ReuseEditorAction() { - super("Reuse Editor"); - } - - public void run() { - super.run(); - IEditorInput[] inputs = getSelectedInputs(); - for (int i = 0; i < inputs.length; i++) { - IEditorPart editor = getSite().getWorkbenchWindow().getActivePage().getActiveEditor(); - if (editor instanceof IReusableEditor) { - getSite().getWorkbenchWindow().getActivePage().reuseEditor(((IReusableEditor) editor), inputs[i]); - } - else { - SSEUIPlugin.getDefault().getWorkbench().getDisplay().beep(); - } - } - } - - public void update() { - boolean enable = true; - try { - enable = fSelectedElement != null && getSite().getWorkbenchWindow().getActivePage().getActiveEditor() instanceof IReusableEditor; - } - catch (Exception e) { - enable = true; - } - setEnabled(enable); - } - } - - - public static final boolean provideIStorageFullPath = true; - - /** - * Open an error style dialog for PartInitException by including any extra - * information from the nested CoreException if present. - */ - public static void openError(Shell parent, String title, String message, PartInitException exception) { - // Check for a nested CoreException - CoreException nestedException = null; - IStatus status = exception.getStatus(); - if (status != null && status.getException() instanceof CoreException) - nestedException = (CoreException) status.getException(); - - if (nestedException != null) { - // Open an error dialog and include the extra - // status information from the nested CoreException - ErrorDialog.openError(parent, title, message, nestedException.getStatus()); - } - else { - // Open a regular error dialog since there is no - // extra information to display - MessageDialog.openError(parent, title, message); - } - } - - private List actions = null; - - TableViewer fInputList = null; - - List fInputs = new ArrayList(0); - - Object fSelectedElement = null; - - - public ExtendedStorageEditorInputView() { - super(); - actions = new ArrayList(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - fInputList = new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - fInputList.setContentProvider(new ArrayContentProvider()); - fInputList.setLabelProvider(new EditorInputLabelProvider()); - fInputList.addDoubleClickListener(new DoubleClickListener()); - fInputList.getTable().setHeaderVisible(true); - fInputList.getTable().setLinesVisible(true); - String[] columns = new String[]{"Path", "Type"}; - fInputList.setLabelProvider(new EditorInputLabelProvider()); - - - TableLayout tlayout = new TableLayout(); - CellEditor[] cellEditors = new CellEditor[5]; - for (int i = 0; i < columns.length; i++) { - tlayout.addColumnData(new ColumnWeightData(1)); - TableColumn tc = new TableColumn(fInputList.getTable(), SWT.NONE); - tc.setText(columns[i]); - tc.setResizable(true); - tc.setWidth(Display.getCurrent().getBounds().width / 14); - } - fInputList.setCellEditors(cellEditors); - fInputList.setColumnProperties(columns); - - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - fInputList.getTable().setLayoutData(gd); - - MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$ - menuManager.setRemoveAllWhenShown(false); - - menuManager.add(new InputOpenAction()); - menuManager.add(new Separator()); - menuManager.add(new InputMoveAction()); - menuManager.add(new InputChangeDirtyStateAction()); - menuManager.add(new InputDeleteAction()); - menuManager.add(new InputReplaceContentsAction()); - menuManager.add(new Separator()); - menuManager.add(new RemoveInputAction()); - Menu menu = menuManager.createContextMenu(fInputList.getControl()); - fInputList.getControl().setMenu(menu); - - - SSETestsPlugin.getDefault().getPluginPreferences().setDefault(getInputsPreferenceName(), ""); - String paths[] = StringUtils.unpack(SSETestsPlugin.getDefault().getPluginPreferences().getString(getInputsPreferenceName())); - for (int i = 0; i < paths.length; i++) { - if (paths[i].startsWith("S!")) { - fInputs.add(new FileStorageEditorInput(new File(paths[i].substring(2)))); - } - else if (paths[i].startsWith("F!")) { - fInputs.add(new FileEditorInput(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(paths[i].substring(2))))); - } - } - - fInputList.setInput(fInputs); - fInputList.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection sel = ((IStructuredSelection) event.getSelection()); - fSelectedElement = sel.getFirstElement(); - } - }); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - List paths = new ArrayList(0); - for (int i = 0; i < fInputs.size(); i++) { - try { - Object input = fInputs.get(i); - String path = null; - if (input instanceof FileStorageEditorInput) { - path = "S!" + ((FileStorageEditorInput) input).getFile().getCanonicalPath(); - } - else if (input instanceof IFileEditorInput) { - path = "F!" + ((IFileEditorInput) input).getFile().getFullPath().toString(); - } - if (path != null) { - paths.add(path); - } - } - catch (IOException e) { - e.printStackTrace(); - } - } - SSETestsPlugin.getDefault().getPluginPreferences().setValue(getInputsPreferenceName(), StringUtils.pack((String[]) paths.toArray(new String[0]))); - SSETestsPlugin.getDefault().savePluginPreferences(); - } - - String getEditorId(IEditorInput input) { - IWorkbench workbench = PlatformUI.getWorkbench(); - IEditorRegistry editorRegistry = workbench.getEditorRegistry(); - IContentType[] types = null; - String editorID = null; - if (input instanceof IStorageEditorInput) { - InputStream inputStream = null; - try { - inputStream = ((IStorageEditorInput) input).getStorage().getContents(); - } - catch (CoreException e) { - e.printStackTrace(); - } - try { - types = Platform.getContentTypeManager().findContentTypesFor(inputStream, input.getName()); - } - catch (IOException e) { - e.printStackTrace(); - } - try { - if (inputStream != null) { - inputStream.close(); - } - } - catch (IOException e) { - e.printStackTrace(); - } - } - - IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(input.getName(), types[0]); - if (descriptor != null) { - editorID = descriptor.getId(); - } - if (editorID == null) { - editorID = EditorsUI.DEFAULT_TEXT_EDITOR_ID; - } - return editorID; - } - - /** - * @return - */ - String getInputsPreferenceName() { - return "ExtendedStorageEditorInputView:inputs"; - } - - IEditorInput[] getSelectedInputs() { - ISelection selection = fInputList.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection sel = (IStructuredSelection) selection; - if (sel.isEmpty()) { - return new IEditorInput[0]; - } - Object[] arr = sel.toArray(); - IEditorInput[] inputs = new IEditorInput[arr.length]; - System.arraycopy(arr, 0, inputs, 0, inputs.length); - return inputs; - } - return new IEditorInput[0]; - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite) - */ - public void init(IViewSite site) throws PartInitException { - super.init(site); - - site.getActionBars().getToolBarManager().add(rememberAction(new AddStorageInputAction())); - site.getActionBars().getToolBarManager().add(rememberAction(new AddFileInputAction())); - site.getActionBars().getToolBarManager().add(rememberAction(new ReuseEditorAction())); - site.getActionBars().getToolBarManager().add(rememberAction(new RemoveInputAction())); - - site.getActionBars().getMenuManager().add(rememberAction(new InputOpenAction())); - site.getActionBars().getMenuManager().add(rememberAction(new ReuseEditorAction())); - site.getActionBars().getMenuManager().add(new Separator()); - site.getActionBars().getMenuManager().add(rememberAction(new InputMoveAction())); - site.getActionBars().getMenuManager().add(rememberAction(new InputChangeDirtyStateAction())); - site.getActionBars().getMenuManager().add(rememberAction(new InputDeleteAction())); - site.getActionBars().getMenuManager().add(rememberAction(new InputReplaceContentsAction())); - } - - IAction rememberAction(IAction action) { - actions.add(action); - return action; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#setFocus() - */ - public void setFocus() { - fInputList.getControl().setFocus(); - } - - - protected void updateEnablement() { - for (int i = 0; i < actions.size(); i++) { - Object action = actions.get(i); - if (action instanceof IUpdate) { - ((IUpdate) action).update(); - } - } - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/Logger.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/Logger.java deleted file mode 100644 index d37e8a0d9..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/Logger.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -/** - * Small convenience class to log messages to plugin's log file and also, if - * desired, the console. This class should only be used by classes in this - * plugin. Other plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.ui.tests"; //$NON-NLS-1$ - - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - - public static final int OK = IStatus.OK; // 0 - public static final int INFO = IStatus.INFO; // 1 - public static final int WARNING = IStatus.WARNING; // 2 - public static final int ERROR = IStatus.ERROR; // 4 - - public static final int OK_DEBUG = 200 + OK; - public static final int INFO_DEBUG = 200 + INFO; - public static final int WARNING_DEBUG = 200 + WARNING; - public static final int ERROR_DEBUG = 200 + ERROR; - - /** - * Adds message to log. - * - * @param level - * severity level of the message (OK, INFO, WARNING, ERROR, - * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message - * text to add to the log - * @param exception - * exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) - return; - } - - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG : - case INFO : - severity = IStatus.INFO; - break; - case WARNING_DEBUG : - case WARNING : - severity = IStatus.WARNING; - break; - case ERROR_DEBUG : - case ERROR : - severity = IStatus.ERROR; - } - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * - * @param message - * text to print - * @param category - * category of the message, to be compared with - * /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - /** - * Determines if currently tracing a category - * - * @param category - * @return true if tracing category, false otherwise - */ - public static boolean isTracing(String category) { - if (!isDebugging()) - return false; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - return true; - } - } - } - return false; - } - - public static void log(int level, String message) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSETestsPlugin.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSETestsPlugin.java deleted file mode 100644 index 5c4d91e25..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSETestsPlugin.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.Plugin; - -/** - * The main plugin class to be used in the desktop. - */ -public class SSETestsPlugin extends Plugin { - //The shared instance. - private static SSETestsPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public SSETestsPlugin() { - super(); - plugin = this; - try { - resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.sse.ui.tests.TestsPluginResources"); - } catch (MissingResourceException x) { - resourceBundle = null; - } - } - - /** - * Returns the shared instance. - */ - public static SSETestsPlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, or 'key' if not - * found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = SSETestsPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSEUITestSuite.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSEUITestSuite.java deleted file mode 100644 index 12cb458c5..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/SSEUITestSuite.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.wst.sse.ui.tests.viewer.TestViewerConfiguration; - -/** - * @author pavery - */ -public class SSEUITestSuite extends TestSuite { - public static Test suite() { - return new SSEUITestSuite(); - } - - public SSEUITestSuite() { - super("SSE UI Test Suite"); - addTest(new TestSuite(VerifyEditorPlugin.class)); - addTest(new TestSuite(CommonEditorPreferencesTest.class)); - addTest(new TestSuite(TestViewerConfiguration.class)); - addTest(new TestSuite(TestStructuredTextEditor.class)); - } -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestActionDelegate.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestActionDelegate.java deleted file mode 100644 index 36c0e5013..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestActionDelegate.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.sse.ui.tests; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; - -/** - * @author nsd - * - */ -public class TestActionDelegate extends Action implements IEditorActionDelegate { - IEditorPart editor = null; - IAction faction = null; - - /** - * - */ - public TestActionDelegate() { - super(); - } - - /** - * @param text - */ - public TestActionDelegate(String text) { - super(text); - } - - /** - * @param text - * @param image - */ - public TestActionDelegate(String text, ImageDescriptor image) { - super(text, image); - } - - /** - * @param text - * @param style - */ - public TestActionDelegate(String text, int style) { - super(text, style); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, - * org.eclipse.ui.IEditorPart) - */ - public void setActiveEditor(IAction targetAction, IEditorPart targetEditor) { - editor = targetEditor; - faction = targetAction; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction runAction) { - MessageDialog.openInformation(editor.getEditorSite().getShell(), "Test", "Completed"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - // do nothing - } -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestEmailNotice.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestEmailNotice.java deleted file mode 100644 index c4c3eeaaf..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestEmailNotice.java +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - * Copyright (c) 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.sse.ui.tests; - -import junit.framework.TestCase; - -public class TestEmailNotice extends TestCase { - private boolean sendNotifications = false; - - public TestEmailNotice() { - super(); - } - - public TestEmailNotice(String name) { - super(name); - } - - public void testEmail() { - assertFalse("Simple test to be sure email gets sent on failure", sendNotifications); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestLineStyleProvider.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestLineStyleProvider.java deleted file mode 100644 index 81f3ae474..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestLineStyleProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.sse.ui.tests; - -import java.util.Collection; - -import org.eclipse.jface.text.ITypedRegion; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.internal.provisional.style.Highlighter; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; -import org.eclipse.wst.sse.ui.internal.util.EditorUtility; - -public class TestLineStyleProvider implements LineStyleProvider { - - Color foreground = null; - - /** - * - */ - public TestLineStyleProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.style.LineStyleProvider#init(org.eclipse.wst.sse.core.text.IStructuredDocument, - * org.eclipse.wst.sse.ui.style.Highlighter) - */ - public void init(IStructuredDocument document, Highlighter highlighter) { - // nothing to init - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.style.LineStyleProvider#prepareRegions(org.eclipse.jface.text.ITypedRegion, - * int, int, java.util.Collection) - */ - public boolean prepareRegions(ITypedRegion currentRegion, int start, int length, Collection styleRanges) { - // make everything bold grey - if (foreground == null) - foreground = EditorUtility.getColor(new RGB(127, 127, 127)); - styleRanges.add(new StyleRange(start, length, foreground, null, SWT.BOLD)); - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.ui.style.LineStyleProvider#release() - */ - public void release() { - // nothing to release - } - -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestStructuredTextEditor.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestStructuredTextEditor.java deleted file mode 100644 index eccd14b8f..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/TestStructuredTextEditor.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.sse.ui.tests; - -import java.io.ByteArrayInputStream; - -import junit.framework.TestCase; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.SWT; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.IShowInTargetList; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; - -public class TestStructuredTextEditor extends TestCase { - private final String PROJECT_NAME = "TestStructuredTextEditor"; - private final String FILE_NAME = "testStructuredTextEditor.xml"; - - private static StructuredTextEditor fEditor; - private static IFile fFile; - private static boolean fIsSetup = false; - - public TestStructuredTextEditor() { - super("TestStructredTextEditor"); - } - - protected void setUp() throws Exception { - if (!fIsSetup) { - // create project - createProject(PROJECT_NAME); - fFile = getOrCreateFile(PROJECT_NAME + "/" + FILE_NAME); - fIsSetup = true; - } - - if (fIsSetup && fEditor == null) { - IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - IEditorInput input = new FileEditorInput(fFile); - /* - * This should take care of testing init, createPartControl, - * beginBackgroundOperation, endBackgroundOperation methods - */ - IEditorPart part = page.openEditor(input, "org.eclipse.wst.sse.ui.StructuredTextEditor", true); - if (part instanceof StructuredTextEditor) - fEditor = (StructuredTextEditor) part; - else - assertTrue("Unable to open structured text editor", false); - } - } - - protected void tearDown() throws Exception { - if (fEditor != null) { - /* - * This should take care of testing close and dispose methods - */ - fEditor.close(false); - assertTrue("Unable to close editor", true); - fEditor = null; - } - } - - private void createProject(String projName) { - IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projName); - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); - try { - project.create(description, new NullProgressMonitor()); - project.open(new NullProgressMonitor()); - } - catch (CoreException e) { - e.printStackTrace(); - } - } - - protected IFile getOrCreateFile(String filePath) { - IFile blankJspFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)); - if (blankJspFile != null && !blankJspFile.exists()) { - try { - blankJspFile.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor()); - } - catch (CoreException e) { - e.printStackTrace(); - } - } - return blankJspFile; - } - - public void testDoSaving() { - fEditor.doRevertToSaved(); - assertTrue("Unable to revert to saved", true); - fEditor.doSave(new NullProgressMonitor()); - assertTrue("Unable to save", true); - } - - public void testEditorContextMenuAboutToShow() { - IMenuManager menu = new MenuManager(); - fEditor.editorContextMenuAboutToShow(menu); - assertTrue("Unable to prepare for context menu about to show", true); - menu.dispose(); - menu = null; - } - - public void testGetAdapter() { - Object adapter = fEditor.getAdapter(IShowInTargetList.class); - assertTrue("Get adapter for show in target failed", adapter instanceof IShowInTargetList); - } - - public void testGetSetEditorPart() { - fEditor.setEditorPart(null); - assertTrue("Unable to set editor part", true); - IEditorPart part = fEditor.getEditorPart(); - assertTrue("Did not get expected editor part", part instanceof StructuredTextEditor); - } - - public void testInitializeDocumentProvider() { - fEditor.initializeDocumentProvider(null); - assertTrue("Unable to initialize document provider", true); - } - - public void testGetOrientation() { - int or = fEditor.getOrientation(); - assertEquals(SWT.LEFT_TO_RIGHT, or); - } - - public void testGetSelectionProvider() { - ISelectionProvider provider = fEditor.getSelectionProvider(); - assertNotNull("Editor's selection provider was null", provider); - } - - public void testGetTextViewer() { - StructuredTextViewer viewer = fEditor.getTextViewer(); - assertNotNull("Editor's text viewer was null", viewer); - } - - public void testRememberRestoreSelection() { - fEditor.rememberSelection(); - assertTrue("Unable to remember editor selection", true); - fEditor.restoreSelection(); - assertTrue("Unable to restore editor selection", true); - } - - public void testSafelySanityCheck() { - fEditor.safelySanityCheckState(fEditor.getEditorInput()); - assertTrue("Unable to safely sanity check editor state", true); - } - - public void testShowBusy() { - fEditor.showBusy(false); - assertTrue("Unable to show editor is busy", true); - } - - public void testUpdate() { - fEditor.update(); - assertTrue("Unable to update editor", true); - } -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/VerifyEditorPlugin.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/VerifyEditorPlugin.java deleted file mode 100644 index 6753f6aa3..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/VerifyEditorPlugin.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.eclipse.wst.sse.ui.tests; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; - -/***************************************************************************** - * Copyright (c) 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 - * - ****************************************************************************/ - -public class VerifyEditorPlugin extends TestCase { - - List colorList = new ArrayList(); - - public void testPluginExists() { - Plugin plugin = null; - try { - plugin = SSEUIPlugin.getDefault(); - - } - catch (Exception e) { - plugin = null; - } - assertNotNull("sse editor plugin could not be instantiated", plugin); - - } - - /** - * The purpose of this test is just to test if we can directly create lots - * of RBG colors, even if display set to "256" (on Linux). And, BTW, it - * does not fail even with 256 colors set, at least on Linux, in dev. env. - * Varying all three RGB numbers, though, it is easy to run out of memory! - * - */ - public void testColorHandles() { - Display display = Display.getCurrent(); - if (display == null) - display = Display.getDefault(); - assertNotNull("display could not be instantiated", display); - for (int i = 0; i < 256; i++) { - for (int j = 0; j < 256; j++) { - // 256 cubed runs out of memory - // for (int k = 0; k < 256; k++) { - colorList.add(new Color(display, new RGB(i, j, 50))); - // } - - } - - } - // if we get this far without error, all is ok. - assertTrue(true); - } -} diff --git a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/viewer/TestViewerConfiguration.java b/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/viewer/TestViewerConfiguration.java deleted file mode 100644 index ab1498215..000000000 --- a/tests/org.eclipse.wst.sse.ui.tests/src/org/eclipse/wst/sse/ui/tests/viewer/TestViewerConfiguration.java +++ /dev/null @@ -1,270 +0,0 @@ -package org.eclipse.wst.sse.ui.tests.viewer; - -import junit.framework.TestCase; - -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.IInformationControlCreator; -import org.eclipse.jface.text.ITextDoubleClickStrategy; -import org.eclipse.jface.text.IUndoManager; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.formatter.IContentFormatter; -import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; -import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; -import org.eclipse.jface.text.information.IInformationPresenter; -import org.eclipse.jface.text.presentation.IPresentationReconciler; -import org.eclipse.jface.text.reconciler.IReconciler; -import org.eclipse.jface.text.source.IAnnotationHover; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitioning; -import org.eclipse.wst.sse.core.text.IStructuredPartitions; -import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; -import org.eclipse.wst.sse.ui.tests.Logger; - -public class TestViewerConfiguration extends TestCase { - - private StructuredTextViewerConfiguration fConfig = null; - private boolean fDisplayExists = true; - private StructuredTextViewer fViewer = null; - private boolean isSetup = false; - - public TestViewerConfiguration() { - super("TestViewerConfiguration"); - } - - protected void setUp() throws Exception { - - super.setUp(); - if (!this.isSetup) { - setUpViewerConfiguration(); - this.isSetup = true; - } - } - - private void setUpViewerConfiguration() { - if (Display.getCurrent() != null) { - - Shell shell = null; - Composite parent = null; - - if (PlatformUI.isWorkbenchRunning()) { - shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - } - else { - shell = new Shell(Display.getCurrent()); - } - parent = new Composite(shell, SWT.NONE); - - // dummy viewer - fViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE); - fConfig = new StructuredTextViewerConfiguration(); - } - else { - fDisplayExists = false; - Logger.log(Logger.INFO, "Remember, viewer configuration tests are not run because workbench is not open (normal on build machine)"); - } - } - - public void testGetAnnotationHover() { - - // probably no display - if (!fDisplayExists) - return; - - IAnnotationHover hover = fConfig.getAnnotationHover(fViewer); - assertNotNull("AnnotationHover is null", hover); - } - - /** - * Not necessary - */ - public void testGetAutoEditStrategies() { - - // probably no display - if (!fDisplayExists) - return; - - IAutoEditStrategy[] strategies = fConfig.getAutoEditStrategies(fViewer, IStructuredPartitions.DEFAULT_PARTITION); - assertNotNull(strategies); - assertTrue("there are no auto edit strategies", strategies.length > 0); - } - - /** - * Not necessary - */ - public void testGetConfiguredContentTypes() { - - // probably no display - if (!fDisplayExists) - return; - - String[] configuredContentTypes = fConfig.getConfiguredContentTypes(fViewer); - assertNotNull(configuredContentTypes); - assertTrue(configuredContentTypes.length == 1); - } - - public void testGetConfiguredDocumentPartitioning() { - - // probably no display - if (!fDisplayExists) - return; - - String partitioning = fConfig.getConfiguredDocumentPartitioning(fViewer); - assertEquals(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING, partitioning); - } - - public void testGetConfiguredTextHoverStateMasks() { - - // probably no display - if (!fDisplayExists) - return; - - int[] masks = fConfig.getConfiguredTextHoverStateMasks(fViewer, IStructuredPartitions.DEFAULT_PARTITION); - assertEquals(2, masks.length); - } - - public void testGetContentAssistant() { - - // probably no display - if (!fDisplayExists) - return; - - IContentAssistant ca = fConfig.getContentAssistant(fViewer); - assertNotNull("there is no content assistant", ca); - } - - public void testGetContentFormatter() { - - // probably no display - if (!fDisplayExists) - return; - - IContentFormatter cf = fConfig.getContentFormatter(fViewer); - assertNull("there is a content formatter", cf); - } - - /** - * Not necessary - */ - public void testGetDoubleClickStrategy() { - - // probably no display - if (!fDisplayExists) - return; - - String[] contentTypes = fConfig.getConfiguredContentTypes(fViewer); - for (int i = 0; i < contentTypes.length; i++) { - ITextDoubleClickStrategy strategy = fConfig.getDoubleClickStrategy(fViewer, contentTypes[i]); - if (strategy != null) { - return; - } - } - assertTrue("there are no configured double click strategies", false); - } - - /** - * Not necessary - */ - public void testGetHyperlinkDetectors() { - - // probably no display - if (!fDisplayExists) - return; - - IHyperlinkDetector[] detectors = fConfig.getHyperlinkDetectors(fViewer); - assertNotNull("there are no hyperlink detectors", detectors); - assertTrue("there are no hyperlink detectors", detectors.length > 0); - } - - public void testGetHyperlinkPresenter() { - - // probably no display - if (!fDisplayExists) - return; - - IHyperlinkPresenter presenter = fConfig.getHyperlinkPresenter(fViewer); - assertNotNull("hyperlink presenter shouldn't be null", presenter); - } - - public void testGetInformationControlCreator() { - - // probably no display - if (!fDisplayExists) - return; - - IInformationControlCreator infoControlCreator = fConfig.getInformationControlCreator(fViewer); - assertNotNull("info control creator was null", infoControlCreator); - } - - public void testGetInformationPresenter() { - - // probably no display - if (!fDisplayExists) - return; - - IInformationPresenter presenter = fConfig.getInformationPresenter(fViewer); - assertNotNull("InformationPresenter was null", presenter); - } - - public void testGetLineStyleProviders() { - // probably no display - if (!fDisplayExists) - return; - - // there should be no linestyleproviders for default - String[] contentTypes = fConfig.getConfiguredContentTypes(fViewer); - for (int i = 0; i < contentTypes.length; i++) { - LineStyleProvider providers[] = fConfig.getLineStyleProviders(fViewer, contentTypes[i]); - assertNull("line style providers is not null", providers); - } - } - - /** - * Not necessary - */ - public void testGetOverviewRulerAnnotationHover() { - - // probably no display - if (!fDisplayExists) - return; - - IAnnotationHover annotationHover = fConfig.getOverviewRulerAnnotationHover(fViewer); - assertNotNull("annotation hover was null", annotationHover); - } - - public void testGetPresentationReconciler() { - - // probably no display - if (!fDisplayExists) - return; - - IPresentationReconciler presentationReconciler = fConfig.getPresentationReconciler(fViewer); - // our default presentation reconciler is null - assertNull("presentation reconciler was not null", presentationReconciler); - } - - public void testGetReconciler() { - - // probably no display - if (!fDisplayExists) - return; - - IReconciler r = fConfig.getReconciler(fViewer); - assertNotNull("Reconciler was null", r); - } - - public void testGetUndoManager() { - - // probably no display - if (!fDisplayExists) - return; - - IUndoManager undoManager = fConfig.getUndoManager(fViewer); - assertNotNull("undo manager was null", undoManager); - } -} |