public static void initParams(String[] s) {
    if (s.length != 3) {
      autorun = true;
      debug = false;
      testModifier = NONE;
    } else {
      autorun = Boolean.valueOf(s[0]);
      debug = Boolean.valueOf(s[1]);

      if (s[2].equals("NONE")) {
        testModifier = NONE;
      }
      if (s[2].equals("SHIFT")) {
        testModifier = SHIFT;
      }
      if (s[2].equals("CTRL")) {
        testModifier = CTRL;
      }
      if (s[2].equals("ALT")) {
        testModifier = ALT;
      }
    }
    System.out.println("Autorun : " + autorun);
    System.out.println("Debug mode : " + debug);
    System.out.println("Modifier to verify : " + testModifier);
  }
Пример #2
0
 /**
  * Gets the <code>defaultLightWeightPopupEnabled</code> property, which by default is <code>true
  * </code>.
  *
  * @return the value of the <code>defaultLightWeightPopupEnabled</code> property
  * @see #setDefaultLightWeightPopupEnabled
  */
 public static boolean getDefaultLightWeightPopupEnabled() {
   Boolean b = (Boolean) SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
   if (b == null) {
     SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
     return true;
   }
   return b.booleanValue();
 }
Пример #3
0
 void LoadConfig() {
   String id = Long.toString(robot_uid);
   limit_top = Double.valueOf(prefs.get(id + "_limit_top", "0"));
   limit_bottom = Double.valueOf(prefs.get(id + "_limit_bottom", "0"));
   limit_left = Double.valueOf(prefs.get(id + "_limit_left", "0"));
   limit_right = Double.valueOf(prefs.get(id + "_limit_right", "0"));
   m1invert = Boolean.parseBoolean(prefs.get(id + "_m1invert", "false"));
   m2invert = Boolean.parseBoolean(prefs.get(id + "_m2invert", "false"));
 }
Пример #4
0
 void SaveConfig() {
   String id = Long.toString(robot_uid);
   prefs.put(id + "_limit_top", Double.toString(limit_top));
   prefs.put(id + "_limit_bottom", Double.toString(limit_bottom));
   prefs.put(id + "_limit_right", Double.toString(limit_right));
   prefs.put(id + "_limit_left", Double.toString(limit_left));
   prefs.put(id + "_m1invert", Boolean.toString(m1invert));
   prefs.put(id + "_m2invert", Boolean.toString(m2invert));
 }
 public void setValueAt(Object aValue, int row, int column) {
   Boolean bolVal = (Boolean) aValue;
   conditionTypes[row][0] = aValue;
   if (bolVal.booleanValue()) {
     condition.addType((MediaType) conditionTypes[row][1]);
   } else {
     condition.removeType((MediaType) conditionTypes[row][1]);
   }
 }
  private void setActive(boolean active) {
    myCloseButton.putClientProperty("paintActive", Boolean.valueOf(active));

    if (getWindowDecorationStyle() == JRootPane.FRAME) {
      myIconifyButton.putClientProperty("paintActive", Boolean.valueOf(active));
      myToggleButton.putClientProperty("paintActive", Boolean.valueOf(active));
    }

    getRootPane().repaint();
  }
Пример #7
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
Пример #8
0
 public void keyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   if (code == KeyEvent.VK_SPACE) {
     AbstractButton button = (AbstractButton) e.getSource();
     Boolean wasPressed = (Boolean) button.getClientProperty(SPACEBAR_PRESSED);
     if (wasPressed == null || wasPressed.booleanValue() == false) {
       button.putClientProperty(SPACEBAR_PRESSED, Boolean.TRUE);
       button.doClick();
     }
   }
 }
Пример #9
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     // System.out.println("Debug:TextViewer: ActionChangedListener enabled");
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
  public void configurationChanged(ConfigurationChangeEvent evt) {
    if (evt == null || evt.getPropertyName().startsWith("recording")) {
      enableMouseMoves = cfg.getBoolean("recording.enableMouseMoves").booleanValue();
      enableMouseDrags = cfg.getBoolean("recording.enableMouseDrags").booleanValue();
      enableMouseClicks = cfg.getBoolean("recording.enableMouseClicks").booleanValue();
      enableKeyboard = cfg.getBoolean("recording.enableKeyboard").booleanValue();
      enableMouseWheel = cfg.getBoolean("recording.enableMouseWheel").booleanValue();

      RFB_SIZE_LIMIT = cfg.getInteger("recording.minEventSize").intValue();

      // This delay will be used to decide whether two subsequent clicks define a double click or
      // two separate clicks
      mouseMultiDelay = cfg.getInteger("recording.mouse.multiClickDelay").intValue();
      mouseMoveDelay = cfg.getInteger("recording.mouse.moveDelay").intValue();
      mouseMoveInsertPrevious = cfg.getInteger("recording.mouse.moveInsertPrevious").intValue();
      if (mouseMovesList.size() > mouseMoveInsertPrevious) {
        mouseMovesList.remove(mouseMovesList.size() - 1);
      }

      keyMutiDelay = cfg.getInteger("recording.keyboard.multiKeyDelay").intValue();
      useTypeline = cfg.getBoolean("recording.keyboard.enableTypeline").booleanValue();
      typelineDelay = cfg.getInteger("recording.keyboard.typelineDelay").intValue();

      insertUpdateArea = cfg.getBoolean("recording.waitfor.update.insertArea").booleanValue();
      insertUpdateExtent = cfg.getBoolean("recording.waitfor.update.insertExtent").booleanValue();
      defaultUpdateExtent = cfg.getDouble("recording.waitfor.update.defaultExtent").floatValue();
      insertUpdateTimeout = cfg.getBoolean("recording.waitfor.update.insertTimeout").booleanValue();
      timeoutUpdateRatio = cfg.getDouble("recording.waitfor.update.timeoutRatio").floatValue();
      useMinUpdateTimeout = cfg.getBoolean("recording.waitfor.update.useMinTimeout").booleanValue();
      minUpdateTimeout = cfg.getInteger("recording.waitfor.update.minTimeout").intValue();

      useUpdateWait = cfg.getBoolean("recording.waitfor.update.useWait").booleanValue();
      useMinUpdateWait = cfg.getBoolean("recording.waitfor.update.useMinWait").booleanValue();
      waitUpdateRatio = cfg.getDouble("recording.waitfor.update.waitRatio").floatValue();
      minUpdateWait = cfg.getInteger("recording.waitfor.update.minWait").intValue();
      resetUpdateWait = cfg.getBoolean("recording.waitfor.update.resetUpdateWait").booleanValue();

      useBellCount = cfg.getBoolean("recording.waitfor.bell.useCount").booleanValue();
      insertBellTimeout = cfg.getBoolean("recording.waitfor.bell.insertTimeout").booleanValue();
      timeoutBellRatio = cfg.getDouble("recording.waitfor.bell.timeoutRatio").floatValue();
      useMinBellTimeout = cfg.getBoolean("recording.waitfor.bell.useMinTimeout").booleanValue();
      minBellTimeout = cfg.getInteger("recording.waitfor.bell.minTimeout").intValue();
      resetBellWait = cfg.getBoolean("recording.waitfor.bell.resetBellWait").booleanValue();
    } else if (evt.getPropertyName().startsWith("rfb.readOnly")) {
      Boolean b = cfg.getBoolean("rfb.readOnly");
      readOnly = b == null ? false : b.booleanValue();
      if (readOnly) {
        resetTime();
      }
    }
  }
