Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Can't show a popup during target feedback
Can't show a popup during target feedback [message #547201] Thu, 15 July 2010 22:20
Swavek  is currently offline Swavek
Messages: 20
Registered: March 2010
Junior Member
I am adding a functionality which will show a popup with detailed status information when user hovers over a node on my diagram. Towards that goal I created and installed an edit policy in my edit part in createDefaultEditPolicies method of my edit part.


// install edit policy which will show a popup containing details of node execution
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ShowExecutionFeedbackPolicy());

The edit policy gets called when I mouse over with a request which is a SelectionRequest. I don't require selection for this popup to be shown but that is just the request I see.

In showTargetFeedback I create a popup which is a Composite with a table in it. As a parent of this popup I am passing it the parent of the root of the diagram like so.

Control rootControl = getHost().getRoot().getViewer().getControl();
Composite rootParent = rootControl.getParent();
fExecutionInfoDisplayPanel = new ExecutionInfoDisplayPanel (rootParent, SWT.BORDER);

No matter what I try the panel doesn't want to show up. Is this a wrong parent to pass to this panel. I tried Shell and it didn't work. Does feedback need to be shown in a feedback layer?

I had no problems displaying dialogs to configure nodes using a Shell as a parent so I am confused here? The panel shows up OK when I run it in a standalone application so I don't think it is a problem with the panel itself.

here is the code for my panel.

public class ExecutionInfoDisplayPanel extends Composite {

// table for displaying values of execution info properties
private Table fTable;

/**
* Constructor
*
* @param parent
* @param style
*/
public ExecutionInfoDisplayPanel(Composite parent, int style) {
super(parent, style);
this.setLayout(new FillLayout());
fTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.HIDE_SELECTION);
fTable.setLinesVisible(true);
fTable.setHeaderVisible(true);

String[] titles = { "Attribute", "Value" };
for (int i = 0; i < titles.length; i++) {
TableColumn column = new TableColumn(fTable, SWT.NONE);
column.setText(titles[i]);
}
}

/**
* fills the table with xml execution info
*
* @param executionAtrributeToValueMap
*/
public void fillExecutionInfo(Map<String, Object> executionAtrributeToValueMap) {
fTable.removeAll();

Set<String> attributeNames = executionAtrributeToValueMap.keySet();
for (String attribute : attributeNames) {
Object value = executionAtrributeToValueMap.get(attribute);
TableItem item = new TableItem(fTable, SWT.NONE);
item.setText(0, attribute);
item.setText(1, value.toString());
System.out.println ("added table item for " + attribute + " value: " + value.toString());
}

for (int i = 0; i < fTable.getColumnCount(); i++) {
fTable.getColumn(i).pack();
}
}
}


-----------------------------------------------
Here is the relevant code from my edit policy

public void showTargetFeedback(Request request) {
if (request instanceof SelectionRequest) {
SelectionRequest selectionRequest = (SelectionRequest)request;
// get the contents for the panel
// first get the domain model object corresponding to this graphical edit part
View view = (View)getHost().getModel();
EmfNode emfNode = (EmfNode) view.getElement();
// get the execution info for the entire application
NetworkResourceImpl networkResource = (NetworkResourceImpl) emfNode.eResource();
NetworkExecutionStateManager nesm = networkResource.getExecutionStateManager();
// when application is executing
if (nesm.isRunning()) {
if (fExecutionInfoDisplayPanel == null) {
System.out.println ("showTargetFeedback at " + selectionRequest.getLocation().toString());
// Control targetControl = getHost().getViewer().getControl();
// Shell shell = targetControl.getShell();
// Composite parent = targetControl.getParent();
Control rootControl = getHost().getRoot().getViewer().getControl();
Composite rootParent = rootControl.getParent();
fExecutionInfoDisplayPanel = new ExecutionInfoDisplayPanel (rootParent, SWT.BORDER);

XmlExecutionInfo appXmlExecutionInfo = nesm.getfXmlExecutionInfo();

// now get the map of attribute name to value extracted from the execution info for this node
ExecutionInfoSpecification pExecInfoSpec = null;
String nodeId = emfNode.getId();
Map<String, Object> executionAttributeToValueMap = XmlExecutionInfoHelper.getExecutionInfo(nodeId, appXmlExecutionInfo, pExecInfoSpec);

// fill and display it
fExecutionInfoDisplayPanel.fillExecutionInfo(executionAttrib uteToValueMap );
Point location = new Point(selectionRequest.getLocation().x,
selectionRequest.getLocation().y - 20);
fExecutionInfoDisplayPanel.setLocation(location);
fExecutionInfoDisplayPanel.setVisible(true);
}
}
}
}

@Override
public void eraseTargetFeedback(Request request) {
if (fExecutionInfoDisplayPanel != null) {
fExecutionInfoDisplayPanel.setVisible(false);
fExecutionInfoDisplayPanel = null;
}
}


Thanks,

Swavek


Previous Topic:Problem using GEF,ZEST GraphViewer in RCP views
Next Topic:Adapt FlowLayoutEditPolicy for ToolbarLayout
Goto Forum:
  


Current Time: Sat Oct 25 05:51:56 GMT 2014

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

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