Exemple #1
1
  /**
   * Compute a logical, reasonably efficient join on the specified tables. See project description
   * for hints on how this should be implemented.
   *
   * @param stats Statistics for each table involved in the join, referenced by base table names,
   *     not alias
   * @param filterSelectivities Selectivities of the filter predicates on each table in the join,
   *     referenced by table alias (if no alias, the base table name)
   * @param explain Indicates whether your code should explain its query plan or simply execute it
   * @return A Vector<LogicalJoinNode> that stores joins in the left-deep order in which they should
   *     be executed.
   * @throws ParsingException when stats or filter selectivities is missing a table in the join, or
   *     or when another internal error occurs
   */
  public Vector<LogicalJoinNode> orderJoins(
      HashMap<String, TableStats> stats,
      HashMap<String, Double> filterSelectivities,
      boolean explain)
      throws ParsingException {

    // See the project writeup for some hints as to how this function
    // should work.

    // some code goes here
    PlanCache pc = new PlanCache();
    for (int i = 1; i <= joins.size(); i++) {
      Set<Set<LogicalJoinNode>> subsets = enumerateSubsets(joins, i);
      for (Set<LogicalJoinNode> subset : subsets) {
        CostCard best = new CostCard();
        best.cost = Double.MAX_VALUE;
        for (LogicalJoinNode node : subset) {
          CostCard subCard =
              computeCostAndCardOfSubplan(stats, filterSelectivities, node, subset, best.cost, pc);
          if (subCard != null) {
            if (subCard.cost < best.cost) best = subCard;
            pc.addPlan(subset, best.cost, best.card, best.plan);
          }
        }
      }
    }
    if (explain) printJoins(joins, pc, stats, filterSelectivities);
    HashSet<LogicalJoinNode> joinSet = new HashSet<LogicalJoinNode>();
    for (int i = 0; i < joins.size(); i++) {
      joinSet.add(joins.get(i));
    }
    Vector<LogicalJoinNode> order = pc.getOrder(joinSet);
    if (order != null) return order;
    return joins;
  }
 public void redrawTree(boolean doRepaint) {
   displayText = false;
   if (argument == null) return;
   if (argument.isMultiRoots()) {
     argument.deleteDummyRoot();
     argument.setMultiRoots(false);
   }
   TreeVertex root = null;
   Vector roots = argument.getTree().getRoots();
   if (roots.size() > 1) {
     if (argument.getDummyRoot() == null) {
       argument.addDummyRoot(roots);
     }
     root = argument.getDummyRoot();
   } else if (roots.size() == 1) {
     root = (TreeVertex) roots.firstElement();
   }
   // if root == null, the entire tree has been erased,
   // so call emptyTree() to clean things up and
   // clear the display
   if (root == null) {
     argument.emptyTree(false);
   } else {
     calcTreeShape(root);
   }
   if (doRepaint) {
     repaint();
   }
   /*
   if (displayFrame.getMainDiagramPanel() == this)
   {
     searchFrame.updateDisplays(false);
   }
    */
 }
