use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class TreeTransferHandler method createTransferable.
@Override
protected Transferable createTransferable(JComponent c) {
NlComponentTree tree = (NlComponentTree) c;
setDragImage(getDragImageOfSelection(tree));
NlModel model = tree.getDesignerModel();
if (model == null || model.getSelectionModel().isEmpty()) {
return null;
}
return model.getSelectionAsTransferable();
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class ConstraintsLayer method paint.
/**
* Base paint method. Draw the layer's background and call drawComponent() on the root component.
*
* @param gc The Graphics object to draw into
*/
@Override
public void paint(@NotNull Graphics2D gc) {
myScreenView.getSize(myScreenViewSize);
mySizeRectangle.setBounds(myScreenView.getX(), myScreenView.getY(), myScreenViewSize.width, myScreenViewSize.height);
Rectangle2D.intersect(mySizeRectangle, gc.getClipBounds(), mySizeRectangle);
if (mySizeRectangle.isEmpty()) {
return;
}
NlModel myModel = myScreenView.getModel();
if (!myShowOnHover && showOnSelection) {
return;
}
if (myModel.getComponents().size() == 0) {
return;
}
NlComponent component = myModel.getComponents().get(0);
component = component.getRoot();
// Draw the background
Graphics2D g = (Graphics2D) gc.create();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Draw the components
if (drawComponent(g, component, false)) {
Dimension size = myScreenView.getSize();
if (size.width != 0 && size.height != 0) {
myDesignSurface.repaint(myScreenView.getX(), myScreenView.getY(), size.width, size.height);
} else {
myDesignSurface.repaint();
}
}
g.dispose();
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class LayoutTestUtilities method createModel.
public static NlModel createModel(DesignSurface surface, AndroidFacet facet, XmlFile xmlFile) {
NlModel model = SyncNlModel.create(surface, xmlFile.getProject(), facet, xmlFile);
model.notifyModified(NlModel.ChangeType.UPDATE_HIERARCHY);
return model;
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class NlProperties method currentActivityIfFoundIsDerivedFromAppCompatActivity.
private static boolean currentActivityIfFoundIsDerivedFromAppCompatActivity(@NotNull List<NlComponent> components) {
assert !components.isEmpty();
NlModel model = components.get(0).getModel();
Configuration configuration = model.getConfiguration();
String activityClassName = configuration.getActivity();
if (activityClassName == null) {
// Assume we are since this is how the default activities are created.
return true;
}
if (activityClassName.startsWith(".")) {
MergedManifest manifest = MergedManifest.get(model.getModule());
String pkg = StringUtil.notNullize(manifest.getPackage());
activityClassName = pkg + activityClassName;
}
JavaPsiFacade facade = JavaPsiFacade.getInstance(model.getProject());
PsiClass activityClass = facade.findClass(activityClassName, model.getModule().getModuleScope());
while (activityClass != null && !CLASS_APP_COMPAT_ACTIVITY.equals(activityClass.getQualifiedName())) {
activityClass = activityClass.getSuperClass();
}
return activityClass != null;
}
use of com.android.tools.idea.uibuilder.model.NlModel in project android by JetBrains.
the class ViewEditorImpl method displayResourceInput.
@Nullable
@Override
public String displayResourceInput(@NotNull String title, @NotNull EnumSet<ResourceType> types) {
NlModel model = myScreen.getModel();
ChooseResourceDialog dialog = ChooseResourceDialog.builder().setModule(model.getModule()).setTypes(types).setConfiguration(model.getConfiguration()).build();
if (!title.isEmpty()) {
dialog.setTitle(title);
}
dialog.show();
if (dialog.isOK()) {
String resource = dialog.getResourceName();
if (resource != null && !resource.isEmpty()) {
return resource;
}
}
return null;
}
Aggregations