public List<Tab> getTabs() {
   List<Tab> tabs = new LinkedList<Tab>();
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     if (tabbedPane.getComponentAt(i) instanceof Tab) {
       tabs.add((Tab) tabbedPane.getComponentAt(i));
     }
   }
   return tabs;
 }
 public void previousTab() {
   int t = tabbedPane.getSelectedIndex();
   if (t == 0) {
     t = tabbedPane.getTabCount() - 1;
   } else {
     t--;
   }
   tabbedPane.setSelectedIndex(t);
 }
 public void appendText(final String tabTitle, final String text) {
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     if (tabbedPane.getTitleAt(i).equals(tabTitle)) {
       if (tabbedPane.getComponentAt(i) instanceof Tab) {
         Tab tab = (Tab) tabbedPane.getComponentAt(i);
         tab.append(text);
       }
     }
   }
 }
 public boolean selectTabWith(File file) {
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     if (tabbedPane.getComponentAt(i) instanceof Tab) {
       Tab tab = (Tab) tabbedPane.getComponentAt(i);
       if (tab.getFile() != null && tab.getFile().equals(file)) {
         tabbedPane.setSelectedIndex(i);
         return true;
       }
     }
   }
   return false;
 }
 public Tab currentTab() {
   Component comp = tabbedPane.getSelectedComponent();
   if (comp instanceof Tab) {
     return (Tab) comp;
   }
   return null;
 }
 /**
  * This method is called when the state of the ATabbedPane changes, i. e. when the tab to be
  * displayed changes.
  *
  * @param e
  */
 public void stateChanged(ChangeEvent e) {
   setTitle(tabbedPane.getCurrentTitle() + " - Quick Sequence Diagram Editor");
   Action closeAction = menuBar.getActionByName("[F12]&Close");
   if (closeAction != null) {
     closeAction.setEnabled(tabbedPane.getTabCount() > 1);
   }
   final Tab tab = currentTab();
   if (tab != null) {
     tab.leaveFilterMode();
     scalePanel.setScalable(tab.getZoomPane());
     fireCodeChanged(false);
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             tab.getTextArea().requestFocusInWindow();
           }
         });
   }
   enableComponents();
 }
 public String addTab(String tabTitle, Bean<Configuration> configuration) {
   Tab tab =
       new Tab(
           this,
           redrawThread,
           ConfigurationManager.getGlobalConfiguration().getEditorFont(),
           configuration);
   for (UserInterfaceListener listener : listeners) {
     if (listener.getPanelPaintDeviceListener() != null) {
       tab.addPanelPaintDeviceListener(listener.getPanelPaintDeviceListener());
     }
   }
   String uniqueTitle = tabbedPane.addTab(tab, tabTitle);
   currentTab().layout(configuration.getDataObject().isVerticallySplit() ? 1 : 0);
   enableComponents();
   return uniqueTitle;
 }
 public void help(String title, String path, boolean navigation) {
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     if (!(tabbedPane.getComponentAt(i) instanceof Tab)) {
       if (tabbedPane.getTitleAt(i).equals(title)
           || tabbedPane.getTitleAt(i).startsWith(title + "-")) {
         tabbedPane.setSelectedIndex(i);
         return;
       }
     }
   }
   JComponent help;
   if (navigation) {
     help = new AdvancedHelpPanel(getClass().getResource(path), this);
   } else {
     help = new JScrollPane(new HelpPanel(getClass().getResource(path), this).getPane());
   }
   tabbedPane.addTab(help, title, Icons.getIcon("help"));
 }
 public void nextTab() {
   int t = tabbedPane.getSelectedIndex();
   t = (t + 1) % tabbedPane.getTabCount();
   tabbedPane.setSelectedIndex(t);
 }
 public int getNumberOfTabs() {
   return tabbedPane.getTabCount();
 }
 public boolean removeCurrentTab(boolean check) {
   setErrorStatus(false, "", -1, -1);
   boolean flag = tabbedPane.removeCurrentTab(check);
   enableComponents();
   return flag;
 }
 public void setCurrentFile(File file) {
   currentTab().setFile(file);
   if (file != null) {
     tabbedPane.setToolTipTextAt(tabbedPane.getSelectedIndex(), file.getAbsolutePath());
   }
 }
 public void setTabTitle(String title) {
   tabbedPane.setTabTitle(title);
   setTitle(title + " - Quick Sequence Diagram Editor");
 }
  @SuppressWarnings("serial")
  public void showUI() {
    setIconImage(Icons.getIcon("icon").getImage());
    fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    tabbedPane = new ATabbedPane();
    tabbedPane.addChangeListener(this);
    tabbedPane.addListener(this);

    pane.add(tabbedPane, BorderLayout.CENTER);

    pane.add(toolbar, BorderLayout.NORTH);

    bottomPanel = new JPanel();
    bottomPanel.setLayout(new BorderLayout());

    scalePanel = new ScalePanel(false);
    Dimension spSize = new Dimension(140, 24);

    scalePanel.setMaximumSize(spSize);
    scalePanel.setMinimumSize(spSize);
    scalePanel.setPreferredSize(spSize);

    scalePanel.setOpaque(false);
    addToolbarSeparator();
    toolbar.add(scalePanel);

    registerComponent(scalePanel, nonEmptyDiagramActivator);

    addToolbarSeparator();

    addToToolbar(scalePanel.normalSizeAction, nonEmptyDiagramActivator);
    addToToolbar(scalePanel.fitHeightAction, nonEmptyDiagramActivator);
    addToToolbar(scalePanel.fitWidthAction, nonEmptyDiagramActivator);
    addToToolbar(scalePanel.fitWindowAction, nonEmptyDiagramActivator);

    pane.add(bottomPanel, BorderLayout.SOUTH);

    int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;

    int width = (int) (0.8 * screenWidth);
    int height = (int) (0.8 * screenHeight);

    int left = (int) (0.1 * screenWidth);
    int top = (int) (0.1 * screenHeight);

    setSize(width, height);
    setLocation(left, top);

    fullScreen = new FullScreen();
    fullScreen.addListener(this);
    LookAndFeelManager.instance().register(fullScreen);

    setJMenuBar(menuBar);
    LookAndFeelManager.instance().register(this);

    // printDialog.loadProfiles();
    ConfigurationManager.getGlobalConfigurationBean()
        .addPropertyChangeListener(
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {
                enableComponents();
              }
            });

    enableComponents();
    setVisible(true);
  }