Java Code Examples for org.eclipse.ui.PlatformUI#createAndRunWorkbench()

The following examples show how to use org.eclipse.ui.PlatformUI#createAndRunWorkbench() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Application.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object start ( final IApplicationContext context ) throws Exception
{
    Display display = PlatformUI.createDisplay ();
    try
    {
        int returnCode = PlatformUI.createAndRunWorkbench ( display, new ApplicationWorkbenchAdvisor () );
        if ( returnCode == PlatformUI.RETURN_RESTART )
        {
            return IApplication.EXIT_RESTART;
        }
        else
        {
            return IApplication.EXIT_OK;
        }
    }
    finally
    {
        display.dispose ();
    }

}
 
Example 2
Source File: Application.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
public Object start(IApplicationContext context) {

		Display display = PlatformUI.createDisplay();

		display.asyncExec(new Runnable() {
			public void run() {
				launchOrionApplication();
				new OSGiConsoleFactory().openConsole();
			}
		});
		try {
			int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
			if (returnCode == PlatformUI.RETURN_RESTART) {
				return IApplication.EXIT_RESTART;
			}
			return IApplication.EXIT_OK;
		} finally {
			display.dispose();
		}
	}
 
Example 3
Source File: GWTCodeFormatterApplication.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void startWorkbench() {
  PlatformUI.createAndRunWorkbench(PlatformUI.createDisplay(),
      new WorkbenchAdvisor() {
        @Override
        public String getInitialWindowPerspectiveId() {
          return null;
        }

        @Override
        public void postStartup() {
          // Kill it when it opens so that the thread is unstuck.
          Workbench.getInstance().close();
        }

      });
}
 
Example 4
Source File: RcpApplication.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Object start(final IApplicationContext context) throws Exception {
	Object result = null;
	Display display = PlatformUI.createDisplay();
	try {
		final int returnCode = PlatformUI.createAndRunWorkbench(display,
				new RcpWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			result = IApplication.EXIT_RESTART;
		} else {
			result = IApplication.EXIT_OK;
		}
	} finally {
		display.dispose();
	}
	return result;
}
 
Example 5
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		PreferenceUtil.initProductEdition();

		deleteErrorMemoryInfo();

		initSystemLan();
		PreferenceUtil.checkCleanValue();
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 6
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		PreferenceUtil.initProductEdition();
		if (!PreferenceUtil.checkEdition()) {
			MessageDialog.openInformation(display.getActiveShell(), Messages.getString("dialog.AboutDialog.msgTitle"),
					Messages.getString("dialog.AboutDialog.msg"));
			return IApplication.EXIT_OK;
		}
		initSystemLan();
		SystemResourceUtil.beforeload();
		PreferenceUtil.checkCleanValue();
		deleteErrorMemoryFile();
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 7
Source File: Application.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
 */
@Override
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}

}
 
Example 8
Source File: ExamplesApplication.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 9
Source File: BonitaStudioApplication.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Object createAndRunWorkbench(final Display display) {
    try {
        final int returnCode = PlatformUI.createAndRunWorkbench(display, createWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART) {
            return IApplication.EXIT_RESTART;
        }
        return IApplication.EXIT_OK;
    } finally {
        display.dispose();
    }
}
 
Example 10
Source File: Application.java    From jbt with Apache License 2.0 5 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();

	/*
	 * Before doing anything at all, standard nodes must be loaded. If they
	 * cannot be loaded, the application will not start.
	 */
	try {
		NodesLoader.loadStandardNodes();
		ApplicationIcons.loadIcons();
	} catch (Exception e) {
		StandardDialogs
				.exceptionDialog(
						"Could not start application",
						"There were errors while loading the set of standard nodes",
						e);
		return IApplication.EXIT_OK;
	}

	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		/* Dispose loaded icons. */
		ApplicationIcons.disposeIcons();
		display.dispose();
	}

}
 
Example 11
Source File: Application.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
  Display display = PlatformUI.createDisplay();

  try {
    int returnCode = PlatformUI.createAndRunWorkbench(
        display, new ApplicationWorkbenchAdvisor());
    if (returnCode == PlatformUI.RETURN_RESTART) {
      return IApplication.EXIT_RESTART;
    }
    return IApplication.EXIT_OK;
  } finally {
    display.dispose();
  }
}
 
Example 12
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public int createUI() {
   final Display display = PlatformUI.createDisplay();
   
   UICallBack.activate(String.valueOf(display.hashCode()));
   RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
	
	public void beforeDestroy(SessionStoreEvent event) {
		UICallBack.deactivate(String.valueOf(display.hashCode()));
	}
});
   
   WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
   return PlatformUI.createAndRunWorkbench( display, advisor );
 }
 
