private void parameterFormatAnalysis() {
   publish("Parameter Format Analysis...");
   int total =
       urlParameters.size()
           + bodyParameters.size()
           + cookieParameters.size()
           + jsonParameters.size();
   int i = 0;
   publish(0);
   for (CorrelatedParam cp : urlParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : bodyParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : cookieParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
   for (CorrelatedParam cp : jsonParameters.values()) {
     cp.analyzeAll(callbacks);
     i += 1;
     publish(100 * i / total);
   }
 }
  @NotNull
  public synchronized List<Breakpoint> getBreakpoints() {
    if (myBreakpointsListForIteration == null) {
      myBreakpointsListForIteration = new ArrayList<Breakpoint>(myBreakpoints.size());

      XBreakpoint<?>[] xBreakpoints =
          ApplicationManager.getApplication()
              .runReadAction(
                  new Computable<XBreakpoint<?>[]>() {
                    public XBreakpoint<?>[] compute() {
                      return getXBreakpointManager().getAllBreakpoints();
                    }
                  });
      for (XBreakpoint<?> xBreakpoint : xBreakpoints) {
        if (isJavaType(xBreakpoint)) {
          Breakpoint breakpoint = myBreakpoints.get(xBreakpoint);
          if (breakpoint == null) {
            breakpoint = createJavaBreakpoint(xBreakpoint);
            myBreakpoints.put(xBreakpoint, breakpoint);
          }
        }
      }

      myBreakpointsListForIteration.addAll(myBreakpoints.values());
    }
    return myBreakpointsListForIteration;
  }
 private synchronized void startAnimation(
     JComponent component, Part part, State startState, State endState, long millis) {
   boolean isForwardAndReverse = false;
   if (endState == State.DEFAULTED) {
     isForwardAndReverse = true;
   }
   Map<Part, AnimationState> map = animationStateMap.get(component);
   if (millis <= 0) {
     if (map != null) {
       map.remove(part);
       if (map.size() == 0) {
         animationStateMap.remove(component);
       }
     }
     return;
   }
   if (map == null) {
     map = new EnumMap<Part, AnimationState>(Part.class);
     animationStateMap.put(component, map);
   }
   map.put(part, new AnimationState(startState, millis, isForwardAndReverse));
   if (!timer.isRunning()) {
     timer.start();
   }
 }
  private Color getThreadBlockColor(BumpThread bt) {
    if (bt == null) return Color.BLACK;

    synchronized (thread_colors) {
      Color c = thread_colors.get(bt);
      if (c == null) {
        double v;
        int ct = thread_colors.size();
        if (ct == 0) v = 0;
        else if (ct == 1) v = 1;
        else {
          v = 0.5;
          int p0 = ct - 1;
          int p1 = 1;
          for (int p = p0; p > 1; p /= 2) {
            v /= 2.0;
            p0 -= p1;
            p1 *= 2;
          }
          if ((p0 & 1) == 0) p0 = 2 * p1 - p0 + 1;
          v = v * p0;
        }
        float h = (float) (v * 0.8);
        float s = 0.7f;
        float b = 1.0f;
        int rgb = Color.HSBtoRGB(h, s, b);
        rgb |= 0xc0000000;
        c = new Color(rgb, true);
        thread_colors.put(bt, c);
      }
      return c;
    }
  }
 public UpdateOrStatusOptionsDialog(Project project, Map<Configurable, AbstractVcs> confs) {
   super(project);
   setTitle(getRealTitle());
   myProject = project;
   if (confs.size() == 1) {
     myMainPanel = new JPanel(new BorderLayout());
     final Configurable configurable = confs.keySet().iterator().next();
     addComponent(confs.get(configurable), configurable, BorderLayout.CENTER);
     myMainPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
   } else {
     myMainPanel = new JBTabbedPane();
     final ArrayList<AbstractVcs> vcses = new ArrayList<>(confs.values());
     Collections.sort(
         vcses,
         new Comparator<AbstractVcs>() {
           public int compare(final AbstractVcs o1, final AbstractVcs o2) {
             return o1.getDisplayName().compareTo(o2.getDisplayName());
           }
         });
     Map<AbstractVcs, Configurable> vcsToConfigurable = revertMap(confs);
     for (AbstractVcs vcs : vcses) {
       addComponent(vcs, vcsToConfigurable.get(vcs), vcs.getDisplayName());
     }
   }
   init();
 }
 public synchronized void actionPerformed(ActionEvent e) {
   java.util.List<JComponent> componentsToRemove = null;
   java.util.List<Part> partsToRemove = null;
   for (JComponent component : animationStateMap.keySet()) {
     component.repaint();
     if (partsToRemove != null) {
       partsToRemove.clear();
     }
     Map<Part, AnimationState> map = animationStateMap.get(component);
     if (!component.isShowing() || map == null || map.size() == 0) {
       if (componentsToRemove == null) {
         componentsToRemove = new ArrayList<JComponent>();
       }
       componentsToRemove.add(component);
       continue;
     }
     for (Part part : map.keySet()) {
       if (map.get(part).isDone()) {
         if (partsToRemove == null) {
           partsToRemove = new ArrayList<Part>();
         }
         partsToRemove.add(part);
       }
     }
     if (partsToRemove != null) {
       if (partsToRemove.size() == map.size()) {
         // animation is done for the component
         if (componentsToRemove == null) {
           componentsToRemove = new ArrayList<JComponent>();
         }
         componentsToRemove.add(component);
       } else {
         for (Part part : partsToRemove) {
           map.remove(part);
         }
       }
     }
   }
   if (componentsToRemove != null) {
     for (JComponent component : componentsToRemove) {
       animationStateMap.remove(component);
     }
   }
   if (animationStateMap.size() == 0) {
     timer.stop();
   }
 }
Esempio n. 7
0
 /**
  * \ Draw saved State (color dots on panel) on WhiteBoard
  *
  * @param outstream
  * @throws IOException
  */
 public void writeState(OutputStream outstream) throws IOException {
   if (state == null) return;
   synchronized (state) {
     DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(outstream));
     // DataOutputStream dos=new DataOutputStream(outstream);
     dos.writeInt(state.size());
     for (Map.Entry<Point, Color> entry : state.entrySet()) {
       Point point = entry.getKey();
       Color col = entry.getValue();
       dos.writeInt(point.x);
       dos.writeInt(point.x);
       dos.writeInt(col.getRGB());
     }
     dos.flush();
     System.out.println("wrote " + state.size() + " elements");
   }
 }