Exemple #3
1
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
Exemple #4
1
  @Override
  public void run() {
    // TODO Auto-generated method stub
    while (true) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {
        // TODO: handle exception
      }
      //			判断每一粒子弹和每一辆敌人的坦克都是否有重合(击中)
      for (int i = 0; i < hero.bombs.size(); i++) {
        //				取出每个子弹
        Bomb myBomb = hero.bombs.get(i);
        //				子弹必须得存活才有判断的意义
        if (myBomb.isLive) {
          for (int j = 0; j < ets.size(); j++) {
            //						取出每辆坦克
            EnemyTank et = ets.get(j);
            if (et.isLive) {
              this.isHit(myBomb, et);
            }
          }
        }
      }

      this.repaint();
    }
  }
 /**
  * Return the graph items for this graph.
  *
  * @return the graph items for this graph.
  */
 public GraphItem[] getGraphItems() {
   GraphItem gia[] = new GraphItem[graphItems.size()];
   for (int i = 0; i < graphItems.size(); i++) {
     gia[i] = (GraphItem) graphItems.elementAt(i);
   }
   return gia;
 }
  private void doSave() {
    ObjectOutputStream objectStream = getObjectOutputStream();

    if (objectStream != null) {
      try {
        System.out.println("Saving " + selectedChildrenPaths.size() + " Selected Generations...");

        for (int i = 0; i < selectedChildrenPaths.size(); i++) {
          // Get the userObject at the supplied path
          Object selectedPath =
              ((TreePath) selectedChildrenPaths.elementAt(i)).getLastPathComponent();
          DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedPath;

          objectStream.writeObject(selectedNode.getUserObject());
        }

        objectStream.close();
        System.out.println("Save completed successfully.");
      } catch (IOException e) {
        System.err.println(e);
      }
    } else {
      System.out.println("Save Selected Files has been aborted!");
    }
  }
  /**
   * Constructs a <code>VariabilityRecordTable</code> with a list of variability records.
   *
   * @param record_list the list of variability records.
   * @param desktop the parent desktop.
   */
  public VariabilityRecordTable(Vector record_list, net.aerith.misao.gui.Desktop desktop) {
    this.record_list = record_list;
    this.desktop = desktop;

    index = new ArrayIndex(record_list.size());

    model = new DefaultTableModel(column_names, 0);
    Object[] objects = new Object[column_names.length];
    objects[0] = new Boolean(true);
    for (int i = 1; i < column_names.length; i++) objects[i] = "";
    for (int i = 0; i < record_list.size(); i++) model.addRow(objects);
    setModel(model);

    column_model = (DefaultTableColumnModel) getColumnModel();
    for (int i = 1; i < column_names.length; i++)
      column_model
          .getColumn(i)
          .setCellRenderer(
              new StringRenderer(column_names[i], LabelTableCellRenderer.MODE_MULTIPLE_SELECTION));

    initializeCheckColumn();

    setTableHeader(new TableHeader(column_model));

    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    initializeColumnWidth();

    pane = this;

    initPopupMenu();
  }
  /**
   * Adds nodes to the specified parent node recurrsively.
   *
   * @param parent_node the parent node.
   * @param list the list of child node names.
   */
  protected void addNode(DefaultMutableTreeNode parent_node, Vector list) {
    SortableArray array = null;

    if (mode == DATE_ORIENTED && parent_node.getLevel() <= 2) {
      array = new Array(list.size());

      for (int i = 0; i < list.size(); i++)
        ((Array) array).set(i, Integer.parseInt((String) list.elementAt(i)));
    } else {
      array = new StringArray(list.size());

      for (int i = 0; i < list.size(); i++)
        ((StringArray) array).set(i, (String) list.elementAt(i));
    }

    ArrayIndex index = array.sortAscendant();

    for (int i = 0; i < array.getArraySize(); i++) {
      String name = (String) list.elementAt(index.get(i));

      // Converts 1...12 to January...December.
      if (mode == DATE_ORIENTED && parent_node.getLevel() == 1) {
        int month = Integer.parseInt(name);
        name = JulianDay.getFullSpellMonthString(month);
      }

      DefaultMutableTreeNode node = new DefaultMutableTreeNode(name);
      parent_node.add(node);
    }
  }
 /** Get row count (part of table model interface) */
 public int getRowCount() {
   int count = data.size();
   if (filter_data != null) {
     count = filter_data.size();
   }
   return count;
 }
