public void actionPerformed(ActionEvent e) { final JButton source = (e.getSource() instanceof JButton) ? (JButton) e.getSource() : null; final TopComponent mainWindow = WindowManager.getDefault().findTopComponent("KenaiTopComponent"); // NOI18N mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final ProgressHandle progress = ProgressHandleFactory.createHandle( NbBundle.getMessage(CreateChatAction.class, "LBL_CheckPermissions")); progress.setInitialDelay(0); progress.start(); if (source != null) source.setEnabled(true); RequestProcessor.getDefault() .post( new Runnable() { public void run() { try { if (!project.getKenai().isAuthorized(project, KenaiActivity.PROJECTS_ADMIN)) { SwingUtilities.invokeLater( new Runnable() { public void run() { progress.finish(); JOptionPane.showMessageDialog( null, NbBundle.getMessage( CreateChatAction.class, "CTL_NotAuthorizedToCreateChat", getValue(NAME))); mainWindow.setCursor(Cursor.getDefaultCursor()); if (source != null) source.setEnabled(true); } }); return; } } catch (KenaiException ex) { Exceptions.printStackTrace(ex); } SwingUtilities.invokeLater( new Runnable() { public void run() { int value = JOptionPane.showOptionDialog( null, NbBundle.getMessage( CreateChatAction.class, "LBL_CreateChatQuestions"), NbBundle.getMessage(CreateChatAction.class, "LBL_CreateChatTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (value == JOptionPane.YES_OPTION) { progress.setDisplayName( NbBundle.getMessage( CreateChatAction.class, "CTL_CreatingChatProgress")); RequestProcessor.getDefault() .post( new Runnable() { public void run() { try { final KenaiFeature f = project.createProjectFeature( project.getName(), NbBundle.getMessage( CreateChatAction.class, "CTL_ChatRoomName", project.getName()), NbBundle.getMessage( CreateChatAction.class, "CTL_ChatRoomDescription", project.getName()), KenaiService.Names.XMPP_CHAT, null, null, null); SwingUtilities.invokeLater( new Runnable() { public void run() { final ChatTopComponent chatTc = ChatTopComponent.findInstance(); chatTc.open(); chatTc.addChat( new ChatPanel( KenaiConnection.getDefault( project.getKenai()) .getChat(f))); mainWindow.setCursor(Cursor.getDefaultCursor()); progress.finish(); if (source != null) source.setEnabled(true); chatTc.requestActive(); } }); } catch (KenaiException kenaiException) { Exceptions.printStackTrace(kenaiException); mainWindow.setCursor(Cursor.getDefaultCursor()); progress.finish(); if (source != null) source.setEnabled(true); } } }); } else { mainWindow.setCursor(Cursor.getDefaultCursor()); progress.finish(); if (source != null) source.setEnabled(true); } } }); } }); }