It's all about the answers!

Ask a question

istartup plugin does nto work in jazz


a k (2699) | asked Jul 19 '10, 11:25 a.m.
i wrote some code to display a message whenever a user changes the perspective. this works in eclipse as a plug in, but it does not work in RTC. it uses istartup plugin. my code is below:
public class startupperspective implements IStartup {

public void earlyStartup() {
/*
* The registration of the listener should have been done in the UI thread
* since PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null
* if it is called outside of the UI thread.
* */
System.out.print("aba");
Display.getDefault().asyncExec(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow != null) {
workbenchWindow.addPerspectiveListener(new PerspectiveAdapter() {
/* (non-Javadoc)
* @see org.eclipse.ui.PerspectiveAdapter#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor)
*/
@Override
public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspectiveDescriptor) {
super.perspectiveActivated(page, perspectiveDescriptor);
// TODO implement the task to execute when the perspective change
//System.out.println("Something changed!");
String e, d1, d, s, l, n;
s= perspectiveDescriptor.getDescription();
n = perspectiveDescriptor.getId();
l= perspectiveDescriptor.getLabel();


IEditorPart viewDescription = PlatformUI.getWorkbench().
getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (viewDescription!=null) {
e = viewDescription.getEditorInput().getName();
}
else{
e="";
}

if (viewDescription!=null) {
d1= viewDescription.getEditorSite().getRegisteredName();
}
else{
d1="";
}

MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "perspective", n+" : "+s+" : "+l+" file: "+e+" editor:"+d1);
}
});
}
}
});
}

}

Be the first one to answer this question!


Register or to post your answer.