Exemplo n.º 1
0
  public void attemptToFinishActiveJob(String caseID, String taskID) {
    Set workItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();
      if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
        try {
          String outputData = _myActiveTasks.getOutputData(caseID, taskID);

          /** AJH: Write the output data into test data file */
          File testDataDir = YAdminGUI.getSpecTestDataDirectory(item.getSpecificationID().getKey());
          File taskInputData = new File(testDataDir, taskID + ".xml");
          if (!taskInputData.exists()) {
            logger.info("Creating task data file - " + taskInputData.getAbsolutePath());
            taskInputData.createNewFile();
          }
          StringUtil.stringToFile(taskInputData.getAbsolutePath(), outputData);

          //        _engineClient.completeWorkItem(item, outputData, inSequenceWorkitemIDs);
          _engineClient.completeWorkItem(item, outputData, null, YEngine.WorkItemCompletion.Normal);
        } catch (YDataStateException e) {
          String errors = e.getMessage();
          if (errors.indexOf("FAILED TO VALIDATE AGAINST SCHEMA =") != -1) {
            System.out.println(e.getMessage());
            new SpecificationQueryProcessingValidationErrorBox(_frame, item, e);
          } else {
            new UserInputValidationErrorBox(_frame, item, e);
            System.out.println(e.getMessage());
          }
        } catch (Exception e) {
          // todo AJH - Create defalut skeleton at this point????
          reportGeneralProblem(e);
        }
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Return the XML test data for a specified task
   *
   * @param caseID
   * @param taskID
   * @return testData
   */
  public String getTaskTestData(String caseID, String taskID) {
    String testData = null;
    File taskInputData = null;

    Set workItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();
      if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
        try {
          File testDataDir = YAdminGUI.getSpecTestDataDirectory(item.getSpecificationID().getKey());
          taskInputData = new File(testDataDir, taskID + ".xml");
          if (taskInputData.exists()) {
            testData = StringUtil.fileToString(taskInputData);
          }
        } catch (Exception e) {
          reportGeneralProblem(e);
        }
      }
    }

    if (testData == null) {
      return testData;
    } else if (testData.startsWith(xmlCommentHeader)) {
      return testData;
    } else {
      return xmlCommentHeader + taskInputData.getName() + " -->\n" + testData;
    }
  }
 @Override
 protected void postProcess(Sector.Triangle[] triangles) {
   if (show.contains("triangles")) {
     int i = 0;
     for (Sector.Triangle t : triangles) {
       GeoPoint[] trianglePoints = t.getPoints('A');
       double x = 0, y = 0;
       int l = trianglePoints.length;
       double[] points = new double[l * 2 + 2];
       for (int j = 0; j <= l; j++) {
         Point p = trianglePoints[j % l].toPoint(1000.0);
         points[j * 2] = p.x;
         points[j * 2 + 1] = p.z;
         if (j < l) {
           x += p.x;
           y += p.z;
         }
       }
       x /= l;
       y /= l;
       for (int j = 0; j <= l; j++) {
         points[j * 2] = points[j * 2] * 0.95 + x * 0.05;
         points[j * 2 + 1] = points[j * 2 + 1] * 0.95 + y * 0.05;
       }
       Color color = t.inverted ? triangleInverted : triangleNormal;
       out.addLine(color, points);
       if (show.contains("labels")) {
         out.addLabel(color, "" + i, x, y);
       }
       i++;
     }
   }
   super.postProcess(triangles);
 }
 private int countDistinctGlobalSectors(Set<Sector> neighbors) {
   Set<GlobalSector> globalSectors = new HashSet<GlobalSector>();
   for (Sector s : neighbors) {
     globalSectors.add(s.getParent());
   }
   return globalSectors.size();
 }
    public TooltipRenderer calcTooltipRenderer(
        @NotNull final Collection<RangeHighlighter> highlighters) {
      LineTooltipRenderer bigRenderer = null;
      // do not show same tooltip twice
      Set<String> tooltips = null;

      for (RangeHighlighter highlighter : highlighters) {
        final Object tooltipObject = highlighter.getErrorStripeTooltip();
        if (tooltipObject == null) continue;

        final String text = tooltipObject.toString();
        if (tooltips == null) {
          tooltips = new THashSet<String>();
        }
        if (tooltips.add(text)) {
          if (bigRenderer == null) {
            bigRenderer = new LineTooltipRenderer(text, new Object[] {highlighters});
          } else {
            bigRenderer.addBelow(text);
          }
        }
      }

      return bigRenderer;
    }
  private void addCondition(@NotNull ArrangementUiComponent component) {
    mySkipStateChange = true;
    try {
      component.setSelected(true);
      Collection<Set<ArrangementSettingsToken>> mutexes = mySettingsManager.getMutexes();

      // Update 'mutex conditions', i.e. conditions which can't be active at the same time (e.g.
      // type 'field' and type 'method').
      for (Set<ArrangementSettingsToken> mutex : mutexes) {
        if (!mutex.contains(component.getToken())) {
          continue;
        }
        for (ArrangementSettingsToken key : mutex) {
          if (key.equals(component.getToken())) {
            continue;
          }
          ArrangementUiComponent c = myComponents.get(key);
          if (c != null && c.isEnabled()) {
            removeCondition(c);
          }
        }
      }
      refreshConditions();
    } finally {
      mySkipStateChange = false;
    }
  }
  private List<String> mergeAttributes(Map<String, List<File>> inputFiles) {
    Set<String> mergedAttributes = new HashSet<String>();
    for (List<File> plateFiles : inputFiles.values()) {
      mergedAttributes.addAll(getAssayParamNames(plateFiles));
    }

    for (String barcode : inputFiles.keySet()) {
      List<File> plateFiles = inputFiles.get(barcode);

      HashSet<String> curSetAttribtues = new HashSet<String>(getAssayParamNames(plateFiles));

      if (!mergedAttributes.equals(curSetAttribtues)) {
        logger.error(
            "The attributes '"
                + curSetAttribtues
                + "'of plate '"
                + barcode
                + "' are not the same as the collected ones: '"
                + mergedAttributes
                + "'");
      }
    }

    return new ArrayList<String>(mergedAttributes);
  }
  public boolean checkCanRemove(final List<? extends PackagingElementNode<?>> nodes) {
    Set<PackagingNodeSource> rootSources = new HashSet<PackagingNodeSource>();
    for (PackagingElementNode<?> node : nodes) {
      rootSources.addAll(getRootNodeSources(node.getNodeSources()));
    }

    if (!rootSources.isEmpty()) {
      final String message;
      if (rootSources.size() == 1) {
        final String name = rootSources.iterator().next().getPresentableName();
        message =
            "The selected node belongs to '"
                + name
                + "' element. Do you want to remove the whole '"
                + name
                + "' element from the artifact?";
      } else {
        message =
            "The selected node belongs to "
                + nodes.size()
                + " elements. Do you want to remove all these elements from the artifact?";
      }
      final int answer =
          Messages.showYesNoDialog(
              myArtifactsEditor.getMainComponent(), message, "Remove Elements", null);
      if (answer != Messages.YES) return false;
    }
    return true;
  }
  private void calculateRoots() {
    final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
    // assertion for read access inside
    final Module[] modules =
        ApplicationManager.getApplication()
            .runReadAction(
                new Computable<Module[]>() {
                  public Module[] compute() {
                    return moduleManager.getModules();
                  }
                });

    final TreeSet<VirtualFile> checkSet =
        new TreeSet<VirtualFile>(FilePathComparator.getInstance());
    myRoots = new HashSet<VirtualFile>();
    myRoots.addAll(myInitialRoots);
    checkSet.addAll(myInitialRoots);
    for (Module module : modules) {
      final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
      for (VirtualFile file : files) {
        final VirtualFile floor = checkSet.floor(file);
        if (floor != null) {
          myModulesSet.put(file, module.getName());
          myRoots.add(file);
        }
      }
    }
  }
  @Override
  public void saveAllDocuments() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myMultiCaster.beforeAllDocumentsSaving();
    if (myUnsavedDocuments.isEmpty()) return;

    final Map<Document, IOException> failedToSave = new HashMap<Document, IOException>();
    final Set<Document> vetoed = new HashSet<Document>();
    while (true) {
      int count = 0;

      for (Document document : myUnsavedDocuments) {
        if (failedToSave.containsKey(document)) continue;
        if (vetoed.contains(document)) continue;
        try {
          doSaveDocument(document);
        } catch (IOException e) {
          //noinspection ThrowableResultOfMethodCallIgnored
          failedToSave.put(document, e);
        } catch (SaveVetoException e) {
          vetoed.add(document);
        }
        count++;
      }

      if (count == 0) break;
    }

    if (!failedToSave.isEmpty()) {
      handleErrorsOnSave(failedToSave);
    }
  }
  public void addSelection(Point p) {
    ExprPoint ep = null;
    int minDist = -1;

    for (ExprPoint ex : points) {
      int sd = ex.screenDist(p);
      if (ep == null || sd < minDist) {
        ep = ex;
        minDist = sd;
      }
    }

    if (ep != null) {
      Set<Point> remove = new HashSet<Point>();
      for (Point rp : selections.keySet()) {
        if (selections.get(rp).equals(ep)) {
          remove.add(rp);
        }
      }

      selections.put(p, ep);

      for (Point rp : remove) {
        selections.remove(rp);
      }
    }
  }
 /**
  * Generate new configuration name basing on descriptor
  *
  * @return the generated configuration name
  */
 private String generateNewConfigurationName() {
   String name = null;
   for (BranchDescriptor d : myBranches) {
     if (d.newBranchName != null) {
       name = d.newBranchName;
       break;
     }
     if (d.existingBranches.contains(d.currentReference)) {
       name = d.currentReference;
     }
   }
   if (name == null) {
     name = "untitled";
   }
   if (myExistingConfigNames.contains(name)) {
     for (int i = 2; i < Integer.MAX_VALUE; i++) {
       String t = name + i;
       if (!myExistingConfigNames.contains(t)) {
         name = t;
         break;
       }
     }
   }
   return name;
 }
 private Set<Key> getActiveProviderKeys() {
   Set<Key> result = new HashSet<Key>();
   for (BeforeRunTask task : myModel.getItems()) {
     result.add(task.getProviderId());
   }
   return result;
 }
