Skip to content

Commit

Permalink
removed unused packages
Browse files Browse the repository at this point in the history
  • Loading branch information
PioBeat committed Sep 8, 2017
1 parent b6a7f0b commit 9f9cade
Showing 1 changed file with 37 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
Expand All @@ -31,8 +28,6 @@

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -66,7 +61,7 @@ public class LanguageFileEditorGUI {
private JPanel topPanel;
private JPanel centerPanel;

public LanguageFileEditorGUI(GravLangFileEditor editor, TranslationTableModel model) {
LanguageFileEditorGUI(GravLangFileEditor editor, TranslationTableModel model) {
this.model = model;
this.languages = model.getLanguages();
this.editor = editor;
Expand Down Expand Up @@ -220,48 +215,46 @@ private JPopupMenu createPopupMenu() {
JMenuItem jumpToKey = new JMenuItem("Jump To Key");
jumpToKey.setIcon(AllIcons.General.Locate);
popupMenu.add(jumpToKey);
jumpToKey.addActionListener(e -> {
SwingUtilities.invokeLater(() -> {
final Project project = GravProjectComponent.getEnabledProject();
if (project == null) return;
String key = model.getKeys(true).get(basicPopupListener.rowAtPoint);
List<String> qualifiedKey = GravYAMLUtils.splitKeyAsList(key);
String lang = model.getLanguages()[basicPopupListener.colAtPoint - 1];
VirtualFile file;
switch (editor.getLanguageFileEditorType()) {
case LANGUAGE_FILE:
file = fileMap.elements().nextElement();
qualifiedKey.add(0, lang);
break;
case LANGUAGE_FOLDER:
file = fileMap.get(lang);
break;
default:
file = fileMap.get(lang);
break;
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null || ((YAMLFile) psiFile).getDocuments() == null) return;
YAMLDocument doc = ((YAMLFile) psiFile).getDocuments().get(0);
jumpToKey.addActionListener(e -> SwingUtilities.invokeLater(() -> {
final Project project = GravProjectComponent.getEnabledProject();
if (project == null) return;
String key = model.getKeys(true).get(basicPopupListener.rowAtPoint);
List<String> qualifiedKey = GravYAMLUtils.splitKeyAsList(key);
String lang = model.getLanguages()[basicPopupListener.colAtPoint - 1];
VirtualFile file;
switch (editor.getLanguageFileEditorType()) {
case LANGUAGE_FILE:
file = fileMap.elements().nextElement();
qualifiedKey.add(0, lang);
break;
case LANGUAGE_FOLDER:
file = fileMap.get(lang);
break;
default:
file = fileMap.get(lang);
break;
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null || ((YAMLFile) psiFile).getDocuments() == null) return;
YAMLDocument doc = ((YAMLFile) psiFile).getDocuments().get(0);

tabbedPane.setSelectedIndex(basicPopupListener.colAtPoint);
tabbedPane.setSelectedIndex(basicPopupListener.colAtPoint);

YAMLKeyValue value = YAMLUtil.getQualifiedKeyInDocument(doc, qualifiedKey);
if (value == null || value.getOriginalElement() == null) return;
PsiElement psiElement = value.getOriginalElement();
EventQueue.invokeLater(() -> {
editorMap.get(lang).getContentComponent().grabFocus();
editorMap.get(lang).getContentComponent().requestFocusInWindow();
});
YAMLKeyValue value = YAMLUtil.getQualifiedKeyInDocument(doc, qualifiedKey);
if (value == null || value.getOriginalElement() == null) return;
PsiElement psiElement = value.getOriginalElement();
EventQueue.invokeLater(() -> {
editorMap.get(lang).getContentComponent().grabFocus();
editorMap.get(lang).getContentComponent().requestFocusInWindow();
});

ScrollingModel scrollingModel = editorMap.get(lang).getScrollingModel();
CaretModel caretModel = editorMap.get(lang).getCaretModel();
caretModel.moveToOffset(psiElement.getTextOffset() + psiElement.getTextLength(), false);
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
caretModel.getCurrentCaret().setSelection(caretModel.getOffset(), caretModel.getOffset());
ScrollingModel scrollingModel = editorMap.get(lang).getScrollingModel();
CaretModel caretModel = editorMap.get(lang).getCaretModel();
caretModel.moveToOffset(psiElement.getTextOffset() + psiElement.getTextLength(), false);
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
caretModel.getCurrentCaret().setSelection(caretModel.getOffset(), caretModel.getOffset());

});
});
}));

basicPopupListener = new BasicPopupListener(table1, popupMenu, deleteItem, jumpToKey);
popupMenu.addPopupMenuListener(basicPopupListener);
Expand Down

0 comments on commit 9f9cade

Please sign in to comment.