Fix DesktopTextArea rows behaviour with specified height #PL-6129

This commit is contained in:
Yuriy Artamonov 2015-10-08 10:05:38 +00:00
parent bd9edb6da3
commit 9f90d60bce
2 changed files with 36 additions and 8 deletions

View File

@ -14,9 +14,18 @@ import org.dom4j.Element;
*/
public class DesktopResizableTextArea extends DesktopTextArea implements ResizableTextArea {
protected boolean resizable = false;
protected boolean settingsEnabled = true;
@Override
public boolean isResizable() {
return false;
return resizable;
}
@Override
public void setResizable(boolean resizable) {
this.resizable = resizable;
//Do nothing, because desktop text area is not resizable
}
@Override
@ -29,11 +38,6 @@ public class DesktopResizableTextArea extends DesktopTextArea implements Resizab
//Do nothing, because desktop text area is not resizable
}
@Override
public void setResizable(boolean resizable) {
//Do nothing, because desktop text area is not resizable
}
@Override
public void addResizeListener(ResizeListener resizeListener) {
//Do nothing, because desktop text area is not resizable
@ -56,11 +60,12 @@ public class DesktopResizableTextArea extends DesktopTextArea implements Resizab
@Override
public boolean isSettingsEnabled() {
return false;
return settingsEnabled;
}
@Override
public void setSettingsEnabled(boolean settingsEnabled) {
this.settingsEnabled = settingsEnabled;
//Do nothing, because desktop text area is not resizable
}
}

View File

@ -25,6 +25,7 @@ import static javax.swing.KeyStroke.getKeyStroke;
public class DesktopTextArea extends DesktopAbstractTextField<JTextArea> implements TextArea {
protected JComponent composition;
protected int rows;
public DesktopTextArea() {
setRows(5);
@ -94,11 +95,13 @@ public class DesktopTextArea extends DesktopAbstractTextField<JTextArea> impleme
@Override
public int getRows() {
return impl.getRows();
return this.rows;
}
@Override
public void setRows(int rows) {
this.rows = 5;
impl.setRows(rows);
int minHeight = impl.getPreferredSize().height;
@ -111,6 +114,26 @@ public class DesktopTextArea extends DesktopAbstractTextField<JTextArea> impleme
composition.setMinimumSize(new Dimension(minWidth, minHeight));
}
@Override
public void setHeight(String height) {
super.setHeight(height);
if (getHeight() >= 0) {
impl.setRows(1);
} else {
impl.setRows(this.rows);
}
int minHeight = impl.getPreferredSize().height;
int minWidth = impl.getPreferredSize().width;
Insets insets = impl.getInsets();
minWidth += insets.left + insets.right;
minHeight += insets.bottom + insets.top;
composition.setMinimumSize(new Dimension(minWidth, minHeight));
}
@Override
public int getColumns() {
return impl.getColumns();