Exemplo n.º 14
0
 private void fireTilesChangedIncludeBorder(Set<Tile> tiles) {
   if (showBorder
       && (tileProvider instanceof Dimension)
       && (((Dimension) tileProvider).getDim() == DIM_NORMAL)
       && (((Dimension) tileProvider).getBorder() != null)) {
     final Set<Point> coordSet = new HashSet<>();
     for (Tile tile : tiles) {
       final int tileX = tile.getX(),
           tileY = tile.getY(),
           borderSize = ((Dimension) tileProvider).getBorderSize();
       for (int dx = -borderSize; dx <= borderSize; dx++) {
         for (int dy = -borderSize; dy <= borderSize; dy++) {
           coordSet.add(getTileCoordinates(tileX + dx, tileY + dy));
         }
       }
     }
     for (TileListener listener : listeners) {
       listener.tilesChanged(this, coordSet);
     }
   } else {
     Set<Point> coords = tiles.stream().map(this::getTileCoordinates).collect(Collectors.toSet());
     for (TileListener listener : listeners) {
       listener.tilesChanged(this, coords);
     }
   }
 }
 @NotNull
 private static Collection<PsiLanguageInjectionHost> collectInjectionHosts(
     @NotNull PsiFile file, @NotNull TextRange range) {
   Stack<PsiElement> toProcess = new Stack<PsiElement>();
   for (PsiElement e = file.findElementAt(range.getStartOffset());
       e != null;
       e = e.getNextSibling()) {
     if (e.getTextRange().getStartOffset() >= range.getEndOffset()) {
       break;
     }
     toProcess.push(e);
   }
   if (toProcess.isEmpty()) {
     return Collections.emptySet();
   }
   Set<PsiLanguageInjectionHost> result = null;
   while (!toProcess.isEmpty()) {
     PsiElement e = toProcess.pop();
     if (e instanceof PsiLanguageInjectionHost) {
       if (result == null) {
         result = ContainerUtilRt.newHashSet();
       }
       result.add((PsiLanguageInjectionHost) e);
     } else {
       for (PsiElement child = e.getFirstChild(); child != null; child = child.getNextSibling()) {
         if (e.getTextRange().getStartOffset() >= range.getEndOffset()) {
           break;
         }
         toProcess.push(child);
       }
     }
   }
   return result == null ? Collections.<PsiLanguageInjectionHost>emptySet() : result;
 }
  private static void updateExistingPluginInfo(
      IdeaPluginDescriptor descr, IdeaPluginDescriptor existing) {
    int state = StringUtil.compareVersionNumbers(descr.getVersion(), existing.getVersion());
    final PluginId pluginId = existing.getPluginId();
    final String idString = pluginId.getIdString();
    final JDOMExternalizableStringList installedPlugins =
        PluginManagerUISettings.getInstance().getInstalledPlugins();
    if (!installedPlugins.contains(idString)
        && !((IdeaPluginDescriptorImpl) existing).isDeleted()) {
      installedPlugins.add(idString);
    }
    final PluginManagerUISettings updateSettings = PluginManagerUISettings.getInstance();
    if (state > 0
        && !PluginManager.isIncompatible(descr)
        && !updatedPlugins.contains(descr.getPluginId())) {
      NewVersions2Plugins.put(pluginId, 1);
      if (!updateSettings.myOutdatedPlugins.contains(idString)) {
        updateSettings.myOutdatedPlugins.add(idString);
      }

      final IdeaPluginDescriptorImpl plugin = (IdeaPluginDescriptorImpl) existing;
      plugin.setDownloadsCount(descr.getDownloads());
      plugin.setVendor(descr.getVendor());
      plugin.setVendorEmail(descr.getVendorEmail());
      plugin.setVendorUrl(descr.getVendorUrl());
      plugin.setUrl(descr.getUrl());

    } else {
      updateSettings.myOutdatedPlugins.remove(idString);
      if (NewVersions2Plugins.remove(pluginId) != null) {
        updatedPlugins.add(pluginId);
      }
    }
  }
