Revert "Do not wrap border with TitledBorder if there is not title"

This reverts commit 44c2a03e5c.
This commit is contained in:
Alexander Zolotov
2014-04-25 15:25:49 +04:00
parent c25513919f
commit 9bc7805376
9 changed files with 36 additions and 217 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -852,20 +852,20 @@ public class AsmCodeGenerator {
else {
generator.push((String) null);
}
pushBorderProperties(container, generator, borderTitle, componentLocal);
if (borderTitle != null) {
pushBorderProperties(container, generator, borderTitle, componentLocal);
Type borderFactoryType = ourBorderFactoryType;
StringDescriptor borderFactoryValue = (StringDescriptor)container.getDelegeeClientProperties().get(ourBorderFactoryClientProperty);
if (borderFactoryValue == 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);
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),

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -776,9 +776,8 @@ public final class FormSourceCodeGenerator {
if (!borderNone || borderTitle != null) {
startMethodCall(variable, "setBorder");
if (borderTitle != null) {
startStaticMethodCall(BorderFactory.class, "createTitledBorder");
}
startStaticMethodCall(BorderFactory.class, "createTitledBorder");
if (!borderNone) {
startStaticMethodCall(BorderFactory.class, borderFactoryMethodName);
@@ -802,26 +801,26 @@ public final class FormSourceCodeGenerator {
push((String) null);
}
if (borderTitle != 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());
}
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(); // createTitledBorder
endMethod(); // setBorder
}
}

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="BindingTest">
<grid id="a78aa" binding="myRootComponent" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="167" y="123" width="36" height="52"/>
</constraints>
<properties/>
<border type="empty"/>
<children/>
</grid>
</form>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="BindingTest">
<grid id="a78aa" binding="myRootComponent" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="167" y="123" width="36" height="52"/>
</constraints>
<properties/>
<border type="none" title="BorderTitle"/>
<children/>
</grid>
</form>

View File

@@ -1,27 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import javax.swing.*;
public class BindingTest {
public JComponent myRootComponent;
public static JComponent myStaticField;
public final JComponent myFinalField = null;
public int myIntField;
public String myStringField;
public BindingTest() {
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import javax.swing.*;
public class BindingTest {
public JComponent myRootComponent;
public static JComponent myStaticField;
public final JComponent myFinalField = null;
public int myIntField;
public String myStringField;
public BindingTest() {
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
myRootComponent = new JPanel();
myRootComponent.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(4, 1, new java.awt.Insets(0, 0, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new java.awt.Insets(0, 0, 0, 0), -1, -1));
myRootComponent.add(panel1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.setBorder(javax.swing.BorderFactory.createEmptyBorder());
final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer();
myRootComponent.add(spacer1, new com.intellij.uiDesigner.core.GridConstraints(3, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_VERTICAL, 1, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new java.awt.Insets(0, 0, 0, 0), -1, -1));
myRootComponent.add(panel2, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEmptyBorder(), "BorderTitle"));
final JPanel panel3 = new JPanel();
panel3.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new java.awt.Insets(0, 0, 0, 0), -1, -1));
myRootComponent.add(panel3, new com.intellij.uiDesigner.core.GridConstraints(2, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel3.setBorder(javax.swing.BorderFactory.createTitledBorder("BorderTitle"));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return myRootComponent;
}
}

View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="BindingTest">
<grid id="91062" binding="myRootComponent" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="131" y="90" width="40" height="158"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="f7d8a" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="empty"/>
<children/>
</grid>
<vspacer id="e260d">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="45af7" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="empty" title="BorderTitle"/>
<children/>
</grid>
<grid id="a14db" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="BorderTitle"/>
<children/>
</grid>
</children>
</grid>
</form>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,6 @@ import junit.framework.TestCase;
import org.jetbrains.asm4.ClassWriter;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
@@ -333,19 +331,6 @@ public class AsmCodeGeneratorTest extends TestCase {
assertEquals("BorderTitle", border.getTitle());
assertTrue(border.getBorder().toString(), border.getBorder() instanceof EtchedBorder);
}
public void testBorderWithoutTitle() throws Exception {
JPanel panel = (JPanel) getInstrumentedRootComponent("TestBorderWithoutTitle.form", "BindingTest");
Border border = panel.getBorder();
assertTrue(border.toString(), border instanceof EmptyBorder);
}
public void testNoneBorderWithTitle() throws Exception {
JPanel panel = (JPanel) getInstrumentedRootComponent("TestNoneBorderWithTitle.form", "BindingTest");
assertTrue(panel.getBorder() instanceof TitledBorder);
TitledBorder border = (TitledBorder) panel.getBorder();
assertEquals("BorderTitle", border.getTitle());
}
public void testMnemonic() throws Exception {
JPanel panel = (JPanel) getInstrumentedRootComponent("TestMnemonics.form", "BindingTest");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,10 @@
package com.intellij.uiDesigner.make;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -56,10 +58,6 @@ public class FormSourceCodeGeneratorTest extends PsiTestCase {
public void testSimple() throws IOException {
doTest();
}
public void testBorders() throws IOException {
doTest();
}
public void testCustomCreateComponent() throws IOException {
doTest();