Esempio n. 1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
Esempio n. 2
0
  @Override
  public void readExternal(Element element) throws InvalidDataException {
    myMap.clear();
    myRendererColors.clear();
    final List children = element.getChildren(INFO_TAG);
    for (Object child : children) {
      final Element infoElement = (Element) child;

      final SeverityBasedTextAttributes highlightInfo =
          new SeverityBasedTextAttributes(infoElement);

      Color color = null;
      final String colorStr = infoElement.getAttributeValue(COLOR_ATTRIBUTE);
      if (colorStr != null) {
        color = new Color(Integer.parseInt(colorStr, 16));
      }
      registerSeverity(highlightInfo, color);
    }
    myReadOrder = new JDOMExternalizableStringList();
    myReadOrder.readExternal(element);
    List<HighlightSeverity> read = new ArrayList<HighlightSeverity>(myReadOrder.size());
    final List<HighlightSeverity> knownSeverities = getDefaultOrder();
    for (String name : myReadOrder) {
      HighlightSeverity severity = getSeverity(name);
      if (severity == null || !knownSeverities.contains(severity)) continue;
      read.add(severity);
    }
    OrderMap orderMap = fromList(read);
    if (orderMap.isEmpty()) {
      orderMap = fromList(knownSeverities);
    } else {
      // enforce include all known
      List<HighlightSeverity> list = getOrderAsList(orderMap);
      for (int i = 0; i < knownSeverities.size(); i++) {
        HighlightSeverity stdSeverity = knownSeverities.get(i);
        if (!list.contains(stdSeverity)) {
          for (int oIdx = 0; oIdx < list.size(); oIdx++) {
            HighlightSeverity orderSeverity = list.get(oIdx);
            HighlightInfoType type = STANDARD_SEVERITIES.get(orderSeverity.getName());
            if (type != null && knownSeverities.indexOf(type.getSeverity(null)) > i) {
              list.add(oIdx, stdSeverity);
              myReadOrder = null;
              break;
            }
          }
        }
      }
      orderMap = fromList(list);
    }
    myOrderMap = orderMap;
    severitiesChanged();
  }
    @Override
    public synchronized void dispose() {

      for (Map.Entry<File, Jp2File> entry : openFiles.entrySet()) {
        System.out.println("closing " + entry.getKey());
        try {
          final Jp2File jp2File = entry.getValue();
          if (jp2File.stream != null) {
            jp2File.stream.close();
            jp2File.stream = null;
          }
        } catch (IOException e) {
          // warn
        }
      }

      for (File file : openFiles.keySet()) {
        System.out.println("deleting " + file);
        if (!file.delete()) {
          // warn
        }
      }

      openFiles.clear();

      if (!cacheDir.delete()) {
        // warn
      }
    }
 private void releaseAllEditors() {
   for (final Editor editor : myEditors.values()) {
     if (!editor.isDisposed()) {
       EditorFactory.getInstance().releaseEditor(editor);
     }
   }
   myEditors.clear();
 }
Esempio n. 5
0
 /** Clear all contents */
 public void clear() {
   if (gr == null) return;
   gr.clearRect(0, 0, getSize().width, getSize().height);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.clear();
     }
   }
 }
  /** ***************************************************************************** */
  @Override
  public void handleHistoryStarted() {
    synchronized (this) {
      update_needed = true;
      restart_needed = true;
      thread_colors.clear();
    }

    draw_area.repaint();
  }
  private static void cleanupSwingDataStructures() throws Exception {
    Class<?> aClass = Class.forName("javax.swing.KeyboardManager");

    Method get = aClass.getMethod("getCurrentManager");
    get.setAccessible(true);
    Object manager = get.invoke(null);
    {
      Field mapF = aClass.getDeclaredField("componentKeyStrokeMap");
      mapF.setAccessible(true);
      Object map = mapF.get(manager);
      ((Map) map).clear();
    }
    {
      Field mapF = aClass.getDeclaredField("containerMap");
      mapF.setAccessible(true);
      Object map = mapF.get(manager);
      ((Map) map).clear();
    }
  }
Esempio n. 8
0
 @Override
 public void dispose() {
   setRefreshVisible(false);
   InlineProgressIndicator[] indicators =
       getCurrentInlineIndicators().toArray(new InlineProgressIndicator[0]);
   for (InlineProgressIndicator indicator : indicators) {
     Disposer.dispose(indicator);
   }
   myInline2Original.clear();
   myOriginal2Inlines.clear();
 }
 public void updateRepositoryPlugins() {
   myPlugin2host.clear();
   final JDOMExternalizableStringList pluginHosts = UpdateSettings.getInstance().myPluginHosts;
   for (String host : pluginHosts) {
     try {
       final ArrayList<PluginDownloader> downloaded = new ArrayList<PluginDownloader>();
       UpdateChecker.checkPluginsHost(host, downloaded, false, null);
       for (PluginDownloader downloader : downloaded) {
         myPlugin2host.put(downloader.getPluginId(), host);
       }
     } catch (Exception ignored) {
     }
   }
 }
