Exemple #1
0
 // Note: this comparator imposes orderings that are inconsistent with equals.
 public int compare(String a, String b) {
   if (base.get(a) >= base.get(b)) {
     return -1;
   } else {
     return 1;
   } // returning 0 would merge keys
 }
  private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args)
      throws DebuggerException {
    if (bndlPrefix != null) {
      if (connector.transport().name().equals("dt_shmem")) {
        Argument a = (Argument) args.get("name");
        if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_shmem"))
                  .format(new Object[] {a.value()}),
              ERR_OUT);
      } else if (connector.transport().name().equals("dt_socket")) {
        Argument name = (Argument) args.get("hostname");
        Argument port = (Argument) args.get("port");
        if ((name == null) || (port == null))
          println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_socket"))
                  .format(new Object[] {name.value(), port.value()}),
              ERR_OUT);
      } else println(bundle.getString(bndlPrefix), ERR_OUT);
    }

    // launch VM
    try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N
      return connector.attach(args);
    } catch (Exception e) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee"))
              .format(new Object[] {e.toString()}),
          e);
    }
  }
 /** highlight a route (maybe to show it's in use...) */
 public void highlightRoute(String src, String dst) {
   Iterator i = rows.iterator();
   while (i.hasNext()) {
     Map temp = (Map) i.next();
     if (temp.get("Address").equals(dst) && temp.get("Pivot").equals(src)) {
       temp.put("Active", Boolean.TRUE);
     }
   }
 }
  public void showTask(String sTaskClass) {

    m_appview.waitCursorBegin();

    if (m_appuser.hasPermission(sTaskClass)) {

      JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass);

      // cierro la antigua
      if (m_jLastView == null || (m_jMyView != m_jLastView && m_jLastView.deactivate())) {

        // Construct the new view
        if (m_jMyView == null) {

          // Is the view prepared
          m_jMyView = m_aPreparedViews.get(sTaskClass);
          if (m_jMyView == null) {
            // The view is not prepared. Try to get as a Bean...
            try {
              m_jMyView = (JPanelView) m_appview.getBean(sTaskClass);
            } catch (BeanFactoryException e) {
              m_jMyView = new JPanelNull(m_appview, e);
            }
          }

          m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass);
          m_aCreatedViews.put(sTaskClass, m_jMyView);
        }

        // ejecuto la tarea
        try {
          m_jMyView.activate();
        } catch (BasicException e) {
          JMessageDialog.showMessage(
              this,
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e));
        }

        // se tiene que mostrar el panel
        m_jLastView = m_jMyView;

        showView(sTaskClass);
        // Y ahora que he cerrado la antigua me abro yo
        String sTitle = m_jMyView.getTitle();
        m_jPanelTitle.setVisible(sTitle != null);
        m_jTitle.setText(sTitle);
      }
    } else {
      // No hay permisos para ejecutar la accion...
      JMessageDialog.showMessage(
          this,
          new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions")));
    }
    m_appview.waitCursorEnd();
  }
  /**
   * Loads the list of enabled and disabled encryption protocols with their priority.
   *
   * @param enabledEncryptionProtocols The list of enabled encryption protocol available for this
   *     account.
   * @param disabledEncryptionProtocols The list of disabled encryption protocol available for this
   *     account.
   */
  private void loadEncryptionProtocols(
      Map<String, Integer> encryptionProtocols, Map<String, Boolean> encryptionProtocolStatus) {
    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    // Load stored values.
    int prefixeLength = ProtocolProviderFactory.ENCRYPTION_PROTOCOL.length() + 1;
    String encryptionProtocolPropertyName;
    String name;
    int index;
    boolean enabled;
    Iterator<String> encryptionProtocolNames = encryptionProtocols.keySet().iterator();
    while (encryptionProtocolNames.hasNext()) {
      encryptionProtocolPropertyName = encryptionProtocolNames.next();
      index = encryptionProtocols.get(encryptionProtocolPropertyName);
      // If the property is set.
      if (index != -1) {
        name = encryptionProtocolPropertyName.substring(prefixeLength);
        if (isExistingEncryptionProtocol(name)) {
          enabled =
              encryptionProtocolStatus.get(
                  ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + "." + name);
          encryptions[index] = name;
          selectedEncryptions[index] = enabled;
        }
      }
    }

    // Load default values.
    String encryptionProtocol;
    boolean set;
    int j = 0;
    for (int i = 0; i < ENCRYPTION_PROTOCOLS.length; ++i) {
      encryptionProtocol = ENCRYPTION_PROTOCOLS[i];
      // Specify a default value only if there is no specific value set.
      if (!encryptionProtocols.containsKey(
          ProtocolProviderFactory.ENCRYPTION_PROTOCOL + "." + encryptionProtocol)) {
        set = false;
        // Search for the first empty element.
        while (j < encryptions.length && !set) {
          if (encryptions[j] == null) {
            encryptions[j] = encryptionProtocol;
            // By default only ZRTP is set to true.
            selectedEncryptions[j] = encryptionProtocol.equals("ZRTP");
            set = true;
          }
          ++j;
        }
      }
    }

    this.encryptionConfigurationTableModel.init(encryptions, selectedEncryptions);
  }
 /** Remove a given manipulator from a given window. The window must be registered. */
 public synchronized void removeManipFromWindow(Manip manip, AWTGLAutoDrawable window) {
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info == null) {
     throw new RuntimeException("Window not registered");
   }
   if (!info.manips.remove(manip)) {
     throw new RuntimeException("Manip not registered in window");
   }
   Set windows = (Set) manipToWindowMap.get(manip);
   assert windows != null;
   windows.remove(window);
 }
 /**
  * Make a given manipulator visible and active in a given window. The window must be registered.
  */
 public synchronized void showManipInWindow(Manip manip, AWTGLAutoDrawable window) {
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info == null) {
     throw new RuntimeException("Window not registered");
   }
   info.manips.add(manip);
   Set windows = (Set) manipToWindowMap.get(manip);
   if (windows == null) {
     windows = new HashSet();
     manipToWindowMap.put(manip, windows);
   }
   windows.add(window);
 }
  void install() {
    Vector components = new Vector();
    Vector indicies = new Vector();
    int size = 0;

    JPanel comp = selectComponents.comp;
    Vector ids = selectComponents.filesets;

    for (int i = 0; i < comp.getComponentCount(); i++) {
      if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) {
        size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size");
        components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset"));
        indicies.addElement(new Integer(i));
      }
    }

    String installDir = chooseDirectory.installDir.getText();

    Map osTaskDirs = chooseDirectory.osTaskDirs;
    Iterator keys = osTaskDirs.keySet().iterator();
    while (keys.hasNext()) {
      OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next();
      String dir = ((JTextField) osTaskDirs.get(osTask)).getText();
      if (dir != null && dir.length() != 0) {
        osTask.setEnabled(true);
        osTask.setDirectory(dir);
      } else osTask.setEnabled(false);
    }

    InstallThread thread =
        new InstallThread(installer, progress, installDir, osTasks, size, components, indicies);
    progress.setThread(thread);
    thread.start();
  }
 private void fireUpdate(Manip manip) {
   Set windows = (Set) manipToWindowMap.get(manip);
   assert windows != null;
   for (Iterator iter = windows.iterator(); iter.hasNext(); ) {
     windowListener.update((AWTGLAutoDrawable) iter.next());
   }
 }
  @Override
  public void mouseMoved(MouseEvent e) {
    Component source = e.getComponent();
    Point location = e.getPoint();
    direction = 0;

    if (location.x < dragInsets.left) direction += WEST;

    if (location.x > source.getWidth() - dragInsets.right - 1) direction += EAST;

    if (location.y < dragInsets.top) direction += NORTH;

    if (location.y > source.getHeight() - dragInsets.bottom - 1) direction += SOUTH;

    //  Mouse is no longer over a resizable border

    if (direction == 0) {
      source.setCursor(sourceCursor);
    } else // use the appropriate resizable cursor
    {
      int cursorType = cursors.get(direction);
      Cursor cursor = Cursor.getPredefinedCursor(cursorType);
      source.setCursor(cursor);
    }
  }