Exemplo n.º 17
0
  private void checkForEmptyAndDuplicatedNames(
      MyNode rootNode,
      String prefix,
      String title,
      Class<? extends NamedConfigurable> configurableClass,
      boolean recursively)
      throws ConfigurationException {
    final Set<String> names = new HashSet<String>();
    for (int i = 0; i < rootNode.getChildCount(); i++) {
      final MyNode node = (MyNode) rootNode.getChildAt(i);
      final NamedConfigurable scopeConfigurable = node.getConfigurable();

      if (configurableClass.isInstance(scopeConfigurable)) {
        final String name = scopeConfigurable.getDisplayName();
        if (name.trim().length() == 0) {
          selectNodeInTree(node);
          throw new ConfigurationException("Name should contain non-space characters");
        }
        if (names.contains(name)) {
          final NamedConfigurable selectedConfigurable = getSelectedConfigurable();
          if (selectedConfigurable == null
              || !Comparing.strEqual(selectedConfigurable.getDisplayName(), name)) {
            selectNodeInTree(node);
          }
          throw new ConfigurationException(
              CommonBundle.message("smth.already.exist.error.message", prefix, name), title);
        }
        names.add(name);
      }

      if (recursively) {
        checkForEmptyAndDuplicatedNames(node, prefix, title, configurableClass, true);
      }
    }
  }
 private void updateRightTreeModel() {
   Set<PsiFile> deps = new HashSet<PsiFile>();
   Set<PsiFile> scope = getSelectedScope(myLeftTree);
   myIllegalsInRightTree = new HashSet<PsiFile>();
   for (PsiFile psiFile : scope) {
     Map<DependencyRule, Set<PsiFile>> illegalDeps = myIllegalDependencies.get(psiFile);
     if (illegalDeps != null) {
       for (final DependencyRule rule : illegalDeps.keySet()) {
         myIllegalsInRightTree.addAll(illegalDeps.get(rule));
       }
     }
     final Set<PsiFile> psiFiles = myDependencies.get(psiFile);
     if (psiFiles != null) {
       for (PsiFile file : psiFiles) {
         if (file != null && file.isValid()) {
           deps.add(file);
         }
       }
     }
   }
   deps.removeAll(scope);
   myRightTreeExpansionMonitor.freeze();
   myRightTree.setModel(buildTreeModel(deps, myRightTreeMarker));
   myRightTreeExpansionMonitor.restore();
   expandFirstLevel(myRightTree);
 }
