Пример #1
0
 public void drawInfoBox(Graphics2D g2d, InfoBox n) {
   g2d.setColor(n.getBackColor());
   g2d.fill(new Rectangle2D.Float(n.x, n.y, n.width, n.height));
   g2d.setColor(n.getTextColor());
   for (int i = 0; i < n.text.length; i++) {
     g2d.drawString(n.text[i], n.x + 2, n.y + 12 + (12 * i));
   }
   g2d.setColor(Color.GRAY);
   g2d.drawRect(n.x, n.y, n.width, n.height);
 }
Пример #2
0
  SMTPprotocol() {
    super("SMTP Protocol Test v.1.0 by Tair Abdurman");
    setBackground(Color.lightGray);
    setLayout(new FlowLayout());
    // ******************************************************************
    smtpServer = new TextField("smtp.blueyonder.co.uk", 50);
    smtpPort = new TextField("25", 10);
    senderMail = new TextField("*****@*****.**", 80);
    reciverMail = new TextField("*****@*****.**", 0);
    ccMail = new TextField("", 80);
    bccMail = new TextField("", 80);
    subjectMail = new TextField("SMTP deneme", 80);

    add(new Label("SMTP Server:"));
    add(smtpServer);
    add(new Label("SMTP Port:"));
    add(smtpPort);

    add(new Label("From:    "));
    add(senderMail);
    add(new Label("To  :    "));
    add(reciverMail);
    add(new Label("Cc  :    "));
    add(ccMail);
    add(new Label("Bcc :    "));
    add(bccMail);
    add(new Label("Subject :"));
    add(subjectMail);

    add(new Label("Content :               "));
    bodyMail = new InfoBox(5, 90);
    bodyMail.setEditable(true);

    add(bodyMail);

    sendMail = new Button("send");
    clearMail = new Button("clear");
    quitProgram = new Button("quit");

    add(sendMail);
    add(clearMail);
    add(quitProgram);

    infoArea = new InfoBox(4, 90);
    add(infoArea);

    // ******************************************************************
    resize(700, 450);
    show();
    infoArea.Println("ready ...");
  }
  /**
   * React to the users input, create a filter and set the variable of the filter.
   *
   * @see Filter
   */
  public void onEvent(Event ev) {
    if (ev instanceof ControlEvent && ev.type == ControlEvent.PRESSED) {
      if (ev.target == btnCancel) {
        if (savedFiltersChanged) {
          Global.getPref().savePreferences();
          savedFiltersChanged = false;
        }
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);
      } else if (ev.target == btnRoute) {

        File datei;
        FileChooser fc = new FileChooser(FileChooserBase.OPEN, Global.getProfile().dataDir);
        fc.setTitle(MyLocale.getMsg(712, "Select route file"));
        if (fc.execute() != FormBase.IDCANCEL) {
          datei = fc.getChosenFile();
          InfoBox inf = new InfoBox("Distance?", "Dist:", InfoBox.INPUT);
          inf.execute();
          Vm.showWait(true);
          Filter flt = new Filter();
          flt.doFilterRoute(datei, Convert.toDouble(inf.feedback.getText()));
        }
        Vm.showWait(false);
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);

      } else if (ev.target == btnApply) {
        Vm.showWait(true);

        FilterData data = getDataFromScreen();
        Global.getProfile().setCurrentFilter(data);

        Filter flt = new Filter();
        flt.setFilter();
        flt.doFilter();
        if (savedFiltersChanged) {
          Global.getPref().savePreferences();
          savedFiltersChanged = false;
        }
        Global.mainTab.tbP.tc.scrollToVisible(0, 0);
        Vm.showWait(false);
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);
      } else if (ev.target == btnSaveFlt) {
        String ID = fltList.getText();
        FilterData data = getDataFromScreen();
        MessageBox mBox;
        InputBox inp = new InputBox("ID");
        String newID = inp.input(ID, 20);
        if (newID != null && !newID.equals("")) {
          if (Global.getPref().hasFilter(newID)) {
            mBox =
                new MessageBox(
                    MyLocale.getMsg(221, "Overwrite Filter?"),
                    MyLocale.getMsg(222, "The filter already exists. Overwrite it?"),
                    FormBase.IDYES | FormBase.IDNO);
            if (mBox.execute() == FormBase.IDYES) {
              Global.getPref().addFilter(newID, data);
              savedFiltersChanged = true;
              buildFilterList();
            }
          } else {
            Global.getPref().addFilter(newID, data);
            savedFiltersChanged = true;
            buildFilterList();
          }
        }
      } else if (ev.target == btnDelFlt) {
        String ID = fltList.getText();
        if (!ID.equals("")) {
          FilterData data = Global.getPref().getFilter(ID);
          // We only need to delete anything, if there is already a filter of the id
          // in the list box. If not, just delete the text in the box.
          if (data != null) {
            MessageBox mBox =
                new MessageBox(
                    MyLocale.getMsg(223, "Delete filter?"),
                    ID + MyLocale.getMsg(224, " - Delete this filter?"),
                    FormBase.IDYES | FormBase.IDNO);
            if (mBox.execute() == FormBase.IDYES) {
              Global.getPref().removeFilter(ID);
              fltList.setText("");
              savedFiltersChanged = true;
              this.buildFilterList();
            }
          } else {
            fltList.setText("");
          }
        }
      } else if (ev.target == addiWptChk) { // Set all addi filters to value of main addi filter
        chkParking.setState(addiWptChk.state);
        chkStage.setState(addiWptChk.state);
        chkQuestion.setState(addiWptChk.state);
        chkFinal.setState(addiWptChk.state);
        chkTrailhead.setState(addiWptChk.state);
        chkReference.setState(addiWptChk.state);
        addiWptChk.bgColor = Color.White;
        addiWptChk.repaint();
      } else if (ev.target == btnBearing) cp.select(0);
      else if (ev.target == btnAttributes) cp.select(1);
      else if (ev.target == btnRatings) cp.select(2);
      else if (ev.target == btnTypes) cp.select(3);
      else if (ev.target == btnAddi) cp.select(4);
      else if (ev.target == btnContainer) cp.select(5);
      else if (ev.target == btnSearch) cp.select(6);
      else if (ev.target == btnCacheAttributes) cp.select(7);
      else if (ev.target == btnDeselect) {
        chkNW.state =
            chkNNW.state =
                chkN.state =
                    chkNNE.state =
                        chkNE.state =
                            chkENE.state =
                                chkE.state =
                                    chkESE.state =
                                        chkSE.state =
                                            chkSSE.state =
                                                chkS.state =
                                                    chkSSW.state =
                                                        chkSW.state =
                                                            chkWSW.state =
                                                                chkW.state = chkWNW.state = false;
        setColors();
        repaint();

      } else if (ev.target == btnSelect) {
        chkNW.state =
            chkNNW.state =
                chkN.state =
                    chkNNE.state =
                        chkNE.state =
                            chkENE.state =
                                chkE.state =
                                    chkESE.state =
                                        chkSE.state =
                                            chkSSE.state =
                                                chkS.state =
                                                    chkSSW.state =
                                                        chkSW.state =
                                                            chkWSW.state =
                                                                chkW.state = chkWNW.state = true;
        setColors();
        repaint();
      }
    }
    if (ev instanceof DataChangeEvent) {
      if (ev.target == fltList) {
        if (!currentFilterID.equals(fltList.getText())) {
          FilterData data = Global.getPref().getFilter(fltList.getText());
          if (data != null) {
            currentFilterID = fltList.getText();
            this.setData(data);
            this.repaintNow();
          }
        }
        //				Vm.debug("Event: "+ev.toString()+"; Target: "+ev.target+"; Liste: "+fltList.getText()+
        //						" (alt: "+fltList.oldText+")");
        // setColors();
      }
      setColors();
    }
  }