Example 13
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 14
Source File: Application.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 15
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor();

	Display display = PlatformUI.createDisplay();
	display.addListener(SWT.OpenDocument, openDocProcessor);

	try {
		IProduct product = Platform.getProduct();
		String id = product.getId();
		String hsVersion = "";
		if (id.equals("net.heartsome.cat.te.tmx_editor_product")) {
			hsVersion = "F";
		}
		System.getProperties().put("TSVersion", "88");
		System.getProperties().put("TSEdition", hsVersion);

		String versionDate = System.getProperty("date", "");
		String version = System.getProperty("version", "");
		System.getProperties().put("TSVersionDate", version + "." + versionDate);
		checkCleanValue();

		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor(openDocProcessor));
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}

}
 
Example 16
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public int createUI() {
   final Display display = PlatformUI.createDisplay();
   
   UICallBack.activate(String.valueOf(display.hashCode()));
   RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener() {
	
	public void beforeDestroy(SessionStoreEvent event) {
		UICallBack.deactivate(String.valueOf(display.hashCode()));
	}
});
   
   WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
   return PlatformUI.createAndRunWorkbench( display, advisor );
 }
 
Example 17
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 18
Source File: Application.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
    Display display = PlatformUI.createDisplay();
    try {
        // fetch the Location that we will be modifying
        fInstanceLoc = Platform.getInstanceLocation();

        // -data @noDefault in <applName>.ini allows us to set the workspace here.
        // If the user wants to change the location then he has to change
        // @noDefault to a specific location or remove -data @noDefault for
        // default location
        if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) {
            File workspaceRoot = new File(TracingRcpPlugin.getWorkspaceRoot());

            if (!workspaceRoot.exists()) {
                MessageDialog.openError(display.getActiveShell(),
                        Messages.Application_WorkspaceCreationError,
                        MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() }));
                return IApplication.EXIT_OK;
            }

            if (!workspaceRoot.canWrite()) {
                MessageDialog.openError(display.getActiveShell(),
                        Messages.Application_WorkspaceCreationError,
                        MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() }));
                return IApplication.EXIT_OK;
            }

            String workspace = TracingRcpPlugin.getWorkspaceRoot() + File.separator + TracingRcpPlugin.WORKSPACE_NAME;
            // set location to workspace
            fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$
        }

        /*
         * Execute the early command line options.
         */
        try {
            CliCommandLine cmdLine = CliParserManager.getInstance().parse(Platform.getCommandLineArgs());
            TracingRcpPlugin.getDefault().setCommandLine(cmdLine);
            if (cmdLine != null && CliParserManager.applicationStartup(cmdLine)) {
                return IApplication.EXIT_OK;
            }
        } catch (CliParserException e) {
            TracingRcpPlugin.getDefault().logError("Error parsing command line arguments", e); //$NON-NLS-1$
            return IApplication.EXIT_OK;
        }

        if (!fInstanceLoc.lock()) {
            MessageDialog.openError(display.getActiveShell(),
                    Messages.Application_WorkspaceCreationError,
                    MessageFormat.format(Messages.Application_WorkspaceInUseError, new Object[] { fInstanceLoc.getURL().getPath() }));
            return IApplication.EXIT_OK;
        }

        int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART) {
            return IApplication.EXIT_RESTART;
        }
        return IApplication.EXIT_OK;
    } finally {
        display.dispose();
    }
}
 
Example 19
Source File: Application.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object start(final IApplicationContext context) throws Exception {

	Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
		if ( e instanceof OutOfMemoryError ) {
			final boolean close = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Out of memory",
				"GAMA is out of memory and will likely crash. Do you want to close now ?");
			if ( close ) {
				this.stop();
			}
			e.printStackTrace();
		}

	});
	Display.setAppName("Gama Platform");
	Display.setAppVersion("1.8.1");
	// DEBUG.OUT(System.getProperties());
	createProcessor();
	final Object check = checkWorkspace();
	if ( EXIT_OK.equals(check) ) { return EXIT_OK; }
	// if ( check == EXIT_RESTART ) {
	// ClearWorkspace(true);
	// No need to restart : the value will be checked later
	// return EXIT_RESTART;
	// }
	Display display = null;
	try {
		display = Display.getDefault();
		checkWorkbenchXMI();
		// final String splash = getProperty("org.eclipse.equinox.launcher.splash.location");
		// if ( splash != null ) {
		// setProperty("org.eclipse.equinox.launcher.splash.location", splash.replace("bmp", "png"));
		// }
		final int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if ( returnCode == PlatformUI.RETURN_RESTART ) { return IApplication.EXIT_RESTART; }
		return IApplication.EXIT_OK;
	} finally {
		if ( display != null ) {
			display.dispose();
		}
		final Location instanceLoc = Platform.getInstanceLocation();
		if ( instanceLoc != null ) {
			instanceLoc.release();
		}
	}

}
 
Example 20
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int createUI() {
	Display display = PlatformUI.createDisplay();
	WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
	return PlatformUI.createAndRunWorkbench(display, advisor);
}