Skip to content

Commit

Permalink
Fix 'diffLabel' IllegalArgumentException in add starters wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Mar 6, 2024
1 parent 1abd3e6 commit 399f24e
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.CompareViewerPane;
import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.Splitter;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.AbstractViewer;
import org.eclipse.compare.internal.BufferedResourceNode;
import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
import org.eclipse.compare.internal.CompareMessages;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.IMergeViewerTestAdapter;
Expand Down Expand Up @@ -76,6 +80,7 @@
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
Expand Down Expand Up @@ -665,7 +670,7 @@ public void acceptAllChanges() {
Set<Object> visited = new HashSet<>();
Queue<Object> toVisit = new LinkedList<>(getStructuredSelection().toList());
// To avoid problems with currently opened TextMergeViewer close whatever was opened
// fireOpen(new OpenEvent(this, StructuredSelection.EMPTY));
fireOpen(new OpenEvent(this, StructuredSelection.EMPTY));
while (!toVisit.isEmpty()) {
Object o = toVisit.poll();
if (!visited.contains(o)) {
Expand Down Expand Up @@ -736,6 +741,48 @@ public Viewer getMergeContentViewer() {
}
}

class CustomNullViewer extends AbstractViewer {

private final Control fDummy;
private final Composite parent;
private boolean firstSetInput = true;

public CustomNullViewer(Composite parent) {
this.parent = parent;
fDummy= new Tree(parent, SWT.NULL);

}

@Override
public void setInput(Object input) {
if (!parent.isDisposed() && firstSetInput) {
CompareViewerPane.clearToolBar(parent);
}
super.setInput(input);
firstSetInput = false;
}

@Override
public Control getControl() {
return fDummy;
}
}

@Override
protected CompareViewerSwitchingPane createContentViewerSwitchingPane(Splitter parent, int style, CompareEditorInput cei) {
return new CompareContentViewerSwitchingPane(parent, style, cei) {
@Override
protected Viewer getViewer(Viewer oldViewer, Object input) {
if (input instanceof MyDiffNode n) {
if (ITypedElement.FOLDER_TYPE.equals(n.getId().getType())) {
return new CustomNullViewer(this);
}
}
return super.getViewer(oldViewer, input);
}
};
}

@Override
public Viewer createDiffViewer(Composite parent) {
fDiffViewer= new CustomDiffTreeViewer(parent, getCompareConfiguration());
Expand Down

0 comments on commit 399f24e

Please sign in to comment.