Esempio n. 1
0
 /**
  * Make changes to UI to notify content change
  *
  * @param contentchanged
  */
 public final void notifyContentChange(boolean contentchanged) {
   if (contentchanged) {
     this.cmdSave.setEnabled(true);
     if (ContainerComponent instanceof Frame) {
       ((Frame) ContainerComponent).setTitle(getTitle() + "*");
     } else if (ContainerComponent instanceof Dialog) {
       ((Dialog) ContainerComponent).setTitle(getTitle() + "*");
     } else if (ContainerComponent instanceof JTabbedPane) {
       if (TabId > 0) {
         // ((JTabbedPane)ContainerComponent).setTitleAt(getTabId(), getTitle() + "*");
         JTabbedPane jtb = (JTabbedPane) ContainerComponent;
         jtb.setTitleAt(jtb.indexOfComponent(this), getTitle() + "*");
       }
     }
   } else {
     this.cmdSave.setEnabled(false);
     if (ContainerComponent instanceof Frame) {
       ((Frame) ContainerComponent).setTitle(getTitle());
     } else if (ContainerComponent instanceof Dialog) {
       ((Dialog) ContainerComponent).setTitle(getTitle());
     } else if (ContainerComponent instanceof JTabbedPane) {
       if (TabId > 0) {
         // ((JTabbedPane)ContainerComponent).setTitleAt(getTabId(), getTitle());
         JTabbedPane jtb = (JTabbedPane) ContainerComponent;
         jtb.setTitleAt(jtb.indexOfComponent(this), getTitle());
       }
     }
   }
 }
 private void updateTabTitles() {
   tabbedPane.setTitleAt(
       tabbedPane.indexOfComponent(matchTable), tr(marktr("Matches ({0})"), matches.size()));
   tabbedPane.setTitleAt(
       tabbedPane.indexOfComponent(referenceOnlyList),
       tr(marktr("Reference only ({0})"), referenceOnlyListModel.size()));
   tabbedPane.setTitleAt(
       tabbedPane.indexOfComponent(subjectOnlyList),
       tr(marktr("Subject only ({0})"), subjectOnlyListModel.size()));
 }
Esempio n. 3
0
  public MainFrame(String title, UserFrontEnd ptheApp) {
    super(title);
    theApp = ptheApp;
    // identify the OS

    if (theApp.runningOSX()) initForOSX(); // OSX specific inits
    else if (theApp.runningWindows()) { // Windows specific inits
      initForWindows();
    } else if (theApp.runningLinux()) {
      initForLinux();
    } else {
      JOptionPane.showMessageDialog(
          this,
          "Phylontal doesn't recognize your operating system (yet!)",
          "Operating System unknown",
          JOptionPane.WARNING_MESSAGE);
    }

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    // add tabbed pane
    tabbedView = new JTabbedPane(JTabbedPane.TOP);
    tabbedView.addChangeListener(this);

    tabbedView.addTab("Project", projectTab = new ProjectTab(theApp));
    tabbedView.addTab("Matcher", matcherTab = new MatcherTab(theApp));

    int matchIndex = tabbedView.indexOfComponent(matcherTab);
    tabbedView.setToolTipTextAt(matchIndex, "Disabled until a project is specified");
    tabbedView.setEnabledAt(matchIndex, false);

    int projectIndex = tabbedView.indexOfComponent(projectTab);
    tabbedView.setToolTipTextAt(projectIndex, "Create or Load a project; specify components");

    currentTabComponent = tabbedView.getSelectedComponent();
    if (currentTabComponent instanceof TabView) {
      resetMenuBar();
      JMenuBar tmpBar = ((TabView) currentTabComponent).initializeMenus();
      if (tmpBar != null) {
        menuBar = tmpBar;
        setJMenuBar(menuBar);
      }
    }

    Container content = getContentPane(); // get content pane
    content.setLayout(new BorderLayout());
    content.add(tabbedView, BorderLayout.CENTER);

    // add icons

    // add preferences Dialog

    preferencesDialog = new PreferencesDialog(this);
  }
Esempio n. 4
0
 public void enableTab(TabView view, String toolTip) {
   int index = tabbedView.indexOfComponent(view);
   if (index != -1) {
     tabbedView.setEnabledAt(index, true);
     tabbedView.setToolTipTextAt(index, toolTip);
   }
 }
 public void notify(String user, int alarmLevel) {
   if (alarmLevel <= 0 || !hasUser(user)) return;
   ChatPane entry = chatPanes.get(user == null ? PUBLIC_PANE : user);
   entry.notify = alarmLevel;
   int idx = tabs.indexOfComponent(entry.component);
   if (idx >= 0) ((ChatTabTitleComponent) tabs.getTabComponentAt(idx)).updateAlarm();
 }
