コード例 #1
0
 public boolean equals(Object o) {
   if (o instanceof StructureViewTreeElementWrapper) {
     return Comparing.equal(
         unwrapValue(getValue()), unwrapValue(((StructureViewTreeElementWrapper) o).getValue()));
   } else if (o instanceof StructureViewTreeElement) {
     return Comparing.equal(unwrapValue(getValue()), ((StructureViewTreeElement) o).getValue());
   }
   return false;
 }
コード例 #2
0
  public boolean equalsByActualOffset(@NotNull HighlightInfo info) {
    if (info == this) return true;

    return info.getSeverity() == getSeverity()
        && info.getActualStartOffset() == getActualStartOffset()
        && info.getActualEndOffset() == getActualEndOffset()
        && Comparing.equal(info.type, type)
        && Comparing.equal(info.gutterIconRenderer, gutterIconRenderer)
        && Comparing.equal(info.forcedTextAttributes, forcedTextAttributes)
        && Comparing.equal(info.forcedTextAttributesKey, forcedTextAttributesKey)
        && Comparing.strEqual(info.getDescription(), getDescription());
  }
コード例 #3
0
  @Override
  public boolean equals(Object obj) {
    if (obj == this) return true;
    if (!(obj instanceof HighlightInfo)) return false;
    HighlightInfo info = (HighlightInfo) obj;

    return info.getSeverity() == getSeverity()
        && info.startOffset == startOffset
        && info.endOffset == endOffset
        && Comparing.equal(info.type, type)
        && Comparing.equal(info.gutterIconRenderer, gutterIconRenderer)
        && Comparing.equal(info.forcedTextAttributes, forcedTextAttributes)
        && Comparing.equal(info.forcedTextAttributesKey, forcedTextAttributesKey)
        && Comparing.strEqual(info.getDescription(), getDescription());
  }
コード例 #4
0
  private static boolean addToPath(
      AbstractTreeNode<?> rootElement,
      Object element,
      ArrayList<AbstractTreeNode> result,
      Collection<Object> processedElements) {
    Object value = rootElement.getValue();
    if (value instanceof StructureViewTreeElement) {
      value = ((StructureViewTreeElement) value).getValue();
    }
    if (!processedElements.add(value)) {
      return false;
    }

    if (Comparing.equal(value, element)) {
      result.add(0, rootElement);
      return true;
    }

    Collection<? extends AbstractTreeNode> children = rootElement.getChildren();
    for (AbstractTreeNode child : children) {
      if (addToPath(child, element, result, processedElements)) {
        result.add(0, rootElement);
        return true;
      }
    }

    return false;
  }
コード例 #5
0
 public void refreshPresentation() {
   // 1. vertical 2. number of lines 3. soft wraps (4. ignore spaces)
   PresentationState current = new PresentationState();
   if (myFragmentedContent != null && !Comparing.equal(myPresentationState, current)) {
     myFragmentedContent.recalculate();
     refreshData(myFragmentedContent);
   }
   myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myParent);
   myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myParent);
 }
コード例 #6
0
  public Couple<String> setText(@Nullable final String text, @Nullable final String requestor) {
    if (StringUtil.isEmpty(text)
        && !Comparing.equal(requestor, myCurrentRequestor)
        && !EventLog.LOG_REQUESTOR.equals(requestor)) {
      return Couple.of(myInfoPanel.getText(), myCurrentRequestor);
    }

    boolean logMode = myInfoPanel.updateText(EventLog.LOG_REQUESTOR.equals(requestor) ? "" : text);
    myCurrentRequestor = logMode ? EventLog.LOG_REQUESTOR : requestor;
    return Couple.of(text, requestor);
  }
コード例 #7
0
 @Nullable
 private VirtualFile findNextFile(final VirtualFile file) {
   final EditorWindow[] windows = getWindows(); // TODO: use current file as base
   for (int i = 0; i != windows.length; ++i) {
     final VirtualFile[] files = windows[i].getFiles();
     for (final VirtualFile fileAt : files) {
       if (!Comparing.equal(fileAt, file)) {
         return fileAt;
       }
     }
   }
   return null;
 }