Exemplo n.º 19
0
 public void writeMap(Cluster cluster, float yBar) {
   Set<Submission> subSet = new HashSet<Submission>(cluster.size());
   String documents = "";
   for (int i = 0; i < cluster.size(); i++) {
     Submission sub = submissions.elementAt(cluster.getSubmissionAt(i));
     documents += sub.name + " ";
     subSet.add(sub);
   }
   documents = documents.trim();
   String theme =
       ThemeGenerator.generateThemes(subSet, this.program.get_themewords(), false, this.program);
   mapString +=
       "<area shape=\"rect\" coords=\""
           + (cluster.x - 2)
           + ","
           + (yBar)
           + ","
           + (cluster.x + 2)
           + ","
           + (cluster.y + 2)
           + "\" onMouseover=\"set('"
           + cluster.size()
           + "','"
           + trimStringToLength(String.valueOf(cluster.getSimilarity()), 6)
           + "','"
           + trimStringToLength(documents, 50)
           + "','"
           + theme
           + "')\" ";
   //		if (cluster.size() == 1)
   //			mapString += "href=\"submission"+cluster.getSubmissionAt(0)+".html\">\n";
   //		else
   mapString += "nohref>\n";
 }
  @Nullable
  public FilteringTreeStructure.FilteringNode selectPsiElement(PsiElement element) {
    Set<PsiElement> parents = getAllParents(element);

    FilteringTreeStructure.FilteringNode node =
        (FilteringTreeStructure.FilteringNode) myAbstractTreeBuilder.getRootElement();
    while (node != null) {
      boolean changed = false;
      for (FilteringTreeStructure.FilteringNode n : node.children()) {
        final PsiElement psiElement = getPsi(n);
        if (psiElement != null && parents.contains(psiElement)) {
          node = n;
          changed = true;
          break;
        }
      }
      if (!changed) {
        myAbstractTreeBuilder.select(node);
        if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) {
          TreeUtil.selectFirstNode(myTree);
        }
        myInitialNodeIsLeaf = node.getChildren().length == 0;
        return node;
      }
    }
    TreeUtil.selectFirstNode(myTree);
    return null;
  }
  void doAddAction(AnActionButton button) {
    if (isUnknown()) {
      return;
    }

    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BeforeRunTaskProvider<BeforeRunTask>[] providers =
        Extensions.getExtensions(
            BeforeRunTaskProvider.EXTENSION_POINT_NAME, myRunConfiguration.getProject());
    Set<Key> activeProviderKeys = getActiveProviderKeys();

    DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
    for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
      if (provider.createTask(myRunConfiguration) == null) continue;
      if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton()) continue;
      AnAction providerAction =
          new AnAction(provider.getName(), null, provider.getIcon()) {
            @Override
            public void actionPerformed(AnActionEvent e) {
              BeforeRunTask task = provider.createTask(myRunConfiguration);
              if (task != null) {
                provider.configureTask(myRunConfiguration, task);
                if (!provider.canExecuteTask(myRunConfiguration, task)) return;
              } else {
                return;
              }
              task.setEnabled(true);

              Set<RunConfiguration> configurationSet = new HashSet<RunConfiguration>();
              getAllRunBeforeRuns(task, configurationSet);
              if (configurationSet.contains(myRunConfiguration)) {
                JOptionPane.showMessageDialog(
                    BeforeRunStepsPanel.this,
                    ExecutionBundle.message(
                        "before.launch.panel.cyclic_dependency_warning",
                        myRunConfiguration.getName(),
                        provider.getDescription(task)),
                    ExecutionBundle.message("warning.common.title"),
                    JOptionPane.WARNING_MESSAGE);
                return;
              }
              addTask(task);
              myListener.fireStepsBeforeRunChanged();
            }
          };
      actionGroup.add(providerAction);
    }
    final ListPopup popup =
        popupFactory.createActionGroupPopup(
            ExecutionBundle.message("add.new.run.configuration.acrtion.name"),
            actionGroup,
            SimpleDataContext.getProjectContext(myRunConfiguration.getProject()),
            false,
            false,
            false,
            null,
            -1,
            Condition.TRUE);
    popup.show(button.getPreferredPopupPoint());
  }
