diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference')
27 files changed, 0 insertions, 5600 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java deleted file mode 100644 index ffe8a64f0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.geometry.Transform;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
/**
* A figure decorator
*
*/
/*package*/ class BaseFigureDecorator extends Label implements RotatableDecoration
{
/**
* The default position for the decorator
*/
protected static int DEFAULT_DECORATOR_POSITION =
PositionConstants.SOUTH_WEST;
private Point location = new Point();
private Transform transform = new Transform();
private int position;
/**
* @param image
*/
public BaseFigureDecorator(Image image)
{
this.position = DEFAULT_DECORATOR_POSITION;
setIcon(image);
setSize(getPreferredSize());
}
/**
* @param image
* @param tooltip
*/
public BaseFigureDecorator(Image image, String tooltip)
{
this.position = DEFAULT_DECORATOR_POSITION;
setIcon(image);
setSize(getPreferredSize());
setToolTip(new Label(tooltip));
}
/**
* @param image
* @param tooltip
* @param position
*/
public BaseFigureDecorator(Image image, String tooltip, int position)
{
this.position = position;
setIcon(image);
setSize(getPreferredSize());
setToolTip(new Label(tooltip));
}
public Font getFont()
{
Font localFont = getLocalFont();
if (localFont == null)
{
localFont = JFaceResources.getFontRegistry().get(
JFaceResources.DEFAULT_FONT);
// TODO: it's not clear that setFont is correct to call
// here since this does a revalidate if the font changes
// whereas the deprecated assignment to font that it replaces
// does not
setFont(localFont);
}
return localFont;
}
/**
*
* @return Returns the position.
*
*/
public int getPosition()
{
return position;
}
/**
*
* @param position
*
* The position to set.
*
*/
public void setPosition(int position)
{
this.position = position;
}
/**
* @param tooltip
*/
public void setToolTipText(String tooltip)
{
super.setToolTip(new Label(tooltip));
}
/**
* @return the label tool tip text
*/
public String getToolTipText()
{
Label label = (Label) super.getToolTip();
return label.getText();
}
/**
*
* Sets the location of this PolygonDecoration.
*
*
*
* @param p
*
* the new location
*
*/
public void setLocation(Point p)
{
bounds = null;
location.setLocation(p);
transform.setTranslation(p.x, p.y);
}
public Rectangle getBounds()
{
if (bounds == null)
{
if (prefSize == null)
{
getPreferredSize();
}
int w = prefSize.width;
int h = prefSize.height;
Point p = location; // transform.getTransformed(new Point(w/2,h/2));
bounds = new Rectangle(p.x - w / 2, p.y - h / 2, w, h).getExpanded(
w, h);
}
return bounds;
}
/**
*
* @see org.eclipse.draw2d.Figure#useLocalCoordinates()
*
*/
protected boolean useLocalCoordinates()
{
return false;
}
/**
* @param x
* @param y
*/
public void setScale(double x, double y)
{
// TODO: figure out how to scale images
bounds = null;
transform.setScale(x, y);
}
/**
*
* Sets the rotation of this decoration so that the decoration points toward
* the
*
* given reference point.
*
* @param ref
* the reference point
*
* @see org.eclipse.draw2d.RotatableDecoration#setReferencePoint(org.eclipse.draw2d.geometry.Point)
*
*/
public void setReferencePoint(Point ref)
{
// TODO: figure out how to rotate images
bounds = null;
Point pt = Point.SINGLETON;
pt.setLocation(ref);
pt.negate().translate(location);
setRotation(Math.atan2(pt.y, pt.x));
}
/**
*
* Sets the angle by which rotation is to be done on the PolygonDecoration.
*
*
*
* @param angle
* Angle of rotation
*
* @since 2.0
*
*/
public void setRotation(double angle)
{
bounds = null;
// transform.setRotation(angle);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java deleted file mode 100644 index 096bef977..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java +++ /dev/null @@ -1,946 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayoutManager; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; - -/** - * The <code>BaseNodeFigure</code> class is the base class for all the figures - * representing DiagramNodes, ie those that can have ports with maxConnections - * to other nodes. - * - * Assumes that all NodeFigures have some number of input and output ports - * - * @author ddean - * - */ -/*package*/ class BaseNodeFigure extends Figure implements IBaseFigure { - private IBaseFigure baseFigure; - - private boolean anchorsVisible = true; - - private Hashtable connectionAnchors = new Hashtable(7); - - private Vector inputConnectionAnchors = new Vector(2, 2); - - private Vector outputConnectionAnchors = new Vector(2, 2); - - private Vector topConnectionAnchors = new Vector(); - - private Vector bottomConnectionAnchors = new Vector(); - - private Vector leftConnectionAnchors = new Vector(); - - private Vector rightConnectionAnchors = new Vector(); - - /** - * @param figure - */ - public BaseNodeFigure(IBaseFigure figure) { - setBaseFigure(figure); - ObserveVisibleXYLayout layout = new ObserveVisibleXYLayout(); - layout.setObserveVisibility(true); - setLayoutManager(layout); - } - - /** - * @param figure - */ - public void setBaseFigure(IBaseFigure figure) { - setBaseFigure(figure, new Rectangle(0, 0, -1, -1)); - } - - public void setHighlight(boolean flag) { - if (baseFigure != null) { - moveToTop(this, baseFigure); - baseFigure.setHighlight(flag); - } - } - - /** - * @param figure - * @param constraint - */ - public void setBaseFigure(IBaseFigure figure, Rectangle constraint) { - if (!getChildren().contains(figure)) { - if (getChildren().contains(baseFigure)) - remove(baseFigure); - - baseFigure = figure; - if (!getChildren().contains(baseFigure)) { - // CR389070: Figures are abbreviating rule figures names and - // making them unreadable - if (getParent() != null - && getParent().getLayoutManager() != null) { - Rectangle r = getBounds().getCopy(); - r.width = -1; - r.height = -1; - getParent().getLayoutManager().setConstraint(this, r); - } - // CR389495: Working with nested complex activities causes in - // the BP editor causes lockup - // ensure that constraints are set on figure before add() - this - // will cause a layout() - this.add(baseFigure, constraint, 0); - } - } - } - - /** - * @return the base figure - */ - public IBaseFigure getBaseFigure() { - return baseFigure; - } - - /*************************************************************************** - * Input/Output Ports - **************************************************************************/ - - /** - * Add an input port and its anchor - * - * @param portName - * unique name to refer to the port - */ - public void addInput(String portName) { - InputPortFigure inputPort = new InputPortFigure(); - add(inputPort); - inputPort.setToolTipText(portName); - - PortConnectionAnchor anchor = new PortConnectionAnchor(inputPort); - getTargetConnectionAnchors().add(anchor); - connectionAnchors.put(portName, anchor); - } - - /** - * Add an output port and its anchor - * - * @param portName - * unique name to refer to the port - * @return the connection anchor - */ - public PortConnectionAnchor addOutput(String portName) { - OutputPortFigure outputPort = new OutputPortFigure(); - add(outputPort); - outputPort.setToolTipText(portName); - - PortConnectionAnchor anchor = new PortConnectionAnchor(outputPort); - getSourceConnectionAnchors().add(anchor); - connectionAnchors.put(portName, anchor); - return anchor; - } - - /** - * Searches for and returns the anchor on this figure that is closest to the - * reference point <code>p</code> - * - * @param p - * the reference point - * @return the anchor on this figure that is closest to <code>p</code> - */ - public ConnectionAnchor connectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getSourceConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - e = getTargetConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns an anchor given its name - * - * @param portName - * name of the anchor - * @return the anchor with the name <code>portName</code> - */ - public ConnectionAnchor getConnectionAnchor(String portName) { - return (ConnectionAnchor) connectionAnchors.get(portName); - } - - /** - * returns the name of the specified anchor - * - * @param c - * the anchor whose name is requested - * @return the name of the specifed anchor - */ - public String getConnectionAnchorName(ConnectionAnchor c) { - Enumeration enumer = connectionAnchors.keys(); - String key; - while (enumer.hasMoreElements()) { - key = (String) enumer.nextElement(); - if (connectionAnchors.get(key).equals(c)) - return key; - } - return null; - } - - /** - * returns the source connection anchor that is closest to the reference - * point - * - * @param p - * the reference point - * @return the closest connection anchor to <code>p</code> - */ - public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getSourceConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns all the source connection anchors on this node figure - * - * @return a vector of all the source connection anchors for this figure - */ - public Vector getSourceConnectionAnchors() { - return outputConnectionAnchors; - } - - /** - * returns the target connection anchor that is closest to the reference - * point - * - * @param p - * the reference point - * @return the closest target connection anchor to <code>p</code> - */ - public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getTargetConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns all the target connection anchors on this node figure - * - * @return a vector of all the target connection anchors for this figure - */ - public Vector getTargetConnectionAnchors() { - return inputConnectionAnchors; - } - - /** - * Returns the name of the specified anchor - * - * @param anchor - * the connectio anchor whose name is requested - * @return the anchor's name - */ - public String getNameForAnchor(ConnectionAnchor anchor) { - if (anchor != null) { - Iterator it = connectionAnchors.keySet().iterator(); - String name; - - while (it.hasNext()) { - name = (String) it.next(); - - if (anchor.equals(connectionAnchors.get(name))) { - return name; - } - } - } - return null; - } - - /** - * @param visible - */ - public void setAnchorsVisible(boolean visible) { - if (anchorsVisible != visible) { - anchorsVisible = visible; - //ConnectionAnchor port; - List all = new ArrayList(); - all.addAll(getTargetConnectionAnchors()); - all.addAll(getSourceConnectionAnchors()); - Iterator it = all.iterator(); - while (it.hasNext()) { - IFigure fig = ((ConnectionAnchor) it.next()).getOwner(); - fig.setVisible(visible); - } - validate(); - } - } - - /** - * Determine which side of the figure to place each anchor based on the - * relative position (north, south, east or west) of the connection line's - * opposite anchor. If the anchor is not connected to anything else, the - * default is to place target (input) anchors on the left and source - * (output) anchors on the right. - */ - private void determineAnchorPositions() { - Iterator it; - topConnectionAnchors.clear(); - bottomConnectionAnchors.clear(); - leftConnectionAnchors.clear(); - rightConnectionAnchors.clear(); - - if (anchorsVisible) { - //final Dimension size = baseFigure.getPreferredSize(); - PortConnectionAnchor port; - - // start with outputs - it = getSourceConnectionAnchors().iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - int direction = port.getOrientation(); - if (direction == PositionConstants.NONE) { - Point loc = port.getOwner().getParent().getBounds() - .getLocation(); - // loc.x += size.width/2; - // loc.y += size.height/2; - Iterator itc = port.getConnections().iterator(); - if (itc.hasNext()) { - while (itc.hasNext()) { - PolylineConnection conn = (PolylineConnection) itc - .next(); - ConnectionAnchor otherPort; - if (port == conn.getSourceAnchor()) - otherPort = conn.getTargetAnchor(); - else - otherPort = conn.getSourceAnchor(); - if (otherPort.getOwner() == null) - continue; - Point otherLoc = otherPort.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize = - // ((BaseNodeFigure)otherPort.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc.x += otherSize.width/2; - // otherLoc.y += otherSize.height/2; - direction = loc.getPosition(otherLoc); - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.WEST) - leftConnectionAnchors.add(port); - else - rightConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(direction); - break; // currently, only the first connection is - // considered - } - } else { - rightConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(PositionConstants.EAST); - } - } else { - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.WEST) - leftConnectionAnchors.add(port); - else - rightConnectionAnchors.add(port); - } - } - it = getTargetConnectionAnchors().iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - int direction = port.getOrientation(); - if (direction == PositionConstants.NONE) { - Point loc = port.getOwner().getParent().getBounds() - .getLocation(); - // loc.x += size.width/2; - // loc.y += size.height/2; - Iterator itc = port.getConnections().iterator(); - if (itc.hasNext()) { - while (itc.hasNext()) { - PolylineConnection conn = (PolylineConnection) itc - .next(); - ConnectionAnchor otherPort; - if (port == conn.getSourceAnchor()) - otherPort = conn.getTargetAnchor(); - else - otherPort = conn.getSourceAnchor(); - if (otherPort.getOwner() == null) - continue; - Point otherLoc = otherPort.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize = - // ((BaseNodeFigure)otherPort.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc.x += otherSize.width/2; - // otherLoc.y += otherSize.height/2; - direction = loc.getPosition(otherLoc); - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.EAST) - rightConnectionAnchors.add(port); - else - leftConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(direction); - break; // currently, only the first connection is - // considered - } - } else { - leftConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(PositionConstants.WEST); - } - } else { - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.EAST) - rightConnectionAnchors.add(port); - else - leftConnectionAnchors.add(port); - } - } - - Comparator comparePorts = new Comparator() { - public int compare(Object arg0, Object arg1) { - PortConnectionAnchor port0 = (PortConnectionAnchor) arg0; - if (port0.getConnections().size() < 1) - return 0; - PortConnectionAnchor port1 = (PortConnectionAnchor) arg1; - if (port1.getConnections().size() < 1) - return 0; - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (port0.getOrientation() != PositionConstants.NONE) - return 0; - if (port1.getOrientation() != PositionConstants.NONE) - return 0; - - PolylineConnection conn0 = (PolylineConnection) port0 - .getConnections().get(0); - ConnectionAnchor otherPort0; - if (port0 == conn0.getSourceAnchor()) - otherPort0 = conn0.getTargetAnchor(); - else - otherPort0 = conn0.getSourceAnchor(); - Point otherLoc0 = otherPort0.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize0 = - // ((BaseNodeFigure)otherPort0.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc0.x += otherSize0.width/2; - // otherLoc0.y += otherSize0.height/2; - - PolylineConnection conn1 = (PolylineConnection) port1 - .getConnections().get(0); - ConnectionAnchor otherPort1; - if (port1 == conn1.getSourceAnchor()) - otherPort1 = conn1.getTargetAnchor(); - else - otherPort1 = conn1.getSourceAnchor(); - Point otherLoc1 = otherPort1.getOwner().getParent() - .getBounds().getLocation(); -// Dimension otherSize1 = ((BaseNodeFigure) otherPort1 -// .getOwner().getParent()).getBaseFigure() -// .getPreferredSize(); - // otherLoc1.x += otherSize1.width/2; - // otherLoc1.y += otherSize1.height/2; - - switch (((PortFigure) port0.getOwner()).getOrientation()) { - case PositionConstants.NORTH: - case PositionConstants.SOUTH: - return otherLoc0.x - otherLoc1.x; - case PositionConstants.EAST: - case PositionConstants.WEST: - return otherLoc0.y - otherLoc1.y; - } - return 0; - } - }; - - // order the anchors on each side so connection lines don't cross - Collections.sort(topConnectionAnchors, comparePorts); - Collections.sort(leftConnectionAnchors, comparePorts); - Collections.sort(bottomConnectionAnchors, comparePorts); - Collections.sort(rightConnectionAnchors, comparePorts); - } - } - - private void placeAnchors() { - determineAnchorPositions(); - if (anchorsVisible) { - Iterator it; - PortConnectionAnchor port; - int y, x; - - Dimension sz = baseFigure.getPreferredSize(); - LayoutManager layout = getLayoutManager(); - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - - // left ports - x = 0; - y = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // keep a constant inset on all 4 sides of the icon - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - y += (sz.height - (leftConnectionAnchors.size() * (d.height + FigureConstants.PORT_SPACING))) / 2; - it = leftConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - y += d.height + FigureConstants.PORT_SPACING; - } - - // right ports - x = sz.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - y = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - y += (sz.height - (rightConnectionAnchors.size() * (d.height + FigureConstants.PORT_SPACING))) / 2; - it = rightConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - y += d.height + FigureConstants.PORT_SPACING; - } - - // top ports - y = 0; - x = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - x += (sz.width - (topConnectionAnchors.size() * (d.width + FigureConstants.PORT_SPACING))) / 2; - it = topConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - x += d.width + FigureConstants.PORT_SPACING; - } - - // bottom ports - y = sz.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - x = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - x += (sz.width - (bottomConnectionAnchors.size() * (d.width + FigureConstants.PORT_SPACING))) / 2; - it = bottomConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - x += d.width + FigureConstants.PORT_SPACING; - } - } - } - - /** - * CR389070: Figures are abbreviating rule figures names and making them - * unreadable Anchor size is now dependent on icon size, not constant. Asks - * the connection anchor for its size. - */ - private Dimension getAnchorSize() { - Dimension d = new Dimension(FigureConstants.PORT_SIDE, - FigureConstants.PORT_SIDE); - if (!connectionAnchors.isEmpty()) { - Iterator iter = connectionAnchors.values().iterator(); - PortConnectionAnchor a = (PortConnectionAnchor) iter.next(); - d = a.getOwner().getPreferredSize(); - } - return d; - } - - /** - * @return the anchor insets - */ - protected final Insets getAnchorInsets() { - Insets in = new Insets(0, 0, 0, 0); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - in.left = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - in.right = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - in.top = d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - in.bottom = d.height; - return in; - } - - public void invalidate() { - super.invalidate(); - } - - /** - * validate method override to arrange the input and output ports around the - * links of the node figures - */ - public void validate() { - placeAnchors(); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - int x = 0; - int y = 0; - // if anchors are not visible (CompoundNodeFigure is maximized) always - // set position at 0,0 - if (anchorsVisible) { - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y = d.height; - } - getLayoutManager().setConstraint(baseFigure, - new Rectangle(x, y, -1, -1)); - layout(); - super.validate(); - } - - /*************************************************************************** - * Miscellaneous - **************************************************************************/ - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#useLocalCoordinates() - */ - protected boolean useLocalCoordinates() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#setBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setBounds(Rectangle rect) { - Rectangle r = rect.getCopy(); - r.x = 0; - r.y = 0; - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - { - r.x += d.width; - r.width -= d.width; - } - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - r.width -= d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - { - r.y += d.height; - r.height -= d.height; - } - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - r.height -= d.height; - } - baseFigure.setBounds(r); - r.setLocation(rect.getLocation()); - super.setBounds(r); - } - - public Rectangle getBounds() { - Dimension size = baseFigure.getBounds().getSize(); - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - size.height += d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - size.height += d.height; - } - Rectangle r = super.getBounds(); - r.setSize(size); - return r; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#getPreferredSize(int, int) - */ - public Dimension getPreferredSize(int wHint, int hHint) { - Dimension size = baseFigure.getPreferredSize(wHint, hHint).getCopy(); - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - size.height += d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - size.height += d.height; - } - return size; - } - - private static void moveToTop(IFigure parent, IFigure child) { - parent.getChildren().remove(child); - parent.getChildren().add(child); - } - - /** - * move to top layer - */ - protected final void moveToTop() { - IFigure parent = getParent(); - IFigure child = this; - while (parent != null && !(parent instanceof Layer)) { - child = parent; - parent = parent.getParent(); - } - if (parent instanceof Layer) { - parent.getChildren().remove(child); - parent.getChildren().add(child); - } - } - - /*************************************************************************** - * IBaseFigure methods delegate to the baseFigure - **************************************************************************/ - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText(java.lang.String) - */ - public void setText(String text) { - baseFigure.setText(text); - } - - public void setIcon(Image image) { - baseFigure.setIcon(image); - } - - /** - * The description property of a DiagramNode is displayed as a tool tip. - * This method is used to set it. Passing a null or zero-length string will - * remove the tool tip - * - * @param text - * the description to use for this node's tool tip - * - * @see IBaseFigure#setToolTipText(java.lang.String) - */ - public void setToolTipText(String text) { - baseFigure.setToolTipText(text); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(BaseFigureDecorator decorator) { - baseFigure.addDecorator(decorator); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - baseFigure.removeDecorator(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(int position) { - baseFigure.removeDecorator(position); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - return baseFigure.getDecorators(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - return baseFigure.getText(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - Rectangle r = baseFigure.getTextBounds().getCopy(); - r.x += getBounds().x; - r.y += getBounds().y; - return r; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return baseFigure.getIcon(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - return baseFigure.getToolTipText(); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java deleted file mode 100644 index f67bbaa28..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
*
* A field editor for a font type preference.
*
*/
/*package*/ class ColorFontFieldEditor extends FieldEditor {
private static final String ColorFontFieldEditor_ColorPref = "Color"; //$NON-NLS-1$
private static final int NUM_CONTROLS_WHEN_PREVIEWER = 4;
private static final int NUM_CONTROLS_WHEN_NO_PREVIEWER = 3;
/**
*
* The change font button, or <code>null</code> if none
*
* (before creation and after disposal).
*
*/
private Button changeFontButton = null;
/**
*
* The text for the change font button, or <code>null</code>
*
* if missing.
*
*/
private String changeButtonText;
/**
*
* The text for the preview, or <code>null</code> if no preview is desired
*
*/
private String previewText;
/**
*
* Font data for the chosen font button, or <code>null</code> if none.
*
*/
private FontData[] chosenFont;
/**
*
* Font color for the chosen font
*
*/
private RGB fontRGB;
/**
*
* The label that displays the selected font, or <code>null</code> if
* none.
*
*/
private Label valueControl;
/**
*
* The previewer, or <code>null</code> if none.
*
*/
private DefaultPreviewer previewer;
/**
*
* Internal font previewer implementation.
*
*/
private static class DefaultPreviewer {
private Text text;
private String string;
private Font font;
// private Color color;
/**
* @param s
* @param parent
*/
public DefaultPreviewer(String s, Composite parent) {
string = s;
text = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (font != null)
font.dispose();
}
});
if (string != null)
text.setText(string);
}
/**
* @return the text control
*/
public Control getControl() {
return text;
}
/**
* @param fontData
*/
public void setFont(FontData[] fontData) {
if (font != null && !font.isDisposed())
font.dispose();
font = new Font(text.getDisplay(), fontData);
text.setFont(font);
}
// /**
// * @param fontRGB
// */
// public void setRGB(RGB fontRGB) {
// if (fontRGB != null) {
// if (color != null && !color.isDisposed())
// color.dispose();
// color = new Color(null, fontRGB);
// text.setForeground(color);
// }
// }
/**
* @return the preferred extent
*/
public int getPreferredExtent() {
return 40;
}
}
/**
*
* Creates a new font field editor
*
*/
protected ColorFontFieldEditor() {
// control instantiation
}
/**
*
* Creates a font field editor with an optional preview area.
*
*
*
* @param name
* the name of the preference this field editor works on
*
* @param labelText
* the label text of the field editor
*
* @param previewAreaText
* the text used for the preview window. If it is
*
* <code>null</code> there will be no preview area,
*
* @param parent
* the parent of the field editor's control
*
*/
public ColorFontFieldEditor(
String name,
String labelText,
String previewAreaText,
Composite parent) {
init(name, labelText);
previewText = previewAreaText;
changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$
createControl(parent);
}
/**
*
* Creates a font field editor without a preview.
*
*
*
* @param name
* the name of the preference this field editor works on
*
* @param labelText
* the label text of the field editor
*
* @param parent
* the parent of the field editor's control
*
*/
public ColorFontFieldEditor(String name, String labelText, Composite parent) {
this(name, labelText, null, parent);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void adjustForNumColumns(int numColumns) {
GridData data = new GridData();
if (valueControl.getLayoutData() != null)
data = (GridData) valueControl.getLayoutData();
data.horizontalSpan = numColumns - getNumberOfControls() + 1;
valueControl.setLayoutData(data);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void applyFont() {
if (chosenFont != null && previewer != null)
previewer.setFont(chosenFont);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
getLabelControl(parent);
valueControl = getValueControl(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL
| GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = numColumns - getNumberOfControls() + 1;
valueControl.setLayoutData(gd);
if (previewText != null) {
previewer = new DefaultPreviewer(previewText, parent);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = previewer.getPreferredExtent();
gd.widthHint = previewer.getPreferredExtent();
previewer.getControl().setLayoutData(gd);
}
changeFontButton = getChangeControl(parent);
gd = new GridData();
int widthHint = convertHorizontalDLUsToPixels(changeFontButton,
IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max(widthHint, changeFontButton.computeSize(
SWT.DEFAULT, SWT.DEFAULT, true).x);
changeFontButton.setLayoutData(gd);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doLoad() {
if (changeFontButton == null)
return;
fontRGB = PreferenceConverter.getColor(getPreferenceStore(),
getPreferenceName() + ColorFontFieldEditor_ColorPref);
updateFont(PreferenceConverter.getFontDataArray(getPreferenceStore(),
getPreferenceName()));
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doLoadDefault() {
if (changeFontButton == null)
return;
updateFont(PreferenceConverter.getDefaultFontDataArray(
getPreferenceStore(), getPreferenceName()));
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doStore() {
if (chosenFont != null) {
PreferenceConverter.setValue(getPreferenceStore(),
getPreferenceName(), chosenFont);
}
if (fontRGB != null) {
PreferenceConverter.setValue(getPreferenceStore(),
getPreferenceName() + ColorFontFieldEditor_ColorPref, fontRGB);
}
}
/**
*
* Returns the change button for this field editor.
*
*
* @param parent
* @return the change button
*
*/
protected Button getChangeControl(Composite parent) {
if (changeFontButton == null) {
changeFontButton = new Button(parent, SWT.PUSH);
if (changeButtonText != null)
changeFontButton.setText(changeButtonText);
changeFontButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FontDialog fontDialog = new FontDialog(changeFontButton
.getShell());
if (chosenFont != null)
fontDialog.setFontList(chosenFont);
if (fontRGB != null)
fontDialog.setRGB(fontRGB);
FontData font = fontDialog.open();
if (font != null) {
FontData[] oldFont = chosenFont;
if (oldFont == null)
oldFont = JFaceResources.getDefaultFont()
.getFontData();
setPresentsDefaultValue(false);
FontData[] newData = new FontData[1];
newData[0] = font;
fontRGB = fontDialog.getRGB();
updateFont(newData);
fireValueChanged(VALUE, oldFont[0], font);
}
}
});
changeFontButton.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
changeFontButton = null;
}
});
changeFontButton.setFont(parent.getFont());
setButtonLayoutData(changeFontButton);
} else
checkParent(changeFontButton, parent);
return changeFontButton;
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
public int getNumberOfControls() {
if (previewer == null)
{
return NUM_CONTROLS_WHEN_NO_PREVIEWER;
}
return NUM_CONTROLS_WHEN_PREVIEWER;
}
/**
*
* Returns the preferred preview height.
*
*
*
* @return the height, or <code>-1</code> if no previewer
*
* is installed
*
*/
public int getPreferredPreviewHeight() {
if (previewer == null)
return -1;
return previewer.getPreferredExtent();
}
/**
*
* Returns the preview control for this field editor.
*
*
*
* @return the preview control
*
*/
public Control getPreviewControl() {
if (previewer == null)
return null;
return previewer.getControl();
}
/**
*
* Returns the value control for this field editor. The value control
*
* displays the currently selected font name.
* @param parent
*
*
*
* @return the value control
*
*/
protected Label getValueControl(Composite parent) {
if (valueControl == null) {
valueControl = new Label(parent, SWT.LEFT);
valueControl.setFont(parent.getFont());
valueControl.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
valueControl = null;
}
});
} else
checkParent(valueControl, parent);
return valueControl;
}
/**
*
* Sets the text of the change button.
*
*
*
* @param text
* the new text
*
*/
public void setChangeButtonText(String text) {
Assert.isNotNull(text);
changeButtonText = text;
if (changeFontButton != null)
changeFontButton.setText(text);
}
/**
*
* Updates the change font button and the previewer to reflect the
*
* newly selected font.
*
*/
private void updateFont(FontData font[]) {
FontData[] bestFont = JFaceResources.getFontRegistry().filterData(
font, valueControl.getDisplay());
// if we have nothing valid do as best we can
if (bestFont == null)
bestFont = getDefaultFontData();
// Now cache this value in the receiver
this.chosenFont = bestFont;
if (valueControl != null) {
if (fontRGB != null) {
ColorRegistry registry = JFaceResources.getColorRegistry();
Color color = registry.get(fontRGB.toString());
if (color == null) {
registry.put(fontRGB.toString(), fontRGB);
color = registry.get(fontRGB.toString());
}
valueControl.setForeground(color);
}
valueControl.setText(StringConverter.asString(chosenFont[0]));
}
if (previewer != null) {
previewer.setFont(bestFont);
}
}
/**
*
* Store the default preference for the field
*
* being edited
*
*/
protected void setToDefault() {
FontData[] defaultFontData = PreferenceConverter
.getDefaultFontDataArray(getPreferenceStore(),
getPreferenceName());
PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(),
defaultFontData);
}
/**
*
* Get the system default font data.
*
*/
private FontData[] getDefaultFontData() {
return valueControl.getDisplay().getSystemFont().getFontData();
}
/*
*
* @see FieldEditor.setEnabled(boolean,Composite).
*
*/
public void setEnabled(boolean enabled, Composite parent) {
super.setEnabled(enabled, parent);
getChangeControl(parent).setEnabled(enabled);
getValueControl(parent).setEnabled(enabled);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java deleted file mode 100644 index 53ce7b21c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* A field editor for a combo box that allows the drop-down selection of one of
* a list of items.
*
*/
/*package*/ class ComboFieldEditor extends FieldEditor {
/**
*
* The <code>Combo</code> widget.
*
*/
private Combo fCombo;
/**
*
* The value (not the name) of the currently selected item in the Combo
* widget.
*
*/
private String fValue;
/**
*
* The names (labels) and underlying values to populate the combo widget.
* These should be
*
* arranged as: { {name1, value1}, {name2, value2}, ...}
*
*/
private String[][] fEntryNamesAndValues;
/**
* @param name
* @param labelText
* @param entryNamesAndValues
* @param parent
*/
public ComboFieldEditor(String name, String labelText,
String[][] entryNamesAndValues, Composite parent) {
init(name, labelText);
Assert.isTrue(checkArray(entryNamesAndValues));
fEntryNamesAndValues = entryNamesAndValues;
createControl(parent);
}
/**
*
* Checks whether given <code>String[][]</code> is of "type"
*
* <code>String[][2]</code>.
*
*
*
* @return <code>true</code> if it is ok, and <code>false</code>
* otherwise
*
*/
private boolean checkArray(String[][] table) {
if (table == null) {
return false;
}
for (int i = 0; i < table.length; i++) {
String[] array = table[i];
if (array == null || array.length != 2) {
return false;
}
}
return true;
}
/**
*
* @see FieldEditor#adjustForNumColumns(int)
*
*/
protected void adjustForNumColumns(int numColumns) {
if (numColumns > 1) {
Control control = getLabelControl();
int left = numColumns;
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
left = left - 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = left;
} else {
Control control = getLabelControl();
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = 1;
}
}
/**
*
* @see FieldEditor#doFillIntoGrid(Composite, int)
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
int comboC = 1;
if (numColumns > 1) {
comboC = numColumns - 1;
}
Control control = getLabelControl(parent);
GridData gd = new GridData();
gd.horizontalSpan = 1;
control.setLayoutData(gd);
control = getComboBoxControl(parent);
gd = new GridData();
gd.horizontalSpan = comboC;
gd.horizontalAlignment = GridData.FILL;
control.setLayoutData(gd);
}
/**
*
* @see FieldEditor#doLoad()
*
*/
protected void doLoad() {
updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
}
/**
*
* @see FieldEditor#doLoadDefault()
*
*/
protected void doLoadDefault() {
updateComboForValue(getPreferenceStore().getDefaultString(
getPreferenceName()));
}
/**
*
* @see FieldEditor#doStore()
*
*/
protected void doStore() {
if (fValue == null) {
getPreferenceStore().setToDefault(getPreferenceName());
return;
}
getPreferenceStore().setValue(getPreferenceName(), fValue);
}
/**
*
* @see FieldEditor#getNumberOfControls()
*
*/
public int getNumberOfControls() {
return 1;
}
/**
*
* Lazily create and return the Combo control.
* @param parent
* @return the combo box
*
*/
public Combo getComboBoxControl(Composite parent) {
if (fCombo == null) {
fCombo = new Combo(parent, SWT.READ_ONLY);
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
fCombo.add(fEntryNamesAndValues[i][0], i);
}
fCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
String oldValue = fValue;
String name = fCombo.getText();
fValue = getValueForName(name);
setPresentsDefaultValue(false);
fireValueChanged(VALUE, oldValue, fValue);
}
});
}
return fCombo;
}
/**
*
* Given the name (label) of an entry, return the corresponding value.
* @param name
* @return the value corresponding to name or the first value if
* not found
*
*/
protected String getValueForName(String name) {
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
String[] entry = fEntryNamesAndValues[i];
if (name.equals(entry[0])) {
return entry[1];
}
}
return fEntryNamesAndValues[0][0];
}
/**
*
* Set the name in the combo widget to match the specified value.
* @param value
*
*/
protected void updateComboForValue(String value) {
fValue = value;
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
if (value.equals(fEntryNamesAndValues[i][1])) {
fCombo.setText(fEntryNamesAndValues[i][0]);
return;
}
}
if (fEntryNamesAndValues.length > 0) {
fValue = fEntryNamesAndValues[0][1];
}
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java deleted file mode 100644 index c2646482f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -/** - * @author bbrodt - * - * Interface definition for listeners of CompoundFigure events. Events are - * generated when a user presses a different tab (tabChanged event) or presses - * one of the minimize/maximize/restore buttons (stateChanged event) - */ -/*package*/ interface CompoundFigureListener extends WindowFigureListener { - /** - * @param oldState - * @param newState - */ - void stateChanged(int oldState, int newState); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java deleted file mode 100644 index 8de3c5eec..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java +++ /dev/null @@ -1,480 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; - -import org.eclipse.draw2d.ActionEvent; -import org.eclipse.draw2d.ActionListener; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayoutManager; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * The figure for Compound nodes - */ -/*package*/ class CompoundNodeFigure extends BaseNodeFigure implements - FreeformFigure, IContainerFigure { - - private static final String RESTORE_HILITE_IMAGE_FILE = "restore_hilite.gif"; //$NON-NLS-1$ - - private static final String RESTORE_IMAGE_FILE = "restore.gif"; //$NON-NLS-1$ - - private static final String MAXIMIZE_HILITE_IMAGE_FILE = "maximize_hilite.gif"; //$NON-NLS-1$ - - private static final String MAXIMIZE_IMAGE_FILE = "maximize.gif"; //$NON-NLS-1$ - - private static final String MINIMIZE_HILITE_IMAGE_FILE = "minimize_hilite.gif"; //$NON-NLS-1$ - - private static final String MINIMIZE_IMAGE_FILE = "minimize.gif"; //$NON-NLS-1$ - - private final static int MINIMIZED = 1; - - final static int RESTORED = 2; - - private final static int MAXIMIZED = 3; - - private int state = RESTORED; - - private TitleBarButton minButton; - - private TitleBarButton maxButton; - - private IconFigure iconFigure; - - private WindowFigure windowFigure; - - private static String DEFAULT_NAME = "CompoundNode"; //$NON-NLS-1$ - - private static String DEFAULT_ICON = "editor/CompoundNode.gif"; //$NON-NLS-1$ - - private static Image minimizeImage = EditorPlugin.getDefault().getImage( - MINIMIZE_IMAGE_FILE); - - private static Image minimizeHiliteImage = EditorPlugin.getDefault() - .getImage(MINIMIZE_HILITE_IMAGE_FILE); - - private static Image maximizeImage = EditorPlugin.getDefault().getImage( - MAXIMIZE_IMAGE_FILE); - - private static Image maximizeHiliteImage = EditorPlugin.getDefault() - .getImage(MAXIMIZE_HILITE_IMAGE_FILE); - - private static Image restoreImage = EditorPlugin.getDefault().getImage( - RESTORE_IMAGE_FILE); - - private static Image restoreHiliteImage = EditorPlugin.getDefault() - .getImage(RESTORE_HILITE_IMAGE_FILE); - - /** - * Default constructor - */ - public CompoundNodeFigure() { - // create all of the figures and adornments: - // the icon figure - super(new IconFigure(DEFAULT_NAME, EditorPlugin.getDefault().getImage( - DEFAULT_ICON))); - iconFigure = (IconFigure) getBaseFigure(); - // and the window figure - windowFigure = new WindowFigure(); - windowFigure.setForegroundColor(IconFigure.defaultForegroundColor); - windowFigure.setFont(IconFigure.defaultFont); - - // then the minimize/maximize buttons. - // Note that the maxButton is also used for the "Restore" action - // TODO: - // The reason for putting these buttons in CompoundNodeFigure instead of - // WindowFigure where they really belong, is that the TitleBarButton is - // a - // draw2d Button (which subclasses Figure) and these must be placed in - // the - // titlebar (i.e. a SchemeBorder) because that's where they belong. The - // problem - // with this is that the Figure.paint() method first draws all of its - // children - // figures, then the border which means that the buttons would be - // obscured. - // This should be fixed as time allows and the WindowFigureListener - // interface - // should then also be modified to include a buttonPressed() - // notification - // for which CompoundNodeFigure can be a listener. - minButton = new TitleBarButton(minimizeImage, minimizeHiliteImage, - null, null); - maxButton = new TitleBarButton(maximizeImage, maximizeHiliteImage, - restoreImage, restoreHiliteImage); - - add(minButton); - add(maxButton); - - minButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(CompoundNodeFigure.MINIMIZED); - } - }); - maxButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(maxButton.getState() ? CompoundNodeFigure.MAXIMIZED - : CompoundNodeFigure.RESTORED); - } - }); - - // show as a normal window initially - showIcon(); - - // testing BaseFigureDecorators: - // BaseFigureDecorator decorator; - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "top right", - // PositionConstants.NORTH_EAST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "top left", - // PositionConstants.NORTH_WEST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "bottom right", - // PositionConstants.SOUTH_EAST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "bottom left", - // PositionConstants.SOUTH_WEST); - // addDecorator(decorator); - } - - public void setOpaque(boolean flag) { - windowFigure.setOpaque(flag); - } - - /* - * Remove the window figure and its buttons and replace them with the icon - * figure. - */ - private void showIcon() { - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(false); - minButton.setVisible(false); - maxButton.setVisible(false); - super.setBaseFigure(iconFigure); - - setAnchorsVisible(true); - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(true); - } - - /* - * Remove the icon figure and replace with the window figure. Make sure the - * buttons are reset to their correct states. - */ - private void showWindow() { - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(false); - if (state == RESTORED) { - super.setBaseFigure(windowFigure); - - minButton.setVisible(true); - minButton.setState(false); - minButton.setToolTip(new Label(PreferenceMessages.CompoundNodeFigure_MinimizeLabel)); - - maxButton.setVisible(true); - maxButton.setState(false); - maxButton.setToolTip(new Label(PreferenceMessages.CompoundNodeFigure_MaximizeLabel)); - - setAnchorsVisible(true); - } else if (state == MAXIMIZED) { - setAnchorsVisible(false); - - Rectangle constraint = new Rectangle(0, 0, -1, -1); - IFigure parent = getParent(); - if (parent != null) { - constraint = parent.getBounds().getCopy(); - constraint.width += constraint.x; - constraint.height += constraint.y; - constraint.x = 0; - constraint.y = 0; - } - - super.setBaseFigure(windowFigure, constraint); - if (parent != null && parent.getLayoutManager() != null) { - // System.out.println("CompoundNode.showWindow: maximize - // "+constraint); - parent.getLayoutManager().setConstraint(this, constraint); - } - - // the maximize button is used for both Maximize and Restore actions - minButton.setVisible(false); - - maxButton.setVisible(true); - maxButton.setState(true); - maxButton.setToolTip(new Label(PreferenceMessages.CompoundNodeFigure_RestoreLabel)); - } - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(true); - } - - public void addDecorator(BaseFigureDecorator decorator) { - iconFigure.addDecorator(decorator); - } - - public void removeDecorator() { - iconFigure.removeDecorator(); - } - - public void removeDecorator(int position) { - iconFigure.removeDecorator(position); - } - - /** - * @param flag - */ - public void setHilight(boolean flag) { - windowFigure.setHighlight(flag); - if (flag) - moveToTop(); - } - - public void setText(String name) { - iconFigure.setText(name); - windowFigure.setText(name); - } - - public void setIcon(Image image) { - iconFigure.setIcon(image); - } - - public void setToolTipText(String text) { - iconFigure.setToolTipText(text); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#layout() - */ - public void validate() { - LayoutManager layout = getLayoutManager(); - if (state == MINIMIZED) { - // iconFigure.validate(); - } else if (state == RESTORED) { - Rectangle r = windowFigure.getBounds().getCopy(); - Insets i = windowFigure.getInsets(); - Dimension dm = maxButton.getSize(); - Insets p = windowFigure.getTabbedTitleBarBorder().getPadding(); - layout.setConstraint(maxButton, new Rectangle(r.x + r.width - - dm.width - p.right - i.right, r.y + p.top + i.top - - dm.height - i.bottom, -1, -1)); - layout.setConstraint(minButton, new Rectangle(r.x + r.width - 2 - * dm.width - 2 * p.right - i.right, r.y + p.top + i.top - - dm.height - i.bottom, -1, -1)); - } else if (state == MAXIMIZED) { - // CR387660: restore icon on complex activity bounces around - // we need to use the parent's bounds when maximized instead of - // current window bounds - if (getParent() == null) - return; - Rectangle r = getParent().getBounds().getCopy(); - Insets i = windowFigure.getInsets(); - Dimension dm = maxButton.getSize(); - Insets p = windowFigure.getTabbedTitleBarBorder().getPadding(); - layout.setConstraint(maxButton, new Rectangle(r.x + r.width - - dm.width - p.right - i.right, r.y + p.top, -1, -1)); - } - super.validate(); - } - /** - * @return the window figure - */ - public WindowFigure getWindowFigure() { - return windowFigure; - } - - public void setFont(Font f) { - iconFigure.setFont(f); - windowFigure.setFont(f); - } - - public void setForegroundColor(Color c) { - iconFigure.setForegroundColor(c); - windowFigure.setForegroundColor(c); - } - - public void setBackgroundColor(Color c) { - iconFigure.setBackgroundColor(c); - windowFigure.setBackgroundColor(c); - } - - /** - * @return the state - */ - public int getState() { - return state; - } - - /** - * @param newState - */ - public void setState(int newState) { - int oldState = state; - state = newState; - - if (state == CompoundNodeFigure.MINIMIZED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.width = -1; - constraint.height = -1; - } - showIcon(); - } else if (state == CompoundNodeFigure.MAXIMIZED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.x = 0; - constraint.y = 0; - constraint.width = -1; - constraint.height = -1; - } - showWindow(); - } else if (state == CompoundNodeFigure.RESTORED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.setSize(windowFigure.getBounds().getSize()); - } - showWindow(); - } - fireStateChanged(oldState, newState); - } - - private void fireStateChanged(int oldState, int newState) { - Object l[] = windowFigure.getTabbedTitleBarBorder().getListeners(); - for (int i = 0; i < l.length; ++i) { - if (l[i] instanceof CompoundFigureListener) - ((CompoundFigureListener) l[i]) - .stateChanged(oldState, newState); - } - } - - public Dimension getMinimumSize(int wHint, int hHint) { - if (getState() == CompoundNodeFigure.RESTORED) { - Dimension d = windowFigure.getMinimumSize(wHint, hHint); - d.width += minButton.getSize().width - + maxButton.getSize().width - + 2 - * windowFigure.getTabbedTitleBarBorder().getPadding() - .getWidth(); - return d; - } - if (getState() == CompoundNodeFigure.MINIMIZED) - return iconFigure.getMinimumSize(wHint, hHint); - return super.getMinimumSize(wHint, hHint); - } - - // ////////////////////////////////////////////////////////////////////// - // FreeformFigure methods - // ////////////////////////////////////////////////////////////////////// - - private WindowFreeformHelper helper = new WindowFreeformHelper(this); - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#addFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void addFreeformListener(FreeformListener listener) { - addListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#fireExtentChanged() - */ - public void fireExtentChanged() { - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // not specifically related to this CR, but caused a problem when - // compound node - // was moved beyond viewport's client area and de-selected - this would - // resize - // the viewport so that compound node no longer participated in bounds - // calculation. - if (state == MAXIMIZED) { - Iterator iter = getListeners(FreeformListener.class); - while (iter.hasNext()) - ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#getFreeformExtent() - */ - public Rectangle getFreeformExtent() { - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // same as above - if (state == MAXIMIZED) - return helper.getFreeformExtent(); - return getBounds(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#removeFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void removeFreeformListener(FreeformListener listener) { - removeListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - if (getState() == MAXIMIZED) - helper.setFreeformBounds(bounds); - } - - /* - * CR389070: Figures are abbreviating rule figures names and making them - * unreadable New Method on IContainerFigure - * - * @see com.sybase.stf.gem.diagram.editor.figures.IContainerFigure#getLayer(java.lang.Object) - */ - public Layer getLayer(Object key) { - if (windowFigure != null && windowFigure.isVisible()) - return windowFigure.getLayer(key); - return null; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java deleted file mode 100644 index bb57abe47..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
/**
*
*
*
* Constants for figure dimensions, etc. used in the sample app
*
*/
/*package*/ class FigureConstants
{
/**
*
*
*
*/
private FigureConstants()
{
// no external instantiation
}
/**
* the default dimension of a port anchor
*/
public static final int PORT_SIDE = 10; // (int)Math.round( ARROW_SIDE *
// Math.cos( 30 ) );
// CR389070: Figures are abbreviating rule figures names and making them
// unreadable
/**
* the y port spacing value
*/
public static final int PORT_SPACING = 2; // ARROW_SIDE / 2;
// this is the type of port; input or output
/**
* identifies a port that is an input
*/
public static int INPUT_PORT = 0;
/**
* identifies a port that is an output
*/
public static int OUTPUT_PORT = 1;
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java deleted file mode 100644 index 790f2c51c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java +++ /dev/null @@ -1,834 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.ColorFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ColorRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * This class represents a preference page that is contributed to the - * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>, - * we can use the field support built into JFace that allows us to create a page - * that is small and knows how to save, restore and apply itself. - * <p> - * This page is used to modify preferences only. They are stored in the - * preference store that belongs to the main plug-in class. That way, - * preferences can be accessed directly via the preference store. - */ - -public final class GEMPreferences extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - // appearance - /** - * Key for preference for whether or not the intro editor should be shown - */ - public final static String SHOW_INTRO_EDITOR = "ShowIntroEditor"; //$NON-NLS-1$ - - /** - * use system colors preference - */ - public final static String USE_SYSTEM_COLORS = "UseSystemColors"; //$NON-NLS-1$ - - /** - * canvas color preference - */ - public final static String CANVAS_COLOR = "CanvasColor"; //$NON-NLS-1$ - - /** - * figure label font - */ - public final static String FIGURE_LABEL_FONT = "FigureLabelFont"; //$NON-NLS-1$ - - /** - * - */ - public final static String FIGURE_LABEL_FONT_COLOR = "FigureLabelFontColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String LABEL_PLACEMENT = "LabelPlacement"; //$NON-NLS-1$ - - /** - * - */ - public final static String INPUT_PORT_COLOR = "InputPortColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String OUTPUT_PORT_COLOR = "OutputPortColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String SHOW_LINE_LABELS = "ShowLineLabels"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_LABEL_FONT = "LineLabelFont"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_LABEL_FONT_COLOR = "LineLabelFontColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_LABEL_COLOR = "LineLabelColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_WIDTH = "LineWidth"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_COLOR = "LineColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String LINE_ROUTING = "LineRouting"; //$NON-NLS-1$ - - /** - * - */ - public final static String SNAP_TO_GRID = "SnapToGrid"; //$NON-NLS-1$ - - /** - * - */ - public final static String SNAP_TO_GEOMETRY = "SnapToGeometry"; //$NON-NLS-1$ - - /** - * - */ - public final static String GRID_WIDTH = "GridWidth"; //$NON-NLS-1$ - - /** - * - */ - public final static String GRID_HEIGHT = "GridHeight"; //$NON-NLS-1$ - - /** - * - */ - public final static String GRID_COLOR = "GridColor"; //$NON-NLS-1$ - - /** - * - */ - public final static String LABEL_PLACEMENT_TOP = "Top"; //$NON-NLS-1$ - - /** - * - */ - public final static String LABEL_PLACEMENT_BOTTOM = "Bottom"; //$NON-NLS-1$ - - /** - * - */ - public final static String LABEL_PLACEMENT_LEFT = "Left"; //$NON-NLS-1$ - - /** - * - */ - public final static String LABEL_PLACEMENT_RIGHT = "Right"; //$NON-NLS-1$ - - // - /** - * "Direct" routing was intended for connections lines without bendpoints; - * this has been removed because it is unnecessary. - * public final static String LINE_ROUTING_DIRECT = "Direct"; - * "Manhattan" line routing creates orthogonal lines - */ - public final static String LINE_ROUTING_MANHATTAN = "Manhattan"; //$NON-NLS-1$ - - /** - * "Manual" routing allows user to create bendpoints - */ - public final static String LINE_ROUTING_MANUAL = "Manaul"; //$NON-NLS-1$ - - private final static String[][] m_lineRoutingLabels = { - // display, key - // { GEMPlugin.getResourceString("CanvasPreferences.LABEL.Direct"), - // LINE_ROUTING_DIRECT }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Manual, LINE_ROUTING_MANUAL }, - { - PreferenceMessages.CanvasPreferences_LABEL_Manhattan, LINE_ROUTING_MANHATTAN } - }; - - private final static String[][] m_labelPlacementLabels = { - { - PreferenceMessages.CanvasPreferences_LABEL_Top, LABEL_PLACEMENT_TOP }, - { - PreferenceMessages.CanvasPreferences_LABEL_Bottom, LABEL_PLACEMENT_BOTTOM }, - { - PreferenceMessages.CanvasPreferences_LABEL_Left, LABEL_PLACEMENT_LEFT }, - { - PreferenceMessages.CanvasPreferences_LABEL_Right, LABEL_PLACEMENT_RIGHT } - }; - - private Group canvasGroup; - - private Group iconGroup; - - private Group lineGroup; - - private BooleanField useSystemColors; - - private ColorFieldEditor canvasColor; - - private BooleanField snapToGrid; - - private IntegerFieldEditor gridWidth; - - private IntegerFieldEditor gridHeight; - - private ColorFieldEditor gridColor; - - private BooleanField showLineLabels; - - private ColorFieldEditor lineLabelColor; - - private ColorFieldEditor lineColor; - - private ColorFontFieldEditor iconFont; - - private ColorFontFieldEditor lineFont; - - // private ColorFieldEditor inputPortColor; - // - // private ColorFieldEditor outputPortColor; - - // CR392586: resource leaks - // at least keep leaks bounded... -// private static Hashtable resourceRegistry = new Hashtable(); - - private class BooleanField extends BooleanFieldEditor { - private Composite parent; - - /** - * @param name - * @param label - * @param parent - */ - public BooleanField(String name, String label, Composite parent) { - super(name, label, parent); - this.parent = parent; - } - - /** - * @return the change control button - */ - public Button getButton() { - return getChangeControl(parent); - } - } - - /** - * Constructor - */ - public GEMPreferences() { - super(GRID); - // FIXME: we should be encapsulating what pref store is used for all callers of this class - setPreferenceStore(EditorPlugin.getDefault().getPreferenceStore()); - setDescription(PreferenceMessages.GEMPreferences_description); - } - - /** - * Sets the default values of the preferences. - */ - public static void initializeDefaults() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - Font f = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - store.setDefault(SHOW_INTRO_EDITOR, true); - store.setDefault(USE_SYSTEM_COLORS, true); - PreferenceConverter.setDefault(store, CANVAS_COLOR, new RGB(255, 255, - 255)); - PreferenceConverter.setDefault(store, FIGURE_LABEL_FONT, f - .getFontData()); - store.setDefault(LINE_WIDTH, 1); - store.setDefault(LINE_ROUTING, getLineRoutingLabels()[0][1]); - store.setDefault(SHOW_LINE_LABELS, true); - PreferenceConverter.setDefault(store, LINE_COLOR, new RGB(0, 0, 0)); - PreferenceConverter.setDefault(store, LINE_LABEL_COLOR, new RGB(255, - 255, 255)); - PreferenceConverter.setDefault(store, LINE_LABEL_FONT, f.getFontData()); - store.setDefault(SNAP_TO_GEOMETRY, true); - store.setDefault(SNAP_TO_GRID, true); - store.setDefault(GRID_WIDTH, 12); - store.setDefault(GRID_HEIGHT, 12); - PreferenceConverter.setDefault(store, GRID_COLOR, - new RGB(230, 230, 230)); - store.setDefault(LABEL_PLACEMENT, LABEL_PLACEMENT_BOTTOM); - } - - /** - * Creates the field editors. Field editors are abstractions of the common - * GUI blocks needed to manipulate various types of preferences. Each field - * editor knows how to save and restore itself. - */ - - public void createFieldEditors() { - - // note, we aren't saving the reference. It's assumed that parent - // worries about destruction, persistence etc. - addBooleanField( - SHOW_INTRO_EDITOR, - PreferenceMessages.EditorPreferences_LABEL_ShowIntroEditor, - getFieldEditorParent()); - - useSystemColors = addBooleanField( - USE_SYSTEM_COLORS, - PreferenceMessages.CanvasPreferenceTab_LABEL_UseSystemColors, - getFieldEditorParent()); - - canvasGroup = new Group(getFieldEditorParent(), SWT.NULL); - lineGroup = new Group(getFieldEditorParent(), SWT.NULL); - iconGroup = new Group(getFieldEditorParent(), SWT.NULL); - - canvasGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_Canvas); - canvasColor = addColorField( - CANVAS_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_BackgroundColor, canvasGroup); - // Fix for Bug 268443: [hotbug] FacesConfig Editor preferences page needs more info for screen readers - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=268443 - canvasColor.getColorSelector().getButton().getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_BackgroundColor; - } - }); - - addBooleanField( - SNAP_TO_GEOMETRY, - PreferenceMessages.CanvasPreferenceTab_LABEL_SnapToGeometry, canvasGroup); - snapToGrid = addBooleanField( - SNAP_TO_GRID, - PreferenceMessages.CanvasPreferenceTab_LABEL_SnapToGrid, canvasGroup); - gridColor = addColorField( - GRID_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridLineColor, canvasGroup); - gridColor.getColorSelector().getButton().getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_GridLineColor; - } - }); - gridWidth = addIntegerField( - GRID_WIDTH, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridWidth, canvasGroup); - gridHeight = addIntegerField( - GRID_HEIGHT, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridHeight, canvasGroup); - - iconGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_IconGroup); - iconFont = addFontField( - FIGURE_LABEL_FONT, - PreferenceMessages.CanvasPreferenceTab_LABEL_IconLabelFont, iconGroup); - iconFont.getChangeControl(iconGroup).getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_IconLabelFont; - } - }); - addComboField(LABEL_PLACEMENT, PreferenceMessages.CanvasPreferenceTab_LABEL_LabelPlacement, - getLabelPlacementLabels(), iconGroup); - // inputPortColor = addColorField( - // INPUT_PORT_COLOR, - // EditorPlugin - // .getResourceString("CanvasPreferenceTab.LABEL.InputPortColor"), - // iconGroup); //$NON-NLS-1$ - // outputPortColor = addColorField( - // OUTPUT_PORT_COLOR, - // EditorPlugin - // .getResourceString("CanvasPreferenceTab.LABEL.OutputPortColor"), - // iconGroup); //$NON-NLS-1$ - - lineGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_LineGroup); - showLineLabels = addBooleanField(SHOW_LINE_LABELS, PreferenceMessages.CanvasPreferenceTab_LABEL_ShowLineLabels, - lineGroup); - lineFont = addFontField( - LINE_LABEL_FONT, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelFont, lineGroup); - lineFont.getChangeControl(lineGroup).getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelFont; - } - }); - lineLabelColor = addColorField( - LINE_LABEL_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelColor, lineGroup); - lineLabelColor.getColorSelector().getButton().getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelColor; - } - }); - - lineColor = addColorField( - LINE_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineColor, lineGroup); - lineColor.getColorSelector().getButton().getAccessible().addAccessibleListener( - new AccessibleAdapter () { - public void getName (final AccessibleEvent e) { - e.result = PreferenceMessages.CanvasPreferenceTab_LABEL_LineColor; - } - }); - addIntegerField( - LINE_WIDTH, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineWidth, lineGroup); - addComboField(LINE_ROUTING, PreferenceMessages.CanvasPreferenceTab_LABEL_LineRouting, - getLineRoutingLabels(), lineGroup); - } - - protected void initialize() { - // Color use: Default canvas colors should pick up system defaults - // enable or disable all of the color and font selection controls in the - // preference dialog - // depending on whether the "Use System Colors" checkbox is selected. - super.initialize(); - - ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; - - canvasGroup.setLayout(new GridLayout(3, false)); - canvasGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - canvasColor.fillIntoGrid(canvasGroup, 3); - gridColor.fillIntoGrid(canvasGroup, 3); - - iconGroup.setLayout(new GridLayout(3, false)); - iconGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - iconFont.fillIntoGrid(iconGroup, 3); - - lineGroup.setLayout(new GridLayout(3, false)); - lineGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - lineColor.fillIntoGrid(lineGroup, 3); - lineLabelColor.fillIntoGrid(lineGroup, 3); - lineFont.fillIntoGrid(lineGroup, 3); - - boolean userColorsValue = !useSystemColors.getBooleanValue(); - boolean showLineLabelsValue = showLineLabels.getBooleanValue(); - boolean snapToGridValue = snapToGrid.getBooleanValue(); - canvasColor.setEnabled(userColorsValue, canvasGroup); - gridColor.setEnabled(snapToGridValue && userColorsValue, canvasGroup); - iconFont.setEnabled(userColorsValue, iconGroup); - // inputPortColor.setEnabled(userColorsValue, iconGroup); - // outputPortColor.setEnabled(userColorsValue, iconGroup); - lineColor.setEnabled(userColorsValue, lineGroup); - lineLabelColor.setEnabled(showLineLabelsValue && userColorsValue, - lineGroup); - lineFont.setEnabled(showLineLabelsValue && userColorsValue, lineGroup); - gridWidth.setEnabled(snapToGridValue, canvasGroup); - gridHeight.setEnabled(snapToGridValue, canvasGroup); - - useSystemColors.getButton().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors - .getBooleanValue(); - boolean showLineLabelsValue_ = showLineLabels - .getBooleanValue(); - boolean snapToGridValue_ = snapToGrid.getBooleanValue(); - - canvasColor.setEnabled(userColorsValue_, canvasGroup); - gridColor - .setEnabled(snapToGridValue_ && userColorsValue_, - canvasGroup); - iconFont.setEnabled(userColorsValue_, iconGroup); - // inputPortColor.setEnabled(userColorsValue, - // iconGroup); - // outputPortColor.setEnabled(userColorsValue, - // iconGroup); - lineColor.setEnabled(userColorsValue_, lineGroup); - lineLabelColor.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - lineFont.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - } - }); - - showLineLabels.getButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors.getBooleanValue(); - boolean showLineLabelsValue_ = showLineLabels.getBooleanValue(); - lineLabelColor.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - lineFont.setEnabled(showLineLabelsValue_ && userColorsValue_, - lineGroup); - } - }); - - snapToGrid.getButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors.getBooleanValue(); - boolean snapToGridValue_ = snapToGrid.getBooleanValue(); - - gridColor.setEnabled(snapToGridValue_ && userColorsValue_, - canvasGroup); - gridWidth.setEnabled(snapToGridValue_, canvasGroup); - gridHeight.setEnabled(snapToGridValue_, canvasGroup); - } - }); - - } - - public void init(IWorkbench workbench) { - // no initialization - } - - private ColorFieldEditor addColorField(String name, String labelText, - Composite parent) { - ColorFieldEditor f = new ColorFieldEditor(name, labelText, parent); - addField(f); - return f; - } - - private ComboFieldEditor addComboField(String name, String labelText, - String[][] entryNamesAndValues, Composite parent) { - ComboFieldEditor f = new ComboFieldEditor(name, labelText, - entryNamesAndValues, parent); - addField(f); - return f; - } - - private IntegerFieldEditor addIntegerField(String name, String labelText, - Composite parent) { - IntegerFieldEditor f = new IntegerFieldEditor(name, labelText, parent); - addField(f); - return f; - } - - private BooleanField addBooleanField(String name, String labelText, - Composite parent) { - BooleanField f = new BooleanField(name, labelText, parent); - addField(f); - return f; - } - -// private StringFieldEditor addStringField(String name, String labelText, -// Composite parent) { -// StringFieldEditor f = new StringFieldEditor(name, labelText, parent); -// addField(f); -// return f; -// } - - // protected NumberField addNumberField(String name, String labelText, - // Composite parent) - // { - // NumberField f = new NumberField(name,labelText,parent); - // addField(f); - // return f; - // } - - private ColorFontFieldEditor addFontField(String name, String labelText, - Composite parent) { - ColorFontFieldEditor f = new ColorFontFieldEditor(name, labelText, - parent); - addField(f); - return f; - } - - private static String[][] getLineRoutingLabels() { - return m_lineRoutingLabels; - } - - private static String[][] getLabelPlacementLabels() { - return m_labelPlacementLabels; - } - -// private static void propagateProperty(String property, EditPart part) { -// Iterator iter = part.getChildren().iterator(); -// while (iter.hasNext()) { -// EditPart child = (EditPart) iter.next(); -// Figure fig = (Figure) ((GraphicalEditPart) child).getFigure(); -// GEMPreferences.propagateProperty(property, fig); -// propagateProperty(property, child); -// } -// } - - /** - * @return true if the preference is set to show the introduction - * editor. false otherwise. - */ - public static boolean getShowIntroEditor() - { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(SHOW_INTRO_EDITOR); - } - - /** - * @param store - * @param property - * @return the color property for the key 'property' - */ - public static Color getColor(IPreferenceStore store, String property) { - boolean useSystemColors = store.getBoolean(USE_SYSTEM_COLORS); - - Color c = ColorConstants.black; - if (useSystemColors) { - if (GRID_COLOR.equals(property)) - // c = ColorConstants.buttonDarkest; - c = ColorConstants.button; - if (LINE_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (LINE_LABEL_FONT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (LINE_LABEL_COLOR.equals(property)) - c = ColorConstants.listBackground; - if (CANVAS_COLOR.equals(property)) - c = ColorConstants.listBackground; - if (INPUT_PORT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (OUTPUT_PORT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (FIGURE_LABEL_FONT_COLOR.equals(property)) - c = ColorConstants.listForeground; - } else { - // CR392586: resource leaks - RGB rgb = PreferenceConverter.getColor(store, property); - ColorRegistry registry = JFaceResources.getColorRegistry(); - if (registry.get(rgb.toString()) != null) - return registry.get(rgb.toString()); - registry.put(rgb.toString(), rgb); - c = registry.get(rgb.toString()); - } - return c; - } - -// // CR392586: resource leaks -// private static Font getFont(IPreferenceStore store, String property) { -// FontData fd = PreferenceConverter.getFontData(store, property); -// FontRegistry registry = JFaceResources.getFontRegistry(); -// if (!registry.get(fd.toString()).equals(registry.defaultFont())) -// return registry.get(fd.toString()); -// -// registry.put(fd.toString(), new FontData[] {fd}); -// return registry.get(fd.toString()); -// } - -// private static void propagateProperty(String property, Figure fig) { -// IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); -// WindowFigure window = null; -// IconFigure icon = null; -// LinkFigure link = null; -// if (fig instanceof CompoundNodeFigure) { -// window = ((CompoundNodeFigure) fig).getWindowFigure(); -// icon = ((CompoundNodeFigure) fig).getIconFigure(); -// } else if (fig instanceof WindowFigure) -// window = (WindowFigure) fig; -// else if (fig instanceof LinkFigure) -// link = (LinkFigure) fig; -// -// if (property != null && property.equals(USE_SYSTEM_COLORS)) -// // reload all properties - it's easiest -// property = null; -// -// if (property == null || SNAP_TO_GRID.equals(property)) { -// boolean b = store.getBoolean(SNAP_TO_GRID); -// WindowFigure.defaultGridEnabled = b; -// -// if (window != null) -// window.getGridLayer().setVisible(b); -// } -// -// if (property == null || GRID_WIDTH.equals(property) -// || GRID_HEIGHT.equals(property)) { -// Dimension d = new Dimension(store.getInt(GRID_WIDTH), store -// .getInt(GRID_HEIGHT)); -// WindowFigure.defaultGridSpacing = d; -// -// if (window != null) -// window.getGridLayer().setSpacing(d); -// } -// -// if (property == null || GRID_COLOR.equals(property)) { -// Color c = getColor(store, GRID_COLOR); -// WindowFigure.defaultGridColor = c; -// -// if (window != null) -// window.getGridLayer().setForegroundColor(c); -// } -// -// // TODO: since the line router is managed by the EditPart for the -// // container figure, setting the line routing style in the WindowFigure -// // does not change the line routing immediately. The editor must be -// // restarted for line routing to take effect. -// if (property == null || LINE_ROUTING.equals(property)) { -// String s = store.getString(LINE_ROUTING); -// int style; -// if (LINE_ROUTING_MANHATTAN.equals(s)) -// style = WindowFigure.LINE_ROUTING_MANHATTAN; -// else -// style = WindowFigure.LINE_ROUTING_MANUAL; -// -// WindowFigure.defaultLineRoutingStyle = style; -// if (window != null) -// window.setLineRoutingStyle(style); -// } -// -// if (property == null || LINE_WIDTH.equals(property)) { -// int w = store.getInt(LINE_WIDTH); -// LinkFigure.defaultLineWidth = w; -// -// if (link != null) -// link.setLineWidth(w); -// } -// -// if (property == null || LINE_COLOR.equals(property)) { -// Color c = getColor(store, LINE_COLOR); -// LinkFigure.defaultLineColor = c; -// -// if (link != null) -// link.setForegroundColor(c); -// } -// -// if (property == null || SHOW_LINE_LABELS.equals(property)) { -// boolean b = store.getBoolean(SHOW_LINE_LABELS); -// LinkFigure.defaultLabelVisible = b; -// -// if (link != null) -// link.setLabelVisible(b); -// } -// -// if (property == null || LINE_LABEL_FONT.equals(property) -// || LINE_LABEL_FONT_COLOR.equals(property)) { -// // CR392586: resource leaks -// Font f = getFont(store, LINE_LABEL_FONT); -// Color c = getColor(store, LINE_LABEL_FONT_COLOR); -// LinkFigure.defaultFont = f; -// LinkFigure.defaultLabelForeground = c; -// -// if (link != null) { -// link.setFont(f); -// link.setLabelForeground(c); -// } -// } -// -// if (property == null || LINE_LABEL_COLOR.equals(property)) { -// Color c = getColor(store, LINE_LABEL_COLOR); -// LinkFigure.defaultLabelBackground = c; -// -// if (link != null) -// link.setLabelBackground(c); -// } -// -// if (property == null || CANVAS_COLOR.equals(property)) { -// Color c = getColor(store, CANVAS_COLOR); -// WindowFigure.defaultBackgroundColor = c; -// -// if (window != null) -// window.setBackgroundColor(c); -// if (icon != null) -// icon.setBackgroundColor(c); -// } -// -// if (property == null || INPUT_PORT_COLOR.equals(property)) { -// Color c = getColor(store, INPUT_PORT_COLOR); -// InputPortFigure.defaultForegroundColor = c; -// -// if (fig instanceof InputPortFigure) -// fig.setForegroundColor(c); -// } -// -// if (property == null || OUTPUT_PORT_COLOR.equals(property)) { -// Color c = getColor(store, OUTPUT_PORT_COLOR); -// OutputPortFigure.defaultForegroundColor = c; -// -// if (fig instanceof OutputPortFigure) -// fig.setForegroundColor(c); -// } -// -// if (property == null || FIGURE_LABEL_FONT.equals(property) -// || FIGURE_LABEL_FONT_COLOR.equals(property)) { -// // CR392586: resource leaks -// Font f = getFont(store, FIGURE_LABEL_FONT); -// Color c = getColor(store, FIGURE_LABEL_FONT_COLOR); -// IconFigure.defaultFont = f; -// IconFigure.defaultForegroundColor = c; -// WindowFigure.defaultFont = f; -// WindowFigure.defaultForegroundColor = c; -// -// if (window != null) { -// window.setFont(f); -// window.setForegroundColor(c); -// } -// if (icon != null) { -// icon.setFont(f); -// icon.setForegroundColor(c); -// } -// if (fig instanceof IconFigure) { -// fig.setFont(f); -// fig.setForegroundColor(c); -// } -// } -// -// if (property == null || LABEL_PLACEMENT.equals(property)) { -// int placement = PositionConstants.SOUTH; -// String s = store.getString(LABEL_PLACEMENT); -// if (LABEL_PLACEMENT_TOP.equals(s)) -// placement = PositionConstants.NORTH; -// if (LABEL_PLACEMENT_BOTTOM.equals(s)) -// placement = PositionConstants.SOUTH; -// if (LABEL_PLACEMENT_LEFT.equals(s)) -// placement = PositionConstants.WEST; -// if (LABEL_PLACEMENT_RIGHT.equals(s)) -// placement = PositionConstants.EAST; -// IconFigure.defaultTextPlacement = placement; -// -// if (icon != null) -// icon.setTextPlacement(placement); -// if (fig instanceof IconFigure) -// ((IconFigure) fig).setTextPlacement(placement); -// } -// -// Iterator iter = fig.getChildren().iterator(); -// while (iter.hasNext()) { -// Figure child = (Figure) iter.next(); -// propagateProperty(property, child); -// } -// } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java deleted file mode 100644 index 41196365f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; - -/** - * @author Bob - */ -/*package*/ interface IBaseFigure extends IFigure -{ - /** - * @param text - */ - public abstract void setText(String text); - - /** - * @return the text - */ - public abstract String getText(); - - /** - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - * @return the text bounds rectangle - */ - public abstract Rectangle getTextBounds(); - - /** - * @param image - */ - public abstract void setIcon(Image image); - - /** - * @return the icon - */ - public abstract Image getIcon(); - - /** - * @param text - */ - public abstract void setToolTipText(String text); - - /** - * @return the tool tip text - */ - public abstract String getToolTipText(); - - /** - * @param flag - */ - public abstract void setHighlight(boolean flag); - - /** - * Add decorator. May - * cause the figure to become invalidated - * @param decorator - */ - public abstract void addDecorator(BaseFigureDecorator decorator); - - /** - * Remove the decorator - */ - public abstract void removeDecorator(); - - /** - * @param position - */ - public abstract void removeDecorator(int position); - - /** - * @return the list of decoractors - */ - public abstract List getDecorators(); -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java deleted file mode 100644 index 4de2acbd5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Layer;
/**
*
* @author bbrodt
*
*
*
* This class extends IBaseFigure by including a layer accessor.
*
*/
/*package*/ interface IContainerFigure extends IBaseFigure
{
/**
* @param key
* @return the layer of key
*/
public Layer getLayer(Object key);
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java deleted file mode 100644 index 1336edc08..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java +++ /dev/null @@ -1,415 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AncestorListener; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * And IconFigure consists of a bitmap image with a text label below it. - * - * @author bbrodt - */ -/*package*/ class IconFigure extends Label implements IBaseFigure { - private static int defaultTextPlacement = PositionConstants.SOUTH; - - static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - static Color defaultForegroundColor = ColorConstants.black; - - private ArrayList decorators; - - private IconLabel iconLabel = null; - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // New class that implements a separate "floating" label which is NOT - // included in bounds calculations for this IconFigure - private class IconLabel extends Label { - private LabelLocator locator; - - private IconFigure host; - - /** - * @param host - * @param text - */ - public IconLabel(IconFigure host, String text) { - super(text); - this.host = host; - locator = new LabelLocator(this); - } - - /** - * @return the icon figure - */ - public IconFigure getHost() { - return host; - } - - public Dimension getPreferredSize(int wHint, int hHing) { - return host.getTextBounds().getSize(); - } - - public void setText(String text) { - super.setText(text); - if (locator != null) - locator.setConstraints(); - } - - public void invalidate() { - if (locator != null) - locator.setConstraints(); - super.invalidate(); - } - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // helper class that relocates the IconLabel whenever ancestor is moved or - // added/removed - private class LabelLocator implements AncestorListener { - IconLabel label; - - /** - * @param label - */ - public LabelLocator(IconLabel label) { - this.label = label; - label.getHost().addAncestorListener(this); - } - - // CR408950: BP Save problems - // fixed icon label refresh problems - private Layer getParentLayer() { - IFigure fig = label.getHost(); - while (fig != null) { - if (fig instanceof Layer) - return (Layer) fig; - fig = fig.getParent(); - } - return null; - } - - public void ancestorAdded(IFigure ancestor) { - Layer layer = getParentLayer(); - if (layer != null && !layer.getChildren().contains(label)) { - layer.add(label); - setConstraints(); - } - } - - public void ancestorMoved(IFigure ancestor) { - setConstraints(); - } - - public void ancestorRemoved(IFigure ancestor) { - // CR400779: GEM minimizing a complex activity sometimes leaves junk - // on the screen - if (label.getParent() != null - && label.getParent().getChildren().contains(label)) - label.getParent().remove(label); - } - - /** - * - */ - public void setConstraints() { - Layer layer = getParentLayer(); - if (layer != null && layer.getLayoutManager() != null - && layer.getChildren().contains(label)) { - Rectangle r = IconFigure.this.getParent().getBounds().getCopy(); - r.translate(IconFigure.this.getBounds().getLocation()); - r.translate(IconFigure.this.getTextLocation()); - r.width = -1; - r.height = -1; - Rectangle oldr = (Rectangle) layer.getLayoutManager() - .getConstraint(label); - if (oldr == null || oldr.x != r.x || oldr.y != r.y) - layer.setConstraint(label, r); - } - } - } - - /** - * @param name - * @param icon - */ - public IconFigure(String name, Image icon) { - super(name, icon); - setTextPlacement(defaultTextPlacement); - setOpaque(false); - setIcon(icon); - setIconTextGap(0); - setForegroundColor(defaultForegroundColor); - // CR396303: DND in RulePanel does not get correct location if viewer is - // scrolled - setBackgroundColor(ColorConstants.titleGradient); - XYLayout layout = new XYLayout(); - setLayoutManager(layout); - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - iconLabel = new IconLabel(this, name); - iconLabel.setFont(getFont()); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - /** - * @return the label - */ - public Label getLabel() { - return iconLabel; - } - - public List getDecorators() { - if (decorators == null) - decorators = new ArrayList(); - return decorators; - } - - public Font getFont() { - if (defaultFont == null) - { - defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - } - - if (getLocalFont() == null) - { - // TODO: replaced a deprecated assignment to font - // with this, but the behaviour is a little different - setFont(defaultFont); - } - - return getLocalFont(); - } - - public void setFont(Font f) { - Font localFont = getLocalFont(); - if (localFont != f) { - iconLabel.setFont(f); - } - super.setFont(f); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - iconLabel.setVisible(visible); - } - - public void setText(String text) { - super.setText(text); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - if (iconLabel != null && iconLabel.isVisible()) { - iconLabel.setText(text); - iconLabel.setFont(getFont()); - // labelLocator.setConstraints(); - } - } - - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } - - public void setHighlight(boolean flag) { - if (flag) - setOpaque(true); - else - setOpaque(false); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - protected Dimension getSubStringTextSize() { - return getTextSize(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated We must - * override this so that the label gets truncated - */ - public Dimension getPreferredSize(int wHint, int hHint) { - if (prefSize == null) { - super.getPreferredSize(-1, -1); - prefSize.width = getIconBounds().getSize().width; - Dimension minSize_ = getMinimumSize(wHint, hHint); - if (prefSize.width < minSize_.width) - prefSize.width = minSize_.width; - if (prefSize.height < minSize_.height) - prefSize.height = minSize_.height; - } - return prefSize; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#getMinimumSize(int, int) - */ - public Dimension getMinimumSize(int w, int h) { - return new Dimension(8, 8); - } - - public void addDecorator(BaseFigureDecorator decorator) { - removeDecorator(decorator.getPosition()); - getDecorators().add(decorator); - add(decorator); - invalidate(); - } - - public void removeDecorator() { - removeDecorator(BaseFigureDecorator.DEFAULT_DECORATOR_POSITION); - } - - public void removeDecorator(int position) { - Iterator it = getDecorators().iterator(); - while (it.hasNext()) { - BaseFigureDecorator d = (BaseFigureDecorator) it.next(); - if (d.getPosition() == position) { - it.remove(); - remove(d); - invalidate(); - break; - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Label#setTextPlacement(int) - */ - public void setTextPlacement(int where) { - super.setTextPlacement(where); - layout(); - invalidate(); - } - - public void invalidate() { - // CR405873: F111-Error decorator missing - // this was moved to paintFigure() - // placeDecorators(); - super.invalidate(); - } - - private void placeDecorators() { - Point o = getLocation(); - Point p = getIconBounds().getLocation(); - Dimension size = this.getIconBounds().getSize(); - Iterator it = getDecorators().iterator(); - while (it.hasNext()) { - int x = p.x - o.x, y = p.y - o.y; - BaseFigureDecorator decorator = (BaseFigureDecorator) it.next(); - Dimension decoratorSize = decorator.getPreferredSize(); - switch (decorator.getPosition()) { - case (PositionConstants.CENTER | PositionConstants.MIDDLE): - // CR378889: Case of decoration that should be right in the - // middle. - // Had to add a fudge factor because it's not exactly where I - // want it. - int fudge = 4; - y += size.height / 2 - decoratorSize.height / 2 + fudge; - x += size.width / 2 - decoratorSize.width / 2; - break; - case PositionConstants.NORTH: - x += size.width / 2 - decoratorSize.width / 2; - break; - case PositionConstants.NORTH_EAST: - x += size.width - decoratorSize.width; - break; - case PositionConstants.EAST: - x += size.width - decoratorSize.width; - y += size.height / 2 - decoratorSize.height / 2; - break; - case PositionConstants.SOUTH_EAST: - x += size.width - decoratorSize.width; - y += size.height - decoratorSize.height; - break; - case PositionConstants.SOUTH: - x += size.width / 2 - decoratorSize.width / 2; - y += size.height - decoratorSize.height; - break; - case PositionConstants.SOUTH_WEST: - y += size.height - decoratorSize.height; - break; - case PositionConstants.WEST: - y += size.height / 2 - decoratorSize.height / 2; - break; - case PositionConstants.NORTH_WEST: - break; - } - getLayoutManager().setConstraint(decorator, - new Rectangle(x, y, -1, -1)); - } - layout(); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - protected void paintFigure(Graphics graphics) { - if (isOpaque()) - super.paintFigure(graphics); - // CR405873: F111-Error decorator missing - placeDecorators(); - Rectangle bounds_ = getBounds(); - graphics.translate(bounds_.x, bounds_.y); - if (getIcon() != null) - graphics.drawImage(getIcon(), getIconLocation()); - if (iconLabel == null || !iconLabel.isVisible()) { - if (!isEnabled()) { - graphics.translate(1, 1); - graphics.setForegroundColor(ColorConstants.buttonLightest); - graphics.drawText(getSubStringText(), getTextLocation()); - graphics.translate(-1, -1); - graphics.setForegroundColor(ColorConstants.buttonDarker); - } - graphics.drawText(getSubStringText(), getTextLocation()); - } - graphics.translate(-bounds_.x, -bounds_.y); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java deleted file mode 100644 index 66ca25bee..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.graphics.Color;
/**
*
* Figure used to draw input ports
*
*/
/*package*/ class InputPortFigure extends PortFigure
{
private final static Color defaultForegroundColor = ColorConstants.black;
private final static Color defaultBackgroundColor = ColorConstants.white;
/**
*
*
*
*/
public InputPortFigure()
{
super(FigureConstants.INPUT_PORT);
setBackgroundColor(defaultBackgroundColor);
setForegroundColor(defaultForegroundColor);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java deleted file mode 100644 index 11e0a8028..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.MidpointLocator; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * @author Bob - */ -/*package*/ class LinkFigure extends PolylineConnection implements IBaseFigure { - private final static Color defaultLineColor = ColorConstants.black; - - private final static int defaultLineWidth = 1; - - private final static boolean defaultLabelVisible = false; - - private final static Color defaultLabelForeground = ColorConstants.black; - - private final static Color defaultLabelBackground = ColorConstants.white; - - private final static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - private LinkLabel label; - - /** - * Default constructor - */ - public LinkFigure() { - super(); - setLineWidth(defaultLineWidth); - setForegroundColor(defaultLineColor); - - // BaseFigureDecorator decorator; - // decorator = new - // BaseFigureDecorator(GEMPlugin.getDefault().getGEMImage("delete.gif"),"target",PositionConstants.WEST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(GEMPlugin.getDefault().getGEMImage("delete.gif"),"target",PositionConstants.EAST); - // addDecorator(decorator); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText() - */ - public void setToolTipText(final String text) { - Label toolTip_ = null; - - if (text != null && text.length() > 0) { - toolTip_ = new Label(text); - toolTip_.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTip_); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - if (getToolTip() != null) - { - return ((Label) getToolTip()).getText(); - } - return null; - } - - public void setHighlight(final boolean flag) { - if (flag) { - setForegroundColor(ColorConstants.titleBackground); - // setLineWidth(defaultLineWidth * 2); - } else { - setForegroundColor(defaultLineColor); - // setLineWidth(defaultLineWidth); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText() - */ - public void setText(final String text) { - if (text != null && text.length() == 0) { - if (label != null) { - remove(label); - label = null; - } - } else { - getLabel().setText(text); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - if (label == null) - { - return null; - } - return label.getText(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - return label.getTextBounds(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setIcon(org.eclipse.swt.graphics.Image) - */ - public void setIcon(final Image image) { - getLabel().setIcon(image); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return getLabel().getIcon(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(final BaseFigureDecorator decorator) { - final int pos = decorator.getPosition(); - if (pos == BaseFigureDecorator.DEFAULT_DECORATOR_POSITION - || pos == PositionConstants.WEST - || pos == PositionConstants.LEFT) { - setTargetDecoration(decorator); - } else if (pos == PositionConstants.EAST - || pos == PositionConstants.RIGHT) { - setSourceDecoration(decorator); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - removeDecorator(BaseFigureDecorator.DEFAULT_DECORATOR_POSITION); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(final int position) { - if (position == BaseFigureDecorator.DEFAULT_DECORATOR_POSITION) - { - setTargetDecoration(null); - } - else - { - setSourceDecoration(null); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - final List list = new ArrayList(2); - Object d; - d = getSourceDecoration(); - if (d != null) - { - list.add(d); - } - d = getTargetDecoration(); - if (d != null) - { - list.add(d); - } - return list; - } - - private LinkLabel getLabel() { - if (label == null) { - label = new LinkLabel(); - add(label, new MidpointLocator(this, 0)); - } - return label; - } - - @Override - public void setFont(final Font f) { - getLabel().setFont(f); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Shape#setLineWidth(int) - */ - @Override - public void setLineWidth(final int w) { - getLabel().setBorderWidth(w); - super.setLineWidth(w); - } - - @Override - public void setForegroundColor(final Color c) { - getLabel().setBorderColor(c); - super.setForegroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Polyline#setPoints(org.eclipse.draw2d.geometry.PointList) - */ - @Override - public void setPoints(final PointList points) { - super.setPoints(points); - if (label != null) { - int i = getPoints().size() / 2 - 1; - if (i < 0) - { - i = 0; - } - if (getLayoutManager() != null) - { - getLayoutManager().setConstraint(label, - new MidpointLocator(this, i)); - } - } - } - - @Override - public Rectangle getBounds() { - if (bounds == null) { - if (bounds == null) { - bounds = getPoints().getBounds().getExpanded(lineWidth / 2, - lineWidth / 2); - } - // CR382243: Clicking on the node icon selects the connection line - // rather than the node - // NOTE: expanding the bounds to include children (in this case, - // the Link labels) causes problems when the connection line becomes - // short (i.e., when the 2 anchor figures at each end of the - // connection are - // close together) because the bounds of this link figure will be - // greater - // than the actual length of the line. This causes the link figure - // to - // be hit-tested beyond its visual size. - if (getLabel().isVisible()) { - for (int i = 0; i < getChildren().size(); i++) { - final IFigure child = (IFigure) getChildren().get(i); - bounds.union(child.getBounds()); - } - } - } - return bounds; - } - - /* - * Helper class for line labels. - */ - private static class LinkLabel extends Label { - LinkLabel() { - setBorder(new LineBorder()); - setOpaque(true); - setForegroundColor(defaultLabelForeground); - setBackgroundColor(defaultLabelBackground); - setFont(defaultFont); - final LineBorder border_ = new LineBorder(defaultLineWidth); - setBorder(border_); - border_.setColor(defaultLineColor); - setVisible(defaultLabelVisible); - } - - void setBorderWidth(final int w) { - ((LineBorder) getBorder()).setWidth(w); - } - - void setBorderColor(final Color c) { - ((LineBorder) getBorder()).setColor(c); - } - - @Override - protected boolean useLocalCoordinates() { - return false; - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java deleted file mode 100644 index bee006f3a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; -import java.util.ListIterator; - -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * @author Bob Brodt - * - * This is an XY layout that actually observes visiblity of children figures - * when doint its layout. - * - * Apparently there is a bug in the GEF XYLayout class because it does not - * observe visibility. - * - * @see org.eclipse.draw2d.AbstractLayout#isObservingVisibility() - */ -/*package*/ class ObserveVisibleXYLayout extends FreeformLayout { - protected Dimension calculatePreferredSize(IFigure f, int wHint, int hHint) { - Rectangle rect = new Rectangle(); - ListIterator children = f.getChildren().listIterator(); - while (children.hasNext()) { - IFigure child = (IFigure) children.next(); - // bug fix - if (isObservingVisibility() && !child.isVisible()) - continue; - Rectangle r = (Rectangle) constraints.get(child); - if (r == null) - continue; - - if (r.width == -1 || r.height == -1) { - Dimension preferredSize_ = child.getPreferredSize(r.width, - r.height); - r = r.getCopy(); - if (r.width == -1) - r.width = preferredSize_.width; - if (r.height == -1) - r.height = preferredSize_.height; - } - rect.union(r); - } - Dimension d = rect.getSize(); - Insets insets = f.getInsets(); - return new Dimension(d.width + insets.getWidth(), d.height - + insets.getHeight()).union(getBorderPreferredSize(f)); - } - - public void layout(IFigure parent) { - Iterator children = parent.getChildren().iterator(); - Point offset = getOrigin(parent); - IFigure f; - while (children.hasNext()) { - f = (IFigure) children.next(); - // bug fix - if (isObservingVisibility() && !f.isVisible()) - continue; - Rectangle bounds = (Rectangle) getConstraint(f); - if (bounds == null) - continue; - - if (bounds.width == -1 || bounds.height == -1) { - Dimension preferredSize_ = f.getPreferredSize(bounds.width, - bounds.height); - bounds = bounds.getCopy(); - if (bounds.width == -1) - bounds.width = preferredSize_.width; - if (bounds.height == -1) - bounds.height = preferredSize_.height; - } - bounds = bounds.getTranslated(offset); - f.setBounds(bounds); - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java deleted file mode 100644 index 49d920135..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.graphics.Color;
/**
*
*/
/*package*/ class OutputPortFigure extends PortFigure
{
private final static Color defaultForegroundColor = ColorConstants.black;
private final static Color defaultBackgroundColor = ColorConstants.white;
/**
*
*
*
*/
public OutputPortFigure()
{
super(FigureConstants.OUTPUT_PORT);
setBackgroundColor(defaultBackgroundColor);
setForegroundColor(defaultForegroundColor);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java deleted file mode 100644 index f81c5076f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import java.util.Iterator;
import java.util.Vector;
import org.eclipse.draw2d.AbstractConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
/**
*
*/
/*package*/ class PortConnectionAnchor extends AbstractConnectionAnchor
{
// CR386077: SplitActivity True and False outputs switch positions based on
// their targets
private final int orientation = PositionConstants.NONE;
/**
*
*
*
*/
public PortConnectionAnchor()
{
super();
}
/**
*
* @param owner
*
*/
public PortConnectionAnchor(IFigure owner)
{
super(owner);
}
// CR386077: SplitActivity True and False outputs switch positions based on
// their targets
/**
* @return the orientation value; one of PositionConstants.*
*/
public int getOrientation()
{
return orientation;
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.ConnectionAnchor#getLocation(org.eclipse.draw2d.geometry.Point)
*
*/
public Point getLocation(Point arg0)
{
PortFigure portFigure = (PortFigure) getOwner();
Point result = new Point(0, 0);
Rectangle r = portFigure.getBounds();
switch (portFigure.getOrientation())
{
case PositionConstants.NORTH:
result = new PrecisionPoint(r.x + r.width / 2, r.y);
break;
case PositionConstants.SOUTH:
result = new PrecisionPoint(r.x + r.width / 2, r.y + r.height);
break;
case PositionConstants.WEST:
result = new PrecisionPoint(r.x, r.y + r.height / 2);
break;
case PositionConstants.EAST:
result = new PrecisionPoint(r.x + r.width, r.y + r.height / 2);
break;
}
portFigure.translateToAbsolute(result);
return result;
}
/**
* @return the connections list
*/
public Vector getConnections()
{
Vector list = new Vector();
Iterator it = listeners.iterator();
while (it.hasNext())
{
Object listener = it.next();
if (listener instanceof PolylineConnection)
list.add(listener);
}
return list;
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java deleted file mode 100644 index f99290246..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
/**
*
* Provides the base implementation for all the port figures.
*
*/
/*package*/ class PortFigure extends Figure
{
private boolean showBox = false;
private boolean showArrow = true;
// orientation is one of the four positions constants
// NORTH, SOUTH, EAST or WEST and indicates on which side
// of the parent figure the connection anchor figure is
// located.
private int orientation = PositionConstants.WEST;
// type is the port type; either input or output
private int type = FigureConstants.INPUT_PORT;
/**
*
* Construct a port figure.
* @param type
*
*/
public PortFigure(int type)
{
super();
this.type = type;
setOpaque(false);
}
/**
*
* @param b
*
*/
public void setBoxVisible(boolean b)
{
showBox = b;
repaint();
}
/**
* @param b
*/
public void setArrowVisible(boolean b)
{
showArrow = b;
repaint();
}
/**
*
* @return Returns the type.
*
*/
public int getType()
{
return type;
}
/**
*
* @param type
* The type to set.
*
*/
public void setType(int type)
{
this.type = type;
}
/**
* @param o
*/
public void setOrientation(int o)
{
orientation = o;
}
/**
* @return the orientation; one of PositionConstants.*
*/
public int getOrientation()
{
return orientation;
}
/**
* @param text
*/
public void setToolTipText(String text)
{
setToolTip(new Label(text));
}
/**
* @return the tool tip text
*/
public String getToolTipText()
{
IFigure fig = getToolTip();
if (fig instanceof Label)
return ((Label) fig).getText();
return null;
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics)
*
*/
public void paintFigure(Graphics g)
{
super.paintFigure(g);
Rectangle bounds_ = getBounds();
g.setForegroundColor(getForegroundColor());
if (showBox)
{
// draw outer rectangle
g.setBackgroundColor(getBackgroundColor());
g.fillRectangle(getBounds().getCropped(new Insets(0, 1, 1, 0)));
Rectangle r = getBounds().getExpanded(-1, -1).getTranslated(0, -1);
r.height += 1;
g.drawRectangle(r);
}
if (showArrow)
{
// draw arrowhead
g.setBackgroundColor(getForegroundColor());
PointList pts = new PointList();
if (type == FigureConstants.INPUT_PORT)
{
switch (orientation)
{
case PositionConstants.NORTH:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottom());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.SOUTH:
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTop());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getBottomLeft());
break;
case PositionConstants.EAST:
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getLeft());
pts.addPoint(bounds_.getTopRight());
break;
case PositionConstants.WEST:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getRight());
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTopLeft());
break;
}
}
else
{
switch (orientation)
{
case PositionConstants.NORTH:
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTop());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getBottomLeft());
break;
case PositionConstants.SOUTH:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottom());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.EAST:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getRight());
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.WEST:
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getLeft());
pts.addPoint(bounds_.getTopRight());
break;
}
}
g.fillPolygon(pts);
g.drawPolyline(pts);
}
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.IFigure#getPreferredSize(int, int)
*
*/
public Dimension getPreferredSize(int wHint, int hHint)
{
Dimension d = new Dimension(FigureConstants.PORT_SIDE,
FigureConstants.PORT_SIDE);
// CR389070: Figures are abbreviating rule figures names and making them
// unreadable
// anchor size is now determined by the size of the owning figure icon
if (getParent() instanceof BaseNodeFigure)
{
IBaseFigure fig = ((BaseNodeFigure) getParent()).getBaseFigure();
if (fig != null && fig.getIcon() != null)
{
org.eclipse.swt.graphics.Rectangle r = fig.getIcon()
.getBounds();
if (r.width < 40)
d.width /= 2;
if (r.height < 40)
d.height /= 2;
}
}
return d;
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java deleted file mode 100644 index e9220c1ff..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.osgi.util.NLS; - -/** - * The NLS message manager for PreferenceMessages - * - */ -/*package*/ final class PreferenceMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.preference.PreferenceMessages"; //$NON-NLS-1$ - - private PreferenceMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, PreferenceMessages.class); - } - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_UseSystemColors; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_BackgroundColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_Canvas; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridHeight; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridLineColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridWidth; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconLabelFont; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconGroup; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_InputPortColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_OutputPortColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineGroup; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_ShowLineLabels; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineLabelColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineLabelFont; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineRouting; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineWidth; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_SnapToGeometry; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_SnapToGrid; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_UndoStackSize; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Direct; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Manhattan; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Manual; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LabelPlacement; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Top; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Bottom; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Left; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Right; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconSize; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Small; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Medium; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Large; - - /** - * label property for check box that selects whether or not - * the introduction section editor should be loaded. - */ - public static String EditorPreferences_LABEL_ShowIntroEditor; - - /** - * see PreferenceMessages.properties - */ - public static String GEMPreferences_description; - /** - * see PreferenceMessages.properties - */ - public static String CompoundNodeFigure_MaximizeLabel; - /** - * see PreferenceMessages.properties - */ - public static String CompoundNodeFigure_MinimizeLabel; - /** - * see PreferenceMessages.properties - */ - public static String CompoundNodeFigure_RestoreLabel; - /** - * see PreferenceMessages.properties - */ - public static String WindowFigure_NoTitleText; - /** - * see PreferenceMessages.properties - */ - public static String WindowFigure_Title; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties deleted file mode 100644 index 5a91a3724..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties +++ /dev/null @@ -1,54 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -# -# Appearance preference labels -# -CanvasPreferenceTab_LABEL_UseSystemColors=Use System colors -EditorPreferences_LABEL_ShowIntroEditor=Show Introduction Tab (open editors must be reloaded to take effect) -CanvasPreferenceTab_LABEL_BackgroundColor=Background color: -CanvasPreferenceTab_LABEL_Canvas=Canvas -CanvasPreferenceTab_LABEL_GridHeight=Grid height: -CanvasPreferenceTab_LABEL_GridLineColor=Grid color: -CanvasPreferenceTab_LABEL_GridWidth=Grid width: -CanvasPreferenceTab_LABEL_IconLabelFont=Label font: -CanvasPreferenceTab_LABEL_IconGroup=Icons -CanvasPreferenceTab_LABEL_InputPortColor=Input Port color: -CanvasPreferenceTab_LABEL_OutputPortColor=Output Port color: -CanvasPreferenceTab_LABEL_LineGroup=Connection Lines -CanvasPreferenceTab_LABEL_LineColor=Line color: -CanvasPreferenceTab_LABEL_ShowLineLabels=Show labels -CanvasPreferenceTab_LABEL_LineLabelColor=Label color: -CanvasPreferenceTab_LABEL_LineLabelFont=Label font: -CanvasPreferenceTab_LABEL_LineRouting=Line Routing: -CanvasPreferenceTab_LABEL_LineWidth=Line width: -CanvasPreferenceTab_LABEL_SnapToGeometry=Snap to geometry -CanvasPreferenceTab_LABEL_SnapToGrid=Snap to grid -CanvasPreferenceTab_LABEL_UndoStackSize="Undo\" stack size: -CanvasPreferences_LABEL_Direct=Direct -CanvasPreferences_LABEL_Manhattan=Manhattan -CanvasPreferences_LABEL_Manual=Manual -CanvasPreferenceTab_LABEL_LabelPlacement=Label Placement: -CanvasPreferences_LABEL_Top=Top -CanvasPreferences_LABEL_Bottom=Bottom -CanvasPreferences_LABEL_Left=Left -CanvasPreferences_LABEL_Right=Right -CanvasPreferenceTab_LABEL_IconSize=Icon Size: -CanvasPreferences_LABEL_Small=Small -CanvasPreferences_LABEL_Medium=Medium -CanvasPreferences_LABEL_Large=Large -GEMPreferences_description=Preferences for the graphical page of FacesConfig editor. - -################################################# -CompoundNodeFigure_MaximizeLabel=Maximize -CompoundNodeFigure_MinimizeLabel=Minimize -CompoundNodeFigure_RestoreLabel=Restore -WindowFigure_NoTitleText=?? -WindowFigure_Title=Window diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java deleted file mode 100644 index 566958fd9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.LayerConstants; - -/** - * This is a printable layer that draws page outline tiles enclosing all of the - * printable child figures. The page outlines represent complete pages as they - * would appear if they were printed on dead trees, thus the pageSize set on - * this layer should be the currently selected printer's page resolution. - * - * The reason this needs to be added to the printable layers is so that it will - * show up in the content outline viewer. - */ -/*package*/ class PrintedPageLayer extends FreeformLayer { - // our layer name - static final String PRINTED_PAGE_LAYER = "Printed Page"; //$NON-NLS-1$ - - // the size of the page tiles (this should be the printer's resolution) - private Dimension pageSize = new Dimension(850, 1100); - - // the WindowFigure that owns this layer - private final WindowFigure host; - - // flag to lock out multiple calls to setFreeformBounds() when adding - // and removing PrintedPageFigures. - private boolean busy; - - // A simple page outline figure. We can get fancy later with turned-up - // dogears, page numbers, titles and whatnot... - static class PrintedPageFigure extends RectangleFigure { - PrintedPageFigure() { - super(); - setFill(false); - setOutline(true); - setLineWidth(1); - } - } - - /** - * @param figure - */ - public PrintedPageLayer(WindowFigure figure) { - super(); - this.host = figure; - } - - /** - * @param x - * @param y - * @return the print page figure - */ - protected PrintedPageFigure createPage(int x, int y) { - PrintedPageFigure page = new PrintedPageFigure(); - page.setBounds(new Rectangle(x, y, pageSize.width, pageSize.height)); - return page; - } - - /** - * Sets the page width and height. This should be the currently selected - * printer's page size. - * - * @param d - */ - public void setPageSize(Dimension d) { - pageSize = d.getCopy(); - } - - /** - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - if (!busy && getParent() instanceof FreeformLayeredPane - && pageSize.width > 0 && pageSize.height > 0) { - busy = true; - - // build the new printing layer extent by looking at only the - // contents of the Primary, Connection and Feedback layers - Rectangle b; - FreeformLayer layer; - layer = (FreeformLayer) host.getLayer(LayerConstants.PRIMARY_LAYER); - b = layer.getFreeformExtent().getCopy(); - layer = (FreeformLayer) host - .getLayer(LayerConstants.CONNECTION_LAYER); - b = b.union(layer.getFreeformExtent()); - layer = (FreeformLayer) host - .getLayer(LayerConstants.FEEDBACK_LAYER); - b = b.union(layer.getFreeformExtent()); - - // calculate x and y for the page tiles - int x = 0, y = 0; - if (b.x < 0) { - while (x > b.x) - x -= pageSize.width; - } else { - while (x + pageSize.width < b.x) - x += pageSize.width; - } - if (b.y < 0) { - while (y > b.y) - y -= pageSize.height; - } else { - while (y + pageSize.height < b.y) - y += pageSize.height; - } - - // get list of pagefigures that intersect the new extent - // and a list of those that don't - List keepers = new ArrayList(); - List trash = new ArrayList(); - Iterator iter = getChildren().iterator(); - while (iter.hasNext()) { - Figure child = (Figure) iter.next(); - if (child.getBounds().intersects(b)) - keepers.add(child); - else - trash.add(child); - } - - // calculate width and height - int w = 0, h = 0; - while (x + w < b.x + b.width) - w += pageSize.width; - while (y + h < b.y + b.height) - h += pageSize.height; - - // determine the required pagefigures - for (int xi = x; xi < x + w; xi += pageSize.width) { - for (int yi = y; yi < y + h; yi += pageSize.height) { - boolean found = false; - iter = keepers.iterator(); - while (iter.hasNext()) { - Figure child = (Figure) iter.next(); - Point p = child.getBounds().getLocation(); - if (p.x == xi && p.y == yi) { - found = true; - break; - } - } - if (!found) { - // add the new page - add(createPage(xi, yi)); - } - } - } - - // remove all the old pages - iter = trash.iterator(); - while (iter.hasNext()) - remove((Figure) iter.next()); - - busy = false; - } - super.setFreeformBounds(bounds); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java deleted file mode 100644 index 03aadbbd8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; - -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * A List<Rectangle> implementation with a coordinate-based - * convenience method for adding rectangles. - * - */ -class RectangleList extends ArrayList<Rectangle> -{ - private static final long serialVersionUID = -4088355285820327890L; - - /** - * Default constructor - */ - public RectangleList() { - super(); - } - - /** - * @param x1 - * @param y1 - * @param x2 - * @param y2 - */ - public void addRectangle(int x1, int y1, int x2, int y2) { - add(new Rectangle(x1, y1, x2 - x1, y2 - y1)); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java deleted file mode 100644 index 60cd9792a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureUtilities; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.draw2d.SchemeBorder; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Composite; - -/** - * A border for the tabbed title bar - * - */ -/*package*/ class TabbedTitleBarBorder extends SchemeBorder { - // private int state = CompoundFigureListener.RESTORED; - - private IFigure parent; - - private ListenerList listenerList; - - private List tabList; - - private int currentTab; - - private Font font; - - private boolean visible = true; - - // from TitleBarBorder: - private Color textColor = ColorConstants.black; - - private Color bgColor = ColorConstants.menuBackground; - - private Insets insets; - - private Insets padding = new Insets(2, 2, 2, 2); - - /** - * Constructs a TitleBarBorder with its label set to the name of this class. - * @param parent - * - * @since 2.0 - */ - public TabbedTitleBarBorder(final IFigure parent) { - super(SCHEMES.LOWERED); - - this.parent = parent; - - parent.addMouseListener(new MouseListener() { - public void mousePressed(MouseEvent me) { - Insets padding_ = getPadding(); - Point mp = me.getLocation(); - mp.x -= padding_.left; - mp.y -= padding_.top + 3; // 3==width of the outer border - Point pp = parent.getBounds().getLocation(); - Rectangle tr = new Rectangle(pp.x, pp.y, 0, 0); - //int activeIndex = -1; - - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - Dimension d = t.getTextExtents(); - d.height += padding_.top + padding_.bottom; - d.width += padding_.left; - tr.setSize(d); - if (tr.contains(mp)) { - setCurrentTab(i); - return; - } - tr.x += d.width; - } - } - - public void mouseReleased(MouseEvent me) { - // do nothing: not handling release - } - - public void mouseDoubleClicked(MouseEvent me) { - // do nothing: not handling release - } - }); - } - - /** - * @return the tab list - */ - protected List getTabList() { - if (tabList == null) - tabList = new ArrayList(); - return tabList; - } - - /** - * Add a new tab with the text - * @param text - * @return the previous number of tabs - */ - public int addTab(String text) { - getTabList().add(new Tab(text)); - return getTabList().size() - 1; - } - - /** - * @param index - */ - public void removeTab(int index) { - if (index >= 0 && index < getTabList().size()) { - tabList.remove(index); - if (index >= tabList.size()) - index = tabList.size() - 1; - setCurrentTab(index); - } - } - - /** - * @param newIndex - */ - public void setCurrentTab(int newIndex) { - if (newIndex >= 0 && newIndex < getTabList().size()) { - Tab newTab = (Tab) tabList.get(newIndex); - int oldIndex = -1; - for (int i = 0; i < tabList.size(); ++i) { - Tab t = (Tab) tabList.get(i); - if (t.isActive()) { - oldIndex = i; - t.setActive(false); - break; - } - } - newTab.setActive(true); - if (parent != null) { - parent.invalidate(); - parent.repaint(); - } - currentTab = newIndex; - fireTabChanged(oldIndex, newIndex); - } - } - - /** - * @return the index of the current tab - */ - public int getCurrentTab() { - return currentTab; - } - - /** - * @param index - * @return the contents object of the tab at index - * or null if index is out of range - */ - public Object getContents(int index) { - if (index >= 0 && index < getTabList().size()) - return ((Tab) tabList.get(index)).getContents(); - return null; - } - - /** - * @param index - * @param contents - */ - public void setContents(int index, Object contents) { - if (index >= 0 && index < getTabList().size()) - ((Tab) tabList.get(index)).setContents(contents); - } - - /** - * @param listener - */ - public void addTabbedWindowListener(WindowFigureListener listener) { - if (listenerList == null) - listenerList = new ListenerList(ListenerList.IDENTITY); - listenerList.add(listener); - } - - /** - * @param listener - */ - public void removeTabbedWindowListener(WindowFigureListener listener) { - if (listenerList != null) - listenerList.remove(listener); - } - - /** - * @return the listeners - */ - public Object[] getListeners() { - return listenerList.getListeners(); - } - - /** - * @param oldIndex - * @param newIndex - */ - protected void fireTabChanged(int oldIndex, int newIndex) { - Object l[] = listenerList.getListeners(); - for (int i = 0; i < l.length; ++i) { - if (l[i] instanceof WindowFigureListener) - ((WindowFigureListener) l[i]).tabChanged(oldIndex, newIndex); - } - } - - /** - * @return Returns the font. - */ - public Font getFont() { - if (font == null) { - font = parent.getFont(); - if (font == null) - font = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - } - return font; - } - - /** - * @param font - * The font to set. - */ - public void setFont(Font font) { - this.font = font; - invalidate(); - } - - /** - * @return Returns the insets. - */ - public Insets getInsets() { - return insets; - } - - /** - * @param c - */ - public void setTextColor(Color c) { - textColor = c; - } - - /** - * @return the text color - */ - public Color getTextColor() { - return textColor; - } - - /** - * @param c - */ - public void setBackgroundColor(Color c) { - bgColor = c; - } - - /** - * @return the background color - */ - public Color getBackgroundColor() { - return bgColor; - } - - /** - * @param p - */ - public void setPadding(Insets p) { - padding = p; - invalidate(); - } - - /** - * @return the padding insets - */ - public Insets getPadding() { - return padding; - } - - /** - * @param text - */ - public void setLabel(String text) { - setLabel(currentTab, text); - } - - /** - * @param index - * @param text - */ - public void setLabel(int index, String text) { - if (index >= 0 && index < getTabList().size()) - ((Tab) tabList.get(index)).setLabel(text); - } - - /** - * @return the label - */ - public String getLabel() { - return getLabel(currentTab); - } - - /** - * @param index - * @return the label - */ - public String getLabel(int index) { - if (index >= 0 && index < getTabList().size()) - return ((Tab) tabList.get(index)).getLabel(); - return ""; //$NON-NLS-1$ - } - - /** - * @return the parent figureb - */ - public IFigure getParent() { - return parent; - } - - /** - * validate each of the tabs - */ - public void invalidate() { - insets = null; - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - t.invalidate(); - } - } - - /** - * @param f - * @return the text extends - */ - public Dimension getTextExtents(IFigure f) { - Dimension d = new Dimension(0, 0); - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - if (d.height == 0) - d = t.getTextExtents(); - else - d.width += t.getTextExtents().width; - } - return d; - } - - /** - * Sets the min/max buttons visible - * - * @param flag - - * if true, buttons are made visible. - */ - public void setVisible(boolean flag) { - visible = flag; - } - - /** - * Calculates and returns the Insets for this border. - * - * @param figure - * the figure on which Insets calculations are based - * @return the calculated Insets - * @since 2.0 - */ - protected Insets calculateInsets(IFigure figure) { - insets = new Insets(super.getInsets(figure)); - insets.top = getTextExtents(figure).height; - return insets; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Border#getInsets(org.eclipse.draw2d.IFigure) - */ - public Insets getInsets(IFigure figure) { - if (insets == null) - calculateInsets(figure); - return insets; - } - - /** - * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) - */ - public void paint(IFigure figure, Graphics g, Insets in) { - if (!visible) - return; - - Insets is = new Insets(in); - getInsets(figure); - is.top += insets.top; - super.paint(figure, g, is); - // Insets insets = getInsets(pane); - // Insets padding = getPadding(); - // Insets in = new Insets(figureInsets); - // in.top += insets.top; - // super.paint(pane, g, in); - - tempRect.setBounds(getPaintRectangle(figure, in)); - Rectangle r = tempRect; - r.height = Math.min(r.height, getTextExtents(figure).height); - - g.clipRect(r); - g.setBackgroundColor(getBackgroundColor()); - g.fillRectangle(r); - int x = r.x; - int y = r.y; - - Iterator iter = getTabList().iterator(); - while (iter.hasNext()) { - Tab t = (Tab) iter.next(); - t.paint(g, figure, x, y); - x += t.getTextExtents().width; - } - - g.setBackgroundColor(getBackgroundColor()); - } - - /** - * @param wHint - * @param hHint - * @return the minimum size - */ - public Dimension getMinimumSize(int wHint, int hHint) { - Dimension d = getTextExtents(parent); - getInsets(parent); - d.expand(insets.left + insets.right, insets.top + insets.bottom); - // add enough width for the min/max buttons - // d.width += minButton.getSize().width + maxButton.getSize().width; - return d; - } - - private class Tab { - private String label = ""; //$NON-NLS-1$ - - private Object contents = null; - - private Dimension textExtents; - - private boolean active; - - /** - * @param text - */ - public Tab(String text) { - this.label = text; - } - - /** - * @param contents - */ - public void setContents(Object contents) { - this.contents = contents; - } - - /** - * @return the contents - */ - public Object getContents() { - return contents; - } - - /** - * @param active - */ - public void setActive(boolean active) { - this.active = active; - } - - /** - * @return the active state - */ - public boolean isActive() { - return active; - } - - /** - * @return the label - */ - public String getLabel() { - return label; - } - - /** - * @param text - */ - public void setLabel(String text) { - if (text == null) - this.label = ""; //$NON-NLS-1$ - else - this.label = text; - textExtents = null; - } - - /** - * @return the text extents - */ - public Dimension calculateTextExtents() { - textExtents = FigureUtilities.getTextExtents(label == null ? "W" //$NON-NLS-1$ - : label, getFont()); - textExtents.width += getPadding().getWidth(); - textExtents.height += getPadding().getHeight(); - return textExtents; - } - - /** - * @return the text extents. A copy is returned based on what - * is cached internall by calculateTextExtents - */ - public Dimension getTextExtents() { - if (textExtents == null) - calculateTextExtents(); - return textExtents.getCopy(); - } - - /** - * - */ - public void invalidate() { - textExtents = null; - } - - /** - * @param g - * @param f - * @param x - * @param y - */ - public void paint(Graphics g, IFigure f, int x, int y) { - if (contents instanceof Composite) { - return; - } - IFigure pane = (IFigure) contents; - getTextExtents(); - - Insets p = getPadding(); - int w = textExtents.width; - int h = textExtents.height; - int radius = Math.max(p.getWidth(), p.getHeight()) + 2; - - // CR408950: BP Save problems - // fixed icon label refresh problems - if (getTabList().size() > 1) { - // only draw tabList if there are more than 1 - if (active) - g.setBackgroundColor(pane == null ? ColorConstants.white - : pane.getBackgroundColor()); - else - g.setBackgroundColor(getBackgroundColor()); - - --w; - g.setForegroundColor(active ? ColorConstants.buttonDarkest - : ColorConstants.buttonDarker); - // g.setForegroundColor(ColorConstants.red); - g.drawRectangle(x, y + h / 2, w, h); - // g.setBackgroundColor(ColorConstants.green); - g.fillRoundRectangle(new Rectangle(x, y, w, h), radius, radius); - // g.setForegroundColor(ColorConstants.blue); - g.drawRoundRectangle(new Rectangle(x, y, w, h), radius, radius); - // g.setBackgroundColor(ColorConstants.yellow); - g.fillRectangle(x + 1, y + h / 2, w - 1, h); - } else - g.setBackgroundColor(getBackgroundColor()); - - g.setFont(getFont()); - g.setForegroundColor(getTextColor()); - if (label != null) - g.drawString(label, x + padding.left + 1, y + padding.top); - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java deleted file mode 100644 index 6d41870e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureUtilities; -import org.eclipse.draw2d.FrameBorder; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.SchemeBorder; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.widgets.Composite; - -/** - * A frame border for a tabbed window - * - */ -/* package */final class TabbedWindowBorder extends FrameBorder -{ - private boolean isVisible = true; - - // CR392586: resource leaks - private static MySchemeBorder normalBorder = new MySchemeBorder( - new MySchemeBorder.MyScheme(new Color[] - { ColorConstants.button, ColorConstants.buttonLightest, - ColorConstants.button }, new Color[] - { ColorConstants.buttonDarkest, ColorConstants.buttonDarker, - ColorConstants.button })); - - // CR392586: resource leaks - private static MySchemeBorder highlightBorder = new MySchemeBorder( - new MySchemeBorder.MyScheme(new Color[] - { FigureUtilities.lighter(ColorConstants.titleBackground), - ColorConstants.titleBackground, - FigureUtilities.darker(ColorConstants.titleBackground) }, - new Color[] - { - FigureUtilities - .darker(ColorConstants.titleGradient), - ColorConstants.titleGradient, - FigureUtilities - .lighter(ColorConstants.titleGradient) })); - - /** - * A border scheme - * - */ - private static class MySchemeBorder extends SchemeBorder - { - private static class MyScheme extends SchemeBorder.Scheme - { - /** - * @param highlight - * @param shadow - */ - public MyScheme(final Color[] highlight, final Color[] shadow) - { - super(highlight, shadow); - } - - @Override - public Color[] getHighlight() - { - return super.getHighlight(); - } - - @Override - public Color[] getShadow() - { - return super.getHighlight(); - } - } - - MySchemeBorder(final MyScheme scheme) - { - super(scheme); - } - - /** - * @return the scheme - */ - public MyScheme getMyScheme() - { - return (MyScheme) super.getScheme(); - } - - /** - * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) - * @param comp - * @param gc - * @param insets - */ - public void paint(final Composite comp, final GC gc, final Insets insets) - { - final Color[] tl = getMyScheme().getHighlight(); - final Color[] br = getMyScheme().getShadow(); - paint(comp, gc, insets, tl, br); - } - - /** - * Paints the border using the information in the set Scheme and the - * inputs given. Side widths are determined by the number of colors in - * the Scheme for each side. - * - * @param comp - * the composit whose rect should be used for the inset - * bounds - * @param gc - * the graphics object - * @param insets - * the insets - * @param tl - * the highlight (top/left) colors - * @param br - * the shadow (bottom/right) colors - */ - protected void paint(final Composite comp, final GC gc, final Insets insets, final Color[] tl, - final Color[] br) - { - final org.eclipse.swt.graphics.Rectangle rect = comp.getBounds(); - - gc.setLineWidth(1); - gc.setLineStyle(SWT.LINE_SOLID); - - final int top = rect.y - insets.top; - final int left = rect.x - insets.left; - int bottom = rect.y + rect.height + insets.bottom; - int right = rect.x + rect.width + insets.right; - gc.setClipping(new org.eclipse.swt.graphics.Rectangle(left, top, - right - left, bottom - top)); - - final Color color = ColorConstants.red; - gc.setForeground(color); - gc.drawLine(left, top, right, bottom); - - for (int i = 0; i < br.length; i++) - { - // color = br[i]; - gc.setForeground(color); - gc.drawLine(right - i, bottom - i, right - i, top + i); - gc.drawLine(right - i, bottom - i, left + i, bottom - i); - } - - right--; - bottom--; - - for (int i = 0; i < tl.length; i++) - { - // color = tl[i]; - gc.setForeground(color); - gc.drawLine(left + i, top + i, right - i, top + i); - gc.drawLine(left + i, top + i, left + i, bottom - i); - } - color.dispose(); - } - } - - /** - * @param parent - */ - public TabbedWindowBorder(final IFigure parent) - { - // apparently paint() gets called before createBorders() has had - // a chance to create the borders, so we just create them here - inner = new TabbedTitleBarBorder(parent); - outer = normalBorder; - } - - /** - * @param flag - */ - public void setVisible(final boolean flag) - { - if (isVisible != flag) - { - isVisible = flag; - ((TabbedTitleBarBorder) inner).setVisible(flag); - if (flag) - { - ((TabbedTitleBarBorder) inner).getParent().repaint(); - } - } - } - - /** - * @param flag - */ - public void setHighlight(final boolean flag) - { - if (flag) - { - outer = highlightBorder; - } - else - { - outer = normalBorder; - } - ((TabbedTitleBarBorder) inner).getParent().repaint(); - } - - @Override - protected void createBorders() - { - // TODO: NOTE: this is overriding default border creation - } - - @Override - public void paint(final IFigure figure, final Graphics g, final Insets insets) - { - if (isVisible) - { - if (comp != null) - { - final GC gc = new GC(comp); - paint(comp, gc, insets); - gc.dispose(); - } - else - { - super.paint(figure, g, insets); - } - } - } - - private Composite comp; - - /** - * @param comp_ - * @param gc - * @param insets - */ - public void paint(final Composite comp_, final GC gc, final Insets insets) - { - this.comp = comp_; - if (isVisible) - { - ((MySchemeBorder) outer).paint(comp_, gc, insets); - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java deleted file mode 100644 index 1496ca4de..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; - -import org.eclipse.draw2d.ActionEvent; -import org.eclipse.draw2d.ActionListener; -import org.eclipse.draw2d.Button; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Cursors; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseMotionListener; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Image; - -/** - * A title bar button - * - */ -/*package*/ final class TitleBarButton extends Button { - private boolean state = false; - - private Image uncheckedImage; - - private Image checkedImage; - - private Image uncheckedHiliteImage; - - private Image checkedHiliteImage; - - private RectangleList uncheckedRects; - - private RectangleList checkedRects; - - private boolean hilite = false; - - - - /** - * @param unchecked - * @param uncheckedHilite - * @param checked - * @param checkedHilite - */ - public TitleBarButton(Image unchecked, Image uncheckedHilite, - Image checked, Image checkedHilite) { - super(); - uncheckedImage = unchecked; - if (uncheckedHilite == null) - uncheckedHiliteImage = unchecked; - else - uncheckedHiliteImage = uncheckedHilite; - if (checked == null) - checkedImage = unchecked; - else - checkedImage = checked; - if (checkedHilite == null) - checkedHiliteImage = unchecked; - else - checkedHiliteImage = checkedHilite; - initialize(); - } - - /** - * @param rects - */ - public TitleBarButton(RectangleList rects) { - super(); - uncheckedRects = rects; - initialize(); - } - - /** - * @param unchecked - * @param checked - */ - public TitleBarButton(RectangleList unchecked, RectangleList checked) { - super(); - uncheckedRects = unchecked; - checkedRects = checked; - initialize(); - } - - /** - * @return the state - */ - public boolean getState() { - return state; - } - - /** - * @param newState - */ - public void setState(boolean newState) { - state = newState; - hilite = false; - } - - private void initialize() { - setRequestFocusEnabled(true); - setFocusTraversable(true); - - if (uncheckedImage != null) { - org.eclipse.swt.graphics.Rectangle r = uncheckedImage.getBounds(); - setBounds(new Rectangle(0, 0, r.width, r.height)); - prefSize = new Dimension(r.width, r.height); - } else { - setForegroundColor(ColorConstants.black); - setBackgroundColor(ColorConstants.white); - calculatePreferredSize(); - setBounds(new Rectangle(0, 0, prefSize.width, prefSize.height)); - } - setCursor(Cursors.ARROW); - setBorder(null); - setFont(JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT)); - - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(!state); - } - }); - this.addMouseMotionListener(new MouseMotionListener() { - - public void mouseDragged(MouseEvent me) { - // TODO Auto-generated method stub - - } - - public void mouseEntered(MouseEvent me) { - hilite = true; - repaint(); - } - - public void mouseExited(MouseEvent me) { - hilite = false; - repaint(); - } - - public void mouseHover(MouseEvent me) { - // TODO Auto-generated method stub - - } - - public void mouseMoved(MouseEvent me) { - // TODO Auto-generated method stub - - } - }); - } - - /** - * @return the preferred size dimensions - */ - public Dimension calculatePreferredSize() { - if (prefSize == null) { - Rectangle rect = new Rectangle(0, 0, 0, 0); - if (uncheckedRects != null) { - Iterator<Rectangle> iter = uncheckedRects.iterator(); - while (iter.hasNext()) { - /*Point p =*/ getLocation(); - Rectangle r = iter.next().getCopy(); - rect = rect.getUnion(r); - } - } - if (checkedRects != null) { - Iterator<Rectangle> iter = checkedRects.iterator(); - while (iter.hasNext()) { - /*Point p =*/ getLocation(); - Rectangle r = iter.next().getCopy(); - rect = rect.getUnion(r); - } - } - prefSize = rect.getSize(); - if (prefSize.width > prefSize.height) - prefSize.height = prefSize.width; - else if (prefSize.height > prefSize.width) - prefSize.width = prefSize.height; - prefSize.width += 4; - prefSize.height += 4; - } - return prefSize; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics) - */ - public void paint(Graphics graphics) { - if (!isVisible()) - return; - if (uncheckedImage != null) { - if (hilite) { - if (state == false) - graphics.drawImage(uncheckedHiliteImage, getLocation()); - else - graphics.drawImage(checkedHiliteImage, getLocation()); - } else { - if (state == false) - graphics.drawImage(uncheckedImage, getLocation()); - else - graphics.drawImage(checkedImage, getLocation()); - } - } else { - Iterator<Rectangle> iter = null; - if (state == false) - iter = uncheckedRects.iterator(); - else - iter = checkedRects.iterator(); - while (iter.hasNext()) { - Point p = getLocation(); - Rectangle r = iter.next().getCopy(); - r = r.translate(p.x, p.y); - graphics.setForegroundColor(getForegroundColor()); - if (hilite) - graphics.setBackgroundColor(ColorConstants.lightBlue); - else - graphics.setBackgroundColor(ColorConstants.white); - graphics.fillRectangle(r); - graphics.drawRectangle(r); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java deleted file mode 100644 index 073402316..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java +++ /dev/null @@ -1,621 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AncestorListener; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.FreeformViewport; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayeredPane; -import org.eclipse.draw2d.ScalableFreeformLayeredPane; -import org.eclipse.draw2d.ScrollPane; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.GridLayer; -import org.eclipse.gef.editparts.GuideLayer; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -/** - * A ScollPane used as figure container - * - */ -/*package*/ class WindowFigure extends ScrollPane implements IContainerFigure, - LayerConstants, FreeformFigure { - private TabbedWindowBorder windowBorder; - - private TabbedTitleBarBorder titleBarBorder; - - private FreeformViewport myViewport; - - // private FreeformLayeredPane layeredPane; - - private ScalableFreeformLayeredPane scaledLayers; - - private LayeredPane innerLayers; - - private LayeredPane printableLayers; - - private FreeformLayer primaryLayer; - - private final static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - private final static Color defaultForegroundColor = ColorConstants.black; - - private final static Color defaultBackgroundColor = ColorConstants.white; - - private final static Color defaultGridColor = ColorConstants.lightGray; - - private final static Dimension defaultGridSpacing = null; - - private final static boolean defaultGridEnabled = false; - - // Line Routing is not used within the WindowFigure class; it just serves as - // a storage - // location for communicating between the GEMPreferences and EditParts that - // actually - // create the line routers. - private final static int LINE_ROUTING_MANUAL = 0; - - // TODO: should this really be static? - private static int defaultLineRoutingStyle = LINE_ROUTING_MANUAL; - - private class MyGridLayer extends GridLayer { - -// public Point getOrigin() { -// return origin.getCopy(); -// } - } - - private class MyFeedbackLayer extends FreeformLayer { - MyFeedbackLayer() { - setEnabled(false); - } - } - - /** - * Default constructor - */ - public WindowFigure() { - super(); - - windowBorder = new TabbedWindowBorder(this); - titleBarBorder = (TabbedTitleBarBorder) windowBorder.getInnerBorder(); - setBorder(windowBorder); - setFont(defaultFont); - setForegroundColor(defaultForegroundColor); - setBackgroundColor(defaultBackgroundColor); - - innerLayers = new FreeformLayeredPane(); - createLayers(innerLayers); - - myViewport = new FreeformViewport(); - myViewport.setContents(innerLayers); - - setViewport(myViewport); - - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // not related to this CR but discovered while working on it: - // make sure we observe grid visibility from preferences - getGridLayer().setVisible(defaultGridEnabled); - getGridLayer().setSpacing(defaultGridSpacing); - getGridLayer().setForegroundColor(defaultGridColor); - - setText(PreferenceMessages.WindowFigure_Title); - - addTabbedWindowListener(new WindowFigureListener() { - public void tabChanged(int oldIndex, int newIndex) { - internalSetCurrentTab(newIndex); - validate(); - } - }); - addAncestorListener(new AncestorListener() { - - public void ancestorAdded(IFigure ancestor) { - setVisible(true); - } - - public void ancestorMoved(IFigure ancestor) { - // validateComposite(); - } - - public void ancestorRemoved(IFigure ancestor) { - setVisible(false); - } - }); - } - - // ////////////////////////////////////////////////////////////////////////// - // Layer management - // ////////////////////////////////////////////////////////////////////////// - - /** - * @param layeredPane - */ - protected void createLayers(LayeredPane layeredPane) { - layeredPane.add(getScaledLayers(), SCALABLE_LAYERS); - layeredPane.add(new FreeformLayer(), HANDLE_LAYER); - // CR377650: Horizontal scrolling needs to be improved - // moved the feedback layer into printable layers so it shows up in - // content outline - // layeredPane.add(new MyFeedbackLayer(), FEEDBACK_LAYER); - layeredPane.add(new GuideLayer(), GUIDE_LAYER); - } - - /** - * @return the pane - */ - protected ScalableFreeformLayeredPane createScaledLayers() { - ScalableFreeformLayeredPane layers = new ScalableFreeformLayeredPane(); - layers.add(createGridLayer(), GRID_LAYER); - layers.add(getPrintableLayers(), PRINTABLE_LAYERS); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // not needed (?) - // layers.add(new MyFeedbackLayer(), SCALED_FEEDBACK_LAYER); - return layers; - } - - /** - * @return layered pane - */ - protected LayeredPane getScaledLayers() { - if (scaledLayers == null) - scaledLayers = createScaledLayers(); - return scaledLayers; - } - - /** - * @return layered pane - */ - protected LayeredPane createPrintableLayers() { - FreeformLayeredPane layeredPane = new FreeformLayeredPane(); - - PrintedPageLayer pageTileLayer = new PrintedPageLayer(this); - // TODO: get the printer page size from printer preferences - // and set into the PageTileLayer. - pageTileLayer.setPageSize(new Dimension(0, 0)); - layeredPane.add(pageTileLayer, PrintedPageLayer.PRINTED_PAGE_LAYER, -1); - - // CR400208: Lines bleed from the bp canvas through the Fault handler - // window - // changed z-order of connection layer so that it is below figures - layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER, -1); - primaryLayer = new FreeformLayer(); - layeredPane.add(primaryLayer, PRIMARY_LAYER, -1); - primaryLayer.setLayoutManager(new FreeformLayout()); - - // CR377650: Horizontal scrolling needs to be improved - // let's put the feedback layer in with the printable layers so - // we can see the feedback figures in the content outline viewer - layeredPane.add(new MyFeedbackLayer(), FEEDBACK_LAYER); - return layeredPane; - } - - /** - * @return the layered pane - */ - protected LayeredPane getPrintableLayers() { - if (printableLayers == null) - printableLayers = createPrintableLayers(); - return printableLayers; - } - - /** - * @return the grid layer - */ - protected GridLayer createGridLayer() { - return new MyGridLayer(); - } - - /** - * @return the grid layer - */ - public GridLayer getGridLayer() { - return (GridLayer) getLayer(GRID_LAYER); - } - - public Layer getLayer(Object key) { - // ScalableFreeformRootEditPart: - Layer layer = null; - if (scaledLayers != null) - layer = scaledLayers.getLayer(key); - if (layer != null) - return layer; - // FreeformGraphicalRootEditPart: - if (innerLayers == null) - return null; - layer = innerLayers.getLayer(key); - if (layer != null) - return layer; - if (printableLayers == null) - return null; - return printableLayers.getLayer(key); - } - - // ////////////////////////////////////////////////////////////////////////// - // Properties - // ////////////////////////////////////////////////////////////////////////// - - /** - * @return the scroll position - */ - public Point getScrollPosition() { - int x = getHorizontalScrollBar().getRangeModel().getValue(); - int y = getVerticalScrollBar().getRangeModel().getValue(); - return new Point(x, y); - } - - /** - * @return the border - */ - public TabbedTitleBarBorder getTabbedTitleBarBorder() { - return titleBarBorder; - } - - /** - * @return the border - */ - public TabbedWindowBorder getTabbedWindowBorder() { - return windowBorder; - } - - /** - * @param listener - */ - public void addTabbedWindowListener(WindowFigureListener listener) { - titleBarBorder.addTabbedWindowListener(listener); - } - - /** - * @param listener - */ - public void removeTabbedWindowListener(WindowFigureListener listener) { - titleBarBorder.removeTabbedWindowListener(listener); - } - - public Dimension getMinimumSize(int wHint, int hHint) { - Dimension d = titleBarBorder.getMinimumSize(wHint, hHint); - d.expand(getInsets().getWidth(), getInsets().getHeight()); - return d; - } - - /** - * @param s - * @return the previous number of tabs - */ - public int addTab(String s) { - return titleBarBorder.addTab(s); - } - - /** - * @param index - */ - public void removeTab(int index) { - titleBarBorder.removeTab(index); - internalSetCurrentTab(titleBarBorder.getCurrentTab()); - } - - private void internalSetCurrentTab(int index) { - // Object contents = titleBarBorder.getContents(index); - // if (contents instanceof IFigure) - // setContents((IFigure) contents); - } - - /** - * @param index - */ - public void setCurrentTab(int index) { - internalSetCurrentTab(index); - titleBarBorder.setCurrentTab(index); - } - - /** - * @return the current tab index - */ - public int getCurrentTab() { - return titleBarBorder.getCurrentTab(); - } - - public void setContents(IFigure figure) { - titleBarBorder.setContents(0, figure); - super.setContents(figure); - } - - /** - * @param index - * @param contents - */ - public void setContents(int index, Object contents) { - if (contents instanceof IFigure) - setContents((IFigure) contents); - titleBarBorder.setContents(index, contents); - } - - /** - * @param index - * @return the content object of the index - */ - public Object getContents(int index) { - return titleBarBorder.getContents(index); - } - - public void setVisible(boolean flag) { - super.setVisible(flag); - windowBorder.setVisible(flag); - // hide/show the window contents if it's a SWT composite - Object contents = getContents(); - if (contents instanceof Composite) - ((Composite) contents).setVisible(flag); - } - - public void setHighlight(boolean flag) { - windowBorder.setHighlight(flag); - } - - public void setFont(Font f) { - titleBarBorder.setFont(f); - } - - public void setForegroundColor(Color c) { - titleBarBorder.setTextColor(c); - } - - /** - * @param style - */ - public void setLineRoutingStyle(int style) { - defaultLineRoutingStyle = style; - revalidate(); - } - - /** - * @return the line routing style - */ - public int getLineRoutingStyle() { - return defaultLineRoutingStyle; - } - - public Dimension getPreferredSize(int wHint, int hHint) { - if (prefSize == null) { - IFigure parent = getParent(); - prefSize = parent.getSize(); - this.getLayoutManager().invalidate(); - Dimension m = super.getPreferredSize(wHint, hHint); - if (getParent() instanceof CompoundNodeFigure) { - if (((CompoundNodeFigure) parent).getState() == CompoundNodeFigure.RESTORED) { - Insets in = ((CompoundNodeFigure) getParent()) - .getAnchorInsets(); - prefSize.width -= in.getWidth(); - prefSize.height -= in.getHeight(); - } - } else { - if (m.width > prefSize.width) - prefSize.width = m.width; - if (m.height > prefSize.height) - prefSize.height = m.height; - } - } - return prefSize; - } - - protected boolean isValidationRoot() { - return true; - } - - // private void validateComposite() { - // Object contents = getContents(); - // // System.out.println("validate: "+titleBarBorder.getLabel(0)+" - // // "+contents); - // if (contents instanceof Composite) { - // if (getParent() == null) { - // System.err.println("TabbedWindowFigure.validate() - ERROR"); - // return; - // } - // Rectangle r = getBounds().getCopy(); - // r.crop(getInsets()); - // Dimension ps = getParent().getParent().getPreferredSize(); - // Rectangle pr = getParent().getParent().getBounds(); - // titleBarBorder.invalidate(); - // titleBarBorder.getInsets(this); - // Insets in = getParent().getParent().getInsets(); - // Composite comp = (Composite) getContents(); - // comp.setBounds(pr.x + r.x + in.left, pr.y + r.y, r.width, r.height); - // comp.moveAbove(null); - // } - // } - - public void invalidate() { - prefSize = null; - super.invalidate(); - } - - // ////////////////////////////////////////////////////////////////////// - // IBaseFigure methods - // ////////////////////////////////////////////////////////////////////// - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText(String - * text) - */ - public void setText(String name) { - titleBarBorder.setLabel(name); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - if (titleBarBorder == null) - return PreferenceMessages.WindowFigure_NoTitleText; - return titleBarBorder.getLabel(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - Rectangle r = getClientArea().getCopy(); - r.height = titleBarBorder.getTextExtents(this).height; - r.x += getInsets().left; - r.y -= getInsets().top; - return r; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setIcon(org.eclipse.swt.graphics.Image) - */ - public void setIcon(Image image) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText(java.lang.String) - */ - public void setToolTipText(String text) { - // do nothing - } - - public String getToolTipText() { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(BaseFigureDecorator decorator) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(int position) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - return null; - } - - // ////////////////////////////////////////////////////////////////////// - // FreeformFigure methods - // ////////////////////////////////////////////////////////////////////// - - private WindowFreeformHelper helper = new WindowFreeformHelper(this); - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#addFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void addFreeformListener(FreeformListener listener) { - addListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#fireExtentChanged() - */ - public void fireExtentChanged() { - Iterator iter = getListeners(FreeformListener.class); - while (iter.hasNext()) - ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#getFreeformExtent() - */ - public Rectangle getFreeformExtent() { - Rectangle r = helper.getFreeformExtent(); - r.x = 0; - r.y = 0; - return r; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#removeFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void removeFreeformListener(FreeformListener listener) { - removeListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - helper.setFreeformBounds(bounds); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java deleted file mode 100644 index e26390440..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -/** - * @author Bob Brodt - * - * Defines an interface for notifying listeners of page switches on a tabbed - * window figure. - */ -/*package*/ interface WindowFigureListener { - /** - * @param oldIndex - * @param newIndex - */ - void tabChanged(int oldIndex, int newIndex); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java deleted file mode 100644 index 55be3a40a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.List; - -import org.eclipse.draw2d.FigureListener; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * Stolen from org.eclipse.draw2d.FreeformHelper. See also FreeformLayeredPane. - * - * @author bbrodt - */ -/*package*/ class WindowFreeformHelper implements FreeformListener { - FreeformLayeredPane x; - - class ChildTracker implements FigureListener { - public void figureMoved(IFigure source) { - invalidate(); - } - } - - private FreeformFigure host; - - private Rectangle freeformExtent; - - private FigureListener figureListener = new ChildTracker(); - - /** - * @param host - */ - public WindowFreeformHelper(FreeformFigure host) { - this.host = host; - } - - /** - * @return the freeform extent - */ - public Rectangle getFreeformExtent() { - if (freeformExtent != null) - return freeformExtent; - Rectangle r; - List children = host.getChildren(); - for (int i = 0; i < children.size(); i++) { - IFigure child = (IFigure) children.get(i); - if (child instanceof FreeformFigure) - r = ((FreeformFigure) child).getFreeformExtent(); - else - r = child.getBounds(); - if (freeformExtent == null) - freeformExtent = r.getCopy(); - else - freeformExtent.union(r); - } - Insets insets = host.getInsets(); - if (freeformExtent == null) - freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets - .getHeight()); - else { - host.translateToParent(freeformExtent); - freeformExtent.expand(insets); - } - // System.out.println("New extent calculated for " + host + " = " + - // freeformExtent); - return freeformExtent; - } - - /** - * @param child - */ - public void hookChild(IFigure child) { - invalidate(); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).addFreeformListener(this); - else - child.addFigureListener(figureListener); - } - - void invalidate() { - freeformExtent = null; - host.fireExtentChanged(); - if (host.getParent() != null) - host.getParent().revalidate(); - else - host.revalidate(); - } - - public void notifyFreeformExtentChanged() { - // A childs freeform extent has changed, therefore this extent must be - // recalculated - invalidate(); - } - - /** - * @param bounds - */ - public void setFreeformBounds(Rectangle bounds) { - host.setBounds(bounds); - bounds = bounds.getCopy(); - host.translateFromParent(bounds); - List children = host.getChildren(); - for (int i = 0; i < children.size(); i++) { - IFigure child = (IFigure) children.get(i); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).setFreeformBounds(bounds); - } - // CR420954: Compensation Handler canvas goes blank after Variables - // Sections is expanded - host.getLayoutManager().layout(host); - } - - /** - * @param child - */ - public void unhookChild(IFigure child) { - invalidate(); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).removeFreeformListener(this); - else - child.removeFigureListener(figureListener); - } - -}
\ No newline at end of file |