Index: src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 PerformanceNodePart.java --- src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java 5 May 2005 23:47:58 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java 16 May 2005 21:42:22 -0000 @@ -43,8 +43,8 @@ import java.util.List; import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; import nongnu.cashews.eclipse.composer.model.PerformanceElement; import nongnu.cashews.eclipse.composer.model.Node; -import nongnu.cashews.eclipse.composer.tools.PerformanceNodeCellEditorLocator; -import nongnu.cashews.eclipse.composer.tools.PerformanceNodeDirectEditManager; +import nongnu.cashews.eclipse.composer.tools.PerformanceCellEditorLocator; +import nongnu.cashews.eclipse.composer.tools.PerformanceDirectEditManager; import org.eclipse.draw2d.IFigure; @@ -125,11 +125,10 @@ public class PerformanceNodePart if (manager == null) { PerformanceNodeFigure nodeFigure = (PerformanceNodeFigure) getFigure(); - manager = new PerformanceNodeDirectEditManager( + manager = new PerformanceDirectEditManager( this, TextCellEditor.class, - new PerformanceNodeCellEditorLocator( - nodeFigure), + new PerformanceCellEditorLocator(nodeFigure), nodeFigure); } manager.show(); Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceCellEditorLocator.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceCellEditorLocator.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceCellEditorLocator.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/PerformanceCellEditorLocator.java 16 May 2005 21:42:22 -0000 @@ -0,0 +1,70 @@ +/* EllipseNodeCellEditorLocator.java -- Locator for elliptical nodes. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; + +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +public class PerformanceCellEditorLocator + implements CellEditorLocator +{ + + private PerformanceNodeFigure nodeFigure; + + public PerformanceCellEditorLocator(PerformanceNodeFigure nodeFigure) + { + this.nodeFigure = nodeFigure; + } + + // ------------------------------------------------------------------------ + // Abstract methods from CellEditorLocator + + public void relocate(CellEditor celleditor) + { + Text text = (Text) celleditor.getControl(); + Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = nodeFigure.getTextBounds(); + text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); + } +} Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceDirectEditManager.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceDirectEditManager.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceDirectEditManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/PerformanceDirectEditManager.java 16 May 2005 21:42:22 -0000 @@ -0,0 +1,138 @@ +/* EllipseNodeDirectEditManager.java -- Manager for direct edits. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; + +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Dimension; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; + +public class PerformanceDirectEditManager + extends DirectEditManager +{ + + Font scaledFont; + + protected VerifyListener verifyListener; + + protected PerformanceNodeFigure ellipseNodeFigure; + + public PerformanceDirectEditManager(GraphicalEditPart source, + Class editorType, + CellEditorLocator locator, + PerformanceNodeFigure ellipseNodeFigure) + { + super(source, editorType, locator); + this.ellipseNodeFigure = ellipseNodeFigure; + } + + // ------------------------------------------------------------------------ + // Overridden methods from DirectEditManager + + protected void bringDown() + { + Font disposeFont = this.scaledFont; + this.scaledFont = null; + super.bringDown(); + if (disposeFont != null) + { + disposeFont.dispose(); + } + } + + protected void unhookListeners() + { + super.unhookListeners(); + Text text = (Text) getCellEditor().getControl(); + text.removeVerifyListener(verifyListener); + verifyListener = null; + } + + // ------------------------------------------------------------------------ + // Abstract methods from DirectEditManager + + protected void initCellEditor() + { + + verifyListener = new VerifyListener() + { + public void verifyText(VerifyEvent event) + { + Text text = (Text) getCellEditor().getControl(); + String oldText = text.getText(); + String leftText = oldText.substring(0, event.start); + String rightText = oldText.substring(event.end, oldText.length()); + GC gc = new GC(text); + Point size = gc.textExtent(leftText + event.text + rightText); + gc.dispose(); + if (size.x != 0) + { + size = text.computeSize(size.x, SWT.DEFAULT); + } + getCellEditor().getControl().setSize(size.x, size.y); + } + }; + + Text text = (Text) getCellEditor().getControl(); + text.addVerifyListener(verifyListener); + + getCellEditor().setValue(this.ellipseNodeFigure.getText()); + IFigure figure = ((GraphicalEditPart) getEditPart()).getFigure(); + scaledFont = figure.getFont(); + FontData data = scaledFont.getFontData()[0]; + Dimension fontSize = new Dimension(0, data.getHeight()); + data.setHeight(fontSize.height); + scaledFont = new Font(null, data); + + text.setFont(scaledFont); + text.selectAll(); + } +} Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java --- src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java 5 May 2005 23:47:59 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,70 +0,0 @@ -/* EllipseNodeCellEditorLocator.java -- Locator for elliptical nodes. - Copyright (C) 2005 The University of Sheffield. - -This file is part of the CASheW-s editor Eclipse plug-in. - -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. - -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. - -*/ - -package nongnu.cashews.eclipse.composer.tools; - -import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -public class PerformanceNodeCellEditorLocator - implements CellEditorLocator -{ - - private PerformanceNodeFigure nodeFigure; - - public PerformanceNodeCellEditorLocator(PerformanceNodeFigure nodeFigure) - { - this.nodeFigure = nodeFigure; - } - - // ------------------------------------------------------------------------ - // Abstract methods from CellEditorLocator - - public void relocate(CellEditor celleditor) - { - Text text = (Text) celleditor.getControl(); - Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle rect = this.nodeFigure.getTextBounds(); - text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); - } -} Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java --- src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java 5 May 2005 23:47:59 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,138 +0,0 @@ -/* EllipseNodeDirectEditManager.java -- Manager for direct edits. - Copyright (C) 2005 The University of Sheffield. - -This file is part of the CASheW-s editor Eclipse plug-in. - -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. - -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. - -*/ - -package nongnu.cashews.eclipse.composer.tools; - -import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; - -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; - -public class PerformanceNodeDirectEditManager - extends DirectEditManager -{ - - Font scaledFont; - - protected VerifyListener verifyListener; - - protected PerformanceNodeFigure ellipseNodeFigure; - - public PerformanceNodeDirectEditManager(GraphicalEditPart source, - Class editorType, - CellEditorLocator locator, - PerformanceNodeFigure ellipseNodeFigure) - { - super(source, editorType, locator); - this.ellipseNodeFigure = ellipseNodeFigure; - } - - // ------------------------------------------------------------------------ - // Overridden methods from DirectEditManager - - protected void bringDown() - { - Font disposeFont = this.scaledFont; - this.scaledFont = null; - super.bringDown(); - if (disposeFont != null) - { - disposeFont.dispose(); - } - } - - protected void unhookListeners() - { - super.unhookListeners(); - Text text = (Text) getCellEditor().getControl(); - text.removeVerifyListener(verifyListener); - verifyListener = null; - } - - // ------------------------------------------------------------------------ - // Abstract methods from DirectEditManager - - protected void initCellEditor() - { - - verifyListener = new VerifyListener() - { - public void verifyText(VerifyEvent event) - { - Text text = (Text) getCellEditor().getControl(); - String oldText = text.getText(); - String leftText = oldText.substring(0, event.start); - String rightText = oldText.substring(event.end, oldText.length()); - GC gc = new GC(text); - Point size = gc.textExtent(leftText + event.text + rightText); - gc.dispose(); - if (size.x != 0) - { - size = text.computeSize(size.x, SWT.DEFAULT); - } - getCellEditor().getControl().setSize(size.x, size.y); - } - }; - - Text text = (Text) getCellEditor().getControl(); - text.addVerifyListener(verifyListener); - - getCellEditor().setValue(this.ellipseNodeFigure.getText()); - IFigure figure = ((GraphicalEditPart) getEditPart()).getFigure(); - scaledFont = figure.getFont(); - FontData data = scaledFont.getFontData()[0]; - Dimension fontSize = new Dimension(0, data.getHeight()); - data.setHeight(fontSize.height); - scaledFont = new Font(null, data); - - text.setFont(scaledFont); - text.selectAll(); - } -}