*** empty log message ***
diff --git a/update/org.eclipse.update.ui.forms/.classpath b/update/org.eclipse.update.ui.forms/.classpath
index e3cec1c..4848249 100644
--- a/update/org.eclipse.update.ui.forms/.classpath
+++ b/update/org.eclipse.update.ui.forms/.classpath
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="Eclipse Forms"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/DetailsPart.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/DetailsPart.java
deleted file mode 100644
index 28812c7..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/DetailsPart.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Created on Jan 24, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms;
-import java.util.*;
-
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.widgets.ScrolledPageBook;
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public class DetailsPart implements IFormPart, IPartSelectionListener {
- private IManagedForm managedForm;
- private ScrolledPageBook pageBook;
- private IStructuredSelection currentSelection;
- private Hashtable pages;
- private IDetailsPageProvider pageProvider;
-
- public DetailsPart(ManagedForm mform, ScrolledPageBook pageBook) {
- this.pageBook = pageBook;
- pages = new Hashtable();
- initialize(mform);
- }
- public DetailsPart(ManagedForm mform, Composite parent, int style) {
- this(mform, mform.getToolkit().createPageBook(parent, SWT.V_SCROLL|SWT.H_SCROLL));
- }
- public void registerPage(Object objectClass, IDetailsPage page) {
- pages.put(objectClass, page);
- page.initialize(managedForm);
- }
- public void setPageProvider(IDetailsPageProvider provider) {
- this.pageProvider = provider;
- }
- public void commit(boolean onSave) {
- IDetailsPage page = getCurrentPage();
- if (page != null)
- page.commit();
- }
- public IDetailsPage getCurrentPage() {
- Control control = pageBook.getCurrentPage();
- if (control != null) {
- Object data = control.getData();
- if (data instanceof IDetailsPage)
- return (IDetailsPage) data;
- }
- return null;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#dispose()
- */
- public void dispose() {
- for (Enumeration enum = pages.elements(); enum.hasMoreElements();) {
- IDetailsPage page = (IDetailsPage) enum.nextElement();
- page.dispose();
- }
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
- */
- public void initialize(IManagedForm form) {
- this.managedForm = form;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#isDirty()
- */
- public boolean isDirty() {
- IDetailsPage page = getCurrentPage();
- if (page != null)
- return page.isDirty();
- return false;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#refresh()
- */
- public void refresh() {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#setFocus()
- */
- public void setFocus() {
- IDetailsPage page = getCurrentPage();
- if (page != null)
- page.setFocus();
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
- */
- public void setFormInput(Object input) {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IFormPart part, ISelection selection) {
- if (currentSelection != null) {
- // see if the page is dirty
- }
- if (selection instanceof IStructuredSelection)
- currentSelection = (IStructuredSelection) selection;
- else
- currentSelection = null;
- update();
- }
- private void update() {
- Object key = null;
- if (currentSelection != null) {
- for (Iterator iter = currentSelection.iterator(); iter.hasNext();) {
- Object obj = iter.next();
- if (key == null)
- key = getKey(obj);
- else if (getKey(obj).equals(key) == false) {
- key = null;
- break;
- }
- }
- }
- showPage(key);
- }
- private Object getKey(Object object) {
- if (pageProvider!=null) {
- Object key = pageProvider.getPageKey(object);
- if (key!=null)
- return key;
- }
- return object.getClass();
- }
- private void showPage(final Object key) {
- if (key != null) {
- IDetailsPage page = (IDetailsPage) pages.get(key);
- if (page==null) {
- // try to get the page dynamically from the provider
- if (pageProvider!=null) {
- page = pageProvider.getPage(key);
- if (page!=null) {
- page.initialize(managedForm);
- pages.put(key, page);
- }
- }
- }
- if (page != null) {
- final IDetailsPage fpage = page;
- BusyIndicator.showWhile(pageBook.getDisplay(), new Runnable() {
- public void run() {
- if (!pageBook.hasPage(key)) {
- Composite parent = pageBook.createPage(key);
- fpage.createContents(parent);
- }
- fpage.inputChanged(currentSelection);
- pageBook.showPage(key);
- }
- });
- return;
- }
- }
- pageBook.showEmptyPage();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormColors.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormColors.java
deleted file mode 100644
index 1738adb..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormColors.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import java.util.*;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Manages colors that will be applied to forms and form widgets. The colors
- * are chosen to make the widgets look correct in the editor area. If a
- * different set of colors is needed, subclass this class and override
- * 'initialize' and/or 'initializeColors'.
- *
- * @since 3.0
- */
-public class FormColors {
- public static final String TITLE = "org.eclipse.ui.forms.TITLE";
- public static final String BORDER = "org.eclipse.ui.forms.BORDER";
- public static final String SEPARATOR = "org.eclipse.ui.forms.SEPARATOR";
-
- protected Map colorRegistry = new HashMap(10);
-
- protected Color background;
- protected Color foreground;
- private boolean shared;
- protected Display display;
- protected Color border;
-
- /**
- * Creates form colors using the provided display.
- *
- * @param display
- * the display to use
- */
- public FormColors(Display display) {
- this.display = display;
- initialize();
- }
-
- /**
- * Returns the display used to create colors.
- *
- * @return the display
- */
- public Display getDisplay() {
- return display;
- }
- /**
- * Initializes the colors. Subclasses can override this method to change
- * the way colors are created. Alternatively, only the color table can be
- * modified by overriding <code>initializeColorTable()</code>.
- *
- * @see #initializeColorTable
- */
- protected void initialize() {
- background = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- foreground = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- initializeColorTable();
- updateBorderColor();
- }
-
- /**
- * Allocates colors for the following keys: BORDER, COMPOSITE_SEPARATOR and
- * DEFAULT_HEADER. Subclasses can override to allocate this colors
- * differently.
- */
- protected void initializeColorTable() {
- createColor(BORDER, 195, 191, 179);
- createColor(SEPARATOR, 152, 170, 203);
- createColor(TITLE, 102, 120, 153);
- }
-
- /**
- * Creates the color for the specified key using the provided RGB object.
- * The color object will be returned and also put into the registry. When
- * the class is disposed, the color will be disposed with it.
- *
- * @param key
- * the unique color key
- * @param rgb
- * the RGB object
- * @return the allocated color object
- */
- public Color createColor(String key, RGB rgb) {
- return createColor(key, rgb.red, rgb.green, rgb.blue);
- }
-
- /**
- * Creates the color for the specified key using the provided RGB values.
- * The color object will be returned and also put into the registry. When
- * the class is disposed, the color will be disposed with it.
- *
- * @param key
- * the unique color key
- * @param r
- * red value
- * @param g
- * green value
- * @param b
- * blue value
- * @return the allocated color object
- */
- public Color createColor(String key, int r, int g, int b) {
- Color c = new Color(display, r, g, b);
- colorRegistry.put(key, c);
- return c;
- }
-
- /**
- * Computes the border color relative to the background. Allocated border
- * color is designed to work well with white. Otherwise, stanard widget
- * background color will be used.
- */
- protected void updateBorderColor() {
- if (isWhiteBackground())
- border = getColor(BORDER);
- else
- border = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- }
- /**
- * Sets the background color. All the toolkits that use this class will
- * share the same background.
- *
- * @param bg
- * background color
- */
- public void setBackground(Color bg) {
- this.background = bg;
- updateBorderColor();
- }
- /**
- * Sets the foreground color. All the toolkits that use this class will
- * share the same foreground.
- *
- * @param fg
- * foreground color
- */
- public void setForeground(Color fg) {
- this.foreground = fg;
- }
-
- /**
- * Returns the current background color.
- *
- * @return the background color
- */
- public Color getBackground() {
- return background;
- }
- /**
- * Returns the current foreground color.
- *
- * @return the foreground color
- */
- public Color getForeground() {
- return foreground;
- }
- /**
- * Returns the computed border color. Border color depends on the
- * background and is recomputed whenever the background changes.
- *
- * @return the current border color
- */
- public Color getBorderColor() {
- return border;
- }
- /**
- * Tests if the background is white. White background has RGB value
- * 255,255,255.
- *
- * @return <samp>true</samp> if background is white, <samp>false</samp>
- * otherwise.
- */
- public boolean isWhiteBackground() {
- return background.getRed() == 255
- && background.getGreen() == 255
- && background.getBlue() == 255;
- }
-
- /**
- * Returns the color object for the provided key or <samp>null</samp> if
- * not in the registry.
- *
- * @param key
- * the color key
- * @return color object if found, or <samp>null</samp> if not.
- */
- public Color getColor(String key) {
- return (Color) colorRegistry.get(key);
- }
-
- /**
- * Disposes all the colors in the registry.
- */
-
- public void dispose() {
- Iterator e = colorRegistry.values().iterator();
- while (e.hasNext())
- ((Color) e.next()).dispose();
- colorRegistry = null;
- }
-
- /**
- * Marks the colors shared. This prevents toolkits that share this object
- * from disposing it.
- */
- public void markShared() {
- this.shared = true;
- }
- /**
- * Tests if the colors are shared.
- *
- * @return <code>true</code> if shared, <code>false</code> otherwise.
- */
- public boolean isShared() {
- return shared;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizard.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizard.java
deleted file mode 100644
index 5bffd2e..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizard.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-/**
- * Creates a wizard that hosts one or more pages based on forms.
- */
-public abstract class FormWizard extends Wizard {
- protected FormToolkit toolkit;
-
- /**
- * Creates the wizard that will own its own colors.
- */
- public FormWizard() {
- }
- /**
- * Creates a wizard that will use shared colors.
- *
- * @param colors
- * shared colors
- */
- public FormWizard(FormColors colors) {
- toolkit = new FormToolkit(colors);
- }
- /**
- * Creates form toolkit if missing before creating page controls.
- *
- * @param pageContainer
- * the page container widget
- */
- public void createPageControls(Composite pageContainer) {
- if (toolkit == null)
- toolkit = new FormToolkit(pageContainer.getDisplay());
- super.createPageControls(pageContainer);
- }
- /**
- * Disposes the toolkit and the wizard itself.
- */
- public void dispose() {
- super.dispose();
- toolkit.dispose();
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardDialog.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardDialog.java
deleted file mode 100644
index 26ad891..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardDialog.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.wizard.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Modifies the standard wizard dialog to accept form wizards. Modification
- * consists of adjusting colors and layout so that scrollable forms can be
- * hosted.
- *
- * @since 3.0
- */
-public class FormWizardDialog extends WizardDialog {
- protected FormColors colors;
-
- /**
- * Creats the wizard dialog. Colors are required to modify the dialog
- * appearance to fit the forms.
- *
- * @param shell
- * the parent shell
- * @param wizard
- * the wizard to host
- * @param colors
- * the colors to use
- */
- public FormWizardDialog(
- Shell shell,
- FormWizard wizard,
- FormColors colors) {
- super(shell, wizard);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.colors = colors;
- }
- /**
- * Extends the parent method by adjusting the colors and margins to fit the
- * forms.
- *
- * @param the
- * dialog area parent
- * @return the dialog area
- */
- protected Control createDialogArea(Composite parent) {
- Composite c = (Composite) super.createDialogArea(parent);
- setChildColors(c);
- c.setBackground(colors.getBackground());
- c.setForeground(colors.getForeground());
- return c;
- }
- /**
- * Extends the parent method by adjusting the colors of the button bar.
- *
- * @param parent
- * the button bar parent
- * @return the button bar
- */
- protected Control createButtonBar(Composite parent) {
- Control bar = super.createButtonBar(parent);
- bar.setBackground(colors.getBackground());
- bar.setForeground(colors.getForeground());
- parent.setBackground(colors.getBackground());
- parent.setForeground(colors.getForeground());
- return bar;
- }
-
- private void setChildColors(Composite parent) {
- Control[] children = parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
- child.setBackground(colors.getBackground());
- if (child instanceof ProgressMonitorPart)
- setChildColors((ProgressMonitorPart) child);
- if (child instanceof Composite) {
- Layout l = ((Composite) child).getLayout();
- if (l instanceof PageContainerFillLayout) {
- PageContainerFillLayout pl = (PageContainerFillLayout) l;
- pl.marginWidth = 0;
- pl.marginHeight = 0;
- }
- }
- }
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardPage.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardPage.java
deleted file mode 100644
index 3564be0..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/FormWizardPage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.*;
-
-/**
- * Form wizard page is a page that hosts a scrollable form. Subclasses
- * are supposed to implement 'fillFormBody' that
- */
-public abstract class FormWizardPage extends WizardPage {
- protected FormToolkit toolkit;
- protected ManagedForm managedForm;
-
- public FormWizardPage(String id, FormToolkit toolkit) {
- super(id);
- this.toolkit = toolkit;
- }
-
-/**
- * Creates the form wizard page control. This method is final. Clients
- * are expected to implement <code>createFormContents(Composite)</code> instead.
- */
- public final void createControl(Composite parent) {
- Form form = toolkit.createForm(parent);
- form.setExpandHorizontal(true);
- form.setExpandVertical(true);
- managedForm = new ManagedForm(toolkit, form);
- createFormContents(form.getBody());
- setControl(form);
- }
-
- public void dispose() {
- managedForm.dispose();
- super.dispose();
- }
-
- protected abstract void createFormContents(Composite form);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkGroup.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkGroup.java
deleted file mode 100644
index 07e59cd..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkGroup.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-
-/**
- * Manages a group of hyperlinks. It tracks activation, updates normal and
- * active colors and updates underline state depending on the underline
- * preference. Hyperlink labels are added to the group after creation and are
- * automatically removed from the group when they are disposed.
- *
- * @since 3.0
- */
-
-public class HyperlinkGroup extends HyperlinkSettings {
- private ArrayList links = new ArrayList();
- private Hyperlink lastActivated;
- private Hyperlink lastEntered;
- private GroupListener listener;
-
- private class GroupListener implements Listener, HyperlinkListener {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.MouseEnter :
- onMouseEnter(e);
- break;
- case SWT.MouseExit :
- onMouseExit(e);
- break;
- case SWT.MouseDown :
- onMouseDown(e);
- break;
- case SWT.Dispose :
- unhook((Hyperlink) e.widget);
- break;
- }
- }
- private void onMouseEnter(Event e) {
- Hyperlink link = (Hyperlink) e.widget;
- if (getActiveBackground() != null)
- link.setBackground(getActiveBackground());
- if (getActiveForeground() != null)
- link.setForeground(getActiveForeground());
- }
- private void onMouseExit(Event e) {
- Hyperlink link = (Hyperlink) e.widget;
- if (getBackground() != null)
- link.setBackground(getBackground());
- if (getForeground() != null)
- link.setForeground(getForeground());
- }
- public void linkActivated(HyperlinkEvent e) {
- }
-
- public void linkEntered(HyperlinkEvent e) {
- if (lastEntered != null) {
- linkExited(lastEntered);
- }
- Hyperlink link = (Hyperlink) e.widget;
- link.setCursor(getHyperlinkCursor());
- if (getHyperlinkUnderlineMode() == UNDERLINE_ROLLOVER)
- link.setUnderlined(true);
- lastEntered = link;
- }
-
- public void linkExited(HyperlinkEvent e) {
- linkExited((Hyperlink) e.widget);
- }
- private void linkExited(Hyperlink link) {
- link.setCursor(null);
- if (getHyperlinkUnderlineMode() == UNDERLINE_ROLLOVER)
- link.setUnderlined(false);
- if (lastEntered == link)
- lastEntered = null;
- }
- }
-
- /**
- * Creates a hyperlink group.
- */
-
- public HyperlinkGroup(Display display) {
- super(display);
- listener = new GroupListener();
- }
-
- /**
- * Returns the link that has been active the last, or <code>null</code>
- * if no link has been active yet or the last active link has been
- * disposed.
- *
- * @return the last active link or <code>null</code>
- */
- public Hyperlink getLastActivated() {
- return lastActivated;
- }
- /**
- * Adds a hyperlink to the group to be jointly managed. Hyperlink will be
- * managed until it is disposed. Settings like colors, cursors and modes
- * will affect all managed hyperlinks.
- *
- * @param link
- */
-
- public void add(Hyperlink link) {
- if (getBackground() != null)
- link.setBackground(getBackground());
- if (getForeground() != null)
- link.setForeground(getForeground());
- if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS)
- link.setUnderlined(true);
- hook(link);
- }
- /**
- * Sets the group background and also sets the background of all the
- * currently managed links.
- *
- * @param bg
- * the new background
- */
-
- public void setBackground(Color bg) {
- super.setBackground(bg);
- if (links != null) {
- for (int i = 0; i < links.size(); i++) {
- Hyperlink label = (Hyperlink) links.get(i);
- label.setBackground(bg);
- }
- }
- }
- /**
- * Sets the group foreground and also sets the background of all the
- * currently managed links.
- *
- * @param fg
- * the new foreground
- */
- public void setForeground(Color fg) {
- super.setForeground(fg);
- if (links != null) {
- for (int i = 0; i < links.size(); i++) {
- Hyperlink label = (Hyperlink) links.get(i);
- label.setForeground(fg);
- }
- }
- }
- /**
- * Sets the hyperlink underline mode.
- *
- * @param mode
- * the new hyperlink underline mode
- * @see HyperlinkSettings
- */
- public void setHyperlinkUnderlineMode(int mode) {
- super.setHyperlinkUnderlineMode(mode);
- if (links != null) {
- for (int i = 0; i < links.size(); i++) {
- Hyperlink label = (Hyperlink) links.get(i);
- label.setUnderlined(mode == UNDERLINE_ALWAYS);
- }
- }
- }
-
- private void hook(Hyperlink link) {
- link.addListener(SWT.MouseDown, listener);
- link.addHyperlinkListener(listener);
- link.addListener(SWT.Dispose, listener);
- link.addListener(SWT.MouseEnter, listener);
- link.addListener(SWT.MouseExit, listener);
- links.add(link);
- }
-
- private void unhook(Hyperlink link) {
- link.removeListener(SWT.MouseDown, listener);
- link.removeHyperlinkListener(listener);
- link.removeListener(SWT.MouseEnter, listener);
- link.removeListener(SWT.MouseExit, listener);
- if (lastActivated == link)
- lastActivated = null;
- if (lastEntered == link)
- lastEntered = null;
- links.remove(link);
- }
-
- private void onMouseDown(Event e) {
- if (e.button == 1)
- return;
- lastActivated = (Hyperlink) e.widget;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkSettings.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkSettings.java
deleted file mode 100644
index f59f376..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/HyperlinkSettings.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.resource.JFaceColors;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.forms.internal.widgets.*;
-
-/**
- * Manages color and underline mode settings for a group of hyperlinks.
- */
-
-public class HyperlinkSettings {
- public static final int UNDERLINE_NEVER = 1;
- public static final int UNDERLINE_ROLLOVER = 2;
- public static final int UNDERLINE_ALWAYS = 3;
-
- private int hyperlinkUnderlineMode = UNDERLINE_ALWAYS;
- private Color background;
- private Color foreground;
- private Color activeBackground;
- private Color activeForeground;
-
- public HyperlinkSettings(Display display) {
- initializeDefaultForegrounds(display);
- }
-
- public void initializeDefaultForegrounds(Display display) {
- setForeground(JFaceColors.getHyperlinkText(display));
- setActiveForeground(JFaceColors.getActiveHyperlinkText(display));
- }
-
- public Color getActiveBackground() {
- return activeBackground;
- }
- public Color getActiveForeground() {
- return activeForeground;
- }
- public Color getBackground() {
- return background;
- }
- public Cursor getBusyCursor() {
- return FormsResources.getBusyCursor();
- }
- public Cursor getTextCursor() {
- return FormsResources.getTextCursor();
- }
- public Color getForeground() {
- return foreground;
- }
- public Cursor getHyperlinkCursor() {
- return FormsResources.getHandCursor();
- }
- public int getHyperlinkUnderlineMode() {
- return hyperlinkUnderlineMode;
- }
-
- public void setActiveBackground(Color newActiveBackground) {
- activeBackground = newActiveBackground;
- }
- public void setActiveForeground(Color newActiveForeground) {
- activeForeground = newActiveForeground;
- }
- public void setBackground(Color newBackground) {
- background = newBackground;
- }
- public void setForeground(Color newForeground) {
- foreground = newForeground;
- }
-
- public void setHyperlinkUnderlineMode(int mode) {
- hyperlinkUnderlineMode = mode;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPage.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPage.java
deleted file mode 100644
index 4571822..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Created on Jan 24, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public interface IDetailsPage {
-/**
- *
- * @param form
- */
- void initialize(IManagedForm form);
-/**
- *
- * @param parent
- */
- void createContents(Composite parent);
-/**
- *
- * @param selection
- */
- void inputChanged(IStructuredSelection selection);
-/**
- *
- *
- */
- void commit();
-/**
- *
- *
- */
- void setFocus();
-/**
- *
- *
- */
- void dispose();
-/**
- *
- * @return
- */
- boolean isDirty();
-/**
- *
- *
- */
- void refresh();
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPageProvider.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPageProvider.java
deleted file mode 100644
index 1e72f23..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IDetailsPageProvider.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Created on Jan 30, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms;
-
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public interface IDetailsPageProvider {
- Object getPageKey(Object object);
- IDetailsPage getPage(Object objectClass);
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IFormPart.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IFormPart.java
deleted file mode 100644
index 207bf4c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IFormPart.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-/**
- *
- * @see IManagedForm
- */
-public interface IFormPart {
- /**
- * Initializes the part.
- *
- * @param form the managed form that manages the part
- */
- void initialize(IManagedForm form);
- /**
- * Disposes the part allowing it to release allocated resources.
- */
- void dispose();
- /**
- * Returns true if the part has been modified with respect to
- * the data loaded from the model.
- * @return
- */
- boolean isDirty();
- /**
- * If part is displaying information loaded from a model, this method
- * instructs it to commit the new (modified) data back into the model.
- *
- * @param onSave
- * indicates if commit is called during 'save' operation or for
- * some other reason (for example, if form is contained in a
- * wizard or a multi-page editor and the user is about to leave
- * the page).
- */
- void commit(boolean onSave);
-
- /**
- * Notifies the part that an object has been set as overall form's input.
- * The part can elect to react by revealing or selecting the object, or do
- * nothing if not applicable.
- */
- void setFormInput(Object input);
- /**
- * Instructs form part to transfer focus to the widget that should has
- * focus in that part. The method can do nothing (if it has no widgets
- * capable of accepting focus).
- */
- void setFocus();
- /**
- * Refreshes the part completely from the information freshly obtained from
- * the model.
- */
- void refresh();
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IManagedForm.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IManagedForm.java
deleted file mode 100644
index 3ec2b52..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IManagedForm.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.forms.widgets.*;
-
-/**
- * Managed form wraps a form widget and adds life cycle methods
- * for form parts. A form part is a portion of the form that
- * participates in form life cycle events.
- * <p>There is no 1/1 mapping between widgets and form parts.
- * A widget like Section can be a part by itself, but a number
- * of widgets can gather around one form part.
- *
- * @since 3.0
- */
-public interface IManagedForm {
-/**
- * Returns the toolkit used by this form.
- * @return the toolkit
- */
- public FormToolkit getToolkit();
-
-/**
- * Returns the form widget managed by this form.
- * @return the form widget
- */
- public Form getForm();
-
-/**
- * A part can use this method to notify other parts that
- * implement IPartSelectionListener about selection changes.
- * @param part the part that broadcasts the selection
- * @param selection the selection in the part
- */
- public void fireSelectionChanged(IFormPart part, ISelection selection);
-
-/**
- * Returns all the parts currently managed by this form.
- * @return the managed parts
- */
- IFormPart [] getParts();
-
-/**
- * Sets the input of this page to the provided object.
- * @param input the new page input
- */
- void setInput(Object input);
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IPartSelectionListener.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IPartSelectionListener.java
deleted file mode 100644
index e7f45af..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/IPartSelectionListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-
-import org.eclipse.jface.viewers.ISelection;
-
-/**
- * Form parts can implement this interface if they want to be notified when
- * another part on the same form changes selection state.
- *
- * @see IFormPart
- */
-public interface IPartSelectionListener {
- /**
- * Called when the provided part has changed selection state.
- *
- * @param part
- * the selection source
- * @param selection
- * the new selection
- */
- public void selectionChanged(IFormPart part, ISelection selection);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/ManagedForm.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/ManagedForm.java
deleted file mode 100644
index 6f53f32..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/ManagedForm.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package org.eclipse.ui.forms;
-
-import java.util.Vector;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.*;
-
-/**
- * Managed form wraps a form widget and adds life cycle methods for form parts.
- * A form part is a portion of the form that participates in form life cycle
- * events.
- * <p>
- * There is requirement for 1/1 mapping between widgets and form parts. A
- * widget like Section can be a part by itself, but a number of widgets can
- * join around one form part.
- *
- * @since 3.0
- */
-public class ManagedForm implements IManagedForm {
- private Form form;
- private FormToolkit toolkit;
- private boolean ownsToolkit;
- private Vector parts = new Vector();
-
- /**
- * Creates a managed form in the provided parent. Form toolkit and widget
- * will be created and owned by this object.
- *
- * @param parent
- * the parent widget
- */
-
- public ManagedForm(Composite parent) {
- toolkit = new FormToolkit(parent.getDisplay());
- ownsToolkit = true;
- form = toolkit.createForm(parent);
- }
- /**
- * Creates a managed form that will use the provided toolkit and
- *
- * @param toolkit
- * @param form
- */
- public ManagedForm(FormToolkit toolkit, Form form) {
- this.form = form;
- this.toolkit = toolkit;
- }
-
- /**
- * Add a part to be managed by this form.
- *
- * @param part
- * part to add
- */
- public void addPart(IFormPart part) {
- parts.add(part);
- }
- /**
- * Remove the part from this form.
- *
- * @param part
- * part to remove
- */
- public void removePart(IFormPart part) {
- parts.remove(part);
- }
-
- /**
- * Returns all the parts current managed by this form.
- */
- public IFormPart[] getParts() {
- return (IFormPart[]) parts.toArray(new IFormPart[parts.size()]);
- }
- /**
- * Returns the toolkit used by this form.
- *
- * @return the toolkit
- */
- public FormToolkit getToolkit() {
- return toolkit;
- }
-
- /**
- * Returns the form widget managed by this form.
- *
- * @return the form widget
- */
- public Form getForm() {
- return form;
- }
-
- /**
- * A part can use this method to notify other parts that implement
- * IPartSelectionListener about selection changes.
- *
- * @param part
- * the part that broadcasts the selection
- * @param selection
- * the selection in the part
- * @see IPartSelectionListener
- */
- public void fireSelectionChanged(IFormPart part, ISelection selection) {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart cpart = (IFormPart) parts.get(i);
- if (part.equals(cpart))
- continue;
- if (cpart instanceof IPartSelectionListener) {
- ((IPartSelectionListener) cpart).selectionChanged(
- part,
- selection);
- }
- }
- }
-
- /**
- * Initializes all the parts in this form.
- */
- public void initialize() {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- part.initialize(this);
- }
- }
-
- /**
- * Disposes all the parts in this form.
- */
- public void dispose() {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- part.dispose();
- }
- if (ownsToolkit) {
- toolkit.dispose();
- }
- }
-
- /**
- * Refreshes the form by forcing all the parts to reload the content from
- * the model.
- */
- public void refresh() {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- part.refresh();
- }
- form.reflow(true);
- }
-
- /**
- * Refreshes the form by forcing all the parts to reload the content from
- * the model.
- */
- public void commit(boolean onSave) {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- part.commit(onSave);
- }
- }
-
- /**
- * Sets the form input. Managed parts could opt to react to it by selecting
- * and/or revealing the object if they contain it.
- *
- * @param input
- * the input object
- */
- public void setInput(Object input) {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- part.setFormInput(input);
- }
- }
- /**
- * Transfers the focus to the first form part.
- */
- public void setFocus() {
- if (parts.size() > 0) {
- IFormPart part = (IFormPart) parts.get(0);
- part.setFocus();
- }
- }
-
- public boolean isDirty() {
- for (int i = 0; i < parts.size(); i++) {
- IFormPart part = (IFormPart) parts.get(i);
- if (part.isDirty())
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/MasterDetailsBlock.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/MasterDetailsBlock.java
deleted file mode 100644
index 1144470..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/MasterDetailsBlock.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Created on Jan 20, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.*;
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public abstract class MasterDetailsBlock {
- protected DetailsPart detailsPart;
- protected SashForm sashForm;
-
- public void createContent(ManagedForm managedForm) {
- final Form form = managedForm.getForm();
- FormToolkit toolkit = managedForm.getToolkit();
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- form.getBody().setLayout(layout);
- sashForm = new SashForm(form.getBody(), SWT.NULL);
- toolkit.adapt(sashForm, false, false);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createMasterPart(managedForm, sashForm);
- createDetailsPart(managedForm, sashForm);
- createToolBarActions(managedForm);
- form.updateToolBar();
- }
-
- protected abstract void createMasterPart(ManagedForm managedForm, Composite parent);
- protected abstract void registerPages(DetailsPart detailsPart);
- protected abstract void createToolBarActions(ManagedForm managedForm);
-
- private void createDetailsPart(final ManagedForm mform, Composite parent) {
- detailsPart = new DetailsPart(mform, parent, SWT.NULL);
- mform.addPart(detailsPart);
- registerPages(detailsPart);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/SectionPart.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/SectionPart.java
deleted file mode 100644
index 0c16b5c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/SectionPart.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.widgets.*;
-/**
- * Section part implements IFormPart interface based on the Section widget.
- *
- * @see Section
- */
-public class SectionPart implements IFormPart {
- private IManagedForm managedForm;
- private Section section;
- /**
- * Creates a new section part based on the provided section.
- *
- * @param section
- * the section to use
- */
- public SectionPart(Section section) {
- this.section = section;
- initialize();
- }
- public SectionPart(Composite parent, FormToolkit toolkit, int style) {
- this(toolkit.createSection(parent, style));
- }
- /**
- * Initializes the section.
- */
- protected void initialize() {
- if ((section.getExpansionStyle() & Section.TWISTIE) != 0
- || (section.getExpansionStyle() & Section.TREE_NODE) != 0) {
- section.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanging(ExpansionEvent e) {
- SectionPart.this.expansionStateChanging(e.getState());
- }
- public void expansionStateChanged(ExpansionEvent e) {
- SectionPart.this.expansionStateChanged(e.getState());
- }
- });
- }
- }
- /**
- * Returns the section widget used in this part.
- *
- * @return the section widget
- */
- public Section getSection() {
- return section;
- }
- protected void expansionStateChanging(boolean expanding) {
- }
- protected void expansionStateChanged(boolean expanded) {
- managedForm.getForm().reflow(false);
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.ManagedForm)
- */
- public void initialize(IManagedForm form) {
- this.managedForm = form;
- }
-
- public IManagedForm getForm() {
- return managedForm;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#dispose()
- */
- public void dispose() {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
- */
- public void commit(boolean onSave) {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
- */
- public void setFormInput(Object input) {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#setFocus()
- */
- public void setFocus() {
- Control client = section.getClient();
- if (client != null)
- client.setFocus();
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.IFormPart#refresh()
- */
- public void refresh() {
- }
- public boolean isDirty() {
- return false;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormEditor.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormEditor.java
deleted file mode 100644
index b3a556a..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormEditor.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.editor;
-import java.util.Vector;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.*;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.part.*;
-import org.eclipse.update.ui.forms.internal.FormsPlugin;
-/**
- * This class forms a base of multi-page form editors that typically use one or
- * more pages with forms and one page for raw source of the editor input.
- * <p>
- * Pages are added 'lazily' i.e. adding a page reserves a tab for it but does
- * not cause the page control to be created. Page control is created when an
- * attempt is made to select the page in question. This allows editors with
- * several tabs and complex pages to open quickly.
- *
- * @since 3.0
- */
-public abstract class FormEditor extends MultiPageEditorPart {
- private FormToolkit toolkit;
- protected Vector pages;
- private IEditorPart sourcePage;
- private IEditorPart lastActiveEditor = null;
- private int currentPage = -1;
- /**
- * The constructor.
- */
- public FormEditor() {
- pages = new Vector();
- }
- /**
- * Creates the common toolkit for this editor and adds pages to the editor.
- *
- * @see #addPages
- */
- protected void createPages() {
- toolkit = createToolkit(getContainer().getDisplay());
- addPages();
- }
- protected FormToolkit createToolkit(Display display) {
- return new FormToolkit(display);
- }
- /**
- * Subclass should implement this method to add pages to the editor using
- * 'addPage(IFormPage)' method.
- */
- protected abstract void addPages();
- /**
- * Overrides 'super' to create a multi-page key binding editor site for key
- * binding delegation down to the editor nested sites.
- */
- protected IEditorSite createSite(IEditorPart editor) {
- return new MultiPageKeyBindingEditorSite(this, editor);
- }
- /**
- * Adds the form page to this editor.
- *
- * @param page
- * the page to add
- */
- public int addPage(IFormPage page) {
- int i = addPage(page.getPartControl());
- configurePage(i, page);
- return i;
- }
- public int addPage(IEditorPart editor, IEditorInput input)
- throws PartInitException {
- int index = super.addPage(editor, input);
- if (editor instanceof IFormPage) {
- configurePage(index, (IFormPage) editor);
- }
- return index;
- }
- protected void configurePage(int index, IFormPage page) {
- setPageText(index, page.getTitle());
- //setPageImage(index, page.getTitleImage());
- page.setIndex(index);
- registerPage(page);
- }
- /**
- * Disposes the pages and the toolkit after disposing the editor itself.
- * Subclasses must call 'super' when reimplementing the method.
- */
- public void dispose() {
- super.dispose();
- for (int i = 0; i < pages.size(); i++) {
- IFormPage page = (IFormPage) pages.get(i);
- // don't dispose source pages because they will
- // be disposed as nested editors by the superclass
- if (!page.isSource()) page.dispose();
- }
- pages = null;
- toolkit.dispose();
- toolkit = null;
- }
- /**
- * Returns the toolkit owned by this editor.
- *
- * @return the toolkit object
- */
- public FormToolkit getToolkit() {
- return toolkit;
- }
- /*
- * Widens visibility for access by MultiPageKeyBindingEditorSite
- */
- public IEditorPart getActiveEditor() {
- return super.getActiveEditor();
- }
- /**
- * Returns the current page index. The value is identical to the value of
- * 'getActivePage()' except during the page switch, when this method still
- * has the old active page index.
- *
- * @return
- */
- protected int getCurrentPage() {
- return currentPage;
- }
- /**
- * @see MultiPageEditorPart#pageChange(int)
- */
- protected void pageChange(int newPageIndex) {
- // deactivate the old editor's site
- if (lastActiveEditor != null) {
- ((MultiPageKeyBindingEditorSite) lastActiveEditor.getSite())
- .deactivate();
- lastActiveEditor = null;
- }
- // Now is the absolute last moment to create the page control.
- IFormPage page = (IFormPage) pages.get(newPageIndex);
- if (page.getPartControl() == null) {
- page.createPartControl(getContainer());
- setControl(newPageIndex, page.getPartControl());
- }
- // fix for windows handles
- int oldPage = getCurrentPage();
- if (pages.size() > newPageIndex
- && pages.get(newPageIndex) instanceof IFormPage)
- ((IFormPage) pages.get(newPageIndex)).setActive(true);
- if (oldPage != -1 && pages.size() > oldPage
- && pages.get(oldPage) instanceof IFormPage)
- ((IFormPage) pages.get(oldPage)).setActive(false);
- // Call super - this will cause pages to switch
- super.pageChange(newPageIndex);
- // activate the new editor's site
- IEditorPart activeEditor = getActiveEditor();
- if (activeEditor != null) {
- if (activeEditor.getSite() instanceof MultiPageKeyBindingEditorSite) {
- ((MultiPageKeyBindingEditorSite) activeEditor.getSite())
- .activate();
- lastActiveEditor = activeEditor;
- }
- }
- this.currentPage = newPageIndex;
- }
- /**
- * Sets the active page using the unique page identifier.
- *
- * @param pageId
- * the id of the page to switch to
- * @return page that was set active or <samp>null</samp> if not found.
- */
- public IFormPage setActivePage(String pageId) {
- for (int i = 0; i < pages.size(); i++) {
- IFormPage page = (IFormPage) pages.get(i);
- if (page.getId().equals(pageId)) {
- setActivePage(i);
- return page;
- }
- }
- return null;
- }
- /**
- * Finds the page instance that has the provided id.
- *
- * @param pageId
- * the id of the page to find
- * @return page with the matching id or <code>null</code> if not found.
- */
- public IFormPage findPage(String pageId) {
- for (int i = 0; i < pages.size(); i++) {
- IFormPage page = (IFormPage) pages.get(i);
- if (page.getId().equals(pageId))
- return page;
- }
- return null;
- }
- /**
- * Sets the active page using the unique page identifier and sets its input
- * to the provided object.
- *
- * @param pageId
- * the id of the page to switch to
- * @param pageInput
- * the page input
- * @return page that was set active or <samp>null</samp> if not found.
- */
- public IFormPage setActivePage(String pageId, Object pageInput) {
- IFormPage page = setActivePage(pageId);
- if (page != null) {
- IManagedForm mform = page.getManagedForm();
- if (mform != null)
- mform.setInput(pageInput);
- }
- return page;
- }
- /**
- * Returns active page instance if the currently selected page index is not
- * -1, or <code>null</code> if it is.
- *
- * @return active page instance if selected, or <code>null</code> if no
- * page is currently active.
- */
- public IFormPage getActivePageInstance() {
- int index = getActivePage();
- if (index != -1)
- return (IFormPage) pages.get(index);
- return null;
- }
- /**
- * @see MultiPageEditorPart#setActivePage(int)
- */
- protected void setActivePage(int pageIndex) {
- // fix for window handles problem
- // this should be called only when the editor is first opened
- if (pages.size() > pageIndex
- && pages.get(pageIndex) instanceof IFormPage) {
- pageChange(pageIndex);
- IFormPage activePage = (IFormPage) pages.get(pageIndex);
- activePage.setActive(true);
- super.setActivePage(pageIndex);
- } else
- super.setActivePage(pageIndex);
- // this is to enable the undo/redo actions before a page change has
- // occurred
- IEditorActionBarContributor contributor = getEditorSite()
- .getActionBarContributor();
- if (contributor != null
- && contributor instanceof MultiPageEditorActionBarContributor) {
- ((MultiPageEditorActionBarContributor) contributor)
- .setActivePage(getEditor(pageIndex));
- }
- }
- private void registerPage(IFormPage page) {
- if (!pages.contains(page))
- pages.add(page);
- if (page.isSource() == false) {
- try {
- page.init(getEditorSite(), getEditorInput());
- } catch (PartInitException e) {
- FormsPlugin.logException(e);
- }
- }
- }
- /**
- * Closes the editor programmatically.
- *
- * @param save
- * if <code>true</code>, the content should be saved before
- * closing.
- */
- public void close(final boolean save) {
- Display display = getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- if (toolkit != null) {
- getSite().getPage().closeEditor(FormEditor.this, save);
- }
- }
- });
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormPage.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormPage.java
deleted file mode 100644
index fa7fddb..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/FormPage.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.editor;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.forms.*;
-import org.eclipse.ui.forms.widgets.Form;
-import org.eclipse.ui.part.EditorPart;
-
-/**
- * A base class that all pages that should be added to FormEditor
- * must subclass. Form page has a managed form. Subclasses should
- * override method 'createFormContent(ManagedForm)' to fill the
- * form with content. Note that page itself can be loaded
- * lazily (when first open). Consequently, the call to create
- * the form content can come after the editor has been opened
- * for a while (in fact, it is possible to open and close the
- * editor and never create the form because no attempt was
- * made to show the page).
- */
-public class FormPage extends EditorPart implements IFormPage {
- private FormEditor editor;
- private ManagedForm mform;
- private int index;
- private String id;
- private String title;
-
- public FormPage(FormEditor editor, String id, String title) {
- this(id, title);
- initialize(editor);
- }
-
-/**
- * The constructor.
- * @param id a unique page identifier
- * @param title a user-friendly page title
- */
- public FormPage(String id, String title) {
- this.id = id;
- this.title = title;
- }
-
-/**
- * Initializes the form page.
- * @see IEditorPart#init
- */
- public void init(IEditorSite site, IEditorInput input) {
- setSite(site);
- setInput(input);
- }
-
- public void initialize(FormEditor editor) {
- this.editor = editor;
- }
-
- public FormEditor getEditor() {
- return editor;
- }
-
- public IManagedForm getManagedForm() {
- return mform;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.IFormPage#setActive(boolean)
- */
- public void setActive(boolean active) {
- }
-
- public boolean isActive() {
- return this.equals(editor.getActivePageInstance());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl(Composite parent) {
- Form form = editor.getToolkit().createForm(parent);
- mform = new ManagedForm(editor.getToolkit(), form);
- BusyIndicator.showWhile(parent.getDisplay(), new Runnable() {
- public void run() {
- createFormContent(mform);
- }
- });
- }
-
-/**
- * Subclasses should override this method to create content
- * in the form hosted in this page.
- * @param managedForm the form hosted in this page.
- */
- protected void createFormContent(ManagedForm managedForm) {
- }
-
- public Control getPartControl() {
- return mform!=null?mform.getForm():null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- if (mform!=null) mform.dispose();
- }
-
- public String getId() {
- return id;
- }
-
- public String getTitle() {
- return title;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
- */
- public Image getTitleImage() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- if (mform!=null) mform.setFocus();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void doSave(IProgressMonitor monitor) {
- if (mform!=null) mform.commit(true);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISaveablePart#doSaveAs()
- */
- public void doSaveAs() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISaveablePart#isDirty()
- */
- public boolean isDirty() {
- return mform!=null?mform.isDirty():false;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- public int getIndex() {
- return index;
- }
- public boolean isSource() {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.IFormPage#focusOn(java.lang.Object)
- */
- public void focusOn(Object object) {
- if (mform!=null)
- mform.setInput(object);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/IFormPage.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/IFormPage.java
deleted file mode 100644
index 8275497..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/IFormPage.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.editor;
-
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.forms.IManagedForm;
-
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public interface IFormPage extends IEditorPart {
-/**
- *
- *@param editor the form editor that this page belongs to
- */
- void initialize(FormEditor editor);
-
-/**
- * Returns the editor this page belongs to.
- * @return the form editor
- */
- FormEditor getEditor();
-/**
- * Returns the managed form of this page, unless this is a source page.
- * @return the managed form or <samp>null</samp> if this is a source
- * page.
- */
- IManagedForm getManagedForm();
-/**
- * Indicates whether the page has become the active in the editor.
- * Classes that implement this
- * interface may use this method to commit the page (on <code>false</code>)
- * or lazily create and/or populate the content on <code>true</code>.
- * @param active <code>true</code> if page should be visible,
- * <code>false</code> otherwise.
- */
- void setActive(boolean active);
-/**
- * Returns <samp>true</samp> if page is currently active,
- * false if not.
- * @return <samp>true</samp> for active page.
- */
- boolean isActive();
-/**
- * Returns the control associated with this page.
- * @return the control of this page if created or <samp>null</samp>
- * if the page has not been shown yet.
- */
- Control getPartControl();
-/**
- * Page must have a unique id that can be used to show it
- * without knowing its relative position in the editor.
- * @return the unique page identifier
- */
- String getId();
-/**
- * Returns the position of the page in the editor.
- * @return the zero-based index of the page in the editor.
- */
- int getIndex();
-/**
- * Sets the position of the page in the editor.
- * @param index the zero-based index of the page in the editor.
- */
- void setIndex(int index);
-/**
- * Tests whether this page shows the editor input in the raw (source)
- * form.
- * @return <samp>true</samp> if the page shows editor input source,
- * <samp>false</samp> if this is a form page.
- */
- boolean isSource();
-/**
- * A hint to bring the provided object into focus. If the object
- * is in a tree or table control, select it. If it is shown
- * on a scrollable page, ensure that it is visible.
- * @param object object to bring into focus
- */
- void focusOn(Object object);
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingEditorSite.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingEditorSite.java
deleted file mode 100644
index 5e1a780..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingEditorSite.java
+++ /dev/null
@@ -1,47 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.editor;
-import org.eclipse.ui.*;
-import org.eclipse.ui.part.*;
-
-/**
- * Extends <code>MultiPageEditorSite</code> with a "virtualized" <code>IKeyBindingService</code>.
- *
- * @since 3.0
- */
-public class MultiPageKeyBindingEditorSite extends MultiPageEditorSite {
- private MultiPageKeyBindingService keyBindingService;
-
- public MultiPageKeyBindingEditorSite(
- MultiPageEditorPart multiPageEditor,
- IEditorPart editor) {
- super(multiPageEditor, editor);
- keyBindingService = new MultiPageKeyBindingService(this);
- }
-
- public IKeyBindingService getKeyBindingService() {
- return keyBindingService;
- }
-
- public void activate() {
- keyBindingService.activate();
- }
-
- public void deactivate() {
- keyBindingService.deactivate();
- }
-
- public boolean isActive() {
- //return getEditor() == ((MultiPageKeyBindingEditorPart)
- // getMultiPageEditor()).getActiveEditor();
- return true;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingService.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingService.java
deleted file mode 100644
index 55d9b76..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/editor/MultiPageKeyBindingService.java
+++ /dev/null
@@ -1,119 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.editor;
-
-import java.util.*;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.internal.IWorkbenchConstants;
-
-/**
- * Implementation of <code>IKeyBindingService</code> for nested editors.
- * "Virtualizes" the key binding service by keeping the outer key binding
- * service up to date for the currently active nested editor.
- */
-public class MultiPageKeyBindingService implements IKeyBindingService {
-
- private MultiPageKeyBindingEditorSite site;
- private String[] scopes =
- new String[] { IWorkbenchConstants.DEFAULT_ACCELERATOR_SCOPE_ID };
- private HashMap commandIdToActionMap = new HashMap();
-
- public MultiPageKeyBindingService(MultiPageKeyBindingEditorSite site) {
- this.site = site;
- }
-
- /**
- * Is the corresponding nested editor active?
- */
- private boolean isActive() {
- return site.isActive();
- }
-
- public void activate() {
- // register all actions with the outer service
- for (Iterator i = commandIdToActionMap.values().iterator();
- i.hasNext();
- ) {
- getOuterService().registerAction((IAction) i.next());
- }
- }
-
- public void deactivate() {
- // deregister all actions from the outer service
- for (Iterator i = commandIdToActionMap.values().iterator();
- i.hasNext();
- ) {
- getOuterService().unregisterAction((IAction) i.next());
- }
- }
-
- /**
- * Returns the outer key binding service.
- */
- private IKeyBindingService getOuterService() {
- return site.getMultiPageEditor().getSite().getKeyBindingService();
- }
-
- public String[] getScopes() {
- return (String[]) scopes.clone();
- }
-
- public void setScopes(String[] scopes) {
- if (scopes == null || scopes.length < 1)
- throw new IllegalArgumentException();
- for (int i = 0; i < scopes.length; i++)
- if (scopes[i] == null)
- throw new IllegalArgumentException();
- this.scopes = (String[]) scopes.clone();
- if (isActive())
- getOuterService().setScopes(scopes);
- }
-
- public void registerAction(IAction action) {
- // remember the registered action and forward to the outer service
- // if the corresponding nested editor is active
- String command = action.getActionDefinitionId();
- if (command != null) {
- commandIdToActionMap.put(command, action);
- if (isActive())
- getOuterService().registerAction(action);
- }
- }
-
- public void unregisterAction(IAction action) {
- // forget the registered action and forward to the outer service
- // if the corresponding nested editor is active
- String command = action.getActionDefinitionId();
- if (command != null) {
- commandIdToActionMap.remove(command);
- if (isActive())
- getOuterService().unregisterAction(action);
- }
- }
-
- public String getActiveAcceleratorScopeId() {
- return getScopes()[0];
- }
-
- public void setActiveAcceleratorScopeId(String scopeId) {
- setScopes(new String[] { scopeId });
- }
-
- public boolean processKey(KeyEvent event) {
- return false;
- }
-
- public void enable(boolean enable) {
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionAdapter.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionAdapter.java
deleted file mode 100644
index d88edeb..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionAdapter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>HyperlinkListener</code> interface.
- * <p>
- * Classes that wish to deal with <code>HyperlinkEvent</code>s can
- * extend this class and override only the methods which they are
- * interested in.
- * </p>
- *
- * @see ExpansionListener
- * @see ExpansionEvent
- */
-public class ExpansionAdapter implements ExpansionListener {
-
- /**
- * Sent when the link is entered. The default behaviour
- * is to do nothing.
- * @param e the event
- */
- public void expansionStateChanging(ExpansionEvent e) {
- }
-
- /**
- * Sent when the link is exited. The default behaviour
- * is to do nothing.
- * @param e the event
- */
- public void expansionStateChanged(ExpansionEvent e) {
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionEvent.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionEvent.java
deleted file mode 100644
index fa569b8..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionEvent.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-import org.eclipse.swt.events.TypedEvent;
-
-/**
- * Notifies listeners about a hyperlink change.
- */
-public class ExpansionEvent extends TypedEvent {
-
-/**
- * Creates a new hyperlink
- * @param obj event source
- * @param href the hyperlink reference that will be followed upon when
- * the hyperlink is activated.
- * @param label the name of the hyperlink (the text that is rendered
- * as a link in the source widget).
- */
- public ExpansionEvent(Object obj, boolean state) {
- super(obj);
- data = state?Boolean.TRUE:Boolean.FALSE;
- }
-
- public boolean getState() {
- return data.equals(Boolean.TRUE)?true:false;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionListener.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionListener.java
deleted file mode 100644
index be3fb79..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/ExpansionListener.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-public interface ExpansionListener {
- void expansionStateChanging(ExpansionEvent e);
- void expansionStateChanged(ExpansionEvent e);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkAdapter.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkAdapter.java
deleted file mode 100644
index 34a7d72..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>HyperlinkListener</code> interface.
- * <p>
- * Classes that wish to deal with <code>HyperlinkEvent</code>s can
- * extend this class and override only the methods which they are
- * interested in.
- * </p>
- *
- * @see HyperlinkListener
- * @see HyperlinkEvent
- */
-public class HyperlinkAdapter implements HyperlinkListener {
-
- /**
- * Sent when the link is entered. The default behaviour
- * is to do nothing.
- * @param e the event
- */
- public void linkEntered(HyperlinkEvent e) {
- }
-
- /**
- * Sent when the link is exited. The default behaviour
- * is to do nothing.
- * @param e the event
- */
- public void linkExited(HyperlinkEvent e) {
- }
-
- /**
- * Sent when the link is activated. The default behaviour
- * is to do nothing.
- * @param e the event
- */
- public void linkActivated(HyperlinkEvent e) {
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkEvent.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkEvent.java
deleted file mode 100644
index 44b6691..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkEvent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-import org.eclipse.swt.events.TypedEvent;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Notifies listeners about a hyperlink change.
- */
-public class HyperlinkEvent extends TypedEvent {
- private String label;
-
-/**
- * Creates a new hyperlink
- * @param obj event source
- * @param href the hyperlink reference that will be followed upon when
- * the hyperlink is activated.
- * @param label the name of the hyperlink (the text that is rendered
- * as a link in the source widget).
- */
- public HyperlinkEvent(Widget widget, Object href, String label) {
- super(widget);
- this.widget = widget;
- this.data = href;
- this.label = label;
- }
-/**
- * The hyperlink reference that will be followed when the hyperlink
- * is activated.
- * @return the hyperlink reference object
- */
- public Object getHref() {
- return this.data;
- }
-/**
- * The text of the hyperlink rendered in the source widget.
- * @return the hyperlink label
- */
- public String getLabel() {
- return label;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkListener.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkListener.java
deleted file mode 100644
index 4b00d22..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/HyperlinkListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-public interface HyperlinkListener {
-/**
- * Sent when hyperlink is entered either by mouse
- * entering the link client area, or keyboard focus
- * switching to the hyperlink.
- * @param e an event containing information about the hyperlink
- */
- void linkEntered(HyperlinkEvent e);
-/**
- * Sent when hyperlink is exited either by mouse
- * exiting the link client area, or keyboard focus
- * switching from the hyperlink.
- * @param e an event containing information about the hyperlink
- */
- void linkExited(HyperlinkEvent e);
-/**
- * Sent when hyperlink is avtivated either by mouse
- * click inside the link client area, or by pressing 'Enter'
- * key while hyperlink has keyboard focus.
- * @param e an event containing information about the hyperlink
- */
- void linkActivated(HyperlinkEvent e);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/IFormEntryListener.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/IFormEntryListener.java
deleted file mode 100644
index 559b8e6..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/events/IFormEntryListener.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.events;
-
-import org.eclipse.ui.forms.widgets.FormEntry;
-
-public interface IFormEntryListener {
- void textValueChanged(FormEntry entry);
- void textDirty(FormEntry entry);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/BulletParagraph.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/BulletParagraph.java
deleted file mode 100644
index 997dfb3..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/BulletParagraph.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.util.Hashtable;
-
-import org.eclipse.swt.graphics.*;
-
-public class BulletParagraph extends Paragraph {
- public static final int CIRCLE = 1;
- public static final int TEXT = 2;
- public static final int IMAGE = 3;
- private int style = CIRCLE;
- private String text;
- private int CIRCLE_DIAM = 5;
- private int SPACING = 10;
- private int indent = -1;
- /**
- * Constructor for BulletParagraph.
- * @param addVerticalSpace
- */
- public BulletParagraph(boolean addVerticalSpace) {
- super(addVerticalSpace);
- }
-
- public int getIndent() {
- if (indent != -1)
- return indent;
- switch (style) {
- case CIRCLE :
- return CIRCLE_DIAM + SPACING;
- }
- return 20;
- }
-
- /*
- * @see IBulletParagraph#getBulletStyle()
- */
- public int getBulletStyle() {
- return style;
- }
-
- public void setBulletStyle(int style) {
- this.style = style;
- }
-
- public void setBulletText(String text) {
- this.text = text;
- }
-
- public void setIndent(int indent) {
- this.indent = indent;
- }
-
- /*
- * @see IBulletParagraph#getBulletText()
- */
- public String getBulletText() {
- return text;
- }
-
- public void paint(
- GC gc,
- int width,
- Locator loc,
- int lineHeight,
- Hashtable objectTable,
- HyperlinkSegment selectedLink) {
- paintBullet(gc, loc, lineHeight, objectTable);
- super.paint(gc, width, loc, lineHeight, objectTable, selectedLink);
- }
-
- public void paintBullet(
- GC gc,
- Locator loc,
- int lineHeight,
- Hashtable objectTable) {
- int x = loc.x - getIndent();
- if (style == CIRCLE) {
- int y = loc.y + lineHeight / 2 - CIRCLE_DIAM / 2;
- Color bg = gc.getBackground();
- Color fg = gc.getForeground();
- gc.setBackground(fg);
- gc.fillRectangle(x, y + 1, 5, 3);
- gc.fillRectangle(x + 1, y, 3, 5);
- gc.setBackground(bg);
- } else if (style == TEXT && text != null) {
- gc.drawText(text, x, loc.y);
- } else if (style == IMAGE && text != null) {
- Image image = (Image) objectTable.get(text);
- if (image != null) {
- int y = loc.y + lineHeight / 2 - image.getBounds().height / 2;
- gc.drawImage(image, x, y);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/FormsResources.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/FormsResources.java
deleted file mode 100644
index 108c5a0..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/FormsResources.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Created on Nov 27, 2003
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms.internal.widgets;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Utility methods to access shared form-specific resources.
- * <p>
- * All methods declared on this class are static. This
- * class cannot be instantiated.
- * </p>
- * <p>
- * </p>
- */
-public class FormsResources {
- private static Cursor busyCursor;
- private static Cursor handCursor;
- private static Cursor textCursor;
-
- public static Cursor getBusyCursor() {
- if (busyCursor==null)
- busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
- return busyCursor;
- }
- public static Cursor getHandCursor() {
- if (handCursor==null)
- handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- return handCursor;
- }
- public static Cursor getTextCursor() {
- if (textCursor==null)
- textCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_IBEAM);
- return textCursor;
- }
- public static void shutdown() {
- if (busyCursor!=null)
- busyCursor.dispose();
- if (handCursor!=null)
- handCursor.dispose();
- if (textCursor!=null)
- textCursor.dispose();
- busyCursor=null;
- handCursor=null;
- textCursor=null;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/HyperlinkSegment.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/HyperlinkSegment.java
deleted file mode 100644
index 7274256..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/HyperlinkSegment.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.util.Hashtable;
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.ui.forms.HyperlinkSettings;
-
-/**
- * @version 1.0
- * @author
- */
-public class HyperlinkSegment
- extends TextSegment {
- private String href;
- private HyperlinkSettings settings;
-
- public HyperlinkSegment(String text, HyperlinkSettings settings, String fontId) {
- super(text, fontId);
- this.settings = settings;
- underline = settings.getHyperlinkUnderlineMode()==HyperlinkSettings.UNDERLINE_ALWAYS;
- }
-
- /*
- * @see IObjectReference#getObjectId()
- */
- public String getHref() {
- return href;
- }
-
- void setHref(String href) {
- this.href = href;
- }
- public void paint(GC gc, int width, Locator locator, Hashtable objectTable, boolean selected) {
- setColor(settings.getForeground());
- super.paint(gc, width, locator, objectTable, selected);
- }
-
- public void repaint(GC gc, boolean hover) {
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
- int descent = fm.getDescent();
- boolean rolloverMode = settings.getHyperlinkUnderlineMode()==HyperlinkSettings.UNDERLINE_ROLLOVER;
- for (int i=0; i<areaRectangles.size(); i++) {
- AreaRectangle areaRectangle = (AreaRectangle)areaRectangles.get(i);
- Rectangle rect = areaRectangle.rect;
- String text = areaRectangle.getText();
- Point extent = gc.textExtent(text);
- int textX = rect.x + 1;
- gc.drawString(text, textX, rect.y, true);
- if (underline || hover || rolloverMode) {
- int lineY = rect.y + lineHeight - descent + 1;
- Color saved=null;
- if (rolloverMode && !hover) {
- saved = gc.getForeground();
- gc.setForeground(gc.getBackground());
- }
- gc.drawLine(textX, lineY, textX+extent.x, lineY);
- if (saved!=null)
- gc.setForeground(saved);
- }
- }
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ImageSegment.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ImageSegment.java
deleted file mode 100644
index 9848978..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ImageSegment.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.util.Hashtable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-
-/**
- * @version 1.0
- * @author
- */
-public class ImageSegment extends ParagraphSegment {
- public static final int TOP = 1;
- public static final int MIDDLE = 2;
- public static final int BOTTOM = 3;
-
- private int alignment = BOTTOM;
- private String imageId;
-
- public int getVerticalAlignment() {
- return alignment;
- }
-
- void setVerticalAlignment(int alignment) {
- this.alignment = alignment;
- }
-
- public Image getImage(Hashtable objectTable) {
- if (imageId==null) return null;
- Object obj = objectTable.get(imageId);
- if (obj==null) return null;
- if (obj instanceof Image) return (Image)obj;
- return null;
- }
-
- public String getObjectId() {
- return imageId;
- }
-
- void setObjectId(String imageId) {
- this.imageId = imageId;
- }
-
- public void advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable) {
- Image image = getImage(objectTable);
- int iwidth = 0;
- int iheight = 0;
- if (image!=null) {
- Rectangle rect = image.getBounds();
- iwidth = rect.width;
- iheight = rect.height;
- }
- if (wHint != SWT.DEFAULT && loc.x + iwidth > wHint) {
- // new line
- loc.x = loc.indent + iwidth;
- loc.width = loc.x;
- loc.y += loc.rowHeight;
- loc.rowHeight = iheight;
- }
- else {
- loc.x += iwidth;
- loc.rowHeight = Math.max(loc.rowHeight, iheight);
- }
- }
-
- public void paint(GC gc, int width, Locator loc, Hashtable objectTable, boolean selected) {
- Image image = getImage(objectTable);
- int iwidth = 0;
- int iheight = 0;
- if (image!=null) {
- Rectangle rect = image.getBounds();
- iwidth = rect.width;
- iheight = rect.height;
- }
- else return;
- loc.width = iwidth;
- loc.height = iheight;
-
- int ix = loc.x;
- int iy = loc.y;
-
- if (ix + iwidth > width) {
- // new row
- ix = loc.indent + loc.marginWidth;
- iy += loc.rowHeight;
- loc.rowHeight = 0;
- }
-
- gc.drawImage(image, ix, iy);
- loc.x = ix + iwidth;
- loc.y = iy;
- loc.rowHeight = Math.max(loc.rowHeight, iheight);
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Locator.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Locator.java
deleted file mode 100644
index 5a15992..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Locator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-/**
- * @version 1.0
- * @author
- */
-public class Locator {
- public int indent;
- public int x, y;
- public int width, height;
- public int rowHeight;
- public int marginWidth;
- public int marginHeight;
-
- public void newLine() {
- resetCaret();
- y += rowHeight;
- rowHeight = 0;
- }
-
- public void resetCaret() {
- x = marginWidth + indent;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Paragraph.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Paragraph.java
deleted file mode 100644
index 7153719..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/Paragraph.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.io.*;
-import java.util.*;
-
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.ui.forms.HyperlinkSettings;
-
-/**
- * @version 1.0
- * @author
- */
-public class Paragraph {
- public static final String HTTP = "http://";
- private Vector segments;
- private boolean addVerticalSpace = true;
-
- public Paragraph(boolean addVerticalSpace) {
- this.addVerticalSpace = addVerticalSpace;
- }
-
- public int getIndent() {
- return 0;
- }
-
- public boolean getAddVerticalSpace() {
- return addVerticalSpace;
- }
-
- /*
- * @see IParagraph#getSegments()
- */
- public ParagraphSegment[] getSegments() {
- if (segments == null)
- return new ParagraphSegment[0];
- return (ParagraphSegment[]) segments.toArray(
- new ParagraphSegment[segments.size()]);
- }
-
- public void addSegment(ParagraphSegment segment) {
- if (segments == null)
- segments = new Vector();
- segments.add(segment);
- }
-
- public void parseRegularText(
- String text,
- boolean expandURLs,
- HyperlinkSettings settings,
- String fontId) {
- if (text.length() == 0)
- return;
- if (expandURLs) {
- int loc = text.indexOf(HTTP);
-
- if (loc == -1)
- addSegment(new TextSegment(text, fontId));
- else {
- int textLoc = 0;
- while (loc != -1) {
- addSegment(new TextSegment(text.substring(textLoc, loc), fontId));
- boolean added = false;
- for (textLoc = loc; textLoc < text.length(); textLoc++) {
- char c = text.charAt(textLoc);
- if (Character.isSpaceChar(c)) {
- addHyperlinkSegment(text.substring(loc, textLoc), settings, fontId);
- added = true;
- break;
- }
- }
- if (!added) {
- // there was no space - just end of text
- addHyperlinkSegment(text.substring(loc), settings, fontId);
- break;
- }
- loc = text.indexOf(HTTP, textLoc);
- }
- if (textLoc < text.length()) {
- addSegment(new TextSegment(text.substring(textLoc), fontId));
- }
- }
- } else {
- addSegment(new TextSegment(text, fontId));
- }
- }
-
- private void addHyperlinkSegment(
- String text,
- HyperlinkSettings settings,
- String fontId) {
- HyperlinkSegment hs = new HyperlinkSegment(text, settings, fontId);
- hs.setWordWrapAllowed(false);
- hs.setHref(text);
- addSegment(hs);
- }
-
- public void paint(
- GC gc,
- int width,
- Locator loc,
- int lineHeight,
- Hashtable objectTable,
- HyperlinkSegment selectedLink) {
- ParagraphSegment [] segments = getSegments();
- if (segments.length > 0) {
- if (segments[0] instanceof TextSegment
- && ((TextSegment) segments[0]).isSelectable())
- loc.x += 1;
- for (int j = 0; j < segments.length; j++) {
- ParagraphSegment segment = segments[j];
- boolean doSelect = false;
- if (selectedLink != null && segment.equals(selectedLink))
- doSelect = true;
- segment.paint(gc, width, loc, objectTable, doSelect);
- }
- loc.y += loc.rowHeight;
- } else {
- loc.y += lineHeight;
- }
- }
- public String getAccessibleText() {
- ParagraphSegment [] segments = getSegments();
- StringWriter swriter = new StringWriter();
- PrintWriter writer = new PrintWriter(swriter);
- for (int i = 0; i < segments.length; i++) {
- ParagraphSegment segment = segments[i];
- if (segment instanceof TextSegment) {
- String text = ((TextSegment)segment).getText();
- writer.print(text);
- }
- }
- writer.println();
- swriter.flush();
- return swriter.toString();
- }
- public TextSegment findSegmentAt(int x, int y) {
- if (segments!=null) {
- for (int i=0; i<segments.size(); i++) {
- ParagraphSegment segment = (ParagraphSegment)segments.get(i);
- if (segment instanceof TextSegment) {
- TextSegment textSegment = (TextSegment)segment;
- if (textSegment.contains(x, y))
- return textSegment;
- }
- }
- }
- return null;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ParagraphSegment.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ParagraphSegment.java
deleted file mode 100644
index 3521732..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/ParagraphSegment.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.util.Hashtable;
-
-import org.eclipse.swt.graphics.GC;
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class ParagraphSegment {
- public abstract void advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable);
- public abstract void paint(GC gc, int width, Locator loc, Hashtable objectTable, boolean selected);
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/RichTextModel.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/RichTextModel.java
deleted file mode 100644
index 801322c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/RichTextModel.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.io.*;
-import java.util.Vector;
-
-import javax.xml.parsers.*;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.ui.forms.*;
-import org.eclipse.update.ui.forms.internal.FormsPlugin;
-import org.w3c.dom.*;
-import org.xml.sax.*;
-
-public class RichTextModel {
- private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-
- private Vector paragraphs;
- private HyperlinkSegment[] hyperlinks;
- private int selectedLinkIndex = -1;
- private HyperlinkSettings hyperlinkSettings;
-
- public RichTextModel() {
- reset();
- }
-
- /*
- * @see ITextModel#getParagraphs()
- */
- public Paragraph[] getParagraphs() {
- if (paragraphs == null)
- return new Paragraph[0];
- return (Paragraph[]) paragraphs.toArray(
- new Paragraph[paragraphs.size()]);
- }
-
- public String getAccessibleText() {
- if (paragraphs == null)
- return "";
- StringBuffer sbuf = new StringBuffer();
- for (int i=0; i<paragraphs.size(); i++) {
- Paragraph paragraph = (Paragraph)paragraphs.get(i);
- String text = paragraph.getAccessibleText();
- sbuf.append(text);
- }
- return sbuf.toString();
- }
-
- /*
- * @see ITextModel#parse(String)
- */
- public void parseTaggedText(String taggedText, boolean expandURLs)
- throws CoreException {
- if (taggedText==null) {
- reset();
- return;
- }
- try {
- InputStream stream =
- new ByteArrayInputStream(taggedText.getBytes("UTF8"));
- parseInputStream(stream, expandURLs);
- } catch (UnsupportedEncodingException e) {
- }
- }
-
- public void parseInputStream(InputStream is, boolean expandURLs)
- throws CoreException {
-
- documentBuilderFactory.setNamespaceAware(true);
-
- reset();
- try {
- DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder();
- InputSource source = new InputSource(is);
- Document doc = parser.parse(source);
- processDocument(doc, expandURLs);
- } catch (ParserConfigurationException e) {
- FormsPlugin.logException(e);
- } catch (SAXException e) {
- FormsPlugin.logException(e);
- } catch (IOException e) {
- FormsPlugin.logException(e);
- }
- }
-
- private void processDocument(Document doc, boolean expandURLs) {
- Node root = doc.getDocumentElement();
- NodeList children = root.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.TEXT_NODE) {
- // Make an implicit paragraph
- String text = child.getNodeValue();
- if (text != null && !isIgnorableWhiteSpace(text, true)) {
- Paragraph p = new Paragraph(true);
- p.parseRegularText(
- text,
- expandURLs,
- getHyperlinkSettings(),
- null);
- paragraphs.add(p);
- }
- } else if (child.getNodeType() == Node.ELEMENT_NODE) {
- String tag = child.getNodeName().toLowerCase();
- if (tag.equals("p")) {
- Paragraph p = processParagraph(child, expandURLs);
- if (p != null)
- paragraphs.add(p);
- } else if (tag.equals("li")) {
- Paragraph p = processListItem(child, expandURLs);
- if (p != null)
- paragraphs.add(p);
- }
- }
- }
- }
- private Paragraph processParagraph(Node paragraph, boolean expandURLs) {
- NodeList children = paragraph.getChildNodes();
- NamedNodeMap atts = paragraph.getAttributes();
- Node addSpaceAtt = atts.getNamedItem("addVerticalSpace");
- boolean addSpace = true;
-
- if (addSpaceAtt != null) {
- String value = addSpaceAtt.getNodeValue();
- addSpace = value.equalsIgnoreCase("true");
- }
- Paragraph p = new Paragraph(addSpace);
-
- processSegments(p, children, expandURLs);
- return p;
- }
- private Paragraph processListItem(Node listItem, boolean expandURLs) {
- NodeList children = listItem.getChildNodes();
- NamedNodeMap atts = listItem.getAttributes();
- Node addSpaceAtt = atts.getNamedItem("addVerticalSpace");
- Node styleAtt = atts.getNamedItem("style");
- Node valueAtt = atts.getNamedItem("value");
- Node indentAtt = atts.getNamedItem("indent");
- int style = BulletParagraph.CIRCLE;
- int indent = -1;
- String text = null;
- boolean addSpace = true;
-
- if (addSpaceAtt != null) {
- String value = addSpaceAtt.getNodeValue();
- addSpace = value.equalsIgnoreCase("true");
- }
- if (styleAtt != null) {
- String value = styleAtt.getNodeValue();
- if (value.equalsIgnoreCase("text")) {
- style = BulletParagraph.TEXT;
- } else if (value.equalsIgnoreCase("image")) {
- style = BulletParagraph.IMAGE;
- }
- }
- if (valueAtt != null) {
- text = valueAtt.getNodeValue();
- }
- if (indentAtt != null) {
- String value = indentAtt.getNodeValue();
- try {
- indent = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- }
- }
-
- BulletParagraph p = new BulletParagraph(addSpace);
- p.setIndent(indent);
- p.setBulletStyle(style);
- p.setBulletText(text);
-
- processSegments(p, children, expandURLs);
- return p;
- }
-
- private void processSegments(
- Paragraph p,
- NodeList children,
- boolean expandURLs) {
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- ParagraphSegment segment = null;
-
- if (child.getNodeType() == Node.TEXT_NODE) {
- String value = child.getNodeValue();
-
- if (value != null && !isIgnorableWhiteSpace(value, false)) {
- p.parseRegularText(
- value,
- expandURLs,
- getHyperlinkSettings(),
- null);
- }
- } else if (child.getNodeType() == Node.ELEMENT_NODE) {
- String name = child.getNodeName();
- if (name.equalsIgnoreCase("img")) {
- segment = processImageSegment(child);
- } else if (name.equalsIgnoreCase("a")) {
- segment =
- processHyperlinkSegment(child, getHyperlinkSettings());
- } else if (name.equalsIgnoreCase("text")) {
- processTextSegment(p, expandURLs, child);
- } else if (name.equalsIgnoreCase("b")) {
- String text = getNodeText(child).trim();
- String fontId = JFaceResources.BANNER_FONT;
- p.parseRegularText(
- text,
- expandURLs,
- getHyperlinkSettings(),
- fontId);
- }
- }
- if (segment != null) {
- p.addSegment(segment);
- }
- }
- }
-
- private boolean isIgnorableWhiteSpace(String text, boolean ignoreSpaces) {
- for (int i = 0; i < text.length(); i++) {
- char c = text.charAt(i);
- if (ignoreSpaces && c == ' ')
- continue;
- if (c == '\n' || c == '\r' || c == '\f')
- continue;
- return false;
- }
- return true;
- }
-
- private ParagraphSegment processImageSegment(Node image) {
- ImageSegment segment = new ImageSegment();
- NamedNodeMap atts = image.getAttributes();
- Node id = atts.getNamedItem("href");
- Node align = atts.getNamedItem("align");
- if (id != null) {
- String value = id.getNodeValue();
- segment.setObjectId(value);
- }
- if (align != null) {
- String value = align.getNodeValue().toLowerCase();
- if (value.equals("top"))
- segment.setVerticalAlignment(ImageSegment.TOP);
- else if (value.equals("middle"))
- segment.setVerticalAlignment(ImageSegment.MIDDLE);
- else if (value.equals("bottom"))
- segment.setVerticalAlignment(ImageSegment.BOTTOM);
- }
- return segment;
- }
-
- private String getNodeText(Node node) {
- NodeList children = node.getChildNodes();
- String text = "";
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.TEXT_NODE) {
- text += child.getNodeValue();
- }
- }
- return text;
- }
-
- private ParagraphSegment processHyperlinkSegment(
- Node link,
- HyperlinkSettings settings) {
- String text = getNodeText(link);
- HyperlinkSegment segment = new HyperlinkSegment(text, settings, null);
- NamedNodeMap atts = link.getAttributes();
- Node href = atts.getNamedItem("href");
- if (href != null) {
- String value = href.getNodeValue();
- segment.setHref(value);
- }
- return segment;
- }
-
- private void processTextSegment(
- Paragraph p,
- boolean expandURLs,
- Node textNode) {
- String text = getNodeText(textNode).trim();
-
- NamedNodeMap atts = textNode.getAttributes();
- Node font = atts.getNamedItem("font");
- String fontId = null;
- if (font != null) {
- fontId = font.getNodeValue();
- }
- p.parseRegularText(text, expandURLs, getHyperlinkSettings(), fontId);
- }
-
- public void parseRegularText(String regularText, boolean convertURLs)
- throws CoreException {
- reset();
-
- if (regularText==null) return;
-
- Paragraph p = new Paragraph(true);
- paragraphs.add(p);
- int pstart = 0;
-
- for (int i = 0; i < regularText.length(); i++) {
- char c = regularText.charAt(i);
- if (p == null) {
- p = new Paragraph(true);
- paragraphs.add(p);
- }
- if (c == '\n') {
- String text = regularText.substring(pstart, i);
- pstart = i + 1;
- p.parseRegularText(
- text,
- convertURLs,
- getHyperlinkSettings(),
- null);
- p = null;
- }
- }
- if (p != null) {
- // no new line
- String text = regularText.substring(pstart);
- p.parseRegularText(text, convertURLs, getHyperlinkSettings(), null);
- }
- }
-
- public HyperlinkSettings getHyperlinkSettings() {
- return hyperlinkSettings;
- }
-
- public void setHyperlinkSettings(HyperlinkSettings settings) {
- this.hyperlinkSettings = settings;
- }
-
- private void reset() {
- if (paragraphs == null)
- paragraphs = new Vector();
- paragraphs.clear();
- selectedLinkIndex = -1;
- hyperlinks = null;
- }
-
- HyperlinkSegment[] getHyperlinks() {
- if (hyperlinks != null || paragraphs == null)
- return hyperlinks;
- Vector result = new Vector();
- for (int i = 0; i < paragraphs.size(); i++) {
- Paragraph p = (Paragraph) paragraphs.get(i);
- ParagraphSegment[] segments = p.getSegments();
- for (int j = 0; j < segments.length; j++) {
- if (segments[j] instanceof HyperlinkSegment)
- result.add(segments[j]);
- }
- }
- hyperlinks =
- (HyperlinkSegment[]) result.toArray(
- new HyperlinkSegment[result.size()]);
- return hyperlinks;
- }
-
- public HyperlinkSegment findHyperlinkAt(int x, int y) {
- HyperlinkSegment[] links = getHyperlinks();
- for (int i = 0; i < links.length; i++) {
- if (links[i].contains(x, y))
- return links[i];
- }
- return null;
- }
- public TextSegment findSegmentAt(int x, int y) {
- for (int i = 0; i < paragraphs.size(); i++) {
- Paragraph p = (Paragraph) paragraphs.get(i);
- TextSegment segment = p.findSegmentAt(x, y);
- if (segment != null)
- return segment;
- }
- return null;
- }
-
- public HyperlinkSegment getSelectedLink() {
- if (selectedLinkIndex == -1)
- return null;
- return hyperlinks[selectedLinkIndex];
- }
-
- public boolean traverseLinks(boolean next) {
- HyperlinkSegment[] links = getHyperlinks();
- if (links == null)
- return false;
- int size = links.length;
- if (next) {
- selectedLinkIndex++;
- } else
- selectedLinkIndex--;
-
- if (selectedLinkIndex < 0 || selectedLinkIndex > size - 1) {
- selectedLinkIndex = -1;
- }
- return selectedLinkIndex != -1;
- }
-
- public void selectLink(HyperlinkSegment link) {
- if (link == null)
- selectedLinkIndex = -1;
- else {
- HyperlinkSegment[] links = getHyperlinks();
- selectedLinkIndex = -1;
- if (links == null)
- return;
- for (int i = 0; i < links.length; i++) {
- if (links[i].equals(link)) {
- selectedLinkIndex = i;
- break;
- }
- }
- }
- }
-
- public boolean hasFocusSegments() {
- HyperlinkSegment[] links = getHyperlinks();
- if (links.length > 0)
- return true;
- return false;
- }
-
- public void dispose() {
- paragraphs = null;
- selectedLinkIndex = -1;
- hyperlinks = null;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/TextSegment.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/TextSegment.java
deleted file mode 100644
index b3877b4..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/TextSegment.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-
-import java.text.BreakIterator;
-import java.util.*;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-
-/**
- * @version 1.0
- * @author
- */
-public class TextSegment extends ParagraphSegment {
- private Color color;
- private String fontId;
- private String text;
- protected boolean underline;
- private boolean wrapAllowed = true;
- protected Vector areaRectangles = new Vector();
-
- class AreaRectangle {
- Rectangle rect;
- int from, to;
- public AreaRectangle(Rectangle rect, int from, int to) {
- this.rect = rect;
- this.from = from;
- this.to = to;
- }
- public boolean contains(int x, int y) {
- return rect.contains(x, y);
- }
- public String getText() {
- if (from==0 && to== -1)
- return TextSegment.this.getText();
- if (from >0 && to == -1)
- return TextSegment.this.getText().substring(from);
- return TextSegment.this.getText().substring(from, to);
- }
- }
-
- public TextSegment(String text, String fontId) {
- this.text = cleanup(text);
- this.fontId = fontId;
- }
-
- private String cleanup(String text) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < text.length(); i++) {
- char c = text.charAt(i);
- if (c == '\n' || c == '\r' || c=='\f') {
- if (i > 0)
- buf.append(' ');
- } else
- buf.append(c);
- }
- return buf.toString();
- }
-
- public void setWordWrapAllowed(boolean value) {
- wrapAllowed = value;
- }
-
- public boolean isWordWrapAllowed() {
- return wrapAllowed;
- }
-
- public boolean isSelectable() {
- return false;
- }
-
- public Color getColor() {
- return color;
- }
-
- public Font getFont() {
- if (fontId == null)
- return JFaceResources.getDefaultFont();
- else
- return JFaceResources.getFontRegistry().get(fontId);
- }
-
- public String getText() {
- return text;
- }
-
- void setText(String text) {
- this.text = cleanup(text);
- }
-
- void setColor(Color color) {
- this.color = color;
- }
-
- void setFontId(String fontId) {
- this.fontId = fontId;
- }
-
- public boolean contains(int x, int y) {
- for (int i = 0; i < areaRectangles.size(); i++) {
- AreaRectangle ar = (AreaRectangle) areaRectangles.get(i);
- if (ar.contains(x, y))
- return true;
- }
- return false;
- }
-
- public Rectangle getBounds() {
- int x=0, y=0;
- int width = 0, height = 0;
-
- for (int i=0; i<areaRectangles.size(); i++) {
- AreaRectangle ar = (AreaRectangle)areaRectangles.get(i);
- if (i==0) {
- x = ar.rect.x;
- y = ar.rect.y;
- }
- else
- x = Math.min(ar.rect.x, x);
- width = Math.max(ar.rect.width, width);
- height += ar.rect.height;
- }
- return new Rectangle(x, y, width, height);
- }
-
- public void advanceLocator(
- GC gc,
- int wHint,
- Locator locator,
- Hashtable objectTable) {
- Font oldFont = null;
- if (fontId != null) {
- oldFont = gc.getFont();
- gc.setFont(getFont());
- }
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
-
- if (wHint == SWT.DEFAULT || !wrapAllowed) {
- Point extent = gc.textExtent(text);
-
- if (locator.x + extent.x > wHint) {
- // new line
- locator.x = isSelectable()?locator.indent+1:locator.indent;
- locator.y += locator.rowHeight;
- locator.rowHeight = 0;
- }
- int width = extent.x;
- if (isSelectable()) width+=2;
- locator.x += width;
- locator.width = width;
- locator.height = extent.y;
- locator.rowHeight = Math.max(locator.rowHeight, extent.y);
- return;
- }
-
- BreakIterator wb = BreakIterator.getLineInstance();
- wb.setText(text);
-
- int saved = 0;
- int last = 0;
-
- int width = 0;
-
- Point lastExtent = null;
-
- for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
- String word = text.substring(saved, loc);
- Point extent = gc.textExtent(word);
-
- if (locator.x + extent.x > wHint) {
- // overflow
- String savedWord = text.substring(saved, last);
- if (lastExtent==null)
- lastExtent = gc.textExtent(savedWord);
- int lineWidth = locator.x + lastExtent.x;
- if (isSelectable()) lineWidth+=2;
-
- saved = last;
- locator.rowHeight = Math.max(locator.rowHeight, lastExtent.y);
- locator.x = isSelectable()?locator.indent+1:locator.indent;
- locator.y += locator.rowHeight;
- locator.rowHeight = 0;
- width = Math.max(width, lineWidth);
- }
- last = loc;
- lastExtent = extent;
- }
- String lastString = text.substring(saved, last);
- Point extent = gc.textExtent(lastString);
- int lineWidth = extent.x;
- if (isSelectable()) lineWidth += 2;
- locator.x += lineWidth;
- locator.width = width;
- locator.height = lineHeight;
- locator.rowHeight = Math.max(locator.rowHeight, extent.y);
- if (oldFont != null) {
- gc.setFont(oldFont);
- }
- }
-
- public void paint(
- GC gc,
- int width,
- Locator locator,
- Hashtable objectTable,
- boolean selected) {
- Font oldFont = null;
- Color oldColor = null;
-
- areaRectangles.clear();
-
- if (fontId != null) {
- oldFont = gc.getFont();
- gc.setFont(getFont());
- }
- if (color != null) {
- oldColor = gc.getForeground();
- gc.setForeground(color);
- }
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
- int descent = fm.getDescent();
-
- if (!wrapAllowed) {
- Point extent = gc.textExtent(text);
- int ewidth = extent.x;
- if (isSelectable()) ewidth += 2;
-
- if (locator.x + ewidth > width) {
- // new line
- locator.resetCaret();
- if (isSelectable()) locator.x += 1;
- locator.y += locator.rowHeight;
- locator.rowHeight = 0;
- }
- gc.drawString(text, locator.x, locator.y);
- if (underline) {
- int lineY = locator.y + lineHeight - descent + 1;
- gc.drawLine(locator.x, lineY, locator.x + extent.x, lineY);
- }
- Rectangle br =
- new Rectangle(locator.x - 1, locator.y, extent.x + 2, lineHeight - descent + 3);
- areaRectangles.add(new AreaRectangle(br, 0, -1));
- if (selected) {
- if (color != null)
- gc.setForeground(oldColor);
- gc.drawFocus(br.x, br.y, br.width, br.height);
- }
-
- locator.x += ewidth;
- locator.width = ewidth;
- locator.height = lineHeight;
- locator.rowHeight = Math.max(locator.rowHeight, extent.y);
- if (oldFont != null) {
- gc.setFont(oldFont);
- }
- if (oldColor != null) {
- gc.setForeground(oldColor);
- }
- return;
- }
-
- BreakIterator wb = BreakIterator.getLineInstance();
- wb.setText(text);
-
- int saved = 0;
- int last = 0;
-
- for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
- if (loc == 0)
- continue;
- String word = text.substring(saved, loc);
- Point extent = gc.textExtent(word);
- int ewidth = extent.x;
- if (isSelectable()) ewidth += 2;
-
- if (locator.x + ewidth > width) {
- // overflow
- String prevLine = text.substring(saved, last);
- gc.drawString(prevLine, locator.x, locator.y, true);
- Point prevExtent = gc.textExtent(prevLine);
- int prevWidth = prevExtent.x;
- if (isSelectable()) prevWidth += 2;
-
- if (underline) {
- int lineY = locator.y + lineHeight - descent + 1;
- gc.drawLine(locator.x, lineY, locator.x + prevWidth, lineY);
- }
- Rectangle br =
- new Rectangle(
- locator.x - 1,
- locator.y,
- prevExtent.x + 2,
- lineHeight - descent + 3);
- if (selected) {
- if (color != null)
- gc.setForeground(oldColor);
- gc.drawFocus(br.x, br.y, br.width, br.height);
- if (color != null)
- gc.setForeground(color);
- }
- areaRectangles.add(new AreaRectangle(br, saved, last));
-
- locator.rowHeight = Math.max(locator.rowHeight, prevExtent.y);
- locator.resetCaret();
- if (isSelectable()) locator.x +=1;
- locator.y += locator.rowHeight;
- locator.rowHeight = 0;
- saved = last;
- }
- last = loc;
- }
- // paint the last line
- String lastLine = text.substring(saved, last);
- gc.drawString(lastLine, locator.x, locator.y, true);
- Point lastExtent = gc.textExtent(lastLine);
- int lastWidth = lastExtent.x;
- if (isSelectable()) lastWidth += 2;
- Rectangle br =
- new Rectangle(
- locator.x - 1,
- locator.y,
- lastExtent.x + 2,
- lineHeight - descent + 3);
- areaRectangles.add(new AreaRectangle(br, saved, last));
- if (underline) {
- int lineY = locator.y + lineHeight - descent + 1;
- gc.drawLine(locator.x, lineY, locator.x + lastExtent.x, lineY);
- }
- if (selected) {
- if (color != null)
- gc.setForeground(oldColor);
- gc.drawFocus(br.x, br.y, br.width, br.height);
- }
- locator.x += lastWidth;
- locator.rowHeight = Math.max(locator.rowHeight, lastExtent.y);
- if (oldFont != null) {
- gc.setFont(oldFont);
- }
- if (oldColor != null) {
- gc.setForeground(oldColor);
- }
- }
-
- public void paintFocus(GC gc, Color bg, Color fg, boolean selected) {
- if (areaRectangles==null) return;
- for (int i=0; i<areaRectangles.size(); i++) {
- AreaRectangle areaRectangle = (AreaRectangle)areaRectangles.get(i);
- Rectangle br = areaRectangle.rect;
- if (selected) {
- gc.setBackground(bg);
- gc.setForeground(fg);
- gc.drawFocus(br.x, br.y, br.width, br.height);
- }
- else {
- gc.setForeground(bg);
- gc.drawRectangle(br.x, br.y, br.width-1, br.height-1);
- }
- }
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WidgetTest.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WidgetTest.java
deleted file mode 100644
index 986e180..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WidgetTest.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.internal.widgets;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.*;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.widgets.*;
-
-public class WidgetTest {
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- FormColors colors = new FormColors(display);
- colors.markShared();
- FormToolkit toolkit = new FormToolkit(colors);
- toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(
- HyperlinkSettings.UNDERLINE_ROLLOVER);
- CTabFolder folder = new CTabFolder(shell, SWT.NULL);
- CTabItem t1 = new CTabItem(folder, SWT.NULL);
- Form f1 = createForm1(folder, toolkit);
- t1.setControl(f1);
- t1.setText(f1.getText());
-
- CTabItem t2 = new CTabItem(folder, SWT.NULL);
- Form f2 = createForm2(folder, toolkit);
- t2.setControl(f2);
- t2.setText(f2.getText());
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- colors.dispose();
- }
-
- private static Form createForm1(Composite parent, FormToolkit toolkit) {
- Form form = toolkit.createForm(parent);
- form.setText("Wrapped Form");
- URL bdURL = WidgetTest.class.getResource("form_banner.gif");
- ImageDescriptor bd = ImageDescriptor.createFromURL(bdURL);
- form.setBackgroundImage(bd.createImage());
- TableWrapLayout layout = new TableWrapLayout();
- layout.leftMargin = 10;
- layout.rightMargin = 10;
- //layout.numColumns = 2;
- //layout.makeColumnsEqualWidth = true;
- form.getBody().setLayout(layout);
-
- TableWrapData td;
- Hyperlink link =
- toolkit.createHyperlink(
- form.getBody(),
- "Sample hyperlink with longer text.",
- SWT.WRAP);
- link.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- }
- }
- });
- td = new TableWrapData();
- //td.colspan = 2;
- td.align = TableWrapData.LEFT;
- link.setLayoutData(td);
-
- ImageHyperlink ilink =
- new ImageHyperlink(form.getBody(), SWT.WRAP);
- ilink.setText("Sample hyperlink with an image and text.");
- ilink.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- }
- }
- });
- URL iURL = WidgetTest.class.getResource("test.gif");
- ImageDescriptor id = ImageDescriptor.createFromURL(iURL);
- ilink.setImage(id.createImage());
- toolkit.adapt(ilink, true, true);
- toolkit.getHyperlinkGroup().add(ilink);
- td = new TableWrapData();
- //td.colspan = 2;
- td.align = TableWrapData.LEFT;
- ilink.setLayoutData(td);
-
- ImageHyperlink ilink2 =
- new ImageHyperlink(form.getBody(), SWT.WRAP);
- ilink2.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- }
- }
- });
- URL i2URL = WidgetTest.class.getResource("migrate_30_wiz.gif");
- ImageDescriptor i2d = ImageDescriptor.createFromURL(i2URL);
- URL i2hURL = WidgetTest.class.getResource("image1.gif");
- ImageDescriptor i2hd = ImageDescriptor.createFromURL(i2hURL);
- ilink2.setImage(i2d.createImage());
- ilink2.setHoverImage(i2hd.createImage());
- ilink2.setToolTipText("Image only hyperlink");
- toolkit.adapt(ilink2, true, true);
- toolkit.getHyperlinkGroup().add(ilink2);
- td = new TableWrapData();
- //td.colspan = 2;
- td.align = TableWrapData.LEFT;
- ilink2.setLayoutData(td);
- createExpandable(form, toolkit);
- createRichTextSection(form, toolkit);
- return form;
- }
-
- private static Form createForm2(Composite parent, FormToolkit toolkit) {
- Form form = toolkit.createForm(parent);
- form.setText("Jelly Form");
- URL bdURL = WidgetTest.class.getResource("form_banner.gif");
- ImageDescriptor bd = ImageDescriptor.createFromURL(bdURL);
- form.setBackgroundImage(bd.createImage());
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- form.getBody().setLayout(layout);
- createTableSection(form, toolkit, "Extensions");
- createTableSection(form, toolkit, "Extension Points");
- return form;
- }
-
- private static void createExpandable(
- final Form form,
- final FormToolkit toolkit) {
- ExpandableComposite exp =
- toolkit
- .createExpandableComposite(
- form.getBody(),
- ExpandableComposite.TREE_NODE
- // ExpandableComposite.NONE
- );
- exp.setActiveToggleColor(
- toolkit.getHyperlinkGroup().getActiveForeground());
- exp.setToggleColor(toolkit.getColors().getColor(FormColors.SEPARATOR));
- Composite client = toolkit.createComposite(exp);
- exp.setClient(client);
- TableWrapLayout elayout = new TableWrapLayout();
- client.setLayout(elayout);
- elayout.leftMargin = elayout.rightMargin = 0;
- final Button button = toolkit.createButton(client, "Button", SWT.PUSH);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- openFormWizard(button.getShell(), toolkit.getColors());
- }
- });
- exp.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- form.reflow(false);
- }
- });
- exp.setText("Expandable Section with a longer title");
- TableWrapData td = new TableWrapData();
- //td.colspan = 2;
- td.align = TableWrapData.LEFT;
- //td.align = TableWrapData.FILL;
- exp.setLayoutData(td);
- }
-
- static class SampleFormWizard extends FormWizard {
- public SampleFormWizard(FormColors colors) {
- super(colors);
- setNeedsProgressMonitor(true);
- URL banner = WidgetTest.class.getResource("migrate_30_wiz.gif");
- ImageDescriptor bd = ImageDescriptor.createFromURL(banner);
- setDefaultPageImageDescriptor(bd);
- setForcePreviousAndNextButtons(true);
- }
-
- public void addPages() {
- addPage(new SampleFormWizardPage(toolkit));
- }
- public boolean performFinish() {
- try {
- getContainer().run(false, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException {
- monitor.beginTask("Processing...", 100);
- for (int i=0; i<100; i++) {
- Thread.sleep(100);
- monitor.worked(1);
- }
- monitor.done();
- }
- });
- }
- catch (InterruptedException e) {
- return false;
- }
- catch (InvocationTargetException e) {
- return false;
- }
- return true;
- }
-
- }
-
- static class SampleFormWizardPage extends FormWizardPage {
- public SampleFormWizardPage(FormToolkit toolkit) {
- super("formPage", toolkit);
- setTitle("Sample Form Page");
- setDescription("This is a sample of a form in the wizard");
- }
- protected void createFormContents(Composite parent) {
- TableWrapLayout layout = new TableWrapLayout();
- layout.leftMargin = 10;
- //layout.rightMargin = 10;
- //layout.bottomMargin = 0;
- //layout.topMargin = 0;
- parent.setLayout(layout);
- Section sec = toolkit.createSection(parent, Section.TWISTIE);
- sec.setSeparatorControl(toolkit.createCompositeSeparator(sec));
- sec.setText("A section inside a wizard page");
- sec.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- managedForm.getForm().reflow(false);
- }
- });
- Composite group = toolkit.createComposite(sec);
- sec.setClient(group);
- GridLayout glayout = new GridLayout();
- group.setLayout(glayout);
- glayout.numColumns = 2;
- toolkit.createLabel(group, "Some text:");
- Text text = toolkit.createText(group, "");
- GridData gd = new GridData();
- gd.widthHint = 150;
- text.setLayoutData(gd);
- Button b;
- gd = new GridData();
- b = toolkit.createButton(group, "An option to select", SWT.CHECK);
- gd = new GridData();
- gd.horizontalSpan = 2;
- b.setLayoutData(gd);
- b = toolkit.createButton(group, "Choice 1", SWT.RADIO);
- gd = new GridData();
- gd.horizontalSpan = 2;
- b.setLayoutData(gd);
- b = toolkit.createButton(group, "Choice 2", SWT.RADIO);
- gd = new GridData();
- gd.horizontalSpan = 2;
- b.setLayoutData(gd);
- TableWrapData td = new TableWrapData();
- sec.setLayoutData(td);
- //createExpandable(form, toolkit);
- RichText rtext = toolkit.createRichText(parent, false);
- loadRichText(rtext, toolkit);
- td = new TableWrapData();
- td.align = TableWrapData.FILL;
- td.grabHorizontal = true;
- toolkit.paintBordersFor(group);
- rtext.setLayoutData(td);
- }
- }
- private static void openFormWizard(Shell shell, FormColors colors) {
- FormWizard wizard = new SampleFormWizard(colors);
- FormWizardDialog wd = new FormWizardDialog(shell, wizard, colors);
- wd.create();
- wd.getShell().setText("Sample Form Wizard");
- wd.getShell().setSize(600, 500);
- wd.open();
- }
-
- private static void createRichTextSection(final Form form, FormToolkit toolkit) {
- Section section =
- toolkit.createSection(
- form.getBody(),
- Section.TWISTIE | Section.DESCRIPTION);
- section.setActiveToggleColor(
- toolkit.getHyperlinkGroup().getActiveForeground());
- section.setToggleColor(
- toolkit.getColors().getColor(FormColors.SEPARATOR));
- toolkit.createCompositeSeparator(section);
- RichText rtext = toolkit.createRichText(section, false);
- section.setClient(rtext);
- loadRichText(rtext, toolkit);
- section.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- form.reflow(false);
- }
- });
- section.setText("Section title");
- section.setDescription(
- "This is a section description that should be rendered below the separator.");
- TableWrapData td = new TableWrapData();
- td.align = TableWrapData.FILL;
- td.grabHorizontal = true;
- section.setLayoutData(td);
- }
-
- private static void createStaticSection(final Form form, FormToolkit toolkit) {
- Section section =
- toolkit.createSection(
- form.getBody(),
- Section.TWISTIE | Section.DESCRIPTION);
- section.setActiveToggleColor(
- toolkit.getHyperlinkGroup().getActiveForeground());
- section.setToggleColor(
- toolkit.getColors().getColor(FormColors.SEPARATOR));
- toolkit.createCompositeSeparator(section);
- Composite client = toolkit.createComposite(section, SWT.WRAP);
- GridLayout layout = new GridLayout();
- client.setLayout(layout);
- toolkit.createButton(client, "Radio 1", SWT.RADIO);
- toolkit.createButton(client, "Radio 2", SWT.RADIO);
- toolkit.createButton(client, "Radio 3", SWT.RADIO);
- toolkit.createButton(
- client,
- "Checkbox with somewhat longer text",
- SWT.CHECK);
- section.setText("Static Section");
- section.setDescription("This section contains a list of links.");
- section.setClient(client);
- section.setExpanded(true);
- section.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- form.reflow(false);
- }
- });
- TableWrapData td = new TableWrapData();
- td.align = TableWrapData.FILL;
- //td.grabHorizontal = true;
- section.setLayoutData(td);
- }
-
- private static void createTableSection(final Form form, FormToolkit toolkit, String title) {
- Section section =
- toolkit.createSection(
- form.getBody(),
- Section.TWISTIE | Section.DESCRIPTION);
- section.setActiveToggleColor(
- toolkit.getHyperlinkGroup().getActiveForeground());
- section.setToggleColor(
- toolkit.getColors().getColor(FormColors.SEPARATOR));
- toolkit.createCompositeSeparator(section);
- Composite client = toolkit.createComposite(section, SWT.WRAP);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
-
- client.setLayout(layout);
- Table t = toolkit.createTable(client, SWT.NULL);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 200;
- gd.widthHint = 100;
- t.setLayoutData(gd);
- toolkit.paintBordersFor(client);
- Button b = toolkit.createButton(client, "Add...", SWT.PUSH);
- gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- b.setLayoutData(gd);
- section.setText(title);
- section.setDescription("This section a tree and a button.");
- section.setClient(client);
- section.setExpanded(true);
- section.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- form.reflow(false);
- }
- });
- gd = new GridData(GridData.FILL_BOTH);
- //td.valign = TableWrapData.FILL;
- //td.grabHorizontal = true;
- section.setLayoutData(gd);
- }
-
- private static void loadRichText(RichText rtext, FormToolkit toolkit) {
- rtext.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- System.out.println("Link activated: href=" + e.getHref());
- }
- });
- rtext.setHyperlinkSettings(toolkit.getHyperlinkGroup());
- URL i1URL = WidgetTest.class.getResource("image1.gif");
- ImageDescriptor id1 = ImageDescriptor.createFromURL(i1URL);
- rtext.setImage("image1", id1.createImage());
- InputStream is = WidgetTest.class.getResourceAsStream("index.xml");
- rtext.setContents(is, true);
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WrappedPageBook.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WrappedPageBook.java
deleted file mode 100644
index 28be4d5..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/WrappedPageBook.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Created on Feb 13, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms.internal.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.widgets.ILayoutExtension;
-;
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-/**
- * A pagebook is a composite control where only a single control is visible at
- * a time. It is similar to a notebook, but without tabs.
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @see PageBookView
- */
-public class WrappedPageBook extends Composite {
- class PageBookLayout extends Layout implements ILayoutExtension {
- protected Point computeSize(Composite composite, int wHint, int hHint,
- boolean flushCache) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
- Point result = null;
- if (currentPage != null) {
- result = currentPage.computeSize(wHint, hHint, flushCache);
- } else {
- result = new Point(0, 0);
- }
- return result;
- }
- protected void layout(Composite composite, boolean flushCache) {
- if (currentPage != null) {
- currentPage.setBounds(composite.getClientArea());
- }
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.widgets.ILayoutExtension#computeMaximumWidth(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- public int computeMaximumWidth(Composite parent, boolean changed) {
- return computeSize(parent, SWT.DEFAULT, SWT.DEFAULT, changed).x;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.widgets.ILayoutExtension#computeMinimumWidth(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- public int computeMinimumWidth(Composite parent, boolean changed) {
- return computeSize(parent, 0, SWT.DEFAULT, changed).x;
- }
- }
- /**
- * The current control; <code>null</code> if none.
- */
- private Control currentPage = null;
- /**
- * Creates a new empty pagebook.
- *
- * @param parent
- * the parent composite
- * @param style
- * the SWT style bits
- */
- public WrappedPageBook(Composite parent, int style) {
- super(parent, style);
- setLayout(new PageBookLayout());
- }
- /**
- * Shows the given page. This method has no effect if the given page is not
- * contained in this pagebook.
- *
- * @param page
- * the page to show
- */
- public void showPage(Control page) {
- if (page == currentPage)
- return;
- if (page.getParent() != this)
- return;
- Control oldPage = currentPage;
- currentPage = page;
- // show new page
- if (page != null) {
- if (!page.isDisposed()) {
- //page.setVisible(true);
- layout(true);
- page.setVisible(true);
- }
- }
- // hide old *after* new page has been made visible in order to avoid
- // flashing
- if (oldPage != null && !oldPage.isDisposed())
- oldPage.setVisible(false);
- }
- public Point computeSize(int wHint, int hHint, boolean changed) {
- return ((PageBookLayout) getLayout()).computeSize(this, wHint, hHint,
- changed);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/form_banner.gif b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/form_banner.gif
deleted file mode 100644
index aebc0b2..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/form_banner.gif
+++ /dev/null
Binary files differ
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/image1.gif b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/image1.gif
deleted file mode 100644
index c5c94ee..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/image1.gif
+++ /dev/null
Binary files differ
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/index.xml b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/index.xml
deleted file mode 100644
index eaf0aa6..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/index.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form>
-<p>
-To check for updates for features you have installed,
-go to the <a href="action1">My Eclipse 1</a> and select
-<b>Available Updates</b> folder. <b>Search page</b> will
-be shown allowing you to initiate and customize the search.
-Now we <b>will</b> add an
-<img href="image1"/>
-image here. Just
- to show how wrapping should apply to images when they are
- larger than the regular text.
-</p>
-<li style="text" value="1.">To check for updates for features you have installed,
-go to the <a href="action2">My Eclipse 2</a> and select
-<b>Available Updates</b> folder. <b>Search page</b> will
-be shown allowing you to initiate and customize the search.</li>
-<li style="text" value="2.">This is the item number 2.</li>
-<li style="text" value="3.">This is the item number 3.</li>
-<li>This is the bullet item.</li>
-<li>This is another bullet item.</li>
-</form>
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/migrate_30_wiz.gif b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/migrate_30_wiz.gif
deleted file mode 100644
index 7ce1184..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/migrate_30_wiz.gif
+++ /dev/null
Binary files differ
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/test.gif b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/test.gif
deleted file mode 100644
index 2e472d4..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/internal/widgets/test.gif
+++ /dev/null
Binary files differ
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/AbstractHyperlink.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/AbstractHyperlink.java
deleted file mode 100644
index 8f2637c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/AbstractHyperlink.java
+++ /dev/null
@@ -1,257 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import java.util.Vector;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.internal.widgets.FormsResources;
-/**
- * This is the base class for custom hyperlink widget. It is responsible for
- * processing mouse and keyboard events, and converting them into unified
- * hyperlink events. Subclasses are responsible for rendering the hyperlink in
- * the client area.
- *
- * @since 3.0
- */
-public abstract class AbstractHyperlink extends Canvas {
- private boolean hasFocus;
- private Vector listeners;
- /**
- * Amount of the margin width around the hyperlink (default is 1).
- */
- protected int marginWidth = 1;
- /**
- * Amount of the margin height around the hyperlink (default is 1).
- */
- protected int marginHeight = 1;
- /**
- * Creates a new hyperlink in the provided parent.
- *
- * @param parent
- * the control parent
- * @param style
- * the widget style
- */
- public AbstractHyperlink(Composite parent, int style) {
- super(parent, style);
- addListener(SWT.KeyDown, new Listener() {
- public void handleEvent(Event e) {
- if (e.character == '\r') {
- handleActivate();
- }
- }
- });
- addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- paint(e);
- }
- });
- addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event e) {
- switch (e.detail) {
- case SWT.TRAVERSE_PAGE_NEXT :
- case SWT.TRAVERSE_PAGE_PREVIOUS :
- case SWT.TRAVERSE_ARROW_NEXT :
- case SWT.TRAVERSE_ARROW_PREVIOUS :
- case SWT.TRAVERSE_RETURN :
- e.doit = false;
- return;
- }
- e.doit = true;
- }
- });
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.FocusIn :
- hasFocus = true;
- handleEnter();
- break;
- case SWT.FocusOut :
- hasFocus = false;
- handleExit();
- break;
- case SWT.DefaultSelection :
- handleActivate();
- break;
- case SWT.MouseEnter :
- handleEnter();
- break;
- case SWT.MouseExit :
- handleExit();
- break;
- case SWT.MouseUp :
- handleMouseUp(e);
- break;
- }
- }
- };
- addListener(SWT.MouseEnter, listener);
- addListener(SWT.MouseExit, listener);
- addListener(SWT.MouseUp, listener);
- addListener(SWT.FocusIn, listener);
- addListener(SWT.FocusOut, listener);
- setCursor(FormsResources.getHandCursor());
- }
- /**
- * Adds the event listener to this hyperlink.
- *
- * @param listener
- * the event listener to add
- */
- public void addHyperlinkListener(HyperlinkListener listener) {
- if (listeners == null)
- listeners = new Vector();
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
- /**
- * Removes the event listener from this hyperlink.
- *
- * @param listener
- * the event listener to remove
- */
- public void removeHyperlinkListener(HyperlinkListener listener) {
- if (listeners == null)
- return;
- listeners.remove(listener);
- }
- /**
- * Returns the selection state of the control. When focus is gained, the
- * state will be <samp>true </samp>; it will switch to <samp>false </samp>
- * when the control looses focus.
- *
- * @return <code>true</code> if the widget has focus, <code>false</code>
- * otherwise.
- */
- public boolean getSelection() {
- return hasFocus;
- }
- /**
- * Called when hyperlink is entered. Subclasses that override this method
- * must call 'super'.
- */
- protected void handleEnter() {
- redraw();
- if (listeners == null)
- return;
- int size = listeners.size();
- HyperlinkEvent e = new HyperlinkEvent(this, getHref(), getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkEntered(e);
- }
- }
- /**
- * Called when hyperlink is exited. Subclasses that override this method
- * must call 'super'.
- */
- protected void handleExit() {
- redraw();
- if (listeners == null)
- return;
- int size = listeners.size();
- HyperlinkEvent e = new HyperlinkEvent(this, getHref(), getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkExited(e);
- }
- }
- /**
- * Called when hyperlink has been activated. Subclasses that override this
- * method must call 'super'.
- */
- protected void handleActivate() {
- if (listeners == null)
- return;
- int size = listeners.size();
- setCursor(FormsResources.getBusyCursor());
- HyperlinkEvent e = new HyperlinkEvent(this, getHref(), getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkActivated(e);
- }
- if (!isDisposed())
- setCursor(FormsResources.getHandCursor());
- }
- /**
- * Sets the object associated with this hyperlink. Concrete implementation
- * of this class can use if to store text, URLs or model objects that need
- * to be processed on hyperlink events.
- *
- * @param href
- * the hyperlink object reference
- */
- public void setHref(Object href) {
- setData("href", href);
- }
- /**
- * Returns the object associated with this hyperlink.
- *
- * @see #setHref
- * @return the hyperlink object reference
- */
- public Object getHref() {
- return getData("href");
- }
- /**
- * Returns the textual representation of this hyperlink suitable for
- * showing in tool tips or on the status line.
- *
- * @return the hyperlink text
- */
- public String getText() {
- return getToolTipText();
- }
- /**
- * Paints the hyperlink as a reaction to the provided paint event.
- *
- * @param e
- * the paint event
- */
- protected abstract void paintHyperlink(PaintEvent e);
- /**
- * Paints the control as a reaction to the provided paint event.
- *
- * @param e
- * the paint event
- */
- protected void paint(PaintEvent e) {
- paintHyperlink(e);
- if (hasFocus) {
- GC gc = e.gc;
- Rectangle carea = getClientArea();
- gc.setForeground(getForeground());
- gc.drawFocus(0, 0, carea.width, carea.height);
- }
- }
- private void handleMouseUp(Event e) {
- if (e.button != 1)
- return;
- Point size = getSize();
- // Filter out mouse up events outside
- // the link. This can happen when mouse is
- // clicked, dragged outside the link, then
- // released.
- if (e.x < 0)
- return;
- if (e.y < 0)
- return;
- if (e.x >= size.x)
- return;
- if (e.y >= size.y)
- return;
- handleActivate();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayout.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayout.java
deleted file mode 100644
index fec0fd0..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayout.java
+++ /dev/null
@@ -1,237 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-/**
- * This layout manager arranges children of the composite parent in vertical
- * columns. All the columns are identical size and children are stretched
- * horizontally to fill the column width. The goal is to give layout some
- * reasonable range of column numbers to allow it to handle various parent
- * widths. That way, column number will drop to the lowest number in the range
- * when width decreases, and grow up to the highest number in the range when
- * allowed by the parent width.
- * <p>
- * In addition, the layout attempts to 'fill the space' equally i.e. to avoid
- * large gaps at the and of the last column.
- * <p>
- * Child controls are layed out according to their 'natural' (preferred) size.
- * For 'stretchy' controls that do not have natural preferred size, it is
- * possible to set width and/or height hints using ColumnLayoutData objects.
- *
- * @see ColumnLayoutData
- * @since 3.0
- */
-public class ColumnLayout extends Layout implements ILayoutExtension {
- /**
- * Minimum number of columns (default is 1).
- */
- public int minNumColumns = 1;
- /**
- * Maximum number of columns (default is 3).
- */
- public int maxNumColumns = 3;
- /**
- * Horizontal spacing between columns (default is 5).
- */
- public int horizontalSpacing = 5;
- /**
- * Vertical spacing between controls (default is 5).
- */
- public int verticalSpacing = 5;
- /**
- * Top margin (default is 5).
- */
- public int topMargin = 5;
- /**
- * Left margin (default is 5).
- */
- public int leftMargin = 5;
- /**
- * Bottom margin (default is 5).
- */
- public int bottomMargin = 5;
- /**
- * Right margin (default is 5).
- */
- public int rightMargin = 5;
- /**
- * Creates a new instance of the column layout.
- */
- public ColumnLayout() {
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite,
- * int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint,
- boolean flushCache) {
- if (wHint == 0)
- return computeSize(composite, wHint, hHint, minNumColumns);
- else if (wHint == SWT.DEFAULT)
- return computeSize(composite, wHint, hHint, maxNumColumns);
- else
- return computeSize(composite, wHint, hHint, -1);
- }
- private Point computeSize(Composite parent, int wHint, int hHint,
- int ncolumns) {
- Control[] children = parent.getChildren();
- int cwidth = 0;
- int cheight = 0;
- Point[] sizes = new Point[children.length];
- for (int i = 0; i < children.length; i++) {
- sizes[i] = computeControlSize(children[i]);
- cwidth = Math.max(cwidth, sizes[i].x);
- cheight += sizes[i].y;
- }
- if (ncolumns == -1) {
- // must compute
- ncolumns = (wHint - leftMargin - rightMargin - horizontalSpacing)
- / (cwidth + horizontalSpacing);
- ncolumns = Math.max(ncolumns, minNumColumns);
- ncolumns = Math.min(ncolumns, maxNumColumns);
- }
- int perColHeight = cheight / ncolumns;
- if (cheight % ncolumns != 0)
- perColHeight++;
- int colHeight = 0;
- int[] heights = new int[ncolumns];
- int ncol = 0;
- for (int i = 0; i < sizes.length; i++) {
- int childHeight = sizes[i].y;
- if (colHeight + childHeight > perColHeight) {
- ncol++;
- if (ncol == ncolumns) {
- // overflow - start filling in
- ncol = findShortestColumn(heights);
- colHeight = heights[ncol];
- } else
- colHeight = 0;
- }
- colHeight += childHeight;
- if (heights[ncol] > 0)
- heights[ncol] += verticalSpacing;
- heights[ncol] += childHeight;
- }
- Point size = new Point(0, 0);
- for (int i = 0; i < ncolumns; i++) {
- size.y = Math.max(size.y, heights[i]);
- }
- size.x = cwidth * ncolumns + (ncolumns - 1) * horizontalSpacing;
- size.x += leftMargin + rightMargin;
- System.out.println("ColumnLayout: whint="+wHint+", size.x="+size.x);
- size.y += topMargin + bottomMargin;
- return size;
- }
- private Point computeControlSize(Control c) {
- ColumnLayoutData cd = (ColumnLayoutData) c.getLayoutData();
- int widthHint = cd != null ? cd.widthHint : SWT.DEFAULT;
- int heightHint = cd != null ? cd.heightHint : SWT.DEFAULT;
- return c.computeSize(widthHint, heightHint);
- }
- private int findShortestColumn(int[] heights) {
- int result = 0;
- int height = Integer.MAX_VALUE;
- for (int i = 0; i < heights.length; i++) {
- if (height > heights[i]) {
- height = heights[i];
- result = i;
- }
- }
- return result;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- protected void layout(Composite parent, boolean flushCache) {
- Control[] children = parent.getChildren();
- Rectangle carea = parent.getClientArea();
- int cwidth = 0;
- int cheight = 0;
- Point[] sizes = new Point[children.length];
- for (int i = 0; i < children.length; i++) {
- sizes[i] = computeControlSize(children[i]);
- cwidth = Math.max(cwidth, sizes[i].x);
- cheight += sizes[i].y;
- }
- int ncolumns = (carea.width - leftMargin - rightMargin - horizontalSpacing)
- / (cwidth + horizontalSpacing);
- ncolumns = Math.max(ncolumns, minNumColumns);
- ncolumns = Math.min(ncolumns, maxNumColumns);
- int realWidth = (carea.width - leftMargin - rightMargin + horizontalSpacing)
- / ncolumns - horizontalSpacing;
- int childrenPerColumn = children.length / ncolumns;
- if (children.length % ncolumns != 0)
- childrenPerColumn++;
- int colWidth = 0;
- int colHeight = 0;
- int ncol = 0;
- int x = leftMargin, y = topMargin;
- int ccolCount = 0;
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
- Point csize = sizes[i];
- ccolCount++;
- ColumnLayoutData cd = (ColumnLayoutData)child.getLayoutData();
- int align = cd!=null?cd.horizontalAlignment:ColumnLayoutData.FILL;
- int fillWidth = Math.max(cwidth, realWidth);
- int childWidth = align==ColumnLayoutData.FILL?fillWidth:csize.x;
- if (y + csize.y + bottomMargin > carea.height
- || ccolCount > childrenPerColumn) {
- // wrap
- x += horizontalSpacing + fillWidth;
- y = topMargin;
- ncol++;
- ccolCount = 1;
- }
- if (ncol == ncolumns - 1 && align==ColumnLayoutData.FILL) {
- childWidth = carea.width - x - rightMargin;
- }
- switch (align) {
- case ColumnLayoutData.LEFT:
- case ColumnLayoutData.FILL:
- child.setBounds(x, y, childWidth, csize.y);
- break;
- case ColumnLayoutData.RIGHT:
- child.setBounds(x+fillWidth-childWidth, y, childWidth, csize.y);
- break;
- case ColumnLayoutData.CENTER:
- child.setBounds(x+fillWidth/2-childWidth/2, y, childWidth, csize.y);
- break;
- }
- y += csize.y + verticalSpacing;
- }
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.widgets.ILayoutExtension#computeMaximumWidth(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- public int computeMaximumWidth(Composite parent, boolean changed) {
- return computeSize(parent, SWT.DEFAULT, SWT.DEFAULT, changed).x;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.widgets.ILayoutExtension#computeMinimumWidth(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- public int computeMinimumWidth(Composite parent, boolean changed) {
- return computeSize(parent, 0, SWT.DEFAULT, changed).x;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayoutData.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayoutData.java
deleted file mode 100644
index 3e44087..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ColumnLayoutData.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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-/**
- * This class is used to store layout data for the
- * <code>ColumnLayout</code> class.
- *
- * @see ColumnLayout
- * @since 3.0
- */
-public class ColumnLayoutData {
- /**
- * Width hint that will be used instead of the computed control width when
- * used in conjunction with <code>ColumnLayout</code> class (default is SWT.DEFAULT).
- */
- public int widthHint = SWT.DEFAULT;
- /**
- * Height hint that will be used instead of the computed control height
- * when used in conjunction with <code>ColumnLayout</code> class (default is
- * SWT.DEFAULT).
- */
- public int heightHint = SWT.DEFAULT;
- public static final int LEFT = 1;
- public static final int CENTER = 2;
- public static final int RIGHT = 3;
- public static final int FILL = 4;
-
- public int horizontalAlignment = FILL;
-
- /**
- * Creates the new instance of the class.
- *
- * @param wHint
- * width hint value
- * @param hHint
- * height hint value
- */
- public ColumnLayoutData(int wHint, int hHint) {
- this.widthHint = wHint;
- this.heightHint = hHint;
- }
- public ColumnLayoutData() {}
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ExpandableComposite.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ExpandableComposite.java
deleted file mode 100644
index 62c8354..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ExpandableComposite.java
+++ /dev/null
@@ -1,563 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import java.util.Vector;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.internal.widgets.FormsResources;
-/**
- * This composite is capable of expanding or collapsing a single client that is
- * its direct child. The composite renders an expansion toggle afforance
- * (according to the chosen style), and a title that also acts as a hyperlink
- * (can be selected and is traversable). The client is layed out below the
- * title when expanded, or hidden when collapsed.
- *
- * @since 3.0
- */
-public class ExpandableComposite extends Composite {
- /**
- * If this style is used, a twistie will be used to render the expansion
- * toggle.
- */
- public static final int TWISTIE = 1 << 1;
- /**
- * If this style is used, a tree node with either + or - signs will be used
- * to render the expansion toggle.
- */
- public static final int TREE_NODE = 1 << 2;
- /**
- * If this style is used, the title text will be rendered as a hyperlink
- * that can individually accept focus. Otherwise, it will still act like a
- * hyperlink, but only the toggle control will accept focus.
- */
- public static final int FOCUS_TITLE = 1 << 3;
- /**
- * If this style is used, the client origin will be vertically aligned with
- * the title text. Otherwise, it will start at x = 0.
- */
- public static final int CLIENT_INDENT = 1 << 4;
- /**
- * If this style is used, computed size of the composite will take the
- * client width into consideration only in the expanded state. Otherwise,
- * client width will always be taken into acount.
- */
- public static final int COMPACT = 1 << 5;
- /**
- * If this style is used, the control will be created in the expanded
- * state. This state can later be changed programmatically or by the user
- * if TWISTIE or TREE_NODE style is used.
- */
- public static final int EXPANDED = 1 << 6;
- public int marginWidth = 0;
- public int marginHeight = 0;
- private int GAP = 4;
- private int VSPACE = 3;
- private int SEPARATOR_HEIGHT = 2;
- private int expansionStyle = TWISTIE | FOCUS_TITLE | EXPANDED;
- private boolean expanded;
- private Control client;
- private Vector listeners;
- protected ToggleHyperlink toggle;
- protected Control textLabel;
- private class ExpandableLayout extends Layout implements ILayoutExtension {
- protected void layout(Composite parent, boolean changed) {
- Rectangle clientArea = parent.getClientArea();
- int x = marginWidth;
- int y = marginHeight;
- Point tsize = null;
- if (toggle != null)
- tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
- int twidth = clientArea.width - marginWidth - marginWidth;
- if (tsize != null)
- twidth -= tsize.x + GAP;
- Point size = textLabel.computeSize(twidth, SWT.DEFAULT, changed);
- if (textLabel instanceof Label) {
- Point defSize = textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- if (defSize.y == size.y) {
- // One line - pick the smaller of the two widths
- size.x = Math.min(defSize.x, size.x);
- }
- }
- if (toggle != null) {
- GC gc = new GC(ExpandableComposite.this);
- gc.setFont(getFont());
- FontMetrics fm = gc.getFontMetrics();
- int fontHeight = fm.getHeight();
- gc.dispose();
- int ty = fontHeight / 2 - tsize.y / 2 + 1;
- ty = Math.max(ty, 0);
- toggle.setLocation(x, ty);
- toggle.setSize(tsize);
- x += tsize.x + GAP;
- }
- textLabel.setBounds(x, y, size.x, size.y);
- y += size.y;
- if (getSeparatorControl() != null) {
- y += VSPACE;
- getSeparatorControl().setBounds(marginWidth, y,
- clientArea.width - marginWidth - marginWidth,
- SEPARATOR_HEIGHT);
- y += SEPARATOR_HEIGHT;
- if (expanded)
- y += VSPACE;
- }
- if (expanded) {
- int areaWidth = clientArea.width - marginWidth - marginWidth;
- int cx = marginWidth;
- if ((expansionStyle & CLIENT_INDENT) != 0) {
- cx = x;
- areaWidth -= x;
- }
- if (client != null) {
- Point dsize = null;
- Control desc = getDescriptionControl();
- if (desc != null) {
- dsize = desc.computeSize(areaWidth, SWT.DEFAULT,
- changed);
- desc.setBounds(cx, y, dsize.x, dsize.y);
- y += dsize.y + VSPACE;
- }
- int cwidth = clientArea.width - marginWidth - marginWidth
- - cx;
- int cheight = clientArea.height - marginHeight
- - marginHeight - y;
- client.setBounds(cx, y, cwidth, cheight);
- }
- }
- }
- protected Point computeSize(Composite parent, int wHint, int hHint,
- boolean changed) {
- int width = 0, height = 0;
- Point tsize = null;
- int twidth = 0;
- if (toggle != null) {
- tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
- twidth = tsize.x + GAP;
- }
- int innerwHint = wHint;
- if (innerwHint != SWT.DEFAULT)
- innerwHint -= twidth;
- Point size = textLabel
- .computeSize(innerwHint, SWT.DEFAULT, changed);
- if (textLabel instanceof Label) {
- Point defSize = textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- if (defSize.y == size.y) {
- // One line - pick the smaller of the two widths
- size.x = Math.min(defSize.x, size.x);
- }
- }
- width = size.x;
- height = size.y;
- if (getSeparatorControl() != null) {
- height += VSPACE + SEPARATOR_HEIGHT;
- if (expanded && client != null)
- height += VSPACE;
- }
- if ((expanded || (expansionStyle & COMPACT) != 0) && client != null) {
- int cwHint = wHint;
- if ((expansionStyle & CLIENT_INDENT) != 0)
- cwHint = innerwHint;
- Point dsize = null;
- Point csize = client.computeSize(FormUtil.getWidthHint(cwHint,
- client), SWT.DEFAULT, changed);
- if (getDescriptionControl() != null) {
- int dwHint = cwHint;
- if (dwHint == SWT.DEFAULT) {
- dwHint = csize.x;
- if ((expansionStyle & CLIENT_INDENT) != 0)
- dwHint -= twidth;
- }
- dsize = getDescriptionControl().computeSize(dwHint,
- SWT.DEFAULT, changed);
- }
- if (dsize != null) {
- if ((expansionStyle & CLIENT_INDENT) != 0)
- dsize.x -= twidth;
- width = Math.max(width, dsize.x);
- if (expanded)
- height += dsize.y + VSPACE;
- }
- if ((expansionStyle & CLIENT_INDENT) != 0)
- csize.x -= twidth;
- width = Math.max(width, csize.x);
- if (expanded)
- height += csize.y;
- }
- if (toggle != null) {
- height = height - size.y + Math.max(size.y, tsize.y);
- width += twidth;
- }
- return new Point(width + marginWidth + marginWidth, height
- + marginHeight + marginHeight);
- }
- public int computeMinimumWidth(Composite parent, boolean changed) {
- int width = 0;
- Point size = textLabel.computeSize(5, SWT.DEFAULT, changed);
- width = size.x;
- if ((expanded || (expansionStyle & COMPACT) != 0) && client != null) {
- Point dsize = null;
- if (getDescriptionControl() != null) {
- dsize = getDescriptionControl().computeSize(5, SWT.DEFAULT,
- changed);
- width = Math.max(width, dsize.x);
- }
- int cwidth = FormUtil.computeMinimumWidth(client, changed);
- width = Math.max(width, cwidth);
- }
- if (toggle != null) {
- Point tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- width += tsize.x + GAP;
- }
- return width + marginWidth + marginWidth;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.parts.ILayoutExtension#computeMinimumWidth(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- public int computeMaximumWidth(Composite parent, boolean changed) {
- int width = 0;
- Point size = textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- width = size.x;
- if ((expanded || (expansionStyle & COMPACT) != 0) && client != null) {
- Point dsize = null;
- if (getDescriptionControl() != null) {
- dsize = getDescriptionControl().computeSize(SWT.DEFAULT,
- SWT.DEFAULT, changed);
- width = Math.max(width, dsize.x);
- }
- int cwidth = FormUtil.computeMaximumWidth(client, changed);
- width = Math.max(width, cwidth);
- }
- if (toggle != null) {
- Point tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- width += tsize.x + GAP;
- }
- return width + marginWidth + marginWidth;
- }
- }
- /**
- * Creates an expandable composite using a TWISTIE toggle.
- *
- * @param parent
- * the parent composite
- * @param style
- * SWT style bits
- */
- public ExpandableComposite(Composite parent, int style) {
- this(parent, style, TWISTIE);
- }
- /**
- * Creates the expandable composite in the provided parent.
- *
- * @param parent
- * the parent
- * @param style
- * the control style
- * @param expansionStyle
- * the style of the expansion widget (TREE_NODE, TWISTIE,
- * CLIENT_INDENT, COMPACT, FOCUS_TITLE)
- */
- public ExpandableComposite(Composite parent, int style, int expansionStyle) {
- super(parent, style);
- this.expansionStyle = expansionStyle;
- super.setLayout(new ExpandableLayout());
- listeners = new Vector();
- if ((expansionStyle & TWISTIE) != 0)
- toggle = new Twistie(this, SWT.NULL);
- else if ((expansionStyle & TREE_NODE) != 0)
- toggle = new TreeNode(this, SWT.NULL);
- else
- expanded = true;
- if ((expansionStyle & EXPANDED) != 0)
- expanded = true;
- if (toggle != null) {
- toggle.setExpanded(expanded);
- toggle.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- toggleState();
- }
- });
- }
- if ((expansionStyle & FOCUS_TITLE) != 0) {
- Hyperlink link = new Hyperlink(this, SWT.WRAP);
- link.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- toggle.setExpanded(!toggle.isExpanded());
- toggleState();
- }
- });
- textLabel = link;
- } else {
- final Label label = new Label(this, SWT.WRAP);
- if (!isFixedStyle()) {
- label.setCursor(FormsResources.getHandCursor());
- label.addListener(SWT.MouseDown, new Listener() {
- public void handleEvent(Event e) {
- if (toggle != null)
- toggle.setFocus();
- }
- });
- label.addListener(SWT.MouseUp, new Listener() {
- public void handleEvent(Event e) {
- label.setCursor(FormsResources.getBusyCursor());
- toggle.setExpanded(!toggle.isExpanded());
- toggleState();
- label.setCursor(FormsResources.getHandCursor());
- }
- });
- }
- textLabel = label;
- }
- }
- /**
- * Prevents assignment of the layout manager - expandable composite uses
- * its own layout.
- */
- public final void setLayout(Layout layout) {
- }
- /**
- * Sets the background of all the custom controls in the expandable.
- */
- public void setBackground(Color bg) {
- super.setBackground(bg);
- textLabel.setBackground(bg);
- if (toggle != null)
- toggle.setBackground(bg);
- }
- /**
- * Sets the foreground of all the custom controls in the expandable.
- */
- public void setForeground(Color fg) {
- super.setForeground(fg);
- textLabel.setForeground(fg);
- if (toggle != null)
- toggle.setForeground(fg);
- }
- /**
- * Sets the color of the toggle affordance.
- *
- * @param c
- * the color object
- */
- public void setToggleColor(Color c) {
- if (toggle != null)
- toggle.setDecorationColor(c);
- }
- /**
- * Sets the active color of the toggle affordance (when the mouse enters
- * the toggle area).
- *
- * @param c
- * the active color object
- */
- public void setActiveToggleColor(Color c) {
- if (toggle != null)
- toggle.setActiveDecorationColor(c);
- }
- /**
- * Sets the fonts of all the custom controls in the expandable.
- */
- public void setFont(Font font) {
- super.setFont(font);
- textLabel.setFont(font);
- if (toggle != null)
- toggle.setFont(font);
- }
- /**
- * Sets the client of this expandable composite. The client must not be
- * <samp>null </samp> and must be a direct child of this container.
- *
- * @param client
- * the client that will be expanded or collapsed
- */
- public void setClient(Control client) {
- Assert.isTrue(client != null && client.getParent().equals(this));
- this.client = client;
- }
- /**
- * Returns the current expandable client.
- *
- * @return the client control
- */
- public Control getClient() {
- return client;
- }
- /**
- * Sets the title of the expandable composite. The title will act as a
- * hyperlink and activating it will toggle the client between expanded and
- * collapsed state.
- *
- * @param title
- * the new title string
- * @see #getTitle
- */
- public void setText(String title) {
- if (textLabel instanceof Label)
- ((Label) textLabel).setText(title);
- else
- ((Hyperlink) textLabel).setText(title);
- }
- /**
- * Returns the title string.
- *
- * @return the title string
- * @see #setTitle
- */
- public String getText() {
- if (textLabel instanceof Label)
- return ((Label) textLabel).getText();
- else
- return ((Hyperlink) textLabel).getText();
- }
- /**
- * Tests the expanded state of the composite.
- *
- * @return <samp>true </samp> if expanded, <samp>false </samp> if
- * collapsed.
- */
- public boolean isExpanded() {
- return expanded;
- }
- /**
- * Returns the bitwise-ORed style bits for the expansion control.
- *
- * @return
- */
- public int getExpansionStyle() {
- return expansionStyle;
- }
- /**
- * Programmatically changes expanded state.
- *
- * @param expanded
- * the new expanded state
- */
- public void setExpanded(boolean expanded) {
- internalSetExpanded(expanded);
- if (toggle != null)
- toggle.setExpanded(expanded);
- }
- /**
- * Performs the expansion state change for the expandable control.
- *
- * @param expanded
- * the expansion state
- */
- protected void internalSetExpanded(boolean expanded) {
- if (this.expanded != expanded) {
- this.expanded = expanded;
- if (getDescriptionControl() != null)
- getDescriptionControl().setVisible(expanded);
- if (client != null)
- client.setVisible(expanded);
- layout();
- }
- }
- /**
- * Adds the listener that will be notified when the expansion state
- * changes.
- *
- * @param listener
- * the listener to add
- */
- public void addExpansionListener(ExpansionListener listener) {
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
- /**
- * Removes the expansion listener.
- *
- * @param listener
- * the listner to remove
- */
- public void removeExpansionListener(ExpansionListener listener) {
- if (listeners.contains(listener))
- listeners.remove(listener);
- }
- private void toggleState() {
- boolean newState = !isExpanded();
- fireExpanding(newState, true);
- internalSetExpanded(!isExpanded());
- fireExpanding(newState, false);
- }
- private void fireExpanding(boolean state, boolean before) {
- int size = listeners.size();
- if (size == 0)
- return;
- ExpansionEvent e = new ExpansionEvent(this, state);
- for (int i = 0; i < size; i++) {
- ExpansionListener listener = (ExpansionListener) listeners.get(i);
- if (before)
- listener.expansionStateChanging(e);
- else
- listener.expansionStateChanged(e);
- }
- }
- /**
- * Returns description control that will be placed under the title if
- * present.
- *
- * @return the description control or <samp>null </samp> if not used.
- */
- protected Control getDescriptionControl() {
- return null;
- }
- /**
- * Returns the separator control that will be placed between the title and
- * the description if present.
- *
- * @return the separator control or <samp>null </samp> if not used.
- */
- protected Control getSeparatorControl() {
- return null;
- }
- /**
- * Computes the size of the expandable composite.
- *
- * @see org.eclipse.swt.widgets.Composite#computeSize
- */
- public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- Point size;
- ExpandableLayout layout = (ExpandableLayout) getLayout();
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- size = layout.computeSize(this, wHint, hHint, changed);
- } else {
- size = new Point(wHint, hHint);
- }
- Rectangle trim = computeTrim(0, 0, size.x, size.y);
- return new Point(trim.width, trim.height);
- }
- /**
- * Returns <samp>true </samp> if the composite is fixed i.e. cannot be
- * expanded or collapsed. Fixed control will still contain the title,
- * separator and description (if present) as well as the client, but will
- * be in the permanent expanded state and the toggle affordance will not be
- * shown.
- *
- * @return <samp>true </samp> if the control is fixed in the expanded
- * state, <samp>false </samp> if it can be collapsed.
- */
- protected boolean isFixedStyle() {
- return (expansionStyle & TWISTIE) == 0
- && (expansionStyle & TREE_NODE) == 0;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Form.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Form.java
deleted file mode 100644
index ce132ef..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Form.java
+++ /dev/null
@@ -1,157 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-/**
- * Form is a control that is capable of scrolling an instance of
- * the FormContent class. It should be created in a parent that
- * will allow it to use all the available area (for example, a shell,
- * a view or an editor).
- * <p>
- * Children of the form should typically be created using FormToolkit to match
- * the appearance and behaviour. When creating children, use a form body as a
- * parent by calling 'getBody()' on the form instance. Example:
- *
- * <pre>
- * Form form = new Form(parent);
- * FormToolkit toolkit = new FormToolkit(parent.getDisplay());
- * form.setText("Sample form");
- * form.getBody().setLayout(new GridLayout());
- * toolkit.createButton(form.getBody(), "Checkbox", SWT.CHECK);
- * </pre>
- *
- * <p>
- * No layout manager has been set on the body. Clients are required to set the
- * desired layout manager explicitly.
- *
- * @since 3.0
- */
-public class Form extends SharedScrolledComposite {
- private FormContent content;
-
- public Form(Composite parent) {
- this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- }
- /**
- * Creates the form control as a child of the provided parent.
- *
- * @param parent
- * the parent widget
- */
- public Form(Composite parent, int style) {
- super(parent, style);
- content = new FormContent(this, SWT.NULL);
- super.setContent(content);
- content.setMenu(getMenu());
- }
- /**
- * Returns the title text that will be rendered at the top of the form.
- *
- * @return the title text
- */
- public String getText() {
- return content.getText();
- }
- /**
- * Sets the foreground color of the form. This color will also be used for
- * the body.
- */
- public void setForeground(Color fg) {
- super.setForeground(fg);
- content.setForeground(fg);
- }
- /**
- * Sets the background color of the form. This color will also be used for
- * the body.
- */
- public void setBackground(Color bg) {
- super.setBackground(bg);
- content.setBackground(bg);
- }
- /**
- * The form sets the content widget. This method should not be called by
- * classes that instantiate this widget.
- */
- public final void setContent(Control c) {
- }
- /**
- * Sets the text to be rendered at the top of the form above the body as a
- * title.
- *
- * @param text
- * the title text
- */
- public void setText(String text) {
- content.setText(text);
- reflow(true);
- }
- /**
- * Returns the optional background image of this form. The image is
- * rendered starting at the position 0,0 and is painted behind the title.
- *
- * @return Returns the background image.
- */
- public Image getBackgroundImage() {
- return content.getBackgroundImage();
- }
- /**
- * Sets the optional background image to be rendered behind the title
- * starting at the position 0,0.
- *
- * @param backgroundImage
- * The backgroundImage to set.
- */
- public void setBackgroundImage(Image backgroundImage) {
- content.setBackgroundImage(backgroundImage);
- }
- /**
- * Returns the tool bar manager that is used to manage tool items in the
- * form's title area.
- *
- * @return form tool bar manager
- */
- public IToolBarManager getToolBarManager() {
- return content.getToolBarManager();
- }
- /**
- * Updates the local tool bar manager if used. Does nothing if local tool
- * bar manager has not been created yet.
- */
- public void updateToolBar() {
- content.updateToolBar();
- }
- /**
- * Recomputes the body layout and form scroll bars. The method should be
- * used when changes somewhere in the form body invalidate the current
- * layout and/or scroll bars.
- *
- * @param flushCache
- * if <samp>true </samp>, drop any cached layout information and
- * compute new one.
- */
- public void reflow(boolean flushCache) {
- content.layout();
- super.reflow(flushCache);
- }
- /**
- * Returns the container that occupies the body of the form (the form area
- * below the title). Use this container as a parent for the controls that
- * should be in the form. No layout manager has been set on the form body.
- *
- * @return Returns the body of the form.
- */
- public Composite getBody() {
- return content.getBody();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormContent.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormContent.java
deleted file mode 100644
index 2212165..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormContent.java
+++ /dev/null
@@ -1,317 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.jface.action.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.internal.widgets.FormsResources;
-/**
- * FormContent is a custom control that renders a title and
- * an optional background image above the body composite.
- * It can be used alone when part of parents that are scrolled.
- * If scrolling is required, use <code>Form</code> instead
- * because it has an instance of FormContent and adds scrolling
- * capability.
- * <p>
- * Children of the form should typically be created using FormToolkit to match
- * the appearance and behaviour. When creating children, use a form body as a
- * parent by calling 'getBody()' on the form instance. Example:
- *
- * <pre>
- * FormToolkit toolkit = new FormToolkit(parent.getDisplay());
- * FormContent formContent = toolkit.createFormContent(parent);
- * formContent.setText("Sample form");
- * formContent.getBody().setLayout(new GridLayout());
- * toolkit.createButton(formContent.getBody(), "Checkbox", SWT.CHECK);
- * </pre>
- *
- * <p>
- * No layout manager has been set on the body. Clients are required to set the
- * desired layout manager explicitly.
- *
- * @since 3.0
- */
-public class FormContent extends Composite {
- private int TITLE_HMARGIN = 10;
- private int TITLE_VMARGIN = 5;
- private int TITLE_GAP = 5;
- private Image backgroundImage;
- private boolean backgroundImageTiled;
- private String text;
- private Composite body;
- private ToolBarManager toolBarManager;
-
- private class FormLayout extends Layout implements ILayoutExtension {
- public int computeMinimumWidth(Composite composite, boolean flushCache) {
- return computeSize(composite, 5, SWT.DEFAULT, flushCache).x;
- }
- public int computeMaximumWidth(Composite composite, boolean flushCache) {
- return computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache).x;
- }
- public Point computeSize(Composite composite, int wHint, int hHint,
- boolean flushCache) {
- int width = 0;
- int height = 0;
- if (text != null) {
- GC gc = new GC(composite);
- gc.setFont(getFont());
- if (wHint != SWT.DEFAULT) {
- Point wsize = FormUtil.computeWrapSize(gc, text, wHint);
- width = wsize.x;
- height = wsize.y;
- } else {
- Point extent = gc.textExtent(text);
- width = extent.x;
- height = extent.y;
- }
- gc.dispose();
- }
- if (toolBarManager != null) {
- ToolBar toolBar = toolBarManager.getControl();
- if (toolBar != null) {
- Point tbsize = toolBar
- .computeSize(SWT.DEFAULT, SWT.DEFAULT);
- if (width != 0)
- width += TITLE_GAP;
- width += tbsize.x;
- height = Math.max(height, tbsize.y);
- }
- }
- if (height != 0)
- height += TITLE_VMARGIN * 2;
- if (width != 0)
- width += TITLE_HMARGIN * 2;
- int ihHint = hHint;
- if (ihHint > 0 && ihHint != SWT.DEFAULT)
- ihHint -= height;
- Point bsize = body.computeSize(FormUtil.getWidthHint(wHint, body),
- FormUtil.getHeightHint(ihHint, body), flushCache);
- width = Math.max(bsize.x, width);
- height += bsize.y;
- return new Point(width, height);
- }
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle carea = composite.getClientArea();
- int height = 0;
- Point tbsize = null;
- int twidth = carea.width - TITLE_HMARGIN * 2;
- if (toolBarManager != null) {
- ToolBar toolBar = toolBarManager.getControl();
- if (toolBar != null) {
- tbsize = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- toolBar.setBounds(carea.width - 1 - TITLE_HMARGIN
- - tbsize.x, TITLE_VMARGIN, tbsize.x, tbsize.y);
- height = tbsize.y;
- }
- }
- if (tbsize != null) {
- twidth -= tbsize.x - TITLE_GAP;
- }
- if (text != null) {
- GC gc = new GC(composite);
- gc.setFont(getFont());
- height = FormUtil.computeWrapSize(gc, text, twidth).y;
- gc.dispose();
- if (tbsize != null)
- height = Math.max(tbsize.y, height);
- }
- if (height > 0)
- height += TITLE_VMARGIN * 2;
- body.setBounds(0, height, carea.width, carea.height - height);
- }
- }
- /**
- * Creates the form content control as a child of the provided parent.
- *
- * @param parent
- * the parent widget
- */
- public FormContent(Composite parent, int style) {
- super(parent, style);
- addListener(SWT.Paint, new Listener() {
- public void handleEvent(Event e) {
- onPaint(e.gc);
- }
- });
- super.setLayout(new FormLayout());
- body = new LayoutComposite(this, SWT.NULL);
- body.setMenu(getMenu());
- }
- /**
- * Fully delegates the size computation to the internal
- * layout manager.
- */
- public Point computeSize(int wHint, int hHint, boolean changed) {
- return ((FormLayout) getLayout()).computeSize(this, wHint, hHint,
- changed);
- }
- /**
- * Prevents from changing the custom control layout.
- */
- public final void setLayout(Layout layout) {
- }
- /**
- * Returns the title text that will be rendered at the top of the form.
- *
- * @return the title text
- */
- public String getText() {
- return text;
- }
- /**
- * Sets the foreground color of the form. This color will also be used for
- * the body.
- */
- public void setForeground(Color fg) {
- super.setForeground(fg);
- body.setForeground(fg);
- }
- /**
- * Sets the background color of the form. This color will also be used for
- * the body.
- */
- public void setBackground(Color bg) {
- super.setBackground(bg);
- body.setBackground(bg);
- if (toolBarManager != null)
- toolBarManager.getControl().setBackground(bg);
- }
- /**
- * Sets the text to be rendered at the top of the form above the body as a
- * title.
- *
- * @param text
- * the title text
- */
- public void setText(String text) {
- this.text = text;
- layout(true);
- redraw();
- }
- /**
- * Returns the optional background image of this form. The image is
- * rendered starting at the position 0,0 and is painted behind the title.
- *
- * @return Returns the background image.
- */
- public Image getBackgroundImage() {
- return backgroundImage;
- }
- /**
- * Sets the optional background image to be rendered behind the title
- * starting at the position 0,0.
- *
- * @param backgroundImage
- * The backgroundImage to set.
- */
- public void setBackgroundImage(Image backgroundImage) {
- this.backgroundImage = backgroundImage;
- redraw();
- }
- /**
- * Returns the tool bar manager that is used to manage tool items in the
- * form's title area.
- *
- * @return form tool bar manager
- */
- public IToolBarManager getToolBarManager() {
- if (toolBarManager == null) {
- toolBarManager = new ToolBarManager(SWT.FLAT);
- ToolBar toolbar = toolBarManager.createControl(this);
- toolbar.setBackground(getBackground());
- toolbar.setForeground(getForeground());
- toolbar.setCursor(FormsResources.getHandCursor());
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (toolBarManager != null) {
- toolBarManager.dispose();
- toolBarManager = null;
- }
- }
- });
- }
- return toolBarManager;
- }
- /**
- * Updates the local tool bar manager if used. Does nothing if local tool
- * bar manager has not been created yet.
- */
- public void updateToolBar() {
- if (toolBarManager != null)
- toolBarManager.update(false);
- }
- /**
- * Returns the container that occupies the body of the form (the form area
- * below the title). Use this container as a parent for the controls that
- * should be in the form. No layout manager has been set on the form body.
- *
- * @return Returns the body of the form.
- */
- public Composite getBody() {
- return body;
- }
- private void onPaint(GC gc) {
- Rectangle carea = getClientArea();
- Point textSize=null;
-
- if (text != null) {
- gc.setFont(getFont());
- textSize = FormUtil.computeWrapSize(gc, text, carea.width-TITLE_HMARGIN-TITLE_HMARGIN);
- }
- if (backgroundImage != null) {
- drawBackgroundImage(gc, carea.width, TITLE_VMARGIN+textSize.y+TITLE_VMARGIN);
- }
- if (text != null) {
- gc.setBackground(getBackground());
- gc.setForeground(getForeground());
- Rectangle tbounds = new Rectangle(TITLE_VMARGIN, TITLE_HMARGIN,carea.width-TITLE_HMARGIN-TITLE_HMARGIN, carea.height-TITLE_VMARGIN-TITLE_VMARGIN);
- FormUtil.paintWrapText(gc, text, tbounds);
- }
- }
- private void drawBackgroundImage(GC gc, int width, int height) {
- if (backgroundImageTiled) {
- Rectangle ibounds = backgroundImage.getBounds();
- int x=0;
- int y=0;
- // loop and tile image until the entire title area is covered
- for (;;) {
- gc.drawImage(backgroundImage, x, y);
- x+=ibounds.width;
- if (x>width) {
- //wrap
- x = 0;
- y += ibounds.height;
- if (y>height) break;
- }
- }
- }
- else {
- gc.drawImage(backgroundImage, 0, 0);
- }
-
- }
- /**
- * @return Returns the backgroundImageTiled.
- */
- public boolean isBackgroundImageTiled() {
- return backgroundImageTiled;
- }
- /**
- * @param backgroundImageTiled The backgroundImageTiled to set.
- */
- public void setBackgroundImageTiled(boolean backgroundImageTiled) {
- this.backgroundImageTiled = backgroundImageTiled;
- if (isVisible())
- redraw();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormEntry.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormEntry.java
deleted file mode 100644
index 52bf887..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormEntry.java
+++ /dev/null
@@ -1,117 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import java.util.*;
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.events.IFormEntryListener;
-
-/**
- *TODO Need to return to this class - not clear how to rework it.
- */
-
-public class FormEntry {
- private Text text;
- private String value;
- private boolean dirty;
- private Vector listeners = new Vector();
- boolean ignoreModify = false;
-
- public FormEntry(Text text) {
- this.text = text;
- this.value = text.getText();
- addListeners();
- }
- public void addFormTextListener(IFormEntryListener listener) {
- listeners.addElement(listener);
- }
- private void addListeners() {
- text.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- keyReleaseOccured(e);
- }
- });
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- editOccured(e);
- }
- });
- text.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- if (dirty)
- commit();
- }
- });
- }
-
- public void commit() {
- if (dirty) {
- value = text.getText();
- //notify
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- ((IFormEntryListener) iter.next()).textValueChanged(this);
- }
- }
- dirty = false;
- }
-
- protected void editOccured(ModifyEvent e) {
- if (ignoreModify)
- return;
- dirty = true;
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- ((IFormEntryListener) iter.next()).textDirty(this);
- }
- }
-
- public Text getControl() {
- return text;
- }
- public java.lang.String getValue() {
- return value;
- }
- public boolean isDirty() {
- return dirty;
- }
- protected void keyReleaseOccured(KeyEvent e) {
- if (e.character == '\r') {
- // commit value
- if (dirty)
- commit();
- } else if (e.character == '\u001b') { // Escape character
- text.setText(value != null ? value : ""); // restore old
- dirty = false;
- }
- }
-
- public void removeFormTextListener(IFormEntryListener listener) {
- listeners.removeElement(listener);
- }
-
- public void setDirty(boolean newDirty) {
- dirty = newDirty;
- }
-
- public void setValue(String value) {
- if (text != null)
- text.setText(value != null ? value : "");
- this.value = value;
- }
-
- public void setValue(String value, boolean blockNotification) {
- ignoreModify = blockNotification;
- setValue(value);
- ignoreModify = false;
- }
-
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormToolkit.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormToolkit.java
deleted file mode 100644
index 46506c6..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormToolkit.java
+++ /dev/null
@@ -1,624 +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 Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.*;
-/**
- * The toolkit is responsible for creating SWT controls adapted to work in
- * Eclipse forms. In addition to changing their presentation properties (fonts,
- * colors etc.), various listeners are attached to make them behave correctly
- * in the form context.
- * <p>
- * In addition to being the control factory, the toolkit is also responsible
- * for painting flat borders for select controls, managing hyperlink groups and
- * control colors.
- * <p>
- * The toolkit creates some of the most common controls used to populate
- * Eclipse forms. Controls that must be created using their constructors,
- * <samp>adapt </samp> method is available to change its properties in the same
- * way as with the supported toolkit controls.
- * <p>
- * Typically, one toolkit object is created per workbench part (for example, an
- * editor or a form wizard). The toolkit is disposed when the part is disposed.
- * To conserve resources, it is possible to create one color object for the
- * entire plug-in and share it between several toolkits. The plug-in is
- * responsible for disposing the colors (disposing the toolkit that uses shared
- * color object will not dispose the colors).
- *
- * @since 3.0
- */
-public class FormToolkit {
- public static final String KEY_DRAW_BORDER = "FormWidgetFactory.drawBorder";
- public static final String TREE_BORDER = "treeBorder";
- public static final String TEXT_BORDER = "textBorder";
- private int borderStyle = SWT.NULL;
- private FormColors colors;
- private KeyListener deleteListener;
- private BorderPainter borderPainter;
- private HyperlinkGroup hyperlinkGroup;
- /* default */
- VisibilityHandler visibilityHandler;
- /* default */
- KeyboardHandler keyboardHandler;
- private class BorderPainter implements PaintListener {
- public void paintControl(PaintEvent event) {
- Composite composite = (Composite) event.widget;
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control c = children[i];
- boolean inactiveBorder = false;
- boolean textBorder = false;
- if (!c.isVisible()) continue;
- if (c.getEnabled() == false && !(c instanceof CCombo))
- continue;
- if (c instanceof Hyperlink)
- continue;
- Object flag = c.getData(KEY_DRAW_BORDER);
- if (flag != null) {
- if (flag.equals(Boolean.FALSE))
- continue;
- if (flag.equals(TREE_BORDER))
- inactiveBorder = true;
- else if (flag.equals(TEXT_BORDER))
- textBorder = true;
- }
- if (!inactiveBorder
- && (c instanceof Text || c instanceof Canvas
- || c instanceof CCombo || textBorder)) {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(c.getBackground());
- gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1,
- b.height + 1);
- gc.setForeground(colors.getForeground());
- if (c instanceof CCombo)
- gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1,
- b.height + 1);
- else
- gc.drawRectangle(b.x - 1, b.y - 2, b.width + 1,
- b.height + 3);
- } else if (inactiveBorder || c instanceof Table
- || c instanceof Tree || c instanceof TableTree) {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(colors.getBorderColor());
- gc.drawRectangle(b.x - 1, b.y - 1, b.width + 2,
- b.height + 2);
- }
- }
- }
- }
- private static class VisibilityHandler extends FocusAdapter {
- public void focusGained(FocusEvent e) {
- Widget w = e.widget;
- if (w instanceof Control) {
- FormUtil.ensureVisible((Control) w);
- }
- }
- }
- private static class KeyboardHandler extends KeyAdapter {
- public void keyPressed(KeyEvent e) {
- Widget w = e.widget;
- if (w instanceof Control) {
- FormUtil.processKey(e.keyCode, (Control) w);
- }
- }
- }
- /**
- * Creates a toolkit that is self-sufficient (will manage its own colors).
- *
- */
- public FormToolkit(Display display) {
- this(new FormColors(display));
- }
- /**
- * Creates a toolkit that will use the provided (shared) colors. The
- * toolkit will <b>not </b> dispose the provided colors.
- *
- * @param colors
- * the shared colors
- */
- public FormToolkit(FormColors colors) {
- this.colors = colors;
- initialize();
- }
- /**
- * Creates a button as a part of the form.
- *
- * @param parent
- * the button parent
- * @param text
- * an optional text for the button (can be <code>null</code>)
- * @param style
- * the button style (for example, <code>SWT.PUSH</code>)
- * @return the button widget
- */
- public Button createButton(Composite parent, String text, int style) {
- Button button = new Button(parent, style | SWT.FLAT);
- if (text != null)
- button.setText(text);
- adapt(button, true, true);
- return button;
- }
- /**
- * Creates the composite as a part of the form.
- *
- * @param parent
- * the composite parent
- * @return the composite widget
- */
- public Composite createComposite(Composite parent) {
- return createComposite(parent, SWT.NULL);
- }
- /**
- * Creates the composite as part of the form using the provided style.
- *
- * @param parent
- * the composite parent
- * @param style
- * the composite style
- * @return the composite widget
- */
- public Composite createComposite(Composite parent, int style) {
- Composite composite = new LayoutComposite(parent, style);
- adapt(composite);
- return composite;
- }
- /**
- * Creats the composite that can server as a separator between various
- * parts of a form. Separator height should be controlled by setting the
- * height hint on the layout data for the composite.
- *
- * @param parent
- * the separator parent
- * @return the separator widget
- */
- public Composite createCompositeSeparator(Composite parent) {
- final Composite composite = new Composite(parent, SWT.NONE);
- composite.addListener(SWT.Paint, new Listener() {
- public void handleEvent(Event e) {
- if (composite.isDisposed())
- return;
- Rectangle bounds = composite.getBounds();
- GC gc = e.gc;
- gc.setForeground(colors.getColor(FormColors.SEPARATOR));
- gc.setBackground(colors.getBackground());
- gc.fillGradientRectangle(0, 0, bounds.width, bounds.height,
- false);
- }
- });
- if (parent instanceof Section)
- ((Section) parent).setSeparatorControl(composite);
- return composite;
- }
- /**
- * Creates a label as a part of the form.
- *
- * @param parent
- * the label parent
- * @param text
- * the label text
- * @return the label widget
- */
- public Label createLabel(Composite parent, String text) {
- return createLabel(parent, text, SWT.NONE);
- }
- /**
- * Creates a label as a part of the form.
- *
- * @param parent
- * the label parent
- * @param text
- * the label text
- * @param style
- * the label style
- * @return the label widget
- */
- public Label createLabel(Composite parent, String text, int style) {
- Label label = new Label(parent, style);
- if (text != null)
- label.setText(text);
- adapt(label, false, false);
- return label;
- }
- /**
- * Creates a hyperlink as a part of the form. The hyperlink will be added
- * to the hyperlink group that belongs to this toolkit.
- *
- * @param parent
- * the hyperlink parent
- * @param text
- * the text of the hyperlink
- * @param style
- * the hyperlink style
- * @return the hyperlink widget
- */
- public Hyperlink createHyperlink(Composite parent, String text, int style) {
- Hyperlink hyperlink = new Hyperlink(parent, style);
- if (text != null)
- hyperlink.setText(text);
- hyperlink.addFocusListener(visibilityHandler);
- hyperlink.addKeyListener(keyboardHandler);
- hyperlinkGroup.add(hyperlink);
- return hyperlink;
- }
- /**
- * Creates an image hyperlink as a part of the form. The hyperlink will be
- * added to the hyperlink group that belongs to this toolkit.
- *
- * @param parent
- * the hyperlink parent
- * @param style
- * the hyperlink style
- * @return the image hyperlink widget
- */
- public ImageHyperlink createImageHyperlink(Composite parent, int style) {
- ImageHyperlink hyperlink = new ImageHyperlink(parent, style);
- hyperlink.addFocusListener(visibilityHandler);
- hyperlink.addKeyListener(keyboardHandler);
- hyperlinkGroup.add(hyperlink);
- return hyperlink;
- }
- /**
- * Creates a rich text as a part of the form.
- *
- * @param parent
- * the rich text parent
- * @param trackFocus
- * if <code>true</code>, the toolkit will monitor focus
- * transfers to ensure that the hyperlink in focus is visible in
- * the form.
- * @return the rich text widget
- */
- public RichText createRichText(Composite parent, boolean trackFocus) {
- RichText engine = new RichText(parent, SWT.WRAP);
- engine.marginWidth = 1;
- engine.marginHeight = 0;
- engine.setHyperlinkSettings(getHyperlinkGroup());
- adapt(engine, trackFocus, true);
- engine.setMenu(parent.getMenu());
- return engine;
- }
- /**
- * Adapts a control to be used in a form that is associated with this
- * toolkit. This involves adjusting colors and optionally adding handlers
- * to ensure focus tracking and keyboard management.
- *
- * @param control
- * a control to adapt
- * @param trackFocus
- * if <code>true</code>, form will be scrolled horizontally
- * and/or vertically if needed to ensure that the control is
- * visible when it gains focus. Set it to <code>false</code>
- * if the control is not capable of gaining focus.
- * @param trackKeyboard
- * if <code>true</code>, the control that is capable of
- * gaining focus will be tracked for certain keys that are
- * important to the underlying form (for example, PageUp,
- * PageDown, ScrollUp, ScrollDown etc.). Set it to <code>false</code>
- * if the control is not capable of gaining focus or these
- * particular key event are already used by the control.
- */
- public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
- control.setBackground(colors.getBackground());
- control.setForeground(colors.getForeground());
- if (trackFocus)
- control.addFocusListener(visibilityHandler);
- if (trackKeyboard)
- control.addKeyListener(keyboardHandler);
- }
- /**
- * Adapts a composite to be used in a form associated with this toolkit.
- *
- * @param composite
- * the composite to adapt
- */
- public void adapt(Composite composite) {
- composite.setBackground(colors.getBackground());
- composite.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- ((Control) e.widget).setFocus();
- }
- });
- composite.setMenu(composite.getParent().getMenu());
- }
- /**
- * Creates a section as a part of the form.
- *
- * @param parent
- * the section parent
- * @param sectionStyle
- * the section style
- * @return the section widget
- */
- public Section createSection(Composite parent, int sectionStyle) {
- Section section = new Section(parent, sectionStyle);
- section.setBackground(colors.getBackground());
- section.setForeground(colors.getForeground());
- section.textLabel.addFocusListener(visibilityHandler);
- section.textLabel.addKeyListener(keyboardHandler);
- if (section.toggle != null) {
- section.toggle.addFocusListener(visibilityHandler);
- section.toggle.addKeyListener(keyboardHandler);
- section.toggle.setActiveDecorationColor(getHyperlinkGroup()
- .getActiveForeground());
- section.toggle.setDecorationColor(colors
- .getColor(FormColors.SEPARATOR));
- }
- section.setFont(JFaceResources.getFontRegistry().get(
- JFaceResources.BANNER_FONT));
- return section;
- }
- /**
- * Creates an expandable composite as a part of the form.
- *
- * @param parent
- * the expandable composite parent
- * @param expansionStyle
- * the expandable composite style
- * @return the expandable composite widget
- */
- public ExpandableComposite createExpandableComposite(Composite parent,
- int expansionStyle) {
- ExpandableComposite ec = new ExpandableComposite(parent, SWT.NULL,
- expansionStyle);
- ec.setBackground(colors.getBackground());
- ec.setForeground(colors.getForeground());
- //hyperlinkGroup.add(ec.textLabel);
- if (ec.toggle != null) {
- ec.toggle.addFocusListener(visibilityHandler);
- ec.toggle.addKeyListener(keyboardHandler);
- }
- ec.textLabel.addFocusListener(visibilityHandler);
- ec.textLabel.addKeyListener(keyboardHandler);
- ec.setFont(JFaceResources.getFontRegistry().get(
- JFaceResources.BANNER_FONT));
- return ec;
- }
- /**
- * Creates a separator label as a part of the form.
- *
- * @param parent
- * the separator parent
- * @param style
- * the separator style
- * @return the separator label
- */
- public Label createSeparator(Composite parent, int style) {
- Label label = new Label(parent, SWT.SEPARATOR | style);
- label.setBackground(colors.getBackground());
- label.setForeground(colors.getBorderColor());
- return label;
- }
- /**
- * Creates a table as a part of the form.
- *
- * @param parent
- * the table parent
- * @param style
- * the table style
- * @return the table widget
- */
- public Table createTable(Composite parent, int style) {
- Table table = new Table(parent, style | borderStyle);
- adapt(table, false, false);
- hookDeleteListener(table);
- return table;
- }
- /**
- * Creates a text as a part of the form.
- *
- * @param parent
- * the text parent
- * @param value
- * the text initial value
- * @return the text widget
- */
- public Text createText(Composite parent, String value) {
- return createText(parent, value, SWT.SINGLE);
- }
- /**
- * Creates a text as a part of the form.
- *
- * @param parent
- * the text parent
- * @param value
- * the text initial value
- * @param the
- * text style
- * @return the text widget
- */
- public Text createText(Composite parent, String value, int style) {
- Text text = new Text(parent, borderStyle | style);
- if (value != null)
- text.setText(value);
- adapt(text, true, false);
- return text;
- }
- /**
- * Creates a tree widget as a part of the form.
- *
- * @param parent
- * the tree parent
- * @param style
- * the tree style
- * @return the tree widget
- */
- public Tree createTree(Composite parent, int style) {
- Tree tree = new Tree(parent, borderStyle | style);
- adapt(tree, false, false);
- hookDeleteListener(tree);
- return tree;
- }
- /**
- * Creates a form widget in the provided parent.
- *
- * @param parent
- * the form parent
- * @return the form widget
- */
- public Form createForm(Composite parent) {
- Form form = new Form(parent);
- form.setExpandHorizontal(true);
- form.setExpandVertical(true);
- form.setBackground(colors.getBackground());
- form.setForeground(colors.getColor(FormColors.TITLE));
- form.setFont(JFaceResources.getHeaderFont());
- return form;
- }
- public FormContent createFormContent(Composite parent) {
- FormContent formContent = new FormContent(parent, SWT.NULL);
- formContent.setBackground(colors.getBackground());
- formContent.setForeground(colors.getColor(FormColors.TITLE));
- formContent.setFont(JFaceResources.getHeaderFont());
- return formContent;
- }
- /**
- * Creates a rich text as a part of the form.
- *
- * @param parent
- * the rich text parent
- * @param trackFocus
- * if <code>true</code>, the toolkit will monitor focus
- * transfers to ensure that the hyperlink in focus is visible in
- * the form.
- * @return the rich text widget
- */
- public ScrolledPageBook createPageBook(Composite parent, int style) {
- ScrolledPageBook book = new ScrolledPageBook(parent, style);
- adapt(book, true, true);
- book.setMenu(parent.getMenu());
- return book;
- }
- //TODO hook delete key
- /*
- * private void deleteKeyPressed(Widget widget) { if (!(widget instanceof
- * Control)) return; Control control = (Control) widget; for (Control
- * parent = control.getParent(); parent != null; parent =
- * parent.getParent()) { if (parent.getData() instanceof SectionPart) {
- * SectionPart section = (SectionPart) parent.getData();
- * section.doGlobalAction(ActionFactory.DELETE.getId()); break; } } }
- */
- /**
- * Disposes the toolkit.
- */
- public void dispose() {
- if (colors.isShared() == false) {
- colors.dispose();
- colors = null;
- }
- }
- /**
- * Returns the hyperlink group that manages hyperlinks for this toolkit.
- *
- * @return the hyperlink group
- */
- public HyperlinkGroup getHyperlinkGroup() {
- return hyperlinkGroup;
- }
- public void hookDeleteListener(Control control) {
- if (deleteListener == null) {
- deleteListener = new KeyAdapter() {
- public void keyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- //TODO hook delete key
- //deleteKeyPressed(event.widget);
- }
- }
- };
- }
- control.addKeyListener(deleteListener);
- }
-/**
- * Sets the background color for the entire toolkit. The method
- * delegates the call to the FormColors object and also updates
- * the hyperlink group so that hyperlinks and other objects are
- * in sync.
- * @param bg the new background color
- */
- public void setBackground(Color bg) {
- hyperlinkGroup.setBackground(bg);
- colors.setBackground(bg);
- }
- /**
- * Refreshes the hyperlink colors by loading from JFace settings.
- */
- public void refreshHyperlinkColors() {
- hyperlinkGroup.initializeDefaultForegrounds(colors.getDisplay());
- }
- /**
- * Paints flat borders for widgets created by this toolkit within the
- * provided parent. Borders will not be painted if the global border style
- * is SWT.BORDER (i.e. if native borders are used). Call this method during
- * creation of a form composite to get the borders of its children painted.
- * Care should be taken when selection layout margins. At least one pixel
- * pargin width and height must be chosen to allow the toolkit to paint the
- * border on the parent around the widgets.
- * <p>
- * Borders are painted for some controls that are selected by the toolkit
- * by default. If a control needs a border but is not on its list, it is
- * possible to force border in the following way:
- *
- * <pre>
- * widget.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
- *
- * or
- *
- * widget.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- * </pre>
- *
- * @param parent
- * the parent that owns the children for which the border needs
- * to be painted.
- */
- public void paintBordersFor(Composite parent) {
- if (borderStyle == SWT.BORDER)
- return;
- if (borderPainter == null)
- borderPainter = new BorderPainter();
- parent.addPaintListener(borderPainter);
- }
- /**
- * Returns the colors used by this toolkit.
- *
- * @return the color object
- */
- public FormColors getColors() {
- return colors;
- }
- /**
- * Returns the border style used for various widgets created by this
- * toolkit. The intent of the toolkit is to create controls with styles
- * that yield a 'flat' appearance. On systems where the native borders are
- * already flat, we set the style to SWT.BORDER and don't paint the borders
- * ourselves. Otherwise, the style is set to SWT.NULL, and borders are
- * painted by the toolkit.
- *
- * @return the global border style
- */
- public int getBorderStyle() {
- return borderStyle;
- }
- private void initialize() {
- String osname = System.getProperty("os.name");
- if (osname.equals("Windows XP"))
- borderStyle = SWT.BORDER;
- hyperlinkGroup = new HyperlinkGroup(colors.getDisplay());
- hyperlinkGroup.setBackground(colors.getBackground());
- visibilityHandler = new VisibilityHandler();
- keyboardHandler = new KeyboardHandler();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormUtil.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormUtil.java
deleted file mode 100644
index 97a7f63..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/FormUtil.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import java.text.BreakIterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.*;
-
-/**
- *
- */
-public class FormUtil {
- static final int H_SCROLL_INCREMENT = 5;
- static final int V_SCROLL_INCREMENT = 64;
-
- public static Text createText(
- Composite parent,
- String label,
- FormToolkit factory) {
- return createText(parent, label, factory, 1);
- }
- public static Text createText(
- Composite parent,
- String label,
- FormToolkit factory,
- int span) {
- factory.createLabel(parent, label);
- Text text = factory.createText(parent, "");
- int hfill =
- span == 1
- ? GridData.FILL_HORIZONTAL
- : GridData.HORIZONTAL_ALIGN_FILL;
- GridData gd = new GridData(hfill | GridData.VERTICAL_ALIGN_CENTER);
- gd.horizontalSpan = span;
- text.setLayoutData(gd);
- return text;
- }
- public static Text createText(
- Composite parent,
- String label,
- FormToolkit factory,
- int span,
- int style) {
- Label l = factory.createLabel(parent, label);
- if ((style & SWT.MULTI) != 0) {
- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- l.setLayoutData(gd);
- }
- Text text = factory.createText(parent, "", style);
- int hfill =
- span == 1
- ? GridData.FILL_HORIZONTAL
- : GridData.HORIZONTAL_ALIGN_FILL;
- GridData gd = new GridData(hfill | GridData.VERTICAL_ALIGN_CENTER);
- gd.horizontalSpan = span;
- text.setLayoutData(gd);
- return text;
- }
- public static Text createText(
- Composite parent,
- FormToolkit factory,
- int span) {
- Text text = factory.createText(parent, "");
- int hfill =
- span == 1
- ? GridData.FILL_HORIZONTAL
- : GridData.HORIZONTAL_ALIGN_FILL;
- GridData gd = new GridData(hfill | GridData.VERTICAL_ALIGN_CENTER);
- gd.horizontalSpan = span;
- text.setLayoutData(gd);
- return text;
- }
-
- static int computeMinimumWidth(GC gc, String text) {
- BreakIterator wb = BreakIterator.getWordInstance();
- wb.setText(text);
- int last = 0;
-
- int width = 0;
-
- for (int loc = wb.first();
- loc != BreakIterator.DONE;
- loc = wb.next()) {
- String word = text.substring(last, loc);
- Point extent = gc.textExtent(word);
- width = Math.max(width, extent.x);
- last = loc;
- }
- return width;
- }
-
- static Point computeWrapSize(GC gc, String text, int wHint) {
- BreakIterator wb = BreakIterator.getWordInstance();
- wb.setText(text);
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
-
- int saved = 0;
- int last = 0;
- int height = lineHeight;
- int maxWidth = 0;
-
- for (int loc = wb.first();
- loc != BreakIterator.DONE;
- loc = wb.next()) {
- String word = text.substring(saved, loc);
- Point extent = gc.textExtent(word);
- maxWidth = Math.max(maxWidth, extent.x);
- if (extent.x > wHint) {
- // overflow
- saved = last;
- height += extent.y;
- }
- last = loc;
- }
- return new Point(maxWidth, height);
- }
- static void paintWrapText(
- GC gc,
- String text,
- Rectangle bounds) {
- paintWrapText(gc, text, bounds, false);
- }
- static void paintWrapText(
- GC gc,
- String text,
- Rectangle bounds,
- boolean underline) {
- BreakIterator wb = BreakIterator.getWordInstance();
- wb.setText(text);
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
- int descent = fm.getDescent();
-
- int saved = 0;
- int last = 0;
- int y = bounds.y;
- int width = bounds.width;
-
- for (int loc = wb.first();
- loc != BreakIterator.DONE;
- loc = wb.next()) {
- String line = text.substring(saved, loc);
- Point extent = gc.textExtent(line);
-
- if (extent.x > width) {
- // overflow
- String prevLine = text.substring(saved, last);
- gc.drawText(prevLine, bounds.x, y, true);
- if (underline) {
- Point prevExtent = gc.textExtent(prevLine);
- int lineY = y + lineHeight - descent + 1;
- gc.drawLine(bounds.x, lineY, bounds.x+prevExtent.x, lineY);
- }
-
- saved = last;
- y += lineHeight;
- }
- last = loc;
- }
- // paint the last line
- String lastLine = text.substring(saved, last);
- gc.drawText(lastLine, bounds.x, y, true);
- if (underline) {
- int lineY = y + lineHeight - descent + 1;
- Point lastExtent = gc.textExtent(lastLine);
- gc.drawLine(bounds.x, lineY, bounds.x + lastExtent.x, lineY);
- }
- }
- static ScrolledComposite getScrolledComposite(Control c) {
- Composite parent = c.getParent();
-
- while (parent != null) {
- if (parent instanceof ScrolledComposite) {
- return (ScrolledComposite) parent;
- }
- parent = parent.getParent();
- }
- return null;
- }
-
- static void ensureVisible(Control c) {
- ScrolledComposite scomp = getScrolledComposite(c);
- if (scomp != null) {
- FormUtil.ensureVisible(scomp, c);
- }
- }
- static void ensureVisible(ScrolledComposite scomp, Control control) {
- Point controlSize = control.getSize();
- Point controlOrigin = getControlLocation(scomp, control);
- ensureVisible(scomp, controlOrigin, controlSize);
- }
-
- static void ensureVisible(
- ScrolledComposite scomp,
- Point controlOrigin,
- Point controlSize) {
- Rectangle area = scomp.getClientArea();
- Point scompOrigin = scomp.getOrigin();
-
- int x = scompOrigin.x;
- int y = scompOrigin.y;
-
- if (controlOrigin.x + controlSize.x > scompOrigin.x + area.x) {
- x = controlOrigin.x + controlSize.x - area.width;
- }
-
- if (controlOrigin.x < x) {
- x = controlOrigin.x;
- }
-
- if (controlOrigin.y + controlSize.y > scompOrigin.y + area.y) {
- y = controlOrigin.y + controlSize.y - area.height;
- }
-
- if (controlOrigin.y < y) {
- y = controlOrigin.y;
- }
- if (scompOrigin.x!=x || scompOrigin.y!=y)
- scomp.setOrigin(x, y);
- }
-
- static Point getControlLocation(ScrolledComposite scomp, Control control) {
- int x = 0;
- int y = 0;
- Control currentControl = control;
- for (;;) {
- if (currentControl == scomp)
- break;
- if (currentControl.getLocation().x > 0)
- x += currentControl.getLocation().x;
- if (currentControl.getLocation().y > 0)
- y += currentControl.getLocation().y;
- currentControl = currentControl.getParent();
- }
- return new Point(x, y);
- }
-
- static void scrollVertical(ScrolledComposite scomp, boolean up) {
- scroll(scomp, 0, up ? -V_SCROLL_INCREMENT : V_SCROLL_INCREMENT);
- }
- static void scrollHorizontal(ScrolledComposite scomp, boolean left) {
- scroll(scomp, left ? -H_SCROLL_INCREMENT : H_SCROLL_INCREMENT, 0);
- }
- static void scrollPage(ScrolledComposite scomp, boolean up) {
- Rectangle clientArea = scomp.getClientArea();
- int increment = up ? -clientArea.height : clientArea.height;
- scroll(scomp, 0, increment);
- }
- private static void scroll(
- ScrolledComposite scomp,
- int xoffset,
- int yoffset) {
- Point origin = scomp.getOrigin();
- Point contentSize = scomp.getContent().getSize();
- int xorigin = origin.x + xoffset;
- int yorigin = origin.y + yoffset;
- xorigin = Math.max(xorigin, 0);
- xorigin = Math.min(xorigin, contentSize.x - 1);
- yorigin = Math.max(yorigin, 0);
- yorigin = Math.min(yorigin, contentSize.y - 1);
- scomp.setOrigin(xorigin, yorigin);
- }
-
- static void updatePageIncrement(ScrolledComposite scomp) {
- ScrollBar vbar = scomp.getVerticalBar();
- if (vbar != null) {
- Rectangle clientArea = scomp.getClientArea();
- int increment = clientArea.height - 5;
- vbar.setPageIncrement(increment);
- }
- }
- static void processKey(int keyCode, Control c) {
- ScrolledComposite scomp = FormUtil.getScrolledComposite(c);
- if (scomp != null) {
- switch (keyCode) {
- case SWT.ARROW_DOWN :
- FormUtil.scrollVertical(scomp, false);
- break;
- case SWT.ARROW_UP :
- FormUtil.scrollVertical(scomp, true);
- break;
- case SWT.ARROW_LEFT :
- FormUtil.scrollHorizontal(scomp, true);
- break;
- case SWT.ARROW_RIGHT :
- FormUtil.scrollHorizontal(scomp, false);
- break;
- case SWT.PAGE_UP :
- FormUtil.scrollPage(scomp, true);
- break;
- case SWT.PAGE_DOWN :
- FormUtil.scrollPage(scomp, false);
- break;
- }
- }
- }
-
- static boolean isWrapControl(Control c) {
- if (c instanceof Composite) {
- return ((Composite)c).getLayout() instanceof ILayoutExtension;
- }
- else {
- return (c.getStyle() & SWT.WRAP) != 0;
- }
- }
-
- static int getWidthHint(int wHint, Control c) {
- boolean wrap=isWrapControl(c);
- return wrap ? wHint : SWT.DEFAULT;
- }
-
- static int getHeightHint(int hHint, Control c) {
- if (c instanceof Composite) {
- Layout layout = ((Composite)c).getLayout();
- if (layout instanceof ColumnLayout)
- return hHint;
- }
- return SWT.DEFAULT;
- }
-
- static int computeMinimumWidth(Control c, boolean changed) {
- if (c instanceof Composite) {
- Layout layout = ((Composite)c).getLayout();
- if (layout instanceof ILayoutExtension)
- return ((ILayoutExtension)layout).computeMinimumWidth((Composite)c, changed);
- }
- return c.computeSize(FormUtil.getWidthHint(5, c), SWT.DEFAULT, changed).x;
- }
- static int computeMaximumWidth(Control c, boolean changed) {
- if (c instanceof Composite) {
- Layout layout = ((Composite)c).getLayout();
- if (layout instanceof ILayoutExtension)
- return ((ILayoutExtension)layout).computeMaximumWidth((Composite)c, changed);
- }
- return c.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed).x;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Hyperlink.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Hyperlink.java
deleted file mode 100644
index e9aed9e..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Hyperlink.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Created on Nov 26, 2003
- *
- * To change the template for this generated file go to Window - Preferences -
- * Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.*;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-/**
- * Hyperlink is a concrete implementation of the abstract base class that draws
- * text in the client area. Text can be wrapped and underlined. Hyperlink is
- * typically added to the hyperlink group so that certain properties are
- * managed for all the hyperlinks that belong to it.
- *
- * @see org.eclipse.ui.forms.HyperlinkGroup
- * @since 3.0
- */
-public class Hyperlink extends AbstractHyperlink {
- private String text;
- private boolean underlined;
- /**
- * Creates a new hyperlink control in the provided parent.
- *
- * @param parent
- * the control parent
- * @param style
- * the widget style
- */
- public Hyperlink(Composite parent, int style) {
- super(parent, style);
- initAccessible();
- }
- protected void initAccessible() {
- Accessible accessible = getAccessible();
- accessible.addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = getText();
- }
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
- accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point pt = toControl(new Point(e.x, e.y));
- e.childID = (getBounds().contains(pt))
- ? ACC.CHILDID_SELF
- : ACC.CHILDID_NONE;
- }
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_LABEL;
- }
- public void getState(AccessibleControlEvent e) {
- int state = ACC.STATE_NORMAL;
- if (Hyperlink.this.getSelection())
- state = ACC.STATE_SELECTED | ACC.STATE_FOCUSED;
- e.detail = state;
- }
- });
- }
- /**
- * Sets the underlined state. It is not necessary to call this method when
- * in a hyperlink group.
- *
- * @param underlined
- * if <samp>true </samp>, a line will be drawn below the text
- * for each wrapped line.
- */
- public void setUnderlined(boolean underlined) {
- this.underlined = underlined;
- redraw();
- }
- /**
- * Returns the underline state of the hyperlink.
- *
- * @return <samp>true </samp> if text is underlined, <samp>false </samp>
- * otherwise.
- */
- public boolean isUnderlined() {
- return underlined;
- }
- /**
- * Overrides the parent by incorporating the margin.
- */
- public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- int innerWidth = wHint;
- if (innerWidth != SWT.DEFAULT)
- innerWidth -= marginWidth * 2;
- Point textSize = computeTextSize(innerWidth, hHint);
- int textWidth = textSize.x + 2 * marginWidth;
- int textHeight = textSize.y + 2 * marginHeight;
- return new Point(textWidth, textHeight);
- }
- /**
- * Returns the current hyperlink text.
- *
- * @return hyperlink text
- */
- public String getText() {
- return text;
- }
- /**
- * Sets the text of this hyperlink.
- *
- * @param text
- * the hyperlink text
- */
- public void setText(String text) {
- if (text != null)
- this.text = text;
- else
- text = "";
- redraw();
- }
- /**
- * Paints the hyperlink text.
- *
- * @param e
- * the paint event
- */
- protected void paintHyperlink(PaintEvent e) {
- GC gc = e.gc;
- Rectangle carea = getClientArea();
- Rectangle bounds = new Rectangle(marginWidth, marginHeight, carea.width
- - marginWidth - marginWidth, carea.height - marginHeight
- - marginHeight);
- paintText(gc, bounds);
- }
- /**
- * Paints the hyperlink text in provided bounding rectangle.
- *
- * @param gc
- * graphic context
- * @param bounds
- * the bounding rectangle in which to paint the text
- */
- protected void paintText(GC gc, Rectangle bounds) {
- gc.setFont(getFont());
- gc.setForeground(getForeground());
-
- if ((getStyle() & SWT.WRAP) != 0) {
- FormUtil.paintWrapText(gc, text, bounds, underlined);
- } else {
- gc.drawText(getText(), bounds.x, bounds.y, true);
- if (underlined) {
- FontMetrics fm = gc.getFontMetrics();
- int descent = fm.getDescent();
- int lineY = bounds.y + bounds.height - descent + 1;
- gc.drawLine(bounds.x, lineY, bounds.x + bounds.width, lineY);
- }
- }
- }
- protected Point computeTextSize(int wHint, int hHint) {
- Point extent;
- GC gc = new GC(this);
- gc.setFont(getFont());
- if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
- extent = FormUtil.computeWrapSize(gc, getText(), wHint);
- } else {
- extent = gc.textExtent(getText());
- }
- gc.dispose();
- return extent;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ILayoutExtension.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ILayoutExtension.java
deleted file mode 100644
index c889c7c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ILayoutExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Classes that extend abstract class Layout and implement
- * this interface can take part in layout computation of
- * the TableWrapLayout manager. The said layout uses
- * alternative algorithm that computes columns before rows.
- * It allows it to 'flow' wrapped text proportionally
- * (similar to the way web browser render tables). Custom
- * layout managers that implement this interface allow recursive
- * reflow to be performed.
- * @since 3.0
- * @see TableWrapLayout
- */
-public interface ILayoutExtension {
-/**
- * Computes the minimum width of the parent. All widgets
- * capable of word wrapping should return the width
- * of the longest word that cannot be wrapped.
- * @param parent
- * @param changed
- * @return
- */
- public int computeMinimumWidth(Composite parent, boolean changed);
-/**
- * Computes the maximum width of the parent. All widgets
- * capable of word wrapping should return the length
- * of the entire text without wrapping.
- * @param parent
- * @param changed
- * @return
- */
- public int computeMaximumWidth(Composite parent, boolean changed);
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ImageHyperlink.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ImageHyperlink.java
deleted file mode 100644
index e119789..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ImageHyperlink.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-/**
- * This class extends hyperlink widget by adding the capability to render an
- * image relative to the text. If no text has been set, only image will be
- * shown. Images for hover and active states can be set in addition to the
- * normal state image.
- */
-public class ImageHyperlink extends Hyperlink {
- /**
- * Aligns text with the top of the image (value is SWT.TOP)
- */
- public static final int TOP = SWT.TOP;
- /**
- * Aligns text with the bottom of the image (value is SWT.BOTTOM)
- */
- public static final int BOTTOM = SWT.BOTTOM;
- /**
- * Centers text vertically in respect to the image (value is SWT.BOTTOM
- * << 1)
- */
- public static final int MIDDLE = SWT.CENTER;
- private Image image;
- private Image hoverImage;
- private Image activeImage;
- private int state;
- private static final int HOVER = 1 << 1;
- private static final int ACTIVE = 1 << 2;
- /**
- * Amount of pixels between the image and the text (default is 5).
- */
- public int textSpacing = 5;
- /**
- * Creates the image hyperlink instance.
- *
- * @param parent
- * the control parent
- * @param style
- * the control style (SWT.WRAP, BOTTOM, TOP, MIDDLE)
- */
- public ImageHyperlink(Composite parent, int style) {
- super(parent, style);
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.widgets.AbstractHyperlink#paintHyperlink(org.eclipse.swt.events.PaintEvent)
- */
- protected void paintHyperlink(PaintEvent e) {
- Rectangle clientArea = getClientArea();
- GC gc = e.gc;
- Image image = null;
- if ((state & ACTIVE) != 0)
- image = activeImage;
- else if ((state & HOVER) != 0)
- image = hoverImage;
- if (image == null)
- image = this.image;
- if (image == null)
- return;
- Rectangle ibounds = image.getBounds();
- Point maxsize = computeMaxImageSize();
- int x = marginWidth + maxsize.x / 2 - ibounds.width / 2;
- int y = marginHeight + maxsize.y / 2 - ibounds.height / 2;
- gc.drawImage(image, x, y);
- if (getText() != null) {
- int textWidth = clientArea.width - maxsize.x - textSpacing
- - marginWidth - marginWidth;
- int textX = marginWidth + maxsize.x + textSpacing;
- Point textSize = computeTextSize(textWidth, SWT.DEFAULT);
- textWidth = textSize.x;
- int slotHeight = clientArea.height - marginHeight - marginHeight;
- int textY;
- int textHeight = textSize.y;
- if ((getStyle() & BOTTOM) != 0) {
- textY = marginHeight + slotHeight - textHeight;
- } else if ((getStyle() & MIDDLE) != 0) {
- textY = marginHeight + slotHeight / 2 - textHeight / 2;
- } else {
- textY = marginHeight;
- }
- paintText(gc, new Rectangle(textX, textY, textWidth, textHeight));
- }
- }
- /**
- * Computes the control size by reserving space for images in addition to
- * text.
- *
- * @param wHint
- * width hint
- * @param hHint
- * height hint
- * @param changed
- * if <code>true</code>, any cached layout data should be
- * computed anew
- */
- public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- Point isize = computeMaxImageSize();
- Point textSize = null;
- if (getText() != null) {
- int innerWHint = wHint;
- if (wHint != SWT.DEFAULT) {
- innerWHint = wHint - 2 * marginWidth;
- }
- textSize = super.computeSize(innerWHint, hHint, changed);
- }
- int width = isize.x;
- int height = isize.y;
- if (textSize != null) {
- width += textSpacing;
- width += textSize.x;
- height = Math.max(height, textSize.y);
- }
- width += 2 * marginWidth;
- height += 2 * marginHeight;
- return new Point(width, height);
- }
- protected void handleEnter() {
- state = HOVER;
- super.handleEnter();
- }
- protected void handleExit() {
- state = 0;
- super.handleExit();
- }
- protected void handleActivate() {
- state &= ACTIVE;
- redraw();
- super.handleActivate();
- state &= ~ACTIVE;
- redraw();
- }
- /**
- * @return Returns the activeImage.
- */
- public Image getActiveImage() {
- return activeImage;
- }
- /**
- * @param activeImage
- * The activeImage to set.
- */
- public void setActiveImage(Image activeImage) {
- this.activeImage = activeImage;
- }
- /**
- * @return Returns the hoverImage.
- */
- public Image getHoverImage() {
- return hoverImage;
- }
- /**
- * @param hoverImage
- * The hoverImage to set.
- */
- public void setHoverImage(Image hoverImage) {
- this.hoverImage = hoverImage;
- }
- /**
- * @return Returns the image.
- */
- public Image getImage() {
- return image;
- }
- /**
- * @param image
- * The image to set.
- */
- public void setImage(Image image) {
- this.image = image;
- }
- private Point computeMaxImageSize() {
- int x = 0;
- int y = 0;
- if (image != null) {
- x = Math.max(image.getBounds().width, x);
- y = Math.max(image.getBounds().height, y);
- }
- if (hoverImage != null) {
- x = Math.max(hoverImage.getBounds().width, x);
- y = Math.max(hoverImage.getBounds().height, y);
- }
- if (activeImage != null) {
- x = Math.max(activeImage.getBounds().width, x);
- y = Math.max(activeImage.getBounds().height, y);
- }
- return new Point(x, y);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/LayoutComposite.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/LayoutComposite.java
deleted file mode 100644
index 9796a51..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/LayoutComposite.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Created on Jan 24, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms.widgets;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.*;
-
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class LayoutComposite extends Composite {
- public LayoutComposite(Composite parent, int style) {
- super(parent, style);
- }
- public Point computeSize(int wHint, int hHint, boolean changed) {
- Layout layout = getLayout();
- if (layout instanceof TableWrapLayout)
- return ((TableWrapLayout) layout).computeSize(this, wHint,
- hHint, changed);
- if (layout instanceof ColumnLayout)
- return ((ColumnLayout) layout).computeSize(this, wHint, hHint,
- changed);
- return super.computeSize(wHint, hHint, changed);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/RichText.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/RichText.java
deleted file mode 100644
index f8e23e6..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/RichText.java
+++ /dev/null
@@ -1,792 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import java.io.InputStream;
-import java.util.*;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.*;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.HyperlinkSettings;
-import org.eclipse.ui.forms.events.*;
-import org.eclipse.ui.forms.internal.widgets.*;
-import org.eclipse.update.ui.forms.internal.FormsPlugin;
-
-
-public class RichText extends Canvas {
- /**
- * The object ID to be used when registering action to handle URL
- * hyperlinks (those that should result in opening the web browser). Value
- * is "urlHandler".
- */
- public static final String URL_HANDLER_ID = "urlHandler";
- /**
- * Value of the horizontal margin (default is 0).
- */
- public int marginWidth = 0;
- /**
- * Value of hte horizontal margin (default is 1).
- */
- public int marginHeight = 1;
- //private fields
- private boolean hasFocus;
- private boolean paragraphsSeparated = true;
- private RichTextModel model;
- private Vector listeners;
- private Hashtable imageTable = new Hashtable();
-
- private HyperlinkSegment entered;
- private boolean mouseDown = false;
- //private Point dragOrigin;
- private Action openAction;
- private Action copyShortcutAction;
- private boolean loading = true;
- //TODO translate this text
- private String loadingText = "Loading...";
-
- private class RichTextLayout extends Layout implements ILayoutExtension {
- public RichTextLayout() {
- }
-
- public int computeMaximumWidth(Composite parent, boolean changed) {
- return computeSize(parent, SWT.DEFAULT, SWT.DEFAULT, changed).x;
- }
-
- public int computeMinimumWidth(Composite parent, boolean changed) {
- return computeSize(parent, 5, SWT.DEFAULT, true).x;
- }
-
- /*
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
-
- public Point computeSize(
- Composite composite,
- int wHint,
- int hHint,
- boolean changed) {
- int innerWidth = wHint;
- if (isLoading()) {
- return computeLoading();
- }
- if (innerWidth != SWT.DEFAULT)
- innerWidth -= marginWidth * 2;
- Point textSize = computeTextSize(innerWidth);
- int textWidth = textSize.x + 2 * marginWidth;
- int textHeight = textSize.y + 2 * marginHeight;
- Point result = new Point(textWidth, textHeight);
- return result;
- }
-
- private Point computeLoading() {
- GC gc = new GC(RichText.this);
- gc.setFont(getFont());
- String loadingText = getLoadingText();
- Point size = gc.textExtent(loadingText);
- gc.dispose();
- size.x += 2 * marginWidth;
- size.y += 2 * marginHeight;
- return size;
- }
-
- private Point computeTextSize(int wHint) {
- Paragraph[] paragraphs = model.getParagraphs();
-
- GC gc = new GC(RichText.this);
- gc.setFont(getFont());
-
- Locator loc = new Locator();
-
- int width = wHint != SWT.DEFAULT ? wHint : 0;
-
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
-
- for (int i = 0; i < paragraphs.length; i++) {
- Paragraph p = paragraphs[i];
-
- if (i > 0
- && getParagraphsSeparated()
- && p.getAddVerticalSpace())
- loc.y += getParagraphSpacing(lineHeight);
-
- loc.rowHeight = 0;
- loc.indent = p.getIndent();
- loc.x = p.getIndent();
-
- ParagraphSegment[] segments = p.getSegments();
- if (segments.length > 0) {
- for (int j = 0; j < segments.length; j++) {
- ParagraphSegment segment = segments[j];
- segment.advanceLocator(gc, wHint, loc, imageTable);
- width = Math.max(width, loc.width);
- }
- loc.y += loc.rowHeight;
- } else {
- // empty new line
- loc.y += lineHeight;
- }
- }
- gc.dispose();
- return new Point(width, loc.y);
- }
- protected void layout(Composite composite, boolean flushCache) {
- }
- }
- /**
- * Contructs a new rich text widget in the provided parent and using the
- * styles.
- *
- * @param parent
- * rich text parent control
- * @param style
- * the widget style
- */
- public RichText(Composite parent, int style) {
- super(parent, SWT.WRAP | style);
- setLayout(new RichTextLayout());
- model = new RichTextModel();
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- model.dispose();
- }
- });
- addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- paint(e);
- }
- });
- addListener(SWT.KeyDown, new Listener() {
- public void handleEvent(Event e) {
- if (e.character == '\r') {
- activateSelectedLink();
- return;
- }
- }
- });
- addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event e) {
- switch (e.detail) {
- case SWT.TRAVERSE_PAGE_NEXT :
- case SWT.TRAVERSE_PAGE_PREVIOUS :
- case SWT.TRAVERSE_ARROW_NEXT :
- case SWT.TRAVERSE_ARROW_PREVIOUS :
- e.doit = false;
- return;
- }
- if (!model.hasFocusSegments()) {
- e.doit = true;
- return;
- }
- if (e.detail == SWT.TRAVERSE_TAB_NEXT)
- e.doit = advance(true);
- else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)
- e.doit = advance(false);
- else if (e.detail != SWT.TRAVERSE_RETURN)
- e.doit = true;
- }
- });
- addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- if (!hasFocus) {
- hasFocus = true;
- handleFocusChange();
- }
- }
- public void focusLost(FocusEvent e) {
- if (hasFocus) {
- hasFocus = false;
- handleFocusChange();
- }
- }
- });
- addMouseListener(new MouseListener() {
- public void mouseDoubleClick(MouseEvent e) {
- }
- public void mouseDown(MouseEvent e) {
- // select a link
- handleMouseClick(e, true);
- }
- public void mouseUp(MouseEvent e) {
- // activate a link
- handleMouseClick(e, false);
- }
- });
- addMouseTrackListener(new MouseTrackListener() {
- public void mouseEnter(MouseEvent e) {
- handleMouseMove(e);
- }
- public void mouseExit(MouseEvent e) {
- if (entered != null) {
- exitLink(entered);
- paintLinkHover(entered, false);
- entered = null;
- setCursor(null);
- }
- }
- public void mouseHover(MouseEvent e) {
- handleMouseHover(e);
- }
- });
- addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- handleMouseMove(e);
- }
- });
- initAccessible();
- makeActions();
- }
-
- /**
- * Test for focus.
- *
- * @return <samp>true</samp> if the widget has focus.
- */
- public boolean getFocus() {
- return hasFocus;
- }
- /**
- * Test if the widget is currently processing the text it is about to
- * render.
- *
- * @return <samp>true</samp> if the widget is still loading the text,
- * <samp>false</samp> otherwise.
- */
- public boolean isLoading() {
- return loading;
- }
- /**
- * Returns the text that will be shown in the control while the real
- * content is loading.
- *
- * @return loading text message
- */
-
- public String getLoadingText() {
- return loadingText;
- }
- /**
- * Sets the text that will be shown in the control while the real content
- * is loading. This is significant when content to render is loaded from
- * the input stream that created from a remote URL.
- *
- * @param loadingText
- * loading text message
- */
-
- public void setLoadingText(String loadingText) {
- this.loadingText = loadingText;
- }
-
- /**
- * If paragraphs are separated, spacing will be added between them.
- * Otherwise, new paragraphs will simply start on a new line with no
- * spacing.
- *
- * @param value
- * <samp>true</samp> if paragraphs are separated,</samp>
- * false</samp> otherwise.
- */
-
- public void setParagraphsSeparated(boolean value) {
- paragraphsSeparated = value;
- }
-
- /**
- * Tests if there is some inter-paragraph spacing.
- *
- * @return <samp>true</samp> if paragraphs are separated, <samp>false
- * </samp> otherwise.
- */
-
- public boolean getParagraphsSeparated() {
- return paragraphsSeparated;
- }
-
-
- /**
- * Registers the image referenced by the provided key.
- * <p>
- * For <samp>img</samp> tags, an object of a type <samp>Image</samp>
- * must be registered using the key equivalent to the value of the <samp>
- * href</samp> attribute.
- * @param key
- * unique key that matches the value of the <samp>href</samp>
- * attribute.
- * @param image
- * an object of a type <samp>Image</samp>.
- */
- public void setImage(String key, Image image) {
- imageTable.put(key, image);
- }
- /**
- * Renders the provided text. Text can be rendered as-is, or by parsing the
- * formatting tags. Optionally, untagged text can be converted to
- * hyperlinks.
- *
- * @param text
- * the text to render
- * @param parseTags
- * if <samp>true</samp>, formatting tags will be parsed.
- * Otherwise, text will be rendered as-is.
- * @param expandURLs
- * if <samp>true</samp>, URLs found in the untagged text will
- * be converted into hyperlinks.
- */
- public void setText(String text, boolean parseTags, boolean expandURLs) {
- try {
- if (parseTags)
- model.parseTaggedText(text, expandURLs);
- else
- model.parseRegularText(text, expandURLs);
- } catch (CoreException e) {
- FormsPlugin.logException(e);
- } finally {
- loading = false;
- }
- }
- /**
- * Renders the contents of the stream. Optionally, URLs in untagged text
- * can be converted into hyperlinks.
- *
- * @param is
- * stream to render
- * @param expandURLs
- * if <samp>true</samp>, URLs found in untagged text will be
- * converted into hyperlinks.
- */
- public void setContents(InputStream is, boolean expandURLs) {
- try {
- model.parseInputStream(is, expandURLs);
- } catch (CoreException e) {
- FormsPlugin.logException(e);
- } finally {
- loading = false;
- }
- }
- /**
- * Sets the focus to the first hyperlink, or the widget itself if there are
- * no hyperlinks.
- *
- * @return <samp>true</samp> if the control got focus, <samp>false
- * </samp> otherwise.
- */
-
- public boolean setFocus() {
- /*
- * if (!model.hasFocusSegments()) return false;
- */
- return super.setFocus();
- }
-
- /**
- * Returns the hyperlink settings that are in effect for this control.
- *
- * @return current hyperlinks settings
- */
-
- public HyperlinkSettings getHyperlinkSettings() {
- return model.getHyperlinkSettings();
- }
-
- /**
- * Sets the hyperlink settings to be used for this control. Settings will
- * affect things like hyperlink color, rendering style, cursor etc.
- *
- * @param settings
- * hyperlink settings for this control
- */
- public void setHyperlinkSettings(HyperlinkSettings settings) {
- model.setHyperlinkSettings(settings);
- }
-
- /**
- * Adds a listener that will handle hyperlink events.
- * @param listener
- */
- public void addHyperlinkListener(HyperlinkListener listener) {
- if (listeners == null)
- listeners = new Vector();
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
- /**
- * Removes the hyperlink listener.
- * @param listener
- */
- public void removeHyperlinkListener(HyperlinkListener listener) {
- if (listeners == null)
- return;
- listeners.remove(listener);
- }
-
- /**
- * Context menu is about to show - override to add actions to the menu
- * manager. Subclasses are required to call 'super' when overriding.
- *
- * @param manager
- * the pop-up menu manager
- */
- protected void contextMenuAboutToShow(IMenuManager manager) {
- HyperlinkSegment link = model.getSelectedLink();
- if (link != null)
- contributeLinkActions(manager, link);
- }
-
-
- private void makeActions() {
- /*
- openAction = new Action() {
- public void run() {
- activateSelectedLink();
- }
- };
- openAction.setText(
- FormsPlugin.getResourceString("FormEgine.linkPopup.open"));
- copyShortcutAction = new Action() {
- public void run() {
- copyShortcut(model.getSelectedLink());
- }
- };
- copyShortcutAction.setText(
- FormsPlugin.getResourceString("FormEgine.linkPopup.copyShortcut"));
- */
- }
-
- private String getAcessibleText() {
- return model.getAccessibleText();
- }
-
- private void initAccessible() {
- Accessible accessible = getAccessible();
- accessible.addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = getAcessibleText();
- }
-
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
-
- accessible
- .addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point pt = toControl(new Point(e.x, e.y));
- e.childID =
- (getBounds().contains(pt))
- ? ACC.CHILDID_SELF
- : ACC.CHILDID_NONE;
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_TEXT;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = ACC.STATE_READONLY;
- }
- });
- }
-
- private void handleMouseClick(MouseEvent e, boolean down) {
- if (down) {
- // select a hyperlink
- HyperlinkSegment segmentUnder = model.findHyperlinkAt(e.x, e.y);
- if (segmentUnder != null) {
- HyperlinkSegment oldLink = model.getSelectedLink();
- model.selectLink(segmentUnder);
- enterLink(segmentUnder);
- paintFocusTransfer(oldLink, segmentUnder);
- }
- mouseDown = true;
- //dragOrigin = new Point(e.x, e.y);
- } else {
- if (e.button == 1) {
- HyperlinkSegment segmentUnder = model.findHyperlinkAt(e.x, e.y);
- if (segmentUnder != null) {
- activateLink(segmentUnder);
- }
- }
- mouseDown = false;
- }
- }
- private void handleMouseHover(MouseEvent e) {
- }
- private void handleMouseMove(MouseEvent e) {
- if (mouseDown) {
- handleDrag(e);
- return;
- }
- TextSegment segmentUnder = model.findSegmentAt(e.x, e.y);
-
- if (segmentUnder == null) {
- if (entered != null) {
- exitLink(entered);
- paintLinkHover(entered, false);
- entered = null;
- }
- setCursor(null);
- } else {
- if (segmentUnder instanceof HyperlinkSegment) {
- HyperlinkSegment linkUnder = (HyperlinkSegment) segmentUnder;
- if (entered == null) {
- entered = linkUnder;
- enterLink(linkUnder);
- paintLinkHover(entered, true);
- setCursor(
- model.getHyperlinkSettings().getHyperlinkCursor());
- }
- } else {
- if (entered != null) {
- exitLink(entered);
- paintLinkHover(entered, false);
- entered = null;
- }
- setCursor(model.getHyperlinkSettings().getTextCursor());
- }
- }
- }
-
- private boolean advance(boolean next) {
- HyperlinkSegment current = model.getSelectedLink();
- if (current != null)
- exitLink(current);
-
- boolean valid = model.traverseLinks(next);
-
- HyperlinkSegment newLink = model.getSelectedLink();
-
- if (valid)
- enterLink(newLink);
- paintFocusTransfer(current, newLink);
- if (newLink != null)
- ensureVisible(newLink);
- return !valid;
- }
-
- private void handleFocusChange() {
- if (hasFocus) {
- model.traverseLinks(true);
- enterLink(model.getSelectedLink());
- paintFocusTransfer(null, model.getSelectedLink());
- ensureVisible(model.getSelectedLink());
- } else {
- paintFocusTransfer(model.getSelectedLink(), null);
- model.selectLink(null);
- }
- }
-
- private void enterLink(HyperlinkSegment link) {
- if (link == null || listeners==null)
- return;
- int size = listeners.size();
- HyperlinkEvent e = new HyperlinkEvent(this, link.getHref(), link.getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkEntered(e);
- }
- }
-
- private void exitLink(HyperlinkSegment link) {
- if (link == null || listeners==null)
- return;
- int size = listeners.size();
- HyperlinkEvent e = new HyperlinkEvent(this, link.getHref(), link.getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkExited(e);
- }
- }
-
- private void paintLinkHover(HyperlinkSegment link, boolean hover) {
- GC gc = new GC(this);
-
- HyperlinkSettings settings = getHyperlinkSettings();
-
- gc.setForeground(
- hover ? settings.getActiveForeground() : settings.getForeground());
- gc.setBackground(getBackground());
- gc.setFont(getFont());
- boolean selected = (link == model.getSelectedLink());
- link.repaint(gc, hover);
- if (selected) {
- link.paintFocus(gc, getBackground(), getForeground(), false);
- link.paintFocus(gc, getBackground(), getForeground(), true);
- }
- gc.dispose();
- }
-
- private void activateSelectedLink() {
- HyperlinkSegment link = model.getSelectedLink();
- if (link != null)
- activateLink(link);
- }
-
- private void activateLink(HyperlinkSegment link) {
- setCursor(model.getHyperlinkSettings().getBusyCursor());
- if (listeners!=null) {
- int size = listeners.size();
- HyperlinkEvent e = new HyperlinkEvent(this, link.getHref(), link.getText());
- for (int i = 0; i < size; i++) {
- HyperlinkListener listener = (HyperlinkListener) listeners.get(i);
- listener.linkActivated(e);
- }
- }
- if (!isDisposed())
- setCursor(model.getHyperlinkSettings().getHyperlinkCursor());
- }
-
- private void paint(PaintEvent e) {
- int width = getClientArea().width;
-
- GC gc = e.gc;
- gc.setFont(getFont());
- gc.setForeground(getForeground());
- gc.setBackground(getBackground());
-
- Locator loc = new Locator();
- loc.marginWidth = marginWidth;
- loc.marginHeight = marginHeight;
- loc.x = marginWidth;
- loc.y = marginHeight;
-
- FontMetrics fm = gc.getFontMetrics();
- int lineHeight = fm.getHeight();
-
- if (loading) {
- int textWidth = gc.textExtent(loadingText).x;
- gc.drawText(
- loadingText,
- width / 2 - textWidth / 2,
- getClientArea().height / 2 - lineHeight / 2);
- return;
- }
-
- Paragraph[] paragraphs = model.getParagraphs();
-
- HyperlinkSegment selectedLink = model.getSelectedLink();
-
- for (int i = 0; i < paragraphs.length; i++) {
- Paragraph p = paragraphs[i];
-
- if (i > 0 && paragraphsSeparated && p.getAddVerticalSpace())
- loc.y += getParagraphSpacing(lineHeight);
-
- loc.indent = p.getIndent();
- loc.resetCaret();
- loc.rowHeight = 0;
- p.paint(gc, width, loc, lineHeight, imageTable, selectedLink);
- }
- }
- private int getParagraphSpacing(int lineHeight) {
- return lineHeight / 2;
- }
-
- private void paintFocusTransfer(
- HyperlinkSegment oldLink,
- HyperlinkSegment newLink) {
- GC gc = new GC(this);
- Color bg = getBackground();
- Color fg = getForeground();
-
- gc.setFont(getFont());
-
- if (oldLink != null) {
- gc.setBackground(bg);
- gc.setForeground(fg);
- oldLink.paintFocus(gc, bg, fg, false);
- }
- if (newLink != null) {
- //ensureVisible(newLink);
- gc.setBackground(bg);
- gc.setForeground(fg);
- newLink.paintFocus(gc, bg, fg, true);
- }
- gc.dispose();
- }
-
- private void contributeLinkActions(
- IMenuManager manager,
- HyperlinkSegment link) {
- manager.add(openAction);
- manager.add(copyShortcutAction);
- manager.add(new Separator());
- }
-
- private void copyShortcut(HyperlinkSegment link) {
- String text = link.getText();
- Clipboard clipboard = new Clipboard(getDisplay());
- clipboard.setContents(
- new Object[] { text },
- new Transfer[] { TextTransfer.getInstance()});
- }
-
- private void ensureVisible(HyperlinkSegment segment) {
- if (segment==null) return;
- Rectangle bounds = segment.getBounds();
- ScrolledComposite scomp = getScrolledComposite();
- if (scomp == null)
- return;
- Point origin = FormUtil.getControlLocation(scomp, this);
- origin.x += bounds.x;
- origin.y += bounds.y;
- FormUtil.ensureVisible(
- scomp,
- origin,
- new Point(bounds.width, bounds.height));
- }
- private ScrolledComposite getScrolledComposite() {
- Composite parent = getParent();
- while (parent != null) {
- if (parent instanceof ScrolledComposite)
- return (ScrolledComposite) parent;
- parent = parent.getParent();
- }
- return null;
- }
-
- private void handleDrag(MouseEvent e) {
- }
- public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- Point size;
- RichTextLayout layout = (RichTextLayout)getLayout();
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = new Point (wHint, hHint);
- }
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
- return new Point (trim.width, trim.height);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledPageBook.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledPageBook.java
deleted file mode 100644
index 11fe4ab..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledPageBook.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Created on Jan 24, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.ui.forms.widgets;
-import java.util.Hashtable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.internal.widgets.WrappedPageBook;
-/**
- * @author dejan
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public class ScrolledPageBook extends SharedScrolledComposite {
- private WrappedPageBook pageBook;
- private Hashtable pages;
- private Composite emptyPage;
- private Composite currentPage;
-/**
- *
- * @param parent
- * @param style
- */
- public ScrolledPageBook(Composite parent) {
- this(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- }
- public ScrolledPageBook(Composite parent, int style) {
- super(parent, style);
- pageBook = new WrappedPageBook(this, SWT.NULL);
- setContent(pageBook);
- pages = new Hashtable();
- setExpandHorizontal(true);
- setExpandVertical(true);
- this.addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event e) {
- switch (e.detail) {
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- e.doit = true;
- break;
- }
- }
- });
- }
-
- public Point computeSize (int wHint, int hHint, boolean changed) {
- Rectangle trim = computeTrim (0, 0, 10, 10);
- return new Point (trim.width, trim.height);
- }
-/**
- *
- * @param key
- * @return
- */
- public boolean hasPage(Object key) {
- return pages.containsKey(key);
- }
-/**
- *
- * @param key
- * @return
- */
- public Composite createPage(Object key) {
- Composite page = createPage();
- pages.put(key, page);
- return page;
- }
-
- public Composite getContainer() {
- return pageBook;
- }
-
- public void registerPage(Object key, Composite page) {
- pages.put(key, page);
- }
-/**
- *
- * @param key
- */
- public void removePage(Object key) {
- Composite page = (Composite) pages.get(key);
- if (page != null) {
- pages.remove(key);
- page.dispose();
- showEmptyPage();
- }
- }
-/**
- *
- * @param key
- */
- public void showPage(Object key) {
- Composite page = (Composite) pages.get(key);
- if (page != null) {
- pageBook.showPage(page);
- if (currentPage!=null && currentPage!=page) {
- // switching pages - force layout
- page.layout(false);
- }
- currentPage = page;
- } else {
- showEmptyPage();
- }
- reflow(true);
- }
-/**
- *
- *
- */
- public void showEmptyPage() {
- if (emptyPage == null) {
- emptyPage = createPage();
- emptyPage.setLayout(new GridLayout());
- }
- pageBook.showPage(emptyPage);
- currentPage = emptyPage;
- reflow(true);
- }
- public boolean setFocus() {
- if (currentPage!=null)
- return currentPage.setFocus();
- return super.setFocus();
- }
- public Control getCurrentPage() {
- return currentPage;
- }
- private Composite createPage() {
- Composite page = new LayoutComposite(pageBook, SWT.NULL);
- page.setBackground(getBackground());
- page.setForeground(getForeground());
- return page;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledRichText.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledRichText.java
deleted file mode 100644
index ba348b6..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ScrolledRichText.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.*;
-
-public class ScrolledRichText {
- private ScrolledComposite scomp;
- private RichText richText;
- private String text;
- private FormToolkit toolkit;
- private int style;
-
- public ScrolledRichText(int style) {
- this.style = style;
- }
-
- public ScrolledRichText(FormColors colors, int style) {
- this.style = style;
- toolkit = new FormToolkit(colors);
- }
-
- public void createControl(Composite parent) {
- if (toolkit==null) toolkit = new FormToolkit(parent.getDisplay());
- scomp = new ScrolledComposite(parent, style);
- scomp.setBackground(toolkit.getColors().getBackground());
- richText = toolkit.createRichText(scomp, false);
- richText.marginWidth = 2;
- richText.marginHeight = 2;
- richText.setHyperlinkSettings(toolkit.getHyperlinkGroup());
- scomp.setContent(richText);
- scomp.addListener(SWT.Resize, new Listener() {
- public void handleEvent(Event e) {
- updateSize();
- }
- });
- richText.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (toolkit != null) {
- toolkit.dispose();
- toolkit = null;
- }
- }
- });
- if (text != null)
- loadText(text);
- }
-
- public Control getControl() {
- return scomp;
- }
-
- public void setText(String text) {
- this.text = text;
- loadText(text);
- }
-
- private void loadText(String text) {
- if (richText != null) {
- String markup = text;
- if (!markup.startsWith("<form>"))
- markup = "<form>" + text + "</form>";
- richText.setText(markup, true, false);
- updateSize();
- richText.redraw();
- scomp.layout();
- }
- }
- private void updateSize() {
- Rectangle ssize = scomp.getClientArea();
- int swidth = ssize.width;
- ScrollBar vbar = scomp.getVerticalBar();
- if (vbar != null) {
- swidth -= vbar.getSize().x;
- }
- Point size = richText.computeSize(swidth, SWT.DEFAULT, true);
- richText.setSize(size);
- }
- public void dispose() {
- toolkit.dispose();
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Section.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Section.java
deleted file mode 100644
index 9234ad8..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Section.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.*;
-
-/**
- * A variation of the expandable composite that adds optional
- * description below the title.
- */
-
-public class Section extends ExpandableComposite {
- /**
- * Description style. If used, description will be rendered below the
- * title.
- */
- public static final int DESCRIPTION = 1 << 7;
- private Label descriptionLabel;
- private Control separator;
-
- public Section(Composite parent, int style) {
- super(parent, SWT.NULL, style);
- if ((style & DESCRIPTION)!=0) {
- descriptionLabel = new Label(this, SWT.WRAP);
- }
- }
-
- protected void internalSetExpanded(boolean expanded) {
- super.internalSetExpanded(expanded);
- reflow();
- }
-
- protected void reflow() {
- setRedraw(false);
- getParent().setRedraw(false);
- layout(true);
- getParent().layout(true);
- setRedraw(true);
- getParent().setRedraw(true);
- }
-
- public void setDescription(String description) {
- if (descriptionLabel!=null)
- descriptionLabel.setText(description);
- }
-
- public String getDescription() {
- if (descriptionLabel!=null)
- return descriptionLabel.getText();
- return null;
- }
- /**
- * Sets the separator control of this section. The separator
- * must not be <samp>null</samp> and must be a direct child of this
- * container. If defined, separator will be placed below
- * the title text and will remain visible regardless of
- * the expansion state.
- *
- * @param separator
- * the separator that will be placed below the title text.
- */
- public void setSeparatorControl(Control separator) {
- Assert.isTrue(separator != null && separator.getParent().equals(this));
- this.separator = separator;
- }
-
- /**
- * Returns the control that is used as a separator betweeen
- * the title and the client, or <samp>null</samp> if not set.
- * @return separator control or <samp>null</samp> if not set.
- */
-
- public Control getSeparatorControl() {
- return separator;
- }
-
- public void setBackground(Color bg) {
- super.setBackground(bg);
- if (descriptionLabel!=null)
- descriptionLabel.setBackground(bg);
- }
-
- public void setForeground(Color fg) {
- super.setForeground(fg);
- if (descriptionLabel!=null)
- descriptionLabel.setForeground(fg);
- }
- protected Control getDescriptionControl() {
- return descriptionLabel;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java
deleted file mode 100644
index b633908..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- *
- * @since 3.0
- */
-
-public abstract class SharedScrolledComposite extends ScrolledComposite {
- private static final int H_SCROLL_INCREMENT = 5;
- private static final int V_SCROLL_INCREMENT = 64;
-
- /**
- *
- */
- public SharedScrolledComposite(Composite parent, int style) {
- super(parent, style);
- addListener(SWT.Resize, new Listener() {
- public void handleEvent(Event e) {
- reflow(true);
- }
- });
- initializeScrollBars();
- }
-
- public void setForeground(Color fg) {
- super.setForeground(fg);
- getContent().setForeground(fg);
- }
-
- /**
- * Sets the background color of the form. This color will also be used for
- * the body.
- */
- public void setBackground(Color bg) {
- super.setBackground(bg);
- getContent().setBackground(bg);
- }
- /**
- * Sets the font of the form. This font will be used to render the title
- * text. It will not affect the body.
- */
- public void setFont(Font font) {
- super.setFont(font);
- getContent().setFont(font);
- }
-
- public boolean setFocus() {
- if (getContent()!=null)
- return getContent().setFocus();
- else
- return super.setFocus();
- }
-
- /**
- * Recomputes the body layout and form scroll bars. The method should be
- * used when changes somewhere in the form body invalidate the current
- * layout and/or scroll bars.
- *
- * @param flushCache
- */
- public void reflow(boolean flushCache) {
- Composite c = (Composite) getContent();
- Rectangle clientArea = getClientArea();
- if (c == null)
- return;
- c.layout(flushCache);
- Point newSize =
- c.computeSize(
- FormUtil.getWidthHint(clientArea.width, c),
- FormUtil.getHeightHint(clientArea.height, c),
- flushCache);
- c.setSize(newSize);
- setMinSize(newSize);
- FormUtil.updatePageIncrement(this);
- }
- private void initializeScrollBars() {
- ScrollBar hbar = getHorizontalBar();
- if (hbar != null) {
- hbar.setIncrement(H_SCROLL_INCREMENT);
- }
- ScrollBar vbar = getVerticalBar();
- if (vbar != null) {
- vbar.setIncrement(V_SCROLL_INCREMENT);
- }
- FormUtil.updatePageIncrement(this);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapData.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapData.java
deleted file mode 100644
index 613102f..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapData.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Layout data used in conjunction with <code>HTMLTableLayout</code>.
- * Children in a composite that uses this layout should call
- * <samp>setLayoutData</samp> and pass an instance of this class
- * to control physical placement in the parent.
- *
- * @see HTMLTableLayout
- * @since 3.0
- */
-
-public class TableWrapData {
-/**
- * The control will be left-justified.
- */
- public static final int LEFT = 1 << 1;
-/**
- * The control will be centered horizontally.
- */
- public static final int CENTER = 1 << 2;
-/**
- * The control will be right-justified.
- */
- public static final int RIGHT = 1 << 3;
-/**
- * The control will be aligned with the top of the cell.
- */
- public static final int TOP = 1 << 4;
-/**
- * The control will be centered vertically.
- */
- public static final int MIDDLE = 1<< 5;
-/**
- * The control will be aligned with the bottom of the cell.
- */
- public static final int BOTTOM = 1 << 6;
-/**
- * The control will have the same width as the column it occupies.
- */
- public static final int FILL = 1<< 7;
-/**
- * In addition to filling width or height, the control will
- * take part in allocation of any excess space.
- */
- public static final int FILL_GRAB = 1 << 8;
-/**
- * Number of columns to span (defualt is 1).
- */
- public int colspan=1;
-/**
- * Number of rows to span (default is 1).
- */
- public int rowspan=1;
-/**
- * Horizontal alignment (default is LEFT).
- */
- public int align = LEFT;
-/**
- * Vertical alignment (default is TOP).
- */
- public int valign = TOP;
-/**
- * Horizontal indent (default is 0).
- */
- public int indent = 0;
-/**
- * Maximum width of the control (default is SWT.DEFAULT).
- */
- public int maxWidth = SWT.DEFAULT;
-/**
- * Maximum height of the control (default is SWT.DEFAULT).
- */
- public int maxHeight = SWT.DEFAULT;
-/**
- * Height hint of the control (default is SWT.DEFAULT).
- */
- public int heightHint = SWT.DEFAULT;
-/**
- * If <code>true</code>, will grab any excess horizontal space
- * (default is <code>false</code>).
- */
- public boolean grabHorizontal=false;
- /**
- * If <code>true</code>, will grab any excess vertical space
- * (default is <code>false</code>). Note that since
- * TableWrapLayout works top-down and does not grows to fill
- * the parent, this only applies to space created by
- * children that span multiple rows.
- */
- public boolean grabVertical=false;
-
- int childIndex;
- boolean isItemData=true;
- int compWidth;
- Point compSize;
-
-/**
- * The default constructor.
- *
- */
- public TableWrapData() {
- }
-
- /**
- * The convinience constructor - allows passing the horizontal
- * alignment style.
- * @param align horizontal alignment (LEFT, MIDDLE, RIGHT, FILL or FILL_GRAB).
- */
- public TableWrapData(int align) {
- this(align, TOP, 1, 1);
- }
-
-/**
- * The convinience constructor - allows passing the alignment styles.
- * @param align horizontal alignment (LEFT, CENTER, RIGHT, FILL or FILL_GRAB).
- * @param valign vertical alignment (TOP, MIDDLE, BOTTOM, FILL or FILL_GRAB).
- */
- public TableWrapData(int align, int valign) {
- this(align, valign, 1, 1);
- }
-
-/**
- * The convinience constructor - allows passing the alignment styles,
- * column and row spans.
- * @param align horizontal alignment (LEFT, CENTER, RIGHT, FILL or FILL_GRAB).
- * @param valign vertical alignment (TOP, MIDDLE, BOTTOM, FILL or FILL_GRAB)
- * @param rowspan row span (1 or more)
- * @param colspan column span (1 or more)
- */
- public TableWrapData(int align, int valign, int rowspan, int colspan) {
- if (align==FILL_GRAB) {
- align = FILL;
- grabHorizontal = true;
- }
- else this.align = align;
- if (valign==FILL_GRAB) {
- valign = FILL;
- grabVertical = true;
- }
- else this.valign = valign;
- this.rowspan = rowspan;
- this.colspan = colspan;
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapLayout.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapLayout.java
deleted file mode 100644
index d15e13b..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TableWrapLayout.java
+++ /dev/null
@@ -1,812 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import java.util.*;
-import java.util.Vector;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * This implementation of the layout algorithm attempts to position controls in
- * the composite using a two-pass autolayout HTML table altorithm recommeded by
- * HTML 4.01 W3C specification. The main differences with GridLayout is that it
- * has two passes and that width and height are not calculated in the same
- * pass.
- * <p>
- * The advantage of the algorithm over GridLayout is that it is capable of
- * flowing text controls capable of line wrap. These controls do not have
- * natural 'preferred size'. Instead, they are capable of providing the
- * required height if the width is set. Consequently, this algorithm first
- * calculates the widths that will be assigned to columns, and then passes
- * those widths to the controls to calculate the height. When a composite with
- * this layout is a child of the scrolling composite, they should interact in
- * such a way that reduction in the scrolling composite width results in the
- * reflow and increase of the overall height.
- * <p>
- * If none of the columns contain expandable and wrappable controls, the
- * end-result will be similar to the one provided by GridLayout. The difference
- * will show up for layouts that contain controls whose minimum and maximum
- * widths are not the same.
- * @since 3.0
- */
-
-public class TableWrapLayout extends Layout implements ILayoutExtension {
- public int numColumns = 1;
- public int leftMargin = 5;
- public int rightMargin = 5;
- public int topMargin = 5;
- public int bottomMargin = 5;
- public int horizontalSpacing = 5;
- public int verticalSpacing = 5;
- public boolean makeColumnsEqualWidth = false;
-
- private boolean initialLayout = true;
- private Vector grid = null;
- private Hashtable rowspans;
- private int[] minColumnWidths, maxColumnWidths;
- private int widestColumnWidth;
- private int[] growingColumns;
- private int[] growingRows;
-
- class RowSpan {
- Control child;
- int row;
- int column;
- int height;
- int totalHeight;
-
- public RowSpan(Control child, int column, int row) {
- this.child = child;
- this.column = column;
- this.row = row;
- }
- public void update(int currentRow, int rowHeight) {
- TableWrapData td = (TableWrapData)child.getLayoutData();
- if (currentRow - row <= td.rowspan -1) {
- totalHeight += rowHeight;
- if (currentRow > row)
- totalHeight += verticalSpacing;
- }
- }
- public int getRequiredHeightIncrease() {
- if (totalHeight < height)
- return height - totalHeight;
- else
- return 0;
- }
- }
-
- /**
- * Implements ILayoutExtension.
- */
- public int computeMinimumWidth(Composite parent, boolean changed) {
- changed = true;
- initializeIfNeeded(parent, changed);
- if (initialLayout) {
- changed = true;
- initialLayout = false;
- }
- if (grid == null || changed) {
- changed = true;
- grid = new Vector();
- createGrid(parent);
- }
- if (minColumnWidths == null)
- minColumnWidths = new int[numColumns];
- for (int i = 0; i < numColumns; i++) {
- minColumnWidths[i] = 0;
- }
- return internalGetMinimumWidth(parent, changed);
- }
- /**
- * Implements ILayoutExtension.
- */
- public int computeMaximumWidth(Composite parent, boolean changed) {
- changed = true;
- initializeIfNeeded(parent, changed);
- if (initialLayout) {
- changed = true;
- initialLayout = false;
- }
- if (grid == null || changed) {
- changed = true;
- grid = new Vector();
- createGrid(parent);
- }
- if (maxColumnWidths == null)
- maxColumnWidths = new int[numColumns];
- for (int i = 0; i < numColumns; i++) {
- maxColumnWidths[i] = 0;
- }
- return internalGetMaximumWidth(parent, changed);
- }
-
- /**
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite parent, boolean changed) {
- Rectangle clientArea = parent.getClientArea();
- Control[] children = parent.getChildren();
- if (children.length == 0)
- return;
- int parentWidth = clientArea.width;
- changed = true;
- initializeIfNeeded(parent, changed);
- if (initialLayout) {
- changed = true;
- initialLayout = false;
- }
- if (grid == null || changed) {
- changed = true;
- grid = new Vector();
- createGrid(parent);
- }
- resetColumnWidths();
- int minWidth = internalGetMinimumWidth(parent, changed);
- int maxWidth = internalGetMaximumWidth(parent, changed);
-
- int tableWidth = parentWidth;
-
- int[] columnWidths;
-
- if (parentWidth <= minWidth) {
- tableWidth = minWidth;
- if (makeColumnsEqualWidth) {
- columnWidths = new int[numColumns];
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = widestColumnWidth;
- }
- } else
- columnWidths = minColumnWidths;
- } else if (parentWidth > maxWidth) {
- if (growingColumns.length == 0) {
- tableWidth = maxWidth;
- columnWidths = maxColumnWidths;
- } else {
- columnWidths = new int[numColumns];
- int colSpace = tableWidth - leftMargin - rightMargin;
- colSpace -= (numColumns - 1) * horizontalSpacing;
- int extra = parentWidth - maxWidth;
- int colExtra = extra / growingColumns.length;
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = maxColumnWidths[i];
-
- if (isGrowingColumn(i)) {
- columnWidths[i] += colExtra;
- }
- }
- }
- } else {
- columnWidths = new int[numColumns];
- if (makeColumnsEqualWidth) {
- int colSpace = tableWidth - leftMargin - rightMargin;
- colSpace -= (numColumns - 1) * horizontalSpacing;
- int col = colSpace / numColumns;
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = col;
- }
- } else {
- columnWidths =
- assignExtraSpace(tableWidth, maxWidth, minWidth);
- }
- }
- int y = topMargin;
- int [] rowHeights = computeRowHeights(children, columnWidths, changed);
-
- for (int i=0; i<grid.size(); i++) {
- int rowHeight = rowHeights[i];
- int x = leftMargin;
- TableWrapData[] row = (TableWrapData[]) grid.elementAt(i);
- for (int j = 0; j < numColumns; j++) {
- TableWrapData td = row[j];
-
- if (td.isItemData) {
- Control child = children[td.childIndex];
- placeControl(child, td, x, y, rowHeights, i);
- }
- x += columnWidths[j];
- if (j < numColumns - 1)
- x += horizontalSpacing;
- }
- y += rowHeight + verticalSpacing;
- }
- }
-
- int [] computeRowHeights(Control [] children, int [] columnWidths, boolean changed) {
- int [] rowHeights = new int[grid.size()];
-
- for (int i = 0; i < grid.size(); i++) {
- TableWrapData[] row = (TableWrapData[]) grid.elementAt(i);
- rowHeights[i] = 0;
-
- for (int j = 0; j < numColumns; j++) {
- TableWrapData td = row[j];
- if (td.isItemData == false) {
- continue;
- }
- Control child = children[td.childIndex];
- int span = td.colspan;
- int cwidth = 0;
- for (int k = j; k < j + span; k++) {
- cwidth += columnWidths[k];
- if (k < j + span - 1)
- cwidth += horizontalSpacing;
- }
- Point size = computeSize(child, cwidth, changed);
- td.compWidth = cwidth;
-
- if (td.heightHint != SWT.DEFAULT) {
- size = new Point(size.x, td.heightHint);
- }
- td.compSize = size;
- RowSpan rowspan = (RowSpan)rowspans.get(child);
- if (rowspan==null) {
- rowHeights[i] = Math.max(rowHeights[i], size.y);
- }
- else
- rowspan.height = size.y;
- }
- updateRowSpans(i, rowHeights[i]);
- }
- for (Enumeration enum=rowspans.elements(); enum.hasMoreElements();) {
- RowSpan rowspan = (RowSpan)enum.nextElement();
- int increase = rowspan.getRequiredHeightIncrease();
- if (increase==0) continue;
- TableWrapData td = (TableWrapData)rowspan.child.getLayoutData();
- int ngrowing = 0;
- int [] affectedRows = new int [grid.size()];
-
- for (int i=0; i<growingRows.length; i++) {
- int growingRow = growingRows[i];
- if (growingRow>=rowspan.row && growingRow <rowspan.row+td.rowspan) {
- affectedRows[ngrowing++] = growingRow;
- }
- }
- if (ngrowing==0) {
- ngrowing = 1;
- affectedRows[0] = rowspan.row+td.rowspan-1;
- }
- increase += increase % ngrowing;
- int perRowIncrease = increase / ngrowing;
- for (int i=0; i<ngrowing; i++) {
- int growingRow = affectedRows[i];
- rowHeights[growingRow] += perRowIncrease;
- }
- }
- return rowHeights;
- }
-
- boolean isGrowingColumn(int col) {
- if (growingColumns == null)
- return false;
- for (int i = 0; i < growingColumns.length; i++) {
- if (col == growingColumns[i])
- return true;
- }
- return false;
- }
-
- int[] assignExtraSpace(int tableWidth, int maxWidth, int minWidth) {
- int fixedPart =
- leftMargin + rightMargin + (numColumns - 1) * horizontalSpacing;
- int D = maxWidth - minWidth;
-
- int W = tableWidth - fixedPart - minWidth;
-
- int widths[] = new int[numColumns];
-
- int rem = 0;
- for (int i = 0; i < numColumns; i++) {
- int cmin = minColumnWidths[i];
- int cmax = maxColumnWidths[i];
- int d = cmax - cmin;
- int extra = D != 0 ? (d * W) / D : 0;
- if (i < numColumns - 1) {
- widths[i] = cmin + extra;
- rem += widths[i];
- } else {
- widths[i] = tableWidth - fixedPart - rem;
- }
- }
- return widths;
- }
-
- Point computeSize(Control child, int width, boolean changed) {
- int widthArg = width;
- if (!isWrap(child))
- widthArg = SWT.DEFAULT;
- Point size = child.computeSize(widthArg, SWT.DEFAULT, changed);
- return size;
- }
-
- void placeControl(
- Control control,
- TableWrapData td,
- int x,
- int y,
- int [] rowHeights,
- int row) {
- int xloc = x + td.indent;
- int yloc = y;
- int height = td.compSize.y;
- int colWidth = td.compWidth;
- int width = Math.min(td.compSize.x, colWidth);
-
- int slotHeight = rowHeights[row];
- RowSpan rowspan = (RowSpan)rowspans.get(control);
- if (rowspan!=null) {
- slotHeight = 0;
- for (int i=row; i<row+td.rowspan; i++) {
- if (i>row)
- slotHeight += verticalSpacing;
- slotHeight += rowHeights[i];
- }
- }
-
- // align horizontally
- if (td.align == TableWrapData.CENTER) {
- xloc = x + colWidth / 2 - width / 2;
- } else if (td.align == TableWrapData.RIGHT) {
- xloc = x + colWidth - width;
- } else if (td.align == TableWrapData.FILL) {
- width = colWidth;
- }
- // align vertically
- if (td.valign == TableWrapData.MIDDLE) {
- yloc = y + slotHeight / 2 - height / 2;
- } else if (td.valign == TableWrapData.BOTTOM) {
- yloc = y + slotHeight - height;
- } else if (td.valign == TableWrapData.FILL) {
- height = slotHeight;
- }
- control.setBounds(xloc, yloc, width, height);
- }
-
- void createGrid(Composite composite) {
- int row, column, rowFill, columnFill;
- Control[] children;
- TableWrapData spacerSpec;
- Vector growingCols = new Vector();
- Vector growingRows = new Vector();
- rowspans = new Hashtable();
- //
- children = composite.getChildren();
- if (children.length == 0)
- return;
-
- //
- grid.addElement(createEmptyRow());
- row = 0;
- column = 0;
-
- // Loop through the children and place their associated layout specs in
- // the
- // grid. Placement occurs left to right, top to bottom (i.e., by row).
- for (int i = 0; i < children.length; i++) {
- // Find the first available spot in the grid.
- Control child = children[i];
- TableWrapData spec = (TableWrapData) child.getLayoutData();
- while (((TableWrapData[]) grid.elementAt(row))[column] != null) {
- column = column + 1;
- if (column >= numColumns) {
- row = row + 1;
- column = 0;
- if (row >= grid.size()) {
- grid.addElement(createEmptyRow());
- }
- }
- }
- // See if the place will support the widget's horizontal span. If
- // not, go to the
- // next row.
- if (column + spec.colspan - 1 >= numColumns) {
- grid.addElement(createEmptyRow());
- row = row + 1;
- column = 0;
- }
-
- // The vertical span for the item will be at least 1. If it is > 1,
- // add other rows to the grid.
- if (spec.rowspan>1) {
- rowspans.put(child, new RowSpan(child, column, row));
- }
- for (int j = 2; j <= spec.rowspan; j++) {
- if (row + j > grid.size()) {
- grid.addElement(createEmptyRow());
- }
- }
-
- // Store the layout spec. Also cache the childIndex. NOTE: That we
- // assume the children of a
- // composite are maintained in the order in which they are created
- // and added to the composite.
- ((TableWrapData[]) grid.elementAt(row))[column] = spec;
- spec.childIndex = i;
-
- if (spec.grabHorizontal) {
- updateGrowingColumns(growingCols, spec, column);
- }
- if (spec.grabVertical) {
- updateGrowingRows(growingRows, spec, row);
- }
-
- // Put spacers in the grid to account for the item's vertical and
- // horizontal
- // span.
- rowFill = spec.rowspan - 1;
- columnFill = spec.colspan - 1;
- for (int r = 1; r <= rowFill; r++) {
- for (int c = 0; c < spec.colspan; c++) {
- spacerSpec = new TableWrapData();
- spacerSpec.isItemData = false;
- ((TableWrapData[]) grid.elementAt(row + r))[column + c] =
- spacerSpec;
- }
- }
- for (int c = 1; c <= columnFill; c++) {
- for (int r = 0; r < spec.rowspan; r++) {
- spacerSpec = new TableWrapData();
- spacerSpec.isItemData = false;
- ((TableWrapData[]) grid.elementAt(row + r))[column + c] =
- spacerSpec;
- }
- }
- column = column + spec.colspan - 1;
- }
-
- // Fill out empty grid cells with spacers.
- for (int k = column + 1; k < numColumns; k++) {
- spacerSpec = new TableWrapData();
- spacerSpec.isItemData = false;
- ((TableWrapData[]) grid.elementAt(row))[k] = spacerSpec;
- }
- for (int k = row + 1; k < grid.size(); k++) {
- spacerSpec = new TableWrapData();
- spacerSpec.isItemData = false;
- ((TableWrapData[]) grid.elementAt(k))[column] = spacerSpec;
- }
- growingColumns = new int[growingCols.size()];
- for (int i = 0; i < growingCols.size(); i++) {
- growingColumns[i] = ((Integer) growingCols.get(i)).intValue();
- }
- this.growingRows = new int[growingRows.size()];
- for (int i = 0; i < growingRows.size(); i++) {
- this.growingRows[i] = ((Integer) growingRows.get(i)).intValue();
- }
- }
-
- private void updateGrowingColumns(
- Vector growingColumns,
- TableWrapData spec,
- int column) {
- int affectedColumn = column + spec.colspan - 1;
- for (int i = 0; i < growingColumns.size(); i++) {
- Integer col = (Integer) growingColumns.get(i);
- if (col.intValue() == affectedColumn)
- return;
- }
- growingColumns.add(new Integer(affectedColumn));
- }
-
- private void updateGrowingRows(
- Vector growingRows,
- TableWrapData spec,
- int row) {
- int affectedRow = row + spec.rowspan - 1;
- for (int i = 0; i < growingRows.size(); i++) {
- Integer irow = (Integer) growingRows.get(i);
- if (irow.intValue() == affectedRow)
- return;
- }
- growingRows.add(new Integer(affectedRow));
- }
-
- private TableWrapData[] createEmptyRow() {
- TableWrapData[] row = new TableWrapData[numColumns];
- for (int i = 0; i < numColumns; i++)
- row[i] = null;
- return row;
- }
-
- /**
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(
- Composite parent,
- int wHint,
- int hHint,
- boolean changed) {
- Control[] children = parent.getChildren();
- if (children.length == 0) {
- return new Point(0, 0);
- }
- int parentWidth = wHint;
- changed = true;
- initializeIfNeeded(parent, changed);
- if (initialLayout) {
- changed = true;
- initialLayout = false;
- }
- if (grid == null || changed) {
- changed = true;
- grid = new Vector();
- createGrid(parent);
- }
- resetColumnWidths();
- int minWidth = internalGetMinimumWidth(parent, changed);
- int maxWidth = internalGetMaximumWidth(parent, changed);
-
- int tableWidth = parentWidth;
-
- int[] columnWidths;
-
- if (parentWidth <= minWidth) {
- tableWidth = minWidth;
- if (makeColumnsEqualWidth) {
- columnWidths = new int[numColumns];
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = widestColumnWidth;
- }
- } else
- columnWidths = minColumnWidths;
- } else if (parentWidth > maxWidth) {
- if (makeColumnsEqualWidth) {
- columnWidths = new int[numColumns];
- int colSpace = parentWidth - leftMargin - rightMargin;
- colSpace -= (numColumns - 1) * horizontalSpacing;
- int col = colSpace / numColumns;
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = col;
- }
- } else {
- tableWidth = maxWidth;
- columnWidths = maxColumnWidths;
- }
- } else {
- columnWidths = new int[numColumns];
- if (makeColumnsEqualWidth) {
- int colSpace = tableWidth - leftMargin - rightMargin;
- colSpace -= (numColumns - 1) * horizontalSpacing;
- int col = colSpace / numColumns;
- for (int i = 0; i < numColumns; i++) {
- columnWidths[i] = col;
- }
- } else {
- columnWidths =
- assignExtraSpace(tableWidth, maxWidth, minWidth);
- }
- }
- int totalHeight = 0;
- int innerHeight = 0;
- // compute widths
- for (int i = 0; i < grid.size(); i++) {
- TableWrapData[] row = (TableWrapData[]) grid.elementAt(i);
- // assign widths, calculate heights
- int rowHeight = 0;
- for (int j = 0; j < numColumns; j++) {
- TableWrapData td = row[j];
- if (td.isItemData == false) {
- continue;
- }
- Control child = children[td.childIndex];
- int span = td.colspan;
- int cwidth = 0;
- for (int k = j; k < j + span; k++) {
- if (k > j)
- cwidth += horizontalSpacing;
- cwidth += columnWidths[k];
- }
- int cy = td.heightHint;
- if (cy == SWT.DEFAULT) {
- Point size = computeSize(child, cwidth, changed);
- cy = size.y;
- }
- RowSpan rowspan = (RowSpan)rowspans.get(child);
- if (rowspan!=null) {
- // don't take the height of this child into acount
- // because it spans multiple rows
- rowspan.height = cy;
- }
- else {
- rowHeight = Math.max(rowHeight, cy);
- }
- }
- updateRowSpans(i, rowHeight);
- if (i>0) innerHeight += verticalSpacing;
- innerHeight += rowHeight;
- }
- if (!rowspans.isEmpty())
- innerHeight = compensateForRowSpans(innerHeight);
- totalHeight = topMargin + innerHeight + bottomMargin;
- return new Point(tableWidth, totalHeight);
- }
-
- private void updateRowSpans(int row, int rowHeight) {
- if (rowspans==null || rowspans.size()==0) return;
- for (Enumeration enum=rowspans.elements(); enum.hasMoreElements();) {
- RowSpan rowspan = (RowSpan)enum.nextElement();
- rowspan.update(row, rowHeight);
- }
- }
- private int compensateForRowSpans(int totalHeight) {
- for (Enumeration enum=rowspans.elements(); enum.hasMoreElements();) {
- RowSpan rowspan = (RowSpan)enum.nextElement();
- totalHeight += rowspan.getRequiredHeightIncrease();
- }
- return totalHeight;
- }
-
- int internalGetMinimumWidth(Composite parent, boolean changed) {
- if (changed)
- calculateMinimumColumnWidths(parent, true);
- int minimumWidth = 0;
-
- widestColumnWidth = 0;
-
- if (makeColumnsEqualWidth) {
- for (int i = 0; i < numColumns; i++) {
- widestColumnWidth =
- Math.max(widestColumnWidth, minColumnWidths[i]);
- }
- }
- for (int i = 0; i < numColumns; i++) {
- if (i > 0)
- minimumWidth += horizontalSpacing;
- if (makeColumnsEqualWidth)
- minimumWidth += widestColumnWidth;
- else
- minimumWidth += minColumnWidths[i];
- }
- // add margins
- minimumWidth += leftMargin + rightMargin;
- return minimumWidth;
- }
-
- int internalGetMaximumWidth(Composite parent, boolean changed) {
- if (changed)
- calculateMaximumColumnWidths(parent, true);
- int maximumWidth = 0;
- for (int i = 0; i < numColumns; i++) {
- if (i > 0)
- maximumWidth += horizontalSpacing;
- maximumWidth += maxColumnWidths[i];
- }
- // add margins
- maximumWidth += leftMargin + rightMargin;
- return maximumWidth;
- }
-
- void resetColumnWidths() {
- if (minColumnWidths == null)
- minColumnWidths = new int[numColumns];
- if (maxColumnWidths == null)
- maxColumnWidths = new int[numColumns];
- for (int i = 0; i < numColumns; i++) {
- minColumnWidths[i] = 0;
- }
- for (int i = 0; i < numColumns; i++) {
- maxColumnWidths[i] = 0;
- }
- }
-
- void calculateMinimumColumnWidths(Composite parent, boolean changed) {
- Control[] children = parent.getChildren();
-
- for (int i = 0; i < grid.size(); i++) {
- TableWrapData[] row = (TableWrapData[]) grid.elementAt(i);
- for (int j = 0; j < numColumns; j++) {
- TableWrapData td = row[j];
- if (td.isItemData == false)
- continue;
- Control child = children[td.childIndex];
- int minWidth = -1;
- if (child instanceof Composite) {
- Composite cc = (Composite) child;
- Layout l = cc.getLayout();
- if (l instanceof ILayoutExtension) {
- minWidth =
- ((ILayoutExtension) l).computeMinimumWidth(
- cc,
- changed);
- }
- }
- if (minWidth == -1) {
- int minWHint = isWrap(child)?0:SWT.DEFAULT;
- Point size =
- child.computeSize(
- minWHint,
- SWT.DEFAULT,
- changed);
- minWidth = size.x;
- }
- minWidth += td.indent;
- minColumnWidths[j] = Math.max(minColumnWidths[j], minWidth);
- }
- }
- }
-
- boolean isWrap(Control control) {
- if (control instanceof Composite
- && ((Composite) control).getLayout() instanceof ILayoutExtension)
- return true;
- return (control.getStyle() & SWT.WRAP) != 0;
- }
-
- void calculateMaximumColumnWidths(Composite parent, boolean changed) {
- Control[] children = parent.getChildren();
-
- for (int i = 0; i < numColumns; i++) {
- maxColumnWidths[i] = 0;
- }
- for (int i = 0; i < grid.size(); i++) {
- TableWrapData[] row = (TableWrapData[]) grid.elementAt(i);
- for (int j = 0; j < numColumns; j++) {
- TableWrapData td = row[j];
- if (td.isItemData == false)
- continue;
- Control child = children[td.childIndex];
- int maxWidth = SWT.DEFAULT;
- if (child instanceof Composite) {
- Composite cc = (Composite) child;
- Layout l = cc.getLayout();
- if (l instanceof ILayoutExtension) {
- maxWidth =
- ((ILayoutExtension) l).computeMaximumWidth(
- cc,
- changed);
- }
- }
- else if (td.maxWidth!=SWT.DEFAULT)
- maxWidth = td.maxWidth;
- if (maxWidth == SWT.DEFAULT) {
- Point size =
- child.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
- maxWidth = size.x;
- }
- maxWidth += td.indent;
- if (td.colspan == 1)
- maxColumnWidths[j] = Math.max(maxColumnWidths[j], maxWidth);
- else {
- // grow the last column
- int last = j + td.colspan - 1;
- int rem = 0;
- for (int k = j; k < j + td.colspan - 1; k++) {
- rem += maxColumnWidths[k];
- }
- int reduced = maxWidth - rem;
- maxColumnWidths[last] =
- Math.max(maxColumnWidths[last], reduced);
- }
- }
- }
- }
-
- private void initializeIfNeeded(Composite parent, boolean changed) {
- if (changed)
- initialLayout = true;
- if (initialLayout) {
- initializeLayoutData(parent);
- initialLayout = false;
- }
- }
-
- void initializeLayoutData(Composite composite) {
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
- if (child.getLayoutData() == null) {
- child.setLayoutData(new TableWrapData());
- }
- }
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ToggleHyperlink.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ToggleHyperlink.java
deleted file mode 100644
index 76d4a83..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/ToggleHyperlink.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.forms.events.*;
-
-/**
- * A custom selectable control that can be used to control
- * areas that can be expanded or collapsed.
- * <p>
- * This is an abstract class. Subclasses are responsible
- * for rendering the control using decoration and
- * active decoration color. Control should be
- * rendered based on the current expansion state.
- */
-
-public abstract class ToggleHyperlink extends AbstractHyperlink {
- protected int innerWidth;
- protected int innerHeight;
- private boolean expanded;
- protected boolean hover;
- private Color decorationColor;
- private Color activeColor;
-
- /**
- * Creates a control in a provided composite.
- *
- * @param parent
- * the parent
- * @param style
- * the style
- */
-
- public ToggleHyperlink(Composite parent, int style) {
- super(parent, style);
-
- addListener(SWT.MouseEnter, new Listener() {
- public void handleEvent(Event e) {
- hover = true;
- redraw();
- }
- });
- addListener(SWT.MouseExit, new Listener() {
- public void handleEvent(Event e) {
- hover = false;
- redraw();
- }
- });
- addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- setExpanded(!isExpanded());
- }
- });
- initAccessible();
- }
-
- /**
- * Sets the color of the twistie triangle.
- *
- * @param decorationColor
- */
-
- public void setDecorationColor(Color decorationColor) {
- this.decorationColor = decorationColor;
- }
-
- /**
- * Returns the color of the twistie triangle.
- *
- * @return
- */
-
- public Color getDecorationColor() {
- return decorationColor;
- }
-
- /**
- * Sets the active color of the twistie triangle. Active color will be used
- * when mouse enters the twistie area.
- *
- * @param activeColor
- * the active color to use
- */
-
- public void setActiveDecorationColor(Color activeColor) {
- this.activeColor = activeColor;
- }
-
- /**
- * Returns the active color of the twistie triangle.
- *
- * @return the active twistie color
- */
- public Color getActiveDecorationColor() {
- return activeColor;
- }
- /**
- * Computes the size of the control.
- * @param wHint width hint
- * @param hHint height hint
- * @param changed if true, flush any saved layout state
- */
- public Point computeSize(int wHint, int hHint, boolean changed) {
- int width, height;
-
- if (wHint != SWT.DEFAULT)
- width = wHint;
- else
- width = innerWidth + 2 * marginWidth;
- if (hHint != SWT.DEFAULT)
- height = hHint;
- else
- height = innerHeight + 2 * marginHeight;
- return new Point(width, height);
- }
-
- /**
- * Returns the state of the twistie control. When twistie is in the normal
- * (downward) state, the value is <samp>false</samp>. Collapsed
- * twistie will return <samp>true</samp>.
- * @return <samp>true</samp> if collapsed, <samp>false</samp> otherwise.
- */
- public boolean isExpanded() {
- return expanded;
- }
-
- /**
- * Sets the state of the twistie control
- * @param selection
- */
- public void setExpanded(boolean expanded) {
- this.expanded = expanded;
- redraw();
- }
-
- private void initAccessible() {
- getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
-
- getAccessible()
- .addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point testPoint = toControl(new Point(e.x, e.y));
- if (getBounds().contains(testPoint)) {
- e.childID = ACC.CHILDID_SELF;
- }
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_TREE;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail =
- ToggleHyperlink.this.isExpanded()
- ? ACC.STATE_EXPANDED
- : ACC.STATE_COLLAPSED;
- }
-
- public void getValue(AccessibleControlEvent e) {
- e.result = ToggleHyperlink.this.isExpanded() ? "1" : "0";
- }
- });
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TreeNode.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TreeNode.java
deleted file mode 100644
index bd6a7c1..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/TreeNode.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A custom selectable control that can be used to control areas that can be
- * expanded or collapsed. The control control can be toggled between selected
- * and deselected state with a mouse or by pressing 'Enter' while the control
- * has focus.
- * <p>
- * The control is rendered as box with a '+' or '-' sign, depending
- * on the expansion state. Focus indication is rendered around
- * the box when the control has keyboard focus.
- */
-
-public class TreeNode extends ToggleHyperlink {
-
- /**
- * Creates a control in a provided composite.
- *
- * @param parent
- * the parent
- * @param style
- * the style
- */
-
- public TreeNode(Composite parent, int style) {
- super(parent, style);
- innerWidth = 10;
- innerHeight = 10;
- }
-
- protected void paint(PaintEvent e) {
- paintHyperlink(e);
- }
-
- protected void paintHyperlink(PaintEvent e) {
- GC gc = e.gc;
- Rectangle box = getBoxBounds(gc);
- gc.setForeground(
- getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
- gc.drawRectangle(box);
- gc.setForeground(getForeground());
- gc.drawLine(box.x + 2, box.y + 4, box.x + 6, box.y + 4);
- if (!isExpanded()) {
- gc.drawLine(box.x + 4, box.y + 2, box.x + 4, box.y + 6);
- }
- if (getSelection()) {
- gc.setForeground(getForeground());
- gc.drawFocus(box.x-1, box.y-1, box.width+3, box.height+3);
- }
- }
- private Rectangle getBoxBounds(GC gc) {
- int x = 1;
- int y = 0;
-
- gc.setFont(getFont());
- int height = gc.getFontMetrics().getHeight();
- y = height / 2 - 4;
- y = Math.max(y, 0);
- return new Rectangle(x, y, 8, 8);
- }
-}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Twistie.java b/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Twistie.java
deleted file mode 100644
index c86109c..0000000
--- a/update/org.eclipse.update.ui.forms/Eclipse Forms/org/eclipse/ui/forms/widgets/Twistie.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.forms.widgets;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A custom selectable control that can be used to control areas that can be
- * expanded or collapsed. The control control can be toggled between selected
- * and deselected state with a mouse or by pressing 'Enter' while the control
- * has focus.
- * <p>
- * The control is rendered as a triangle that points to the right in the
- * collapsed and down in the expanded state. Triangle color can be changed.
- */
-
-public class Twistie extends ToggleHyperlink {
- private static final int[] onPoints = { 0, 2, 8, 2, 4, 6 };
- private static final int[] offPoints = { 2, -1, 2, 8, 6, 4 };
-
- /**
- * Creates a control in a provided composite.
- *
- * @param parent
- * the parent
- * @param style
- * the style
- */
-
- public Twistie(Composite parent, int style) {
- super(parent, style);
- innerWidth = 9;
- innerHeight = 9;
- }
-
- /*
- * @see SelectableControl#paint(GC)
- */
- protected void paintHyperlink(PaintEvent e) {
- GC gc = e.gc;
- if (hover && getActiveDecorationColor() != null)
- gc.setBackground(getActiveDecorationColor());
- else if (getDecorationColor() != null)
- gc.setBackground(getDecorationColor());
- else
- gc.setBackground(getForeground());
- int[] data;
- Point size = getSize();
- int x = (size.x - 9) / 2;
- int y = (size.y - 9) / 2;
- if (isExpanded())
- data = translate(onPoints, x, y);
-
- else
- data = translate(offPoints, x, y);
- gc.fillPolygon(data);
- gc.setBackground(getBackground());
- }
-
- private int[] translate(int[] data, int x, int y) {
- int[] target = new int[data.length];
- for (int i = 0; i < data.length; i += 2) {
- target[i] = data[i] + x;
- }
- for (int i = 1; i < data.length; i += 2) {
- target[i] = data[i] + y;
- }
- return target;
- }
-}
diff --git a/update/org.eclipse.update.ui.forms/build.properties b/update/org.eclipse.update.ui.forms/build.properties
index 0f7f1ab..14fda25 100644
--- a/update/org.eclipse.update.ui.forms/build.properties
+++ b/update/org.eclipse.update.ui.forms/build.properties
@@ -1,16 +1,6 @@
-###############################################################################
-# Copyright (c) 2000, 2003 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 Corporation - initial API and implementation
-###############################################################################
-source.forms.jar = src/,Eclipse Forms/
-src.includes=about.html
bin.includes = plugin.properties,\
*.jar,\
plugin.xml,\
about.html
+source.forms.jar = src/
+src.includes = about.html