83 public static MCChartCanvas getFirst(Wrap<? extends Shell> shell) {
84 return getAll(shell).get(0);
85 }
86
87 /**
88 * Returns the first visible {@link MCChartCanvas} object underneath the Mission Control main shell
89 *
90 * @return a {@link MCChartCanvas} object
91 */
92 public static MCChartCanvas getChartCanvas() {
93 return getFirst(getShell());
94 }
95
96 /**
97 * Clicks a specific menu item in the context menu
98 * @param menuItemText
99 * the menu item of interest
100 */
101 @SuppressWarnings("unchecked")
102 public void clickContextMenuItem(String menuItemText) {
103 StringPopupOwner<Shell> contextMenu = control.as(StringPopupOwner.class);
104 contextMenu.setPolicy(StringComparePolicy.SUBSTRING);
105 contextMenu.push(getRelativeClickPoint(), new String[]{menuItemText});
106 }
107
108 /**
109 * Checks the isEnabled value for a menu item in the context menu
110 *
111 * @param menuItemText
112 * the menu item of interest
113 * @return the isEnabled value for the menu item of interest
114 */
115 public boolean isContextMenuItemEnabled(String menuItemText) {
116 return this.isContextMenuItemEnabled(getRelativeClickPoint(), menuItemText);
117 }
118
119 /**
120 * Calculates the click point of the Chart Canvas
121 *
122 * @return the Point of the Chart Canvas
123 */
124 private Point getRelativeClickPoint() {
125 Fetcher<Point> fetcher = new Fetcher<Point>() {
126 @Override
127 public void run() {
128 setOutput(new Point(control.getScreenBounds().x, control.getScreenBounds().y));
129 }
130 };
131 Display.getDefault().syncExec(fetcher);
132 return fetcher.getOutput();
133 }
134 }
|
83 public static MCChartCanvas getFirst(Wrap<? extends Shell> shell) {
84 return getAll(shell).get(0);
85 }
86
87 /**
88 * Returns the first visible {@link MCChartCanvas} object underneath the Mission Control main shell
89 *
90 * @return a {@link MCChartCanvas} object
91 */
92 public static MCChartCanvas getChartCanvas() {
93 return getFirst(getShell());
94 }
95
96 /**
97 * Clicks a specific menu item in the context menu
98 * @param menuItemText
99 * the menu item of interest
100 */
101 @SuppressWarnings("unchecked")
102 public void clickContextMenuItem(String menuItemText) {
103 focusMc();
104 StringPopupOwner<Shell> contextMenu = control.as(StringPopupOwner.class);
105 contextMenu.setPolicy(StringComparePolicy.SUBSTRING);
106 contextMenu.push(getRelativeClickPoint(), new String[]{menuItemText});
107 }
108
109 /**
110 * Checks the isEnabled value for a menu item in the context menu
111 *
112 * @param menuItemText
113 * the menu item of interest
114 * @return the isEnabled value for the menu item of interest
115 */
116 public boolean isContextMenuItemEnabled(String menuItemText) {
117 return this.isContextMenuItemEnabled(getRelativeClickPoint(), menuItemText);
118 }
119
120 /**
121 * Calculates the click point of the Chart Canvas
122 *
123 * @return the Point of the Chart Canvas
124 */
125 private Point getRelativeClickPoint() {
126 Fetcher<Point> fetcher = new Fetcher<Point>() {
127 @Override
128 public void run() {
129 setOutput(new Point(control.getScreenBounds().x / 2, control.getScreenBounds().y / 2));
130 }
131 };
132 Display.getDefault().syncExec(fetcher);
133 return fetcher.getOutput();
134 }
135 }
|