projects
/
lgpl
/
argeo-commons.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Massive Argeo APIs refactoring
[lgpl/argeo-commons.git]
/
org.argeo.cms.ui
/
src
/
org
/
argeo
/
cms
/
ui
/
widgets
/
StyledControl.java
diff --git
a/org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/StyledControl.java
b/org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/StyledControl.java
index 9d7037c25a9ef315427eb0e0624d474c17fc1f01..e3a5cb473d588fa47254ddb752773f04fda823d1 100644
(file)
--- a/
org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/StyledControl.java
+++ b/
org.argeo.cms.ui/src/org/argeo/cms/ui/widgets/StyledControl.java
@@
-1,10
+1,10
@@
package org.argeo.cms.ui.widgets;
import javax.jcr.Item;
package org.argeo.cms.ui.widgets;
import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-import org.argeo.cms.ui.CmsConstants;
-import org.argeo.cms.ui.util.CmsUiUtils;
+import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.cms.ui.CmsUiConstants;
+import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseListener;
@@
-12,7
+12,7
@@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/** Editable text part displaying styled text. */
import org.eclipse.swt.widgets.Control;
/** Editable text part displaying styled text. */
-public abstract class StyledControl extends JcrComposite implements CmsConstants {
+public abstract class StyledControl extends JcrComposite implements Cms
Ui
Constants {
private static final long serialVersionUID = -6372283442330912755L;
private Control control;
private static final long serialVersionUID = -6372283442330912755L;
private Control control;
@@
-24,9
+24,11
@@
public abstract class StyledControl extends JcrComposite implements CmsConstants
private Boolean editing = Boolean.FALSE;
private Boolean editing = Boolean.FALSE;
+ private Composite ancestorToLayout;
+
public StyledControl(Composite parent, int swtStyle) {
super(parent, swtStyle);
public StyledControl(Composite parent, int swtStyle) {
super(parent, swtStyle);
- setLayout(Cms
Ui
Utils.noSpaceGridLayout());
+ setLayout(Cms
Swt
Utils.noSpaceGridLayout());
}
public StyledControl(Composite parent, int style, Item item) {
}
public StyledControl(Composite parent, int style, Item item) {
@@
-39,14
+41,20
@@
public abstract class StyledControl extends JcrComposite implements CmsConstants
protected abstract Control createControl(Composite box, String style);
protected abstract Control createControl(Composite box, String style);
- protected Composite createBox(
Composite parent
) {
- Composite box = new Composite(
parent
, SWT.INHERIT_DEFAULT);
+ protected Composite createBox() {
+ Composite box = new Composite(
container
, SWT.INHERIT_DEFAULT);
setContainerLayoutData(box);
setContainerLayoutData(box);
- box.setLayout(CmsUiUtils.noSpaceGridLayout());
- // new Label(box, SWT.NONE).setText("BOX");
+ box.setLayout(CmsSwtUtils.noSpaceGridLayout(3));
return box;
}
return box;
}
+ protected Composite createContainer() {
+ Composite container = new Composite(this, SWT.INHERIT_DEFAULT);
+ setContainerLayoutData(container);
+ container.setLayout(CmsSwtUtils.noSpaceGridLayout());
+ return container;
+ }
+
public Control getControl() {
return control;
}
public Control getControl() {
return control;
}
@@
-59,10
+67,9
@@
public abstract class StyledControl extends JcrComposite implements CmsConstants
assert !isEditing();
editing = true;
// int height = control.getSize().y;
assert !isEditing();
editing = true;
// int height = control.getSize().y;
- String style = (String)
control.getData(STYLE
);
+ String style = (String)
EclipseUiSpecificUtils.getStyleData(control
);
clear(false);
clear(false);
- control = createControl(box, style);
- setControlLayoutData(control);
+ refreshControl(style);
// add the focus listener to the newly created edition control
if (focusListener != null)
// add the focus listener to the newly created edition control
if (focusListener != null)
@@
-72,45
+79,52
@@
public abstract class StyledControl extends JcrComposite implements CmsConstants
public synchronized void stopEditing() {
assert isEditing();
editing = false;
public synchronized void stopEditing() {
assert isEditing();
editing = false;
- String style = (String)
control.getData(STYLE
);
+ String style = (String)
EclipseUiSpecificUtils.getStyleData(control
);
clear(false);
clear(false);
+ refreshControl(style);
+ }
+
+ protected void refreshControl(String style) {
control = createControl(box, style);
setControlLayoutData(control);
control = createControl(box, style);
setControlLayoutData(control);
+ if (ancestorToLayout != null)
+ ancestorToLayout.layout(true, true);
+ else
+ getParent().layout(true, true);
}
public void setStyle(String style) {
Object currentStyle = null;
if (control != null)
}
public void setStyle(String style) {
Object currentStyle = null;
if (control != null)
- currentStyle =
control.getData(STYLE
);
+ currentStyle =
EclipseUiSpecificUtils.getStyleData(control
);
if (currentStyle != null && currentStyle.equals(style))
return;
if (currentStyle != null && currentStyle.equals(style))
return;
- // Integer preferredHeight = control != null ? control.getSize().y :
- // null;
clear(true);
clear(true);
- control = createControl(box, style);
- setControlLayoutData(control);
+ refreshControl(style);
- control.getParent().setData(STYLE, style + "_box");
- control.getParent().getParent().setData(STYLE, style + "_container");
+ if (style != null) {
+ CmsSwtUtils.style(box, style + "_box");
+ CmsSwtUtils.style(container, style + "_container");
+ }
}
/** To be overridden */
protected void setControlLayoutData(Control control) {
}
/** To be overridden */
protected void setControlLayoutData(Control control) {
- control.setLayoutData(Cms
Ui
Utils.fillWidth());
+ control.setLayoutData(Cms
Swt
Utils.fillWidth());
}
/** To be overridden */
protected void setContainerLayoutData(Composite composite) {
}
/** To be overridden */
protected void setContainerLayoutData(Composite composite) {
- composite.setLayoutData(Cms
Ui
Utils.fillWidth());
+ composite.setLayoutData(Cms
Swt
Utils.fillWidth());
}
protected void clear(boolean deep) {
if (deep) {
for (Control control : getChildren())
control.dispose();
}
protected void clear(boolean deep) {
if (deep) {
for (Control control : getChildren())
control.dispose();
- container = create
Box(this
);
- box = createBox(
container
);
+ container = create
Container(
);
+ box = createBox();
} else {
control.dispose();
}
} else {
control.dispose();
}
@@
-131,4
+145,9
@@
public abstract class StyledControl extends JcrComposite implements CmsConstants
if (control != null && this.focusListener != null)
control.addFocusListener(focusListener);
}
if (control != null && this.focusListener != null)
control.addFocusListener(focusListener);
}
+
+ public void setAncestorToLayout(Composite ancestorToLayout) {
+ this.ancestorToLayout = ancestorToLayout;
+ }
+
}
}