Пример #11
0
    /** User has clicked OK in the surrounding JPanel, so save the current state of all variables */
    public void ok() {
      // get the values from the controls and set them in the static properties
      useJavaDefaultFormat = useJavaDefaultFormatChk.isSelected();
      DTProperties.put(
          thisClassName, "useJavaDefaultFormat", Boolean.valueOf(useJavaDefaultFormat).toString());

      localeFormat = dateFormatTypeDrop.getValue();
      dateFormat = new ThreadSafeDateFormat(localeFormat, true); // lenient is set next
      DTProperties.put(thisClassName, "localeFormat", Integer.toString(localeFormat));

      lenient = lenientChk.isSelected();
      dateFormat.setLenient(lenient);
      DTProperties.put(thisClassName, "lenient", Boolean.valueOf(lenient).toString());

      initDateFormat(localeFormat, lenient);
    }
 @Override
 public Object getValue() {
   JTextField text = getComboText();
   if (text == null) {
     return myBooleanResourceValue == null
         ? Boolean.toString(myCheckBox.isSelected())
         : myBooleanResourceValue;
   }
   String value = text.getText();
   if (value == StringsComboEditor.UNSET || StringUtil.isEmpty(value)) {
     return null;
   }
   if (myIsDimension
       && !value.startsWith("@")
       && !value.endsWith("dip")
       && !value.equalsIgnoreCase("wrap_content")
       && !value.equalsIgnoreCase("fill_parent")
       && !value.equalsIgnoreCase("match_parent")) {
     if (value.length() <= 2) {
       return value + "dp";
     }
     int index = value.length() - 2;
     String dimension = value.substring(index);
     if (ArrayUtil.indexOf(ResourceRenderer.DIMENSIONS, dimension) == -1) {
       return value + "dp";
     }
   }
   return value;
 }
  @Override
  public void dispose() {
    PropertiesComponent instance = PropertiesComponent.getInstance();
    instance.setValue(PROP_SORTED, Boolean.toString(isAlphabeticallySorted()));
    instance.setValue(PROP_SHOWCLASSES, Boolean.toString(myShowClasses));

    if (myCopyJavadocCheckbox != null) {
      instance.setValue(PROP_COPYJAVADOC, Boolean.toString(myCopyJavadocCheckbox.isSelected()));
    }

    final Container contentPane = getContentPane();
    if (contentPane != null) {
      contentPane.removeAll();
    }
    mySelectedNodes.clear();
    myElements = null;
    super.dispose();
  }
Пример #14
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   boolean fullscrenable = Boolean.parseBoolean(value.toString());
   if (c.target instanceof RootPaneContainer
       && c.getPeer().getPeerType() == PeerType.FRAME) {
     if (c.isInFullScreen && !fullscrenable) {
       c.toggleFullScreen();
     }
   }
   c.setStyleBits(FULLSCREENABLE, fullscrenable);
 }
