protected void initInsuranceProviders() {
   p1 =
       CC.get()
           .identity()
           .create(system, "+1 555-240-1111", "UAP Insurance", IdentityType.InsuranceProvider);
   p2 =
       CC.get()
           .identity()
           .create(system, "+1 555-240-1112", "Lloyd's of London", IdentityType.InsuranceProvider);
 }
 public void disconnect() {
   try {
     if (getSocket() != null) getSocket().close();
   } catch (Exception x) {
     CC.getLogger().info(HF.getErrorMessage(x));
   }
 }
  protected void initStations() {

    // setup some measurement stations
    msNairobi =
        CC.get()
            .identity()
            .create(system, "+1 555-444-1111", "Nairobi Station", IdentityType.MeasurementStation);
    msNakuru =
        CC.get()
            .identity()
            .create(system, "+1 555-444-1112", "Nakuru Station", IdentityType.MeasurementStation);
    msMombasa =
        CC.get()
            .identity()
            .create(system, "+1 555-444-1113", "Mombasa Station", IdentityType.MeasurementStation);
  }
  /**
   * Builds and returns a wizard button bar. It consists of some left aligned buttons, the back,
   * next group, and some right aligned buttons. To allow the finish button to overlay the next
   * button, you can optionally provide the <code>overlayedFinish</code> parameter.
   *
   * @param leftAlignedButtons an optional array of buttons that will be positioned in the bar's
   *     left hand side
   * @param back the mandatory back button
   * @param next the mandatory next button
   * @param overlaidFinish the optional overlaid finish button
   * @param rightAlignedButtons an optional array of buttons that will be located in the bar's right
   *     hand side
   * @return a wizard button bar with back, next and a bunch of buttons
   */
  public static JPanel buildWizardBar(
      JButton[] leftAlignedButtons,
      JButton back,
      JButton next,
      JButton overlaidFinish,
      JButton[] rightAlignedButtons) {

    MyButtonBarBuilder2 builder = new MyButtonBarBuilder2();
    if (leftAlignedButtons != null) {
      builder.addButton(leftAlignedButtons);
      builder.addRelatedGap();
    }
    builder.addGlue();
    builder.addButton(back);
    builder.addButton(next);

    // Optionally overlay the finish and next button.
    if (overlaidFinish != null) {
      builder.getPanel().add(overlaidFinish, CC.xy(builder.getColumn(), 1));
    }

    if (rightAlignedButtons != null) {
      builder.addRelatedGap();
      builder.addButton(rightAlignedButtons);
    }
    return builder.getPanel();
  }
    @Override
    public void run() {
      while (!mustTerminate()) {
        try {
          processInput();
        } catch (Exception x) {
          CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
        }

        try {
          synchronized (this) {
            wait(100);
          }
        } catch (Exception x) {
          CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
        }
      }
    }
  protected void initVendors() {

    // setup some vendors
    v1 = CC.get().identity().create(system, "+1 555-121-1111", "Mark's Seeds", IdentityType.Vendor);
    v2 = CC.get().identity().create(system, "+1 555-121-1112", "John's Seeds", IdentityType.Vendor);
    v3 =
        CC.get()
            .identity()
            .create(system, "+1 555-121-1113", "Smith's Fertilizer", IdentityType.Vendor);
    v4 =
        CC.get()
            .identity()
            .create(system, "+1 555-121-1114", "Thompson Chemicals", IdentityType.Vendor);
    v5 =
        CC.get()
            .identity()
            .create(system, "+1 555-121-1115", "General Farm Supplies", IdentityType.Vendor);
  }
 /*
  * Writes a line.
  * @param line a string to be written.
  */
 public void writeLine(String line) throws IOException {
   try {
     out.write(line.getBytes("US-ASCII"));
     out.write('\r');
     out.write('\n');
     out.flush();
   } catch (UnsupportedEncodingException x) {
     CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
   }
 }
  /** Creates a new instance of <code>DefaultLSConsoleModel</code>. */
  public DefaultLSConsoleModel() {
    CC.addReconnectListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            reconnect();
          }
        });

    lsConsoleThread.start();
  }
 // as of JDK 1.6: @Override
 public void paintDebugOutline() {
   ComponentWrapper lComponentWrapper = nodeToComponentWrapperMap.get(node);
   CC lCC = fx2ComponentWrapperToCCMap.get(lComponentWrapper);
   if (lCC != null && lCC.isExternal()) {
     addDebugRectangle(
         this.node.getLayoutX() + this.node.getLayoutBounds().getMinX(),
         (double) this.node.getLayoutY() + this.node.getLayoutBounds().getMinY(),
         getWidth(),
         getHeight(),
         DebugRectangleType.EXTERNAL); // always draws node size, even if less is used
   } else {
     addDebugRectangle(
         this.node.getLayoutX() + this.node.getLayoutBounds().getMinX(),
         (double) this.node.getLayoutY() + this.node.getLayoutBounds().getMinY(),
         getWidth(),
         getHeight(),
         DebugRectangleType.OUTLINE); // always draws node size, even if less is used
   }
 }
  private void reconnect() {
    final LSConsoleConnect cnt = new LSConsoleConnect(getSocket());

    cnt.addTaskListener(
        new TaskListener() {
          public void taskPerformed(TaskEvent e) {
            changeSocket(cnt.getResult());
          }
        });

    CC.getTaskQueue().add(cnt);
  }
  private void changeSocket(Socket sock) {
    setSocket(sock);

    try {
      LscpInputStream in;
      in = sock == null ? null : new LscpInputStream(sock.getInputStream());
      out = sock == null ? null : new LscpOutputStream(sock.getOutputStream());

      lsConsoleThread.setInputStream(in);
    } catch (Exception x) {
      CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
    }
  }
  protected void initCustomers() {

    // setup some customers
    c1 =
        CC.get()
            .identity()
            .create(system, "+1 555-231-1111", "John Michaels", IdentityType.Customer);
    c2 =
        CC.get()
            .identity()
            .create(system, "+1 555-231-1112", "Bart Simpson", IdentityType.Customer);
    c3 =
        CC.get()
            .identity()
            .create(system, "+1 555-231-1113", "Dale Barnsworth", IdentityType.Customer);
    c4 =
        CC.get()
            .identity()
            .create(system, "+1 555-231-1114", "Deeshawn Anders", IdentityType.Customer);
    c5 =
        CC.get()
            .identity()
            .create(system, "+1 555-231-1115", "Harold Macaulay", IdentityType.Customer);
  }
  protected void convertToNode(
      CC conversionContext,
      Object unmarshalledNode,
      String modelId,
      Document document,
      Node parentNode)
      throws DOMException {

    // To use our existing model, first we need childResults.
    // We get these using a new Generator object.
    log.debug(modelId);

    DocumentFragment childResults = null;
    if (unmarshalledNode instanceof ContentAccessor) {
      childResults = document.createDocumentFragment();
      AbstractVisitorExporterGenerator<CC> generator =
          getFactory().createInstance(conversionContext, document, childResults);
      new TraversalUtil(((ContentAccessor) unmarshalledNode).getContent(), generator);

    } else if (unmarshalledNode instanceof org.docx4j.wml.Pict) {
      // if it contains a textbox..

      // repeating this...
      org.docx4j.vml.CTTextbox textBox = getTextBox((org.docx4j.wml.Pict) unmarshalledNode);

      if (textBox != null) {

        childResults = document.createDocumentFragment();
        AbstractVisitorExporterGenerator<CC> generator =
            getFactory().createInstance(conversionContext, document, childResults);
        new TraversalUtil(textBox.getTxbxContent().getContent(), generator);
      }
    }

    Node resultNode =
        conversionContext
            .getWriterRegistry()
            .toNode(conversionContext, unmarshalledNode, modelId, childResults, document);

    if (resultNode != null) {
      log.debug("Appending " + XmlUtils.w3CDomNodeToString(resultNode));
      parentNode.appendChild(resultNode);
    }
  }
  /** Executes the command specified in the command line. */
  @Override
  public void execCommand() {
    String cmd = getCommandLineText();
    sessionHistory.add(cmd);
    if (cmd.trim().length() > 0 && !cmd.startsWith("#")) addToCommandHistory(cmd);
    while (cmdHistory.size() > getCommandHistorySize()) cmdHistory.removeFirst();

    setCommandLineText("");
    currentCmd = "";
    cmdHistoryIdx = -1;

    if (getSocket() == null
        || getSocket().isClosed()
        || !getSocket().isConnected()
        || getSocket().isOutputShutdown()
        || out == null) {

      fireResponseReceived(i18n.getMessage("DefaultLSConsoleModel.notConnected"));
    } else {
      CC.getTaskQueue().add(new LSConsoleExecCommand(cmd));
    }

    fireCommandExecuted();
  }