Esempio n. 10
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 void doLayout() {
    selections.clear();
    if (points == null) {
      points = new Vector<ExprPoint>();
    }
    points.clear();

    for (Pair<Integer, Double> p : watsonProbes) {
      ExprPoint ep = new ExprPoint(p.getFirst(), p.getLast(), '+');
      points.add(ep);
    }

    for (Pair<Integer, Double> p : crickProbes) {
      ExprPoint ep = new ExprPoint(p.getFirst(), p.getLast(), '-');
      points.add(ep);
    }
  }
  private void reset() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myUsageNodes.clear();
    myIsFirstVisibleUsageFound = false;

    myModel.reset();
    if (!myPresentation.isDetachedMode()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (isDisposed) return;
              TreeUtil.expand(myTree, 2);
            }
          });
    }
  }
 public void apply() throws ConfigurationException {
   if (!myModifiedModificators.isEmpty()) {
     mySdkSettingsWereModified.run();
   }
   for (SdkModificator modificator : myModifiedModificators) {
     /* This should always be true barring bug elsewhere, log error on else? */
     if (modificator.isWritable()) {
       modificator.commitChanges();
     }
   }
   myModificators.clear();
   myModifiedModificators.clear();
   mySdkListChanged = false;
   final Sdk sdk = getSelectedSdk();
   myShowMoreCallback.consume(sdk);
   PyPackageManagers.getInstance().clearCache(sdk);
   Disposer.dispose(getDisposable());
 }
Esempio n. 14
0
 /**
  * Deselects the specified objects from the list and keep all previous selections.
  *
  * @param objects the objects to be selected
  */
 public void removeCheckBoxListSelectedValues(Object[] objects) {
   if (objects != null) {
     Map<Object, String> map = new HashMap<Object, String>();
     for (Object o : objects) {
       map.put(o, "");
     }
     int i, c;
     ListModel model = getModel();
     boolean changed = false;
     for (i = 0, c = model.getSize(); i < c; i++)
       if (map.get(model.getElementAt(i)) != null) {
         removeCheckBoxListSelectedIndex(i);
         changed = true;
       }
     if (changed) {
       repaint();
     }
     map.clear();
   }
 }
 @Override
 protected void resetDefaultNames() {
   myRenamedFields.clear();
 }
 public void clear() {
   myElements.clear();
   myDirNameMap.clear();
   fireTableDataChanged();
 }
 public void disposeUIResources() {
   myPathToFileMap.clear();
 }