コード例 #8
0
 private static boolean infoEquals(HighlightInfo expectedInfo, HighlightInfo info) {
   if (expectedInfo == info) return true;
   return info.getSeverity() == expectedInfo.getSeverity()
       && info.startOffset == expectedInfo.startOffset
       && info.endOffset == expectedInfo.endOffset
       && info.isAfterEndOfLine() == expectedInfo.isAfterEndOfLine()
       && (expectedInfo.type == WHATEVER || expectedInfo.type.equals(info.type))
       && (Comparing.strEqual(ANY_TEXT, expectedInfo.getDescription())
           || Comparing.strEqual(info.getDescription(), expectedInfo.getDescription()))
       && (expectedInfo.forcedTextAttributes == null
           || Comparing.equal(
               expectedInfo.getTextAttributes(null, null), info.getTextAttributes(null, null)))
       && (expectedInfo.forcedTextAttributesKey == null
           || expectedInfo.forcedTextAttributesKey.equals(info.forcedTextAttributesKey));
 }
コード例 #9
0
  private static boolean containsLineMarker(LineMarkerInfo info, Collection<LineMarkerInfo> where) {
    final String infoTooltip = info.getLineMarkerTooltip();

    for (LineMarkerInfo markerInfo : where) {
      String markerInfoTooltip;
      if (markerInfo.startOffset == info.startOffset
          && markerInfo.endOffset == info.endOffset
          && (Comparing.equal(infoTooltip, markerInfoTooltip = markerInfo.getLineMarkerTooltip())
              || ANY_TEXT.equals(markerInfoTooltip)
              || ANY_TEXT.equals(infoTooltip))) {
        return true;
      }
    }
    return false;
  }
コード例 #10
0
 private void closeEditor() {
   boolean unsplit = false;
   if (mySplittedWindow != null && !mySplittedWindow.isDisposed()) {
     final EditorWithProviderComposite[] editors = mySplittedWindow.getEditors();
     if (editors.length == 1 && Comparing.equal(editors[0].getFile(), myNewVirtualFile)) {
       unsplit = true;
     }
   }
   FileEditorManager.getInstance(myProject).closeFile(myNewVirtualFile);
   if (unsplit) {
     for (EditorWindow editorWindow : mySplittedWindow.findSiblings()) {
       editorWindow.unsplit(true);
     }
   }
 }
コード例 #11
0
 protected static void assertSameLinesWithFile(String filePath, String actualText) {
   String fileText;
   try {
     if (OVERWRITE_TESTDATA) {
       VfsTestUtil.overwriteTestData(filePath, actualText);
       System.out.println("File " + filePath + " created.");
     }
     fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8);
   } catch (FileNotFoundException e) {
     VfsTestUtil.overwriteTestData(filePath, actualText);
     throw new AssertionFailedError("No output text found. File " + filePath + " created.");
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   String expected = StringUtil.convertLineSeparators(fileText.trim());
   String actual = StringUtil.convertLineSeparators(actualText.trim());
   if (!Comparing.equal(expected, actual)) {
     throw new FileComparisonFailure(null, expected, actual, filePath);
   }
 }
コード例 #12
0
 @NotNull
 public VirtualFile[] getSelectedFiles() {
   final Set<VirtualFile> files = new ArrayListSet<VirtualFile>();
   for (final EditorWindow window : myWindows) {
     final VirtualFile file = window.getSelectedFile();
     if (file != null) {
       files.add(file);
     }
   }
   final VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files);
   final VirtualFile currentFile = getCurrentFile();
   if (currentFile != null) {
     for (int i = 0; i != virtualFiles.length; ++i) {
       if (Comparing.equal(virtualFiles[i], currentFile)) {
         virtualFiles[i] = virtualFiles[0];
         virtualFiles[0] = currentFile;
         break;
       }
     }
   }
   return virtualFiles;
 }
コード例 #13
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean selected, boolean focused, int row, int column) {
    RendererComponent panel = getEditorPanel(table);
    EditorEx editor = panel.getEditor();
    editor.getColorsScheme().setEditorFontSize(table.getFont().getSize());

    editor
        .getColorsScheme()
        .setColor(EditorColors.SELECTION_BACKGROUND_COLOR, table.getSelectionBackground());
    editor
        .getColorsScheme()
        .setColor(EditorColors.SELECTION_FOREGROUND_COLOR, table.getSelectionForeground());
    editor.setBackgroundColor(selected ? table.getSelectionBackground() : table.getBackground());
    panel.setSelected(!Comparing.equal(editor.getBackgroundColor(), table.getBackground()));

    panel.setBorder(
        null); // prevents double border painting when ExtendedItemRendererComponentWrapper is used

    customizeEditor(editor, table, value, selected, row, column);
    return panel;
  }