Пример #15
0
  /**
   * The handler for the security event received. The security event for starting establish a secure
   * connection.
   *
   * @param evt the security started event received
   */
  public void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent evt) {
    if (Boolean.parseBoolean(
        GuiActivator.getResources().getSettingsString("impl.gui.PARANOIA_UI"))) {
      SrtpControl srtpControl = null;
      if (callPeer instanceof MediaAwareCallPeer) srtpControl = evt.getSecurityController();

      securityPanel = new ParanoiaTimerSecurityPanel<SrtpControl>(srtpControl);

      setSecurityPanelVisible(true);
    }
  }
  @NotNull
  @Override
  public JComponent getComponent(
      @Nullable PropertiesContainer container,
      @Nullable PropertyContext context,
      Object object,
      @Nullable InplaceContext inplaceContext) {
    myComponent = (RadComponent) container;
    myRootComponent =
        context instanceof RadPropertyContext
            ? ((RadPropertyContext) context).getRootComponent()
            : null;

    String value = (String) object;
    JTextField text = getComboText();

    if (text == null) {
      if (StringUtil.isEmpty(value) || value.equals("true") || value.equals("false")) {
        myBooleanResourceValue = null;
      } else {
        myBooleanResourceValue = value;
      }

      try {
        myIgnoreCheckBoxValue = true;
        myCheckBox.setSelected(Boolean.parseBoolean(value));
      } finally {
        myIgnoreCheckBoxValue = false;
      }

      if (inplaceContext == null) {
        myEditor.setBorder(null);
        myCheckBox.setText(null);
      } else {
        myEditor.setBorder(myCheckBoxBorder);
        myCheckBox.setText(myBooleanResourceValue);
      }
    } else {
      text.setText(value);
      if (inplaceContext != null) {
        text.setColumns(0);
        if (inplaceContext.isStartChar()) {
          text.setText(inplaceContext.getText(text.getText()));
        }
      }
    }
    return myEditor;
  }
Пример #17
0
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
Пример #18
0
  /**
   * @param aEvent
   * @param aStartPoint
   */
  protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) {
    // For now, disabled by default as it isn't 100% working yet...
    if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) {
      return;
    }

    final JComponent source = (JComponent) aEvent.getComponent();
    final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED);

    final GhostGlassPane glassPane =
        (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane();

    Rectangle viewRect;
    final JScrollPane scrollPane =
        SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source);
    if (scrollPane != null) {
      final JViewport viewport = scrollPane.getViewport();
      viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane);
    } else {
      viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane);
    }

    final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane);
    final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane);

    if (dragging) {
      if (!glassPane.isVisible()) {
        glassPane.setVisible(true);
        glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect);
      } else {
        glassPane.updateRenderer(start, current, viewRect);
      }

      glassPane.repaintPartially();
    } else
    /* if ( !dragging ) */
    {
      // Fire off a signal to the zoom controller to do its job...
      this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint());

      glassPane.setVisible(false);
    }
  }
Пример #19
0
    protected void configureEnableToggle(
        Boolean initiallyEnabled, String valueIfDisabled, final List<JComponent> components) {
      if (initiallyEnabled != null) {
        enable = new JCheckBox();
        boolean enabled = initiallyEnabled.booleanValue();
        this.enable.setSelected(enabled);
        for (JComponent c : components) {
          c.setEnabled(enabled);
        }
        this.valueIfDisabled = valueIfDisabled;

        final OptionField f = this;
        this.enable.addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(ItemEvent e) {
                for (JComponent c : components) {
                  c.setEnabled(f.isEnabled());
                }
                fireChangeEvent();
              }
            });
      }
    }
Пример #20
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(
       DOCUMENT_MODIFIED,
       value == null ? false : Boolean.parseBoolean(value.toString()));
 }