Exemple #11
0
  private void processRead(Map read) throws Exception {
    if (!"".equals(read.get("data"))) {
      String text = read.get("data") + "";

      synchronized (this) {
        if (window != null) window.append(text);
      }
      fireSessionReadEvent(text);
      lastRead = System.currentTimeMillis();
    }

    synchronized (this) {
      if (!"".equals(read.get("prompt")) && window != null) {
        window.updatePrompt(cleanText(read.get("prompt") + ""));
      }
    }
  }
 static synchronized PartUIClientPropertyKey getKey(Part part) {
   PartUIClientPropertyKey rv = map.get(part);
   if (rv == null) {
     rv = new PartUIClientPropertyKey(part);
     map.put(part, rv);
   }
   return rv;
 }
 /**
  * This must be called for a registered window every time the camera parameters of the window
  * change.
  */
 public synchronized void updateCameraParameters(
     AWTGLAutoDrawable window, CameraParameters params) {
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info == null) {
     throw new RuntimeException("Window not registered");
   }
   info.params.set(params);
 }
 /** Returns DebuggerInfo. */
 public DebuggerInfo getDebuggerInfo() {
   int i, k = tfParams.length;
   for (i = 0; i < k; i++) {
     Argument a = (Argument) args.get(tfParams[i].getName());
     a.setValue(tfParams[i].getText());
   }
   return new RemoteDebuggerInfo(ac, args);
 }
  public static void setEntity(ConcreteAgent ent, Map attributes) {
    Map currentMap =
        (Map)
            RenderComponentManager.retrieveIDs("ConcreteAgent", ent.getPrefs(attributes).getView());
    current = ent.getPrefs(attributes).getView();
    if (ent != null
        && currentMap.get("_attributes_") != null
        && currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) {

      ((ingenias.editor.rendererxml.AttributesPanel) currentMap.get("_attributes_")).setEntity(ent);
    }

    if (currentMap.get("Id") != null) {
      if (ent != null && ent.getId() != null) {
        if (currentMap.get("Id") instanceof javax.swing.JLabel) {
          ((javax.swing.JLabel) (currentMap).get("Id")).setText(ent.getId().toString());
        } else {
          if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent)
            ((javax.swing.text.JTextComponent) (currentMap).get("Id"))
                .setText(ent.getId().toString());
        }
      } else {
        if (currentMap.get("Id") instanceof javax.swing.JLabel)
          ((javax.swing.JLabel) (currentMap).get("Id")).setText("");
        else {
          if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel))
            ((javax.swing.text.JTextComponent) (currentMap).get("Id")).setText("");
        }
      }
    }
  }
 /**
  * Cause the manipulators for a given window to be drawn. The drawing occurs immediately; this
  * routine must be called when an OpenGL context is valid, i.e., from within the display() method
  * of a GLEventListener.
  */
 public synchronized void render(AWTGLAutoDrawable window, GL2 gl) {
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info == null) {
     throw new RuntimeException("Window not registered");
   }
   for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) {
     ((Manip) iter.next()).render(gl);
   }
 }
  /**
   * This method restores the width of the specified column to its previous width.
   *
   * @param column The column to restore.
   */
  private void restoreColumn(int column) {
    TableColumn tableColumn = table.getColumnModel().getColumn(column);
    Integer width = columnSizes.get(tableColumn);

    if (width != null) {
      table.getTableHeader().setResizingColumn(tableColumn);
      tableColumn.setWidth(width.intValue());
    }
  }
 public List getModifierActionList(Object device, Integer modifier) {
   Map<Object, ArrayList> deviceModActionMap = this.getModifierActionMap(device);
   if (deviceModActionMap == null) {
     String message = Logging.getMessage("nullValue.DeviceKeyIsNull");
     Logging.logger().severe(message);
     throw new IllegalArgumentException(message);
   }
   return (deviceModActionMap.get(modifier));
 }