コード例 #14
0
  public ApplicationImpl(
      boolean isInternal,
      boolean isUnitTestMode,
      boolean isHeadless,
      boolean isCommandLine,
      @NotNull String appName) {
    super(null);

    getPicoContainer().registerComponentInstance(Application.class, this);

    CommonBundle.assertKeyIsFound = isUnitTestMode;

    if ((isInternal || isUnitTestMode)
        && !Comparing.equal("off", System.getProperty("idea.disposer.debug"))) {
      Disposer.setDebugMode(true);
    }
    myStartTime = System.currentTimeMillis();
    myName = appName;
    ApplicationManagerEx.setApplication(this);

    PluginsFacade.INSTANCE =
        new PluginsFacade() {
          public IdeaPluginDescriptor getPlugin(PluginId id) {
            return PluginManager.getPlugin(id);
          }

          public IdeaPluginDescriptor[] getPlugins() {
            return PluginManager.getPlugins();
          }
        };

    if (!isUnitTestMode && !isHeadless) {
      Toolkit.getDefaultToolkit().getSystemEventQueue().push(IdeEventQueue.getInstance());
      if (Patches.SUN_BUG_ID_6209673) {
        RepaintManager.setCurrentManager(new IdeRepaintManager());
      }
      IconLoader.activate();
    }

    myIsInternal = isInternal;
    myTestModeFlag = isUnitTestMode;
    myHeadlessMode = isHeadless;
    myCommandLineMode = isCommandLine;

    loadApplicationComponents();

    if (myTestModeFlag) {
      registerShutdownHook();
    }

    if (!isUnitTestMode && !isHeadless) {
      Disposer.register(this, Disposer.newDisposable(), "ui");

      StartupUtil.addExternalInstanceListener(
          new Consumer<List<String>>() {
            @Override
            public void consume(final List<String> args) {
              invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      final Project project = CommandLineProcessor.processExternalCommandLine(args);
                      final IdeFrame frame;
                      if (project != null) {
                        frame = WindowManager.getInstance().getIdeFrame(project);
                      } else {
                        frame = WindowManager.getInstance().getAllFrames()[0];
                      }
                      ((IdeFrameImpl) frame).requestFocus();
                    }
                  });
            }
          });
    }

    final String s = System.getProperty("jb.restart.code");
    if (s != null) {
      try {
        myRestartCode = Integer.parseInt(s);
      } catch (NumberFormatException ignore) {
      }
    }
  }
コード例 #15
0
  public ApplicationImpl(
      boolean isInternal,
      boolean isUnitTestMode,
      boolean isHeadless,
      boolean isCommandLine,
      @NotNull String appName,
      Splash splash) {
    super(null);

    ApplicationManagerEx.setApplication(
        this, myLastDisposable); // reset back to null only when all components already disposed

    getPicoContainer().registerComponentInstance(Application.class, this);

    CommonBundle.assertKeyIsFound = isUnitTestMode;
    AWTExceptionHandler.register(); // do not crash AWT on exceptions
    if ((isInternal || isUnitTestMode)
        && !Comparing.equal("off", System.getProperty("idea.disposer.debug"))) {
      Disposer.setDebugMode(true);
    }
    myStartTime = System.currentTimeMillis();
    mySplash = splash;
    myName = appName;

    PluginsFacade.INSTANCE =
        new PluginsFacade() {
          public IdeaPluginDescriptor getPlugin(PluginId id) {
            return PluginManager.getPlugin(id);
          }

          public IdeaPluginDescriptor[] getPlugins() {
            return PluginManager.getPlugins();
          }
        };

    myIsInternal = isInternal;
    myTestModeFlag = isUnitTestMode;
    myHeadlessMode = isHeadless;
    myCommandLineMode = isCommandLine;

    myDoNotSave = myTestModeFlag || myHeadlessMode;

    loadApplicationComponents();

    if (myTestModeFlag) {
      registerShutdownHook();
    }

    if (!isUnitTestMode && !isHeadless) {
      Disposer.register(this, Disposer.newDisposable(), "ui");

      StartupUtil.addExternalInstanceListener(
          new Consumer<List<String>>() {
            @Override
            public void consume(final List<String> args) {
              invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      final Project project = CommandLineProcessor.processExternalCommandLine(args);
                      final IdeFrame frame;
                      if (project != null) {
                        frame = WindowManager.getInstance().getIdeFrame(project);
                      } else {
                        frame = WindowManager.getInstance().getAllFrames()[0];
                      }
                      ((IdeFrameImpl) frame).requestFocus();
                    }
                  });
            }
          });
    }

    final String s = System.getProperty("jb.restart.code");
    if (s != null) {
      try {
        myRestartCode = Integer.parseInt(s);
      } catch (NumberFormatException ignore) {
      }
    }

    registerFont("/fonts/Inconsolata.ttf");
  }