Skip to main content



      Home
Home » Eclipse Projects » GEF » Two kinds of inplace editing
Two kinds of inplace editing [message #13270] Mon, 15 July 2002 10:36 Go to next message
Eclipse UserFriend
Hi
i have an editorpart with editparts on it. these editparts have a name
label that shoulb be modified in an inline fashion, similar to the Label
in the logic example. moreover , a subset of these editparts can be
further editted by opening an editpart dedicated to this element only. so
far i used the performRequest method in my editparts, but it is called
only after double-clicking on the editpart, is there a way to do the
following:
a click on the editpart after the edit part is selected - will allow
renaming the editpart in inline fashion (similar to the behaviour of
renaming files in the Windows Explorer).
Double click will result in opening an editor for that editpart.
the second is possible using performRequest, is there a way to do the
first?
thanks
yoav
Re: Two kinds of inplace editing [message #13488 is a reply to message #13270] Mon, 15 July 2002 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

class MyDragEditPartsTracker
extends DragEditPartsTRacker
{

protected boolean handleButtonDown(int button){
//Make sure the part is already selected
if (button == 1 && getSourceEditPart.getSelected() !=
EditPart.SELECTED_NONE)
getSourceEditPart().performRequest(new Request(REQ_DIRECT_EDIT));
return super.handleButtonDown(button);
}

protected boolean handleDoubleClick(int button){
if (button == 1){
//code to open editor here
}
}

}

Return a modified drag tracker from your EditPart similar to the one above.
Note that buttonDown also occurs during a double-click, so you will probably
start directEdit by accident. The way that Windows Explorer avoids this is
that they don't *really* do a direct edit until after a brief pause. That
is why this behavior is so annoying in windows. You could try to simulate
this pause to avoid the double-click conflict.

Another thing you could do would be to return a differend DragTracker based
on where the user clicks. If they click on the label text, return one that
invokes direct edit on double-click. If the user clicks elsewhere, return
the one that opens.

"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:agumld$ksq$1@rogue.oti.com...
> Hi
> i have an editorpart with editparts on it. these editparts have a name
> label that shoulb be modified in an inline fashion, similar to the Label
> in the logic example. moreover , a subset of these editparts can be
> further editted by opening an editpart dedicated to this element only. so
> far i used the performRequest method in my editparts, but it is called
> only after double-clicking on the editpart, is there a way to do the
> following:
> a click on the editpart after the edit part is selected - will allow
> renaming the editpart in inline fashion (similar to the behaviour of
> renaming files in the Windows Explorer).
> Double click will result in opening an editor for that editpart.
> the second is possible using performRequest, is there a way to do the
> first?
> thanks
> yoav
>
Re: Two kinds of inplace editing [message #13551 is a reply to message #13488] Mon, 15 July 2002 16:00 Go to previous messageGo to next message
Eclipse UserFriend
I've done something similar to what Randy describes.... I also have an
editpart whose figure is a composite of two Label parts, one that has an
Icon and one that just has text. The Icon is above the Text and so you end
up with something similar to the figures you get all over Windows. If the
user double clicks on the text I wanted direct ending to be invoked on the
text. If the user double clicks on the Icon then I wanted something else to
happen ( either a wizard gets invoked or an editor gets invoked).

What I did ( and randy does not strickly approve of this.... but too bad )
is I subclassed the SelectionTool and overrode the handleDoubleClick method
that is defined in the AbstractTool class. In this method I ask the target
edit part ( the thing that got doubled clicked on ) to handle it, and I pass
the co-ordinate of the double click. If it is one of my composite figure
parts then it figures out where the user had the mouse when they clicked
and handles it appropriately.

Guy
Re: Two kinds of inplace editing [message #13592 is a reply to message #13551] Tue, 16 July 2002 02:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi
this also sounds ok, but i think i may confuse the user. i think that it
is less accesible to act in two different fashions according to the
location pressed by the user on the figure. i may be wrong here, but isn't
it more intuitive to the user, that if there are two different ways to
edit an element, then there should be two different ways to invoke it. it
is a usability/design issue, but any comment for this will be appreciated.
thanks
yoav
Guy Slade wrote:

> I've done something similar to what Randy describes.... I also have an
> editpart whose figure is a composite of two Label parts, one that has an
> Icon and one that just has text. The Icon is above the Text and so you end
> up with something similar to the figures you get all over Windows. If the
> user double clicks on the text I wanted direct ending to be invoked on the
> text. If the user double clicks on the Icon then I wanted something else to
> happen ( either a wizard gets invoked or an editor gets invoked).

> What I did ( and randy does not strickly approve of this.... but too bad )
> is I subclassed the SelectionTool and overrode the handleDoubleClick method
> that is defined in the AbstractTool class. In this method I ask the target
> edit part ( the thing that got doubled clicked on ) to handle it, and I pass
> the co-ordinate of the double click. If it is one of my composite figure
> parts then it figures out where the user had the mouse when they clicked
> and handles it appropriately.

> Guy
Re: Two kinds of inplace editing [message #13635 is a reply to message #13592] Tue, 16 July 2002 07:34 Go to previous messageGo to next message
Eclipse UserFriend
You have a point with the accessibility issue I guess. On my editor the
direct editing of the text can also be invoked via a pop up context menu. So
I guess in your case one option would be to capture the double click either
as I have described and handle it as you want and then allow the direct
editing only through the context menu.

Guy

"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:ah0fn5$hb7$1@rogue.oti.com...
> Hi
> this also sounds ok, but i think i may confuse the user. i think that it
> is less accesible to act in two different fashions according to the
> location pressed by the user on the figure. i may be wrong here, but isn't
> it more intuitive to the user, that if there are two different ways to
> edit an element, then there should be two different ways to invoke it. it
> is a usability/design issue, but any comment for this will be appreciated.
> thanks
> yoav
> Guy Slade wrote:
>
> > I've done something similar to what Randy describes.... I also have an
> > editpart whose figure is a composite of two Label parts, one that has an
> > Icon and one that just has text. The Icon is above the Text and so you
end
> > up with something similar to the figures you get all over Windows. If
the
> > user double clicks on the text I wanted direct ending to be invoked on
the
> > text. If the user double clicks on the Icon then I wanted something else
to
> > happen ( either a wizard gets invoked or an editor gets invoked).
>
> > What I did ( and randy does not strickly approve of this.... but too
bad )
> > is I subclassed the SelectionTool and overrode the handleDoubleClick
method
> > that is defined in the AbstractTool class. In this method I ask the
target
> > edit part ( the thing that got doubled clicked on ) to handle it, and I
pass
> > the co-ordinate of the double click. If it is one of my composite figure
> > parts then it figures out where the user had the mouse when they
clicked
> > and handles it appropriately.
>
> > Guy
>
>
>
>
>
Re: Two kinds of inplace editing [message #13655 is a reply to message #13592] Tue, 16 July 2002 11:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

I think it is safe to use double click in different places to do different
things. Windows doesn't do this for several reasons. Sometimes
double-click mean expand a treeitem. Sometimes the Icon is so small that
requiring that the user double click the icon would be a burden. I'm
guessing you Icons are at least 32x32. What does the MAC do?

The user should also be able to user F2 for rename, and Enter key for open.

"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:ah0fn5$hb7$1@rogue.oti.com...
> Hi
> this also sounds ok, but i think i may confuse the user. i think that it
> is less accesible to act in two different fashions according to the
> location pressed by the user on the figure. i may be wrong here, but isn't
> it more intuitive to the user, that if there are two different ways to
> edit an element, then there should be two different ways to invoke it. it
> is a usability/design issue, but any comment for this will be appreciated.
> thanks
> yoav
> Guy Slade wrote:
>
> > I've done something similar to what Randy describes.... I also have an
> > editpart whose figure is a composite of two Label parts, one that has an
> > Icon and one that just has text. The Icon is above the Text and so you
end
> > up with something similar to the figures you get all over Windows. If
the
> > user double clicks on the text I wanted direct ending to be invoked on
the
> > text. If the user double clicks on the Icon then I wanted something else
to
> > happen ( either a wizard gets invoked or an editor gets invoked).
>
> > What I did ( and randy does not strickly approve of this.... but too
bad )
> > is I subclassed the SelectionTool and overrode the handleDoubleClick
method
> > that is defined in the AbstractTool class. In this method I ask the
target
> > edit part ( the thing that got doubled clicked on ) to handle it, and I
pass
> > the co-ordinate of the double click. If it is one of my composite figure
> > parts then it figures out where the user had the mouse when they
clicked
> > and handles it appropriately.
>
> > Guy
>
>
>
>
>
Re: Two kinds of inplace editing [message #13742 is a reply to message #13551] Wed, 17 July 2002 10:22 Go to previous messageGo to next message
Eclipse UserFriend
....For anyone who is interested....
Randy Belknap emailed me and asked for the figure code to build a figure
consisting of an icon and text under it. Here it is, in a much stripped down
form. Hopefully I have left enough of the code in to give you the general
idea of how to build it..... it is very simple.

Note: the reason I use the LayeredIconFigure class is because the Icon part
of my figure may consist of a couple of overlayed icons.... this is so I can
show a red cross ( for error), and a warning and an info Icon over the
'actual' icon.

=============================================
package figure.stuff;
import java.util.List;
import com.ibm.etools.draw2d.Figure;
import com.ibm.etools.draw2d.StackLayout;
/**
* Figure with Stack Layout so icons can be placed one on top of the other
*
* @author Guy Slade
*/
public class LayeredIconFigure extends Figure {
/**
* Constructor for LayeredIconFigure.
*/
public LayeredIconFigure() {
super();
StackLayout gl = new StackLayout();
setLayoutManager(gl);
}
}


package figure.stuff;
import org.eclipse.swt.graphics.Image;
import com.ibm.etools.draw2d.*;
import com.ibm.etools.draw2d.geometry.Point;
import com.ibm.etools.struts.Images;

public class CompositeFigure extends Figure {

private Label theText = new Label();
private Label theIcon = new Label();

private LayeredIconFigure layerIconFigure = new LayeredIconFigure();
/**
* Constructor for StrutsGraphicalBlobFigure.
*/
public CompositeFigure() {
super();

// Create and set layout manager
FlowLayout layout = new FlowLayout(false);
layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
setLayoutManager(layout);

// Build the set of labels
add(getLayerIconFigure());
add(getTheText());
getLayerIconFigure().add(getTheIcon());
}

/**
* A public method to enable the text of this figure
* to be changed
*
* @param text The text to set
*/
public void setText(String text) {
getTheText().setText(text);
}

/**
* A public method to enable the background image of this figure
* to be changed
*/
public void setImage(Image img) {
getTheIcon().setIcon(img);
}
/**
* Gets the theIcon.
* @return Returns a Label
*/
public Label getTheIcon() {
return theIcon;
}
/**
* Sets the theIcon.
* @param theIcon The theIcon to set
*/
private void setTheIcon(Label theIcon) {
this.theIcon = theIcon;
}
/**
* Gets the theText.
* @return Returns a Label
*/
public Label getTheText() {
return theText;
}
/**
* Sets the theText.
* @param theText The theText to set
*/
private void setTheText(Label theText) {
this.theText = theText;
}

/**
* Gets the layerIconFigure.
* @return Returns a LayeredIconFigure
*/
private LayeredIconFigure getLayerIconFigure() {
return layerIconFigure;
}
/**
* Sets the layerIconFigure.
* @param layerIconFigure The layerIconFigure to set
*/
private void setLayerIconFigure(LayeredIconFigure layerIconFigure) {
this.layerIconFigure = layerIconFigure;
}

}
Re: Two kinds of inplace editing [message #13779 is a reply to message #13742] Wed, 17 July 2002 15:20 Go to previous message
Eclipse UserFriend
Originally posted by: randy.belknap.epropose.com

Thanks much. It works great!

Just to round out the explanation for anyone else: The figure gets created
in the EditPart which then calls the figure.setText() method to label the
figure.


"Guy Slade" <gslade@us.ibm.com> wrote in message
news:ah3sp3$cfd$1@rogue.oti.com...
> ...For anyone who is interested....
> Randy Belknap emailed me and asked for the figure code to build a figure
> consisting of an icon and text under it. Here it is, in a much stripped
down
> form. Hopefully I have left enough of the code in to give you the general
> idea of how to build it..... it is very simple.
>
> Note: the reason I use the LayeredIconFigure class is because the Icon
part
> of my figure may consist of a couple of overlayed icons.... this is so I
can
> show a red cross ( for error), and a warning and an info Icon over the
> 'actual' icon.
>
> =============================================
> package figure.stuff;
> import java.util.List;
> import com.ibm.etools.draw2d.Figure;
> import com.ibm.etools.draw2d.StackLayout;
> /**
> * Figure with Stack Layout so icons can be placed one on top of the other
> *
> * @author Guy Slade
> */
> public class LayeredIconFigure extends Figure {
> /**
> * Constructor for LayeredIconFigure.
> */
> public LayeredIconFigure() {
> super();
> StackLayout gl = new StackLayout();
> setLayoutManager(gl);
> }
> }
>
>
> package figure.stuff;
> import org.eclipse.swt.graphics.Image;
> import com.ibm.etools.draw2d.*;
> import com.ibm.etools.draw2d.geometry.Point;
> import com.ibm.etools.struts.Images;
>
> public class CompositeFigure extends Figure {
>
> private Label theText = new Label();
> private Label theIcon = new Label();
>
> private LayeredIconFigure layerIconFigure = new LayeredIconFigure();
> /**
> * Constructor for StrutsGraphicalBlobFigure.
> */
> public CompositeFigure() {
> super();
>
> // Create and set layout manager
> FlowLayout layout = new FlowLayout(false);
> layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
> setLayoutManager(layout);
>
> // Build the set of labels
> add(getLayerIconFigure());
> add(getTheText());
> getLayerIconFigure().add(getTheIcon());
> }
>
> /**
> * A public method to enable the text of this figure
> * to be changed
> *
> * @param text The text to set
> */
> public void setText(String text) {
> getTheText().setText(text);
> }
>
> /**
> * A public method to enable the background image of this figure
> * to be changed
> */
> public void setImage(Image img) {
> getTheIcon().setIcon(img);
> }
> /**
> * Gets the theIcon.
> * @return Returns a Label
> */
> public Label getTheIcon() {
> return theIcon;
> }
> /**
> * Sets the theIcon.
> * @param theIcon The theIcon to set
> */
> private void setTheIcon(Label theIcon) {
> this.theIcon = theIcon;
> }
> /**
> * Gets the theText.
> * @return Returns a Label
> */
> public Label getTheText() {
> return theText;
> }
> /**
> * Sets the theText.
> * @param theText The theText to set
> */
> private void setTheText(Label theText) {
> this.theText = theText;
> }
>
> /**
> * Gets the layerIconFigure.
> * @return Returns a LayeredIconFigure
> */
> private LayeredIconFigure getLayerIconFigure() {
> return layerIconFigure;
> }
> /**
> * Sets the layerIconFigure.
> * @param layerIconFigure The layerIconFigure to set
> */
> private void setLayerIconFigure(LayeredIconFigure layerIconFigure) {
> this.layerIconFigure = layerIconFigure;
> }
>
> }
>
>
Previous Topic:Connection Creation Feedback
Next Topic:Adding captions for a flow
Goto Forum:
  


Current Time: Mon Jun 09 03:10:26 EDT 2025

Powered by FUDForum. Page generated in 0.21603 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top