use of com.intellij.ide.structureView.impl.StructureViewComposite in project intellij-community by JetBrains.
the class StructureViewWrapperImpl method rebuild.
public void rebuild() {
if (myProject.isDisposed())
return;
Dimension referenceSize = null;
if (myStructureView != null) {
if (myStructureView instanceof StructureView.Scrollable) {
referenceSize = ((StructureView.Scrollable) myStructureView).getCurrentSize();
}
myStructureView.storeState();
Disposer.dispose(myStructureView);
myStructureView = null;
myFileEditor = null;
}
if (myModuleStructureComponent != null) {
Disposer.dispose(myModuleStructureComponent);
myModuleStructureComponent = null;
}
final ContentManager contentManager = myToolWindow.getContentManager();
contentManager.removeAllContents(true);
if (!isStructureViewShowing()) {
return;
}
VirtualFile file = myFile;
if (file == null) {
final VirtualFile[] selectedFiles = FileEditorManager.getInstance(myProject).getSelectedFiles();
if (selectedFiles.length > 0) {
file = selectedFiles[0];
}
}
String[] names = { "" };
if (file != null && file.isValid()) {
if (file.isDirectory()) {
if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module != null && !(ModuleUtil.getModuleType(module) instanceof InternalModuleType)) {
myModuleStructureComponent = new ModuleStructureComponent(module);
createSinglePanel(myModuleStructureComponent.getComponent());
Disposer.register(this, myModuleStructureComponent);
}
}
} else {
FileEditor editor = FileEditorManager.getInstance(myProject).getSelectedEditor(file);
boolean needDisposeEditor = false;
if (editor == null) {
editor = createTempFileEditor(file);
needDisposeEditor = true;
}
if (editor != null && editor.isValid()) {
final StructureViewBuilder structureViewBuilder = editor.getStructureViewBuilder();
if (structureViewBuilder != null) {
myStructureView = structureViewBuilder.createStructureView(editor, myProject);
myFileEditor = editor;
Disposer.register(this, myStructureView);
updateHeaderActions(myStructureView);
if (myStructureView instanceof StructureView.Scrollable) {
((StructureView.Scrollable) myStructureView).setReferenceSizeWhileInitializing(referenceSize);
}
if (myStructureView instanceof StructureViewComposite) {
final StructureViewComposite composite = (StructureViewComposite) myStructureView;
final StructureViewComposite.StructureViewDescriptor[] views = composite.getStructureViews();
myPanels = new JPanel[views.length];
names = new String[views.length];
for (int i = 0; i < myPanels.length; i++) {
myPanels[i] = createContentPanel(views[i].structureView.getComponent());
names[i] = views[i].title;
}
} else {
createSinglePanel(myStructureView.getComponent());
}
myStructureView.restoreState();
myStructureView.centerSelectedRow();
}
}
if (needDisposeEditor && editor != null) {
Disposer.dispose(editor);
}
}
}
if (myModuleStructureComponent == null && myStructureView == null) {
createSinglePanel(new JLabel(IdeBundle.message("message.nothing.to.show.in.structure.view"), SwingConstants.CENTER));
}
for (int i = 0; i < myPanels.length; i++) {
final Content content = ContentFactory.SERVICE.getInstance().createContent(myPanels[i], names[i], false);
contentManager.addContent(content);
if (i == 0 && myStructureView != null) {
Disposer.register(content, myStructureView);
}
}
if (myPendingSelection != null) {
Runnable selection = myPendingSelection;
myPendingSelection = null;
selection.run();
}
}
use of com.intellij.ide.structureView.impl.StructureViewComposite in project intellij-plugins by JetBrains.
the class HbStructureViewTest method testStructureView.
public void testStructureView(PsiFile file, Consumer<StructureViewComposite> consumer) {
final VirtualFile vFile = file.getVirtualFile();
final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile);
final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
assert builder != null;
StructureViewComposite composite = null;
try {
composite = (StructureViewComposite) builder.createStructureView(fileEditor, file.getProject());
consumer.consume(composite);
} finally {
if (composite != null)
Disposer.dispose(composite);
}
}
use of com.intellij.ide.structureView.impl.StructureViewComposite in project idea-handlebars by dmarcotte.
the class HbStructureViewTest method testStructureView.
public void testStructureView(PsiFile file, Consumer<StructureViewComposite> consumer) {
final VirtualFile vFile = file.getVirtualFile();
final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile);
final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
assert builder != null;
StructureViewComposite composite = null;
try {
composite = (StructureViewComposite) builder.createStructureView(fileEditor, file.getProject());
consumer.consume(composite);
} finally {
if (composite != null)
Disposer.dispose(composite);
}
}
Aggregations