/**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- *
+ * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
import java.text.MessageFormat;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
* @version 1.0
* @author sveyrier
*/
-public class SDWidget extends ScrollView implements SelectionListener, IPropertyChangeListener, DisposeListener, ITimeCompressionListener {
+public class SDWidget extends ScrollView implements SelectionListener,
+ IPropertyChangeListener, DisposeListener, ITimeCompressionListener {
// ------------------------------------------------------------------------
// Attributes
for (int i = 0; i < list.size(); i++) {
if (!fSelectedNodeList.contains(list.get(i))) {
fSelectedNodeList.add(list.get(i));
- ((GraphNode) list.get(i)).setSelected(true);
+ list.get(i).setSelected(true);
}
}
StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
public void removeSelection(List<GraphNode> list) {
fSelectedNodeList.removeAll(list);
for (int i = 0; i < list.size(); i++) {
- ((GraphNode) list.get(i)).setSelected(false);
- ((GraphNode) list.get(i)).setFocused(false);
+ list.get(i).setSelected(false);
+ list.get(i).setFocused(false);
}
StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
fSelProvider.setSelection(selection);
*/
public void clearSelection() {
for (int i = 0; i < fSelectedNodeList.size(); i++) {
- ((GraphNode) fSelectedNodeList.get(i)).setSelected(false);
- ((GraphNode) fSelectedNodeList.get(i)).setFocused(false);
+ fSelectedNodeList.get(i).setSelected(false);
+ fSelectedNodeList.get(i).setFocused(false);
}
fCurrentGraphNode = null;
fSelectedNodeList.clear();
/**
* Sets the zoom in mode.
*
- * @param The mode value to set.
+ * @param value
+ * The mode value to set.
*/
public void setZoomInMode(boolean value) {
if (value) {
/**
* Sets the zoom out mode.
*
- * @param The mode value to set.
+ * @param value
+ * The mode value to set.
*/
public void setZoomOutMode(boolean value) {
if (value) {
fOverView = new Image(getDisplay(), rect.width, rect.height);
GC gcim = new GC(fOverView);
NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
fFrame.draw(context);
setContentsPos(backX, backY);
gcim.dispose();
/**
* Sets the focus on given graph node (current node).
*
- * @param the graph node to focus on.
+ * @param node
+ * The graph node to focus on.
*/
public void setFocus(GraphNode node) {
if (node == null) {
// Set the metrics to use for lifeline text and message text
// using the Graphical Context
- Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+ Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
- int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
- int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
- int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
- int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
+ int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+ int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+ int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+ int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
int messageFontHeight = 0;
if (syncMessFontH > syncMessRetFontH) {
messageFontHeight = asyncMessRetFontH;
}
Metrics.setMessageFontHeight(messageFontHeight);
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
int width = Math.round((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
int height = Math.round((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
/**
* Method to print page ranges.
*
- * @param i The start page
- * @param j The end page
- * @param pd The sequence diagram print dialog
- * @param context The graphical context
- * @param pageNum int the current page
+ * @param i
+ * The start page
+ * @param j
+ * The end page
+ * @param pd
+ * The sequence diagram print dialog
+ * @param context
+ * The graphical context
+ * @param pageNum
+ * The current page
*/
public void printPage(int i, int j, SDPrintDialogUI pd, NGC context, int pageNum) {
fIsPrinting = false;
fFrame.draw(context);
fZoomValue = pageNumFontZoom;
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
String currentPageNum = String.valueOf(pageNum);
int ii = context.textExtent(currentPageNum);
int jj = context.getCurrentFontHeight();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
}
return false;
*/
protected String getPostfixForTooltip(boolean accessible) {
StringBuffer postfix = new StringBuffer();
-// String postfix = "";//$NON-NLS-1$
// Determine if the tooltip must show the time difference between the current mouse position and
// the last selected graphNode
if ((fCurrentGraphNode != null) &&
postfix.append(SDMessages._138);
postfix.append(" "); //$NON-NLS-1$
-// postfix = " -> " + fCurrentGraphNode.getName() + "\n" + SDMessages._138 + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
//double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
ITmfTimestamp firstTime = ((ITimeRange) fCurrentGraphNode).getEndTime();
ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();
- TmfTimestamp delta = (TmfTimestamp) lastTime.getDelta(firstTime);
+ ITmfTimestamp delta = lastTime.getDelta(firstTime);
postfix.append(delta.toString());
-// postfix += delta.toString();
} else {
if ((fToolTipNode instanceof ITimeRange) && ((ITimeRange) fToolTipNode).hasTimeInfo()) {
postfix.append("\n"); //$NON-NLS-1$
-// postfix = "\n";//$NON-NLS-1$
ITmfTimestamp firstTime = ((ITimeRange) fToolTipNode).getStartTime();
ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();
postfix.append("end: "); //$NON-NLS-1$
postfix.append(lastTime.toString());
postfix.append("\n"); //$NON-NLS-1$
-// postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
-// postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
postfix.append(firstTime.toString());
-// postfix += firstTime.toString();
}
}
else if (lastTime != null) {
postfix.append(lastTime.toString());
-// postfix += lastTime.toString();
}
}
}
// Set the metrics to use for lifeline text and message text
// using the Graphical Context
- Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+ Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
- int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
- int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
- int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
- int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
+ int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+ int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+ int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+ int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
int messageFontHeight = 0;
if (syncMessFontH > syncMessRetFontH) {
messageFontHeight = asyncMessRetFontH;
}
Metrics.setMessageFontHeight(messageFontHeight);
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
int width = (int) ((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
int height = (int) ((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
fFrame.draw(context);
if (fDragAndDrop != null) {
- Lifeline node = (Lifeline) fDragAndDrop;
+ Lifeline node = fDragAndDrop;
boolean isSelected = fDragAndDrop.isSelected();
boolean hasFocus = fDragAndDrop.hasFocus();
node.setSelected(false);
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
return false;
}
int rx = Math.round(node.getX() * fZoomValue);
if (rx <= event.x && Math.round(rx + (node.getWidth() * fZoomValue)) >= event.x) {
if ((fCollapseProvider != null) && (fDragAndDrop != node)) {
- fCollapseProvider.collapseTwoLifelines((Lifeline) fDragAndDrop, node);
+ fCollapseProvider.collapseTwoLifelines(fDragAndDrop, node);
}
} else if (rx < event.x) {
- fFrame.insertLifelineAfter((Lifeline) fDragAndDrop, node);
+ fFrame.insertLifelineAfter(fDragAndDrop, node);
if (node.getIndex() < fFrame.lifeLinesCount()) {
- Lifeline temp[] = { (Lifeline) fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
+ Lifeline temp[] = { fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
fReorderList.add(temp);
} else {
- Lifeline temp[] = { (Lifeline) fDragAndDrop, null };
+ Lifeline temp[] = { fDragAndDrop, null };
fReorderList.add(temp);
}
} else {
- fFrame.insertLifelineBefore((Lifeline) fDragAndDrop, node);
- Lifeline temp[] = { (Lifeline) fDragAndDrop, node };
+ fFrame.insertLifelineBefore(fDragAndDrop, node);
+ Lifeline temp[] = { fDragAndDrop, node };
fReorderList.add(temp);
}
}
gc.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
gc.dispose();
return;
- } else {
-// Frame.setUserPref(SDViewPref.getInstance());
- SDViewPref.getInstance();
}
+ // Frame.setUserPref(SDViewPref.getInstance());
+ SDViewPref.getInstance();
Rectangle area = getClientArea();
Image dbuffer = getDrawBuffer();
fOverView = new Image(getDisplay(), r.width, r.height);
GC gcim = new GC(fOverView);
NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
fFrame.draw(context);
setContentsPos(backX, backY);
gcim.dispose();