@Override public void processDrop(final GuiEditor editor, final RadComponent[] components, final GridConstraints[] constraintsToAdjust, final ComponentDragObject dragObject) { RadAbstractGridLayoutManager gridLayout = myContainer.getGridLayoutManager(); if (myContainer.getGridRowCount() == 0 && myContainer.getGridColumnCount() == 0) { gridLayout.insertGridCells(myContainer, 0, false, true, true); gridLayout.insertGridCells(myContainer, 0, true, true, true); } super.processDrop(editor, components, constraintsToAdjust, dragObject); Palette palette = Palette.getInstance(editor.getProject()); ComponentItem hSpacerItem = palette.getItem(HSpacer.class.getName()); ComponentItem vSpacerItem = palette.getItem(VSpacer.class.getName()); InsertComponentProcessor icp = new InsertComponentProcessor(editor); if (myXPart == 0) { insertSpacer(icp, hSpacerItem, GridInsertMode.ColumnAfter); } if (myXPart == 2) { insertSpacer(icp, hSpacerItem, GridInsertMode.ColumnBefore); } if (myYPart == 0) { insertSpacer(icp, vSpacerItem, GridInsertMode.RowAfter); } if (myYPart == 2) { insertSpacer(icp, vSpacerItem, GridInsertMode.RowBefore); } }
/** * Constructor for use in SnapShooter */ public RadVSpacer(final String id, final int row) { super(null, VSpacer.class, id); getConstraints().setRow(row); getConstraints().setVSizePolicy(GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW); getConstraints().setFill(GridConstraints.FILL_VERTICAL); }
private boolean checkAddDependencyOnInsert(final ComponentItem item) { if(item.getClassName().equals(HSpacer.class.getName()) || item.getClassName().equals(VSpacer.class.getName())) { // this is mostly required for IDEA developers, so that developers don't receive prompt to offer ui-designer-impl dependency return true; } PsiManager manager = PsiManager.getInstance(myEditor.getProject()); final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myEditor.getProject()); final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myEditor.getModule()); final PsiClass componentClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), projectScope); if(componentClass != null && JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), moduleScope) == null) { final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myEditor.getProject()).getFileIndex(); List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(componentClass.getContainingFile().getVirtualFile()); if(entries.size() > 0) { if(entries.get(0) instanceof ModuleSourceOrderEntry) { if(!checkAddModuleDependency(item, (ModuleSourceOrderEntry) entries.get(0))) { return false; } } else if(entries.get(0) instanceof LibraryOrderEntry) { if(!checkAddLibraryDependency(item, (LibraryOrderEntry) entries.get(0))) { return false; } } } } return true; }
public boolean isSpacer() { return myClassName.equals(HSpacer.class.getName()) || myClassName.equals(VSpacer.class.getName()); }
public RadComponent newInstance(ModuleProvider module, String className, String id) throws ClassNotFoundException { return new RadVSpacer(module, VSpacer.class, id); }
public RadVSpacer(final ModuleProvider module, final String id) { super(module, VSpacer.class, id); }