Пример #21
0
  /**
   * Returns the main control panel.
   *
   * @param mainFrame The main test frame.
   * @param mainTabbedPane The main tabbed pane.
   * @param mainTabPreviewPainter The preview painter of the main tabbed pane.
   * @param toolbar The toolbar of the main test frame.
   * @return The main control panel.
   */
  public static JPanel getMainControlPanel(
      final JFrame mainFrame,
      final JTabbedPane mainTabbedPane,
      final MyMainTabPreviewPainter mainTabPreviewPainter,
      final JToolBar toolbar) {
    FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(lm);
    // builder.setDefaultDialogBorder();

    builder.appendSeparator("Title pane settings");
    final JCheckBox markAsModified = new JCheckBox("Marked modified");
    markAsModified.setOpaque(false);
    markAsModified.setSelected(false);
    markAsModified.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mainFrame
                .getRootPane()
                .putClientProperty(
                    SubstanceLookAndFeel.WINDOW_MODIFIED,
                    (markAsModified.isSelected() ? Boolean.TRUE : false));
          }
        });
    builder.append("Modified", markAsModified);

    final JCheckBox heapPanel = new JCheckBox("Has heap panel");
    heapPanel.setOpaque(false);
    heapPanel.setSelected(false);
    heapPanel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(),
                heapPanel.isSelected(),
                SubstanceWidgetType.TITLE_PANE_HEAP_STATUS);
          }
        });
    builder.append("Heap panel", heapPanel);

    JButton changeTitleButton = new JButton("Change");
    changeTitleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String random = "abcdefghijklmnopqrstuvwxyz ";
            int length = 60 + (int) (150 * Math.random());
            String title = "";
            while (length > 0) {
              title += random.charAt((int) (random.length() * Math.random()));
              length--;
            }
            mainFrame.setTitle(title);
          }
        });
    builder.append("Title string", changeTitleButton);

    builder.appendSeparator("Miscellaneous");

    final JCheckBox defaultRoundedCorners = new JCheckBox("by default");
    defaultRoundedCorners.setOpaque(false);
    boolean roundable =
        Boolean.valueOf(
            System.getProperty(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS_PROPERTY, "True"));
    defaultRoundedCorners.setSelected(roundable);
    defaultRoundedCorners.setEnabled(roundable);
    defaultRoundedCorners.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, defaultRoundedCorners.isSelected());
          }
        });
    builder.append("Rounded Windows", defaultRoundedCorners);

    final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox("use themed icons");
    useThemedDefaultIconsCheckBox.setOpaque(false);
    useThemedDefaultIconsCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    UIManager.put(
                        SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS,
                        useThemedDefaultIconsCheckBox.isSelected() ? Boolean.TRUE : null);
                    mainFrame.repaint();
                  }
                });
          }
        });
    builder.append("Themed icons", useThemedDefaultIconsCheckBox);

    final JCheckBox useConstantThemesOnDialogs = new JCheckBox("use constant themes");
    useConstantThemesOnDialogs.setOpaque(false);
    useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel.isToUseConstantThemesOnDialogs());
    useConstantThemesOnDialogs.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(
                        useConstantThemesOnDialogs.isSelected());
                    SubstanceLookAndFeel.setSkin(
                        SubstanceLookAndFeel.getCurrentSkin(mainFrame.getRootPane()));
                  }
                });
          }
        });
    builder.append("Option pane icons", useConstantThemesOnDialogs);

    final JComboBox placementCombo = new JComboBox(new Object[] {"top", "bottom", "left", "right"});
    placementCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selected = (String) placementCombo.getSelectedItem();
            if ("top".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.TOP);
            if ("bottom".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
            if ("left".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.LEFT);
            if ("right".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.RIGHT);
          }
        });
    builder.append("Placement", placementCombo);

    try {
      final JComboBox overviewKindCombo =
          new FlexiComboBox<TabOverviewKind>(
              TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) {
            @Override
            public String getCaption(TabOverviewKind item) {
              return item.getName();
            }
          };
      overviewKindCombo.setSelectedItem(
          LafWidgetUtilities2.getTabPreviewPainter(mainTabbedPane).getOverviewKind(mainTabbedPane));
      overviewKindCombo.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              mainTabPreviewPainter.setTabOverviewKind(
                  (TabOverviewKind) overviewKindCombo.getSelectedItem());
            }
          });

      builder.append("Overview kind", overviewKindCombo);
    } catch (NoClassDefFoundError ignored) {
    }

    final JComboBox menuGutterFillCombo =
        new FlexiComboBox<MenuGutterFillKind>(
            MenuGutterFillKind.NONE,
            MenuGutterFillKind.SOFT,
            MenuGutterFillKind.HARD,
            MenuGutterFillKind.SOFT_FILL,
            MenuGutterFillKind.HARD_FILL) {
          @Override
          public String getCaption(MenuGutterFillKind item) {
            return item.name();
          }
        };
    menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD);
    menuGutterFillCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem());
          }
        });
    builder.append("Menu fill", menuGutterFillCombo);

    final JComboBox focusKindCombo =
        new FlexiComboBox<FocusKind>(FocusKind.values()) {
          @Override
          public String getCaption(FocusKind item) {
            return item.name();
          }
        };
    focusKindCombo.setSelectedItem(FocusKind.ALL_INNER);
    focusKindCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo.getSelectedItem());
          }
        });
    builder.append("Focus kind", focusKindCombo);

    JButton buttonGlassPane = new JButton("Show");
    buttonGlassPane.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final JPanel glassPane =
                new JPanel() {
                  @Override
                  public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Graphics2D graphics = (Graphics2D) g;
                    int height = getHeight();
                    int width = getWidth();
                    Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.4);
                    graphics.setComposite(c);
                    for (int i = 0; i < height; i++) {
                      Color color =
                          (i % 2 == 0) ? new Color(200, 200, 255) : new Color(230, 230, 255);
                      graphics.setColor(color);
                      graphics.drawLine(0, i, width, i);
                    }
                    Composite c2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 1.0);
                    graphics.setComposite(c2);
                  }
                };
            glassPane.setOpaque(false);
            glassPane.addMouseListener(new MouseAdapter() {});
            glassPane.addKeyListener(new KeyAdapter() {});
            mainFrame.setGlassPane(glassPane);
            new Thread() {
              @Override
              public void run() {
                glassPane.setVisible(true);
                try {
                  Thread.sleep(5000);
                } catch (InterruptedException ie) {
                  ie.printStackTrace();
                }
                glassPane.setVisible(false);
              }
            }.start();
          }
        });
    builder.append("Glass pane", buttonGlassPane);

    builder.appendSeparator("Custom animations");
    final JCheckBox allowFocusLoopAnimations = new JCheckBox("Allow animation");
    allowFocusLoopAnimations.setOpaque(false);
    allowFocusLoopAnimations.setSelected(
        AnimationConfigurationManager.getInstance()
            .isAnimationAllowed(AnimationFacet.FOCUS_LOOP_ANIMATION, null));
    allowFocusLoopAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowFocusLoopAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            }
          }
        });
    builder.append("Focus loop", allowFocusLoopAnimations);

    final JCheckBox allowGlowIconAnimations = new JCheckBox("Allow animation");
    allowGlowIconAnimations.setOpaque(false);
    allowGlowIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGlowIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance().allowAnimations(AnimationFacet.ICON_GLOW);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.ICON_GLOW);
            }
          }
        });
    builder.append("Icon glow", allowGlowIconAnimations);

    final JCheckBox allowGhostIconAnimations = new JCheckBox("Allow animation");
    allowGhostIconAnimations.setOpaque(false);
    allowGhostIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            }
          }
        });
    builder.append("Icon rollover", allowGhostIconAnimations);

    final JCheckBox allowGhostPressAnimations = new JCheckBox("Allow animation");
    allowGhostPressAnimations.setOpaque(false);
    allowGhostPressAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostPressAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            }
          }
        });
    builder.append("Button press", allowGhostPressAnimations);

    builder.appendSeparator("Toolbar");
    final JCheckBox isToolbarFlat = new JCheckBox("Is flat");
    isToolbarFlat.setOpaque(false);
    isToolbarFlat.setSelected(true);
    isToolbarFlat.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            toolbar.putClientProperty(
                SubstanceLookAndFeel.FLAT_PROPERTY, isToolbarFlat.isSelected());
            toolbar.repaint();
          }
        });
    builder.append("Flat", isToolbarFlat);

    builder.appendSeparator("Menu bar");
    final JCheckBox menuSearch = new JCheckBox("Has menu search");
    menuSearch.setOpaque(false);
    menuSearch.setSelected(false);
    menuSearch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(), menuSearch.isSelected(), SubstanceWidgetType.MENU_SEARCH);
          }
        });
    builder.append("Menu search", menuSearch);

    final JCheckBox menuLocale = new JCheckBox("Has custom locale");
    menuLocale.setOpaque(false);
    menuLocale.setSelected(false);
    menuLocale.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (menuLocale.isSelected()) {
              mainFrame.getJMenuBar().setLocale(Locale.FRENCH);
              mainFrame
                  .getJMenuBar()
                  .putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE);
            } else {
              mainFrame.getJMenuBar().putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, null);
            }
          }
        });
    builder.append("Menu locale", menuLocale);

    JPanel result = builder.getPanel();
    result.setName("Main control panel");
    return result;
  }