Esempio n. 18
0
 private void clearCaches() {
   tiles.clear();
   rendering.clear();
   used.clear();
   nextPoolIndex = 0;
 }
    public String setup(
        final String[] texts,
        final EnumSet<ParameterInfoUIContextEx.Flag>[] flags,
        final Color background) {
      StringBuilder buf = new StringBuilder();
      removeAll();
      final String[] lines =
          UIUtil.splitText(StringUtil.join(texts), getFontMetrics(BOLD_FONT), myWidthLimit, ',');

      int index = 0;
      int curOffset = 0;

      myOneLineComponents = new OneLineComponent[lines.length];

      Map<TextRange, ParameterInfoUIContextEx.Flag> flagsMap =
          new TreeMap<TextRange, ParameterInfoUIContextEx.Flag>(TEXT_RANGE_COMPARATOR);

      int added = 0;
      for (int i = 0; i < texts.length; i++) {
        String line = escapeString(texts[i]);
        if (lines.length <= index) break;
        String text = lines[index];
        final int paramCount = StringUtil.split(text, ", ").size();
        final EnumSet<ParameterInfoUIContextEx.Flag> flag = flags[i];
        if (flag.contains(ParameterInfoUIContextEx.Flag.HIGHLIGHT)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + line.trim().length()),
              ParameterInfoUIContextEx.Flag.HIGHLIGHT);
        }

        if (flag.contains(ParameterInfoUIContextEx.Flag.DISABLE)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + line.trim().length()),
              ParameterInfoUIContextEx.Flag.DISABLE);
        }

        if (flag.contains(ParameterInfoUIContextEx.Flag.STRIKEOUT)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + line.trim().length()),
              ParameterInfoUIContextEx.Flag.STRIKEOUT);
        }

        curOffset += line.length();
        if (i == paramCount + added - 1) {
          myOneLineComponents[index] = new OneLineComponent();
          setBackground(background);
          buf.append(myOneLineComponents[index].setup(escapeString(text), flagsMap, background));
          add(
              myOneLineComponents[index],
              new GridBagConstraints(
                  0,
                  index,
                  1,
                  1,
                  1,
                  0,
                  GridBagConstraints.WEST,
                  GridBagConstraints.NONE,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
          index += 1;
          flagsMap.clear();
          curOffset = 1;
          added += paramCount;
        }
      }
      return buf.toString();
    }
  private void recreateEditorsPanel() {
    myValuesPanel.removeAll();
    myValuesPanel.setLayout(new CardLayout());

    if (!myProject.isOpen()) return;
    JPanel valuesPanelComponent = new MyJPanel(new GridBagLayout());
    myValuesPanel.add(
        new JBScrollPane(valuesPanelComponent) {
          @Override
          public void updateUI() {
            super.updateUI();
            getViewport().setBackground(UIUtil.getPanelBackground());
          }
        },
        VALUES);
    myValuesPanel.add(myNoPropertySelectedPanel, NO_PROPERTY_SELECTED);

    List<PropertiesFile> propertiesFiles = myResourceBundle.getPropertiesFiles();

    GridBagConstraints gc =
        new GridBagConstraints(
            0,
            0,
            0,
            0,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0);
    releaseAllEditors();
    myTitledPanels.clear();
    int y = 0;
    Editor previousEditor = null;
    Editor firstEditor = null;
    for (final PropertiesFile propertiesFile : propertiesFiles) {
      final Editor editor = createEditor();
      final Editor oldEditor = myEditors.put(propertiesFile, editor);
      if (firstEditor == null) {
        firstEditor = editor;
      }
      if (previousEditor != null) {
        editor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
        previousEditor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, editor);
      }
      previousEditor = editor;
      if (oldEditor != null) {
        EditorFactory.getInstance().releaseEditor(oldEditor);
      }
      ((EditorEx) editor)
          .addFocusListener(
              new FocusChangeListener() {
                @Override
                public void focusGained(final Editor editor) {
                  mySelectedEditor = editor;
                }

                @Override
                public void focusLost(final Editor eventEditor) {
                  writeEditorPropertyValue(editor, propertiesFile, null);
                }
              });
      gc.gridx = 0;
      gc.gridy = y++;
      gc.gridheight = 1;
      gc.gridwidth = GridBagConstraints.REMAINDER;
      gc.weightx = 1;
      gc.weighty = 1;
      gc.anchor = GridBagConstraints.CENTER;

      Locale locale = propertiesFile.getLocale();
      List<String> names = new ArrayList<String>();
      if (!Comparing.strEqual(locale.getDisplayLanguage(), null)) {
        names.add(locale.getDisplayLanguage());
      }
      if (!Comparing.strEqual(locale.getDisplayCountry(), null)) {
        names.add(locale.getDisplayCountry());
      }
      if (!Comparing.strEqual(locale.getDisplayVariant(), null)) {
        names.add(locale.getDisplayVariant());
      }

      String title = propertiesFile.getName();
      if (!names.isEmpty()) {
        title += " (" + StringUtil.join(names, "/") + ")";
      }
      JComponent comp =
          new JPanel(new BorderLayout()) {
            @Override
            public Dimension getPreferredSize() {
              Insets insets = getBorder().getBorderInsets(this);
              return new Dimension(100, editor.getLineHeight() * 4 + insets.top + insets.bottom);
            }
          };
      comp.add(editor.getComponent(), BorderLayout.CENTER);
      comp.setBorder(IdeBorderFactory.createTitledBorder(title, true));
      myTitledPanels.put(propertiesFile, (JPanel) comp);

      valuesPanelComponent.add(comp, gc);
    }
    if (previousEditor != null) {
      previousEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, firstEditor);
      firstEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
    }

    gc.gridx = 0;
    gc.gridy = y;
    gc.gridheight = GridBagConstraints.REMAINDER;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.weightx = 10;
    gc.weighty = 1;

    valuesPanelComponent.add(new JPanel(), gc);
    selectionChanged();
    myValuesPanel.repaint();
    UIUtil.invokeAndWaitIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            updateEditorsFromProperties();
          }
        });
  }
 public void clear() {
   myTableModel.clear();
   myElementToPropertiesMap.clear();
 }
 public void clear() {
   myElements.clear();
   myMarkedMap.clear();
   fireTableDataChanged();
 }