Exemplo n.º 22
0
  private void updateCursorHighlighting(boolean scroll) {
    hideBalloon();

    if (myCursorHighlighter != null) {
      HighlightManager.getInstance(mySearchResults.getProject())
          .removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter);
      myCursorHighlighter = null;
    }

    final FindResult cursor = mySearchResults.getCursor();
    Editor editor = mySearchResults.getEditor();
    SelectionModel selection = editor.getSelectionModel();
    if (cursor != null) {
      Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>();
      highlightRange(
          cursor, new TextAttributes(null, null, Color.BLACK, EffectType.ROUNDED_BOX, 0), dummy);
      if (!dummy.isEmpty()) {
        myCursorHighlighter = dummy.iterator().next();
      }

      if (scroll) {
        if (mySearchResults.getFindModel().isGlobal()) {
          FoldingModel foldingModel = editor.getFoldingModel();
          final FoldRegion[] allRegions = editor.getFoldingModel().getAllFoldRegions();

          foldingModel.runBatchFoldingOperation(
              new Runnable() {
                @Override
                public void run() {
                  for (FoldRegion region : allRegions) {
                    if (!region.isValid()) continue;
                    if (cursor.intersects(TextRange.create(region))) {
                      region.setExpanded(true);
                    }
                  }
                }
              });
          selection.setSelection(cursor.getStartOffset(), cursor.getEndOffset());

          editor.getCaretModel().moveToOffset(cursor.getEndOffset());
          editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
        } else {
          if (!SearchResults.insideVisibleArea(editor, cursor)) {
            LogicalPosition pos = editor.offsetToLogicalPosition(cursor.getStartOffset());
            editor.getScrollingModel().scrollTo(pos, ScrollType.CENTER);
          }
        }
      }
      editor
          .getScrollingModel()
          .runActionOnScrollingFinished(
              new Runnable() {
                @Override
                public void run() {
                  showReplacementPreview();
                }
              });
    }
  }
  private Set<String> getDownstream(String mut) {
    Set<String> tfs = new HashSet<String>();
    tfs.add(mut);

    if (depth > 1) tfs.addAll(travSt.getDownstream(tfs, depth - 1));

    return travExp.getDownstream(tfs);
  }
  private boolean checkReadonlyUsages() {
    final Set<VirtualFile> readOnlyUsages = getReadOnlyUsagesFiles();

    return readOnlyUsages.isEmpty()
        || !ReadonlyStatusHandler.getInstance(myProject)
            .ensureFilesWritable(VfsUtil.toVirtualFileArray(readOnlyUsages))
            .hasReadonlyFiles();
  }
 private void collectOptions(Set<String> optionNames, final List<Option> optionList) {
   for (Option option : optionList) {
     if (option.groupName != null) {
       optionNames.add(option.groupName);
     }
     optionNames.add(option.title);
   }
 }
 private Set<Object> doFilter(Set<Object> elements) {
   Set<Object> result = new LinkedHashSet<Object>();
   for (Object o : elements) {
     if (myElementClass.isInstance(o) && getFilter().isAccepted((T) o)) {
       result.add(o);
     }
   }
   return result;
 }
