use of com.intellij.openapi.editor.HectorComponentPanel in project intellij-community by JetBrains.
the class HectorComponent method isModified.
private boolean isModified() {
final FileViewProvider viewProvider = myFile.getViewProvider();
for (Language language : mySliders.keySet()) {
JSlider slider = mySliders.get(language);
final PsiFile root = viewProvider.getPsi(language);
HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(myFile.getProject());
if (root != null && getValue(highlightingLevelManager.shouldHighlight(root), highlightingLevelManager.shouldInspect(root)) != slider.getValue()) {
return true;
}
}
for (HectorComponentPanel panel : myAdditionalPanels) {
if (panel.isModified()) {
return true;
}
}
return false;
}
use of com.intellij.openapi.editor.HectorComponentPanel in project intellij-community by JetBrains.
the class ImportPopupHectorComponentProvider method createConfigurable.
@Override
public HectorComponentPanel createConfigurable(@NotNull final PsiFile file) {
final Project project = file.getProject();
final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project);
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final VirtualFile virtualFile = file.getVirtualFile();
assert virtualFile != null;
final boolean notInLibrary = !fileIndex.isInLibrarySource(virtualFile) && !fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInContent(virtualFile);
return new HectorComponentPanel() {
private JCheckBox myImportPopupCheckBox = new JCheckBox(EditorBundle.message("hector.import.popup.checkbox"));
@Override
public JComponent createComponent() {
DialogUtil.registerMnemonic(myImportPopupCheckBox);
return myImportPopupCheckBox;
}
@Override
public boolean isModified() {
return myImportPopupCheckBox.isSelected() != analyzer.isImportHintsEnabled(file);
}
@Override
public void apply() throws ConfigurationException {
analyzer.setImportHintsEnabled(file, myImportPopupCheckBox.isSelected());
}
@Override
public void reset() {
myImportPopupCheckBox.setSelected(analyzer.isImportHintsEnabled(file));
myImportPopupCheckBox.setEnabled(analyzer.isAutohintsAvailable(file));
myImportPopupCheckBox.setVisible(notInLibrary);
}
@Override
public void disposeUIResources() {
myImportPopupCheckBox = null;
}
};
}
use of com.intellij.openapi.editor.HectorComponentPanel in project intellij-community by JetBrains.
the class HectorComponent method onClose.
private void onClose() {
if (isModified()) {
for (HectorComponentPanel panel : myAdditionalPanels) {
try {
panel.apply();
} catch (ConfigurationException e) {
//shouldn't be
}
}
forceDaemonRestart();
DaemonListeners.getInstance(myFile.getProject()).updateStatusBar();
}
}
use of com.intellij.openapi.editor.HectorComponentPanel in project intellij-community by JetBrains.
the class HectorComponent method showComponent.
public void showComponent(RelativePoint point) {
final JBPopup hector = JBPopupFactory.getInstance().createComponentPopupBuilder(this, this).setRequestFocus(true).setMovable(true).setCancelCallback(() -> {
for (HectorComponentPanel additionalPanel : myAdditionalPanels) {
if (!additionalPanel.canClose()) {
return Boolean.FALSE;
}
}
onClose();
return Boolean.TRUE;
}).createPopup();
Disposer.register(myFile.getProject(), new Disposable() {
@Override
public void dispose() {
final JBPopup oldHector = getOldHector();
if (oldHector != null && !oldHector.isDisposed()) {
Disposer.dispose(oldHector);
}
Disposer.dispose(hector);
}
});
final JBPopup oldHector = getOldHector();
if (oldHector != null) {
oldHector.cancel();
} else {
myHectorRef = new WeakReference<>(hector);
hector.show(point);
}
}
Aggregations