Exemple #19
0
 void initialize(Map m) {
   System.out.println("Initializing");
   if (m.containsKey("wordList")) {
     System.out.println("SettingWordList");
     setWordList((Properties) m.get("wordList"));
   } else {
     setWordList(new Properties());
   }
 }
 /** show the meterpreter routes . :) */
 public void setRoutes(Route[] routes) {
   Iterator i = rows.iterator();
   while (i.hasNext()) {
     Map temp = (Map) i.next();
     for (int x = 0; x < routes.length; x++) {
       Route r = routes[x];
       if (r.shouldRoute(temp.get("Address") + "")) temp.put("Pivot", r.getGateway());
     }
   }
 }
 @Override
 public void excludeUsages(@NotNull Usage[] usages) {
   for (Usage usage : usages) {
     final UsageNode node = myUsageNodes.get(usage);
     if (node != NULL_NODE && node != null) {
       node.setUsageExcluded(true);
     }
   }
   updateImmediately();
 }
 private void motionMethod(AWTGLAutoDrawable window, int x, int y) {
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info.dragging) {
     // Compute ray in 3D
     Vec3f rayStart = new Vec3f();
     Vec3f rayDirection = new Vec3f();
     computeRay(info.params, x, y, rayStart, rayDirection);
     info.curManip.drag(rayStart, rayDirection);
     fireUpdate(info.curManip);
   }
 }