Esempio n. 23
0
  private boolean subtaskPlanning(Problem problem, EvaluationAlgorithm algorithm) {

    if (isSubtaskLoggingOn())
      logger.debug("!!!--------- Starting Planning With Subtasks ---------!!!");

    final int maxDepthBackup = maxDepth;
    if (isSubtaskLoggingOn())
      logger.debug(
          "maxDepthBackup:" + maxDepthBackup + " sbt: " + problem.getRelsWithSubtasks().size());
    PlanningContext context = problem.getCurrentContext();

    try {

      Set<Rel> relsWithSubtasks = new LinkedHashSet<Rel>(problem.getRelsWithSubtasks());

      if (isIncremental) {
        int incrementalDepth = 0;

        while (incrementalDepth
            <= (isSubtaskRepetitionAllowed
                ? maxDepthBackup
                : problem.getRelsWithSubtasks().size() - 1)) {
          if (isSubtaskLoggingOn())
            logger.debug(
                "Incremental dfs, with max depth "
                    + (incrementalDepth + 1)
                    + " and "
                    + problem.getRelsWithSubtasks().size()
                    + " subtasks to solve");

          maxDepth = incrementalDepth++;

          // if we need to compute some specific goals, after reaching a certain depth, but not the
          // maximal depth,
          // the problem may be solved and there is no need to go any deeper.
          if (subtaskPlanningImpl(context, relsWithSubtasks, algorithm, new LinkedList<Rel>(), 0)) {
            if (isSubtaskLoggingOn())
              logger.debug("The problem was solved during idfs after some intermediate MLB");
            return true;
          }

          if (isSubtaskLoggingOn())
            logger.debug("Unsolved subtask left: " + problem.getRelsWithSubtasks().size());
        }

        if (isSubtaskLoggingOn()) logger.debug("Fininshed incremental dfs");

      } else {
        if (!isSubtaskRepetitionAllowed) {
          maxDepth = problem.getRelsWithSubtasks().size() - 1;
        }

        if (isSubtaskLoggingOn())
          logger.debug("Starting subtask dfs with maxDepth: " + (maxDepth + 1));

        if (subtaskPlanningImpl(context, relsWithSubtasks, algorithm, new LinkedList<Rel>(), 0)) {
          if (isSubtaskLoggingOn())
            logger.debug("The problem was solved during dfs after some intermediate MLB");
          return true;
        }
      }

    } finally {
      if (isSubtaskLoggingOn()) logger.debug("Fininshed dfs");

      maxDepth = maxDepthBackup;
      indSubtasks.clear();
    }

    if (isSubtaskLoggingOn()) logger.debug("Invoking final linear planning");

    return linearForwardSearch(context, algorithm, computeAll);
  }
    public String setup(
        final String[] texts,
        Function<String, String> escapeFunction,
        final EnumSet<ParameterInfoUIContextEx.Flag>[] flags,
        final Color background) {
      StringBuilder buf = new StringBuilder();
      removeAll();
      setBackground(background);
      int index = 0;
      int curOffset = 0;
      final ArrayList<OneLineComponent> components = new ArrayList<>();

      Map<TextRange, ParameterInfoUIContextEx.Flag> flagsMap = new TreeMap<>(TEXT_RANGE_COMPARATOR);

      String line = "";
      for (int i = 0; i < texts.length; i++) {
        String paramText = escapeString(texts[i], escapeFunction);
        if (paramText == null) break;
        line += texts[i];
        final EnumSet<ParameterInfoUIContextEx.Flag> flag = flags[i];
        if (flag.contains(ParameterInfoUIContextEx.Flag.HIGHLIGHT)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + paramText.trim().length()),
              ParameterInfoUIContextEx.Flag.HIGHLIGHT);
        }

        if (flag.contains(ParameterInfoUIContextEx.Flag.DISABLE)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + paramText.trim().length()),
              ParameterInfoUIContextEx.Flag.DISABLE);
        }

        if (flag.contains(ParameterInfoUIContextEx.Flag.STRIKEOUT)) {
          flagsMap.put(
              TextRange.create(curOffset, curOffset + paramText.trim().length()),
              ParameterInfoUIContextEx.Flag.STRIKEOUT);
        }

        curOffset += paramText.length();
        if (line.length() >= 50) {
          final OneLineComponent component = new OneLineComponent();
          buf.append(component.setup(escapeString(line, escapeFunction), flagsMap, background));
          add(
              component,
              new GridBagConstraints(
                  0,
                  index,
                  1,
                  1,
                  1,
                  0,
                  GridBagConstraints.WEST,
                  GridBagConstraints.NONE,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
          index += 1;
          flagsMap.clear();
          curOffset = 0;
          line = "";
          components.add(component);
        }
      }
      final OneLineComponent component = new OneLineComponent();
      buf.append(component.setup(escapeString(line, escapeFunction), flagsMap, background));
      add(
          component,
          new GridBagConstraints(
              0,
              index,
              1,
              1,
              1,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(0, 0, 0, 0),
              0,
              0));
      components.add(component);
      myOneLineComponents = components.toArray(new OneLineComponent[components.size()]);
      return buf.toString();
    }
 public void clearSelections() {
   selections.clear();
 }