Esempio n. 6
0
  /**
   * Update the icon on tab page of which session be modified with newer state.
   *
   * @param state newer state of session
   * @param session target session to be modified the icon
   */
  public void updateTabState(final int state, final SessionPane session) {
    int index;
    ImageIcon imageIcon;

    switch (state) {
      case SessionPane.STATE_TRYING:
        imageIcon = tryingIcon;
        break;
      case SessionPane.STATE_CONNECTED:
        imageIcon = connectedIcon;
        break;
      case SessionPane.STATE_CLOSED:
        imageIcon = closedIcon;
        break;
      case SessionPane.STATE_ALERT:
        imageIcon = bellIcon;
        break;
      default:
        imageIcon = null;
    }

    index = tabbedPane.indexOfComponent(session);
    if (index != -1) {
      tabbedPane.setIconAt(index, imageIcon);
    }
  }
Esempio n. 7
0
 /**
  * Selects the prop tab if it is appropriate for the target.
  *
  * @param target the target object
  * @return true if props tab is really selected
  */
 private boolean selectPropsTab(Object target) {
   if (getTabProps().shouldBeEnabled(target)) {
     int indexOfPropPanel = topLevelTabbedPane.indexOfComponent(getTabProps());
     topLevelTabbedPane.setSelectedIndex(indexOfPropPanel);
     lastNonNullTab = indexOfPropPanel;
     return true;
   }
   return false;
 }
Esempio n. 8
0
 /* (non-Javadoc)
  * @see com.nullfish.app.jfd2.ui.container2.JFDContainer#setContainerVisible(boolean)
  */
 public void setContainerVisible(boolean visible) {
   if (visible) {
     if (tabbedPane.indexOfComponent(this) < 0) {
       tabbedPane.addTab("", this);
     }
   } else {
     tabbedPane.remove(this);
   }
 }
Esempio n. 9
0
 private void blink() {
   if (lblTitle.getForeground() == Color.BLACK) {
     lblTitle.setForeground(new Color(255, 130, 13));
   } else {
     lblTitle.setForeground(Color.BLACK);
   }
   if (parent.indexOfComponent(owner) == parent.getSelectedIndex()) {
     this.stopBlink();
   }
 }
Esempio n. 10
0
 /**
  * Reopen session which is currently disconnected.
  *
  * @param session session to be reopened.
  */
 public void reopenSession(final SessionPane session) {
   if (session != null) {
     // 若連線中則開新分頁,已斷線則重連。
     if (session.isClosed()) {
       this.connect(session.getSite(), tabbedPane.indexOfComponent(session));
     } else {
       // FIXME magic number -1
       this.connect(session.getSite(), -1);
     }
   }
 }
Esempio n. 11
0
 private void displayTool(Component comp) {
   if (tabbedPane != null && tabbedPane.getTabCount() > 1) {
     if (tabbedPane.indexOfComponent(comp) >= 0) {
       tabbedPane.setSelectedComponent(comp);
     }
   }
   if (comp instanceof PushpinObj) comp = ((PushpinObj) comp).getPinObj();
   if (comp instanceof XMLToolPanel) {
     ((XMLToolPanel) comp).updateChange();
     ((XMLToolPanel) comp).setEditMode(inEditMode);
   } else if (comp instanceof VToolPanel) ((VToolPanel) comp).updateValue();
 }
Esempio n. 12
0
 // Called when "show GC plot" is called from analysis menu
 private void selectTab(int type) {
   if (type == GC) {
     tabbedPane.setSelectedComponent(gcSliderPanel);
     gcplot.setSelected(true);
     getSZAP().setGraphVisibility(gcplot.isSelected());
     // Neither of these helps restore window to its smaller size, oh well
     //
     // Note the reason for this is that the tabbedPane is set to the size of its largest contained
     // panel which isn't necessarily the panel currently displayed.
     //      pack();
     //      tabbedPane.pack();
   } else {
     //      tabbedPane.setSelectedComponent(resEnzSel);  // can't do
     int which_is_gc = tabbedPane.indexOfComponent(gcSliderPanel);
     tabbedPane.setSelectedIndex(1 - which_is_gc); // kludge
   }
 }
 @Override
 public void actionPerformed(ActionEvent e) {
   if (mcEditor == null) {
     mcEditor = new MessageColorizerBrowser(container, statusObserver);
   }
   if (tabbedPane.indexOfComponent(mcEditor) == -1) {
     int tabCount = tabbedPane.getTabCount();
     tabbedPane.addTab(null, Icons.MESSAGE_COLORIZER, mcEditor);
     tabbedPane.setTabComponentAt(
         tabCount,
         new TabHeader(
             tabbedPane,
             "MessageColorizer editor",
             Icons.MESSAGE_COLORIZER,
             "MessageColorizer editor"));
     tabbedPane.setSelectedIndex(tabCount);
   } else {
     tabbedPane.setSelectedComponent(mcEditor);
   }
 }
