Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/Activator.java

Issue 9703096: Remove Element.getNode() method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes for review comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui_test/plugin.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/Activator.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/Activator.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/Activator.java
new file mode 100644
index 0000000000000000000000000000000000000000..7df3382e0dff5b5bbc2a8719015e99639361af54
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/Activator.java
@@ -0,0 +1,121 @@
+package com.google.dart.tools.ui;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class Activator extends AbstractUIPlugin implements IStartup {
+
+ public Activator() {
+ }
+
+ @Override
+ public void earlyStartup() {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ configureEclipseWindowLocation();
+ closeAllEditors();
+ closeAllViews();
+ }
+ });
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // Workbench
+ //
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Ensures that Eclipse main window is in top-right corner of screen.
+ */
+ private void configureEclipseWindowLocation() {
+ int x = 450;
+ int y = 0;
+ Shell shell = getActiveWorkbenchWindow().getShell();
+ Point shellLocation = shell.getLocation();
+ if (shellLocation.x != x || shellLocation.y != y) {
+ Rectangle clientArea = Display.getDefault().getClientArea();
+ shell.setBounds(x, y, clientArea.width - x, clientArea.height - 350);
+ waitEventLoop(100, 10);
+ }
+ }
+
+ private static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ }
+
+ /**
+ * Closes all {@link IViewPart}s.
+ */
+ public static void closeAllViews() {
+ // run event loop to allow any async's be executed
+ while (Display.getCurrent().readAndDispatch()) {
+ // do nothing
+ }
+ // do close
+ IWorkbenchPage activePage = getActiveWorkbenchWindow().getActivePage();
+ IViewReference[] viewReferences = activePage.getViewReferences();
+ if (viewReferences.length != 0) {
+ for (IViewReference viewReference : viewReferences) {
+ activePage.hideView(viewReference);
+ }
+ waitEventLoop(100);
+ }
+ }
+
+ /**
+ * Closes all editors.
+ */
+ public static void closeAllEditors() {
+ // run event loop to allow any async's be executed
+ while (Display.getCurrent().readAndDispatch()) {
+ // do nothing
+ }
+ // close all editors
+ {
+ IWorkbenchPage activePage = getActiveWorkbenchWindow().getActivePage();
+ activePage.closeAllEditors(false);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // UI
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Waits given number of milliseconds and runs events loop every 1 millisecond. At least one
+ * events loop will be executed.
+ */
+ public static void waitEventLoop(int time) {
+ waitEventLoop(time, 0);
+ }
+
+ /**
+ * Waits given number of milliseconds and runs events loop every <code>sleepMillis</code>
+ * milliseconds. At least one events loop will be executed.
+ */
+ public static void waitEventLoop(int time, long sleepMillis) {
+ long start = System.currentTimeMillis();
+ do {
+ try {
+ Thread.sleep(sleepMillis);
+ } catch (Throwable e) {
+ }
+ while (Display.getCurrent().readAndDispatch()) {
+ // do nothing
+ }
+ } while (System.currentTimeMillis() - start < time);
+ }
+
+}
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui_test/plugin.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698