Пример #4
0
 // ON SEND MAIL
 int onSendMail() {
   String inBuffer;
   String outBuffer;
   Socket sock;
   SMTPInputStream fromServer;
   SMTPOutputStream toServer;
   int intPort;
   // TEST RECIPIENT ADDRESS it must be at once
   if (reciverMail.getText().length() < 1) {
     infoArea.Println("enter recipient please ...");
     return -1;
   }
   // TEST PORT NUMBER FORMAT and ALERT WHEN NOT 25
   intPort = -1;
   infoArea.Clear();
   infoArea.Println("check port ...");
   try {
     intPort = Integer.valueOf(smtpPort.getText()).intValue();
     if ((intPort < 0) || (intPort > 65356)) {
       infoArea.Println("invalid port ...");
       return -1;
     }
     if (intPort != 25) infoArea.Println("attention port is not 25 ...");
     infoArea.Println("port number is " + smtpPort.getText());
   } catch (NumberFormatException e) {
     infoArea.Println("invalid port ...");
     return -1;
   }
   // CREATE SMTP CONNECTION
   infoArea.Println("connect to server ...");
   try {
     sock = new Socket(smtpServer.getText(), intPort);
   } catch (IOException e) {
     infoArea.Println("unable to connect(SK) ... " + e);
     return -1;
   }
   // CREATE SERVER STREAMS
   // INPUT STREAM
   try {
     fromServer = new SMTPInputStream(sock);
   } catch (IOException e) {
     infoArea.Println("unable to connect(IS) ...");
     return -1;
   }
   // OUTPUT STREAM
   try {
     toServer = new SMTPOutputStream(sock);
   } catch (IOException e) {
     infoArea.Println("unable to connect(OS) ...");
     return -1;
   }
   infoArea.Println("connected ...");
   // Mail Sending
   infoArea.Println("sending mail ...");
   // *******************************************************************
   try {
     int i = doSMTPTransaction(fromServer, toServer);
     if (i == 0) infoArea.Println("complete ...");
     else infoArea.Println("error ...");
   } catch (IOException e) {
     infoArea.Println("error ...");
   }
   // *******************************************************************
   // CLOSE SERVER STREAMS
   // OUTPUT STREAM
   infoArea.Println("disconnect from server ...");
   try {
     toServer.Close();
   } catch (IOException e) {
     infoArea.Println("alert OUTPUT STREAM ...");
   }
   // INPUT STREAM
   try {
     fromServer.Close();
   } catch (IOException e) {
     infoArea.Println("alert INPUT STREAM ...");
   }
   // CLOSE CONNECTION
   try {
     sock.close();
     infoArea.Println("disconnected ...");
   } catch (IOException e) {
     infoArea.Println("unable to disconnect ...");
     return -1;
   }
   return 0;
 }