Exemple #15
0
 protected void draw_point(float p[], int i) {
   // System.out.println("DRAW POINT");
   CR.pixel.put_pixel(
       (int) (p[0] + (float) 0.5), (int) (p[1] + (float) 0.5), p[2], CC.ColorTransformation());
 }
 protected void initSystem() {
   // setup the root and the system
   root = new Identity(null, "911", "Root Identity", IdentityType.System);
   system = CC.get().identity().create(root, "+1 555-000-0000", "System", IdentityType.System);
 }
  protected void convertTabToNode(CC conversionContext, Document document) throws DOMException {

    if (!conversionContext.isInComplexFieldDefinition()) {
      getCurrentParent().appendChild(document.createTextNode(TAB_DUMMY));
    }
  }
  @Override
  public List<Object> apply(Object o) {

    if (o instanceof P) {

      currentP = createNode(document, NODE_BLOCK);
      currentSpan = null;
      if (tc.peek() != null) {
        tc.peek().appendChild(currentP);
      } else {
        parentNode.appendChild(currentP);
      }

      pPr = ((P) o).getPPr();
      currentP = handlePPr(conversionContext, pPr, false, currentP);

    } else if (o instanceof org.docx4j.wml.R) {

      if (!conversionContext.isInComplexFieldDefinition()) {
        // Convert run to span
        Element spanEl = createNode(document, NODE_INLINE);
        currentSpan = spanEl;

        rPr = ((R) o).getRPr();
        if (rPr != null) {
          handleRPr(conversionContext, pPr, rPr, currentSpan);
        }

        if (currentP == null) {
          // Hyperlink special case
          parentNode.appendChild(spanEl);
        } else {
          rtlAwareAppendChildToCurrentP(spanEl);
        }

        // To merge nested span (which we could do if there is a single child span),
        // TraversalUtil Callback would need an after walk children
      }

    } else if (o instanceof org.docx4j.wml.FldChar) {
      conversionContext.updateComplexFieldDefinition(((org.docx4j.wml.FldChar) o).getFldCharType());

    } else if (o instanceof org.docx4j.wml.Text) {

      if (!conversionContext.isInComplexFieldDefinition()) {

        if (currentSpan == null) {
          // eg after <br/>
          log.error("null currentSpan! " + ((Text) o).getValue());
          Element spanEl = createNode(document, NODE_INLINE);
          if (currentP == null) {
            // Hyperlink special case
            parentNode.appendChild(spanEl);
          } else {
            currentP.appendChild(spanEl);
          }
          currentSpan = spanEl;
        }

        log.debug(((Text) o).getValue());

        DocumentFragment df =
            (DocumentFragment)
                conversionContext.getRunFontSelector().fontSelector(pPr, rPr, ((Text) o));
        XmlUtils.treeCopy(df, currentSpan);
        // TODO would be more efficient without the treeCopy
        // but fontSelector would need to be refactored a bit

      }

    } else if (o instanceof org.docx4j.wml.R.Tab) {
      convertTabToNode(conversionContext, document);

    } else if (o instanceof org.docx4j.wml.CTSimpleField) {

      convertToNode(
          conversionContext, o, AbstractFldSimpleWriter.WRITER_ID, document, getCurrentParent());

    } else if (o instanceof org.docx4j.wml.P.Hyperlink) {

      convertToNode(
          conversionContext, o, AbstractHyperlinkWriter.WRITER_ID, document, getCurrentParent());

    } else if (o instanceof org.docx4j.wml.CTBookmark) {

      convertToNode(
          conversionContext,
          o,
          AbstractBookmarkStartWriter.WRITER_ID,
          document,
          getCurrentParent());

    } else if (o instanceof org.docx4j.wml.Tbl) {

      convertToNode(
          conversionContext,
          o,
          AbstractTableWriter.WRITER_ID,
          document,
          (currentP != null ? currentP : parentNode));

      currentP = null;
      currentSpan = null;

    } else if (o instanceof org.docx4j.wml.Tr) {

      // done in walkJAXBElements

      //			tr = document.createElementNS(Namespaces.NS_WORD12, "tr");
      //			//parentNode is in this case the DocumentFragment, that get's passed
      //			//to the TableModel/TableModelWriter
      //			parentNode.appendChild(tr);

    } else if (o instanceof org.docx4j.wml.Tc) {

      // done in walkJAXBElements

      //			tc = document.createElementNS(Namespaces.NS_WORD12, "tc");
      //			tr.appendChild(tc);
      //			// now the html p content will go temporarily go in w:tc,
      //			// which is what we need for our existing table model.

      //			System.out.println("#wrapped in w:tc OK");

    } else if (o instanceof org.docx4j.dml.wordprocessingDrawing.Inline
        || o instanceof org.docx4j.dml.wordprocessingDrawing.Anchor) {

      anchorOrInline = o; // keep this until we handle CTBlip

    } else if (o instanceof org.docx4j.dml.CTBlip) {
      /*<w:drawing>
      <wp:inline distT="0" distB="0" distL="0" distR="0">
        <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
          <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
            <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
              <pic:blipFill>
                <a:blip r:embed="rId10" cstate="print"/> */

      DocumentFragment foreignFragment = createImage(IMAGE_E20, conversionContext, anchorOrInline);
      anchorOrInline = null;

      currentP.appendChild(document.importNode(foreignFragment, true));

    } else if (o instanceof org.docx4j.wml.Pict) {
      /*<w:pict>
      <v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:428.25pt;height:321pt">
        <v:imagedata r:id="rId4" o:title=""/>
      </v:shape> */

      org.docx4j.vml.CTTextbox textBox = getTextBox((org.docx4j.wml.Pict) o);

      if (textBox == null) {
        // Assume it contains an image!
        DocumentFragment foreignFragment = createImage(IMAGE_E10, conversionContext, o);
        currentP.appendChild(document.importNode(foreignFragment, true));

      } else {

        convertToNode(
            conversionContext, o, AbstractPictWriter.WRITER_ID, document, getCurrentParent());
      }

    } else if (o instanceof Br) {

      handleBr((Br) o);

    } else if (o instanceof org.docx4j.wml.R.Sym) {

      convertToNode(
          conversionContext, o, AbstractSymbolWriter.WRITER_ID, document, getCurrentParent());

    } else if ((o instanceof org.docx4j.wml.ProofErr)
        || (o instanceof org.docx4j.wml.R.LastRenderedPageBreak)
        || (o instanceof org.docx4j.wml.CTMarkupRange)) {
      // Ignore theese types, they don't need to be outputed/handled
      // CTMarkupRange is the w:bookmarkEnd

    } else {
      getLog().warn("Need to handle " + o.getClass().getName());
      log.debug(XmlUtils.marshaltoString(o));
    }

    return null;
  }
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Andrey Lubchuck
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    scrollPane1 = new JScrollPane();
    textPane1 = new JTextPane();
    button1 = new JButton();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();

    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== dialogPane ========
    {
      dialogPane.setBorder(Borders.createEmptyBorder("7dlu, 7dlu, 7dlu, 7dlu"));

      // JFormDesigner evaluation mark
      dialogPane.setBorder(
          new javax.swing.border.CompoundBorder(
              new javax.swing.border.TitledBorder(
                  new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                  "JFormDesigner Evaluation",
                  javax.swing.border.TitledBorder.CENTER,
                  javax.swing.border.TitledBorder.BOTTOM,
                  new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
                  java.awt.Color.red),
              dialogPane.getBorder()));
      dialogPane.addPropertyChangeListener(
          new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
              if ("border".equals(e.getPropertyName())) throw new RuntimeException();
            }
          });

      dialogPane.setLayout(new BorderLayout());

      // ======== contentPanel ========
      {
        contentPanel.setLayout(
            new FormLayout("17*(default, $lcgap), default", "6*(default, $lgap), default"));

        // ======== scrollPane1 ========
        {
          scrollPane1.setViewportView(textPane1);
        }
        contentPanel.add(scrollPane1, CC.xywh(4, 5, 12, 1));

        // ---- button1 ----
        button1.setText("text");
        button1.setMaximumSize(new Dimension(83, 23));
        button1.setMinimumSize(new Dimension(83, 23));
        contentPanel.add(button1, CC.xywh(21, 11, 11, 1, CC.CENTER, CC.DEFAULT));
      }
      dialogPane.add(contentPanel, BorderLayout.NORTH);

      // ======== buttonBar ========
      {
        buttonBar.setBorder(Borders.createEmptyBorder("5dlu, 0dlu, 0dlu, 0dlu"));
        buttonBar.setLayout(
            new FormLayout("$lcgap, default, $glue, $button, $rgap, $button", "pref"));

        // ---- okButton ----
        okButton.setText("OK");
        buttonBar.add(okButton, CC.xy(4, 1));

        // ---- cancelButton ----
        cancelButton.setText("Cancel");
        cancelButton.setMaximumSize(new Dimension(85, 23));
        cancelButton.setMinimumSize(new Dimension(85, 23));
        buttonBar.add(cancelButton, CC.xy(6, 1));
      }
      dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }