public void changeLAF(int iLAFIndex) {
    try {
      // Change LAF
      if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1;
      UIManager.setLookAndFeel(
          (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance());

      // Update UI
      ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true);
      SwingUtilities.updateComponentTreeUI(this);
      SwingUtilities.updateComponentTreeUI(mnuMain);
      WindowManager.updateLookAndField();

      // Store config
      try {
        Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG);
        prt.put("LAF", String.valueOf(iLAFIndex));
        Global.storeHashtable(prt, Global.FILE_CONFIG);
      } catch (Exception e) {
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
  public void unregisterKeyStroke(KeyStroke ks, JComponent c) {

    // component may have already been removed from the hierarchy, we
    // need to look up the container using the componentKeyStrokeMap.

    ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c, ks);

    Container topContainer = componentKeyStrokeMap.get(ckp);

    if (topContainer == null) { // never heard of this pairing, so bail
      return;
    }

    Hashtable keyMap = containerMap.get(topContainer);
    if (keyMap == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    Object tmp = keyMap.get(ks);
    if (tmp == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    if (tmp instanceof JComponent && tmp == c) {
      keyMap.remove(ks); // remove the KeyStroke from the Map
      // System.out.println("removed a stroke" + ks);
    } else if (tmp
        instanceof Vector) { // this means there is more than one component reg for this key
      Vector v = (Vector) tmp;
      v.removeElement(c);
      if (v.isEmpty()) {
        keyMap.remove(ks); // remove the KeyStroke from the Map
        // System.out.println("removed a ks vector");
      }
    }

    if (keyMap.isEmpty()) { // if no more bindings in this table
      containerMap.remove(topContainer); // remove table to enable GC
      // System.out.println("removed a container");
    }

    componentKeyStrokeMap.remove(ckp);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).unregisterAccelerator(ks);
    }
  }
Beispiel #3
1
  /**
   * Called to initialize the outline by setting the top level bookmark.
   *
   * @param bookmark top level bookmark.
   */
  public void setFirstBookmark(final Bookmark bookmark) {
    final Vector activeVector = getActiveVector();

    synchronized (activeVector) {
      final Hashtable parentMap = getParentMap();
      parentMap.clear();

      final Vector pagenoVector = getPagenoVector();
      pagenoVector.setSize(0);
      getDepthMap().clear();
      mapChildren(bookmark, parentMap, pagenoVector, new Integer(0));
      activeVector.setSize(0);
      activeVector.addElement(bookmark);
      setCheckedItem(0, true);
    }
  }
 public void removeUser(String strChannel) {
   Vector vtData = tblUser.getFilteredData();
   for (int iIndex = 0; iIndex < vtData.size(); iIndex++) {
     Vector vtRow = (Vector) vtData.elementAt(iIndex);
     if (vtRow.elementAt(0).equals(strChannel)) tblUser.deleteRow(iIndex);
   }
 }
Beispiel #5
0
  /**
   * Called to create a map the parent of each bookmark.
   *
   * @param parent top level bookmark.
   * @param parentMap map to add children to.
   * @param pagenoVector vector of page numbers.
   * @param depth object indicating bookmark depth.
   */
  protected void mapChildren(
      final Bookmark parent,
      final Hashtable parentMap,
      final Vector pagenoVector,
      final Number depth) {
    getDepthMap().put(parent, depth);

    final int pageno = parent.getPageno();

    if (pageno >= 0) {
      while (pageno >= pagenoVector.size()) {
        pagenoVector.addElement(null);
      }

      pagenoVector.setElementAt(parent, pageno);
    }

    final Enumeration e = parent.elements();

    if (e.hasMoreElements()) {
      final Number childDepth = new Integer(depth.intValue() + 1);

      do {
        final Bookmark child = (Bookmark) e.nextElement();
        parentMap.put(child, parent);
        mapChildren(child, parentMap, pagenoVector, childDepth);
      } while (e.hasMoreElements());
    }
  }
  public void changeDictionary(String strLanguage) {
    // Change dictionary
    MonitorDictionary.setCurrentLanguage(strLanguage);
    DefaultDictionary.setCurrentLanguage(strLanguage);
    ErrorDictionary.setCurrentLanguage(strLanguage);

    // Update UI
    updateLanguage();
    WindowManager.updateLanguage();
    int iIndex = mvtLanguage.indexOf(strLanguage);
    if (iIndex >= 0) {
      JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex);
      mnu.setSelected(true);
    }

    // Store config
    Hashtable prt = null;
    try {
      prt = Global.loadHashtable(Global.FILE_CONFIG);
    } catch (Exception e) {
      prt = new Hashtable();
    }
    prt.put("Language", strLanguage);
    try {
      Global.storeHashtable(prt, Global.FILE_CONFIG);
    } catch (Exception e) {
    }
  }
 public Object clone() {
   FigForkState figClone = (FigForkState) super.clone();
   Vector v = figClone.getFigs();
   figClone._bigPort = (FigRect) v.elementAt(0);
   figClone._head = (FigRect) v.elementAt(1);
   return figClone;
 }
