Search in sources :

Example 96 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.

the class NlComponentTreeTest method testPasteIntoLayoutAsFirstChild.

public void testPasteIntoLayoutAsFirstChild() {
    copy(myTextView);
    DataContext context = mock(DataContext.class);
    myModel.getSelectionModel().toggle(myLinearLayout);
    assertThat(myTree.isPasteEnabled(context)).isTrue();
    assertThat(myTree.isPastePossible(context)).isTrue();
    myTree.performPaste(context);
    assertThat(toTree()).isEqualTo("<RelativeLayout>  [expanded]\n" + "    <LinearLayout>  [expanded]  [selected]\n" + "        <TextView>\n" + "        <Button>\n" + "    <TextView>\n" + "    <AbsoluteLayout>\n");
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext)

Example 97 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.

the class NlComponentTreeTest method testDelete.

public void testDelete() {
    DataContext context = mock(DataContext.class);
    myModel.getSelectionModel().toggle(myTextView);
    assertThat(myTree.canDeleteElement(context)).isTrue();
    myTree.deleteElement(context);
    assertThat(CopyPasteManager.getInstance().getContents()).isNull();
    assertThat(toTree()).isEqualTo("<RelativeLayout>  [expanded]\n" + "    <LinearLayout>  [expanded]\n" + "        <Button>\n" + "    <AbsoluteLayout>\n");
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext)

Example 98 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.

the class NlComponentTreeTest method testCutRemovesComponents.

public void testCutRemovesComponents() {
    DataContext context = mock(DataContext.class);
    myModel.getSelectionModel().toggle(myTextView);
    assertThat(myTree.isCutVisible(context)).isTrue();
    assertThat(myTree.isCutEnabled(context)).isTrue();
    myTree.performCut(context);
    verify(myCopyPasteManager).setContents(notNull(Transferable.class));
    assertThat(toTree()).isEqualTo("<RelativeLayout>  [expanded]\n" + "    <LinearLayout>  [expanded]\n" + "        <Button>\n" + "    <AbsoluteLayout>\n");
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Transferable(java.awt.datatransfer.Transferable)

Example 99 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.

the class SdkUpdaterConfigurable method isModified.

@Override
public boolean isModified() {
    if (myPanel.isModified()) {
        return true;
    }
    // If the user modifies the channel, comes back here, and then applies the change, we want to be able to update
    // right away. Thus we mark ourselves as modified if UpdateSettingsConfigurable is modified, and then reload in
    // apply().
    DataContext dataContext = DataManager.getInstance().getDataContext(myPanel.getComponent());
    Settings data = Settings.KEY.getData(dataContext);
    if (data != null) {
        Configurable updatesConfigurable = data.find("preferences.updates");
        if (updatesConfigurable != null) {
            return updatesConfigurable.isModified();
        }
    }
    return false;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Settings(com.intellij.openapi.options.ex.Settings)

Example 100 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-plugins by JetBrains.

the class DartSelectWordTest method doTest.

private void doTest(@NotNull final String before, @NotNull final String... after) {
    myFixture.configureByText("file.dart", before);
    final DataContext dataContext = DataManager.getInstance().getDataContext(myFixture.getEditor().getComponent());
    final SelectWordHandler handler = new SelectWordHandler(null);
    for (String text : after) {
        handler.execute(myFixture.getEditor(), myFixture.getEditor().getCaretModel().getCurrentCaret(), dataContext);
        myFixture.checkResult(text);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) SelectWordHandler(com.intellij.codeInsight.editorActions.SelectWordHandler)

Aggregations

DataContext (com.intellij.openapi.actionSystem.DataContext)202 Project (com.intellij.openapi.project.Project)71 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 NotNull (org.jetbrains.annotations.NotNull)23 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)23 Editor (com.intellij.openapi.editor.Editor)21 Nullable (org.jetbrains.annotations.Nullable)21 FileEditor (com.intellij.openapi.fileEditor.FileEditor)20 PsiFile (com.intellij.psi.PsiFile)16 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)16 Module (com.intellij.openapi.module.Module)13 PsiElement (com.intellij.psi.PsiElement)13 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)11 DataManager (com.intellij.ide.DataManager)9 Presentation (com.intellij.openapi.actionSystem.Presentation)9 List (java.util.List)9 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)8 Consumer (com.intellij.util.Consumer)7 AnAction (com.intellij.openapi.actionSystem.AnAction)6 Transferable (java.awt.datatransfer.Transferable)6