Esempio n. 14
0
 public void propertyChange(PropertyChangeEvent e) {
   if (e.getSource() instanceof PanelThreadMonitor) {
     if (e.getPropertyName().equals("Status")) {
       PanelThreadMonitor mntTmp = (PanelThreadMonitor) e.getSource();
       int iMonitorIndex = pnlThread.indexOfComponent(mntTmp);
       if (iMonitorIndex >= 0) {
         if (e.getNewValue().equals("Started")) {
           if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(COLOR_STARTED)) {
             pnlThread.setBackgroundAt(iMonitorIndex, COLOR_STARTED);
             pnlThread.setForegroundAt(iMonitorIndex, COLOR_STARTED_FG);
           }
         } else if (e.getNewValue().equals("Stopped")) {
           if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(SystemColor.controlShadow)) {
             pnlThread.setBackgroundAt(iMonitorIndex, UIManager.getColor("TabbedPane.background"));
             pnlThread.setForegroundAt(iMonitorIndex, SystemColor.textText);
           }
         }
       }
     }
   }
 }
 public void componentAdded(ContainerEvent e) {
   JTabbedPane tp = (JTabbedPane) e.getContainer();
   Component child = e.getChild();
   if (child instanceof UIResource) {
     return;
   }
   int index = tp.indexOfComponent(child);
   String title = tp.getTitleAt(index);
   boolean isHTML = BasicHTML.isHTMLString(title);
   if (isHTML) {
     if (htmlViews == null) { // Initialize vector
       htmlViews = createHTMLVector();
     } else { // Vector already exists
       View v = BasicHTML.createHTMLView(tp, title);
       htmlViews.insertElementAt(v, index);
     }
   } else { // Not HTML
     if (htmlViews != null) { // Add placeholder
       htmlViews.insertElementAt(null, index);
     } // else nada!
   }
 }
Esempio n. 16
0
 /**
  * Returns the index for the specified component.
  *
  * @param component Component reference.
  * @return int Index of the Component or -1 if not found.
  */
 @Override
 public int indexOfComponent(Component component) {
   // get the index from JTabbedPane
   return tabbedPane.indexOfComponent(component);
 }
Esempio n. 17
0
 /**
  * Check if the session is selected on tab page.
  *
  * @param session
  * @return true if the session is selected on tab page; false, otherwise.
  */
 public boolean isTabForeground(final SessionPane session) {
   return (tabbedPane.indexOfComponent(session) == tabbedPane.getSelectedIndex());
 }
Esempio n. 18
0
  /** Refreshes the GUI including locale-based resource strings. */
  protected void refreshGUI() {
    setTitle(ToolsRes.getString("LibraryManager.Title")); // $NON-NLS-1$

    okButton.setText(ToolsRes.getString("Tool.Button.Close")); // $NON-NLS-1$
    addButton.setText(ToolsRes.getString("LibraryManager.Button.Add")); // $NON-NLS-1$
    removeButton.setText(ToolsRes.getString("LibraryManager.Button.Remove")); // $NON-NLS-1$
    moveUpButton.setText(ToolsRes.getString("LibraryTreePanel.Button.Up")); // $NON-NLS-1$
    moveDownButton.setText(ToolsRes.getString("LibraryTreePanel.Button.Down")); // $NON-NLS-1$
    allButton.setText(ToolsRes.getString("LibraryManager.Button.All")); // $NON-NLS-1$
    noneButton.setText(ToolsRes.getString("LibraryManager.Button.None")); // $NON-NLS-1$
    clearCacheButton.setText(ToolsRes.getString("LibraryManager.Button.ClearCache")); // $NON-NLS-1$
    setCacheButton.setText(ToolsRes.getString("LibraryManager.Button.SetCache")); // $NON-NLS-1$

    addButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.Add.Tooltip")); // $NON-NLS-1$
    removeButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.Remove.Tooltip")); // $NON-NLS-1$
    moveUpButton.setToolTipText(
        ToolsRes.getString("LibraryTreePanel.Button.Up.Tooltip")); // $NON-NLS-1$
    moveDownButton.setToolTipText(
        ToolsRes.getString("LibraryTreePanel.Button.Down.Tooltip")); // $NON-NLS-1$
    allButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.All.Tooltip")); // $NON-NLS-1$
    noneButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.None.Tooltip")); // $NON-NLS-1$
    clearCacheButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.ClearCache.Tooltip")); // $NON-NLS-1$
    setCacheButton.setToolTipText(
        ToolsRes.getString("LibraryManager.Button.SetCache.Tooltip")); // $NON-NLS-1$

    nameLabel.setText(
        ToolsRes.getString("LibraryManager.Label.Name") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    pathLabel.setText(
        ToolsRes.getString("LibraryManager.Label.Path") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    collectionsTitleBorder.setTitle(
        ToolsRes.getString("LibraryManager.Title.MenuItems") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    importsTitleBorder.setTitle(
        ToolsRes.getString("LibraryManager.Title.Import") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    searchTitleBorder.setTitle(
        ToolsRes.getString("LibraryManager.Title.Search") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    cacheTitleBorder.setTitle(
        ToolsRes.getString("LibraryManager.Title.Cache") + ":"); // $NON-NLS-1$ //$NON-NLS-2$
    int k = tabbedPane.indexOfComponent(collectionsPanel);
    if (k > -1) {
      tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.MyLibrary")); // $NON-NLS-1$
      tabbedPane.setToolTipTextAt(
          k, ToolsRes.getString("LibraryManager.Tab.MyLibrary.Tooltip")); // $NON-NLS-1$
    }
    k = tabbedPane.indexOfComponent(importsPanel);
    if (k > -1) {
      tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Import")); // $NON-NLS-1$
      tabbedPane.setToolTipTextAt(
          k, ToolsRes.getString("LibraryManager.Tab.Import.Tooltip")); // $NON-NLS-1$
    }
    k = tabbedPane.indexOfComponent(searchPanel);
    if (k > -1) {
      tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Search")); // $NON-NLS-1$
      tabbedPane.setToolTipTextAt(
          k, ToolsRes.getString("LibraryManager.Tab.Search.Tooltip")); // $NON-NLS-1$
    }
    k = tabbedPane.indexOfComponent(cachePanel);
    if (k > -1) {
      tabbedPane.setTitleAt(k, ToolsRes.getString("LibraryManager.Tab.Cache")); // $NON-NLS-1$
      tabbedPane.setToolTipTextAt(
          k, ToolsRes.getString("LibraryManager.Tab.Cache.Tooltip")); // $NON-NLS-1$
    }

    resizeLabels();

    pathField.setForeground(LibraryTreePanel.defaultForeground);
    if (tabbedPane.getSelectedComponent() == collectionsPanel) {
      nameField.setEditable(true);
      int i = collectionList.getSelectedIndex();
      moveDownButton.setEnabled(i < library.pathList.size() - 1);
      moveUpButton.setEnabled(i > 0);
      if (i > -1 && library.pathList.size() > i) {
        removeButton.setEnabled(true);
        String path = library.pathList.get(i);
        pathField.setText(path);
        pathField.setCaretPosition(0);
        String name = library.pathToNameMap.get(path);
        nameField.setText(name);
        boolean unavailable =
            path.startsWith("http:") && !LibraryBrowser.webConnected; // $NON-NLS-1$
        Resource res = unavailable ? null : ResourceLoader.getResourceZipURLsOK(path);
        if (res == null) {
          pathField.setForeground(LibraryTreePanel.darkRed);
        }
      } else {
        removeButton.setEnabled(false);
        nameField.setEditable(false);
        nameField.setText(null);
        nameField.setBackground(Color.white);
        pathField.setText(null);
        pathField.setBackground(Color.white);
      }
    } else if (tabbedPane.getSelectedComponent() == importsPanel) {
      nameField.setEditable(false);
      int i = guestList.getSelectedIndex();
      moveDownButton.setEnabled(i < library.importedPathList.size() - 1);
      moveUpButton.setEnabled(i > 0);
      if (i > -1 && library.importedPathList.size() > i) {
        removeButton.setEnabled(true);
        String path = library.importedPathList.get(i);
        pathField.setText(path);
        pathField.setCaretPosition(0);
        String name = library.importedPathToLibraryMap.get(path).getName();
        nameField.setText(name);
        boolean unavailable =
            path.startsWith("http:") && !LibraryBrowser.webConnected; // $NON-NLS-1$
        Resource res = unavailable ? null : ResourceLoader.getResourceZipURLsOK(path);
        if (res == null) {
          pathField.setForeground(LibraryTreePanel.darkRed);
        }
      } else {
        removeButton.setEnabled(false);
        nameField.setText(null);
        nameField.setBackground(Color.white);
        pathField.setText(null);
        pathField.setBackground(Color.white);
      }
    }
    nameField.setBackground(Color.white);
    pathField.setBackground(Color.white);
  }