Exemplo n.º 27
0
 {
   for (myjava.gui.syntax.Painter painter : myjava.gui.syntax.Painter.getPainters()) {
     painterComboBox.addItem(painter);
     EntryListPanel panel = new EntryListPanel(painter);
     listPanelSet.add(panel);
     centerPanel.add(panel, painter.getName());
   }
   componentSet.addAll(Arrays.asList(matchBracket, painterComboBox, centerPanel));
 }
Exemplo n.º 28
0
  /**
   * Takes the raw page lines represented as one continuous line and sorts the text by the y access
   * of the word bounds. The words are then sliced into separate lines base on y changes. And
   * finally each newly sorted line is sorted once more by each words x coordinate.
   */
  public void sortAndFormatText() {
    ArrayList<LineText> visiblePageLines = new ArrayList<LineText>(pageLines);
    // create new array for storing the sorted lines
    ArrayList<LineText> sortedPageLines = sortLinesVertically(visiblePageLines);
    // try and insert the option words on existing lines
    if (sortedPageLines.size() == 0) {
      sortedPageLines = getVisiblePageLines(true);
    } else {
      insertOptionalLines(sortedPageLines);
    }

    // sort again
    sortedPageLines = sortLinesVertically(sortedPageLines);

    // do a rough check for duplicate strings that are sometimes generated
    // by Chrystal Reports.  Enable with
    // -Dorg.icepdf.core.views.page.text.trim.duplicates=true
    if (checkForDuplicates) {
      for (final LineText lineText : sortedPageLines) {
        final List<WordText> words = lineText.getWords();
        if (words.size() > 0) {
          final List<WordText> trimmedWords = new ArrayList<WordText>();
          final Set<String> refs = new HashSet<String>();
          for (final WordText wordText : words) {
            // use regular rectangle so get a little rounding.
            final String key = wordText.getText() + wordText.getBounds().getBounds();
            if (refs.add(key)) {
              trimmedWords.add(wordText);
            }
          }
          lineText.setWords(trimmedWords);
        }
      }
    }

    // sort each line by x coordinate.
    if (sortedPageLines.size() > 0) {
      for (LineText lineText : sortedPageLines) {
        Collections.sort(lineText.getWords(), new WordPositionComparator());
      }
    }

    // recalculate the line bounds.
    if (sortedPageLines.size() > 0) {
      for (LineText lineText : sortedPageLines) {
        lineText.getBounds();
      }
    }

    // sort the lines
    if (sortedPageLines.size() > 0 && !preserveColumns) {
      Collections.sort(sortedPageLines, new LinePositionComparator());
    }
    // assign back the sorted lines.
    this.sortedPageLines = sortedPageLines;
  }
  private static Set<PsiElement> getAllParents(PsiElement element) {
    Set<PsiElement> parents = new java.util.HashSet<PsiElement>();

    while (element != null) {
      parents.add(element);
      if (element instanceof PsiFile) break;
      element = element.getParent();
    }
    return parents;
  }
Exemplo n.º 30
0
 public void splitObjects() {
   Object[] os = this.list.getSelectedValues();
   if (os.length == 0) return;
   Set<ObjectStructure> channels = new HashSet<ObjectStructure>();
   for (Object o : os) {
     if (split((Object3DGui) o)) channels.add(((Object3DGui) o).getChannel());
   }
   for (ObjectStructure o : channels) o.saveOutput();
   saveOptions();
 }