use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.
the class AbstractPopup method installProjectDisposer.
private void installProjectDisposer() {
final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (c != null) {
final DataContext context = DataManager.getInstance().getDataContext(c);
final Project project = CommonDataKeys.PROJECT.getData(context);
if (project != null) {
myProjectDisposable = new Disposable() {
@Override
public void dispose() {
if (!AbstractPopup.this.isDisposed()) {
Disposer.dispose(AbstractPopup.this);
}
}
};
Disposer.register(project, myProjectDisposable);
}
}
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlPalettePanelTest method testCopy.
public void testCopy() throws Exception {
myPanel.requestFocus();
DataContext context = mock(DataContext.class);
CopyProvider provider = (CopyProvider) myPanel.getData(PlatformDataKeys.COPY_PROVIDER.getName());
assertThat(provider).isNotNull();
assertThat(provider.isCopyVisible(context)).isTrue();
assertThat(provider.isCopyEnabled(context)).isTrue();
provider.performCopy(context);
ArgumentCaptor<Transferable> captor = ArgumentCaptor.forClass(Transferable.class);
verify(myCopyPasteManager).setContents(captor.capture());
Transferable transferable = captor.getValue();
assertThat(transferable).isNotNull();
assertThat(transferable.isDataFlavorSupported(ItemTransferable.DESIGNER_FLAVOR)).isTrue();
Object item = transferable.getTransferData(ItemTransferable.DESIGNER_FLAVOR);
assertThat(item).isInstanceOf(DnDTransferItem.class);
DnDTransferItem dndItem = (DnDTransferItem) item;
assertThat(dndItem.getComponents().size()).isEqualTo(1);
DnDTransferComponent component = dndItem.getComponents().get(0);
assertThat(component.getRepresentation()).startsWith(("<TextView"));
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class ProjectsTest method testGetSelectedModules.
public void testGetSelectedModules() {
createAndAddGradleFacet(myModule);
DataContext dataContext = createMock(DataContext.class);
Module[] data = { myModule };
expect(dataContext.getData(LangDataKeys.MODULE_CONTEXT_ARRAY.getName())).andReturn(data);
replay(dataContext);
Module[] selectedModules = Projects.getModulesToBuildFromSelection(myProject, dataContext);
assertSame(data, selectedModules);
verify(dataContext);
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlComponentTreeTest method testPasteIsNotPossibleWhenMultipleComponentsAreSelected.
public void testPasteIsNotPossibleWhenMultipleComponentsAreSelected() {
copy(myTextView);
DataContext context = mock(DataContext.class);
myModel.getSelectionModel().toggle(myLinearLayout);
myModel.getSelectionModel().toggle(myAbsoluteLayout);
assertThat(myTree.isPasteEnabled(context)).isTrue();
assertThat(myTree.isPastePossible(context)).isFalse();
myTree.performPaste(context);
assertThat(toTree()).isEqualTo("<RelativeLayout> [expanded]\n" + " <LinearLayout> [expanded] [selected]\n" + " <Button>\n" + " <TextView>\n" + " <AbsoluteLayout> [selected]\n");
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlComponentTreeTest method testPasteAfterCut.
public void testPasteAfterCut() {
cut(myTextView);
DataContext context = mock(DataContext.class);
myModel.getSelectionModel().clear();
myModel.getSelectionModel().toggle(myButton);
assertThat(myTree.isPasteEnabled(context)).isTrue();
assertThat(myTree.isPastePossible(context)).isTrue();
myTree.performPaste(context);
assertThat(toTree()).isEqualTo("<RelativeLayout> [expanded]\n" + " <LinearLayout> [expanded]\n" + " <Button> [selected]\n" + " <TextView>\n" + " <AbsoluteLayout>\n");
}
Aggregations