Пример #5
0
 // ON CLEAR MAIL
 void onClearMail() {
   infoArea.Println("clearing mail ...");
   bodyMail.Clear();
 }
Пример #6
0
 // ON QUIT PROGRAM
 void onQuit() {
   infoArea.Println("quit programm ...");
   System.exit(0);
 }
Пример #7
0
  public void doIt() {
    // CellPanel [] p = addToolbar();
    Global.mainForm = this;
    // this.title = "CacheWolf " + Version.getRelease();
    this.exitSystemOnClose = true;
    this.resizable = true;
    this.moveable = true;
    this.windowFlagsToSet = WindowConstants.FLAG_MAXIMIZE_ON_PDA;
    // Rect screen = ((ewe.fx.Rect)
    // (Window.getGuiInfo(WindowConstants.INFO_SCREEN_RECT,null,new
    // ewe.fx.Rect(),0)));
    // if ( screen.height >= 600 && screen.width >= 800)
    // this.setPreferredSize(800, 600);
    this.resizeOnSIP = true;
    InfoBox infB = null;
    try {
      pref.readPrefFile();
      if (MyLocale.initErrors.length() != 0) {
        new MessageBox("Error", MyLocale.initErrors, FormBase.OKB).execute();
      }
      if (Vm.isMobile() == true) {
        // this.windowFlagsToSet |=Window.FLAG_FULL_SCREEN;
        this.resizable = false;
        this.moveable = false;
      } else {
        int h, w;
        h = pref.myAppHeight;
        if (h > MyLocale.getScreenHeight()) h = MyLocale.getScreenHeight();
        w = pref.myAppWidth;
        if (w > MyLocale.getScreenWidth()) w = MyLocale.getScreenWidth();
        this.setPreferredSize(w, h);
      }
      addGuiFont();
      if (!pref.selectProfile(profile, Preferences.PROFILE_SELECTOR_ONOROFF, true))
        ewe.sys.Vm.exit(0); // User MUST select or create a profile
      Vm.showWait(true);

      // Replace buildt-in symbols with customized images
      GuiImageBroker.customizedSymbols();

      // Load CacheList
      infB = new InfoBox("CacheHound", MyLocale.getMsg(5000, "Loading Cache-List"));
      infB.exec();
      infB.waitUntilPainted(100);
      profile.readIndex(infB);
      pref.setCurCenter(new CWPoint(profile.getCenter()));
      profile.updateBearingDistance();
      setTitle("CacheHound " + Version.getRelease() + " - " + profile.name);
    } catch (Exception e) {
      if (pref.debug == true) Vm.debug("MainForm:: Exception:: " + e.toString());
    }

    if (pref.showStatus) statBar = new StatusBar(pref, profile.cacheDB);
    mMenu = new MainMenu(this);
    mTab = new MainTab(mMenu, statBar);
    split = new SplittablePanel(PanelSplitter.HORIZONTAL);
    split.theSplitter.thickness = 0;
    split.theSplitter.modify(Invisible, 0);
    CellPanel pnlCacheList = split.getNextPanel();
    CellPanel pnlMainTab = split.getNextPanel();
    split.setSplitter(
        PanelSplitter.MIN_SIZE | PanelSplitter.BEFORE,
        PanelSplitter.HIDDEN | PanelSplitter.BEFORE,
        PanelSplitter.CLOSED);
    pnlCacheList.addLast(cacheList = new CacheList(), STRETCH, FILL);
    pnlMainTab.addLast(mTab, STRETCH, FILL);

    mTab.dontAutoScroll = true;

    this.addLast(split, STRETCH, FILL);
    /*
     * if (pref.menuAtTop) { this.addLast(mMenu,CellConstants.DONTSTRETCH,
     * CellConstants.FILL); this.addLast(split,STRETCH,FILL); } else {
     * this.addLast(split,STRETCH,FILL);
     * this.addLast(mMenu,CellConstants.DONTSTRETCH, CellConstants.FILL); }
     */
    mMenu.setTablePanel(mTab.getTablePanel());
    if (infB != null) infB.close(0);
    mTab.tbP.refreshTable();
    mTab.tbP.selectFirstRow();
    // mTab.tbP.tc.paintSelection();
    Vm.showWait(false);
  }