/**********************************************************************
- * 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
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
import java.text.MessageFormat;
import java.util.Timer;
import java.util.TimerTask;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.contexts.IContextIds;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelectionProvider;
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.internal.tmf.ui.TmfUiPlugin;
-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;
* <p>
* This class implements sequence diagram widget used in the sequence diagram view.
* </p>
- *
- * @version 1.0
+ *
+ * @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
*/
protected Image fOverView = null;
/**
- * The zoom in menu item.
+ * The zoom in menu item.
*/
protected MenuItem fZoomIn = null;
/**
- * The zoom out menu item.
+ * The zoom out menu item.
*/
protected MenuItem fZoomOut = null;
/**
- * The sequence diagram selection provider.
+ * The sequence diagram selection provider.
*/
protected SDWidgetSelectionProvider fSelProvider = null;
/**
- * The current zoom value.
+ * The current zoom value.
*/
public float fZoomValue = 1;
/**
- * The current zoomInMode (true for zoom in).
+ * The current zoomInMode (true for zoom in).
*/
protected boolean fZoomInMode = false;
/**
- * The current zoomOutMode (true for zoom out).
+ * The current zoomOutMode (true for zoom out).
*/
protected boolean fZoomOutMode = false;
/**
- * The current list of selected graph nodes.
+ * The current list of selected graph nodes.
*/
protected List<GraphNode> fSelectedNodeList = null;
/**
- * Flag whether ctrl button is selected or not.
+ * Flag whether ctrl button is selected or not.
*/
protected boolean fCtrlSelection = false;
/**
- * A reference to the view site.
+ * A reference to the view site.
*/
protected ViewPart fSite = null;
/**
- * The current graph node (the last selected one).
+ * The current graph node (the last selected one).
*/
public GraphNode fCurrentGraphNode = null;
/**
- * The first graph node in list (multiple selection).
+ * The first graph node in list (multiple selection).
*/
public GraphNode fListStart = null;
/**
- * The previous graph node (multiple selection).
+ * The previous graph node (multiple selection).
*/
public List<GraphNode> fPrevList = null;
/**
- * The time compression bar.
+ * The time compression bar.
*/
protected TimeCompressionBar fTimeBar = null;
/**
- * The current diagram tool tip.
+ * The current diagram tool tip.
*/
protected DiagramToolTip fToolTip = null;
/**
*/
protected Lifeline fDragAndDrop = null;
/**
- * The number of focused widgets.
+ * The number of focused widgets.
*/
protected int fFocusedWidget = -1;
/**
*/
protected int fPrinterX = 0;
/**
- * Flag whether drag and drop is enabled or not.
+ * Flag whether drag and drop is enabled or not.
*/
protected boolean fIsDragAndDrop = false;
/**
*/
protected Printer fPrinter = null;
/**
- * Flag whether shift was selected or not.
+ * Flag whether shift was selected or not.
*/
protected boolean fShiftSelection = false;
/**
- * The scroll tooltip.
+ * The scroll tooltip.
*/
protected DiagramToolTip fScrollToolTip = null;
- /**
- * Timer for auto_scroll feature
+ /**
+ * Timer for auto_scroll feature
*/
protected AutoScroll fLocalAutoScroll = null;
/**
- * TimerTask for auto_scroll feature !=null when auto scroll is running
+ * TimerTask for auto_scroll feature !=null when auto scroll is running
*/
protected Timer fLocalAutoScrollTimer = null;
e.detail |= ACC.STATE_FOCUSED;
} else {
e.detail |= ACC.STATE_SELECTABLE;
- if (e.childID == fFocusedWidget)
+ if (e.childID == fFocusedWidget) {
e.detail |= ACC.STATE_FOCUSED | ACC.STATE_SELECTED | ACC.STATE_CHECKED;
+ }
}
}
});
fInsertionCartet = new Caret((Canvas) getViewControl(), SWT.NONE);
fInsertionCartet.setVisible(false);
- fCollapaseCaretImg = TmfUiPlugin.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ);
- fArrowUpCaretImg = TmfUiPlugin.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ);
+ fCollapaseCaretImg = Activator.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ);
+ fArrowUpCaretImg = Activator.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ);
fReorderList = new ArrayList<Lifeline[]>();
getViewControl().addTraverseListener(new LocalTraverseListener());
}
});
}
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/**
* Sets the time compression bar.
- *
+ *
* @param bar The time compression bar to set
*/
public void setTimeBar(TimeCompressionBar bar) {
fTimeBar.addTimeCompressionListener(this);
}
}
-
+
/**
* Resize the contents to insure the frame fit into the view
- *
+ *
* @param frame the frame which will be drawn in the view
*/
public void resizeContents(Frame frame) {
/**
* The frame to render (the sequence diagram)
- *
+ *
* @param theFrame the frame to display
* @param resetPosition boolean
*/
/**
* Returns the current Frame (the sequence diagram container)
- *
- * @return the frame
+ *
+ * @return the frame
*/
public Frame getFrame() {
return fFrame;
/**
* Returns the selection provider for the current sequence diagram
- *
- * @return the selection provider
+ *
+ * @return the selection provider
*/
public ISelectionProvider getSelectionProvider() {
return fSelProvider;
}
-
+
/**
* Returns a list of selected graph nodes.
- *
+ *
* @return a list of selected graph nodes.
*/
public List<GraphNode> getSelection() {
/**
* Adds a graph node to the selected nodes list.
- *
+ *
* @param node A graph node
*/
public void addSelection(GraphNode node) {
/**
* Adds a list of node to the selected nodes list.
- *
+ *
* @param list of graph nodes
*/
public void addSelection(List<GraphNode> list) {
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);
/**
* Removes a node from the selected nodes list.
- *
+ *
* @param node to remove
*/
public void removeSelection(GraphNode node) {
/**
* Removes a list of graph nodes from the selected nodes list.
- *
+ *
* @param list of nodes to remove.
*/
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 view part.
- *
+ *
* @param viewSite The view part to set
*/
public void setSite(ViewPart viewSite) {
/**
* Returns the GraphNode overView the mouse if any
- *
- * @return the current graph node
+ *
+ * @return the current graph node
* */
public GraphNode getMouseOverNode() {
return fCurrentGraphNode;
}
-
+
/**
* 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) {
/**
* Moves the Sequence diagram to ensure the given node is visible and draw it selected
- *
+ *
* @param node the GraphNode to move to
*/
public void moveTo(GraphNode node) {
/**
* Moves the Sequence diagram to ensure the given node is visible
- *
+ *
* @param node the GraphNode to move to
*/
public void ensureVisible(GraphNode node) {
/**
* Returns teh printer reference.
- *
+ *
* @return the printer reference
*/
public Printer getPrinter() {
/**
* Returns whether the widget is used for printing or not.
- *
+ *
* @return whether the widget is used for printing or not
*/
public boolean isPrinting() {
/**
* Gets the overview image.
- *
+ *
* @param rect Rectangle to include overview.
* @return the overview image
*/
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();
fZoomValue = oldzoom;
return fOverView;
}
-
+
/**
* Resets the zoom factor.
*/
/**
* Enable or disable the lifeline reodering using Drag and Drop
- *
+ *
* @param mode - true to enable false otherwise
*/
public void setReorderMode(boolean mode) {
/**
* Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
* element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
- *
- * @return - the re-odered sequence
+ *
+ * @return - the re-odered sequence
*/
public List<Lifeline[]> getLifelineReoderList() {
return fReorderList;
/**
* 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) {
/**
* Returns the graph node focused on.
- *
+ *
* @return the current graph node
*/
public GraphNode getFocusNode() {
traverseLeft();
}
GraphNode node = null;
-
+
if (selectedNode instanceof BaseMessage) {
if (((BaseMessage) selectedNode).getStartLifeline() != null) {
node = fFrame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
/**
* Method to print UI.
- *
+ *
* @param sdPrintDialog the sequence diagram printer dialog.
*/
public void printUI(SDPrintDialogUI sdPrintDialog) {
if ((data == null) || (fFrame == null)) {
return;
}
-
+
fPrinter = new Printer(data);
-
+
String jobName = MessageFormat.format(SDMessages._116, new Object[] { String.valueOf(fSite.getContentDescription()), String.valueOf(fFrame.getName()) });
fPrinter.startJob(jobName);
-
+
GC gc = new GC(fPrinter);
// Frame.setUserPref(SDViewPref.getInstance());
// 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);
return;
}
} catch (Exception e) {
- TmfUiPlugin.getDefault().logError("Error creating image", e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$
return;
}
printUI(sdPrinter.getDialogUI());
/**
* Method to print a page.
- *
+ *
* @param pageNum The page number
* @param pd The sequence diagram print dialog
* @param context The graphical context
/**
* 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();
fIsPrinting = false;
fZoomValue = lastZoom;
}
-
+
/**
* Sets the collapse provider.
- *
+ *
* @param provider The collapse provider to set
*/
protected void setCollapseProvider(ISDCollapseProvider provider) {
fCollapseProvider = provider;
}
-
+
/**
* Checks for focus of children.
- *
+ *
* @param children Control to check
* @return true if child is on focus else false
*/
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
}
return false;
/**
* A post action for a tooltip (before displaying).
- *
+ *
* @param accessible true if accessible else false
* @return the tooltip text.
*/
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) &&
- (fCurrentGraphNode instanceof ITimeRange) &&
- (fToolTipNode instanceof ITimeRange) &&
- (fCurrentGraphNode != fToolTipNode) &&
- ((ITimeRange) fToolTipNode).hasTimeInfo() &&
+ if ((fCurrentGraphNode != null) &&
+ (fCurrentGraphNode instanceof ITimeRange) &&
+ (fToolTipNode instanceof ITimeRange) &&
+ (fCurrentGraphNode != fToolTipNode) &&
+ ((ITimeRange) fToolTipNode).hasTimeInfo() &&
((ITimeRange) fCurrentGraphNode).hasTimeInfo()) {
postfix.append(" -> "); //$NON-NLS-1$
postfix.append(fCurrentGraphNode.getName());
postfix.append("\n"); //$NON-NLS-1$
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();
-
+ ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();
+
if (firstTime != null) {
if (lastTime != null && firstTime.compareTo(lastTime, true) != 0) {
postfix.append("start: "); //$NON-NLS-1$
postfix.append(firstTime.toString());
postfix.append("\n"); //$NON-NLS-1$
- postfix.append("end: "); //$NON-NLS-1$
+ 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();
}
}
}
/**
* Sets a new focused widget.
- *
+ *
* @param newFocusShape A new focus shape.
*/
protected void setFocus(int newFocusShape) {
/**
* Highlight the given GraphNode<br>
* The GraphNode is then displayed using the system default selection color
- *
+ *
* @param node the GraphNode to highlight
*/
protected void performSelection(GraphNode node) {
/**
* Returns a draw buffer image.
- *
- * @return a Image containing the draw buffer.
+ *
+ * @return a Image containing the draw buffer.
*/
protected Image getDrawBuffer() {
try {
dbuffer = new Image(getDisplay(), area.width, area.height);
} catch (Exception e) {
- TmfUiPlugin.getDefault().logError("Error creating image", e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$
}
gcim = new GC(dbuffer);
// 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);
context.dispose();
return dbuffer;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
if (event.character == ' ') {
performSelection(fCurrentGraphNode);
- if (!fShiftSelection)
+ if (!fShiftSelection) {
fListStart = fCurrentGraphNode;
+ }
}
if ((fShiftSelection) && (prevNode != getFocusNode())) {
addSelection(fFrame.getNodeList(fListStart, getFocusNode()));
if (getFocusNode() instanceof Lifeline) {
ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
- } else {
+ } else {
ensureVisible(getFocusNode());
}
} else if ((!fCtrlSelection) && (!fShiftSelection)) {
@Override
protected void keyReleasedEvent(KeyEvent event) {
setFocus(-1);
- if (event.keyCode == SWT.CTRL)
+ if (event.keyCode == SWT.CTRL) {
fCtrlSelection = false;
- if (event.keyCode == SWT.SHIFT)
+ }
+ if (event.keyCode == SWT.SHIFT) {
fShiftSelection = false;
+ }
super.keyReleasedEvent(event);
setFocus(1);
}
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
return false;
}
public boolean setContentsPos(int x, int y) {
int localX = x;
int localY = y;
-
+
if (localX < 0) {
localX = 0;
}
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);
}
}
fIsDragAndDrop = (event.button == 1);
}
-
- /**
- * TimerTask for auto scroll feature.
+
+ /**
+ * TimerTask for auto scroll feature.
*/
protected static class AutoScroll extends TimerTask {
/**
/**
* Constructor for AutoScroll.
- * @param sv sequence diagram widget reference
+ * @param sv sequence diagram widget reference
* @param dx delta x
* @param dy delta y
*/
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
- if (fSdWidget.isDisposed())
+ if (fSdWidget.isDisposed()) {
return;
+ }
fSdWidget.fDragX += fDeltaX;
fSdWidget.fDragY += fDeltaY;
fSdWidget.scrollBy(fDeltaX, fDeltaY);
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();
try {
gc.drawImage(dbuffer, 0, 0, area.width, area.height, 0, 0, area.width, area.height);
} catch (Exception e) {
- TmfUiPlugin.getDefault().logError("Error drawin content", e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error drawin content", e); //$NON-NLS-1$
}
dbuffer.dispose();
setHScrollBarIncrement(Math.round(SDViewPref.getInstance().getLifelineWidth() / (float) 2 * fZoomValue));
/*
* Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
- *
+ *
* (non-Javadoc)
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
{
// Prepare the overview to be reused for the new
// settings (especially the colors)
- if (fOverView != null)
+ if (fOverView != null) {
fOverView.dispose();
+ }
fOverView = null;
redraw();
}
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();
}
return super.getContentsY();
}
-
+
/**
* Traverse Listener implementation.
*/