mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pull NavigatableAdapter to upper level
This commit is contained in:
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package com.intellij.pom;
|
||||
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public interface Navigatable {
|
||||
/**
|
||||
* Open editor and select/navigate to the object there if possible.
|
||||
@@ -38,29 +34,4 @@ public interface Navigatable {
|
||||
* Source means some kind of editor
|
||||
*/
|
||||
boolean canNavigateToSource();
|
||||
|
||||
/**
|
||||
* Very often both methods <code>canNavigate</code> and <code>canNavigateToSource</code>
|
||||
* return <code>true</code>. This adapter class lets focus on navigation
|
||||
* routine only.
|
||||
*
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
abstract class Adapter implements Navigatable {
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canNavigateToSource() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void navigate(Project project, VirtualFile file, boolean requestFocus) {
|
||||
navigate(project, file, 0, requestFocus);
|
||||
}
|
||||
|
||||
public static void navigate(Project project, VirtualFile file, int offset, boolean requestFocus) {
|
||||
new OpenFileDescriptor(project, file, offset).navigate(requestFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.pom;
|
||||
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* Very often both methods <code>canNavigate</code> and <code>canNavigateToSource</code>
|
||||
* return <code>true</code>. This adapter class lets focus on navigation
|
||||
* routine only.
|
||||
*
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class NavigatableAdapter implements Navigatable {
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canNavigateToSource() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void navigate(Project project, VirtualFile file, boolean requestFocus) {
|
||||
navigate(project, file, 0, requestFocus);
|
||||
}
|
||||
|
||||
public static void navigate(Project project, VirtualFile file, int offset, boolean requestFocus) {
|
||||
new OpenFileDescriptor(project, file, offset).navigate(requestFocus);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.pom.NavigatableAdapter;
|
||||
import com.intellij.util.BeforeAfter;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -319,7 +319,7 @@ public class EditorHyperlinkSupport {
|
||||
int newIndex = ranges.isEmpty() ? -1 : i == ranges.size() ? 0 : (i + delta + ranges.size()) % ranges.size();
|
||||
final RangeHighlighter next = newIndex < ranges.size() && newIndex >= 0 ? ranges.get(newIndex) : null;
|
||||
if (next == null) return null;
|
||||
return new OccurenceNavigator.OccurenceInfo(new Navigatable.Adapter() {
|
||||
return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {
|
||||
public void navigate(final boolean requestFocus) {
|
||||
action.consume(next);
|
||||
linkFollowed(editor, ranges, next);
|
||||
|
||||
+2
-1
@@ -48,6 +48,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.pom.NavigatableAdapter;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
@@ -318,7 +319,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
}
|
||||
for (final ShelvedChange shelvedChange : shelvedChanges) {
|
||||
if (shelvedChange.getBeforePath() != null && ! FileStatus.ADDED.equals(shelvedChange.getFileStatus())) {
|
||||
final Navigatable.Adapter navigatable = new Navigatable.Adapter() {
|
||||
final NavigatableAdapter navigatable = new NavigatableAdapter() {
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
final VirtualFile vf = shelvedChange.getBeforeVFUnderProject(myProject);
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.pom.NavigatableAdapter;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
@@ -47,7 +48,7 @@ public class MavenNavigationUtil {
|
||||
public static Navigatable createNavigatableForPom(final Project project, final VirtualFile file) {
|
||||
if (file == null || !file.isValid()) return null;
|
||||
final PsiFile result = PsiManager.getInstance(project).findFile(file);
|
||||
return result == null ? null : new Navigatable.Adapter() {
|
||||
return result == null ? null : new NavigatableAdapter() {
|
||||
public void navigate(boolean requestFocus) {
|
||||
int offset = 0;
|
||||
if (result instanceof XmlFile) {
|
||||
@@ -69,7 +70,7 @@ public class MavenNavigationUtil {
|
||||
|
||||
@Nullable
|
||||
public static Navigatable createNavigatableForDependency(final Project project, final VirtualFile file, final MavenArtifact artifact) {
|
||||
return new Navigatable.Adapter() {
|
||||
return new NavigatableAdapter() {
|
||||
public void navigate(boolean requestFocus) {
|
||||
final PsiFile pom = PsiManager.getInstance(project).findFile(file);
|
||||
if (pom instanceof XmlFile) {
|
||||
|
||||
Reference in New Issue
Block a user