/src/main/java/at/ac/tuwien/sepm/svt3000/guiNew/MainFrame.java
Java | 834 lines | 579 code | 150 blank | 105 comment | 105 complexity | 11d357075fcd5e2dd0cb1d4c4c8faf55 MD5 | raw file
- package at.ac.tuwien.sepm.svt3000.guiNew;
-
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import java.lang.reflect.Method;
- import java.util.Arrays;
- import java.util.Date;
-
- import javax.swing.Box;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JProgressBar;
- import javax.swing.JSeparator;
- import javax.swing.KeyStroke;
- import javax.swing.SwingConstants;
- import javax.swing.UIManager;
-
- import org.apache.log4j.Logger;
- import org.jdesktop.swingx.JXStatusBar;
-
- import at.ac.tuwien.sepm.svt3000.i18n.Messages;
- import at.ac.tuwien.sepm.svt3000.service.IFileService;
- import at.ac.tuwien.sepm.svt3000.service.IUserService;
- import at.ac.tuwien.sepm.svt3000.service.impl.FileService;
- import at.ac.tuwien.sepm.svt3000.service.impl.StudyService;
- import at.ac.tuwien.sepm.svt3000.service.impl.UserService;
-
-
-
- public class MainFrame extends JFrame implements ActionListener {
-
- private static final long serialVersionUID = 1L;
- private static Logger log = Logger.getLogger(MainFrame.class);
-
- /**
- * Singleton
- *
- */
- private static class SingletonHolder {
- private static MainFrame instance = new MainFrame();
- }
-
- public static MainFrame getInstance() {
- return SingletonHolder.instance;
- }
-
- /**
- * Completely recreate the singleton and all relating gui singletons
- * @return
- */
- public static MainFrame getNewInstance() {
- SingletonHolder.instance = new MainFrame();
- SubscribeMainPanel.getNewInstance();
- SearchMainPanel.getNewInstance();
- ProgressMainPanel.getNewInstance();
- CalendarMainPanel.getNewInstance();
- ToDoMainPanel.getNewInstance();
- return SingletonHolder.instance;
- }
-
-
- // accordion objects
- private JAccordion acc = null;
- private JPanel currentMainView = null;
-
- // menu bar objects
- private JMenuItem options= null;
- private JMenuItem pull= null;
- private JMenuItem push= null;
- private JMenuItem vcOptions= null;
- private JMenuItem inscribeStudy= null;
- private JMenuItem switchStudy= null;
- private JMenuItem deleteStudy = null;
- private JMenuItem removeUser = null;
- private JMenuItem logoutUser = null;
- private JMenuItem propertyItem1 = null;
- private JMenuItem hilfe_extra = null;
- private JMenuItem german = null;
- private JMenu language = null;
- private JMenuItem english = null;
-
- // menu panel objects
- private ToDoMenuPanel toDoMenuPanel = null;
- private CalendarMenuPanel calendarMenuPanel = null;
-
- // popup frame objects
- private JProgressBar progressBar = null;
- private InscribeStudyFrame inscribeFrame = null;
- private SwitchStudyFrame switchFrame = null;
- private DeleteStudyFrame deleteStudyFrame = null;
- private PullFrame pullFrame = null;
- private PushFrame pushFrame = null;
-
- // logout button
- private JButton logout = null;
-
- // subscribe main panel
- private SubscribeMainPanel subscribeMainPanel = null;
-
- // status bar objects
- private JLabel statusLabel = new JLabel();
- private JLabel statusLabelLanguage = new JLabel();
- private JLabel statusLabelUser = new JLabel();
- private JLabel statusLabelStudy = new JLabel();
- private JLabel statusLabelCurrentState = new JLabel("Idle");
- JXStatusBar.Constraint c4 = null;
-
- // service objects
- private IUserService us;
- private IFileService fs;
-
- /**
- * Constructor, initalizes MainFrame
- */
- private MainFrame(){
- super("SVT-3000");
- this.setSize(1000, 700);
- this.initializeLookAndFeel();
-
- us = UserService.getInstance();
- fs = new FileService();
- Messages.setLanguage(us.getCurrentUser().getLanguage());
- toDoMenuPanel = new ToDoMenuPanel();
- calendarMenuPanel = new CalendarMenuPanel();
-
- subscribeMainPanel = SubscribeMainPanel.getInstance();
- //subscribeMainPanel = new SubscribeMainPanel();
-
- this.initializeMenu();
- this.initializeAccordion();
- //this.addComponentListener(this);
- this.setCurrentView();
- this.setMinimumSize(new Dimension(880, 680));
-
- // initialize the status bar
- initStatusBar();
-
- // Window Listener for Closing Frame
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent arg0) {
- super.windowClosing(arg0);
- System.exit(0);
- }
- });
- }
-
- /**
- * Initialize the status bar
- */
- private void initStatusBar() {
-
- /**
- * Statusbar
- * @author: manu
- */
- JLabel statusbar = new JLabel();
- statusbar.setPreferredSize(new Dimension(1000, 25));
- statusLabel.setPreferredSize(new Dimension(120, 25));
- statusLabel.setVerticalAlignment(JLabel.TOP);
- statusLabelLanguage.setPreferredSize(new Dimension(80, 25));
- statusLabelLanguage.setVerticalAlignment(JLabel.TOP);
- statusLabelUser.setPreferredSize(new Dimension(120, 25));
- statusLabelUser.setVerticalAlignment(JLabel.TOP);
- statusLabelStudy.setPreferredSize(new Dimension(300, 25));
- statusLabelStudy.setVerticalAlignment(JLabel.TOP);
- statusLabelCurrentState.setPreferredSize(new Dimension(200, 25));
- statusLabelCurrentState.setVerticalAlignment(JLabel.TOP);
-
- if (System.getProperty("os.name").contains("Windows")) {
- statusLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
- statusLabelLanguage.setFont(new Font("SansSerif", Font.PLAIN, 12));
- statusLabelUser.setFont(new Font("SansSerif", Font.PLAIN, 12));
- statusLabelStudy.setFont(new Font("SansSerif", Font.PLAIN, 12));
- statusLabelCurrentState.setFont(new Font("SansSerif", Font.PLAIN, 12));
- }
- else {
- statusLabel.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
- statusLabelLanguage.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
- statusLabelUser.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
- statusLabelStudy.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
- statusLabelCurrentState.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
- }
-
- String language = Messages.BUNDLE_NAME;
-
- statusLabelUser.setText(Messages.getString("MainFrame.39") + ": " + UserService.getInstance().getCurrentUser());
- statusLabelStudy.setText(Messages.getString("MainFrame.40") + ": " + StudyService.getInstance().getCurrentStudy());
-
- language = language.substring(language.length() -2, language.length());
-
- if (language.equals("de"))
- statusLabelLanguage.setText(Messages.getString("MainFrame.35"));
- else
- statusLabelLanguage.setText(Messages.getString("MainFrame.36"));
-
- statusbar.setLayout(new FlowLayout(0, 20, 5));
- progressBar = new JProgressBar();
- progressBar.setStringPainted(true);
- statusbar.add(statusLabel);
- statusbar.add(new JSeparator(JSeparator.VERTICAL));
- statusbar.add(statusLabelLanguage);
- statusbar.add(statusLabelUser);
- statusbar.add(statusLabelStudy);
- statusbar.add(statusLabelCurrentState);
-
-
- this.add(statusbar, BorderLayout.SOUTH);
-
- }
-
- /**
- * @author chris
- * Rerender all panels
- */
- public void rerenderAll() {
-
- SubscribeMainPanel.getInstance().validate();
- SubscribeMainPanel.getInstance().repaint();
- SubscribeFilePanel.getInstance().refresh();
- SubscribeTablePanel.getInstance();
- // @author markus
- SubscribeTablePanel.initializeCourses();
-
- ProgressMainPanel.getInstance().refreshGui();
-
- ToDoMainPanel.getInstance().showToDos();
- CalendarMainPanel.getInstance().showDates();
-
- SubscribeMainPanel.getInstance().setDivider(300);
- }
-
-
- /**
- * Set current state in status bar
- * @author manu
- */
- public void setCurrentState(String state) {
- statusLabelCurrentState.setText(state);
- statusLabelCurrentState.paintImmediately(statusLabelCurrentState.getVisibleRect());
- }
-
- /**
- * Set current user in status bar
- * @param user Current User to show in status bar
- */
- public void setUser(String user) {
- statusLabelUser.setText(Messages.getString("MainFrame.39") + ": " + user);
- }
-
- /**
- * Set current study in status bar
- * @param study Current study to show in status bar
- */
- public void setStudy(String study) {
- statusLabelStudy.setText(Messages.getString("MainFrame.40") + ": " + study);
- }
-
- /**
- * Set status bar text
- * @param text Text to set in status bar
- */
- public void setStatusText(String text) {
- this.statusLabel.setText(text);
- }
-
- public void setProgress(int i){
- progressBar.setValue(i);
- }
-
- /**
- * Get active panel in main frame as String
- * @return Active Panel as String Object
- */
- public String getActivePanelString() {
- int visible = acc.getVisibleBar();
- switch (visible) {
- case 0:
- return Messages.getString("MainFrame.statusbar.active.subscribed");
- case 1:
- return Messages.getString("MainFrame.statusbar.active.search");
- case 2:
- return Messages.getString("MainFrame.statusbar.active.progress");
- case 3:
- return Messages.getString("MainFrame.statusbar.active.calendar");
- case 4:
- return Messages.getString("MainFrame.statusbar.active.todo");
- }
- return "";
- }
-
-
- /**
- * Set nimbus - look and feel if available
- */
- private void initializeLookAndFeel(){
-
- UIManager.LookAndFeelInfo plafinfo[] = UIManager.getInstalledLookAndFeels();
- boolean nimbusfound=false;
- int nimbusindex=0;
-
- for (int look = 0; look < plafinfo.length; look++) {
- if(plafinfo[look].getClassName().toLowerCase().contains(Messages.getString("MainFrame.3"))) { //$NON-NLS-1$
- nimbusfound=true;
- nimbusindex=look;
- }
- }
-
- try {
- if(nimbusfound) {
- UIManager.setLookAndFeel(plafinfo[nimbusindex].getClassName());
- }
- else
- UIManager.setLookAndFeel(
- UIManager.getCrossPlatformLookAndFeelClassName());
- }
- catch(Exception e) {}
- }
-
-
-
- /**
- * Set the accordion(menu) on the left side
- */
- private void initializeAccordion(){
- acc = new JAccordion();
- acc.setPreferredSize(new Dimension(240, this.getHeight()));
- acc.addBar(Messages.getString("MainFrame.4"), SubscribeMenuPanel.getInstance()); //$NON-NLS-1$
- acc.addBar(Messages.getString("MainFrame.5"), SearchMenuPanel.getInstance()); //$NON-NLS-1$
- acc.addBar(Messages.getString("MainFrame.6"), ProgressMenuPanel.getInstance()); //$NON-NLS-1$
- acc.addBar(Messages.getString("MainFrame.7"), calendarMenuPanel); //$NON-NLS-1$
- acc.addBar(Messages.getString("MainFrame.8"), toDoMenuPanel); //$NON-NLS-1$
- getContentPane().setLayout(new BorderLayout(0, 0));
- acc.setVisibleBar(0);
- getContentPane().add(acc, BorderLayout.WEST);
- }
-
-
-
- /**
- * Set the mainMenu on top
- */
- private void initializeMenu(){
- JMenuBar menuBar = new JMenuBar();
- this.setJMenuBar(menuBar);
-
- JMenu user_menu = new JMenu(Messages.getString("MainFrame.menubar.user")); //$NON-NLS-1$
-
- user_menu.add(getLogoutUser());
- user_menu.add(getRemoveUser());
-
- JMenu study_menu = new JMenu(Messages.getString("MainFrame.15")); //$NON-NLS-1$
-
- study_menu.add(getInscribeStudy());
- study_menu.add(getSwitchStudy());
- study_menu.add(getDeleteStudy());
-
- JMenu datei_versioncontrol = new JMenu(Messages.getString("MainFrame.menubar.version")); //$NON-NLS-1$
- datei_versioncontrol.add(getVcPull());
- datei_versioncontrol.add(getVcPush()); //$NON-NLS-1$
- datei_versioncontrol.add(getVcOptions()); //$NON-NLS-1$
- datei_versioncontrol.addActionListener(new MenuBarListener());
-
-
- JMenu datei_options = new JMenu(Messages.getString("MainFrame.16")); //$NON-NLS-1$
- datei_options.add(getOptions());
- datei_options.add(getLanguage());
- datei_options.addActionListener(new MenuBarListener());
-
- JMenu datei_extra = new JMenu("Info"); //$NON-NLS-1$
- hilfe_extra = new JMenuItem(Messages.getString("MainFrame.42"));
- propertyItem1 = new JMenuItem(Messages.getString("MainFrame.20"), new ImageIcon("src/main/resources/icons/info-icon-small.png")); //$NON-NLS-1$ //$NON-NLS-2$
- hilfe_extra.addActionListener(new MenuBarListener());
- propertyItem1.addActionListener(new MenuBarListener());
-
- datei_extra.add(hilfe_extra);
- datei_extra.add(propertyItem1);
- datei_extra.addActionListener(new MenuBarListener());
-
- menuBar.add(user_menu);
- menuBar.add(study_menu);
- menuBar.add(datei_versioncontrol);
- menuBar.add(datei_options);
- menuBar.add(datei_extra);
- menuBar.add(Box.createHorizontalGlue());
-
- logout = new JButton(Messages.getString("MainFrame.menubar.logout"));
- logout.setIcon(new ImageIcon("src/main/resources/icons/logout.png"));
- logout.setHorizontalTextPosition(SwingConstants.LEFT);
- logout.addActionListener(new MenuBarListener());
- menuBar.add(logout);
-
- }
-
-
- /**
- * Set the currently shown panel
- */
- //i<=0 && i>=4
- public void setCurrentView(int i){
- acc.setVisibleBar(i);
- setCurrentView();
- }
-
- /**
- * Change view to subscribed --> new appointment
- * * @param type: type==0 -> todo, else ->appointment
- */
- public void changeToNewAppointment(int type){
- subscribeMainPanel.getTabPanel().setActiveTab(2);
- subscribeMainPanel.getTabPanel().getAppPanel().setActiveTab(0);
- if(type == 0){
- subscribeMainPanel.getTabPanel().getAppPanel().getNewAppPanel().setToDoView();
- }
- else{
- subscribeMainPanel.getTabPanel().getAppPanel().getNewAppPanel().setDateView();
- }
-
- setCurrentView(0);
- subscribeMainPanel.setDivider(300);
- }
-
- /**
- * Change view to subscribed --> change appointment
- * @param type: type==0 -> todo, else ->appointment
- */
- public void changeToChangeAppointment(int type){
- subscribeMainPanel.getTabPanel().setActiveTab(2);
- subscribeMainPanel.getTabPanel().getAppPanel().setActiveTab(1);
- if(type == 0){
- subscribeMainPanel.getTabPanel().getAppPanel().getChangeAppPanel().setToDoView();
- }
- else{
- subscribeMainPanel.getTabPanel().getAppPanel().getChangeAppPanel().setDateView();
- }
-
- setCurrentView(0);
- }
-
- /**
- * set current view. dependent of the accordion-menu status
- */
- public void setCurrentView(){
- //load subscribe view
- if(acc.getVisibleBar() == 0){
- if(currentMainView != null){
- getContentPane().remove(currentMainView);
- }
- setStatusText(Messages.getString("MainFrame.24")); //$NON-NLS-1$
- currentMainView = subscribeMainPanel;
- getContentPane().add(currentMainView, BorderLayout.CENTER);
- SubscribeTablePanel.getInstance().setDetails();
- setCurrentState("Idle");
- }
-
- //load search view
- else if(acc.getVisibleBar() == 1){
- if(currentMainView != null){
- getContentPane().remove(currentMainView);
- }
- setStatusText(Messages.getString("MainFrame.25")); //$NON-NLS-1$
- currentMainView = SearchMainPanel.getInstance();
- getContentPane().add(currentMainView, BorderLayout.CENTER);
- setCurrentState("Idle");
- }
-
- //load progress view
- else if(acc.getVisibleBar() == 2){
- // @author markus
- if(currentMainView != null){
- getContentPane().remove(currentMainView);
- }
- setStatusText(Messages.getString("MainFrame.27")); //$NON-NLS-1$
- currentMainView = ProgressMainPanel.getInstance();
- ((ProgressMainPanel)currentMainView).refreshGui();
- getContentPane().add(currentMainView, BorderLayout.CENTER);
- setCurrentState("Idle");
- }
-
- //load calendar view
- else if(acc.getVisibleBar() == 3){
- if(currentMainView != null){
- getContentPane().remove(currentMainView);
- }
- setStatusText(Messages.getString("MainFrame.28")); //$NON-NLS-1$
- currentMainView = CalendarMainPanel.getInstance();
-
- ((CalendarMainPanel)currentMainView).setCourse(null);
- ((CalendarMainPanel)currentMainView).setDate(new Date());
- ((CalendarMainPanel)currentMainView).showDates();
-
- calendarMenuPanel.updateComboBox();
- calendarMenuPanel.flagDates();
- getContentPane().add(currentMainView, BorderLayout.CENTER);
- setCurrentState("Idle");
- }
-
- //load todo view
- else if(acc.getVisibleBar() == 4){
- if(currentMainView != null){
- getContentPane().remove(currentMainView);
- }
- setStatusText(Messages.getString("MainFrame.29")); //$NON-NLS-1$
- currentMainView = ToDoMainPanel.getInstance();
- ToDoMainPanel.getInstance().showToDos();
- toDoMenuPanel.updateComboBox();
- getContentPane().add(currentMainView, BorderLayout.CENTER);
- setCurrentState("Idle");
- }
-
- this.validate();
- this.repaint();
- }
-
- private JMenu getLanguage(){
- language = new JMenu(Messages.getString("MainFrame.12")); //$NON-NLS-1$
- german = new JMenuItem(Messages.getString("MainFrame.13")); //$NON-NLS-1$
- english = new JMenuItem(Messages.getString("MainFrame.14")); //$NON-NLS-1$
- language.addActionListener(new MenuBarListener());
- german.addActionListener(new MenuBarListener());
- english.addActionListener(new MenuBarListener());
-
- language.add(german);
- language.add(english);
-
- return language;
- }
-
- // --- MENU ITEMS ---
-
- private JMenuItem getInscribeStudy() {
- if (inscribeStudy == null) {
- inscribeStudy = new JMenuItem(Messages.getString("MainFrame.menubar.inscribe")); //$NON-NLS-1$
- inscribeStudy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
- inscribeStudy.addActionListener(new MenuBarListener());
- }
- return inscribeStudy;
- }
-
- private JMenuItem getSwitchStudy() {
- if (switchStudy == null) {
- switchStudy = new JMenuItem(Messages.getString("MainFrame.menubar.switch")); //$NON-NLS-1$
- switchStudy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
- switchStudy.addActionListener(new MenuBarListener());
- }
- return switchStudy;
- }
-
- private JMenuItem getDeleteStudy() {
- if (deleteStudy == null) {
- deleteStudy = new JMenuItem(Messages.getString("MainFrame.32")); //$NON-NLS-1$
- deleteStudy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, ActionEvent.ALT_MASK));
- deleteStudy.addActionListener(new MenuBarListener());
- }
- return deleteStudy;
- }
-
- private JMenuItem getOptions() {
- if (options == null) {
- options = new JMenuItem(Messages.getString("MainFrame.30")); //$NON-NLS-1$
- options.addActionListener(new MenuBarListener());
- }
- return options;
- }
-
- private JMenuItem getVcPull() {
- if (pull == null) {
- pull = new JMenuItem(Messages.getString("MainFrame.menubar.version.pull")); //$NON-NLS-1$
- //pull.setEnabled(SettingService.getInstance().isVersionControlUsed());
- pull.addActionListener(new MenuBarListener());
- }
- return pull;
- }
-
- private JMenuItem getVcPush() {
- if (push == null) {
- push = new JMenuItem(Messages.getString("MainFrame.menubar.version.push")); //$NON-NLS-1$
- //push.setEnabled(SettingService.getInstance().isVersionControlUsed());
- push.addActionListener(new MenuBarListener());
- }
- return push;
- }
-
- private JMenuItem getVcOptions() {
- if (vcOptions == null) {
- vcOptions = new JMenuItem(Messages.getString("MainFrame.menubar.version.settings")); //$NON-NLS-1$
- vcOptions.addActionListener(new MenuBarListener());
- }
- return vcOptions;
- }
-
- private JMenuItem getRemoveUser() {
- if (removeUser == null) {
- removeUser = new JMenuItem(Messages.getString("MainFrame.menubar.deleteuser")); //$NON-NLS-1$
- removeUser.addActionListener(new MenuBarListener());
- }
- return removeUser;
- }
-
- private JMenuItem getLogoutUser() {
- if (logoutUser == null) {
- logoutUser = new JMenuItem(Messages.getString("MainFrame.menubar.logout")); //$NON-NLS-1$
- logoutUser.addActionListener(new MenuBarListener());
- }
- return logoutUser;
- }
-
- // --- POPUP FRAMES ---
-
- /**
- * Get the info frame
- * @return Info Frame
- */
- private JFrame getInfoFrame() {
- return new InfoFrame();
-
- }
-
- private OptionsFrame getOptionsFrame() {
- return new OptionsFrame();
- }
-
- private JFrame getInscribeFrame() {
- inscribeFrame = new InscribeStudyFrame(Messages.getString("InscribeStudyFrame.title")); //$NON-NLS-1$
-
- if(inscribeFrame.isVisible()== false){
- inscribeFrame.setVisible(true);
- }
- return inscribeFrame;
- }
-
- private JFrame getSwitchFrame() {
- switchFrame = new SwitchStudyFrame(Messages.getString("SwitchStudyFrame.title")); //$NON-NLS-1$
-
- if(switchFrame.isVisible()== false){
- switchFrame.setVisible(true);
- }
- return switchFrame;
- }
-
- private JFrame getDeleteFrame() {
- deleteStudyFrame = new DeleteStudyFrame(Messages.getString("MainFrame.37")); //$NON-NLS-1$
-
- if(deleteStudyFrame.isVisible()== false){
- deleteStudyFrame.setVisible(true);
- }
- return deleteStudyFrame;
- }
-
- private JFrame getPullFrame() {
- pullFrame = new PullFrame(Messages.getString("PullFrame.title")); //$NON-NLS-1$
-
- if(pullFrame.isVisible()== false){
- pullFrame.setVisible(true);
- }
- return pullFrame;
- }
-
- private JFrame getPushFrame() {
- pushFrame = new PushFrame(Messages.getString("PushFrame.title")); //$NON-NLS-1$
-
- if(pushFrame.isVisible()== false){
- pushFrame.setVisible(true);
- }
- return pushFrame;
- }
-
-
- private MainFrame getThis() {
- return this;
- }
-
- /**
- * @author manu
- */
- public static void openWebsite(String url) {
-
- String osName = System.getProperty("os.name");
- final String[] browsers = { "firefox", "opera", "konqueror", "epiphany",
- "seamonkey", "galeon", "kazehakase", "mozilla", "netscape" };
-
-
- try {
- if (osName.startsWith("Mac OS")) {
- Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
- Method openURL = fileMgr.getDeclaredMethod("openURL",
- new Class[] {String.class});
- openURL.invoke(null, new Object[] {url});
- }
-
- else if (osName.startsWith("Windows"))
- Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
-
- //assume Unix or Linux
- else {
- boolean found = false;
-
- for (String browser : browsers)
- if (!found) {
- found = Runtime.getRuntime().exec(
- new String[] {"which", browser}).waitFor() == 0;
- if (found)
- Runtime.getRuntime().exec(new String[] {browser, url});
- }
-
- if (!found)
- throw new Exception(Arrays.toString(browsers));
- }
- }
-
- catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error attempting to launch web browser\n" + e.toString());
- }
- }
-
- /**
- * Listener class for the menu bar
- *
- */
- class MenuBarListener implements ActionListener {
- //for menubar
- @Override
- public void actionPerformed(ActionEvent e) {
- String[] yesNoOptions = {Messages.getString("SubscribeMenuPanel.13"), Messages.getString("SubscribeMenuPanel.9")};
-
- if (e.getSource() == options){
- getOptionsFrame();
- }
-
- if (e.getSource() == hilfe_extra) {
- openWebsite("http://svt3000.mlanner.com/site/handbuch.html");
- }
-
- if (e.getSource() == vcOptions){
- OptionsFrame of = getOptionsFrame();
- of.setTab(OptionsFrame.VERSION_CONTROL_INDEX);
- }
-
- if (e.getSource() == pull) {
- if (!UserService.getInstance().getCurrentUser().isSvnUsed()) {
- JOptionPane.showMessageDialog(getThis(), Messages.getString("VersionControl.notactive"), Messages.getString("VersionControl.notactive.title"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
- } else {
- getPullFrame();
-
- }
- }
-
- if (e.getSource() == push) {
-
- if (!UserService.getInstance().getCurrentUser().isSvnUsed()) {
- JOptionPane.showMessageDialog(getThis(), Messages.getString("VersionControl.notactive"), Messages.getString("VersionControl.notactive.title"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
- } else {
- getPushFrame();
-
- }
- }
-
- if (e.getSource() == switchStudy) {
- getSwitchFrame();
- }
-
- if (e.getSource() == deleteStudy) {
- getDeleteFrame();
- }
-
- if (e.getSource() == removeUser) {
- int choice = JOptionPane.showOptionDialog(getThis(), Messages.getString("DeleteUserFrame.confirm"), Messages.getString("DeleteUserFrame.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null);
- if (choice == JOptionPane.YES_OPTION) {
- fs.removeUserDirectory();
- us.removeUser(us.getCurrentUser().getName());
- getThis().dispose();
- new WelcomeFrame();
- }
- }
-
- //Deutsch
- if (e.getSource() == german) {
- int sure = JOptionPane.showOptionDialog(null,
- Messages.getString("MainFrame.33"), Messages.getString("MainFrame.34"),
- JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION, null, yesNoOptions, null);
- if (sure == 0)
- UserService.getInstance().updateLanguageSettings("de");
-
- }
-
- //English
- if (e.getSource() == english) {
- int sure = JOptionPane.showOptionDialog(null, Messages.getString("MainFrame.33"), Messages.getString("MainFrame.34"),
- JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION, null, yesNoOptions, null);
-
- if (sure == 0)
- UserService.getInstance().updateLanguageSettings("en");
-
- }
-
- if (e.getSource() == inscribeStudy)
- getInscribeFrame();
-
-
- if (e.getSource() == propertyItem1){
- getInfoFrame();
- }
-
- if ((e.getSource() == logout) || (e.getSource() == logoutUser)) {
- log.info("logout button pressed.");
- // TODO auto push
- us.updateLogoutCurrentUser(true);
- getThis().dispose();
- new WelcomeFrame();
- }
-
- }
-
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- }
-
-
- }