Beispiel #8
0
  @Override
  public void valueChanged(TreeSelectionEvent e) {
    if (e.getSource() == colors && !locked) {
      TreeSelectionModel tsm = colors.getSelectionModel();
      TreePath tp[] = tsm.getSelectionPaths();
      if (tp == null) return;
      Vector<ClassedItem> tmp = new Vector<ClassedItem>();
      for (TreePath element : tp) {
        try {
          Object[] path = element.getPath();
          ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString());
          tmp.add(ci);
        } catch (Exception exp) {
          // User did not select a leafnode
        }
      }

      if (sceneElement instanceof NenyaImageSceneElement) {
        ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaTileSceneElement) {
        ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaComponentSceneElement) {
        ((NenyaComponentSceneElement) sceneElement)
            .getComponents()[itemList.getSelectedIndex()].setColorList(
                tmp.toArray(new ClassedItem[0]));
      }

      submitElement(sceneElement, null);
    } else {
      super.valueChanged(e);
    }
  }
Beispiel #9
0
  /**
   * Get the specified bookmark.
   *
   * @param item the row number of the bookmark to retrieve.
   * @return the specified bookmark.
   */
  public Bookmark getBookmark(final int item) {
    final Vector activeVector = getActiveVector();

    synchronized (activeVector) {
      return (Bookmark) ((item < activeVector.size()) ? activeVector.elementAt(item) : null);
    }
  }
Beispiel #10
0
 public Object clone() {
   FigUseCase figClone = (FigUseCase) super.clone();
   Vector v = figClone.getFigs();
   figClone._bigPort = (FigCircle) v.elementAt(0);
   figClone._cover = (FigCircle) v.elementAt(1);
   figClone._name = (FigText) v.elementAt(2);
   return figClone;
 }
 public Object clone() {
   FigShallowHistoryState figClone = (FigShallowHistoryState) super.clone();
   Vector v = figClone.getFigs();
   figClone._bigPort = (FigCircle) v.elementAt(0);
   figClone._head = (FigCircle) v.elementAt(1);
   figClone._name = (FigText) v.elementAt(2);
   return figClone;
 }
 // -------------------------------------------
 public static String toSpaceSeparatedString(Vector v) {
   StringBuffer sb = new StringBuffer(30);
   for (int i = 0; i < v.size(); i++) {
     Object o = v.elementAt(i);
     sb.append(" " + o); // NOI18N
   }
   return new String(sb);
 }
Beispiel #13
0
  /**
   * Set the checked property of the specified bookmark.
   *
   * @param item the row number of the bookmark to check or uncheck.
   * @param checked true if checked.
   */
  public void setCheckedItem(final int item, final boolean checked) {
    final Vector activeVector = getActiveVector();

    synchronized (activeVector) {
      if (item < activeVector.size()) {
        setCheckedItem(item, checked, activeVector);
      }
    }
  }
