Exemplo n.º 1
0
  @Override
  protected List<? extends ICompletionProposal> computeProposals(
      final ITextViewer viewer, final int offset) {
    final IDocument document = viewer.getDocument();
    try {
      final String lineContent =
          DocumentUtilities.lineContentBeforeCurrentPosition(document, offset);
      final boolean shouldShowProposal = shouldShowProposals(lineContent, document, offset);

      if (shouldShowProposal) {
        final boolean isTsv = assist.isTsvFile();
        final Optional<IRegion> region =
            DocumentUtilities.findLiveCellRegion(document, isTsv, offset);
        final String prefix = DocumentUtilities.getPrefix(document, region, offset);
        final String content =
            region.isPresent()
                ? document.get(region.get().getOffset(), region.get().getLength())
                : "";
        final Image image =
            ImagesManager.getImage(RedImages.getImageForFileWithExtension(".robot"));

        final List<RedCompletionProposal> proposals = newArrayList();
        for (final IFile resourceFile : assist.getResourceFiles()) {

          final String resourcePath = resourceFile.getFullPath().makeRelative().toString();
          if (resourcePath.toLowerCase().startsWith(prefix.toLowerCase())) {
            final String resourceRelativePath =
                createCurrentFileRelativePath(resourceFile.getFullPath().makeRelative());
            final RedCompletionProposal proposal =
                RedCompletionBuilder.newProposal()
                    .will(assist.getAcceptanceMode())
                    .theText(resourceRelativePath)
                    .atOffset(offset - prefix.length())
                    .givenThatCurrentPrefixIs(prefix)
                    .andWholeContentIs(content)
                    .thenCursorWillStopAtTheEndOfInsertion()
                    .displayedLabelShouldBe(resourcePath)
                    .currentPrefixShouldBeDecorated()
                    .proposalsShouldHaveIcon(image)
                    .create();
            proposals.add(proposal);
          }
        }
        return proposals;
      }
      return null;
    } catch (final BadLocationException e) {
      return null;
    }
  }
Exemplo n.º 2
0
  private void createCurrentFrameworkInfo(final Composite parent) {
    currentFramework = toolkit.createFormText(parent, true);
    currentFramework.setImage(IMAGE_FOR_LINK, ImagesManager.getImage(RedImages.getRobotImage()));
    GridDataFactory.fillDefaults().grab(true, false).indent(15, 5).applyTo(currentFramework);

    final IHyperlinkListener hyperlinkListener = createHyperlinkListener();
    currentFramework.addHyperlinkListener(hyperlinkListener);
    currentFramework.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(final DisposeEvent e) {
            currentFramework.removeHyperlinkListener(hyperlinkListener);
          }
        });
  }
 @Override
 public Image getImage() {
   return ImagesManager.getImage(RedImages.getRobotImage());
 }
Exemplo n.º 4
0
 @Override
 public ImageDescriptor getImage() {
   return RedImages.getRobotSettingImage();
 }