本文整理汇总了Java中com.intellij.openapi.actionSystem.DataConstants类的典型用法代码示例。如果您正苦于以下问题:Java DataConstants类的具体用法?Java DataConstants怎么用?Java DataConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataConstants类属于com.intellij.openapi.actionSystem包,在下文中一共展示了DataConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public void actionPerformed( AnActionEvent e ) {
Editor editor = ( Editor ) e.getDataContext().getData( "editor" );
SelectionModel selectionModel = editor.getSelectionModel();
if ( selectionModel != null ) {
String selectedText = selectionModel.getSelectedText();
if ( selectedText != null && selectedText.trim().length() > 0 ) {
Project project = ( Project ) e.getDataContext().getData( DataConstants.PROJECT );
String panelid = ( String ) project.getUserData( QuickNotes.KEY_PANELID );
QuickNotesPanel quickNotesPanel = QuickNotesManager.getInstance().getQuickNotesPanel( panelid );
if ( quickNotesPanel != null ) {
FileDocumentManager manager = FileDocumentManager.getInstance();
VirtualFile virtualFile = manager.getFile( editor.getDocument() );
quickNotesPanel.addNewNote( "[File: " + virtualFile.getPath() + "]\n" + selectedText );
}
}
}
}
示例2: runEnable
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
@Override
protected boolean runEnable(AnActionEvent anActionEvent) {
Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE);
if (o instanceof XmlFileImpl) {
parentFileName = ((XmlFileImpl) o).getVirtualFile().getParent().getName();
if (isPreference(parentFileName)) {
return true;
}
} else if (o instanceof PsiFile) {
parentFileName = ((PsiFile) o).getVirtualFile().getParent().getName();
if (isDataBase(parentFileName)) {
return true;
}
}
return false;
}
示例3: actionPerformed
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getProject();
if (project == null) return;
final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE);
if (file == null) {
RTFile[] rtFiles = RTFile.DATA_KEY.getData(e.getDataContext());
if (rtFiles == null || rtFiles.length == 0) {
System.out.println("No file for rt compile");
return;
}
// handle all files
for (RTFile rtFile : rtFiles) {
FileEditorManager.getInstance(project).openFile(rtFile.getController().getVirtualFile(), true, true);
}
} else {
VirtualFile vfs = file.getParent().findChild(RTMergerTreeStructureProvider.getJSControllerName(file));
if (vfs != null) {
FileEditorManager.getInstance(project).openFile(vfs, true, true);
}
}
}
示例4: actionPerformed
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) return;
final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE);
JscsProjectComponent component = project.getComponent(JscsProjectComponent.class);
// JscsConfigFileListener.start(collectedInfo.project);
// actualFile = ActualFile2.getOrCreateActualFile(JSCS_TEMP_FILE_KEY, file, collectedInfo.fileContent);
// if (actualFile == null || actualFile.getActualFile() == null) {
// return null;
// }
// File cwd = new File(project.getBasePath());
// if (actualFile instanceof ActualFile2.TempActualFile) {
// cwd = ((ActualFile2.TempActualFile) actualFile).getTempFile().file.getParentFile();
// }
// String relativeFile = actualFile.getActualFile().getName();
// File cwd = actualFile.getActualFile().getParentFile();
// String relativeFile = FileUtils.makeRelative(cwd, actualFile.getActualFile());
String rc = JscsExternalAnnotator.getRC(project, component.jscsRcFile);
LintResult result = JscsRunner.fix(project.getBasePath(), file.getPath(), component.nodeInterpreter, component.jscsExecutable, rc, component.preset, component.settings.esnext, component.settings.esprima);
file.refresh(true, false);
}
示例5: getAndroidFacetName
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
@Override
protected String getAndroidFacetName(AnActionEvent anActionEvent) {
Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE);
if (o instanceof XmlFileImpl) {
return ((XmlFileImpl) o).getVirtualFile().getParent().getParent().getName();
} else if (o instanceof PsiFile) {
return parentFileName = ((PsiFile) o).getVirtualFile().getParent().getParent().getName();
}
return super.getAndroidFacetName(anActionEvent);
}
示例6: runEnable
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
protected boolean runEnable(AnActionEvent anActionEvent) {
Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE);
if (o instanceof PsiFile) {
targetFilePath = ((PsiFile) o).getVirtualFile().getPath();
if (isDataBase(((PsiFile) o).getVirtualFile().getParent().getName())) {
if (isMacOs())
return true;
}
}
return false;
}
示例7: getFile
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
private static PsiFile getFile(final Editor editor ,
final DataContext context )
{
final Project project = (Project) context.getData(DataConstants.PROJECT);
final Document document = editor.getDocument();
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
final VirtualFile virtualFile = fileDocumentManager.getFile(document);
final PsiManager psiManager = PsiManager.getInstance(project);
return psiManager.findFile(virtualFile);
}
示例8: RearrangeIt
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public RearrangeIt(final DataContext dc)
{
this.dc = dc;
if (dc != null) {
this.project = (Project) dc.getData(DataConstants.PROJECT);
}
else this.project = null;
}
示例9: execute
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public final void execute(final Editor editor, final DataContext context)
{
if (editor == null)
{
return;
}
final Project project = (Project) context.getData(DataConstants.PROJECT);
logger.debug("project=" + project);
logger.debug("editor=" + editor);
final Document document = editor.getDocument();
final CaretModel caret = editor.getCaretModel();
int cursorOffset = caret.getOffset();
final PsiFile psiFile = getFile(editor, context);
if (!psiFile.getName().endsWith(".java"))
{
logger.debug("not a .java file -- skipping " + psiFile.getName());
return;
}
if (!RearrangerActionHandler.isFileWritable(psiFile))
{
logger.debug("not a writable .java file -- skipping " + psiFile.getName());
return;
}
logger.debug("inProgress=" + inProgress);
if (!useDialog)
{
if (inProgress)
{
return;
}
setInProgress(true);
}
buildLiveRearrangerData(project, document, psiFile, cursorOffset);
}
示例10: getFile
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
private static PsiFile getFile(final Editor editor,
final DataContext context)
{
final Project project = (Project) context.getData(DataConstants.PROJECT);
final Document document = editor.getDocument();
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
final VirtualFile virtualFile = fileDocumentManager.getFile(document);
final PsiManager psiManager = PsiManager.getInstance(project);
return psiManager.findFile(virtualFile);
}
示例11: execute
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public final void execute(final Editor editor, final DataContext context)
{
if (editor == null) {
return;
}
final Project project = (Project) context.getData(DataConstants.PROJECT);
logger.debug("project=" + project);
logger.debug("editor=" + editor);
final Document document = editor.getDocument();
final CaretModel caret = editor.getCaretModel();
int cursorOffset = caret.getOffset();
final PsiFile psiFile = getFile(editor, context);
if (!psiFile.getName().endsWith(".java")) {
logger.debug("not a .java file -- skipping " + psiFile.getName());
return;
}
if (!psiFile.isWritable()) {
logger.debug("not a writable .java file -- skipping " + psiFile.getName());
return;
}
logger.debug("inProgress=" + inProgress);
if (inProgress) {
return;
}
setInProgress(true);
buildLiveRearrangerData(project, document, psiFile, cursorOffset);
}
示例12: testJUnitPackage
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public void testJUnitPackage() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
final MapDataContext dataContext = new MapDataContext();
final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
dataContext.put(DataConstants.MODULE, module);
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
checkPackage(PACKAGE_NAME, configuration);
checkGeneretedName(configuration, PACKAGE_NAME + " in " + module.getName());
}
示例13: testJUnitDefaultPackage
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
public void testJUnitDefaultPackage() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
PsiPackage defaultPackage = psiPackage.getParentPackage();
final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
final MapDataContext dataContext = new MapDataContext();
dataContext.put(DataConstants.MODULE, module);
JUnitConfiguration configuration = createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
checkPackage("", configuration);
checkGeneretedName(configuration, "All in " + module.getName());
}
示例14: createDataContextFor
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
private DataContext createDataContextFor(final Editor editor) {
return new DataContext() {
@Override
public Object getData(String dataId) {
if (dataId.equals(DataConstants.EDITOR)) return editor;
if (dataId.equals(DataConstants.PROJECT)) return getProject();
return null;
}
};
}
示例15: update
import com.intellij.openapi.actionSystem.DataConstants; //导入依赖的package包/类
@Override
public void update(@NotNull AnActionEvent e) {
boolean enabled = false;
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
boolean rtEnabled = RTActionUtil.isRTEnabled(project);
if (project != null) {
final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE);
enabled = rtEnabled && (RTFileUtil.isRTFile(file) || BuildTemplateAction.isRtFileContext(e.getDataContext()));
// if (file != null) {
// e.getPresentation().setText("Switch to Code Behind file '" + file.getName() + '\'');
// }
}
e.getPresentation().setVisible(enabled);
}