Beispiel #14
0
  @Override
  public void adoptElement(SceneElement elem) {
    if (!(elem instanceof NenyaImageSceneElement
        || elem instanceof NenyaTileSceneElement
        || elem instanceof NenyaComponentSceneElement)) {
      enableEditor(false);
      return;
    }

    DefaultComboBoxModel dcm = (DefaultComboBoxModel) itemList.getModel();

    // Important: Work on a copy, not on the original. Otherwise we mess up the undomanager
    sceneElement = elem.copy();

    if ((sceneElement instanceof NenyaImageSceneElement) && !locked) {
      dcm.removeAllElements();
      String[] tmp = ((NenyaImageSceneElement) sceneElement).getPath();
      dcm.addElement(tmp[tmp.length - 1]);
    }
    if ((sceneElement instanceof NenyaTileSceneElement) && !locked) {
      dcm.removeAllElements();
      dcm.addElement(((NenyaTileSceneElement) sceneElement).getTileName());
    }
    if ((sceneElement instanceof NenyaComponentSceneElement) && !locked) {
      dcm.removeAllElements();
      NenyaComponentItem[] ni = ((NenyaComponentSceneElement) sceneElement).getComponents();
      for (NenyaComponentItem element : ni) {
        dcm.addElement(element);
      }
    }

    try {
      ClassedItem[] cols = null;
      if (elem instanceof NenyaTileSceneElement)
        cols = ((NenyaTileSceneElement) elem).getColorList();
      if (elem instanceof NenyaImageSceneElement)
        cols = ((NenyaImageSceneElement) elem).getColorList();
      if (elem instanceof NenyaComponentSceneElement) {
        NenyaComponentItem nci = (NenyaComponentItem) dcm.getSelectedItem();
        cols = nci.getColorList();
      }
      Vector<TreePath> collect = new Vector<TreePath>();
      TreeNode root = (TreeNode) colors.getModel().getRoot();
      for (ClassedItem col : cols) {
        String[] tmp = {root.toString(), col.getClassName(), col.getItemName()};
        collect.add(TreeUtil.findPath(root, tmp));
      }
      TreePath[] path = collect.toArray(new TreePath[0]);
      colors.getSelectionModel().setSelectionPaths(path);
    } catch (Exception e) {
      // Either the tree is filtered away or the selected item is not colorized.
    }

    enableEditor(true);
    itemList.setEnabled(elem instanceof NenyaComponentSceneElement);
  }
 public void addUser(
     String strChannel, String strUserName, String strConnectDate, String strHost) {
   if (strChannel.equals(mstrChannel)) return;
   removeUser(strChannel);
   Vector vtData = new Vector();
   vtData.addElement(strChannel);
   vtData.addElement(strUserName);
   vtData.addElement(strConnectDate);
   vtData.addElement(strHost);
   tblUser.addRow(vtData);
 }
 public Vector rowObjectsFor(Object t) {
   if (!(t instanceof UMLDeploymentDiagram)) return new Vector();
   UMLDeploymentDiagram d = (UMLDeploymentDiagram) t;
   Vector edges = d.getEdges();
   Vector res = new Vector();
   int size = edges.size();
   for (int i = 0; i < size; i++) {
     Object edge = edges.elementAt(i);
     if (edge instanceof MDependencyImpl) res.addElement(edge);
   }
   return res;
 }
 public void setNode(Vector figures) {
   int size = figures.size();
   if (figures != null && (size > 0)) {
     for (int i = 0; i < size; i++) {
       Object o = figures.elementAt(i);
       if (o instanceof FigComponentInstance) {
         FigComponentInstance figcomp = (FigComponentInstance) o;
         figcomp.setEnclosingFig(this);
       }
     }
   }
 }
 private static void appendHTML(JEditorPane editor, String html) {
   try {
     html = StringUtil.replaceAll(html, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
     html = StringUtil.replaceAll(html, "\r\n", "\n");
     html = StringUtil.replaceAll(html, "\r", "");
     Vector vt = StringUtil.toStringVector(html, "\n");
     HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
     HTMLDocument doc = (HTMLDocument) editor.getDocument();
     for (int iIndex = 0; iIndex < vt.size(); iIndex++)
       kit.insertHTML(doc, doc.getLength(), (String) vt.elementAt(iIndex), 0, 0, null);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Beispiel #19
0
  /**
   * Called to check any bookmarks linked to the specified page number.
   *
   * @param pageno specifies page number.
   */
  public void setCheckedPage(final int pageno) {
    final Vector activeVector = getActiveVector();

    synchronized (activeVector) {
      final Vector pagenoVector = getPagenoVector();

      if (pageno < pagenoVector.size()) {
        final Object bookmark = pagenoVector.elementAt(pageno);

        if (bookmark != null) {
          setCheckedBookmark((Bookmark) bookmark, activeVector);
        }
      }
    }
  }
  private void updateTabBar(Vector vtThread) {
    pnlThread.removeAll();
    for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) {
      try {
        Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex);
        PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel);

        String strThreadID = (String) vtThreadInfo.elementAt(0);
        String strThreadName = (String) vtThreadInfo.elementAt(1);
        int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2));
        mntTemp.setThreadID(strThreadID);
        mntTemp.setThreadName(strThreadName);
        mntTemp.setThreadStatus(iThreadStatus);
        showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3));
        mntTemp.addPropertyChangeListener(this);

        pnlThread.add(strThreadName, mntTemp);
        mntTemp.updateStatus();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
      }
    }
    Skin.applySkin(this);
  }
