This commit is contained in:
Alexey Kudravtsev
2019-04-15 16:54:40 +03:00
parent c597bbb728
commit ad0a834185
12 changed files with 165 additions and 249 deletions
@@ -135,7 +135,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private RunnerContentUi myOriginal;
private final CopyOnWriteArraySet<Listener> myDockingListeners = new CopyOnWriteArraySet<>();
private final Set<RunnerContentUi> myChildren = new TreeSet<>((o1, o2) -> o1.myWindow - o2.myWindow);
private final Set<RunnerContentUi> myChildren = new TreeSet<>(Comparator.comparingInt(o -> o.myWindow));
private int myWindow;
private boolean myDisposing;
@@ -160,19 +160,19 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myWindow = window == 0 ? original.findFreeWindow() : window;
}
public void setTopActions(@NotNull final ActionGroup topActions, @NotNull String place) {
void setTopActions(@NotNull final ActionGroup topActions, @NotNull String place) {
myTopActions = topActions;
myActionsPlace = place;
rebuildCommonActions();
}
public void setTabPopupActions(ActionGroup tabPopupActions) {
void setTabPopupActions(ActionGroup tabPopupActions) {
myTabPopupActions = tabPopupActions;
rebuildTabPopup();
}
public void setAdditionalFocusActions(final ActionGroup group) {
void setAdditionalFocusActions(final ActionGroup group) {
myAdditionalFocusActions = group;
rebuildTabPopup();
}
@@ -187,14 +187,14 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myComponent.repaint();
}
public void setLeftToolbarVisible(boolean value) {
void setLeftToolbarVisible(boolean value) {
myToolbar.setVisible(value);
myComponent.revalidate();
myComponent.repaint();
}
public void setContentToolbarBefore(boolean value) {
void setContentToolbarBefore(boolean value) {
myContentToolbarBefore = value;
for (GridImpl each : getGrids()) {
each.setToolbarBefore(value);
@@ -204,7 +204,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
updateTabsUI(false);
}
public void initUi() {
private void initUi() {
if (myTabs != null) return;
myTabs = JBRunnerTabs.create(myProject, this);
@@ -216,7 +216,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
else if (ViewContext.CONTEXT_KEY.is(dataId)) {
return RunnerContentUi.this;
return this;
}
return null;
});
@@ -371,7 +371,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
public void processBounce(Content content, final boolean activate) {
void processBounce(Content content, final boolean activate) {
final GridImpl grid = getGridFor(content, false);
if (grid == null) return;
@@ -766,7 +766,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
public ActionGroup getSettingsActions() {
ActionGroup getSettingsActions() {
return (ActionGroup)myActionManager.getAction(SETTINGS);
}
@@ -898,7 +898,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
private boolean updateTabUI(TabInfo tab, Set<String> usedNames) {
private boolean updateTabUI(TabInfo tab, Set<? super String> usedNames) {
TabImpl t = getTabFor(tab);
if (t == null) {
return false;
@@ -915,7 +915,8 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
final String name = myLayoutSettings.getDefaultDisplayName(t.getDefaultIndex());
if (name != null && contents.size() > 1 && !usedNames.contains(name)) {
title = name;
} else {
}
else {
title = StringUtil.join(contents, (NotNullFunction<Content, String>)Content::getTabName, " | ");
}
}
@@ -1188,7 +1189,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
public ActionGroup getLayoutActions() {
ActionGroup getLayoutActions() {
return (ActionGroup)myActionManager.getAction(LAYOUT);
}
@@ -1200,11 +1201,11 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
.forEach(ActionToolbar::updateActionsImmediately);
}
public void setMinimizeActionEnabled(final boolean enabled) {
void setMinimizeActionEnabled(final boolean enabled) {
myMinimizeActionEnabled = enabled;
}
public void setMovetoGridActionEnabled(final boolean enabled) {
void setMovetoGridActionEnabled(final boolean enabled) {
myMoveToGridActionEnabled = enabled;
}
@@ -1222,19 +1223,14 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myAttractions.put(contentId, policy);
}
public void setConditionPolicy(final String condition, final LayoutAttractionPolicy policy) {
void setConditionPolicy(final String condition, final LayoutAttractionPolicy policy) {
myConditionAttractions.put(condition, policy);
}
private static LayoutAttractionPolicy getOrCreatePolicyFor(String key,
Map<String, LayoutAttractionPolicy> map,
LayoutAttractionPolicy defaultPolicy) {
LayoutAttractionPolicy policy = map.get(key);
if (policy == null) {
policy = defaultPolicy;
map.put(key, policy);
}
return policy;
return map.computeIfAbsent(key, __ -> defaultPolicy);
}
@Nullable
@@ -1263,7 +1259,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
public void setToDisposeRemovedContent(final boolean toDispose) {
void setToDisposeRemovedContent(final boolean toDispose) {
myToDisposeRemovedContent = toDispose;
}
@@ -1366,7 +1362,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
if (QuickActionProvider.KEY.is(dataId)) {
return RunnerContentUi.this;
}
else if (CloseAction.CloseTarget.KEY.is(dataId)) {
if (CloseAction.CloseTarget.KEY.is(dataId)) {
Content content = getContentManager().getSelectedContent();
if (content != null && content.getManager().canCloseContents() && content.isCloseable()) {
return (CloseAction.CloseTarget)() -> content.getManager().removeContent(content, true, true, true);
@@ -1435,7 +1431,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
@SuppressWarnings({"SSBasedInspection"})
@SuppressWarnings("SSBasedInspection")
// [kirillk] this is done later since "startup" attractions should be done gently, only if no explicit calls are done
private void attractOnStartup() {
final int currentCount = myAttractionCount;
@@ -1449,12 +1445,12 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
processAttraction(content.getUserData(ViewImpl.ID), myAttractions, new LayoutAttractionPolicy.Bounce(), afterInitialized, true);
}
public void attractByCondition(@NotNull String condition, boolean afterInitialized) {
void attractByCondition(@NotNull String condition, boolean afterInitialized) {
processAttraction(myLayoutSettings.getToFocus(condition), myConditionAttractions, myLayoutSettings.getAttractionPolicy(condition),
afterInitialized, true);
}
public void clearAttractionByCondition(String condition, boolean afterInitialized) {
void clearAttractionByCondition(String condition, boolean afterInitialized) {
processAttraction(myLayoutSettings.getToFocus(condition), myConditionAttractions, new LayoutAttractionPolicy.FocusOnce(),
afterInitialized, false);
}
@@ -1500,7 +1496,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return true;
}
public ContentUI getContentUI() {
ContentUI getContentUI() {
return this;
}
@@ -1562,7 +1558,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return myLayoutSettings.getStateFor(content);
}
public boolean isHorizontalToolbar() {
private boolean isHorizontalToolbar() {
return myLayoutSettings.isToolbarHorizontal();
}
@@ -1752,8 +1748,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
@Override
public void dragOutFinished(@NotNull MouseEvent event, TabInfo source) {
final Component component = event.getComponent();
final IdeFrame window = UIUtil.getParentOfType(IdeFrame.class, component);
mySession.process(event);
mySession = null;
}
@@ -1807,11 +1801,11 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return myPresentation;
}
public RunnerContentUi getRunnerUi() {
RunnerContentUi getRunnerUi() {
return RunnerContentUi.this;
}
public RunnerContentUi getOriginalRunnerUi() {
RunnerContentUi getOriginalRunnerUi() {
return myOriginal != null ? myOriginal : RunnerContentUi.this;
}
@@ -1829,13 +1823,13 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
void fireContentOpened(@NotNull Content content) {
private void fireContentOpened(@NotNull Content content) {
for (Listener each : myDockingListeners) {
each.contentAdded(content);
}
}
void fireContentClosed(Content content) {
private void fireContentClosed(Content content) {
for (Listener each : myDockingListeners) {
each.contentRemoved(content);
}
@@ -139,9 +139,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
@NotNull
private static String removeSlashes(String s) {
if (s.startsWith("/")) return removeSlashes(s.substring(1));
if (s.endsWith("/")) return removeSlashes(s.substring(0, s.length() - 1));
return s;
return StringUtil.trimLeading(StringUtil.trimTrailing(s, '/'), '/');
}
@Nullable
@@ -159,7 +157,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
return null;
}
private Iterable<PsiFileSystemItem> matchQualifiers(MinusculeMatcher qualifierMatcher, Iterable<PsiFileSystemItem> iterable) {
private Iterable<PsiFileSystemItem> matchQualifiers(MinusculeMatcher qualifierMatcher, Iterable<? extends PsiFileSystemItem> iterable) {
Map<PsiFileSystemItem, Integer> qualifierMatchingDegrees = new HashMap<>();
List<PsiFileSystemItem> matching = new ArrayList<>();
for (PsiFileSystemItem item : iterable) {
@@ -264,7 +262,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
/** Names placed into buckets where the index of bucket == {@link #findMatchStartingPosition} */
private final List<List<String>> candidateNames;
private int index = 0;
private int index;
NameGrouper(@NotNull String namePattern, @NotNull ProgressIndicator indicator) {
this.namePattern = namePattern;
@@ -347,7 +345,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
List<List<String>> groups = groupByMatchingDegree(!pattern.startsWith("*"), matchingNames);
for (List<String> group : groups) {
Iterable<PsiFileSystemItem> files = getFilesMatchingPath(pattern, everywhere, group, dirMatcher, indicator);
if (qualifierPattern.length() > 0) {
if (!qualifierPattern.isEmpty()) {
files = matchQualifiers(qualifierMatcher, files);
}
files = moveDirectoriesToEnd(files);
@@ -360,20 +358,17 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
}
}
if (!hasSuggestions.get() && !everywhere && hasSuggestionsOutsideProject(pattern, groups, dirMatcher)) {
// let the framework switch to searching outside project to display these well-matching suggestions
// instead of worse-matching ones in project (that are very expensive to calculate)
return false;
}
return true;
// let the framework switch to searching outside project to display these well-matching suggestions
// instead of worse-matching ones in project (that are very expensive to calculate)
return hasSuggestions.get() || everywhere || !hasSuggestionsOutsideProject(pattern, groups, dirMatcher);
}
private boolean hasSuggestionsOutsideProject(@NotNull String pattern,
List<List<String>> groups, DirectoryPathMatcher dirMatcher) {
List<? extends List<String>> groups, DirectoryPathMatcher dirMatcher) {
return ContainerUtil.exists(groups, group -> !getFilesMatchingPath(pattern, true, group, dirMatcher, indicator).isEmpty());
}
private List<List<String>> groupByMatchingDegree(boolean preferStartMatches, List<MatchResult> matchingNames) {
private List<List<String>> groupByMatchingDegree(boolean preferStartMatches, List<? extends MatchResult> matchingNames) {
Comparator<MatchResult> comparator = (mr1, mr2) -> {
boolean exactPrefix1 = StringUtil.startsWith(mr1.elementName, patternSuffix);
boolean exactPrefix2 = StringUtil.startsWith(mr2.elementName, patternSuffix);
@@ -388,7 +383,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
}
private static <T> List<List<T>> sortAndGroup(List<T> items, Comparator<T> comparator) {
private static <T> List<List<T>> sortAndGroup(List<T> items, Comparator<? super T> comparator) {
return StreamEx.of(items).sorted(comparator).groupRuns((n1, n2) -> comparator.compare(n1, n2) == 0).toList();
}
}
@@ -37,8 +37,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
@@ -61,7 +59,7 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
private final boolean myIsShowMembers;
private final boolean myIsShowLibraryContents;
private Tree myTree;
private T mySelectedClass = null;
private T mySelectedClass;
private BaseProjectTreeBuilder myBuilder;
private TabbedPaneWrapper myTabbedPane;
private ChooseByNamePanel myGotoByNamePanel;
@@ -112,12 +110,7 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
}
private Filter<T> allFilter() {
return new Filter<T>() {
@Override
public boolean isAccepted(T element) {
return true;
}
};
return __ -> true;
}
@Override
@@ -189,14 +182,7 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
}
}.installOn(myTree);
myTree.addTreeSelectionListener(
new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
handleSelectionChanged();
}
}
);
myTree.addTreeSelectionListener(__ -> handleSelectionChanged());
new TreeSpeedSearch(myTree);
@@ -295,9 +281,6 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
/**
* Makes sense only in case of not null base class.
*
* @param baseClass
* @return
*/
@Nullable
protected BaseClassInheritorsProvider<T> getInheritorsProvider(@NotNull T baseClass) {
@@ -454,7 +437,7 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
List<T> classes = myTreeClassChooserDialog.getClassesByName(
name, parameters.isSearchInLibraries(), patternName, myTreeClassChooserDialog.getScope()
);
if (classes.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;
if (classes.isEmpty()) return ArrayUtil.EMPTY_OBJECT_ARRAY;
if (classes.size() == 1) {
return isAccepted(classes.get(0)) ? ArrayUtil.toObjectArray(classes) : ArrayUtil.EMPTY_OBJECT_ARRAY;
}
@@ -503,11 +486,11 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
protected abstract String[] getNames();
protected Query<T> searchForInheritorsOfBaseClass() {
Query<T> searchForInheritorsOfBaseClass() {
return searchForInheritors(myBaseClass, myScope, true);
}
protected boolean isInheritorOfBaseClass(T aClass) {
boolean isInheritorOfBaseClass(T aClass) {
return isInheritor(aClass, myBaseClass, true);
}
}
@@ -536,7 +519,7 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
if (System.currentTimeMillis() - start > 500 && !ApplicationManager.getApplication().isUnitTestMode()) {
return false;
}
if ((getTreeClassChooserDialog().getFilter().isAccepted(aClass)) && aClass.getName() != null) {
if (getTreeClassChooserDialog().getFilter().isAccepted(aClass) && aClass.getName() != null) {
nameProcessor.process(aClass.getName());
}
return true;
@@ -555,12 +538,9 @@ public abstract class AbstractTreeClassChooserDialog<T extends PsiNamedElement>
if (myFastMode) {
return getTreeClassChooserDialog().getFilter().isAccepted(aClass);
}
else {
return (aClass == getTreeClassChooserDialog().getBaseClass() ||
myInheritorsProvider.isInheritorOfBaseClass(aClass)) &&
getTreeClassChooserDialog().getFilter().isAccepted(
aClass);
}
return (aClass == getTreeClassChooserDialog().getBaseClass() ||
myInheritorsProvider.isInheritorOfBaseClass(aClass)) &&
getTreeClassChooserDialog().getFilter().isAccepted(aClass);
}
}
@@ -15,7 +15,6 @@ import com.intellij.ide.actions.CopyReferenceAction;
import com.intellij.ide.actions.GotoFileAction;
import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder;
import com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
@@ -76,8 +75,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
@@ -86,8 +83,6 @@ import java.awt.event.*;
import java.util.List;
import java.util.*;
import static com.intellij.openapi.keymap.KeymapUtil.getActiveKeymapShortcuts;
public abstract class ChooseByNameBase implements ChooseByNameViewModel {
public static final String TEMPORARILY_FOCUSABLE_COMPONENT_KEY = "ChooseByNameBase.TemporarilyFocusableComponent";
@@ -95,13 +90,13 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
@Nullable protected final Project myProject;
protected final ChooseByNameModel myModel;
protected ChooseByNameItemProvider myProvider;
protected final String myInitialText;
final String myInitialText;
private boolean mySearchInAnyPlace;
protected Component myPreviouslyFocusedComponent;
Component myPreviouslyFocusedComponent;
private boolean myInitialized;
protected final JPanelProvider myTextFieldPanel = new JPanelProvider();// Located in the layered pane
final JPanelProvider myTextFieldPanel = new JPanelProvider();// Located in the layered pane
protected final MyTextField myTextField = new MyTextField();
private final CardLayout myCard = new CardLayout();
private final JPanel myCardContainer = new JPanel(myCard);
@@ -111,7 +106,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
*/
private JComponent myToolArea;
protected JScrollPane myListScrollPane; // Located in the layered pane
JScrollPane myListScrollPane; // Located in the layered pane
private final SmartPointerListModel<Object> myListModel = new SmartPointerListModel<>();
protected final JList<Object> myList = new JBList<>(myListModel);
private final List<Pair<String, Integer>> myHistory = ContainerUtil.newArrayList();
@@ -121,7 +116,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
protected final Alarm myAlarm = new Alarm();
private boolean myDisposedFlag = false;
private boolean myDisposedFlag;
private final String[][] myNames = new String[2][];
private volatile CalcElementsThread myCalcElementsThread;
@@ -135,16 +130,16 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
private final Alarm myHideAlarm = new Alarm();
private static final boolean myShowListAfterCompletionKeyStroke = false;
protected JBPopup myTextPopup;
JBPopup myTextPopup;
protected JBPopup myDropdownPopup;
private boolean myClosedByShiftEnter = false;
protected final int myInitialIndex;
private boolean myClosedByShiftEnter;
final int myInitialIndex;
private String myFindUsagesTitle;
private ShortcutSet myCheckBoxShortcut;
protected boolean myInitIsDone;
private boolean myInitIsDone;
static final boolean ourLoadNamesEachTime = FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping;
private boolean myAlwaysHasMore = false;
private boolean myAlwaysHasMore;
private Point myFocusPoint;
@Nullable SelectionSnapshot currentChosenInfo;
@@ -252,8 +247,8 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
public class JPanelProvider extends JPanel implements DataProvider, QuickSearchComponent {
private JBPopup myHint = null;
private boolean myFocusRequested = false;
private JBPopup myHint;
private boolean myFocusRequested;
JPanelProvider() {
}
@@ -284,15 +279,13 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
final List<Object> chosenElements = getChosenElements();
if (chosenElements != null) {
List<PsiElement> result = new ArrayList<>(chosenElements.size());
for (Object element : chosenElements) {
if (element instanceof PsiElement) {
result.add((PsiElement)element);
}
List<PsiElement> result = new ArrayList<>(chosenElements.size());
for (Object element : chosenElements) {
if (element instanceof PsiElement) {
result.add((PsiElement)element);
}
return PsiUtilCore.toPsiElementArray(result);
}
return PsiUtilCore.toPsiElementArray(result);
}
else if (PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.is(dataId)) {
return getBounds();
@@ -301,14 +294,14 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
@Override
public void registerHint(JBPopup h) {
public void registerHint(@NotNull JBPopup h) {
if (myHint != null && myHint.isVisible() && myHint != h) {
myHint.cancel();
}
myHint = h;
}
public boolean focusRequested() {
boolean focusRequested() {
boolean focusRequested = myFocusRequested;
myFocusRequested = false;
@@ -337,7 +330,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
return myHint;
}
public void updateHint(PsiElement element) {
void updateHint(PsiElement element) {
if (myHint == null || !myHint.isVisible()) return;
final PopupUpdateProcessor updateProcessor = myHint.getUserData(PopupUpdateProcessor.class);
if (updateProcessor != null) {
@@ -345,7 +338,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
}
public void repositionHint() {
void repositionHint() {
if (myHint == null || !myHint.isVisible()) return;
PopupPositionManager.positionPopupInBestPosition(myHint, null, null);
}
@@ -524,12 +517,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
});
}
myCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
rebuildList(false);
}
});
myCheckBox.addItemListener(__ -> rebuildList(false));
myCheckBox.setFocusable(false);
myTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@@ -593,12 +581,9 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
});
myTextField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent actionEvent) {
if (!getChosenElements().isEmpty()) {
doClose(true);
}
myTextField.addActionListener(__ -> {
if (!getChosenElements().isEmpty()) {
doClose(true);
}
});
@@ -640,20 +625,17 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
myList.setVisibleRowCount(16);
myList.setFont(editorFont);
myList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(@NotNull ListSelectionEvent e) {
if (checkDisposed()) {
return;
}
myList.addListSelectionListener(__ -> {
if (checkDisposed()) {
return;
}
chosenElementMightChange();
updateDocumentation();
chosenElementMightChange();
updateDocumentation();
List<Object> chosenElements = getChosenElements();
if (!chosenElements.isEmpty()) {
currentChosenInfo = new SelectionSnapshot(getTrimmedText(), new HashSet<>(chosenElements));
}
List<Object> chosenElements = getChosenElements();
if (!chosenElements.isEmpty()) {
currentChosenInfo = new SelectionSnapshot(getTrimmedText(), new HashSet<>(chosenElements));
}
});
@@ -694,7 +676,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
@NotNull
private static Set<KeyStroke> getShortcuts(@NotNull String actionId) {
Set<KeyStroke> result = new HashSet<>();
for (Shortcut shortcut : getActiveKeymapShortcuts(actionId).getShortcuts()) {
for (Shortcut shortcut : KeymapUtil.getActiveKeymapShortcuts(actionId).getShortcuts()) {
if (shortcut instanceof KeyboardShortcut) {
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
result.add(keyboardShortcut.getFirstKeyStroke());
@@ -754,7 +736,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
return false;
}
protected void cancelListUpdater() {
void cancelListUpdater() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (checkDisposed()) return;
@@ -859,12 +841,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
DaemonCodeAnalyzer.getInstance(myProject).disableUpdateByTimer(myTextPopup);
}
Disposer.register(myTextPopup, new Disposable() {
@Override
public void dispose() {
cancelListUpdater();
}
});
Disposer.register(myTextPopup, () -> cancelListUpdater());
IdeEventQueue.getInstance().getPopupManager().closeAllPopups(false);
myTextPopup.show(layeredPane);
}
@@ -887,10 +864,10 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
return layeredPane;
}
protected void rebuildList(SelectionPolicy pos,
final int delay,
@NotNull final ModalityState modalityState,
@Nullable final Runnable postRunnable) {
void rebuildList(SelectionPolicy pos,
final int delay,
@NotNull final ModalityState modalityState,
@Nullable final Runnable postRunnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!myInitialized) {
return;
@@ -948,15 +925,15 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
}
public void scheduleCalcElements(String text,
boolean checkboxState,
ModalityState modalityState,
SelectionPolicy policy,
Consumer<Set<?>> callback) {
void scheduleCalcElements(String text,
boolean checkboxState,
ModalityState modalityState,
SelectionPolicy policy,
Consumer<Set<?>> callback) {
new CalcElementsThread(text, checkboxState, callback, modalityState, policy).scheduleThread();
}
private boolean isShowListAfterCompletionKeyStroke() {
private static boolean isShowListAfterCompletionKeyStroke() {
return myShowListAfterCompletionKeyStroke;
}
@@ -1038,11 +1015,11 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
@NotNull
@NonNls
protected String statisticsContext() {
String statisticsContext() {
return "choose_by_name#" + myModel.getPromptText() + "#" + myCheckBox.isSelected() + "#" + getTrimmedText();
}
private void appendToModel(@NotNull List<ModelDiff.Cmd> commands, @NotNull SelectionPolicy selection) {
private void appendToModel(@NotNull List<? extends ModelDiff.Cmd> commands, @NotNull SelectionPolicy selection) {
for (ModelDiff.Cmd command : commands) {
command.apply();
}
@@ -1093,7 +1070,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
private final KeyStroke forwardStroke;
private final KeyStroke backStroke;
private boolean completionKeyStrokeHappened = false;
private boolean completionKeyStrokeHappened;
private MyTextField() {
super(40);
@@ -1124,7 +1101,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
@Nullable
private KeyStroke getShortcut(String actionCodeCompletion) {
final Shortcut[] shortcuts = getActiveKeymapShortcuts(actionCodeCompletion).getShortcuts();
final Shortcut[] shortcuts = KeymapUtil.getActiveKeymapShortcuts(actionCodeCompletion).getShortcuts();
for (final Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
return ((KeyboardShortcut)shortcut).getFirstKeyStroke();
@@ -1271,7 +1248,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
super.paintComponent(g);
}
public boolean isCompletionKeyStroke() {
boolean isCompletionKeyStroke() {
return completionKeyStrokeHappened;
}
}
@@ -1280,7 +1257,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
return myProvider;
}
protected void handlePaste(String str) {
private void handlePaste(String str) {
if (!myInitIsDone) return;
if (myModel instanceof GotoClassModel2 && isFileName(str)) {
//noinspection SSBasedInspection
@@ -1496,7 +1473,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
return isShowListForEmptyPattern() || isShowListAfterCompletionKeyStroke() && lastKeyStrokeIsCompletion();
}
protected boolean lastKeyStrokeIsCompletion() {
private boolean lastKeyStrokeIsCompletion() {
return myTextField.isCompletionKeyStroke();
}
@@ -1558,8 +1535,8 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
fillUsages(Arrays.asList(elements), usages, targets);
if (myListModel.contains(EXTRA_ELEM)) { //start searching for the rest
final boolean everywhere = myCheckBox.isSelected();
final Set<Object> collected = new LinkedHashSet<>();
hideHint();
final Set<Object> collected = new LinkedHashSet<>();
ProgressManager.getInstance().run(new Task.Modal(myProject, prefixPattern, true) {
private ChooseByNameBase.CalcElementsThread myCalcUsagesThread;
@Override
@@ -1611,8 +1588,8 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
private void fillUsages(Collection<Object> matchElementsArray,
Collection<Usage> usages,
List<PsiElement> targets) {
Collection<? super Usage> usages,
List<? super PsiElement> targets) {
for (Object o : matchElementsArray) {
if (o instanceof PsiElement) {
PsiElement element = (PsiElement)o;
@@ -1626,8 +1603,8 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel {
}
}
private void showUsageView(@NotNull List<PsiElement> targets,
@NotNull Collection<Usage> usages,
private void showUsageView(@NotNull List<? extends PsiElement> targets,
@NotNull Collection<? extends Usage> usages,
@NotNull UsageViewPresentation presentation) {
UsageTarget[] usageTargets = targets.isEmpty() ? UsageTarget.EMPTY_ARRAY :
PsiElement2UsageTargetAdapter.convert(PsiUtilCore.toPsiElementArray(targets));
@@ -18,8 +18,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -94,28 +92,13 @@ public abstract class ChooseByNameFilter<T> {
panel.add(myChooser);
JPanel buttons = new JPanel();
JButton all = new JButton("All");
all.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
myChooser.setAllElementsMarked(true);
}
});
all.addActionListener(__ -> myChooser.setAllElementsMarked(true));
buttons.add(all);
JButton none = new JButton("None");
none.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
myChooser.setAllElementsMarked(false);
}
});
none.addActionListener(__ -> myChooser.setAllElementsMarked(false));
buttons.add(none);
JButton invert = new JButton("Invert");
invert.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
myChooser.invertSelection();
}
});
invert.addActionListener(__ -> myChooser.invertSelection());
buttons.add(invert);
panel.add(buttons);
return panel;
@@ -126,7 +109,6 @@ public abstract class ChooseByNameFilter<T> {
*
*
* @param model a model to update
* @param filterConfiguration
* @return a created file chooser
*/
@NotNull
@@ -153,12 +135,9 @@ public abstract class ChooseByNameFilter<T> {
}
}
updateModel(model, chooser, true);
chooser.addElementsMarkListener(new ElementsChooser.ElementsMarkListener<T>() {
@Override
public void elementMarkChanged(final T element, final boolean isMarked) {
filterConfiguration.setVisible(element, isMarked);
updateModel(model, chooser, false);
}
chooser.addElementsMarkListener((ElementsChooser.ElementsMarkListener<T>)(element, isMarked) -> {
filterConfiguration.setVisible(element, isMarked);
updateModel(model, chooser, false);
});
return chooser;
}
@@ -26,7 +26,7 @@ import java.awt.*;
public class ChooseByNamePanel extends ChooseByNameBase implements Disposable {
private JPanel myPanel;
private boolean myCheckBoxVisible = false;
private final boolean myCheckBoxVisible;
public ChooseByNamePanel(Project project, ChooseByNameModel model, String initialText, boolean isCheckboxVisible, final PsiElement context){
super(project, model, initialText, context);
@@ -43,8 +43,8 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
public static final Key<ChooseByNamePopup> CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY = new Key<>("ChooseByNamePopup");
public static final Key<String> CURRENT_SEARCH_PATTERN = new Key<>("ChooseByNamePattern");
private Component myOldFocusOwner = null;
private boolean myShowListForEmptyPattern = false;
private Component myOldFocusOwner;
private boolean myShowListForEmptyPattern;
private final boolean myMayRequestCurrentWindow;
private final ChooseByNamePopup myOldPopup;
private ActionMap myActionMap;
@@ -455,7 +455,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
myRepaintQueue.queue(new Update(this) {
@Override
public void run() {
ChooseByNamePopup.this.repaintListImmediate();
repaintListImmediate();
}
});
}
@@ -39,7 +39,7 @@ public class GotoSymbolModel2 extends FilteringGotoByModel<Language> {
protected synchronized Collection<Language> getFilterItems() {
final Collection<Language> result = super.getFilterItems();
if (result == null) {
return result;
return null;
}
final Collection<Language> items = new HashSet<>(result);
items.add(Language.ANY);
@@ -19,8 +19,8 @@ import org.jetbrains.annotations.NotNull;
public class MatchResult {
public final String elementName;
final int matchingDegree;
final boolean startMatch;
private final int matchingDegree;
private final boolean startMatch;
public MatchResult(String elementName, int matchingDegree, boolean startMatch) {
this.elementName = elementName;
@@ -15,10 +15,9 @@ import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import org.jetbrains.annotations.NotNull;
import java.awt.Component;
import java.awt.Graphics2D;
import javax.swing.*;
import java.awt.*;
import java.util.IdentityHashMap;
import javax.swing.JComponent;
/**
* @author Sergey.Malenkov
@@ -30,7 +29,7 @@ abstract class SpotlightPainter extends AbstractPainter implements ComponentHigh
private final JComponent myTarget;
boolean myVisible;
SpotlightPainter(JComponent target, Disposable parent) {
SpotlightPainter(JComponent target, @NotNull Disposable parent) {
myQueue = new MergingUpdateQueue("SettingsSpotlight", 200, false, target, parent, target);
myGlassPanel = new GlassPanel(target);
myTarget = target;
@@ -31,10 +31,7 @@ import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.*;
import java.util.*;
public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEventQueue.EventDispatcher {
@@ -45,10 +42,10 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
private final DisposableWrapperList<EventListener> myMouseListeners = new DisposableWrapperList<>();
private final Set<EventListener> mySortedMouseListeners = new TreeSet<>((o1, o2) -> {
double weight1 = 0;
double weight2 = 0;
if (o1 instanceof Weighted) {
weight1 = ((Weighted)o1).getWeight();
}
double weight2 = 0;
if (o2 instanceof Weighted) {
weight2 = ((Weighted)o2).getWeight();
}
@@ -141,7 +138,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
if (eventWindow != SwingUtilities.getWindowAncestor(myRootPane)) {
return false;
}
int button1 = MouseEvent.BUTTON1_MASK | MouseEvent.BUTTON1_DOWN_MASK;
int button1 = InputEvent.BUTTON1_MASK | InputEvent.BUTTON1_DOWN_MASK;
final boolean pureMouse1Event = (me.getModifiersEx() | button1) == button1;
if (pureMouse1Event && me.getClickCount() <= 1 && !me.isPopupTrigger()) {
final Point point = SwingUtilities.convertPoint(meComponent, me.getPoint(), myRootPane.getContentPane());
@@ -159,13 +156,13 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
final MouseEvent mouseEvent = MouseEventAdapter.convert(me, target);
switch (me.getID()) {
case MouseEvent.MOUSE_PRESSED:
boolean consumed = false;
if (target.isFocusable()) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(target, true));
}
boolean consumed = false;
for (final MouseListener listener : listeners) {
final String className = listener.getClass().getName();
if (className.indexOf("BasicTreeUI$") >= 0 || className.indexOf("MacTreeUI$") >= 0) continue;
if (className.contains("BasicTreeUI$") || className.contains("MacTreeUI$")) continue;
fireMouseEvent(listener, mouseEvent);
if (mouseEvent.isConsumed()) {
consumed = true;
@@ -174,7 +171,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
}
if (!mouseEvent.isConsumed()) {
final AWTEventListener[] eventListeners = Toolkit.getDefaultToolkit().getAWTEventListeners(MouseEvent.MOUSE_EVENT_MASK);
final AWTEventListener[] eventListeners = Toolkit.getDefaultToolkit().getAWTEventListeners(AWTEvent.MOUSE_EVENT_MASK);
if (eventListeners != null && eventListeners.length > 0) {
for (final AWTEventListener eventListener : eventListeners) {
eventListener.eventDispatched(me);
@@ -201,7 +198,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
if (myPrevPressEvent != null && myPrevPressEvent.getComponent() == target) {
for (final MouseListener listener : listeners) {
final String className = listener.getClass().getName();
if (className.indexOf("BasicTreeUI$") >= 0 || className.indexOf("MacTreeUI$") >= 0) {
if (className.contains("BasicTreeUI$") || className.contains("MacTreeUI$")) {
fireMouseEvent(listener, myPrevPressEvent);
fireMouseEvent(listener, mouseEvent);
if (mouseEvent.isConsumed()) {
@@ -354,17 +351,14 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
}
}
private boolean canProcessCursorFor(Component target) {
if (target instanceof JMenuItem ||
target instanceof Divider ||
target instanceof JSeparator ||
(target instanceof JEditorPane && ((JEditorPane)target).getEditorKit() instanceof HTMLEditorKit)) {
return false;
}
return true;
private static boolean canProcessCursorFor(Component target) {
return !(target instanceof JMenuItem) &&
!(target instanceof Divider) &&
!(target instanceof JSeparator) &&
!(target instanceof JEditorPane && ((JEditorPane)target).getEditorKit() instanceof HTMLEditorKit);
}
private Component getCompWithCursor(Component c) {
private static Component getCompWithCursor(Component c) {
Component eachParentWithCursor = c;
while (eachParentWithCursor != null) {
if (eachParentWithCursor.isCursorSet()) return eachParentWithCursor;
@@ -30,7 +30,6 @@ import com.intellij.openapi.wm.IdeFrame;
import com.intellij.util.ImageLoader;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.JBUIScale;
import com.intellij.util.ui.JBUIScale.ScaleContext;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -66,7 +65,7 @@ final class PaintersHelper implements Painter.Listener {
myRootComponent = component;
}
public boolean hasPainters() {
boolean hasPainters() {
return !myPainters.isEmpty();
}
@@ -77,13 +76,13 @@ final class PaintersHelper implements Painter.Listener {
return false;
}
public void addPainter(@NotNull Painter painter, @Nullable Component component) {
void addPainter(@NotNull Painter painter, @Nullable Component component) {
myPainters.add(painter);
myPainter2Component.put(painter, component == null ? myRootComponent : component);
painter.addListener(this);
}
public void removePainter(@NotNull Painter painter) {
void removePainter(@NotNull Painter painter) {
painter.removeListener(this);
myPainters.remove(painter);
myPainter2Component.remove(painter);
@@ -121,7 +120,6 @@ final class PaintersHelper implements Painter.Listener {
Offsets computeOffsets(Graphics gg, @NotNull JComponent component) {
if (myPainters.isEmpty()) return null;
Offsets offsets = new Offsets();
int i = 0;
offsets.offsets = new int[myPainters.size() * 2];
// store current graphics transform
Graphics2D g = (Graphics2D)gg;
@@ -129,6 +127,7 @@ final class PaintersHelper implements Painter.Listener {
// calculate relative offsets for painters
Rectangle r = null;
Component prev = null;
int i = 0;
for (Painter painter : myPainters) {
if (!painter.needsRepaint()) continue;
@@ -162,7 +161,7 @@ final class PaintersHelper implements Painter.Listener {
}
}
public static void initWallpaperPainter(@NotNull String propertyName, @NotNull PaintersHelper painters) {
static void initWallpaperPainter(@NotNull String propertyName, @NotNull PaintersHelper painters) {
ImagePainter painter = (ImagePainter)newWallpaperPainter(propertyName, painters.myRootComponent);
painters.addPainter(painter, null);
}
@@ -228,8 +227,6 @@ final class PaintersHelper implements Painter.Listener {
IdeBackgroundUtil.Fill newFillType = StringUtil.parseEnum(parts.length > 2 ? parts[2].toUpperCase(Locale.ENGLISH) : "", SCALE, IdeBackgroundUtil.Fill.class);
IdeBackgroundUtil.Anchor newAnchor = StringUtil.parseEnum(parts.length > 3 ? parts[3].toUpperCase(Locale.ENGLISH) : "", CENTER, IdeBackgroundUtil.Anchor.class);
String flip = parts.length > 4 ? parts[4] : "none";
boolean flipH = "flipHV".equals(flip) || "flipH".equals(flip);
boolean flipV = "flipHV".equals(flip) || "flipV".equals(flip);
String filePath = parts[0];
if (StringUtil.isEmpty(filePath)) {
resetImage(propertyValue, null, newAlpha, newFillType, newAnchor);
@@ -241,6 +238,8 @@ final class PaintersHelper implements Painter.Listener {
? new File(filePath)
: new File(PathManager.getConfigPath(), filePath)).toURI().toURL();
ModalityState modalityState = ModalityState.stateForComponent(rootComponent);
boolean flipH = "flipHV".equals(flip) || "flipH".equals(flip);
boolean flipV = "flipHV".equals(flip) || "flipV".equals(flip);
ApplicationManager.getApplication().executeOnPooledThread(() -> {
BufferedImageFilter flipFilter = flipV || flipH ? flipFilter(flipV, flipH) : null;
Image m = ImageLoader.loadFromUrl(url, true, true, new ImageFilter[]{flipFilter}, ScaleContext.create());
@@ -254,11 +253,11 @@ final class PaintersHelper implements Painter.Listener {
};
}
public static AbstractPainter newImagePainter(@NotNull Image image,
@NotNull IdeBackgroundUtil.Fill fillType,
@NotNull IdeBackgroundUtil.Anchor anchor,
float alpha,
@NotNull Insets insets) {
static AbstractPainter newImagePainter(@NotNull Image image,
@NotNull IdeBackgroundUtil.Fill fillType,
@NotNull IdeBackgroundUtil.Anchor anchor,
float alpha,
@NotNull Insets insets) {
return new ImagePainter() {
@Override
public boolean needsRepaint() {
@@ -289,13 +288,13 @@ final class PaintersHelper implements Painter.Listener {
final Map<GraphicsConfiguration, Cached> cachedMap = ContainerUtil.newHashMap();
public void executePaint(@NotNull Graphics2D g,
@NotNull Component component,
@NotNull Image image,
@NotNull IdeBackgroundUtil.Fill fillType,
@NotNull IdeBackgroundUtil.Anchor anchor,
float alpha,
@NotNull Insets insets) {
void executePaint(@NotNull Graphics2D g,
@NotNull Component component,
@NotNull Image image,
@NotNull IdeBackgroundUtil.Fill fillType,
@NotNull IdeBackgroundUtil.Anchor anchor,
float alpha,
@NotNull Insets insets) {
int cw0 = component.getWidth();
int ch0 = component.getHeight();
Insets i = JBUI.insets(insets.top * ch0 / 100, insets.left * cw0 / 100, insets.bottom * ch0 / 100, insets.right * cw0 / 100);
@@ -369,13 +368,13 @@ final class PaintersHelper implements Painter.Listener {
gc.restore();
}
void calcSrcDst(Rectangle src,
Rectangle dst,
int w,
int h,
int cw,
int ch,
IdeBackgroundUtil.Fill fillType) {
static void calcSrcDst(Rectangle src,
Rectangle dst,
int w,
int h,
int cw,
int ch,
IdeBackgroundUtil.Fill fillType) {
if (fillType == SCALE) {
boolean useWidth = cw * h > ch * w;
int sw = useWidth ? w : cw * h / ch;
@@ -397,7 +396,7 @@ final class PaintersHelper implements Painter.Listener {
}
}
void alignRect(Rectangle r, int w, int h, IdeBackgroundUtil.Anchor anchor) {
static void alignRect(Rectangle r, int w, int h, IdeBackgroundUtil.Anchor anchor) {
if (anchor == TOP_CENTER ||
anchor == CENTER ||
anchor == BOTTOM_CENTER) {
@@ -447,8 +446,7 @@ final class PaintersHelper implements Painter.Listener {
@NotNull
private static VolatileImage createImage(@Nullable GraphicsConfiguration cfg, int w, int h) {
GraphicsConfiguration safe;
safe = cfg != null ? cfg : GraphicsEnvironment.getLocalGraphicsEnvironment()
GraphicsConfiguration safe = cfg != null ? cfg : GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage image;
try {