Пример #22
0
  /** Initializes this component. */
  protected void init() {
    this.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    this.setOpaque(false);

    this.add(inviteButton);

    // if we leave a chat room when we close the window
    // there is no need for this button
    if (!ConfigurationUtils.isLeaveChatRoomOnWindowCloseEnabled()) this.add(leaveChatRoomButton);

    this.add(callButton);
    this.add(callVideoButton);
    this.add(desktopSharingButton);
    this.add(sendFileButton);

    ChatPanel chatPanel = chatContainer.getCurrentChat();
    if (chatPanel == null || !(chatPanel.getChatSession() instanceof MetaContactChatSession))
      sendFileButton.setEnabled(false);

    this.addSeparator();

    this.add(historyButton);
    this.add(previousButton);
    this.add(nextButton);

    // We only add the options button if the property SHOW_OPTIONS_WINDOW
    // specifies so or if it's not set.
    Boolean showOptionsProp =
        GuiActivator.getConfigurationService()
            .getBoolean(ConfigurationFrame.SHOW_OPTIONS_WINDOW_PROPERTY, false);

    if (showOptionsProp.booleanValue()) {
      this.add(optionsButton);
    }

    this.addSeparator();

    if (ConfigurationUtils.isFontSupportEnabled()) {
      this.add(fontButton);
      fontButton.setName("font");
      fontButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CHANGE_FONT"));
      fontButton.addActionListener(this);
    }

    initSmiliesSelectorBox();

    this.addSeparator();

    this.inviteButton.setName("invite");
    this.inviteButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.INVITE"));

    this.leaveChatRoomButton.setName("leave");
    this.leaveChatRoomButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.LEAVE"));

    this.callButton.setName("call");
    this.callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

    this.callVideoButton.setName("callVideo");
    this.callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

    this.desktopSharingButton.setName("desktop");
    this.desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP_WITH_CONTACT"));

    this.historyButton.setName("history");
    this.historyButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.HISTORY") + " Ctrl-H");

    optionsButton.setName("options");
    optionsButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.OPTIONS"));

    this.sendFileButton.setName("sendFile");
    this.sendFileButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_FILE"));

    this.previousButton.setName("previous");
    this.previousButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.PREVIOUS"));

    this.nextButton.setName("next");
    this.nextButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.NEXT"));

    inviteButton.addActionListener(this);
    leaveChatRoomButton.addActionListener(this);
    callButton.addActionListener(this);
    callVideoButton.addActionListener(this);
    desktopSharingButton.addActionListener(this);
    historyButton.addActionListener(this);
    optionsButton.addActionListener(this);
    sendFileButton.addActionListener(this);
    previousButton.addActionListener(this);
    nextButton.addActionListener(this);
  }
Пример #23
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(
       HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
 }
Пример #24
0
  /**
   * Indicates that the security is turned on.
   *
   * <p>Sets the secured status icon to the status panel and initializes/updates the corresponding
   * security details.
   *
   * @param evt Details about the event that caused this message.
   */
  public void securityOn(final CallPeerSecurityOnEvent evt) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              securityOn(evt);
            }
          });
      return;
    }

    // If the securityOn is called without a specific event, we'll just set
    // the security label status to on.
    if (evt == null) {
      securityStatusLabel.setSecurityOn();
      return;
    }

    SrtpControl srtpControl = evt.getSecurityController();

    if (!srtpControl.requiresSecureSignalingTransport()
        || callPeer.getProtocolProvider().isSignalingTransportSecure()) {
      if (srtpControl instanceof ZrtpControl) {
        securityStatusLabel.setText("zrtp");

        if (!((ZrtpControl) srtpControl).isSecurityVerified())
          securityStatusLabel.setSecurityPending();
        else securityStatusLabel.setSecurityOn();
      } else securityStatusLabel.setSecurityOn();
    }

    // if we have some other panel, using other control
    if (!srtpControl.getClass().isInstance(securityPanel.getSecurityControl())
        || (securityPanel instanceof ParanoiaTimerSecurityPanel)) {
      setSecurityPanelVisible(false);

      securityPanel = SecurityPanel.create(this, callPeer, srtpControl);

      if (srtpControl instanceof ZrtpControl)
        ((ZrtpSecurityPanel) securityPanel).setSecurityStatusLabel(securityStatusLabel);
    }

    securityPanel.securityOn(evt);

    boolean isSecurityLowPriority =
        Boolean.parseBoolean(
            GuiActivator.getResources()
                .getSettingsString("impl.gui.I_DONT_CARE_THAT_MUCH_ABOUT_SECURITY"));

    // Display ZRTP panel in case SAS was not verified or a AOR mismtach
    // was detected during creation of ZrtpSecurityPanel.
    // Don't show panel if user does not care about security at all.
    if (srtpControl instanceof ZrtpControl
        && !isSecurityLowPriority
        && (!((ZrtpControl) srtpControl).isSecurityVerified()
            || ((ZrtpSecurityPanel) securityPanel).isZidAorMismatch())) {
      setSecurityPanelVisible(true);
    }

    this.revalidate();
  }