Beispiel #21
0
  /**
   * Query if the specified bookmark is checked.
   *
   * @param item row number of the bookmark to query.
   * @return true if the specified bookmark is checked.
   */
  public boolean isCheckedItem(final int item) {
    boolean retval = false;
    final Vector activeVector = getActiveVector();

    synchronized (activeVector) {
      if ((item + 1) < activeVector.size()) {
        final Bookmark bookmark = getBookmark(item);

        if (bookmark.size() > 0) {
          final Bookmark next = getBookmark(item + 1);
          final Bookmark child = (Bookmark) bookmark.elementAt(0);
          retval = (next == child);
        }
      }
    }

    return retval;
  }
Beispiel #22
0
 public void unregisterMenuBar(JMenuBar mb) {
   Container topContainer = getTopAncestor(mb);
   if (topContainer == null) {
     return;
   }
   Hashtable keyMap = containerMap.get(topContainer);
   if (keyMap != null) {
     Vector v = (Vector) keyMap.get(JMenuBar.class);
     if (v != null) {
       v.removeElement(mb);
       if (v.isEmpty()) {
         keyMap.remove(JMenuBar.class);
         if (keyMap.isEmpty()) {
           // remove table to enable GC
           containerMap.remove(topContainer);
         }
       }
     }
   }
 }
Beispiel #23
0
  /**
   * Set the checked value of the specified bookmark.
   *
   * @param bookmark to check.
   * @param activeVector of active bookmarks.
   * @return the row number of the bookmark.
   */
  protected int setCheckedBookmark(final Bookmark bookmark, final Vector activeVector) {
    final Bookmark parent = (Bookmark) (getParentMap().get(bookmark));
    int item = 0;

    if (parent != null) {
      item = setCheckedBookmark(parent, activeVector);
    }

    while (item < activeVector.size()) {
      final Bookmark current = (Bookmark) activeVector.elementAt(item++);

      if (current == bookmark) {
        setCheckedItem(item - 1, true, activeVector);

        break;
      }
    }

    return item;
  }
 public Object clone() {
   FigActor figClone = (FigActor) super.clone();
   Vector v = figClone.getFigs();
   figClone._bigPort = (FigCircle) v.elementAt(0);
   figClone._head = (FigCircle) v.elementAt(1);
   figClone._body = (FigLine) v.elementAt(2);
   figClone._arms = (FigLine) v.elementAt(3);
   figClone._leftLeg = (FigLine) v.elementAt(4);
   figClone._rightLeg = (FigLine) v.elementAt(5);
   figClone._name = (FigText) v.elementAt(6);
   return figClone;
 }
  /**
   * decide which cursor to use (based on text string)
   *
   * @param highlighterName
   */
  public void setCurrentHighlighter(String highlighterName) {
    SWTPlotHighlighter newCursor = null;
    for (Iterator<SWTPlotHighlighter> thisHighlighter = _myHighlighterList.iterator();
        thisHighlighter.hasNext(); ) {
      SWTPlotHighlighter thisP = (SWTPlotHighlighter) thisHighlighter.next();
      if (thisP.getName().equals(highlighterName)) {
        newCursor = thisP;
        break;
      }
    }

    // cool. did we find one?
    if (newCursor != null) setCurrentHighlighter(newCursor);
  }
