use of org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader in project titan.EclipsePlug-ins by eclipse.
the class MSCWidget method contentsMouseUpEvent.
@Override
protected void contentsMouseUpEvent(final MouseEvent event) {
this.toolTip.hideToolTip();
if (this.dragAndDrop != null) {
if ((this.overView != null) && !this.overView.isDisposed()) {
this.overView.dispose();
}
this.overView = null;
Lifeline node = this.frame.getCloserLifeline(this.dragX);
if (node != null) {
Lifeline currLifeline = ((LifelineHeader) this.dragAndDrop).getLifeline();
int rx = Math.round(node.getX() * this.zoomValue);
if ((rx <= event.x) && (Math.round(rx + (node.getWidth() * this.zoomValue)) >= event.x)) {
// Do nothing
} else {
this.frame.moveLifeLineToPosition(currLifeline, node.getIndex());
}
}
((LifelineHeader) this.dragAndDrop).setDragAndDropMode(false);
this.dragAndDrop = null;
}
redraw();
if (this.frame == null) {
return;
}
super.contentsMouseUpEvent(event);
}
use of org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader in project titan.EclipsePlug-ins by eclipse.
the class MSCModel method getNodes.
/**
* Collects the nodes that belong to the range provided.
*
* @param startIndex the index of the first event to process.
* @param endIndex the index of the last event to process.
*
* @return the list of the found nodes.
*/
public List<MSCNode> getNodes(final int startIndex, final int endIndex) {
if (sutLifeline == null) {
this.sutLifeline = new Lifeline();
}
List<IEventObject> events = this.model.getEvents(startIndex, endIndex);
List<MSCNode> result = new ArrayList<MSCNode>();
for (int i = 0; i < 3; i++) {
MSCNode[] nodes = extractNodes(events.get(i), i);
for (MSCNode node : nodes) {
if (!(node instanceof Lifeline) && !(node instanceof LifelineHeader)) {
result.add(node);
}
}
}
for (int i = 3; i < events.size(); i++) {
MSCNode[] nodes = extractNodes(events.get(i), startIndex + i);
for (MSCNode node : nodes) {
if (!(node instanceof Lifeline) && !(node instanceof LifelineHeader)) {
result.add(node);
}
}
}
return result;
}
use of org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader in project titan.EclipsePlug-ins by eclipse.
the class MSCModel method createLifelineAndHeaderComponent.
private void createLifelineAndHeaderComponent(final String ref, final String time, final Lifeline lifeline, final int occurrence) {
if (this.lifelines.containsKey(ref)) {
return;
}
// Add life line
this.lifelines.put(ref, lifeline);
// Get and set name
String name = getComponentNameFromReference(ref);
// Set name without ref so that the visual order works
lifeline.setName(name);
this.frame.addLifeLine(lifeline);
// Create and add Header
LifelineHeader lifeLineHeader = new LifelineHeader(lifeline, this.frame);
if (!name.contentEquals(this.sutName) && !name.contentEquals(MSCConstants.MTC_NAME) && !name.contentEquals(ref)) {
// $NON-NLS-1$ //$NON-NLS-2$
name = name + " (" + ref + ")";
}
lifeLineHeader.setName(name);
this.frame.addLifeLineHeader(lifeLineHeader);
// Create and add Start
lifeline.setCurrentEventOccurrence(occurrence);
ComponentCreation start = new ComponentCreation(occurrence, lifeline);
start.setName(name);
lifeline.setStart(start);
}
use of org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader in project titan.EclipsePlug-ins by eclipse.
the class MSCWidget method drawContents.
@Override
protected void drawContents(final GC gc, final int clipx, final int clipy, final int clipw, final int cliph) {
if (this.frame == null) {
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
gc.dispose();
return;
}
update();
Rectangle area = getClientArea();
Image dbuffer = new Image(getDisplay(), area.width, area.height);
GC gcim = new GC(dbuffer);
NGC context = new NGC(this, gcim);
// Calculate font height and width
MSCConstants.setFontHeight(context.getFontHeight((Font) Activator.getDefault().getCachedResource(MSCConstants.MSC_DEFAULT_FONT)));
MSCConstants.setDefaultFontWidth(context.getFontWidth((Font) Activator.getDefault().getCachedResource(MSCConstants.MSC_DEFAULT_FONT)));
MSCConstants.setBoldFontWidth(context.getFontWidth((Font) Activator.getDefault().getCachedResource(MSCConstants.MSC_BOLD_FONT)));
int width = Math.round(this.frame.getWidth() * this.zoomValue);
int height = Math.round(this.frame.getHeight() * this.zoomValue);
resizeContents(width, height);
context.setBackground((Color) Activator.getDefault().getCachedResource(MSCConstants.DEFAULT_BACKGROUND_COLOR));
context.fillRectangle(0, 0, this.frame.getX(), getContentsHeight());
context.fillRectangle(this.frame.getX() + this.frame.getWidth() + 1, 0, getContentsWidth() - (this.frame.getX() + this.frame.getWidth() + 1), getContentsHeight());
context.fillRectangle(0, this.frame.getY() + this.frame.getHeight() + 1, getContentsWidth(), getContentsHeight() - (this.frame.getY() + this.frame.getHeight() + 1));
gcim.setLineWidth(1);
this.frame.draw(context);
if (this.dragAndDrop instanceof LifelineHeader) {
LifelineHeader node = (LifelineHeader) this.dragAndDrop;
node.draw(context, this.dragX + this.dragAndDropOffsetX, this.dragY);
}
gc.drawImage(dbuffer, 0, 0, area.width, area.height, 0, 0, area.width, area.height);
gcim.dispose();
dbuffer.dispose();
gc.dispose();
context.dispose();
setHScrollBarIncrement(Math.round(MSCConstants.COLUMN_WIDTH * this.zoomValue));
setVScrollBarIncrement(Math.round(MSCConstants.ROW_HEIGHT * this.zoomValue));
int xRatio = getContentsWidth() / getVisibleWidth();
int yRatio = getContentsHeight() / getVisibleHeight();
if (yRatio > xRatio) {
this.overview.setOverviewSize((int) (getVisibleHeight() * 0.75));
} else {
this.overview.setOverviewSize((int) (getVisibleWidth() * 0.75));
}
}
use of org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader in project titan.EclipsePlug-ins by eclipse.
the class MSCWidget method contentsMouseDownEvent.
@Override
protected void contentsMouseDownEvent(final MouseEvent event) {
this.toolTip.hideToolTip();
if (((this.zoomInMode) || (this.zoomOutMode)) && (event.button == 1)) {
int cx = Math.round(event.x / this.zoomValue);
int cy = Math.round(event.y / this.zoomValue);
if (this.zoomInMode) {
if (this.zoomValue < 64) {
this.zoomValue = this.zoomValue * (float) 1.25;
}
} else {
this.zoomValue = this.zoomValue / (float) 1.25;
}
int x = Math.round(cx * this.zoomValue - (float) getVisibleWidth() / 2);
int y = Math.round(cy * this.zoomValue - (float) getVisibleHeight() / 2);
int width = Math.round(this.frame.getWidth() * this.zoomValue);
int height = Math.round(this.frame.getHeight() * this.zoomValue);
resizeContents(width, height);
setContentsPos(x, y);
redraw();
} else {
this.dragAndDropEnabled = true;
if (this.frame != null) {
int oldSelectedLine = frame.getSelectedLine();
int x = Math.round(event.x / this.zoomValue);
int y = Math.round(event.y / this.zoomValue);
MSCNode node = this.frame.getNodeAt(x, y);
if (event.button == 1 || (node != null)) {
this.currentGraphNode = node;
if (node instanceof LifelineHeader) {
this.dragAndDropOffsetX = node.getX() - x;
}
}
// Header
int selectedLine = y / MSCConstants.ROW_HEIGHT - 1;
this.frame.setSelectedLine(selectedLine);
if (frame.getSelectedLine() != oldSelectedLine) {
fireSelectionChangeEvent();
redraw();
}
}
}
if (this.dragAndDrop == null) {
super.contentsMouseDownEvent(event);
}
}
Aggregations