mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
such an awesome haul, part two
remove ~35 unused abstract classes
This commit is contained in:
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class VirtualFileCompileItem<OutputState> extends CompileItem<String, VirtualFilePersistentState, OutputState> {
|
||||
protected final VirtualFile myFile;
|
||||
|
||||
public VirtualFileCompileItem(@NotNull VirtualFile file) {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFilePersistentState computeSourceState() {
|
||||
return new VirtualFilePersistentState(myFile.getTimeStamp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSourceUpToDate(@NotNull VirtualFilePersistentState state) {
|
||||
return myFile.getTimeStamp() == state.getSourceTimestamp();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getKey() {
|
||||
return myFile.getUrl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.packaging.elements;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class PackagingFileFilter {
|
||||
|
||||
public abstract boolean accept(@NotNull VirtualFile virtualFile, @NotNull CompileContext context);
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.impl.PrioritizedTask;
|
||||
@@ -350,24 +349,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
|
||||
return myEditedNode != null ? null : super.createToolTip(e);
|
||||
}
|
||||
|
||||
protected abstract static class RefreshDebuggerTreeCommand extends SuspendContextCommandImpl {
|
||||
private final DebuggerContextImpl myDebuggerContext;
|
||||
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
|
||||
public RefreshDebuggerTreeCommand(DebuggerContextImpl context) {
|
||||
super(context.getSuspendContext());
|
||||
myDebuggerContext = context;
|
||||
}
|
||||
|
||||
public final DebuggerContextImpl getDebuggerContext() {
|
||||
return myDebuggerContext;
|
||||
}
|
||||
}
|
||||
|
||||
public DebuggerContextImpl getDebuggerContext() {
|
||||
return myDebuggerContext;
|
||||
}
|
||||
|
||||
-287
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries.versions;
|
||||
|
||||
import com.intellij.facet.frameworks.LibrariesDownloadAssistant;
|
||||
import com.intellij.facet.frameworks.beans.Artifact;
|
||||
import com.intellij.facet.ui.libraries.FacetLibrariesValidator;
|
||||
import com.intellij.facet.ui.libraries.FacetLibrariesValidatorDescription;
|
||||
import com.intellij.facet.ui.libraries.LibraryInfo;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.libraries.JarVersionDetectionUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class VersionsComponent {
|
||||
private JPanel myMainPanel;
|
||||
private static final String UNKNOWN_RI_NAME = "Unknown";
|
||||
|
||||
private final @NotNull Module myModule;
|
||||
private final FacetLibrariesValidator myValidator;
|
||||
|
||||
private final ButtonGroup myButtonGroup = new ButtonGroup();
|
||||
|
||||
private final Map<String, Pair<JRadioButton, JComboBox>> myButtons = new HashMap<>();
|
||||
|
||||
private Artifact myCurrentVersion = null;
|
||||
|
||||
public VersionsComponent(@NotNull final Module module, FacetLibrariesValidator validator) {
|
||||
myModule = module;
|
||||
myValidator = validator;
|
||||
}
|
||||
|
||||
public JPanel getJComponent() {
|
||||
if (myMainPanel == null) {
|
||||
init();
|
||||
}
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Artifact getCurrentVersion() {
|
||||
return myCurrentVersion;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
myMainPanel = new JPanel(new GridBagLayout());
|
||||
|
||||
Set<String> referenceImplementations = getRIs();
|
||||
|
||||
if (referenceImplementations.size() == 1) {
|
||||
String ri = referenceImplementations.iterator().next();
|
||||
addSingletonReferenceImplementationUI(ri);
|
||||
}
|
||||
else {
|
||||
for (String ri : referenceImplementations) {
|
||||
addMultipleReferenceImplementationUI(ri);
|
||||
|
||||
if (myCurrentVersion == null) {
|
||||
myCurrentVersion = getCurrentVersion(ri);
|
||||
}
|
||||
}
|
||||
|
||||
if (myCurrentVersion != null) {
|
||||
Pair<JRadioButton, JComboBox> currentPair = myButtons.get(myCurrentVersion.getName());
|
||||
if (currentPair != null) {
|
||||
currentPair.first.setSelected(true);
|
||||
currentPair.second.setSelectedItem(myCurrentVersion);
|
||||
for (Pair<JRadioButton, JComboBox> buttonsPair : myButtons.values()) {
|
||||
buttonsPair.second.setEnabled(buttonsPair == currentPair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getFacetDetectionClass(@NotNull String currentRI) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract Artifact[] getLibraries();
|
||||
|
||||
@Nullable
|
||||
private Artifact getCurrentVersion(@NotNull String currentRI) {
|
||||
String detectionClass = getFacetDetectionClass(currentRI);
|
||||
if (detectionClass != null) {
|
||||
final String version = JarVersionDetectionUtil.detectJarVersion(detectionClass, myModule);
|
||||
if (version != null) {
|
||||
Artifact approximatedVersion = null;
|
||||
for (Artifact info : getLibraries()) {
|
||||
if (version.equals(info.getVersion())) {
|
||||
return info;
|
||||
}
|
||||
if (version.contains(info.getVersion())) {
|
||||
approximatedVersion = info;
|
||||
}
|
||||
}
|
||||
return approximatedVersion;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Artifact> getSupportedVersions(@NotNull String ri) {
|
||||
List<Artifact> versions = new ArrayList<>();
|
||||
for (Artifact version : getLibraries()) {
|
||||
if (ri.equals(version.getName())) {
|
||||
versions.add(version);
|
||||
}
|
||||
}
|
||||
|
||||
return versions;
|
||||
}
|
||||
|
||||
private void addSingletonReferenceImplementationUI(@NotNull final String ri) {
|
||||
JComboBox comboBox = createComboBox(ri);
|
||||
addToPanel(new JLabel(ri), comboBox);
|
||||
Artifact version = getCurrentVersion(ri);
|
||||
if (version != null) {
|
||||
comboBox.setSelectedItem(version);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMultipleReferenceImplementationUI(@NotNull final String ri) {
|
||||
final JRadioButton radioButton = createRadioButton(ri);
|
||||
final JComboBox comboBox = createComboBox(ri);
|
||||
|
||||
comboBox.setEnabled(false);
|
||||
|
||||
addToPanel(radioButton, comboBox);
|
||||
|
||||
myButtons.put(ri, Pair.create(radioButton, comboBox));
|
||||
myButtonGroup.add(radioButton);
|
||||
}
|
||||
|
||||
private void addToPanel(@NotNull JComponent first, @NotNull JComponent second) {
|
||||
myMainPanel.add(first, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.LINE_START,
|
||||
GridBagConstraints.BOTH, JBUI.insets(2), 0, 0));
|
||||
myMainPanel.add(second,
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.LINE_END, GridBagConstraints.BOTH,
|
||||
JBUI.insets(2), 0, 0));
|
||||
}
|
||||
|
||||
private JRadioButton createRadioButton(final String ri) {
|
||||
final JRadioButton radioButton = new JRadioButton(ri);
|
||||
radioButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
for (Pair<JRadioButton, JComboBox> pair : myButtons.values()) {
|
||||
if (pair.getFirst().equals(radioButton)) {
|
||||
JComboBox comboBox = pair.second;
|
||||
comboBox.setEnabled(true);
|
||||
|
||||
Artifact currentVersion = getCurrentVersion(ri);
|
||||
if (currentVersion != null) {
|
||||
comboBox.setSelectedItem(currentVersion);
|
||||
}
|
||||
else {
|
||||
if (comboBox.getSelectedIndex() < 0) {
|
||||
comboBox.setSelectedItem(getAppropriateVersion(getSupportedVersions(ri)));
|
||||
}
|
||||
else {
|
||||
updateCurrentVersion(comboBox); // activate already selected
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
pair.second.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return radioButton;
|
||||
}
|
||||
|
||||
private JComboBox createComboBox(String ri) {
|
||||
final JComboBox comboBox = new JComboBox();
|
||||
|
||||
List<Artifact> versions = getSupportedVersions(ri);
|
||||
comboBox.setModel(new CollectionComboBoxModel(versions, null));
|
||||
|
||||
comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateCurrentVersion(comboBox);
|
||||
}
|
||||
});
|
||||
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
private void updateCurrentVersion(JComboBox comboBox) {
|
||||
final Artifact versionInfo = getSelectedVersion(comboBox);
|
||||
|
||||
if (versionInfo != null) {
|
||||
myCurrentVersion = versionInfo;
|
||||
myValidator.setDescription(getFacetLibrariesValidatorDescription(versionInfo));
|
||||
myValidator.setRequiredLibraries(getRequiredLibraries(versionInfo));
|
||||
}
|
||||
}
|
||||
|
||||
protected FacetLibrariesValidatorDescription getFacetLibrariesValidatorDescription(Artifact version) {
|
||||
return new FacetLibrariesValidatorDescription(version.getVersion()) {
|
||||
@Override
|
||||
@NonNls
|
||||
public String getDefaultLibraryName() {
|
||||
if (myCurrentVersion != null) {
|
||||
String ri = myCurrentVersion.getName();
|
||||
String version = myCurrentVersion.getVersion();
|
||||
|
||||
return StringUtil.isEmptyOrSpaces(ri) ? version : ri + "." + version;
|
||||
}
|
||||
|
||||
return super.getDefaultLibraryName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Artifact getAppropriateVersion(List<Artifact> versions) {
|
||||
return versions.size() > 0 ? versions.get(0) : null;
|
||||
}
|
||||
|
||||
private static LibraryInfo[] getRequiredLibraries(Artifact version) {
|
||||
final LibraryInfo[] infos = LibrariesDownloadAssistant.getLibraryInfos(version);
|
||||
|
||||
return infos == null ? LibraryInfo.EMPTY_ARRAY : infos;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Artifact getSelectedVersion(@NotNull JComboBox comboBox) {
|
||||
final Object version = comboBox.getModel().getSelectedItem();
|
||||
return version instanceof Artifact ? (Artifact)version : null;
|
||||
}
|
||||
|
||||
|
||||
public FacetLibrariesValidator getValidator() {
|
||||
return myValidator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Module getModule() {
|
||||
return myModule;
|
||||
}
|
||||
|
||||
public Set<String> getRIs() {
|
||||
Set<String> ris = new HashSet<>();
|
||||
for (Artifact version : getLibraries()) {
|
||||
String ri = version.getName();
|
||||
if (!StringUtil.isEmptyOrSpaces(ri)) {
|
||||
ris.add(ri);
|
||||
}
|
||||
else {
|
||||
ris.add(UNKNOWN_RI_NAME);
|
||||
}
|
||||
}
|
||||
return ris;
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.introduceParameter;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
|
||||
public abstract class VisibilityListener {
|
||||
private final Editor myEditor;
|
||||
private static final Logger LOG = Logger.getInstance(VisibilityListener.class);
|
||||
|
||||
protected VisibilityListener(Editor editor) {
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* to be performed in write action
|
||||
*/
|
||||
public void perform(final PsiVariable variable) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
final Document document = myEditor.getDocument();
|
||||
LOG.assertTrue(variable != null);
|
||||
final PsiModifierList modifierList = variable.getModifierList();
|
||||
LOG.assertTrue(modifierList != null);
|
||||
int textOffset = modifierList.getTextOffset();
|
||||
final String modifierListText = modifierList.getText();
|
||||
|
||||
int length = PsiModifier.PUBLIC.length();
|
||||
int idx = modifierListText.indexOf(PsiModifier.PUBLIC);
|
||||
|
||||
if (idx == -1) {
|
||||
idx = modifierListText.indexOf(PsiModifier.PROTECTED);
|
||||
length = PsiModifier.PROTECTED.length();
|
||||
}
|
||||
|
||||
if (idx == -1) {
|
||||
idx = modifierListText.indexOf(PsiModifier.PRIVATE);
|
||||
length = PsiModifier.PRIVATE.length();
|
||||
}
|
||||
|
||||
String visibility = getVisibility();
|
||||
if (visibility == PsiModifier.PACKAGE_LOCAL) {
|
||||
visibility = "";
|
||||
}
|
||||
|
||||
final boolean wasPackageLocal = idx == -1;
|
||||
final boolean isPackageLocal = visibility.isEmpty();
|
||||
|
||||
final int startOffset = textOffset + (wasPackageLocal ? 0 : idx);
|
||||
final int endOffset;
|
||||
if (wasPackageLocal) {
|
||||
endOffset = startOffset;
|
||||
}
|
||||
else {
|
||||
endOffset = textOffset + length + (isPackageLocal ? 1 : 0);
|
||||
}
|
||||
|
||||
final String finalVisibility = visibility + (wasPackageLocal ? " " : "");
|
||||
|
||||
Runnable runnable = () -> document.replaceString(startOffset, endOffset, finalVisibility);
|
||||
|
||||
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
|
||||
if (lookup != null) {
|
||||
lookup.performGuardedChange(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getVisibility();
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.remoteServer.impl.util;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
|
||||
import com.intellij.remoteServer.util.CloudMultiSourceServerRuntimeInstance;
|
||||
import com.intellij.remoteServer.util.CloudDeploymentNameConfiguration;
|
||||
import com.intellij.remoteServer.util.CloudDeploymentRuntime;
|
||||
import com.intellij.remoteServer.util.ServerRuntimeException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author michael.golubev
|
||||
*/
|
||||
public abstract class RepositoryArtifactDeploymentRuntimeProviderBase extends ArtifactDeploymentRuntimeProviderBase {
|
||||
|
||||
@Override
|
||||
protected CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
|
||||
File artifactFile,
|
||||
CloudMultiSourceServerRuntimeInstance serverRuntime,
|
||||
DeploymentTask<? extends CloudDeploymentNameConfiguration> deploymentTask,
|
||||
DeploymentLogManager logManager) throws ServerRuntimeException {
|
||||
RepositoryDeploymentConfiguration config = (RepositoryDeploymentConfiguration)deploymentTask.getConfiguration();
|
||||
|
||||
String repositoryPath = config.getRepositoryPath();
|
||||
File repositoryRootFile;
|
||||
if (StringUtil.isEmpty(repositoryPath)) {
|
||||
File repositoryParentFolder = new File(PathManager.getSystemPath(), "cloud-git-artifact-deploy");
|
||||
repositoryRootFile = FileUtil.findSequentNonexistentFile(repositoryParentFolder, artifactFile.getName(), "");
|
||||
}
|
||||
else {
|
||||
repositoryRootFile = new File(repositoryPath);
|
||||
}
|
||||
|
||||
if (!FileUtil.createDirectory(repositoryRootFile)) {
|
||||
throw new ServerRuntimeException("Unable to create deploy folder: " + repositoryRootFile);
|
||||
}
|
||||
config.setRepositoryPath(repositoryRootFile.getAbsolutePath());
|
||||
return doCreateDeploymentRuntime(artifactSource, artifactFile, serverRuntime, deploymentTask, logManager, repositoryRootFile);
|
||||
}
|
||||
|
||||
protected abstract CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
|
||||
File artifactFile,
|
||||
CloudMultiSourceServerRuntimeInstance serverRuntime,
|
||||
DeploymentTask<? extends CloudDeploymentNameConfiguration> deploymentTask,
|
||||
DeploymentLogManager logManager,
|
||||
File repositoryRootFile) throws ServerRuntimeException;
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.tasks.actions;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.DocumentListener;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SortedListModel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public abstract class SearchSupport<T extends Task> {
|
||||
|
||||
protected EditorTextField myTextField;
|
||||
protected JBPopup myCurrentPopup;
|
||||
protected JList myList = new JBList();
|
||||
protected boolean myCancelled;
|
||||
|
||||
private final ActionListener myCancelAction = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (myCurrentPopup != null) {
|
||||
myCancelled = true;
|
||||
hideCurrentPopup();
|
||||
}
|
||||
}
|
||||
};
|
||||
private T myResult;
|
||||
private final SortedListModel<T> myListModel;
|
||||
private boolean myAutoPopup;
|
||||
|
||||
public SearchSupport(EditorTextField textField) {
|
||||
|
||||
myTextField = textField;
|
||||
myTextField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void documentChanged(@NotNull DocumentEvent event) {
|
||||
onTextChanged();
|
||||
}
|
||||
});
|
||||
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(() -> myTextField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(final KeyEvent e) {
|
||||
processListSelection(e);
|
||||
}
|
||||
}));
|
||||
|
||||
myList.setVisibleRowCount(10);
|
||||
myListModel = new SortedListModel<>(null);
|
||||
myList.setModel(myListModel);
|
||||
}
|
||||
|
||||
public void setAutoPopup(boolean autoPopup) {
|
||||
myAutoPopup = autoPopup;
|
||||
}
|
||||
|
||||
public void setListRenderer(ListCellRenderer renderer) {
|
||||
myList.setCellRenderer(renderer);
|
||||
}
|
||||
|
||||
protected String getText() {
|
||||
return myTextField.getText();
|
||||
}
|
||||
|
||||
protected void onTextChanged() {
|
||||
if (myResult != null && !myResult.toString().equals(myTextField.getText())) {
|
||||
myResult = null;
|
||||
}
|
||||
if (myCancelled) {
|
||||
return;
|
||||
}
|
||||
if (isPopupShowing() || myAutoPopup) {
|
||||
showPopup(false);
|
||||
} else {
|
||||
hideCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract List<T> getItems(String text);
|
||||
|
||||
private void processListSelection(final KeyEvent e) {
|
||||
if (togglePopup(e)) return;
|
||||
|
||||
if (!isPopupShowing()) return;
|
||||
|
||||
final InputMap map = myTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
if (map != null) {
|
||||
final Object object = map.get(KeyStroke.getKeyStrokeForEvent(e));
|
||||
if (object instanceof Action) {
|
||||
final Action action = (Action)object;
|
||||
if (action.isEnabled()) {
|
||||
action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "action"));
|
||||
e.consume();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Object action = getAction(e, myList);
|
||||
|
||||
if ("selectNextRow".equals(action)) {
|
||||
if (ensureSelectionExists()) {
|
||||
ScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
}
|
||||
}
|
||||
else if ("selectPreviousRow".equals(action)) {
|
||||
ScrollingUtil.moveUp(myList, e.getModifiersEx());
|
||||
}
|
||||
else if ("scrollDown".equals(action)) {
|
||||
ScrollingUtil.movePageDown(myList);
|
||||
}
|
||||
else if ("scrollUp".equals(action)) {
|
||||
ScrollingUtil.movePageUp(myList);
|
||||
}
|
||||
else if ((e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB) && e.getModifiers() == 0) {
|
||||
hideCurrentPopup();
|
||||
e.consume();
|
||||
myCancelled = true;
|
||||
processChosenFromCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getResult() {
|
||||
|
||||
return myResult;
|
||||
}
|
||||
|
||||
private boolean togglePopup(KeyEvent e) {
|
||||
final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
|
||||
final Object action = ((InputMap)UIManager.get("ComboBox.ancestorInputMap")).get(stroke);
|
||||
if ("selectNext".equals(action)) {
|
||||
if (!isPopupShowing() && myAutoPopup) {
|
||||
showPopup(true);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ("togglePopup".equals(action)) {
|
||||
if (isPopupShowing()) {
|
||||
hideCurrentPopup();
|
||||
}
|
||||
else {
|
||||
showPopup(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
final Keymap active = KeymapManager.getInstance().getActiveKeymap();
|
||||
final String[] ids = active.getActionIds(stroke);
|
||||
if (ids.length > 0 && "CodeCompletion".equals(ids[0])) {
|
||||
showPopup(true);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showPopup(boolean explicit) {
|
||||
|
||||
myCancelled = false;
|
||||
|
||||
List<T> list = getItems(myTextField.getText());
|
||||
myListModel.clear();
|
||||
myListModel.addAll(list);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if (explicit) {
|
||||
showNoSuggestions();
|
||||
} else {
|
||||
hideCurrentPopup();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ensureSelectionExists();
|
||||
|
||||
myList.setPrototypeCellValue(null);
|
||||
if (isPopupShowing()) {
|
||||
adjustPopupSize();
|
||||
return;
|
||||
}
|
||||
|
||||
hideCurrentPopup();
|
||||
|
||||
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(myList);
|
||||
builder.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
public void beforeShown(@NotNull LightweightWindowEvent event) {
|
||||
myTextField
|
||||
.registerKeyboardAction(myCancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(@NotNull LightweightWindowEvent event) {
|
||||
myTextField.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
|
||||
}
|
||||
});
|
||||
myCurrentPopup =
|
||||
builder.setRequestFocus(false).setAutoSelectIfEmpty(false).setResizable(false).setCancelCallback(() -> {
|
||||
final int caret = myTextField.getCaretModel().getOffset();
|
||||
getEditor().getSelectionModel().setSelection(caret, caret);
|
||||
myTextField.setFocusTraversalKeysEnabled(true);
|
||||
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
|
||||
IdeFocusManager.getGlobalInstance().requestFocus(myTextField, true);
|
||||
}));
|
||||
return Boolean.TRUE;
|
||||
}).setItemChoosenCallback(() -> processChosenFromCompletion()).setCancelKeyEnabled(false).setAlpha(0.1f).setFocusOwners(new Component[]{myTextField}).
|
||||
createPopup();
|
||||
|
||||
adjustPopupSize();
|
||||
showPopup();
|
||||
}
|
||||
|
||||
private void adjustPopupSize() {
|
||||
Dimension size = myList.getPreferredSize();
|
||||
int cellHeight = myList.getCellRenderer().getListCellRendererComponent(myList, myList.getModel().getElementAt(0), 0, false, false)
|
||||
.getPreferredSize().height;
|
||||
int height = Math.min(size.height, Math.min(myList.getModel().getSize(), 12) * cellHeight) ;
|
||||
myCurrentPopup.setSize(new Dimension(size.width + 28, height + 12));
|
||||
}
|
||||
|
||||
private void showPopup() {
|
||||
Point point = getPopupLocation();
|
||||
if (myCurrentPopup.isVisible()) {
|
||||
myCurrentPopup.setLocation(point);
|
||||
} else {
|
||||
myCurrentPopup.showInScreenCoordinates(myTextField, point);
|
||||
}
|
||||
}
|
||||
|
||||
protected Point getPopupLocation() {
|
||||
VisualPosition visualPosition = getEditor().offsetToVisualPosition(getEditor().getCaretModel().getOffset());
|
||||
Point point = getEditor().visualPositionToXY(visualPosition);
|
||||
SwingUtilities.convertPointToScreen(point, getEditor().getComponent());
|
||||
point.y += 2;
|
||||
return point;
|
||||
}
|
||||
|
||||
private void showNoSuggestions() {
|
||||
hideCurrentPopup();
|
||||
final JComponent message = HintUtil.createErrorLabel(IdeBundle.message("file.chooser.completion.no.suggestions"));
|
||||
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(message, message);
|
||||
builder.setRequestFocus(false).setResizable(false).setAlpha(0.1f).
|
||||
setFocusOwners(new Component[] {myTextField});
|
||||
myCurrentPopup = builder.createPopup();
|
||||
showPopup();
|
||||
}
|
||||
|
||||
|
||||
private void processChosenFromCompletion() {
|
||||
//noinspection unchecked
|
||||
myResult = (T)myList.getSelectedValue();
|
||||
if (myResult != null) {
|
||||
onItemChosen(myResult);
|
||||
}
|
||||
hideCurrentPopup();
|
||||
}
|
||||
|
||||
protected void onItemChosen(T result) {
|
||||
myTextField.setText(result.getPresentableName());
|
||||
}
|
||||
|
||||
private void hideCurrentPopup() {
|
||||
if (myCurrentPopup != null) {
|
||||
myCurrentPopup.cancel();
|
||||
myCurrentPopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean ensureSelectionExists() {
|
||||
if (myList.getSelectedIndex() < 0 || myList.getSelectedIndex() >= myList.getModel().getSize()) {
|
||||
if (myList.getModel().getSize() >= 0) {
|
||||
myList.setSelectedIndex(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isPopupShowing() {
|
||||
return myCurrentPopup != null && myList != null && myList.isShowing();
|
||||
}
|
||||
|
||||
private static Object getAction(final KeyEvent e, final JComponent comp) {
|
||||
final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
|
||||
return comp.getInputMap().get(stroke);
|
||||
}
|
||||
|
||||
protected Editor getEditor() {
|
||||
Editor editor = myTextField.getEditor();
|
||||
assert editor != null;
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user