public void show(DiffRequest data) { if (data instanceof MergeRequestImpl) { showDialog((MergeRequestImpl)data); return; } if (LOG.isDebugEnabled()) { LOG.debug(new Throwable("MergeTool - frame")); } FrameWrapper frameWrapper = new FrameWrapper(data.getProject(), data.getGroupKey()); DiffViewer mergePanel = createMergeComponent(data, null, frameWrapper); frameWrapper.setComponent(mergePanel.getComponent()); frameWrapper.setPreferredFocusedComponent(mergePanel.getPreferredFocusedComponent()); frameWrapper.closeOnEsc(); frameWrapper.setTitle(data.getWindowTitle()); frameWrapper.setProject(data.getProject()); frameWrapper.show(); }
@Override public void show(DiffRequest request) { final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey()); final DiffPanelImpl diffPanel = createDiffPanelImpl(request, frameWrapper.getFrame(), frameWrapper); final Editor editor = diffPanel.getEditor2(); updateHighLights(editor); editor.addEditorMouseListener(new EditorMouseAdapter() { @Override public void mouseClicked(EditorMouseEvent e) { if (e.getArea() != null && e.getArea().equals(EditorMouseEventArea.LINE_MARKERS_AREA)) { final Point locationOnScreen = e.getMouseEvent().getLocationOnScreen(); final int lineNumber = EditorUtil.yPositionToLogicalLine(editor, e.getMouseEvent()) + 1; showCommentsView(locationOnScreen, lineNumber, editor); } } }); DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent()); frameWrapper.setTitle(request.getWindowTitle()); frameWrapper.show(); }
private static void showPreviewDialog(@NotNull Project project, @NotNull TaskFile taskFile) { final FrameWrapper showPreviewFrame = new FrameWrapper(project); final LightVirtualFile userFile = new LightVirtualFile(taskFile.name, taskFile.text); showPreviewFrame.setTitle(userFile.getName()); LabeledEditor labeledEditor = new LabeledEditor(null); final EditorFactory factory = EditorFactory.getInstance(); Document document = FileDocumentManager.getInstance().getDocument(userFile); if (document == null) { return; } final EditorEx createdEditor = (EditorEx)factory.createEditor(document, project, userFile, true); Disposer.register(project, () -> factory.releaseEditor(createdEditor)); for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) { if (answerPlaceholder.getActiveSubtaskInfo().isNeedInsertText()) { answerPlaceholder.setLength(answerPlaceholder.getTaskText().length()); } Integer minIndex = Collections.min(answerPlaceholder.getSubtaskInfos().keySet()); answerPlaceholder.setUseLength(minIndex >= answerPlaceholder.getActiveSubtaskIndex()); EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE); } JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS)); header.setBorder(new EmptyBorder(10, 10, 10, 10)); header.add(new JLabel("Read-only preview.")); String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime()); header.add(new JLabel(String.format("Created %s.", timeStamp))); JComponent editorComponent = createdEditor.getComponent(); labeledEditor.setComponent(editorComponent, header); createdEditor.setCaretVisible(false); createdEditor.setCaretEnabled(false); showPreviewFrame.setComponent(labeledEditor); if (!ApplicationManager.getApplication().isUnitTestMode()) { showPreviewFrame.setSize(new Dimension(500, 500)); showPreviewFrame.show(); } }
public static void initDiffFrame(Project project, @NotNull FrameWrapper frameWrapper, @NotNull final DiffViewer diffPanel, final JComponent mainComponent) { frameWrapper.setComponent(mainComponent); frameWrapper.setProject(project); frameWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png")); frameWrapper.setPreferredFocusedComponent(diffPanel.getPreferredFocusedComponent()); frameWrapper.closeOnEsc(); }
public static void initDiffFrame(Project project, FrameWrapper frameWrapper, final DiffViewer diffPanel, final JComponent mainComponent) { frameWrapper.setComponent(mainComponent); frameWrapper.setProject(project); frameWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png")); frameWrapper.setPreferredFocusedComponent(diffPanel.getPreferredFocusedComponent()); frameWrapper.closeOnEsc(); }
public void show(DiffRequest data) { if (data instanceof MergeRequestImpl) { showDialog((MergeRequestImpl)data); return; } FrameWrapper frameWrapper = new FrameWrapper(data.getProject(), data.getGroupKey()); DiffViewer mergePanel = createMergeComponent(data, null, frameWrapper); frameWrapper.setComponent(mergePanel.getComponent()); frameWrapper.setPreferredFocusedComponent(mergePanel.getPreferredFocusedComponent()); frameWrapper.closeOnEsc(); frameWrapper.setTitle(data.getWindowTitle()); frameWrapper.setProject(data.getProject()); frameWrapper.show(); }
public static void initDiffFrame(Project project, @Nonnull FrameWrapper frameWrapper, @Nonnull final DiffViewer diffPanel, final JComponent mainComponent) { frameWrapper.setComponent(mainComponent); frameWrapper.setProject(project); frameWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png")); frameWrapper.setPreferredFocusedComponent(diffPanel.getPreferredFocusedComponent()); frameWrapper.closeOnEsc(); }