Exemple #10
0
  private void jButtonFindRemoteServicesActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonFindRemoteServicesActionPerformed
    jTextAreaStreamList.setText("");
    jTextAreaRemoteServices.setText("");

    String[] emptyList = {};
    DefaultComboBoxModel emptyDcbm = new DefaultComboBoxModel(emptyList);
    jComboBoxFileList.setModel(emptyDcbm);
    jComboBoxRemoteServices.setModel(emptyDcbm);

    try {
      int ttl = Integer.parseInt(jTextFieldTTL.getText());
      int timeout = Integer.parseInt(jTextFieldTimeout.getText());
      int serviceAmount = Integer.parseInt(jTextFieldServiceAmount.getText());
      availableServices = sc.findStreamService(ttl, timeout, serviceAmount);
      String text = "";
      String[] items = new String[availableServices.size()];
      for (int i = 0; i < availableServices.size(); i++) {
        text += availableServices.elementAt(i) + "\n";
        items[i] = "" + availableServices.elementAt(i);
      }
      jTextAreaRemoteServices.setText(text);
      DefaultComboBoxModel dcm = new DefaultComboBoxModel(items);
      jComboBoxRemoteServices.setModel(dcm);
    } catch (Exception e) {
      e.printStackTrace();
    }
  } // GEN-LAST:event_jButtonFindRemoteServicesActionPerformed
 public XmlUIElement getXmlElement(UserInput uiArg) {
   String type = "textfield";
   Qualifier qual = uiArg.getQualifier();
   String enumNames[] = null;
   String enumValues[] = null;
   if (qual != null) {
     type = qual.getType();
     Vector enumVec = qual.getEnums();
     if (enumVec.size() > 0) {
       enumNames = new String[enumVec.size()];
       enumValues = new String[enumVec.size()];
       for (int i = 0; i < enumNames.length; i++) {
         com.adventnet.management.config.xml.Enum e =
             (com.adventnet.management.config.xml.Enum) enumVec.elementAt(i);
         enumNames[i] = e.getName();
         enumValues[i] = e.getValue();
         if (enumNames[i] == null) {
           enumNames[i] = enumValues[i];
         }
       }
     }
   }
   XmlUIElement el = getXmlUIElementFor(type);
   if (el == null) {
     return null;
   }
   el.setDescription(uiArg.getDescription());
   if (enumNames != null) {
     el.setEnumeratedValues(enumNames, enumValues);
   }
   if ((qual != null) && (qual.getRange() != null) && (!(qual.getRange().equals("")))) {
     el.setRange(qual.getRange());
   }
   if (uiArg.getDefaultValue() != null) {
     el.setValue(uiArg.getDefaultValue());
   }
   String isEditable = uiArg.getAttribute("editable");
   if (isEditable != null) {
     if (isEditable.trim().equals("false")) {
       el.setEditable(false);
     } else {
       el.setEditable(true);
     }
   }
   String required = uiArg.getAttribute("required");
   {
     if (required.trim().equals("true")) {
       el.setRequired(true);
       numberOfRequiredFields++;
     } else {
       el.setRequired(false);
     }
   }
   el.setLabelName(uiArg.getLabel());
   return el;
 }
 /** Sets the pins list's contents with the given vector of PartPinInfo objects. */
 public void setContents(Vector newPins) {
   partPins = new PartPinInfo[newPins.size()];
   valuesStr = new String[newPins.size()];
   newPins.toArray(partPins);
   for (int i = 0; i < partPins.length; i++)
     valuesStr[i] = Format.translateValueToString(partPins[i].value, dataFormat);
   pinsTable.clearSelection();
   pinsTable.revalidate();
   repaint();
 }
Exemple #13
0
 public void setScheme(Subtree scheme) {
   this.scheme = scheme;
   cbList = new CheckBoxList();
   Vector<CQCheck> cqChecks = scheme.getCqChecks();
   checkBoxes = new JCheckBox[cqChecks.size()];
   for (int cq = 0; cq < cqChecks.size(); cq++) {
     CQCheck cqCheck = cqChecks.elementAt(cq);
     checkBoxes[cq] = new JCheckBox(cqCheck.getCqText());
     checkBoxes[cq].setSelected(cqCheck.isCqAnswered());
   }
   cbList.setListData(checkBoxes);
   cqScrollPane.setViewportView(cbList);
 }
 /** Add data to the table as a new row */
 public void addData(SOAPMonitorData soap) {
   int row = data.size();
   data.addElement(soap);
   if (filter_data != null) {
     if (filterMatch(soap)) {
       row = filter_data.size();
       filter_data.addElement(soap);
       fireTableRowsInserted(row, row);
     }
   } else {
     fireTableRowsInserted(row, row);
   }
 }
 /** Creates new form BookmarksDialog */
 public BookmarksDialog(java.awt.Frame parent, boolean modal, Timeline tl) {
   super(parent, modal);
   timeline = tl;
   initComponents();
   allBookmarks = tl.getAllBookmarks();
   for (int pos = 0; pos < allBookmarks.size(); pos++) {
     TimelineItem tli = (TimelineItem) (allBookmarks.elementAt(pos));
     bookmarksListModel.addElement(tli.getBookmark());
   }
   bookmarksList.setModel(bookmarksListModel);
   if (allBookmarks.size() > 0) {
     bookmarksList.setSelectedIndex(0);
   }
   Internationalizer.internationalizeDialogToolTips(this);
 }
  public void nick_name(String msg) {
    try {
      String name = msg.substring(13);
      this.setName(name);
      Vector v = father.onlineList;
      boolean isRepeatedName = false;
      int size = v.size();
      for (int i = 0; i < size; i++) {
        ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
        if (tempSat.getName().equals(name)) {
          isRepeatedName = true;
          break;
        }
      }
      if (isRepeatedName == true) {
        dout.writeUTF("<#NAME_REPEATED#>");
        din.close();
        dout.close();
        sc.close();
        flag = false;
      } else {
        v.add(this);
        father.refreshList();
        String nickListMsg = "";
        StringBuilder nickListMsgSb = new StringBuilder();
        size = v.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
          nickListMsgSb.append("!");
          nickListMsgSb.append(tempSat.getName());
        }
        nickListMsgSb.append("<#NICK_LIST#>");
        nickListMsg = nickListMsgSb.toString();
        Vector tempv = father.onlineList;
        size = tempv.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) tempv.get(i);
          tempSat.dout.writeUTF(nickListMsg);
          if (tempSat != this) {
            tempSat.dout.writeUTF("<#MSG#>" + this.getName() + "is now online....");
          }
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemple #17
0
  // returns the code for the header of the loop, not code for
  // the entire loop that it contains
  public String toCode() {
    String code;
    switch (type) {
      case LOOP_TYPE_REPETITIONS:
        code = "for " + numReps + " " + Utility.wordForm(numReps, "repetitions");

        if (!numWarmups.equals("0")) {
          code += " plus " + numWarmups + " warmup " + Utility.wordForm(numWarmups, "repetitions");
          if (sync) code += " and a synchronization";
        }
        return code;
      case LOOP_TYPE_FOR_EACH:
        code = "for each " + sequenceName + " in ";
        for (int i = 0; i < sequences.size(); i++) {
          String sequence = (String) sequences.elementAt(i);
          if (i > 0) code += ", ";
          code += "{" + sequence + "}";
        }
        return code;
      case LOOP_TYPE_TIMED:
        code = "for " + time + " " + Utility.wordForm(time, timeUnits);
        return code;
      default:
        assert false;
        return "";
    }
  }
Exemple #18
0
  public String toString() {

    StringBuffer st = new StringBuffer();

    st.append(" Cut Panels: ");
    for (int i = 0; i < visibleViewIds.size(); i++) {
      st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]);
    }
    st.append(" \nCutPanelSize: ");
    st.append(cutPanelSize);
    st.append(" \nlonReference: ");
    st.append(lonReference);
    st.append(" \ngeoDisplayFormat: ");
    st.append(geoDisplayFormat);
    st.append(" \nuseCenterWidthOrMinMax: ");
    st.append(useCenterWidthOrMinMax);
    st.append(" \ntimeDisplayFormat: ");
    st.append(timeDisplayFormat);
    st.append(" \ntimeAxisMode:  ");
    st.append(timeAxisMode);
    st.append(" \ntimeAxisReference:  ");
    st.append(timeAxisReference);
    st.append(" \ntimeSinceUnits:  ");
    st.append(timeSinceUnits);
    st.append(" \ndisplayPanelAxes:  ");
    st.append(displayPanelAxes);
    st.append(" \nindependentHandles:  ");
    st.append(independentHandles);
    return st.toString();
  }
Exemple #19
0
  public Properties internalToProperties() {
    Properties props = new Properties();

    StringBuffer st = new StringBuffer();
    st.append(" ");
    for (int i = 0; i < visibleViewIds.size(); i++) {
      st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]);
    }
    // System.out.println(" visibleViewIds: " + st.toString());

    props.setProperty("ndedit.visibleViewIds", st.toString());

    props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString()));
    props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString()));
    props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString()));
    props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString()));
    props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString()));
    props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString()));
    props.setProperty("ndedit.lonReference", (new Double(lonReference).toString()));
    props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString()));
    props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString()));
    props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString()));
    props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString()));
    String dpa = new Boolean(displayPanelAxes).toString();
    props.setProperty("ndedit.displayPanelAxes", dpa);
    dpa = new Boolean(independentHandles).toString();
    props.setProperty("ndedit.independentHandles", dpa);
    return props;
  }
    public void paintComponent(Graphics g) {
      g.setColor(new Color(96, 96, 96));
      image.paintIcon(this, g, 1, 1);

      FontMetrics fm = g.getFontMetrics();

      String[] args = {jEdit.getVersion()};
      String version = jEdit.getProperty("about.version", args);
      g.drawString(version, (getWidth() - fm.stringWidth(version)) / 2, getHeight() - 5);

      g = g.create((getWidth() - maxWidth) / 2, TOP, maxWidth, getHeight() - TOP - BOTTOM);

      int height = fm.getHeight();
      int firstLine = scrollPosition / height;

      int firstLineOffset = height - scrollPosition % height;
      int lines = (getHeight() - TOP - BOTTOM) / height;

      int y = firstLineOffset;

      for (int i = 0; i <= lines; i++) {
        if (i + firstLine >= 0 && i + firstLine < text.size()) {
          String line = (String) text.get(i + firstLine);
          g.drawString(line, (maxWidth - fm.stringWidth(line)) / 2, y);
        }
        y += fm.getHeight();
      }
    }
  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);
  }
 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);
   }
 }
 public void setValueAt(Object value, int row, int col) {
   if (rowData.size() > row && row >= 0) {
     Object[] data = (Object[]) rowData.get(row);
     data[col] = value;
   }
   fireTableCellUpdated(row, col);
 }
    public void actionPerformed(java.awt.event.ActionEvent arg0) {

      if (JTable1.getSelectedRowCount() != 1) {

        Utilities.errorMessage(resourceBundle.getString("Please select a view to edit"));
        return;
      }

      views = new ViewsWizard(ViewConfig.this, applet);
      views.setSecurityModel(model);
      Point p = JLabel1.getLocationOnScreen();
      views.setLocation(p);
      views.init();

      views.setState(false);
      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          views.setValues((AuthViewWithOperations) viewvec.elementAt(i));
        }
      }

      disableButtons();
      views.setVisible(true);
    }
    public void actionPerformed(java.awt.event.ActionEvent arg0) {
      if (JTable1.getSelectedRowCount() != 1) {
        Utilities.errorMessage(resourceBundle.getString("Please select a view to delete"));
        return;
      }

      if (JOptionPane.showConfirmDialog(
              null,
              resourceBundle.getString("Are you sure you want to delete the selected view "),
              resourceBundle.getString("Warning!"),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE,
              null)
          == JOptionPane.NO_OPTION) return;

      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i);

          model.delViewOp(
              avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations());
        }
      }

      disableButtons();
    }
  public String toString() {
    StringBuffer b = new StringBuffer();
    b.append("ID:" + id);
    b.append("\tName:" + name);
    b.append("\tSex:" + sex + "\n");
    b.append("\tAffected:" + affection + "\n");

    if (mother == null) {
      b.append("\tMother: null");
    } else {
      b.append("\tMother:" + mother.id);
    }

    if (father == null) {
      b.append("\tFather: null");
    } else {
      b.append("\tFather:" + father.id);
    }

    b.append("\tChildren:");
    Vector<PelicanPerson> children = getChildren();
    if (children.size() > 0) {
      Iterator<PelicanPerson> it = children.iterator();
      while (it.hasNext()) {
        PelicanPerson p = it.next();
        b.append(p.id + ",");
      }
      b.deleteCharAt(b.length() - 1);
    } else {
      b.append("none");
    }
    b.append("\n");
    return b.toString();
  }
