window.setData("wrapper",ChatWrapper.this);
window.addDisposeListener(disposeListener);
} else if(openType.equals(PreferenceConstants.P_CHAT_OPEN_TYPE_SAMEWINDOW)){
IWorkbenchPage page = account.getDefaultWorkbenchPage();
if(page == null) page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IChatGUI gui = openChatView(page);
if(msg != null) gui.processMessage(msg, alreadyHandled);
window = gui;
} else if(openType.equals(PreferenceConstants.P_CHAT_OPEN_TYPE_NEWTABBEDWINDOW)) {
IWorkbenchPage chatPage = null;
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for(IWorkbenchWindow window : windows) {
IWorkbenchPage[] pages = window.getPages();
for(IWorkbenchPage page : pages) {
for(IPerspectiveDescriptor perspective : page.getSortedPerspectives()) {
if(perspective.getId().equals(ChatPerspectiveFactory.PERSPECTIVE_ID)) {
chatPage = page;
break;
}
}
}
}
if(chatPage == null) {
try {
IWorkbenchWindow wwindow = PlatformUI.getWorkbench().openWorkbenchWindow(ChatPerspectiveFactory.PERSPECTIVE_ID,null);
IChatGUI gui = openChatView(wwindow.getActivePage());
if(msg != null) gui.processMessage(msg, alreadyHandled);
window = gui;
} catch (WorkbenchException e) {
e.printStackTrace();
}
} else {
IChatGUI gui = openChatView(chatPage);
if(msg != null) gui.processMessage(msg, alreadyHandled);
window = gui;
}
} else {
throw new RuntimeException("Unsupported open type ?: " + openType);
}