下面列出了怎么用org.eclipse.ui.intro.IIntroManager的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void starting(Description d) {
name = d.getMethodName();
assertEmptyIndex();
IProject[] projects = IResourcesSetupUtil.root().getProjects();
if (projects.length != 0) {
Assert.assertEquals(1, projects.length);
Assert.assertEquals("RemoteSystemsTempFiles", projects[0].getName());
}
if (PlatformUI.isWorkbenchRunning()) {
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
if (introManager.getIntro() != null) {
Display.getDefault().asyncExec(() -> introManager.closeIntro(introManager.getIntro()));
}
}
}
@Override
public void run(IIntroSite site, Properties params) {
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IProject project = createProject(monitor);
createExample(project);
}
};
try {
PlatformUI.getWorkbench().getProgressService().run(true, true, op);
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart part = introManager.getIntro();
introManager.closeIntro(part);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("hello-world/greeter.sol")));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void showIntroPart(IWorkbenchPage page) {
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
//colse intro to reload content if already opened
hideIntroPart();
final IntroModelRoot model = IntroPlugin.getDefault().getIntroModelRoot();
if (model != null
&& introManager.getIntro() != null
&& ((CustomizableIntroPart) introManager.getIntro()).getControl() != null) {
model.getPresentation().navigateHome();
}
BonitaPerspectivesUtils.switchToPerspective("org.bonitasoft.studio.perspective.welcomePage");
page.setEditorAreaVisible(false);
introManager.showIntro(
page.getWorkbenchWindow(),
false);
page.setPartState(page.findViewReference("org.bonitasoft.studio.application.project.explorer"),
IWorkbenchPage.STATE_RESTORED);
}
@Override
public void run() {
// Close the Eclipse welcome page
IIntroManager manager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart introPart = manager.getIntro();
if (introPart != null) {
manager.closeIntro(introPart);
}
// Open the J2EE perspective
try {
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.showPerspective("org.eclipse.jst.j2ee.J2EEPerspective", workbench.getActiveWorkbenchWindow());
} catch (Exception e) {
Logger.logError("An error occurred trying to open the J2EE perspective", e);
}
// Open the Codewind welcome page
IEditorPart part = OpenWelcomePageAction.openWelcomePage();
// Open the Codewind Explorer view
ViewHelper.openCodewindExplorerViewNoExec();
// Make the welcome page the focus
if (part != null) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
page.activate(part);
}
}
}
}
protected static void closeWelcomePage() throws InterruptedException {
IIntroManager introManager = getWorkbench().getIntroManager();
IIntroPart intro = introManager.getIntro();
if (intro != null) {
introManager.closeIntro(intro);
}
}
@Override
protected void starting(Description d) {
name = d.getMethodName();
assertEmptyIndex();
Assert.assertEquals(0, IResourcesSetupUtil.root().getProjects().length);
if (PlatformUI.isWorkbenchRunning()) {
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
if (introManager.getIntro() != null) {
Display.getDefault().asyncExec(()->introManager.closeIntro(introManager.getIntro()));
}
}
}
/** Close the welcome page.
*/
protected static void closeWelcomePage() {
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
if (introManager != null) {
final IIntroPart intro = introManager.getIntro();
if (intro != null) {
introManager.closeIntro(intro);
}
}
}
private static void openSarosView() {
IIntroManager m = PlatformUI.getWorkbench().getIntroManager();
IIntroPart i = m.getIntro();
/*
* if there is a welcome screen, do not open the SarosView
* because it would be maximized and hiding the workbench window.
*/
if (i == null) ViewUtils.openSarosView();
}
public static boolean isIntroOpen() {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
final IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
for (final IViewReference vr : activePage.getViewReferences()) {
if (vr.getId().equals(INTROVIEW_ID)) {
return true;
}
}
final IWorkbenchPart part = activePage.getActivePart();
if (part != null) {
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
if (introManager != null) {
if (introManager.getIntro() != null) {
return true;
} else {
final IViewPart view = activePage.findView(INTROVIEW_ID);
return view != null;
}
}
}
}
}
return false;
}
@Override
public void earlyStartup() {
Job job = new Job(Activator.PLUGIN_ID + " startup") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Initializing " + Activator.PLUGIN_ID, 2);
// If we were launched from Ghidra, close the Eclipse welcome screen if present,
// and make it so it never shows up again.
if (Activator.getDefault().isLaunchedByGhidra()) {
IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart intro = introManager.getIntro();
if (intro != null) {
Display.getDefault().syncExec(() -> introManager.closeIntro(intro));
}
PlatformUI.getPreferenceStore().setValue(
IWorkbenchPreferenceConstants.SHOW_INTRO, false);
}
// Ask the user (only once) for consent before listening on any ports
boolean firstTimeConsent = false;
if (!GhidraRootPreferences.requestedConsentToOpenPorts()) {
firstTimeConsent = EclipseMessageUtils.showQuestionDialog(
Activator.PLUGIN_ID + "User Consent",
Activator.PLUGIN_ID + " opens ports to enable communication with Ghidra " +
"for various features such as initiating script editing and symbol " +
"lookup from Ghidra.\n\nDo you consent to the ports being opened?\n\n" +
"If you do not consent now, you can enable these features at any " +
"time in the " + Activator.PLUGIN_ID + " preferences.");
GhidraRootPreferences.setOpenPortConsentRequest(true);
}
// Initialize the script editor
ScriptEditorInitializer.init(firstTimeConsent);
monitor.worked(1);
// Initialize symbol lookup
SymbolLookupInitializer.init(firstTimeConsent);
monitor.worked(1);
monitor.done();
return Status.OK_STATUS;
}
};
job.schedule();
}