Пример #25
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
 }
Пример #26
0
  /** Constructs the <tt>LoginWindow</tt>. */
  private void init() {
    String title;

    if (windowTitle != null) title = windowTitle;
    else
      title =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server});

    String text;
    if (windowText != null) text = windowText;
    else
      text =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server});

    String uinText;
    if (usernameLabelText != null) uinText = usernameLabelText;
    else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER");

    String passText;
    if (passwordLabelText != null) passText = passwordLabelText;
    else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD");

    setTitle(title);

    infoTextArea.setEditable(false);
    infoTextArea.setOpaque(false);
    infoTextArea.setLineWrap(true);
    infoTextArea.setWrapStyleWord(true);
    infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    infoTextArea.setText(text);
    infoTextArea.setAlignmentX(0.5f);

    JLabel uinLabel = new JLabel(uinText);
    uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD));

    JLabel passwdLabel = new JLabel(passText);
    passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    TransparentPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    labelsPanel.add(uinLabel);
    labelsPanel.add(passwdLabel);

    TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    textFieldsPanel.add(uinValue);
    textFieldsPanel.add(passwdField);

    JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2));

    this.rememberPassCheckBox.setOpaque(false);
    this.rememberPassCheckBox.setBorder(null);

    southFieldsPanel.add(rememberPassCheckBox);
    if (signupLink != null && signupLink.length() > 0)
      southFieldsPanel.add(
          createWebSignupLabel(
              DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"),
              signupLink));
    else southFieldsPanel.add(new JLabel());

    boolean allowRememberPassword = true;

    String allowRemPassStr =
        DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD);
    if (allowRemPassStr != null) {
      allowRememberPassword = Boolean.parseBoolean(allowRemPassStr);
    }
    allowRememberPassword =
        DesktopUtilActivator.getConfigurationService()
            .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword);

    setAllowSavePassword(allowRememberPassword);

    JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    JPanel southEastPanel = new TransparentPanel(new BorderLayout());
    southEastPanel.add(buttonPanel, BorderLayout.EAST);

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));

    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));

    JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10));
    mainFieldsPanel.add(labelsPanel, BorderLayout.WEST);
    mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER);
    mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH);

    mainPanel.add(infoTextArea, BorderLayout.NORTH);
    mainPanel.add(mainFieldsPanel, BorderLayout.CENTER);
    mainPanel.add(southEastPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel, BorderLayout.EAST);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");
    if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width)
      cancelButton.setPreferredSize(loginButton.getPreferredSize());
    else loginButton.setPreferredSize(cancelButton.getPreferredSize());

    this.loginButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);
  }