Esempio n. 8
0
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
Esempio n. 9
0
 @NotNull
 private List<HighlightSeverity> getDefaultOrder() {
   Collection<SeverityBasedTextAttributes> values = myMap.values();
   List<HighlightSeverity> order =
       new ArrayList<HighlightSeverity>(STANDARD_SEVERITIES.size() + values.size());
   for (HighlightInfoType type : STANDARD_SEVERITIES.values()) {
     order.add(type.getSeverity(null));
   }
   for (SeverityBasedTextAttributes attributes : values) {
     order.add(attributes.getSeverity());
   }
   ContainerUtil.sort(order);
   return order;
 }
Esempio n. 10
0
 public Object getElementAt(int i) {
   if (i < identifiedElements.size()) {
     Object[] elements = identifiedElements.keySet().toArray();
     sort(
         elements,
         new Comparator() {
           public int compare(Object o, Object o1) {
             return o.toString().compareTo(o1.toString());
           }
         });
     return elements[i];
   }
   return null;
 }
  /**
   * Returns the <code>Format.Field</code> constants associated with the text at <code>offset</code>
   * . If <code>offset</code> is not a valid location into the current text, this will return an
   * empty array.
   *
   * @param offset offset into text to be examined
   * @return Format.Field constants associated with the text at the given position.
   */
  public Format.Field[] getFields(int offset) {
    if (getAllowsInvalid()) {
      // This will work if the currently edited value is valid.
      updateMask();
    }

    Map attrs = getAttributes(offset);

    if (attrs != null && attrs.size() > 0) {
      ArrayList al = new ArrayList();

      al.addAll(attrs.keySet());
      return (Format.Field[]) al.toArray(EMPTY_FIELD_ARRAY);
    }
    return EMPTY_FIELD_ARRAY;
  }