Exemple #23
0
  public boolean postProcessKeyEvent(KeyEvent e) {
    // Processing events only if we are in the focused window but
    // we are not focus owner since otherwise we will get
    // duplicate shortcut events in the client - one is from
    // activate_accelerator, another from forwarded event
    // FIXME: This is probably an incompatibility, protocol
    // doesn't say anything about disable accelerators when client
    // is focused.

    XWindowPeer parent = getToplevelXWindow();
    if (parent == null || !((Window) parent.getTarget()).isFocused() || target.isFocusOwner()) {
      return false;
    }

    boolean result = false;

    if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Post-processing event " + e);

    // Process ACCELERATORS
    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    long accel_id = 0;
    boolean exists = false;
    synchronized (ACCEL_LOCK) {
      exists = accel_lookup.containsKey(stroke);
      if (exists) {
        accel_id = accel_lookup.get(stroke).longValue();
      }
    }
    if (exists) {
      if (xembedLog.isLoggable(PlatformLogger.FINE))
        xembedLog.fine("Activating accelerator " + accel_id);
      xembed.sendMessage(
          xembed.handle,
          XEMBED_ACTIVATE_ACCELERATOR,
          accel_id,
          0,
          0); // FIXME: How about overloaded?
      result = true;
    }

    // Process Grabs, unofficial GTK feature
    exists = false;
    GrabbedKey key = new GrabbedKey(e);
    synchronized (GRAB_LOCK) {
      exists = grabbed_keys.contains(key);
    }
    if (exists) {
      if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Forwarding grabbed key " + e);
      forwardKeyEvent(e);
      result = true;
    }

    return result;
  }
 protected Comparator getComparator(int column) {
   Class columnType = tableModel.getColumnClass(column);
   Comparator comparator = (Comparator) columnComparators.get(columnType);
   if (comparator != null) {
     return comparator;
   }
   if (Comparable.class.isAssignableFrom(columnType)) {
     return COMPARABLE_COMAPRATOR;
   }
   return LEXICAL_COMPARATOR;
 }
 private void updateSelectedBotType() {
   String selectedItem = (String) typeComboBox.getSelectedItem();
   if (selectedItem == null) {
     typeComboBox.setSelectedIndex(0);
     updateSelectedBotType();
   }
   BotOptionsUI optionsUI = optionsUIs.get(selectedItem);
   if (optionsUI == null) return;
   optionsPanel.removeAll();
   optionsPanel.add(optionsUI, BorderLayout.CENTER);
   validate();
   optionsPanel.repaint();
 }
 /** Remove all references to a given window, including removing all manipulators from it. */
 public synchronized void unregisterWindow(AWTGLAutoDrawable window) {
   if (window == null) {
     return;
   }
   WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
   if (info != null) {
     Object[] manips = info.manips.toArray();
     for (int i = 0; i < manips.length; i++) {
       removeManipFromWindow((Manip) manips[i], window);
     }
     windowToInfoMap.remove(window);
     removeMouseListeners(window);
   }
 }
  private void mouseMethod(AWTGLAutoDrawable window, int modifiers, boolean isPress, int x, int y) {
    if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
      WindowInfo info = (WindowInfo) windowToInfoMap.get(window);

      if (isPress) {
        // Compute ray in 3D
        Vec3f rayStart = new Vec3f();
        Vec3f rayDirection = new Vec3f();
        computeRay(info.params, x, y, rayStart, rayDirection);
        // Compute all hits
        List hits = new ArrayList();
        for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) {
          ((Manip) iter.next()).intersectRay(rayStart, rayDirection, hits);
        }
        // Find closest one
        HitPoint hp = null;
        for (Iterator iter = hits.iterator(); iter.hasNext(); ) {
          HitPoint cur = (HitPoint) iter.next();
          if ((hp == null) || (cur.intPt.getT() < hp.intPt.getT())) {
            hp = cur;
          }
        }
        if (hp != null) {
          if (info.curHighlightedManip != null) {
            info.curHighlightedManip.clearHighlight();
            fireUpdate(info.curHighlightedManip);
            info.curHighlightedManip = null;
          }

          if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
            hp.shiftDown = true;
          }

          hp.manipulator.makeActive(hp);
          info.curManip = hp.manipulator;
          info.dragging = true;
          fireUpdate(info.curManip);
        }
      } else {
        if (info.curManip != null) {
          info.curManip.makeInactive();
          info.dragging = false;
          fireUpdate(info.curManip);
          info.curManip = null;
          // Check to see where mouse is
          passiveMotionMethod(window, x, y);
        }
      }
    }
  }
  public static void setEntity(WFResponsable ent) {
    Map currentMap =
        (Map) RenderComponentManager.retrieveIDs("WFResponsable", ent.getPrefs().getView());

    if (currentMap.get("Label") != null) {
      if (ent != null && ent.getLabel() != null) {
        if (currentMap.get("Label") instanceof javax.swing.JLabel) {
          ((javax.swing.JLabel) (currentMap).get("Label")).setText(ent.getLabel().toString());
        } else {
          if (currentMap.get("Label") instanceof javax.swing.text.JTextComponent)
            ((javax.swing.text.JTextComponent) (currentMap).get("Label"))
                .setText(ent.getLabel().toString());
        }
      } else {
        if (currentMap.get("Label") instanceof javax.swing.JLabel)
          ((javax.swing.JLabel) (currentMap).get("Label")).setText("");
        else {
          if (!(currentMap.get("Label") instanceof ingenias.editor.rendererxml.CollectionPanel))
            ((javax.swing.text.JTextComponent) (currentMap).get("Label")).setText("");
        }
      }
    }
  }
