Ejemplo n.º 1
0
 boolean processExtInputEventHelper(int type) {
   boolean retval = false;
   if (isHelperAvailable() && cc.cp.supportsGII) {
     boolean isExtEvent = false;
     try {
       isExtEvent = processExtInputEvent(type);
     } catch (java.lang.UnsatisfiedLinkError e) {
       vlog.info("WARNING: Could not invoke processExtInputEvent() from TurboVNC Helper.");
       vlog.info("  Extended input device support will be disabled.");
       helperAvailable = false;
     } catch (java.lang.Exception e) {
       vlog.info("WARNING: Could not invoke processExtInputEvent() from TurboVNC Helper:");
       vlog.info("  " + e.toString());
       vlog.info("  Extended input device support may not work correctly.");
     }
     if (!isExtEvent) return false;
     if (devices == null) {
       vlog.error("ERROR: Attempted to send extended input event when no GII devices exist");
       return false;
     }
     for (Iterator<ExtInputDevice> i = devices.iterator(); i.hasNext(); ) {
       ExtInputDevice dev = (ExtInputDevice) i.next();
       if (lastEvent.deviceID == dev.id && dev.remoteID != 0) {
         if (dev.absolute && lastEvent.type == giiTypes.giiValuatorRelative)
           lastEvent.type = giiTypes.giiValuatorAbsolute;
         cc.giiSendEvent(dev, lastEvent);
         retval = true;
       }
     }
   }
   return retval;
 }
Ejemplo n.º 2
0
  public static boolean isHelperAvailable() {
    if (!triedHelperInit) {
      try {
        System.loadLibrary("turbovnchelper");
        helperAvailable = true;
      } catch (java.lang.UnsatisfiedLinkError e) {
        vlog.info("WARNING: Could not find TurboVNC Helper JNI library.  If it is in a");
        vlog.info("  non-standard location, then add -Djava.library.path=<dir>");
        vlog.info("  to the Java command line to specify its location.");
        vlog.info("  Full-screen mode may not work correctly.");
        if (VncViewer.osEID())
          vlog.info("  Keyboard grabbing and extended input device support will be disabled.");
        else if (VncViewer.osGrab()) vlog.info("  Keyboard grabbing will be disabled.");

      } catch (java.lang.Exception e) {
        vlog.info("WARNING: Could not initialize TurboVNC Helper JNI library:");
        vlog.info("  " + e.toString());
        vlog.info("  Full-screen mode may not work correctly.");
        if (VncViewer.osEID())
          vlog.info("  Keyboard grabbing and extended input device support will be disabled.");
        else if (VncViewer.osGrab()) vlog.info("  Keyboard grabbing will be disabled.");
      }
    }
    triedHelperInit = true;
    return helperAvailable;
  }
Ejemplo n.º 3
0
 public QueryTableModel() {
   cache = new Vector();
   try {
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
   } catch (java.lang.Exception e) {
     System.err.println("Class not found exception : ");
     System.err.println(e.getMessage());
   }
 } // konstr. sonu
Ejemplo n.º 4
0
 public void cleanupExtInputHelper() {
   if (isHelperAvailable() && x11dpy != 0) {
     try {
       cleanupExtInput();
     } catch (java.lang.UnsatisfiedLinkError e) {
       vlog.info("WARNING: Could not invoke cleanupExtInput() from TurboVNC Helper.");
       vlog.info("  Extended input device support will be disabled.");
       helperAvailable = false;
     } catch (java.lang.Exception e) {
       vlog.info("WARNING: Could not invoke cleanupExtInput() from TurboVNC Helper:");
       vlog.info("  " + e.toString());
     }
   }
 }