Esempio n. 12
0
    /**
     * Read State (color dots) from input stream
     *
     * @param instream
     * @throws IOException
     */
    public void readState(InputStream instream) throws IOException {
      DataInputStream in = new DataInputStream(new BufferedInputStream(instream));
      Map<Point, Color> new_state = new LinkedHashMap<Point, Color>();
      int num = in.readInt();
      for (int i = 0; i < num; i++) {
        Point point = new Point(in.readInt(), in.readInt());
        Color col = new Color(in.readInt());
        new_state.put(point, col);
      }

      synchronized (state) {
        state.clear();
        state.putAll(new_state);
        System.out.println("read " + state.size() + " elements");
        createOffscreenImage(true);
      }
    }
  public RunContentDescriptor[] getAllDescriptors() {
    final List<RunContentDescriptor> descriptors = new ArrayList<RunContentDescriptor>();
    final String[] ids =
        myToolwindowIdToContentManagerMap
            .keySet()
            .toArray(new String[myToolwindowIdToContentManagerMap.size()]);
    for (String id : ids) {
      final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(id);
      final Content[] contents = contentManager.getContents();
      for (final Content content : contents) {
        final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
        if (descriptor != null) {
          descriptors.add(descriptor);
        }
      }
    }

    return descriptors.toArray(new RunContentDescriptor[descriptors.size()]);
  }
Esempio n. 14
0
  /**
   * Check the status of the named plugin - whether an older, the same or a newer version is already
   * installed.
   *
   * @param f The plugin file.
   * @return an integer indicating the status
   */
  public static int checkInstalledVersion(File f) {
    String[] nav = getNameAndVersion(f);
    if (nav == null) return UNKNOWN_VERSION;

    VersionNumber vn = new VersionNumber(nav[1]);
    Map<VersionNumber, File> versions = getInstalledVersions(nav[0]);

    if (versions.size() == 0) {
      return NO_VERSIONS_INSTALLED;
    }
    VersionNumber thenum = versions.keySet().iterator().next();
    boolean hasSame = vn.compareTo(thenum) == 0;
    boolean hasNewer = vn.compareTo(thenum) > 0;

    if (hasNewer) return NEWER_VERSION_INSTALLED;
    if (hasSame) return SAME_VERSION_INSTALLED;

    return OLDER_VERSION_INSTALLED;
  }
  @NotNull
  public List<RunContentDescriptor> getAllDescriptors() {
    if (myToolwindowIdToContentManagerMap.isEmpty()) {
      return Collections.emptyList();
    }
    final String[] ids =
        myToolwindowIdToContentManagerMap
            .keySet()
            .toArray(new String[myToolwindowIdToContentManagerMap.size()]);
    final List<RunContentDescriptor> descriptors = new ArrayList<RunContentDescriptor>();
    for (String id : ids) {
      final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(id);
      for (final Content content : contentManager.getContents()) {
        final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
        if (descriptor != null) {
          descriptors.add(descriptor);
        }
      }
    }

    return descriptors;
  }