Пример #27
0
  protected int getInitialStyleBits() {
    // defaults style bits
    int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;

    if (isNativelyFocusableWindow()) {
      styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
      styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
    }

    final boolean isFrame = (target instanceof Frame);
    final boolean isDialog = (target instanceof Dialog);
    final boolean isPopup = (target.getType() == Window.Type.POPUP);
    if (isDialog) {
      styleBits = SET(styleBits, MINIMIZABLE, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always
    // is undecorated.
    {
      this.undecorated =
          isFrame
              ? ((Frame) target).isUndecorated()
              : (isDialog ? ((Dialog) target).isUndecorated() : true);
      if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never
    // resizable
    {
      final boolean resizable =
          isFrame
              ? ((Frame) target).isResizable()
              : (isDialog ? ((Dialog) target).isResizable() : false);
      styleBits = SET(styleBits, RESIZABLE, resizable);
      if (!resizable) {
        styleBits = SET(styleBits, ZOOMABLE, false);
      } else {
        setCanFullscreen(true);
      }
    }

    if (target.isAlwaysOnTop()) {
      styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
    }

    if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
      styleBits = SET(styleBits, MODAL_EXCLUDED, true);
    }

    // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
    if (isPopup) {
      styleBits = SET(styleBits, TEXTURED, false);
      // Popups in applets don't activate applet's process
      styleBits = SET(styleBits, NONACTIVATING, true);
      styleBits = SET(styleBits, IS_POPUP, true);
    }

    if (Window.Type.UTILITY.equals(target.getType())) {
      styleBits = SET(styleBits, UTILITY, true);
    }

    if (target instanceof javax.swing.RootPaneContainer) {
      javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane();
      Object prop = null;

      prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
      if (prop != null) {
        styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
      }

      if (isDialog && ((Dialog) target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
        prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
        if (prop != null) {
          styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString()));
        }
      }

      prop = rootpane.getClientProperty(WINDOW_STYLE);
      if (prop != null) {
        if ("small".equals(prop)) {
          styleBits = SET(styleBits, UTILITY, true);
          if (target.isAlwaysOnTop()
              && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) {
            styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true);
          }
        }
        if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true);
        if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true);
        if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true);
      }

      prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE);
      if (prop != null) {
        styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_CLOSEABLE);
      if (prop != null) {
        styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE);
      if (prop != null) {
        styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
      if (prop != null) {
        styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
      if (prop != null) {
        styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_SHADOW);
      if (prop != null) {
        styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
      if (prop != null) {
        styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
      }
    }

    if (isDialog) {
      styleBits = SET(styleBits, IS_DIALOG, true);
      if (((Dialog) target).isModal()) {
        styleBits = SET(styleBits, IS_MODAL, true);
      }
    }

    peer.setTextured(IS(TEXTURED, styleBits));

    return styleBits;
  }
Пример #28
0
  /**
   * exports the data to a CSV file
   *
   * @param aFile File object
   */
  private void storeToCsvFile(final File aFile, final UARTDataSet aDataSet) {
    try {
      final CsvExporter exporter = ExportUtils.createCsvExporter(aFile);

      exporter.setHeaders(
          "index",
          "start-time",
          "end-time",
          "event?",
          "event-type",
          "RxD event",
          "TxD event",
          "RxD data",
          "TxD data");

      final List<UARTData> decodedData = aDataSet.getData();
      for (int i = 0; i < decodedData.size(); i++) {
        final UARTData ds = decodedData.get(i);

        final String startTime = Unit.Time.format(aDataSet.getTime(ds.getStartSampleIndex()));
        final String endTime = Unit.Time.format(aDataSet.getTime(ds.getEndSampleIndex()));

        String eventType = null;
        String rxdEvent = null;
        String txdEvent = null;
        String rxdData = null;
        String txdData = null;

        switch (ds.getType()) {
          case UARTData.UART_TYPE_EVENT:
            eventType = ds.getEventName();
            break;

          case UARTData.UART_TYPE_RXEVENT:
            rxdEvent = ds.getEventName();
            break;

          case UARTData.UART_TYPE_TXEVENT:
            txdEvent = ds.getEventName();
            break;

          case UARTData.UART_TYPE_RXDATA:
            rxdData = Integer.toString(ds.getData());
            break;

          case UARTData.UART_TYPE_TXDATA:
            txdData = Integer.toString(ds.getData());
            break;

          default:
            break;
        }

        exporter.addRow(
            Integer.valueOf(i),
            startTime,
            endTime,
            Boolean.valueOf(ds.isEvent()),
            eventType,
            rxdEvent,
            txdEvent,
            rxdData,
            txdData);
      }

      exporter.close();
    } catch (final IOException exception) {
      // Make sure to handle IO-interrupted exceptions properly!
      if (!HostUtils.handleInterruptedException(exception)) {
        LOG.log(Level.WARNING, "CSV export failed!", exception);
      }
    }
  }
Пример #29
0
  public XDebuggerTree(
      final @NotNull Project project,
      final @NotNull XDebuggerEditorsProvider editorsProvider,
      final @Nullable XSourcePosition sourcePosition,
      final @NotNull String popupActionGroupId,
      @Nullable XValueMarkers<?, ?> valueMarkers) {
    myValueMarkers = valueMarkers;
    myProject = project;
    myEditorsProvider = editorsProvider;
    mySourcePosition = sourcePosition;
    myTreeModel = new DefaultTreeModel(null);
    setModel(myTreeModel);
    setCellRenderer(new XDebuggerTreeRenderer());
    new TreeLinkMouseListener(new XDebuggerTreeRenderer()) {
      @Override
      protected boolean doCacheLastNode() {
        return false;
      }

      @Override
      protected void handleTagClick(@Nullable Object tag, @NotNull MouseEvent event) {
        if (tag instanceof XDebuggerTreeNodeHyperlink) {
          ((XDebuggerTreeNodeHyperlink) tag).onClick(event);
        }
      }
    }.installOn(this);
    setRootVisible(false);
    setShowsRootHandles(true);

    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        return expandIfEllipsis();
      }
    }.installOn(this);

    addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_SPACE || key == KeyEvent.VK_RIGHT) {
              expandIfEllipsis();
            }
          }
        });

    if (Boolean.valueOf(System.getProperty("xdebugger.variablesView.rss"))) {
      new XDebuggerTreeSpeedSearch(this, SPEED_SEARCH_CONVERTER);
    } else {
      new TreeSpeedSearch(this, SPEED_SEARCH_CONVERTER);
    }

    final ActionManager actionManager = ActionManager.getInstance();
    addMouseListener(
        new PopupHandler() {
          @Override
          public void invokePopup(final Component comp, final int x, final int y) {
            ActionGroup group = (ActionGroup) actionManager.getAction(popupActionGroupId);
            actionManager
                .createActionPopupMenu(ActionPlaces.UNKNOWN, group)
                .getComponent()
                .show(comp, x, y);
          }
        });
    registerShortcuts();

    setTransferHandler(DEFAULT_TRANSFER_HANDLER);

    addComponentListener(myMoveListener);
  }