Beispiel #26
0
  public void registerMenuBar(JMenuBar mb) {
    Container top = getTopAncestor(mb);
    if (top == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(top);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(top);
    }
    // use the menubar class as the key
    Vector menuBars = (Vector) keyMap.get(JMenuBar.class);

    if (menuBars == null) { // if we don't have a list of menubars,
      // then make one.
      menuBars = new Vector();
      keyMap.put(JMenuBar.class, menuBars);
    }

    if (!menuBars.contains(mb)) {
      menuBars.addElement(mb);
    }
  }
  /**
   * decide which cursor to use (based on text string)
   *
   * @param cursorName
   */
  public void setCurrentPainter(String cursorName) {
    TemporalLayerPainter newCursor = null;
    for (Iterator<TemporalLayerPainter> thisPainter = _myPainterList.iterator();
        thisPainter.hasNext(); ) {
      TemporalLayerPainter thisP = (TemporalLayerPainter) thisPainter.next();
      if (thisP.getName().equals(cursorName)) {
        newCursor = thisP;
        break;
      }
    }

    // cool. did we find one?
    if (newCursor != null) setCurrentPainter(newCursor);
  }
Beispiel #28
0
  /**
   * Check bookmark at the specified row number.
   *
   * @param item row number.
   * @param checked true if checked.
   * @param activeVector vector of active bookmarks.
   */
  protected void setCheckedItem(final int item, final boolean checked, final Vector activeVector) {
    final Bookmark bookmark = getBookmark(item);

    if (bookmark.size() > 0) {
      final Enumeration e = bookmark.elements();
      int i = item + 1;

      if (e.hasMoreElements()) {
        if (checked) {
          do {
            final Bookmark child = (Bookmark) e.nextElement();
            final Bookmark next = getBookmark(i);

            if (next == child) {
              break;
            }

            activeVector.insertElementAt(child, i++);
          } while (e.hasMoreElements());
        } else {
          do {
            final Bookmark child = (Bookmark) e.nextElement();
            final Bookmark next = getBookmark(i);

            if (next != child) {
              break;
            }

            setCheckedItem(i, false);
            activeVector.removeElementAt(i);
          } while (e.hasMoreElements());
        }
      }

      repaint(20L);
    }
  }
  /**
   * constructor - to collate the list
   *
   * @param dataProvider
   */
  public LayerPainterManager(TrackDataProvider dataProvider) {
    super(dataProvider);

    // and now build the painters
    _myPainterList = new Vector<TemporalLayerPainter>(0, 1);
    _myPainterList.add(new PlainHighlighter());
    _myPainterList.add(new SnailHighlighter(dataProvider));

    setCurrentPainter((TemporalLayerPainter) _myPainterList.firstElement());

    // and the plot highlighters
    _myHighlighterList = new Vector<SWTPlotHighlighter>(0, 1);
    _myHighlighterList.add(new SWTPlotHighlighter.RectangleHighlight());
    _myHighlighterList.add(new SWTSymbolHighlighter());
    _myHighlighterList.add(new SWTRangeHighlighter());
    _myHighlighterList.add(new NullHighlighter());

    // and sort out the defaults
    _currentPainter = _myPainterList.firstElement();
    _currentHighlighter = _myHighlighterList.firstElement();
  }
  public Object clone() {
    FigComponentInstance figClone = (FigComponentInstance) super.clone();
    Vector v = figClone.getFigs();
    figClone._bigPort = (FigRect) v.elementAt(0);
    figClone._cover = (FigRect) v.elementAt(1);
    figClone._stereo = (FigText) v.elementAt(2);
    figClone._name = (FigText) v.elementAt(3);
    figClone._upperRect = (FigRect) v.elementAt(4);
    figClone._lowerRect = (FigRect) v.elementAt(5);

    return figClone;
  }