本文整理汇总了Java中com.intellij.util.OpenSourceUtil类的典型用法代码示例。如果您正苦于以下问题:Java OpenSourceUtil类的具体用法?Java OpenSourceUtil怎么用?Java OpenSourceUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OpenSourceUtil类属于com.intellij.util包,在下文中一共展示了OpenSourceUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTreeMouseListeners
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
private void addTreeMouseListeners() {
EditSourceOnDoubleClickHandler.install(getTree(), new Runnable() {
@Override
public void run() {
TreePath path = getTree().getSelectionPath();
if (path == null)
return;
DefaultMutableTreeNode selectedElement = (DefaultMutableTreeNode)path.getLastPathComponent();
if (selectedElement == null)
return;
GlobalConfigsTreeStructure.GlobalConfigNode configNode = (GlobalConfigsTreeStructure.GlobalConfigNode)selectedElement.getUserObject();
if (configNode == null)
return;
PsiElement element = configNode.getXmlTag();
if (element == null)
return;
OpenSourceUtil.navigate((Navigatable)element);
}
});
CustomizationUtil.installPopupHandler(getTree(), IdeActions.GROUP_STRUCTURE_VIEW_POPUP, ActionPlaces.STRUCTURE_VIEW_POPUP);
}
示例2: addTreeKeyListener
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
private void addTreeKeyListener() {
getTree().addKeyListener(
new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
DataContext dataContext = DataManager.getInstance().getDataContext(getTree());
OpenSourceUtil.openSourcesFrom(dataContext, false);
}
else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
if (e.isConsumed())
{
return;
}
PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
boolean[] isCopied = new boolean[1];
if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
copyPasteManager.clear();
e.consume();
}
}
}
});
}
示例3: actionPerformed
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
if (navigatableArray != null && navigatableArray.length > 0) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
OpenSourceUtil.navigate(navigatableArray);
}
});
DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
if (dialog != null && dialog.isModal()) {
dialog.doCancelAction();
}
}
}
示例4: scrollToSource
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
protected void scrollToSource(final Component tree) {
DataContext dataContext=DataManager.getInstance().getDataContext(tree);
getReady(dataContext).doWhenDone(new Runnable() {
@Override
public void run() {
DataContext context = DataManager.getInstance().getDataContext(tree);
final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
if (vFile != null) {
// Attempt to navigate to the virtual file with unknown file type will show a modal dialog
// asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;
//IDEA-84881 Don't autoscroll to very large files
if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
}
Navigatable[] navigatables = CommonDataKeys.NAVIGATABLE_ARRAY.getData(context);
if (navigatables != null) {
if (navigatables.length > 1) {
return;
}
for (Navigatable navigatable : navigatables) {
// we are not going to open modal dialog during autoscrolling
if (!navigatable.canNavigateToSource()) return;
}
}
OpenSourceUtil.navigate(false, true, navigatables);
}
});
}
示例5: onSelected
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
@NotNull final TestResultsViewer viewer,
@NotNull final TestFrameworkRunningModel model) {
//TODO: tests o "onSelected"
SMRunnerUtil.runInEventDispatchThread(new Runnable() {
public void run() {
if (ScrollToTestSourceAction.isScrollEnabled(model)) {
final Navigatable descriptor = TestsUIUtil.getOpenFileDescriptor(selectedTestProxy, model);
if (descriptor != null) {
OpenSourceUtil.navigate(false, descriptor);
}
}
}
}, ModalityState.NON_MODAL);
}
示例6: actionPerformed
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
if (navigatableArray != null && navigatableArray.length > 0) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
OpenSourceUtil.navigate(navigatableArray);
}
});
DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
if (dialog != null && dialog.isModal()) {
dialog.doCancelAction();
}
}
}
示例7: initTree
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
private void initTree() {
myTree.setCellRenderer(new MyTreeCellRenderer());
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
UIUtil.setLineStyleAngled(myTree);
TreeUtil.installActions(myTree);
EditSourceOnDoubleClickHandler.install(myTree);
new TreeSpeedSearch(myTree);
myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
@Override
@NotNull
protected PsiElement[] getSelectedElements() {
return getSelectedPsiElements();
}
};
myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
for (ScopeTreeStructureExpander expander : extensions) {
myTree.addTreeWillExpandListener(expander);
}
if (extensions.length == 0) {
myTree.addTreeWillExpandListener(new SortingExpandListener());
}
myTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
final Object component = myTree.getLastSelectedPathComponent();
if (component instanceof DefaultMutableTreeNode) {
final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
if (selectedNode.isLeaf()) {
OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
}
}
}
}
});
}
示例8: doClickAction
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
if (set.size() == 1) {
final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
OpenSourceUtil.navigate(true, n);
} else {
final Define[] array = set.toArray(new Define[set.size()]);
NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function<Define, PsiElement>() {
@Override
public PsiElement fun(Define define) {
return define.getPsiElement();
}
}, PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
}
}
示例9: valueChanged
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getPath();
if (path == null) return;
TestProxy proxy = (TestProxy)tree.getSelectedTest();
if (proxy == null) return;
if (ScrollToTestSourceAction.isScrollEnabled(TestNGResults.this)) {
OpenSourceUtil.openSourcesFrom(tree, false);
}
}
示例10: scrollToSource
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
protected void scrollToSource(final Component tree) {
DataContext dataContext=DataManager.getInstance().getDataContext(tree);
getReady(dataContext).doWhenDone(new Runnable() {
@Override
public void run() {
DataContext context = DataManager.getInstance().getDataContext(tree);
final VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(context);
if (vFile != null) {
// Attempt to navigate to the virtual file with unknown file type will show a modal dialog
// asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;
//IDEA-84881 Don't autoscroll to very large files
if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
}
Navigatable[] navigatables = PlatformDataKeys.NAVIGATABLE_ARRAY.getData(context);
if (navigatables != null) {
if (navigatables.length > 1) {
return;
}
for (Navigatable navigatable : navigatables) {
// we are not going to open modal dialog during autoscrolling
if (!navigatable.canNavigateToSource()) return;
}
}
OpenSourceUtil.navigate(false, true, navigatables);
}
});
}
示例11: onSelected
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
@NotNull final TestResultsViewer viewer,
@NotNull final TestFrameworkRunningModel model) {
//TODO: tests o "onSelected"
SMRunnerUtil.runInEventDispatchThread(new Runnable() {
public void run() {
if (ScrollToTestSourceAction.isScrollEnabled(model)) {
OpenSourceUtil.openSourcesFrom(model.getTreeView(), false);
}
}
}, ModalityState.NON_MODAL);
}
示例12: actionPerformed
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Navigatable[] navigatableArray = e.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
if (navigatableArray != null && navigatableArray.length > 0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
OpenSourceUtil.navigate(navigatableArray);
}
});
myDialogWrapper.doCancelAction();
}
}
示例13: initTree
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
private void initTree() {
myTree.setCellRenderer(new MyTreeCellRenderer());
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
UIUtil.setLineStyleAngled(myTree);
TreeUtil.installActions(myTree);
EditSourceOnDoubleClickHandler.install(myTree);
new TreeSpeedSearch(myTree);
myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
@Override
@NotNull
protected PsiElement[] getSelectedElements() {
return getSelectedPsiElements();
}
};
myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
for (ScopeTreeStructureExpander expander : extensions) {
myTree.addTreeWillExpandListener(expander);
}
if (extensions.length == 0) {
myTree.addTreeWillExpandListener(new SortingExpandListener());
}
myTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
final Object component = myTree.getLastSelectedPathComponent();
if (component instanceof DefaultMutableTreeNode) {
final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
if (selectedNode.isLeaf()) {
OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
}
}
}
}
});
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
示例14: doClickAction
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
if (set.size() == 1) {
final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
OpenSourceUtil.navigate(true, n);
} else {
final Define[] array = set.toArray(new Define[set.size()]);
NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function<Define, PsiElement>() {
public PsiElement fun(Define define) {
return define.getPsiElement();
}
}, PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
}
}
示例15: scrollToSource
import com.intellij.util.OpenSourceUtil; //导入依赖的package包/类
protected void scrollToSource(final Component tree) {
DataContext dataContext=DataManager.getInstance().getDataContext(tree);
getReady(dataContext).doWhenDone(new Runnable() {
@Override
public void run() {
DataContext context = DataManager.getInstance().getDataContext(tree);
final VirtualFile vFile = context.getData(PlatformDataKeys.VIRTUAL_FILE);
if (vFile != null) {
// Attempt to navigate to the virtual file with unknown file type will show a modal dialog
// asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
if (vFile.getFileType() == UnknownFileType.INSTANCE || vFile.getFileType() instanceof INativeFileType) return;
//IDEA-84881 Don't autoscroll to very large files
if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
}
Navigatable[] navigatables = context.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
if (navigatables != null) {
if (navigatables.length > 1) {
return;
}
for (Navigatable navigatable : navigatables) {
// we are not going to open modal dialog during autoscrolling
if (!navigatable.canNavigateToSource()) return;
}
}
OpenSourceUtil.openSourcesFrom(context, false);
}
});
}