Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problems with an input connection
Problems with an input connection [message #174666] Thu, 31 March 2005 12:01 Go to next message
Eclipse UserFriend
Originally posted by: jdelgad.correo.ugr.es

Hi all,

I want to allow that a figure can have several input connections (all
other figures have only one input connection). I have created the
following canExecute() method:

public boolean canExecute() {

if (target != null) {
Vector conns = target.getConnections();
Iterator i = conns.iterator();
while (i.hasNext()) {
Arrow conn = (Arrow)i.next();
if (targetTerminal != null && conn.getTargetTerminal() != null)
if (conn.getTargetTerminal().equals(targetTerminal) &&
conn.getTarget().equals(source))
return false;
}
}
return true;
}

This code allows to create several input connections, but when I close
the file and I reopen it, only one input connection is created correctly
and the others have an incorrect end position (but all the same). Why this
ocurrs? Do you need any other information?

Thank you very much.

--Jose.
Re: Problems with an input connection [message #174690 is a reply to message #174666] Thu, 31 March 2005 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Jose wrote:
> Hi all,
>
> I want to allow that a figure can have several input connections (all
> other figures have only one input connection). I have created the
> following canExecute() method:
>
> public boolean canExecute() {
>
> if (target != null) {
> Vector conns = target.getConnections();
> Iterator i = conns.iterator();
> while (i.hasNext()) {
> Arrow conn = (Arrow)i.next();
> if (targetTerminal != null && conn.getTargetTerminal() != null)
> if (conn.getTargetTerminal().equals(targetTerminal) &&
> conn.getTarget().equals(source))
> return false;
> }
> }
> return true;
> }
>
> This code allows to create several input connections, but when I close
> the file and I reopen it, only one input connection is created correctly
> and the others have an incorrect end position (but all the same). Why
> this ocurrs? Do you need any other information?
>
> Thank you very much.
>
> --Jose.
>

This calculation should be done before you create the command IMHO. The
commands state should not change through external means after the
command is created.

When you are about to create the command, perform your canExecute logic,
and if it fails return a NullCommand, if it does not fail, return a real
command.


as for your real problem. It appears that your models are not properly
storing and using the connections. How are you storing them, and when
are you recreating them upon load of the file?

CL
Re: Problems with an input connection [message #174711 is a reply to message #174690] Thu, 31 March 2005 14:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jdelgad.correo.ugr.es

Hi CL,

first of all, I would like to thank you for your interest in helping me.
The way in which I store the diagram is using the following method:

public void doSave(IProgressMonitor progressMonitor) {
try {
editorSaving = true;
saveProperties();
ByteArrayOutputStream out = new ByteArrayOutputStream();
createOutputStream(out);
IFile file = ((IFileEditorInput) getEditorInput()).getFile();
file.setContents(new ByteArrayInputStream(out.toByteArray()), true,
false, progressMonitor);
out.close();
getCommandStack().markSaveLocation();
} catch (Exception e) {
e.printStackTrace();
} finally {
editorSaving = false;
}
}


The saveProperties() and createOutputStream() methods are the following:

protected void saveProperties() {
getJCLECDiagram().setRulerVisibility(
((Boolean) getGraphicalViewer().getProperty(
RulerProvider.PROPERTY_RULER_VISIBILITY)).booleanValue());
getJCLECDiagram().setGridEnabled(
((Boolean) getGraphicalViewer().getProperty(

SnapToGrid.PROPERTY_GRID_ENABLED)).booleanValue());
getJCLECDiagram().setSnapToGeometry(
((Boolean) getGraphicalViewer().getProperty(

SnapToGeometry.PROPERTY_SNAP_ENABLED)).booleanValue());
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(
ZoomManager.class.toString());
if (manager != null)
getJCLECDiagram().setZoom(manager.getZoom());
}


protected void createOutputStream(OutputStream ostream) throws
IOException {
ObjectOutputStream out = new ObjectOutputStream(ostream);
out.writeObject(getJCLECDiagram());
out.close();
}


Last, the method used for loading the contents of a file created with
the graphical editor is the following:

public void setInput(IEditorInput input) {
superSetInput(input);

IFile file = ((IFileEditorInput) input).getFile();
try {
InputStream is = file.getContents(false);
ObjectInputStream ois = new ObjectInputStream(is);
setJCLECDiagram((JclecDiagram) ois.readObject());
ois.close();
} catch (Exception e) {
e.printStackTrace();
}
if (!editorSaving) {
if (getGraphicalViewer() != null) {
getGraphicalViewer().setContents(getJCLECDiagram());
loadProperties();
}
if (outlinePage != null) {
outlinePage.setContents(getJCLECDiagram());
}
}
}


This is the information I think you can need. But if you need any other
information, please tell me.

Thank you very much.

--Jose.
Re: Problems with an input connection [message #174729 is a reply to message #174711] Thu, 31 March 2005 16:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Jose wrote:
> Hi CL,
>
> first of all, I would like to thank you for your interest in helping me.
> The way in which I store the diagram is using the following method:
>

....

>
>
> This is the information I think you can need. But if you need any other
> information, please tell me.
>
> Thank you very much.
>
> --Jose.
>
>

The important information is how the connections are held within your
model which I believe is called JCLEDiagram. So how have you
implemented saving 'inside' of your class JCLEDiagram. And when you
reload JCLEDiagram, are the connections loaded within it?

CL
Re: Problems with an input connection [message #175092 is a reply to message #174729] Sat, 02 April 2005 08:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jdelgad.correo.ugr.es

Hi,

inside of the JCLECDiagram I don't implement any saving method. And
when I reload de JCLECDiagram, the connections appear inside of it, but
with an incorrect end point (only one of the connections have a a correct
end point).


Thank you
Re: Problems with an input connection [message #175147 is a reply to message #175092] Sun, 03 April 2005 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Jose wrote:
> Hi,
> inside of the JCLECDiagram I don't implement any saving method. And
> when I reload de JCLECDiagram, the connections appear inside of it, but
> with an incorrect end point (only one of the connections have a a
> correct end point).
>
>
> Thank you
>

I dont think you are understanding me. JCLEDiagram MUST know of and
maintain its list of connections. When JCLEDiagram is loaded from the
file it must RESTORE its list of connections in some fashion. How are
you accomplishing this? It would seem that you are not doing this
correctly if the connections are not being restored after you load the file.

CL
Previous Topic:Graphical Text Proposal question
Next Topic:activate() not being called for outline view's tree
Goto Forum:
  


Current Time: Tue Apr 23 06:19:09 GMT 2024

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

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

Back to the top