Ejemplo n.º 5
0
 public void setupExtInputHelper() {
   if (isHelperAvailable() && cc.cp.supportsGII && x11dpy == 0) {
     try {
       setupExtInput();
     } catch (java.lang.UnsatisfiedLinkError e) {
       vlog.info("WARNING: Could not invoke setupExtInput() from TurboVNC Helper.");
       vlog.info("  Extended input device support will be disabled.");
       helperAvailable = false;
     } catch (java.lang.Exception e) {
       vlog.info("WARNING: Could not invoke setupExtInput() from TurboVNC Helper:");
       vlog.info("  " + e.toString());
       vlog.info("  Extended input device support may not work correctly.");
     }
   }
 }
Ejemplo n.º 6
0
 public void x11FullScreenHelper(boolean on) {
   if (isHelperAvailable()) {
     try {
       x11FullScreen(on);
     } catch (java.lang.UnsatisfiedLinkError e) {
       vlog.info("WARNING: Could not invoke x11FullScreen() from TurboVNC Helper.");
       vlog.info("  Full-screen mode may not work correctly.");
       helperAvailable = false;
     } catch (java.lang.Exception e) {
       vlog.info("WARNING: Could not invoke x11FullScreen() from TurboVNC Helper:");
       vlog.info("  " + e.toString());
       vlog.info("  Full-screen mode may not work correctly.");
     }
   }
 }
Ejemplo n.º 7
0
 public void grabKeyboardHelper(boolean on, boolean force) {
   if (isHelperAvailable()) {
     try {
       if (cc.keyboardGrabbed == on && !force) return;
       grabKeyboard(on, VncViewer.grabPointer.getValue());
       cc.keyboardGrabbed = on;
       cc.menu.grabKeyboard.setSelected(cc.keyboardGrabbed);
     } catch (java.lang.UnsatisfiedLinkError e) {
       vlog.info("WARNING: Could not invoke grabKeyboard() from TurboVNC Helper.");
       vlog.info("  Keyboard grabbing will be disabled.");
       helperAvailable = false;
     } catch (java.lang.Exception e) {
       vlog.info("WARNING: Could not invoke grabKeyboard() from TurboVNC Helper:");
       vlog.info("  " + e.toString());
       vlog.info("  Keyboard grabbing may not work correctly.");
     }
   }
 }