Exemple #29
0
  public void run() {
    Map read;
    boolean shouldRead = go_read;
    String command = null;
    long last = 0;

    try {
      /* swallow the banner if requested to do so */
      if (swallow) {
        readResponse();
      }

      while (shouldRead) {
        synchronized (listeners) {
          if (commands.size() > 0) {
            command = (String) commands.removeFirst();
          }
        }

        if (command != null) {
          _sendString(command);
          command = null;
          lastRead = System.currentTimeMillis();
        }

        long now = System.currentTimeMillis();
        if (this.window != null && !this.window.isShowing() && (now - last) < 1500) {
          /* check if our window is not showing... if not, then we're going to switch to a very reduced
          read schedule. */
        } else {
          read = readResponse();
          if (read == null || "failure".equals(read.get("result") + "")) {
            break;
          }

          processRead(read);
          last = System.currentTimeMillis();
        }

        Thread.sleep(100);

        synchronized (listeners) {
          shouldRead = go_read;
        }
      }
    } catch (Exception javaSucksBecauseItMakesMeCatchEverythingFuckingThing) {
      javaSucksBecauseItMakesMeCatchEverythingFuckingThing.printStackTrace();
    }
  }
  @Override
  public void selectUsages(@NotNull Usage[] usages) {
    List<TreePath> paths = new LinkedList<TreePath>();

    for (Usage usage : usages) {
      final UsageNode node = myUsageNodes.get(usage);

      if (node != NULL_NODE && node != null) {
        paths.add(new TreePath(node.getPath()));
      }
    }

    myTree.setSelectionPaths(paths.toArray(new TreePath[paths.size()]));
    if (!paths.isEmpty()) myTree.scrollPathToVisible(paths.get(0));
  }