Пример #30
0
  public Ssys3() {
    store = new Storage();
    tableSorter = new TableRowSorter<Storage>(store);
    jobs = new LinkedList<String>();

    makeGUI();
    frm.setSize(800, 600);
    frm.addWindowListener(
        new WindowListener() {
          public void windowActivated(WindowEvent evt) {}

          public void windowClosed(WindowEvent evt) {
            try {
              System.out.println("joining EDT's");
              for (EDT edt : encryptDecryptThreads) {
                edt.weakStop();
                try {
                  edt.join();
                  System.out.println("  - joined");
                } catch (InterruptedException e) {
                  System.out.println("  - Not joined");
                }
              }
              System.out.println("saving storage");
              store.saveAll(tempLoc);
            } catch (IOException e) {
              e.printStackTrace();
              System.err.println(
                  "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nFailed to save properly\n\n!!!!!!!!!!!!!!!!!!!!!!!!!");
              System.exit(1);
            }
            clean();
            System.exit(0);
          }

          public void windowClosing(WindowEvent evt) {
            windowClosed(evt);
          }

          public void windowDeactivated(WindowEvent evt) {}

          public void windowDeiconified(WindowEvent evt) {}

          public void windowIconified(WindowEvent evt) {}

          public void windowOpened(WindowEvent evt) {}
        });
    ImageIcon ico = new ImageIcon(ICON_NAME);
    frm.setIconImage(ico.getImage());
    frm.setLocationRelativeTo(null);
    frm.setVisible(true);

    // load config
    storeLocs = new ArrayList<File>();
    String ossl = "openssl";
    int numThreadTemp = 2;
    boolean priorityDecryptTemp = true;
    boolean allowExportTemp = false;
    boolean checkImportTemp = true;
    try {
      Scanner sca = new Scanner(CONF_FILE);
      while (sca.hasNextLine()) {
        String ln = sca.nextLine();
        if (ln.startsWith(CONF_SSL)) {
          ossl = ln.substring(CONF_SSL.length());
        } else if (ln.startsWith(CONF_THREAD)) {
          try {
            numThreadTemp = Integer.parseInt(ln.substring(CONF_THREAD.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.equals(CONF_STORE)) {
          while (sca.hasNextLine()) storeLocs.add(new File(sca.nextLine()));
        } else if (ln.startsWith(CONF_PRIORITY)) {
          try {
            priorityDecryptTemp = Boolean.parseBoolean(ln.substring(CONF_PRIORITY.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_EXPORT)) {
          try {
            allowExportTemp = Boolean.parseBoolean(ln.substring(CONF_EXPORT.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_CONFIRM)) {
          try {
            checkImportTemp = Boolean.parseBoolean(ln.substring(CONF_CONFIRM.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        }
      }
      sca.close();
    } catch (IOException e) {

    }
    String osslWorks = OpenSSLCommander.test(ossl);
    while (osslWorks == null) {
      ossl =
          JOptionPane.showInputDialog(
              frm,
              "Please input the command used to run open ssl\n  We will run \"<command> version\" to confirm\n  Previous command: "
                  + ossl,
              "Find open ssl",
              JOptionPane.OK_CANCEL_OPTION);
      if (ossl == null) {
        System.err.println("Refused to provide openssl executable location");
        System.exit(1);
      }
      osslWorks = OpenSSLCommander.test(ossl);
      if (osslWorks == null)
        JOptionPane.showMessageDialog(
            frm, "Command " + ossl + " unsuccessful", "Unsuccessful", JOptionPane.ERROR_MESSAGE);
    }
    if (storeLocs.size() < 1)
      JOptionPane.showMessageDialog(
          frm,
          "Please select an initial sotrage location\nIf one already exists, or there are more than one, please select it");
    while (storeLocs.size() < 1) {
      JFileChooser jfc = new JFileChooser();
      jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      if (jfc.showOpenDialog(frm) != JFileChooser.APPROVE_OPTION) {
        System.err.println("Refused to provide an initial store folder");
        System.exit(1);
      }
      File sel = jfc.getSelectedFile();
      if (sel.isDirectory()) storeLocs.add(sel);
    }
    numThreads = numThreadTemp;
    priorityExport = priorityDecryptTemp;
    allowExport = allowExportTemp;
    checkImports = checkImportTemp;

    try {
      PrintWriter pw = new PrintWriter(CONF_FILE);
      pw.println(CONF_SSL + ossl);
      pw.println(CONF_THREAD + numThreads);
      pw.println(CONF_PRIORITY + priorityExport);
      pw.println(CONF_EXPORT + allowExport);
      pw.println(CONF_CONFIRM + checkImports);
      pw.println(CONF_STORE);
      for (File fi : storeLocs) {
        pw.println(fi.getAbsolutePath());
      }
      pw.close();
    } catch (IOException e) {
      System.err.println("Failed to save config");
    }

    File chk = null;
    for (File fi : storeLocs) {
      File lib = new File(fi, LIBRARY_NAME);
      if (lib.exists()) {
        chk = lib;
        // break;
      }
    }

    char[] pass = null;
    if (chk == null) {
      JOptionPane.showMessageDialog(
          frm,
          "First time run\n  Create your password",
          "Create Password",
          JOptionPane.INFORMATION_MESSAGE);
      char[] p1 = askPassword();
      char[] p2 = askPassword();
      boolean same = p1.length == p2.length;
      for (int i = 0; i < Math.min(p1.length, p2.length); i++) {
        if (p1[i] != p2[i]) same = false;
      }
      if (same) {
        JOptionPane.showMessageDialog(
            frm, "Password created", "Create Password", JOptionPane.INFORMATION_MESSAGE);
        pass = p1;
      } else {
        JOptionPane.showMessageDialog(
            frm, "Passwords dont match", "Create Password", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
      }
    } else {
      pass = askPassword();
    }
    sec = OpenSSLCommander.getCommander(chk, pass, ossl);
    if (sec == null) {
      System.err.println("Wrong Password");
      System.exit(1);
    }
    store.useSecurity(sec);
    store.useStorage(storeLocs);

    tempLoc = new File("temp");
    if (!tempLoc.exists()) tempLoc.mkdirs();
    // load stores
    try {
      store.loadAll(tempLoc);
      store.fireTableDataChanged();
    } catch (IOException e) {
      System.err.println("Storage loading failure");
      System.exit(1);
    }

    needsSave = false;
    encryptDecryptThreads = new EDT[numThreads];
    for (int i = 0; i < encryptDecryptThreads.length; i++) {
      encryptDecryptThreads[i] = new EDT(i);
      encryptDecryptThreads[i].start();
    }

    updateStatus();
    txaSearch.grabFocus();
  }