Exemple #27
0
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
 private void moveUpAndDownPage(boolean _up) {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   Editor page = pageList.get(index);
   if (page == null) return;
   if (_up) {
     if (index == 0) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index - 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index - 1);
   } else {
     if (index == (pageList.size() - 1)) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index + 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index + 1);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   changed = true;
 }
 protected void addPage(String _typeOfPage, String _name, String _code, boolean _enabled) {
   cardLayout.show(finalPanel, "TabbedPanel");
   _name = getUniqueName(_name);
   Editor page = createPage(_typeOfPage, _name, _code);
   page.setFont(myFont);
   page.setColor(myColor);
   int index = tabbedPanel.getSelectedIndex();
   if (index == -1) {
     pageList.addElement(page);
     if (tabbedPanel.getTabCount() == 0) {
       tabbedPanel.addTab(
           page.getName(),
           null,
           page.getComponent(),
           tooltip); // This causes an exception sometimes
     } else {
       tabbedPanel.insertTab(
           page.getName(), null, page.getComponent(), tooltip, tabbedPanel.getTabCount());
     }
     index = 0;
   } else {
     index++;
     pageList.insertElementAt(page, index);
     tabbedPanel.insertTab(page.getName(), null, page.getComponent(), tooltip, index);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   page.setActive(_enabled);
   if (!_enabled) tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   updatePageCounterField(pageList.size());
   // tabbedPanel.validate(); This hangs the computer when reading a file at start-up !!!???
   tabbedPanel.repaint();
   changed = true;
 }
Exemple #30
0
  // get the caption for the loop's visual representation
  // the caption is an abbreviated form of the code
  // the caption appears in the upper-left corner of the loop
  public String getCaption() {
    String caption = "";
    switch (type) {
      case LOOP_TYPE_REPETITIONS:
        if (!numWarmups.equals("0")) {
          caption += numWarmups + " " + Utility.wordForm(numWarmups, "warmups") + " + ";
          if (sync) caption += "sync + ";
        }
        caption += numReps + " " + Utility.wordForm(numReps, "reps");
        return caption;
      case LOOP_TYPE_FOR_EACH:
        caption = sequenceName + " in ";
        for (int i = 0; i < sequences.size(); i++) {
          String sequence = (String) sequences.elementAt(i);
          if (i > 0) caption += ", ";
          caption += "{" + sequence + "}";
        }

        return caption;
      case LOOP_TYPE_TIMED:
        return toCode();
      default:
        assert false;
        return "";
    }
  }