Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-12-06 04:20:29 +0000
committerJean Michel-Lemieux2003-12-06 04:20:29 +0000
commitbff77351dff5acfdcfe816a44efaf180d2313534 (patch)
tree089c58701cf3284c799c246597b0d6b217b09747
parent35ed85e58a0506f809072ce1e300ad0820640341 (diff)
downloadeclipse.platform.team-bff77351dff5acfdcfe816a44efaf180d2313534.tar.gz
eclipse.platform.team-bff77351dff5acfdcfe816a44efaf180d2313534.tar.xz
eclipse.platform.team-bff77351dff5acfdcfe816a44efaf180d2313534.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ParticipantComposite.java81
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormLabel.java240
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormSection.java171
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormWidgetFactory.java377
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkHandler.java211
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkSettings.java116
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/IHyperlinkListener.java19
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/ILayoutExtension.java28
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/SelectableFormLabel.java149
9 files changed, 1270 insertions, 122 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ParticipantComposite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ParticipantComposite.java
index 4e4ae6a2c..70835fd76 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ParticipantComposite.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ParticipantComposite.java
@@ -19,6 +19,8 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.widgets.FormSection;
+import org.eclipse.team.internal.ui.widgets.FormWidgetFactory;
import org.eclipse.team.ui.ISharedImages;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ISynchronizeView;
@@ -35,14 +37,72 @@ public class ParticipantComposite extends Composite {
private Image conflictingImage = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_CONFLICTING).createImage();
private ISynchronizeView view;
+ private FormSection dropDownSection;
public ParticipantComposite(Composite parent, ISynchronizeParticipant participant, ISynchronizeView view, int style) {
super(parent, style);
this.participant = participant;
this.background = new Color(parent.getDisplay(), new RGB(255, 255, 255));
this.participantImage = participant.getImageDescriptor().createImage();
- this.view = view;
+ this.view = view;
+ this.dropDownSection = new FormSection() {
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.widgets.FormSection#getDescription()
+ */
+ public String getDescription() {
+ return "This is the place where the resources are";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.widgets.FormSection#getHeaderText()
+ */
+ public String getHeaderText() {
+ return "Resources are here";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.widgets.FormSection#createClient(org.eclipse.swt.widgets.Composite, org.eclipse.team.internal.ui.widgets.FormWidgetFactory)
+ */
+ public Composite createClient(Composite parent, FormWidgetFactory factory) {
+ Composite top = factory.createComposite(parent);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ //layout.verticalSpacing = 9;
+ //layout.horizontalSpacing = 6;
+ top.setLayout(layout);
+ top.setBackground(new Color(top.getDisplay(), new RGB(134,145,56)));
+ //top.setBackground(getBackgroundColor());
+ {Label label = new Label(top, SWT.NONE);
+ label.setText("Hello!!!");}
+ {Label label = new Label(top, SWT.NONE);
+ label.setText("Hello!!!");}
+ {Label label = new Label(top, SWT.NONE);
+ label.setText("Hello!!!");}
+ {Label label = new Label(top, SWT.NONE);
+ label.setText("Hello!!!");}
+ //factory.paintBordersFor(top);
+ return top;
+ }
+ protected void reflow() {
+ super.reflow();
+ setRedraw(false);
+ getParent().setRedraw(false);
+ layout(true);
+ getParent().layout(true);
+ setRedraw(true);
+ getParent().setRedraw(true);
+ }
+ };
+ dropDownSection.setCollapsable(true);
+ dropDownSection.setCollapsed(false);
createComposite(this);
+ //dropDownSection.setDescription("asdkjfh aklhfd kahsdf kjgdaskjhsagf kjgsdaf j ");
+
+// Control control = dropDownSection.createControl(this, factory);
+// control.setBackground(new Color(parent.getDisplay(), new RGB(0,0,0)));
+// GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
+// control.setLayoutData(gd);
+
}
protected Composite createComposite(Composite area) {
@@ -100,14 +160,21 @@ public class ParticipantComposite extends Composite {
label.setBackground(getBackgroundColor());
}
{
- final Label label = new Label(composite_1, SWT.NONE);
- label.setText("Resources:");
- label.setBackground(getBackgroundColor());
+// final Label label = new Label(composite_1, SWT.NONE);
+// label.setText("Resources:");
+// label.setBackground(getBackgroundColor());
+ FormWidgetFactory factory = new FormWidgetFactory(getDisplay());
+ factory.setBackgroundColor(getBackgroundColor());
+ Control control = dropDownSection.createControl(composite_1, factory);
+ control.setBackground(new Color(composite_1.getDisplay(), new RGB(0,0,0)));
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ control.setLayoutData(gd);
}
{
- final Combo combo = new Combo(composite_1, SWT.READ_ONLY);
- combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- combo.setBackground(getBackgroundColor());
+// final Combo combo = new Combo(composite_1, SWT.READ_ONLY);
+// combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// combo.setBackground(getBackgroundColor());
}
}
{
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormLabel.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormLabel.java
new file mode 100644
index 000000000..14949c7ed
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormLabel.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import java.text.BreakIterator;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * FormText is a windowless control that
+ * draws text in the provided context.
+ */
+public class FormLabel extends Canvas {
+ private String text = "";
+ protected int textMarginWidth = 5;
+ protected int textMarginHeight = 5;
+ private boolean underlined;
+
+ public FormLabel(Composite parent, int style) {
+ super(parent, style);
+ addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ paint(e);
+ }
+ });
+ initAccessible();
+ }
+ public String getText() {
+ return text;
+ }
+ public void setText(String text) {
+ if (text != null)
+ this.text = text;
+ else
+ text = "";
+ }
+
+ 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) {
+ e.detail = ACC.STATE_READONLY;
+ }
+ });
+ }
+
+ public void setUnderlined(boolean underlined) {
+ this.underlined = underlined;
+ }
+
+ public boolean isUnderlined() {
+ return underlined;
+ }
+
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int innerWidth = wHint;
+ if (innerWidth != SWT.DEFAULT)
+ innerWidth -= textMarginWidth * 2;
+ Point textSize = computeTextSize(innerWidth, hHint);
+ int textWidth = textSize.x + 2 * textMarginWidth;
+ int textHeight = textSize.y + 2 * textMarginHeight;
+ return new Point(textWidth, textHeight);
+ }
+
+ public static int computeWrapHeight(GC gc, String text, int width) {
+ BreakIterator wb = BreakIterator.getWordInstance();
+ wb.setText(text);
+ FontMetrics fm = gc.getFontMetrics();
+ int lineHeight = fm.getHeight();
+
+ int saved = 0;
+ int last = 0;
+ int height = lineHeight;
+
+ for (int loc = wb.first();
+ loc != BreakIterator.DONE;
+ loc = wb.next()) {
+ String word = text.substring(saved, loc);
+ Point extent = gc.textExtent(word);
+ if (extent.x > width) {
+ // overflow
+ saved = last;
+ height += extent.y;
+ }
+ last = loc;
+ }
+ return height;
+ }
+
+ private Point computeTextSize(int wHint, int hHint) {
+ Point extent;
+ GC gc = new GC(this);
+
+ gc.setFont(getFont());
+ if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
+ int height = computeWrapHeight(gc, text, wHint);
+ extent = new Point(wHint, height);
+ } else {
+ extent = gc.textExtent(getText());
+ }
+ gc.dispose();
+ return extent;
+ }
+
+ public static void paintWrapText(
+ GC gc,
+ Point size,
+ String text,
+ int marginWidth,
+ int marginHeight) {
+ paintWrapText(gc, size, text, marginWidth, marginHeight, false);
+ }
+
+ public static void paintWrapText(
+ GC gc,
+ Point size,
+ String text,
+ int marginWidth,
+ int marginHeight,
+ 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 = marginHeight;
+ int width = size.x - marginWidth * 2;
+
+ 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.drawString(prevLine, marginWidth, y, true);
+ if (underline) {
+ Point prevExtent = gc.textExtent(prevLine);
+ int lineY = y + lineHeight - descent + 1;
+ gc.drawLine(marginWidth, lineY, prevExtent.x, lineY);
+ }
+
+ saved = last;
+ y += lineHeight;
+ }
+ last = loc;
+ }
+ // paint the last line
+ String lastLine = text.substring(saved, last);
+ gc.drawString(lastLine, marginWidth, y, true);
+ if (underline) {
+ int lineY = y + lineHeight - descent + 1;
+ Point lastExtent = gc.textExtent(lastLine);
+ gc.drawLine(marginWidth, lineY, marginWidth + lastExtent.x, lineY);
+ }
+ }
+
+ protected void paint(PaintEvent e) {
+ GC gc = e.gc;
+ Point size = getSize();
+ gc.setFont(getFont());
+ gc.setForeground(getForeground());
+ if ((getStyle() & SWT.WRAP) != 0) {
+ paintWrapText(
+ gc,
+ size,
+ text,
+ textMarginWidth,
+ textMarginHeight,
+ underlined);
+ } else {
+ gc.drawText(getText(), textMarginWidth, textMarginHeight, true);
+ if (underlined) {
+ FontMetrics fm = gc.getFontMetrics();
+ int descent = fm.getDescent();
+ int lineY = size.y - textMarginHeight - descent + 1;
+ gc.drawLine(
+ textMarginWidth,
+ lineY,
+ size.x - textMarginWidth,
+ lineY);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormSection.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormSection.java
index bd41aa71c..7c9671f74 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormSection.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormSection.java
@@ -19,6 +19,7 @@ import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public abstract class FormSection implements IPropertyChangeListener {
@@ -28,7 +29,7 @@ public abstract class FormSection implements IPropertyChangeListener {
private Control client;
protected Label header;
protected Control separator;
- private SectionChangeManager sectionManager;
+ //private SectionChangeManager sectionManager;
private String description;
private boolean dirty;
protected Label descriptionLabel;
@@ -42,14 +43,13 @@ public abstract class FormSection implements IPropertyChangeListener {
private int widthHint = SWT.DEFAULT;
private int heightHint = SWT.DEFAULT;
private Composite control;
- public boolean compactMode=false;
+ public boolean compactMode = true;
/*
- * This is a special layout for the section. Both the
- * header and the description labels will wrap and
- * they will use client's size to calculate needed
- * height. This kind of behaviour is not possible
- * with stock grid layout.
+ * This is a special layout for the section. Both the header and the
+ * description labels will wrap and they will use client's size to
+ * calculate needed height. This kind of behaviour is not possible with
+ * stock grid layout.
*/
class SectionLayout extends Layout implements ILayoutExtension {
int vspacing = 3;
@@ -71,32 +71,22 @@ public abstract class FormSection implements IPropertyChangeListener {
flush);
}
if (maxWidth == 0) {
- Point csize =
- client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
+ Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
maxWidth = csize.x;
}
}
if (headerPainted && header != null) {
- Point hsize =
- header.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
+ Point hsize = header.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
maxWidth = Math.max(maxWidth, hsize.x);
}
if (descriptionPainted && descriptionLabel != null) {
- Point dsize =
- descriptionLabel.computeSize(
- SWT.DEFAULT,
- SWT.DEFAULT,
- flush);
+ Point dsize = descriptionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
maxWidth = Math.max(maxWidth, dsize.x);
}
return maxWidth;
}
- protected Point computeSize(
- Composite parent,
- int wHint,
- int hHint,
- boolean flush) {
+ protected Point computeSize(Composite parent, int wHint, int hHint, boolean flush) {
int width = 0;
int height = 0;
int cwidth = 0;
@@ -111,31 +101,30 @@ public abstract class FormSection implements IPropertyChangeListener {
if (client != null && !client.isDisposed()) {
if (toggle != null && toggle.getSelection() && compactMode) {
- }
- else {
- //Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
- Point csize = client.computeSize(wHint, SWT.DEFAULT);
- if (width == 0) {
- width = csize.x;
- cwidth = width;
- }
- if (height == 0)
- height = csize.y;
+ } else {
+ //Point csize = client.computeSize(SWT.DEFAULT,
+ // SWT.DEFAULT, flush);
+ Point csize = client.computeSize(wHint, SWT.DEFAULT);
+ if (width == 0) {
+ width = csize.x;
+ cwidth = width;
+ }
+ if (height == 0)
+ height = csize.y;
}
}
Point toggleSize = null;
if (collapsable && toggle != null)
- toggleSize =
- toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
+ toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
if (hHint == SWT.DEFAULT && headerPainted && header != null) {
int hwidth = cwidth;
if (toggleSize != null)
hwidth = cwidth - toggleSize.x - 5;
Point hsize = header.computeSize(hwidth, SWT.DEFAULT, flush);
- height += hsize.y;
+ height += 18; //(hsize.y - 20);
collapsedHeight = hsize.y;
height += vspacing;
}
@@ -145,11 +134,8 @@ public abstract class FormSection implements IPropertyChangeListener {
height += vspacing;
collapsedHeight += vspacing + sepHeight;
}
- if (hHint == SWT.DEFAULT
- && descriptionPainted
- && descriptionLabel != null) {
- Point dsize =
- descriptionLabel.computeSize(cwidth, SWT.DEFAULT, flush);
+ if (hHint == SWT.DEFAULT && descriptionPainted && descriptionLabel != null) {
+ Point dsize = descriptionLabel.computeSize(cwidth, SWT.DEFAULT, flush);
height += dsize.y;
height += vspacing;
}
@@ -166,8 +152,7 @@ public abstract class FormSection implements IPropertyChangeListener {
Point toggleSize = null;
if (collapsable) {
- toggleSize =
- toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
+ toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
}
if (headerPainted && header != null) {
Point hsize;
@@ -194,8 +179,7 @@ public abstract class FormSection implements IPropertyChangeListener {
return;
}
if (descriptionPainted && descriptionLabel != null) {
- Point dsize =
- descriptionLabel.computeSize(width, SWT.DEFAULT, flush);
+ Point dsize = descriptionLabel.computeSize(width, SWT.DEFAULT, flush);
descriptionLabel.setBounds(0, y, width, dsize.y);
y += dsize.y + vspacing;
}
@@ -221,47 +205,36 @@ public abstract class FormSection implements IPropertyChangeListener {
public FormSection() {
/*
- // Description causes problems re word wrapping
- // and causes bad layout in schema and
- // feature editors when in Motif - turning off
- if (SWT.getPlatform().equals("motif")) {
- descriptionPainted = false;
- }
- */
+ * // Description causes problems re word wrapping // and causes bad
+ * layout in schema and // feature editors when in Motif - turning off
+ * if (SWT.getPlatform().equals("motif")) { descriptionPainted = false; }
+ */
JFaceResources.getFontRegistry().addListener(this);
}
public void commitChanges(boolean onSave) {
}
- public abstract Composite createClient(
- Composite parent,
- FormWidgetFactory factory);
- public final Control createControl(
- Composite parent,
- final FormWidgetFactory factory) {
+
+ public abstract Composite createClient(Composite parent, FormWidgetFactory factory);
+
+ public final Control createControl(Composite parent, final FormWidgetFactory factory) {
Composite section = factory.createComposite(parent);
SectionLayout slayout = new SectionLayout();
section.setLayout(slayout);
+ //section.setLayout(new GridLayout());
section.setData(this);
if (headerPainted) {
Color headerColor = factory.getColor(getHeaderColorKey());
- header =
- factory.createHeadingLabel(
- section,
- getHeaderText(),
- headerColor,
- SWT.WRAP);
+ header = factory.createHeadingLabel(section, getHeaderText(), headerColor, SWT.WRAP);
if (collapsable) {
toggle = new ToggleControl(section, SWT.NULL);
toggle.setSelection(collapsed);
toggle.setBackground(factory.getBackgroundColor());
toggle.setActiveDecorationColor(factory.getHyperlinkColor());
- toggle.setDecorationColor(
- factory.getColor(
- FormWidgetFactory.COLOR_COMPOSITE_SEPARATOR));
+ toggle.setDecorationColor(factory.getColor(FormWidgetFactory.COLOR_COMPOSITE_SEPARATOR));
toggle.setActiveCursor(factory.getHyperlinkCursor());
- toggle.addFocusListener(factory.visibilityHandler);
- toggle.addKeyListener(factory.keyboardHandler);
+ //toggle.addFocusListener(factory.visibilityHandler);
+ //toggle.addKeyListener(factory.keyboardHandler);
toggle.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
doToggle();
@@ -291,8 +264,7 @@ public abstract class FormSection implements IPropertyChangeListener {
}
if (descriptionPainted && description != null) {
- descriptionLabel =
- factory.createLabel(section, description, SWT.WRAP);
+ descriptionLabel = factory.createLabel(section, description, SWT.WRAP);
}
client = createClient(section, factory);
section.setData(this);
@@ -318,58 +290,34 @@ public abstract class FormSection implements IPropertyChangeListener {
control.getParent().setRedraw(true);
}
- protected Text createText(
- Composite parent,
- String label,
- FormWidgetFactory factory) {
+ protected Text createText(Composite parent, String label, FormWidgetFactory factory) {
return createText(parent, label, factory, 1);
}
- protected Text createText(
- Composite parent,
- String label,
- FormWidgetFactory factory,
- int span) {
+ protected Text createText(Composite parent, String label, FormWidgetFactory factory, int span) {
factory.createLabel(parent, label);
Text text = factory.createText(parent, "");
- int hfill =
- span == 1
- ? GridData.FILL_HORIZONTAL
- : GridData.HORIZONTAL_ALIGN_FILL;
+ 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;
}
- protected Text createText(
- Composite parent,
- String label,
- FormWidgetFactory factory,
- int span,
- int style) {
+ protected Text createText(Composite parent, String label, FormWidgetFactory 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;
+ 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;
}
- protected Text createText(
- Composite parent,
- FormWidgetFactory factory,
- int span) {
+ protected Text createText(Composite parent, FormWidgetFactory factory, int span) {
Text text = factory.createText(parent, "");
- int hfill =
- span == 1
- ? GridData.FILL_HORIZONTAL
- : GridData.HORIZONTAL_ALIGN_FILL;
+ int hfill = span == 1 ? GridData.FILL_HORIZONTAL : GridData.HORIZONTAL_ALIGN_FILL;
GridData gd = new GridData(hfill | GridData.VERTICAL_ALIGN_CENTER);
//gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = span;
@@ -384,12 +332,7 @@ public abstract class FormSection implements IPropertyChangeListener {
}
public void expandTo(Object object) {
}
- public final void fireChangeNotification(
- int changeType,
- Object changeObject) {
- if (sectionManager == null)
- return;
- sectionManager.dispatchNotification(this, changeType, changeObject);
+ public final void fireChangeNotification(int changeType, Object changeObject) {
}
public final void fireSelectionNotification(Object changeObject) {
fireChangeNotification(SELECTION, changeObject);
@@ -426,10 +369,7 @@ public abstract class FormSection implements IPropertyChangeListener {
public boolean isReadOnly() {
return readOnly;
}
- public void sectionChanged(
- FormSection source,
- int changeType,
- Object changeObject) {
+ public void sectionChanged(FormSection source, int changeType, Object changeObject) {
}
public void setAddSeparator(boolean newAddSeparator) {
addSeparator = newAddSeparator;
@@ -480,9 +420,7 @@ public abstract class FormSection implements IPropertyChangeListener {
public void setHeightHint(int newHeightHint) {
heightHint = newHeightHint;
}
- void setManager(SectionChangeManager manager) {
- this.sectionManager = manager;
- }
+
public void setReadOnly(boolean newReadOnly) {
readOnly = newReadOnly;
}
@@ -503,6 +441,7 @@ public abstract class FormSection implements IPropertyChangeListener {
/**
* Gets the collapsable.
+ *
* @return Returns a boolean
*/
public boolean getCollapsable() {
@@ -511,7 +450,9 @@ public abstract class FormSection implements IPropertyChangeListener {
/**
* Sets the collapsable.
- * @param collapsable The collapsable to set
+ *
+ * @param collapsable
+ * The collapsable to set
*/
public void setCollapsable(boolean collapsable) {
this.collapsable = collapsable;
@@ -520,7 +461,7 @@ public abstract class FormSection implements IPropertyChangeListener {
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
-
+
public boolean isCollapsed() {
return collapsed;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormWidgetFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormWidgetFactory.java
new file mode 100644
index 000000000..708bb21ef
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/FormWidgetFactory.java
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.jface.resource.JFaceColors;
+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.actions.ActionFactory;
+
+public class FormWidgetFactory {
+ public static final String KEY_DRAW_BORDER = "FormWidgetFactory.drawBorder";
+ public static final String TREE_BORDER = "treeBorder";
+ public static final String DEFAULT_HEADER_COLOR = "__default__header__";
+ public static final String COLOR_BORDER = "__border";
+ public static final String COLOR_COMPOSITE_SEPARATOR = "__compSep";
+
+ private Hashtable colorRegistry = new Hashtable();
+ private Color backgroundColor;
+ private KeyListener deleteListener;
+ private Color foregroundColor;
+ private Display display;
+ public static final int BORDER_STYLE = SWT.NONE; //SWT.BORDER;
+ private BorderPainter borderPainter;
+ private HyperlinkHandler hyperlinkHandler;
+ private Color borderColor;
+
+ 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;
+ if (c.getEnabled() == false && !(c instanceof CCombo))
+ continue;
+ //if (c instanceof SelectableFormLabel)
+ // continue;
+ Object flag = c.getData(KEY_DRAW_BORDER);
+ if (flag!=null) {
+ if (flag.equals(Boolean.FALSE)) continue;
+ if (flag.equals(TREE_BORDER)) inactiveBorder=true;
+ }
+
+ if (!inactiveBorder && (c instanceof Text || c instanceof Canvas || c instanceof CCombo)) {
+ 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(foregroundColor);
+ 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(borderColor);
+ //gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
+ gc.drawRectangle(b.x - 1, b.y - 1, b.width + 2, b.height + 2);
+ }
+ }
+ }
+ }
+
+ class VisibilityHandler extends FocusAdapter {
+ public void focusGained(FocusEvent e) {
+ Widget w = e.widget;
+ if (w instanceof Control) {
+ ensureVisible((Control) w);
+ }
+ }
+ }
+
+ class KeyboardHandler extends KeyAdapter {
+ public void keyPressed(KeyEvent e) {
+ Widget w = e.widget;
+ if (w instanceof Control) {
+ processKey(e.keyCode, (Control) w);
+ }
+ }
+ }
+
+ public FormWidgetFactory() {
+ this(Display.getCurrent());
+ }
+
+ public FormWidgetFactory(Display display) {
+ this.display = display;
+ initialize();
+ }
+
+ public static ScrolledComposite getScrolledComposite(Control c) {
+ Composite parent = c.getParent();
+
+ while (parent != null) {
+ if (parent instanceof ScrolledComposite) {
+ return (ScrolledComposite) parent;
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
+ public static void ensureVisible(Control c) {
+ ScrolledComposite scomp = getScrolledComposite(c);
+ //if (scomp != null) {
+ // AbstractSectionForm.ensureVisible(scomp, c);
+ //}
+ }
+
+ public static void processKey(int keyCode, Control c) {
+// ScrolledComposite scomp = getScrolledComposite(c);
+// if (scomp != null) {
+// switch (keyCode) {
+// case SWT.ARROW_DOWN :
+// AbstractSectionForm.scrollVertical(scomp, false);
+// break;
+// case SWT.ARROW_UP :
+// AbstractSectionForm.scrollVertical(scomp, true);
+// break;
+// case SWT.ARROW_LEFT :
+// AbstractSectionForm.scrollHorizontal(scomp, true);
+// break;
+// case SWT.ARROW_RIGHT :
+// AbstractSectionForm.scrollHorizontal(scomp, false);
+// break;
+// case SWT.PAGE_UP :
+// AbstractSectionForm.scrollPage(scomp, true);
+// break;
+// case SWT.PAGE_DOWN :
+// AbstractSectionForm.scrollPage(scomp, false);
+// break;
+// }
+// }
+ }
+
+ public Button createButton(Composite parent, String text, int style) {
+ int flatStyle = BORDER_STYLE == SWT.BORDER ? SWT.NULL : SWT.FLAT;
+ //int flatStyle = SWT.NULL;
+ Button button = new Button(parent, style | flatStyle);
+ button.setBackground(backgroundColor);
+ button.setForeground(foregroundColor);
+ if (text != null)
+ button.setText(text);
+ //button.addFocusListener(visibilityHandler);
+ return button;
+ }
+ public Composite createComposite(Composite parent) {
+ return createComposite(parent, SWT.NULL);
+ }
+ public Composite createComposite(Composite parent, int style) {
+ Composite composite = new Composite(parent, style);
+ composite.setBackground(backgroundColor);
+ composite.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ ((Control) e.widget).setFocus();
+ }
+ });
+ composite.setMenu(parent.getMenu());
+ return composite;
+ }
+ public Composite createCompositeSeparator(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setBackground(getColor(COLOR_COMPOSITE_SEPARATOR));
+ return composite;
+ }
+
+ public Label createHeadingLabel(Composite parent, String text) {
+ return createHeadingLabel(parent, text, null, SWT.NONE);
+ }
+
+ public Label createHeadingLabel(Composite parent, String text, int style) {
+ return createHeadingLabel(parent, text, null, style);
+ }
+
+ public Label createHeadingLabel(Composite parent, String text, Color bg) {
+ return createHeadingLabel(parent, text, bg, SWT.NONE);
+ }
+
+ public Label createHeadingLabel(
+ Composite parent,
+ String text,
+ Color bg,
+ int style) {
+ Label label = new Label(parent, style);
+ if (text != null)
+ label.setText(text);
+ label.setBackground(backgroundColor);
+ label.setForeground(foregroundColor);
+ label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT));
+ return label;
+ }
+
+
+ public Label createLabel(Composite parent, String text) {
+ return createLabel(parent, text, SWT.NONE);
+ }
+ public Label createLabel(Composite parent, String text, int style) {
+ Label label = new Label(parent, style);
+ if (text != null)
+ label.setText(text);
+ label.setBackground(backgroundColor);
+ label.setForeground(foregroundColor);
+ return label;
+ }
+
+
+
+ public Label createSeparator(Composite parent, int style) {
+ Label label = new Label(parent, SWT.SEPARATOR | style);
+ label.setBackground(backgroundColor);
+ label.setForeground(borderColor);
+ return label;
+ }
+ public Table createTable(Composite parent, int style) {
+ Table table = new Table(parent, BORDER_STYLE | style);
+ table.setBackground(backgroundColor);
+ table.setForeground(foregroundColor);
+ hookDeleteListener(table);
+ return table;
+ }
+ public Text createText(Composite parent, String value) {
+ return createText(parent, value, BORDER_STYLE | SWT.SINGLE);
+ }
+ public Text createText(Composite parent, String value, int style) {
+ Text text = new Text(parent, style);
+ if (value != null)
+ text.setText(value);
+ text.setBackground(backgroundColor);
+ text.setForeground(foregroundColor);
+ //text.addFocusListener(visibilityHandler);
+ return text;
+ }
+ public Tree createTree(Composite parent, int style) {
+ Tree tree = new Tree(parent, BORDER_STYLE | style);
+ tree.setBackground(backgroundColor);
+ tree.setForeground(foregroundColor);
+ hookDeleteListener(tree);
+ return tree;
+ }
+ 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 FormSection) {
+ FormSection section = (FormSection) parent.getData();
+ section.doGlobalAction(ActionFactory.DELETE.getId());
+ break;
+ }
+ }
+ }
+ public void dispose() {
+ Enumeration colors = colorRegistry.elements();
+ while (colors.hasMoreElements()) {
+ Color c = (Color) colors.nextElement();
+ c.dispose();
+ }
+ //hyperlinkHandler.dispose();
+ colorRegistry = null;
+ }
+ public Color getBackgroundColor() {
+ return backgroundColor;
+ }
+ public Color getBorderColor() {
+ return borderColor;
+ }
+ public Cursor getBusyCursor() {
+ return hyperlinkHandler.getBusyCursor();
+ }
+ public Color getColor(String key) {
+ return (Color) colorRegistry.get(key);
+ }
+ public Color getForegroundColor() {
+ return foregroundColor;
+ }
+ public HyperlinkHandler getHyperlinkHandler() {
+ return hyperlinkHandler;
+ }
+ public Cursor getHyperlinkCursor() {
+ return hyperlinkHandler.getHyperlinkCursor();
+ }
+ public Color getHyperlinkColor() {
+ return hyperlinkHandler.getForeground();
+ }
+ public Color getHyperlinkHoverColor() {
+ return hyperlinkHandler.getActiveForeground();
+ }
+ public int getHyperlinkUnderlineMode() {
+ return hyperlinkHandler.getHyperlinkUnderlineMode();
+ }
+ public void hookDeleteListener(Control control) {
+ if (deleteListener == null) {
+ deleteListener = new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ deleteKeyPressed(event.widget);
+ }
+ }
+ };
+ }
+ control.addKeyListener(deleteListener);
+ }
+ private void initialize() {
+ backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ registerColor(COLOR_BORDER, 195, 191, 179);
+ registerColor(COLOR_COMPOSITE_SEPARATOR, 152, 170, 203);
+ registerColor(DEFAULT_HEADER_COLOR, 0x48, 0x70, 0x98);
+ if (isWhiteBackground())
+ borderColor = getColor(COLOR_BORDER);
+ else
+ borderColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ hyperlinkHandler = new HyperlinkHandler();
+ hyperlinkHandler.setBackground(backgroundColor);
+ updateHyperlinkColors();
+ //visibilityHandler = new VisibilityHandler();
+ //keyboardHandler = new KeyboardHandler();
+ }
+
+ public boolean isWhiteBackground() {
+ return backgroundColor.getRed()==255 && backgroundColor.getGreen()==255 &&
+ backgroundColor.getBlue()==255;
+ }
+
+ public void updateHyperlinkColors() {
+ Color hyperlinkColor = JFaceColors.getHyperlinkText(display);
+ Color activeHyperlinkColor = JFaceColors.getActiveHyperlinkText(display);
+ hyperlinkHandler.setForeground(hyperlinkColor);
+ hyperlinkHandler.setActiveForeground(activeHyperlinkColor);
+ }
+
+ public void paintBordersFor(Composite parent) {
+ if (BORDER_STYLE == SWT.BORDER)
+ return;
+ if (borderPainter == null)
+ borderPainter = new BorderPainter();
+ parent.addPaintListener(borderPainter);
+ }
+ public Color registerColor(String key, int r, int g, int b) {
+ Color c = new Color(display, r, g, b);
+ colorRegistry.put(key, c);
+ return c;
+ }
+ public void setBackgroundColor(Color color) {
+ backgroundColor = color;
+ }
+ public void setHyperlinkColor(Color color) {
+ hyperlinkHandler.setForeground(color);
+ }
+ public void setHyperlinkHoverColor(org.eclipse.swt.graphics.Color hoverColor) {
+ hyperlinkHandler.setActiveForeground(hoverColor);
+ }
+ public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
+ hyperlinkHandler.setHyperlinkUnderlineMode(newHyperlinkUnderlineMode);
+ }
+ public void turnIntoHyperlink(Control control, IHyperlinkListener listener) {
+ hyperlinkHandler.registerHyperlink(control, listener);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkHandler.java
new file mode 100644
index 000000000..632d61596
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkHandler.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class HyperlinkHandler extends HyperlinkSettings implements MouseListener, MouseTrackListener, SelectionListener, PaintListener {
+ private Hashtable hyperlinkListeners;
+ private Control lastActivated;
+ private Control lastEntered;
+
+ public HyperlinkHandler() {
+ hyperlinkListeners = new Hashtable();
+ }
+
+ public Control getLastLink() {
+ return lastActivated;
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ public void mouseDown(MouseEvent e) {
+ if (e.button == 1)
+ return;
+ lastActivated = (Control) e.widget;
+ }
+ public void mouseEnter(MouseEvent e) {
+ Control control = (Control) e.widget;
+ linkEntered(control);
+ }
+ public void mouseExit(MouseEvent e) {
+ Control control = (Control) e.widget;
+ linkExited(control);
+ }
+ public void mouseHover(MouseEvent e) {
+ }
+
+ public void mouseUp(MouseEvent e) {
+ if (e.button != 1)
+ return;
+ Control linkControl = (Control) e.widget;
+ Point size = linkControl.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;
+ linkActivated(linkControl);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ Control link = (Control) e.widget;
+ linkActivated(link);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ Control link = (Control) e.widget;
+ SelectableFormLabel l = (SelectableFormLabel) link;
+ if (l.getSelection())
+ linkEntered(link);
+ else
+ linkExited(link);
+ }
+
+ private void linkActivated(Control link) {
+ IHyperlinkListener action =
+ (IHyperlinkListener) hyperlinkListeners.get(link);
+ if (action != null) {
+ link.setCursor(getBusyCursor());
+ action.linkActivated(link);
+ if (!link.isDisposed())
+ link.setCursor(
+ isHyperlinkCursorUsed() ? getHyperlinkCursor() : null);
+ }
+ }
+
+ private void linkEntered(Control link) {
+ if (lastEntered != null
+ && lastEntered instanceof SelectableFormLabel) {
+ SelectableFormLabel fl = (SelectableFormLabel) lastEntered;
+ linkExited(fl);
+ }
+ if (isHyperlinkCursorUsed())
+ link.setCursor(getHyperlinkCursor());
+ if (activeBackground != null)
+ link.setBackground(activeBackground);
+ if (activeForeground != null)
+ link.setForeground(activeForeground);
+ if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER)
+ underline(link, true);
+
+ IHyperlinkListener action =
+ (IHyperlinkListener) hyperlinkListeners.get(link);
+ if (action != null)
+ action.linkEntered(link);
+ lastEntered = link;
+ }
+
+ private void linkExited(Control link) {
+ if (isHyperlinkCursorUsed())
+ link.setCursor(null);
+ if (hyperlinkUnderlineMode == UNDERLINE_ROLLOVER)
+ underline(link, false);
+ if (background != null)
+ link.setBackground(background);
+ if (foreground != null)
+ link.setForeground(foreground);
+ IHyperlinkListener action =
+ (IHyperlinkListener) hyperlinkListeners.get(link);
+ if (action != null)
+ action.linkExited(link);
+ if (lastEntered == link)
+ lastEntered = null;
+ }
+
+ public void paintControl(PaintEvent e) {
+ Control label = (Control) e.widget;
+ if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
+ HyperlinkHandler.underline(label, true);
+ }
+
+ public void registerHyperlink(
+ Control control,
+ IHyperlinkListener listener) {
+ if (background != null)
+ control.setBackground(background);
+ if (foreground != null)
+ control.setForeground(foreground);
+ control.addMouseListener(this);
+ control.addMouseTrackListener(this);
+
+ if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS
+ && control instanceof Label)
+ control.addPaintListener(this);
+ if (control instanceof SelectableFormLabel) {
+ SelectableFormLabel sl = (SelectableFormLabel) control;
+ sl.addSelectionListener(this);
+ if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
+ sl.setUnderlined(true);
+ }
+ hyperlinkListeners.put(control, listener);
+ removeDisposedLinks();
+ }
+
+ private void removeDisposedLinks() {
+ for (Enumeration keys = hyperlinkListeners.keys();
+ keys.hasMoreElements();
+ ) {
+ Control control = (Control) keys.nextElement();
+ if (control.isDisposed()) {
+ hyperlinkListeners.remove(control);
+ }
+ }
+ }
+
+ public void reset() {
+ hyperlinkListeners.clear();
+ }
+
+ public static void underline(Control control, boolean inside) {
+ if (control instanceof SelectableFormLabel) {
+ SelectableFormLabel l = (SelectableFormLabel) control;
+ l.setUnderlined(inside);
+ l.redraw();
+ return;
+ }
+ if (!(control instanceof Label))
+ return;
+ Composite parent = control.getParent();
+ Rectangle bounds = control.getBounds();
+ GC gc = new GC(parent);
+ Color color =
+ inside ? control.getForeground() : control.getBackground();
+ gc.setForeground(color);
+ int y = bounds.y + bounds.height;
+ gc.drawLine(bounds.x, y, bounds.x + bounds.width, y);
+ gc.dispose();
+ }
+
+ public void setForeground(Color color) {
+ super.setForeground(color);
+ removeDisposedLinks();
+ for (Enumeration links = hyperlinkListeners.keys();
+ links.hasMoreElements();
+ ) {
+ Control control = (Control) links.nextElement();
+ control.setForeground(color);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkSettings.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkSettings.java
new file mode 100644
index 000000000..222d038d1
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/HyperlinkSettings.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Display;
+
+public class HyperlinkSettings {
+ public static final int UNDERLINE_NEVER = 1;
+ public static final int UNDERLINE_ROLLOVER = 2;
+ public static final int UNDERLINE_ALWAYS = 3;
+
+ protected boolean hyperlinkCursorUsed = true;
+ protected int hyperlinkUnderlineMode = UNDERLINE_ALWAYS;
+ protected Color background;
+ protected Color foreground;
+ protected Color activeBackground;
+ protected Color activeForeground;
+ protected static Cursors cursors = new Cursors();
+
+ static class Cursors {
+ Cursor hyperlinkCursor;
+ Cursor busyCursor;
+ Cursor textCursor;
+ int counter = 0;
+
+ public void allocate() {
+ if (counter == 0) {
+ hyperlinkCursor =
+ new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
+ textCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_IBEAM);
+ }
+ counter++;
+ }
+ public void dispose() {
+ counter--;
+ if (counter == 0) {
+ hyperlinkCursor.dispose();
+ busyCursor.dispose();
+ textCursor.dispose();
+ hyperlinkCursor = null;
+ busyCursor = null;
+ textCursor = null;
+ }
+ }
+ }
+
+ public HyperlinkSettings() {
+ cursors.allocate();
+ }
+
+ public void dispose() {
+ if (cursors != null)
+ cursors.dispose();
+ }
+
+ public Color getActiveBackground() {
+ return activeBackground;
+ }
+ public Color getActiveForeground() {
+ return activeForeground;
+ }
+ public Color getBackground() {
+ return background;
+ }
+ public Cursor getBusyCursor() {
+ return cursors.busyCursor;
+ }
+ public Cursor getTextCursor() {
+ return cursors.textCursor;
+ }
+ public Color getForeground() {
+ return foreground;
+ }
+ public Cursor getHyperlinkCursor() {
+ return cursors.hyperlinkCursor;
+ }
+ public int getHyperlinkUnderlineMode() {
+ return hyperlinkUnderlineMode;
+ }
+
+ public boolean isHyperlinkCursorUsed() {
+ return hyperlinkCursorUsed;
+ }
+
+ 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 setHyperlinkCursorUsed(boolean newHyperlinkCursorUsed) {
+ hyperlinkCursorUsed = newHyperlinkCursorUsed;
+ }
+ public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
+ hyperlinkUnderlineMode = newHyperlinkUnderlineMode;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/IHyperlinkListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/IHyperlinkListener.java
new file mode 100644
index 000000000..2cd7244d3
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/IHyperlinkListener.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import org.eclipse.swt.widgets.*;
+
+public interface IHyperlinkListener {
+ public void linkActivated(Control linkLabel);
+ public void linkEntered(Control linkLabel);
+ public void linkExited(Control linkLabel);
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/ILayoutExtension.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/ILayoutExtension.java
new file mode 100644
index 000000000..cb61ecbb2
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/ILayoutExtension.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.team.internal.ui.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 HTMLTableLayout manager. The said layout uses
+ * alternative algorithm that computes columns before rows.
+ * It allows it to 'flow' wrapped text proportionally
+ * (as in the popular web browsers). Custom layout managers
+ * that implement this interface allow recursive reflow
+ * to be performed.
+ */
+public interface ILayoutExtension {
+ public int getMinimumWidth(Composite parent, boolean changed);
+ public int getMaximumWidth(Composite parent, boolean changed);
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/SelectableFormLabel.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/SelectableFormLabel.java
new file mode 100644
index 000000000..cbcd75c97
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/widgets/SelectableFormLabel.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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.team.internal.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class SelectableFormLabel extends FormLabel {
+ private boolean hasFocus;
+
+ public boolean getSelection() {
+ return hasFocus;
+ }
+
+ /**
+ * Constructor for SelectableFormLabel
+ */
+ public SelectableFormLabel(Composite parent, int style) {
+ super(parent, style);
+ addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ if (e.character == '\r') {
+ // Activation
+ notifyListeners(SWT.DefaultSelection);
+ }
+ }
+ });
+ 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;
+ }
+ });
+ addFocusListener(new FocusListener() {
+ public void focusGained(FocusEvent e) {
+ if (!hasFocus) {
+ hasFocus=true;
+ notifyListeners(SWT.Selection);
+ redraw();
+ }
+ }
+ public void focusLost(FocusEvent e) {
+ if (hasFocus) {
+ hasFocus=false;
+ notifyListeners(SWT.Selection);
+ redraw();
+ }
+ }
+ });
+ textMarginWidth = 1;
+ textMarginHeight = 1;
+ }
+
+ 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_PUSHBUTTON;
+ }
+
+ public void getState(AccessibleControlEvent e) {
+ e.detail = SelectableFormLabel.this.getSelection()?ACC.STATE_SELECTED:ACC.STATE_NORMAL;
+ }
+ });
+ }
+
+ private void notifyListeners(int eventType) {
+ Event event = new Event();
+ event.type = eventType;
+ event.widget = this;
+ notifyListeners(eventType, event);
+ }
+
+ protected void paint(PaintEvent e) {
+ super.paint(e);
+ if (hasFocus) {
+ GC gc = e.gc;
+ Point size = getSize();
+ gc.setForeground(getForeground());
+ gc.drawFocus(0, 0, size.x, size.y);
+ }
+ }
+
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) return;
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+ }
+
+ public void removeSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) return;
+ removeListener (SWT.Selection, listener);
+ removeListener (SWT.DefaultSelection, listener);
+ }
+} \ No newline at end of file

Back to the top