@NotNull public Property[] getChildren(final RadComponent component) { if (!(component instanceof RadContainer)) return Property.EMPTY_ARRAY; BorderType borderType = ((RadContainer)component).getBorderType(); if (borderType.equals(BorderType.EMPTY)) { return new Property[]{new MyTypeProperty(), new MySizeProperty(this), new MyTitleProperty(), new MyTitleIntEnumProperty(this, "title justification", true), new MyTitleIntEnumProperty(this, "title position", false), new MyTitleFontProperty(this), new MyBorderColorProperty(this, true)}; } else if (borderType.equals(BorderType.LINE)) { return new Property[]{new MyTypeProperty(), new MyBorderColorProperty(this, false), new MyTitleProperty(), new MyTitleIntEnumProperty(this, "title justification", true), new MyTitleIntEnumProperty(this, "title position", false), new MyTitleFontProperty(this), new MyBorderColorProperty(this, true)}; } return myChildren; }
public RadContainer(final ModuleProvider module, final Class aClass, final String id) { super(module, aClass, id); myComponents = new ArrayList<RadComponent>(); // By default container doesn't have any special border setBorderType(BorderType.NONE); myLayoutManager = createInitialLayoutManager(); if (myLayoutManager != null) { final LayoutManager layoutManager = myLayoutManager.createLayout(); if (layoutManager != null) { setLayout(layoutManager); } } }
public LwContainer(final String className){ super(className); myComponents = new ArrayList(); // By default container doesn't have any special border setBorderType(BorderType.NONE); myLayout = createInitialLayout(); }
/** * @see BorderType * * @exception IllegalArgumentException if <code>type</code> * is <code>null</code> */ public final void setBorderType(final BorderType type){ if(type==null){ throw new IllegalArgumentException("type cannot be null"); } myBorderType=type; }
/** * 'border' is required subtag */ protected final void readBorder(final Element element) { final Element borderElement = LwXmlReader.getRequiredChild(element, UIFormXmlConstants.ELEMENT_BORDER); setBorderType(BorderType.valueOf(LwXmlReader.getRequiredString(borderElement, UIFormXmlConstants.ATTRIBUTE_TYPE))); StringDescriptor descriptor = LwXmlReader.getStringDescriptor(borderElement, UIFormXmlConstants.ATTRIBUTE_TITLE, UIFormXmlConstants.ATTRIBUTE_TITLE_RESOURCE_BUNDLE, UIFormXmlConstants.ATTRIBUTE_TITLE_KEY); if (descriptor != null) { setBorderTitle(descriptor); } myBorderTitleJustification = LwXmlReader.getOptionalInt(borderElement, UIFormXmlConstants.ATTRIBUTE_TITLE_JUSTIFICATION, 0); myBorderTitlePosition = LwXmlReader.getOptionalInt(borderElement, UIFormXmlConstants.ATTRIBUTE_TITLE_POSITION, 0); Element fontElement = LwXmlReader.getChild(borderElement, UIFormXmlConstants.ELEMENT_FONT); if (fontElement != null) { myBorderTitleFont = LwXmlReader.getFontDescriptor(fontElement); } myBorderTitleColor = LwXmlReader.getOptionalColorDescriptor(LwXmlReader.getChild(borderElement, UIFormXmlConstants.ELEMENT_TITLE_COLOR)); myBorderColor = LwXmlReader.getOptionalColorDescriptor(LwXmlReader.getChild(borderElement, UIFormXmlConstants.ELEMENT_COLOR)); Element sizeElement = LwXmlReader.getChild(borderElement, UIFormXmlConstants.ELEMENT_SIZE); if (sizeElement != null) { try { myBorderSize = LwXmlReader.readInsets(sizeElement); } catch(Exception e) { myBorderSize = null; } } }
@NotNull @Override protected PropertyRenderer<BorderType> compute() { return new LabelPropertyRenderer<BorderType>() { protected void customize(@NotNull final BorderType value) { setText(value.getName()); } }; }
public BorderTypeEditor(){ myCbx.setModel(new DefaultComboBoxModel(BorderType.getAllTypes())); myCbx.setRenderer(new ListCellRendererWrapper<BorderType>() { @Override public void customize(JList list, BorderType value, int index, boolean selected, boolean hasFocus) { final BorderType type = value != null ? value : BorderType.NONE; setText(type.getName()); } }); }
/** * @throws java.lang.IllegalArgumentException * if <code>type</code> * is <code>null</code> * @see com.intellij.uiDesigner.shared.BorderType */ public final void setBorderType(@NotNull final BorderType type) { if (myBorderType == type) { return; } myBorderType = type; updateBorder(); }
private void importSnapshotBorder(final JComponent component) { Border border = component.getBorder(); if (border != null) { if (border instanceof TitledBorder) { TitledBorder titledBorder = (TitledBorder)border; setBorderTitle(StringDescriptor.create(titledBorder.getTitle())); setBorderTitleJustification(titledBorder.getTitleJustification()); setBorderTitlePosition(titledBorder.getTitlePosition()); final Font titleFont = titledBorder.getTitleFont(); setBorderTitleFont(new FontDescriptor(titleFont.getName(), titleFont.getStyle(), titleFont.getSize())); setBorderTitleColor(new ColorDescriptor(titledBorder.getTitleColor())); border = titledBorder.getBorder(); } if (border instanceof EtchedBorder) { setBorderType(BorderType.ETCHED); } else if (border instanceof BevelBorder) { BevelBorder bevelBorder = (BevelBorder)border; setBorderType(bevelBorder.getBevelType() == BevelBorder.RAISED ? BorderType.BEVEL_RAISED : BorderType.BEVEL_LOWERED); } else if (border instanceof EmptyBorder) { EmptyBorder emptyBorder = (EmptyBorder)border; setBorderType(BorderType.EMPTY); setBorderSize(emptyBorder.getBorderInsets()); } else if (border instanceof LineBorder) { LineBorder lineBorder = (LineBorder)border; setBorderType(BorderType.LINE); setBorderColor(new ColorDescriptor(lineBorder.getLineColor())); } } }
private void generateBorder(final LwContainer container, final GeneratorAdapter generator, final int componentLocal) { final BorderType borderType = container.getBorderType(); final StringDescriptor borderTitle = container.getBorderTitle(); final String borderFactoryMethodName = borderType.getBorderFactoryMethodName(); final boolean borderNone = borderType.equals(BorderType.NONE); if (!borderNone || borderTitle != null) { // object to invoke setBorder generator.loadLocal(componentLocal); if (!borderNone) { if (borderType.equals(BorderType.LINE)) { if (container.getBorderColor() == null) { Type colorType = Type.getType(Color.class); generator.getStatic(colorType, "black", colorType); } else { pushPropValue(generator, Color.class.getName(), container.getBorderColor()); } generator.invokeStatic(ourBorderFactoryType, new Method(borderFactoryMethodName, ourBorderType, new Type[] { Type.getType(Color.class) } )); } else if (borderType.equals(BorderType.EMPTY) && container.getBorderSize() != null) { Insets size = container.getBorderSize(); generator.push(size.top); generator.push(size.left); generator.push(size.bottom); generator.push(size.right); generator.invokeStatic(ourBorderFactoryType, new Method(borderFactoryMethodName, ourBorderType, new Type[] { Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE })); } else { generator.invokeStatic(ourBorderFactoryType, new Method(borderFactoryMethodName, ourBorderType, new Type[0])); } } else { generator.push((String) null); } pushBorderProperties(container, generator, borderTitle, componentLocal); Type borderFactoryType = ourBorderFactoryType; StringDescriptor borderFactoryValue = (StringDescriptor)container.getDelegeeClientProperties().get(ourBorderFactoryClientProperty); if (borderFactoryValue == null && borderTitle != null && Boolean.valueOf(System.getProperty("idea.is.internal")).booleanValue()) { borderFactoryValue = StringDescriptor.create("com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); container.getDelegeeClientProperties().put(ourBorderFactoryClientProperty, borderFactoryValue); } if (borderFactoryValue != null && borderFactoryValue.getValue().length() != 0) { borderFactoryType = typeFromClassName(borderFactoryValue.getValue()); } generator.invokeStatic(borderFactoryType, ourCreateTitledBorderMethod); // set border generator.invokeVirtual(Type.getType(JComponent.class), Method.getMethod("void setBorder(javax.swing.border.Border)")); } }
public BorderType getValue(final RadContainer component) { return component.getBorderType(); }
protected void setValueImpl(final RadContainer component, final BorderType value) throws Exception { }
@NotNull public PropertyRenderer<BorderType> getRenderer() { return myRenderer.getValue(); }
public PropertyEditor<BorderType> getEditor() { return null; }
@Override public boolean isModified(final RadContainer component) { return !component.getBorderType().equals(BorderType.NONE) || component.getBorderTitle() != null; }
@Override public void resetValue(RadContainer component) throws Exception { component.setBorderType(BorderType.NONE); component.setBorderTitle(null); }
protected void setValueImpl(final RadContainer component, final BorderType value) throws Exception { component.setBorderType(value); }
@Override public boolean isModified(final RadContainer component) { return !getValue(component).equals(BorderType.NONE); }
@Override public void resetValue(RadContainer component) throws Exception { setValueImpl(component, BorderType.NONE); }
public JComponent getComponent(final RadComponent ignored, final BorderType value, final InplaceContext inplaceContext){ myCbx.setSelectedItem(value); return myCbx; }
/** * Paints container border. For grids the method also paints vertical and * horizontal lines that indicate bounds of the rows and columns. * Method does nothing if the <code>component</code> is not an instance * of <code>RadContainer</code>. */ private static void paintComponentBoundsImpl(final GuiEditor editor, @NotNull final RadComponent component, final Graphics g) { if (!(component instanceof RadContainer) && !(component instanceof RadNestedForm) && !component.isDragBorder()) { return; } boolean highlightBoundaries = (getDesignTimeInsets(component) > 2); if (component instanceof RadContainer && !component.isDragBorder()) { RadContainer container = (RadContainer)component; if (!highlightBoundaries && (container.getBorderTitle() != null || container.getBorderType() != BorderType.NONE)) { return; } } final Point point = SwingUtilities.convertPoint( component.getDelegee(), 0, 0, editor.getRootContainer().getDelegee() ); g.translate(point.x, point.y); try { if (component.isDragBorder()) { Graphics2D g2d = (Graphics2D)g; g2d.setColor(LightColors.YELLOW); g2d.setStroke(new BasicStroke(2.0f)); g2d.translate(1, 1); } else if (highlightBoundaries) { g.setColor(HIGHLIGHTED_BOUNDARY_COLOR); } else if (component.isSelected()) { g.setColor(SELECTED_BOUNDARY_COLOR); } else { g.setColor(NON_SELECTED_BOUNDARY_COLOR); } g.drawRect(0, 0, component.getWidth() - 1, component.getHeight() - 1); if (component.isDragBorder()) { g.translate(-1, -1); } } finally { g.translate(-point.x, -point.y); } }
private void generateBorder(final LwContainer container, final String variable) { final BorderType borderType = container.getBorderType(); final StringDescriptor borderTitle = container.getBorderTitle(); final Insets borderSize = container.getBorderSize(); final String borderFactoryMethodName = borderType.getBorderFactoryMethodName(); final boolean borderNone = borderType.equals(BorderType.NONE); if (!borderNone || borderTitle != null) { startMethodCall(variable, "setBorder"); startStaticMethodCall(BorderFactory.class, "createTitledBorder"); if (!borderNone) { startStaticMethodCall(BorderFactory.class, borderFactoryMethodName); if (borderType.equals(BorderType.LINE)) { if (container.getBorderColor() == null) { pushVar("java.awt.Color.black"); } else { pushColor(container.getBorderColor()); } } else if (borderType.equals(BorderType.EMPTY) && borderSize != null) { push(borderSize.top); push(borderSize.left); push(borderSize.bottom); push(borderSize.right); } endMethod(); } else if (isCustomBorder(container)) { push((String) null); } push(borderTitle); if (isCustomBorder(container)) { push(container.getBorderTitleJustification(), ourTitleJustificationMap); push(container.getBorderTitlePosition(), ourTitlePositionMap); if (container.getBorderTitleFont() != null || container.getBorderTitleColor() != null) { if (container.getBorderTitleFont() == null) { push((String) null); } else { pushFont(variable, container.getBorderTitleFont(), "getFont"); } if (container.getBorderTitleColor() != null) { pushColor(container.getBorderTitleColor()); } } } endMethod(); // createTitledBorder endMethod(); // setBorder } }
/** * @return border's type. * @see com.intellij.uiDesigner.shared.BorderType */ @NotNull public final BorderType getBorderType() { return myBorderType; }