Ejemplo n.º 8
0
 public org.eclipse.swt.widgets.Shell open(org.eclipse.swt.widgets.Display display) {
   java.lang.Class clazz = org.eclipse.swt.examples.hoverhelp.HoverHelp.class;
   try {
     if (images == null) {
       images = new org.eclipse.swt.graphics.Image[imageLocations.length];
       for (int i = 0; i < imageLocations.length; ++i) {
         java.io.InputStream stream = clazz.getResourceAsStream(imageLocations[i]);
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(stream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         images[i] = new org.eclipse.swt.graphics.Image(display, source, mask);
         try {
           stream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
     }
   } catch (java.lang.Exception ex) {
     System.err.println(
         getResourceString(
             "error.CouldNotLoadResources", new java.lang.Object[] {ex.getMessage()}));
     return null;
   }
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell();
   createPartControl(shell);
   shell.addDisposeListener(
       new org.eclipse.swt.events.DisposeListener() {
         public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
           if (images != null) {
             for (int i = 0; i < images.length; i++) {
               final org.eclipse.swt.graphics.Image image = images[i];
               if (image != null) {
                 image.dispose();
               }
             }
             images = null;
           }
         }
       });
   shell.pack();
   shell.open();
   return shell;
 }
Ejemplo n.º 9
0
 /**
  * Prints the stacktrace of the supplied exception to the error stream.
  *
  * @param e any Java exception.
  */
 public static void printException(java.lang.Exception e) {
   if (errStream != null) e.printStackTrace(errStream);
   else e.printStackTrace();
 }
Ejemplo n.º 10
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    ResultSet rs = null;
    try {
      // SET UP Context environment, to look for Data Pooling Resource
      Context initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");
      DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
      Connection dbcon = ds.getConnection();

      // ########### SEARCH INPUT PARAMETERS, EXECUTE search
      // #####################################################
      Vector<String> params = new Vector<String>();
      params.add(request.getParameter("fname"));
      params.add(request.getParameter("lname"));
      params.add(request.getParameter("title"));
      params.add(request.getParameter("year"));
      params.add(request.getParameter("director"));

      List<Movie> movies = new ArrayList<Movie>();
      movies = SQLServices.getMovies(params.toArray(new String[params.size()]), dbcon);

      // ########## SET DEFAULT SESSION() PARAMETERS ####################################
      request.getSession().removeAttribute("movies");
      request.getSession().removeAttribute("linkedListMovies");
      request.getSession().removeAttribute("hasPaged");
      request.getSession().setAttribute("hasPaged", "no");
      request.getSession().setAttribute("movies", movies);
      request.getSession().setAttribute("currentIndex", "0");
      request.getSession().setAttribute("defaultN", "5");

      // ########## IF MOVIES FROM SEARCH NON-EMPTY ###########################################
      List<String> fields = Movie.fieldNames();
      int count = 1;
      if (!movies.isEmpty()) {
        request.setAttribute("movies", movies);
        for (String field : fields) {
          request.setAttribute("f" + count++, field);
        }
        request.getRequestDispatcher("../movieList.jsp").forward(request, response);
      } else {
        out.println("<html><head><title>error</title></head>");
        out.println("<body><h1>could not find any movies, try your search again.</h1>");
        out.println("<p> we are terribly sorry, please go back. </p>");
        out.println("<table border>");
        out.println("</table>");
      }
      dbcon.close();

    } catch (SQLException ex) {
      while (ex != null) {
        System.out.println("SQL Exception:  " + ex.getMessage());
        ex = ex.getNextException();
      }
    } catch (java.lang.Exception ex) {
      out.println(
          "<html>"
              + "<head><title>"
              + "moviedb: error"
              + "</title></head>\n<body>"
              + "<p>SQL error in doGet: "
              + ex.getMessage()
              + "</p></body></html>");
      return;
    }
    out.close();
  }
  public void sampleCode() {

    //  Variables for simple test case
    String procname = "sp_timestampSample";

    /* *CREATE PROCEDURE*
       String createQuery1 =
           "create table spt_timestampSample(f1 int, f2 char(5), f3 timestamp )";
       String insertQuery1 =
           "insert spt_timestampSample(f1,f2) values(1, 'Hello')";

       // Sample Stored Procedure
       String dropProc = "drop proc " + procname;
       String createProc =
           "create proc " + procname +
           "(@p1 int, @p2 timestamp out)" +
           " as " +
           "select 'p1='  + convert(varchar(10),@p1) "  +
           "select @p2 = f3 from spt_timestampSample where f1=1"   +
           "select * from spt_timestampSample " +
           "return 21";
    */
    String sproc = "{? = call " + procname + "(?,?)}";
    try {
      /* *CREATE PROCEDURE*
         // We will create a temp table which contains a timestamp column
         // and we will insert a row.  We will then execute a stored
         // procedure which will returnt the timestamp column as an OUTPUT
         // parameter

         // Create our table
         execDDL( createQuery1);

         // Insert our row
         execDDL( insertQuery1);

         // Now create the Proc
         execDDL( createProc);
      */

      // Now execute our Sproc
      CallableStatement cstmt = _con.prepareCall(sproc);
      output("Executing: " + sproc + "\n");

      // Declare the IN Params.  Note, you must skip the Return Status
      cstmt.setInt(2, 1961);

      // Now declare our OUT Params
      cstmt.registerOutParameter(1, Types.INTEGER);
      cstmt.registerOutParameter(3, Types.VARBINARY);

      boolean results = cstmt.execute();
      int rsnum = 0; // Number of Result Sets processed
      int rowsAffected = 0;

      do {
        if (results) {
          ResultSet rs = cstmt.getResultSet();
          output("\n\nDisplaying ResultSet: " + rsnum + "\n");
          dispResultSet(rs);
          rsnum++;
          rs.close();
        } else {
          rowsAffected = cstmt.getUpdateCount();
          if (rowsAffected >= 0) output(rowsAffected + " rows Affected.\n");
        }
        results = cstmt.getMoreResults();
      } while (results || rowsAffected != -1);

      String s = cstmt.getString(1);
      String s2 = cstmt.getString(3);

      // Now grab the same output parameter as VARBINARY
      byte[] ts = cstmt.getBytes(3);

      // Display the Output Parameters
      output("OUT Param1=" + s + "\n");
      output("OUT Param2 as String=" + s2 + "\n");
      output("OUT Param2 as byte[]=" + toHexString(ts) + "\n");

      cstmt.close();

      /* *CREATE PROCEDURE*
         // Drop our sproc
         execDDL( dropProc);
      */
    } catch (SQLException ex) {
      displaySQLEx(ex);
    } catch (java.lang.Exception ex) {
      // Got some other type of exception.  Dump it.
      ex.printStackTrace();
    }
  }
Ejemplo n.º 12
0
  /**
   * Starts the debugger. The method stops the current debugging (if any) and takes information from
   * the provided info (containing the class to start and arguments to pass it and name of class to
   * stop debugging in) and starts new debugging session.
   *
   * @param info debugger info about class to start
   * @exception DebuggerException if an error occures during the start of the debugger
   */
  public void startDebugger(DebuggerInfo info) throws DebuggerException {
    debuggerInfo = info;
    if (remoteDebugger != null) finishDebugger();
    // S ystem.out.println("startDebugger " + info); // NOI18N
    // RemoteDebugging support
    hostName = null;
    password = null;
    boolean local = true;
    if (info instanceof ReconnectDebuggerInfo) {
      ReconnectDebuggerInfo rdi = (ReconnectDebuggerInfo) info;
      hostName = rdi.getHostName();
      password = rdi.getPassword();
      local = false;
    } else if (info instanceof RemoteDebuggerInfo) {
      hostName = ((RemoteDebuggerInfo) info).getHostName();
      password = ((RemoteDebuggerInfo) info).getPassword();
      local = false;
    }
    boolean stopOnMain = info.getStopClassName() != null;
    stopOnMainFlag = stopOnMain;
    // S ystem.out.println ("ToolsDebugger.startDebugger " + info.getStopClassName ()); // NOI18N
    // T hread.dumpStack ();

    synchronizer = new RequestSynchronizer();

    // open output window ...
    super.startDebugger(info);

    // start & init remote debugger ................................................
    //    process = null;
    if (local) {
      // create process & read password for local debugging

      // create starting string & NbProcessDescriptor
      NbProcessDescriptor debugerProcess;
      if (info instanceof ProcessDebuggerInfo)
        debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess();
      else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS;
      HashMap map;
      if (info instanceof ToolsDebugger10Info) {
        map =
            Utils.processDebuggerInfo(
                info,
                "-debug", // NOI18N
                "sun.tools.debug.EmptyApp" // NOI18N
                );
        map.put(ToolsDebugger10Type.JAVA_HOME_SWITCH, ((ToolsDebugger10Info) info).getJavaHome());
      } else {
        if (info instanceof ToolsDebugger11Info) {
          String javaHome11 = ((ToolsDebugger11Info) info).getJavaHome();
          if ((javaHome11 == null) || (javaHome11.trim().length() == 0)) {
            finishDebugger();
            throw new DebuggerException(bundle.getString("EXC_JDK11_home_is_not_set"));
          }
          map =
              Utils.processDebuggerInfo(
                  info,
                  "-debug -nojit", // NOI18N
                  "sun.tools.debug.EmptyApp" // NOI18N
                  );
          map.put(ToolsDebugger11Type.JAVA_HOME_SWITCH, javaHome11);
        } else {
          map =
              Utils.processDebuggerInfo(
                  info,
                  "-Xdebug", // NOI18N
                  "sun.tools.agent.EmptyApp" // NOI18N
                  );
        }
      }
      MapFormat format = new MapFormat(map);
      String s =
          format.format(
              debugerProcess.getProcessName() + " " + debugerProcess.getArguments() // NOI18N
              );
      println(s, ERR_OUT);

      // start process & read password ......................................
      try {
        process = debugerProcess.exec(format);
        BufferedReader bufferedreader =
            new BufferedReader(new InputStreamReader(process.getInputStream()));
        password = bufferedreader.readLine();
        showOutput(process, ERR_OUT, ERR_OUT);
        connectInput(process);
      } catch (java.lang.Exception e) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
                .format(
                    new Object[] {format.format(debugerProcess.getProcessName()), e.toString()}),
            e);
      }
      if (password == null) {
        // no reply
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_While_connect_to_debuggee"))
                .format(new Object[] {format.format(debugerProcess.getProcessName())}));
      }
      if (password.indexOf("=") < 0) { // NOI18N
        // unexpected reply
        println(bundle.getString("CTL_Unexpected_reply") + ": " + password, ERR_OUT);
        showOutput(process, ERR_OUT + STD_OUT, ERR_OUT);
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Unecpected_debugger_reply"))
                .format(new Object[] {password}));
      }
      password = password.substring(password.indexOf("=") + 1); // NOI18N
      println(bundle.getString("CTL_Password") + ": " + password, ERR_OUT);
      hostName = "127.0.0.1"; // NOI18N
    } // end of local debugging specific
    else if (info instanceof ReconnectDebuggerInfo) {
      println(bundle.getString("CTL_Reconnecting"), ERR_OUT | STD_OUT);
    } else
      println(bundle.getString("CTL_Connecting_to") + ": " + hostName + ":" + password, ERR_OUT);

    // start RemoteDebugger ...................................................
    try {
      remoteDebugger =
          new RemoteDebugger(
              hostName,
              password.length() < 1 ? null : password,
              new ToolsCallback(this),
              isShowMessages());
    } catch (java.net.ConnectException e) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_Cannot_connect_to_debuggee"))
              .format(new Object[] {e.toString()}),
          e);
    } catch (Throwable e) {
      if (e instanceof ThreadDeath) throw (ThreadDeath) e;
      // e.printStackTrace ();
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_Cannot_connect_to_debuggee"))
              .format(new Object[] {e.toString()}),
          e);
    }

    // create arguments for main class ...............................................
    mainClassName = info.getClassName();
    RemoteClass cls;
    String[] args = null;
    if ((mainClassName != null) && (mainClassName.length() > 0)) {
      String[] infoArgs = info.getArguments();
      args = new String[infoArgs.length + 1];
      args[0] = mainClassName;
      System.arraycopy(infoArgs, 0, args, 1, infoArgs.length);
      // args[0] = name of class
      // args[...] = parameters

      // find main class .........................................................
      try {
        cls = remoteDebugger.findClass(mainClassName);
      } catch (Throwable e) {
        if (e instanceof ThreadDeath) throw (ThreadDeath) e;
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Cannot_find_class"))
                .format(new Object[] {mainClassName, e.toString()}),
            e);
      }
      if (cls == null) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Cannot_find_class"))
                .format(new Object[] {mainClassName, new ClassNotFoundException().toString()}));
      }
    }

    // set breakpoint on stop class method ...............................................
    if (stopOnMain) {
      RemoteClass stopClass = null;
      try {
        stopClass = remoteDebugger.findClass(stopClassName = info.getStopClassName());
      } catch (Throwable e) {
        if (e instanceof ThreadDeath) throw (ThreadDeath) e;
        println(
            bundle.getString("MSG_Exc_while_finding_class") + stopClassName + '\n' + e, ERR_OUT);
      }
      if (stopClass == null) {
        println(bundle.getString("CTL_No_such_class") + ": " + stopClassName, ERR_OUT);
      } else {
        try {
          RemoteField[] rf = stopClass.getMethods();
          int i, k = rf.length;
          Type t = Type.tMethod(Type.tVoid, new Type[] {Type.tArray(Type.tString)});
          Type startT = Type.tMethod(Type.tVoid);
          RemoteField startM = null;
          RemoteField initM = null;
          RemoteField constM = null;
          for (i = 0; i < k; i++) {
            if (rf[i].getName().equals("main")
                && // NOI18N
                rf[i].getType().equals(t)) break;
            else if (rf[i].getName().equals("start")
                && // NOI18N
                rf[i].getType().equals(startT)) startM = rf[i];
            else if (rf[i].getName().equals("init")
                && // NOI18N
                rf[i].getType().equals(startT)) initM = rf[i];
            else if (rf[i].getName().equals("<init>")
                && // NOI18N
                rf[i].getType().equals(startT)) constM = rf[i];
          }
          if (i < k) // [PENDING] stop on non main too !!!!!!!!!!!!!!!!!!!!!
          stopClass.setBreakpointMethod(rf[i]); // have main
          else if (initM != null) stopClass.setBreakpointMethod(initM);
          else if (startM != null) stopClass.setBreakpointMethod(startM);
          else if (constM != null) stopClass.setBreakpointMethod(constM);

          // S ystem.out.println ("Stop: " + (i <k) + " " + initM +" " + startM +" " + constM); //
          // NOI18N
          /*          pendingBreakpoints = new RemoteField [1];
          pendingBreakpoints [0] = rf[i];
          pendingBreakpointsClass = stopClass;*/
        } catch (Throwable e) {
          if (e instanceof ThreadDeath) throw (ThreadDeath) e;
          println(bundle.getString("MSG_Exc_while_setting_breakpoint") + '\n' + e, ERR_OUT);
        }
      }
    } // stopOnMain

    setBreakpoints();
    updateWatches();
    println(bundle.getString("CTL_Debugger_running"), STL_OUT);
    setDebuggerState(DEBUGGER_RUNNING);

    // run debugged class ...............................................
    if (args != null) {
      RemoteThreadGroup rtg = null;
      try {
        rtg = remoteDebugger.run(args.length, args);
        //        threadGroup.setRemoteThreadGroup (rtg);
      } catch (Throwable e) {
        if (e instanceof ThreadDeath) throw (ThreadDeath) e;
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_While_calling_run"))
                .format(new Object[] {mainClassName, e.toString()}),
            e);
      }
      if (rtg == null) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_While_calling_run"))
                .format(
                    new Object[] {
                      mainClassName, "" // NOI18N
                    }));
      }
    }

    // start refresh thread .................................................
    if (debuggerThread != null) debuggerThread.stop();
    debuggerThread =
        new Thread(
            new Runnable() {
              public void run() {
                for (; ; ) {
                  try {
                    Thread.sleep(5000);
                  } catch (InterruptedException ex) {
                  }
                  if (getState() == DEBUGGER_RUNNING)
                    try {
                      threadGroup.threadChanged();

                    } catch (Throwable e) {
                      if (e instanceof ThreadDeath) throw (ThreadDeath) e;
                      if (e instanceof java.net.SocketException) {
                        debuggerThread = null;
                        try {
                          finishDebugger();
                        } catch (Throwable ee) {
                          if (ee instanceof ThreadDeath) throw (ThreadDeath) ee;
                        }
                        Thread.currentThread().stop();
                      }
                    }
                }
              }
            },
            "Debugger refresh thread"); // NOI18N
    debuggerThread.setPriority(Thread.MIN_PRIORITY);
    debuggerThread.start();
  }