Esempio n. 16
0
 boolean tryDir(String d) {
   ClassLoader L = getClass().getClassLoader();
   File p = new File(d, PACKAGE);
   System.out.println("Try " + p);
   if (!p.exists() || !p.isDirectory()) return false;
   for (File f : p.listFiles()) {
     String s = f.getName();
     if (!s.endsWith(".class")) continue;
     String name = s.substring(0, s.length() - 6);
     try {
       Class<?> c = L.loadClass(PACKAGE + "." + name);
       if (!Animator.class.isAssignableFrom(c)) continue;
       Animator a = (Animator) c.newInstance();
       a.container().setPreferredSize(DIM);
       map.put(name, a);
       System.out.println("  " + name);
       // ClassNotFoundException InstantiationException IllegalAccessException
     } catch (Exception e) {
       continue;
     }
   }
   return map.size() > 0;
 }
  public VisualizationPanel(List<String> metricNames, final Map<Project, Double[]> results) {
    Map<String, IVisualization> vis = VisualizationsRegistry.visualizations;
    int numVis = vis.size();

    setLayout(new GridLayout(2 + numVis, 1));

    this.metricNames = metricNames;
    this.results = results;

    metricNameComboBox = new JComboBox();
    for (String name : metricNames) {
      metricNameComboBox.addItem(name);
    }
    add(metricNameComboBox);

    for (final String visName : vis.keySet()) {
      JButton btn = new JButton(visName);
      btn.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
              showVis(visName);
            }
          });
      add(btn);
    }

    JButton boxPlotCombined = new JButton("box and whisker combined");
    boxPlotCombined.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            showCombined("box and whisker");
          }
        });
    add(boxPlotCombined);
  }
 @Override
 public int getUsagesCount() {
   return myUsageNodes.size();
 }
  public HectorComponent(@NotNull PsiFile file) {
    super(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0));
    myFile = file;
    mySliders = new HashMap<Language, JSlider>();

    final Project project = myFile.getProject();
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    final VirtualFile virtualFile = myFile.getContainingFile().getVirtualFile();
    LOG.assertTrue(virtualFile != null);
    final boolean notInLibrary =
        !fileIndex.isInLibrarySource(virtualFile) && !fileIndex.isInLibraryClasses(virtualFile)
            || fileIndex.isInContent(virtualFile);
    final FileViewProvider viewProvider = myFile.getViewProvider();
    List<Language> languages = new ArrayList<Language>(viewProvider.getLanguages());
    Collections.sort(languages, PsiUtilBase.LANGUAGE_COMPARATOR);
    for (Language language : languages) {
      @SuppressWarnings("UseOfObsoleteCollectionType")
      final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>();
      sliderLabels.put(1, new JLabel(EditorBundle.message("hector.none.slider.label")));
      sliderLabels.put(2, new JLabel(EditorBundle.message("hector.syntax.slider.label")));
      if (notInLibrary) {
        sliderLabels.put(3, new JLabel(EditorBundle.message("hector.inspections.slider.label")));
      }

      final JSlider slider = new JSlider(SwingConstants.VERTICAL, 1, notInLibrary ? 3 : 2, 1);
      if (UIUtil.isUnderGTKLookAndFeel()) {
        // default GTK+ slider UI is way too ugly
        slider.putClientProperty("Slider.paintThumbArrowShape", true);
        slider.setUI(new BasicSliderUI(slider));
      }
      slider.setLabelTable(sliderLabels);
      UIUtil.setSliderIsFilled(slider, true);
      slider.setPaintLabels(true);
      slider.setSnapToTicks(true);
      slider.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              int value = slider.getValue();
              for (Enumeration<Integer> enumeration = sliderLabels.keys();
                  enumeration.hasMoreElements(); ) {
                Integer key = enumeration.nextElement();
                sliderLabels
                    .get(key)
                    .setForeground(
                        key.intValue() <= value
                            ? UIUtil.getLabelForeground()
                            : UIUtil.getLabelDisabledForeground());
              }
            }
          });

      final PsiFile psiRoot = viewProvider.getPsi(language);
      assert psiRoot != null : "No root in " + viewProvider + " for " + language;
      slider.setValue(
          getValue(
              HighlightLevelUtil.shouldHighlight(psiRoot),
              HighlightLevelUtil.shouldInspect(psiRoot)));
      mySliders.put(language, slider);
    }

    GridBagConstraints gc =
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0);

    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(IdeBorderFactory.createTitledBorder(myTitle, false));
    final boolean addLabel = mySliders.size() > 1;
    if (addLabel) {
      layoutVertical(panel);
    } else {
      layoutHorizontal(panel);
    }
    gc.gridx = 0;
    gc.gridy = 0;
    gc.weighty = 1.0;
    gc.fill = GridBagConstraints.BOTH;
    add(panel, gc);

    gc.gridy = GridBagConstraints.RELATIVE;
    gc.weighty = 0;

    final HyperlinkLabel configurator = new HyperlinkLabel("Configure inspections");
    gc.insets.right = 5;
    gc.insets.bottom = 10;
    gc.weightx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.EAST;
    add(configurator, gc);
    configurator.addHyperlinkListener(
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            final JBPopup hector = getOldHector();
            if (hector != null) {
              hector.cancel();
            }
            if (!DaemonCodeAnalyzer.getInstance(myFile.getProject())
                .isHighlightingAvailable(myFile)) return;
            final Project project = myFile.getProject();
            final ErrorsConfigurable errorsConfigurable =
                ErrorsConfigurable.SERVICE.createConfigurable(project);
            assert errorsConfigurable != null;
            ShowSettingsUtil.getInstance().editConfigurable(project, errorsConfigurable);
          }
        });

    gc.anchor = GridBagConstraints.WEST;
    gc.weightx = 1.0;
    gc.insets.right = 0;
    gc.fill = GridBagConstraints.HORIZONTAL;
    myAdditionalPanels = new ArrayList<HectorComponentPanel>();
    for (HectorComponentPanelsProvider provider :
        Extensions.getExtensions(HectorComponentPanelsProvider.EP_NAME, project)) {
      final HectorComponentPanel componentPanel = provider.createConfigurable(file);
      if (componentPanel != null) {
        myAdditionalPanels.add(componentPanel);
        add(componentPanel.createComponent(), gc);
        componentPanel.reset();
      }
    }
  }
    private void refresh(int index) {
      GridBagConstraints c = new GridBagConstraints();

      // No connector ................
      if (acs.size() == 0) {
        add(new JLabel(bundle.getString("CTL_No_Connector")), c);
        return;
      }

      // Connector switch ................
      if (acs.size() > 1) {
        c.insets = new Insets(0, 0, 3, 3);
        add(new JLabel(bundle.getString("CTL_Connector")), c);

        cbConnectors = new JComboBox();
        int i, k = acs.size();
        for (i = 0; i < k; i++) {
          AttachingConnector ac = (AttachingConnector) acs.get(i);
          int jj = ac.name().lastIndexOf('.');
          String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1);
          cbConnectors.addItem(s + " (" + ac.description() + ")");
        }
        c = new GridBagConstraints();
        c.insets = new Insets(0, 3, 3, 0);
        c.weightx = 1.0;
        c.fill = java.awt.GridBagConstraints.HORIZONTAL;
        c.gridwidth = 0;
        cbConnectors.setSelectedIndex(index);
        cbConnectors.setActionCommand("SwitchMe!");
        cbConnectors.addActionListener(this);
        add(cbConnectors, c);
      }

      ac = (AttachingConnector) acs.get(index);

      // Transport ................
      c = new GridBagConstraints();
      c.insets = new Insets(3, 0, 0, 3);
      add(new JLabel(bundle.getString("CTL_Transport")), c);

      JTextField tfTransport = new JTextField(ac.transport().name());
      tfTransport.setEnabled(false);
      c = new GridBagConstraints();
      c.gridwidth = 0;
      c.insets = new Insets(3, 3, 0, 0);
      c.fill = java.awt.GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      add(tfTransport, c);

      // Other params ................
      args = ac.defaultArguments();
      tfParams = new JTextField[args.size()];
      Iterator it = args.keySet().iterator();
      int i = 0;
      while (it.hasNext()) {
        String name = (String) it.next();
        Argument a = (Argument) args.get(name);

        c = new GridBagConstraints();
        c.insets = new Insets(6, 0, 0, 3);
        c.anchor = GridBagConstraints.WEST;
        add(new JLabel(a.label() + ": "), c);

        JTextField tfParam = new JTextField(a.value());
        tfParams[i++] = tfParam;
        tfParam.setName(name);
        c = new GridBagConstraints();
        c.gridwidth = 0;
        c.insets = new Insets(6, 3, 0, 0);
        c.fill = java.awt.GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        add(tfParam, c);
      }

      c = new GridBagConstraints();
      c.weighty = 1.0;
      JPanel p = new JPanel();
      p.setPreferredSize(new Dimension(1, 1));
      add(p, c);
    }
Esempio n. 21
0
 // ListModel implementation
 public int getSize() {
   return identifiedElements.size();
 }
 /** Returns true if <code>attributes</code> is null or empty. */
 boolean isLiteral(Map attributes) {
   return ((attributes == null) || attributes.size() == 0);
 }