use of com.android.tools.idea.uibuilder.model.SelectionModel in project android by JetBrains.
the class InteractionManagerTest method testDragAndDrop.
public void testDragAndDrop() throws Exception {
// Drops a fragment (xmlFragment below) into the design surface (via drag & drop events) and verifies that
// the resulting document ends up modified as expected.
@Language("XML") String source = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"0dp\"\n" + " android:orientation=\"vertical\">\n" + "\n" + "</LinearLayout>\n";
XmlFile xmlFile = (XmlFile) myFixture.addFileToProject("res/layout/layout.xml", source);
DesignSurface surface = createSurface();
NlModel model = createModel(surface, myFacet, xmlFile);
ScreenView screenView = createScreen(surface, model, new SelectionModel());
DesignSurface designSurface = screenView.getSurface();
InteractionManager manager = createManager(designSurface);
@Language("XML") String xmlFragment = "" + "<TextView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Hello World\"\n" + "/>";
Transferable transferable = createTransferable(DataFlavor.stringFlavor, xmlFragment);
dragDrop(manager, 0, 0, 100, 100, transferable);
Disposer.dispose(model);
@Language("XML") String expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"0dp\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " <TextView\n" + " android:id=\"@+id/textView\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Hello World\" />\n" + "</LinearLayout>\n";
assertEquals(expected, xmlFile.getText());
}
use of com.android.tools.idea.uibuilder.model.SelectionModel in project android by JetBrains.
the class GotoComponentAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView != null) {
SelectionModel selectionModel = screenView.getSelectionModel();
NlComponent primary = selectionModel.getPrimary();
if (primary != null) {
XmlTag tag = primary.getTag();
if (tag.isValid()) {
screenView.getSurface().deactivate();
PsiNavigateUtil.navigate(tag);
}
}
}
}
use of com.android.tools.idea.uibuilder.model.SelectionModel in project android by JetBrains.
the class DeleteAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView == null) {
return;
}
SelectionModel selectionModel = screenView.getSelectionModel();
NlModel model = screenView.getModel();
model.delete(selectionModel.getSelection());
}
use of com.android.tools.idea.uibuilder.model.SelectionModel in project android by JetBrains.
the class SelectAllAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView != null) {
SelectionModel selectionModel = screenView.getSelectionModel();
selectionModel.selectAll(screenView.getModel());
mySurface.repaint();
}
}
use of com.android.tools.idea.uibuilder.model.SelectionModel in project android by JetBrains.
the class SelectParentAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView != null) {
SelectionModel selectionModel = screenView.getSelectionModel();
List<NlComponent> selection = selectionModel.getSelection();
if (selection.size() == 1) {
NlComponent first = selection.get(0);
NlComponent parent = first.getParent();
if (parent != null) {
selectionModel.setSelection(Collections.singletonList(parent));
}
}
mySurface.repaint();
}
}
Aggregations