import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.cms.CmsException;
-import org.argeo.cms.CmsStyles;
-import org.argeo.cms.CmsUiProvider;
+import org.argeo.cms.ui.CmsStyles;
+import org.argeo.cms.ui.CmsUiProvider;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
/** A link to an internal or external location. */
public class CmsLink implements CmsUiProvider {
private final static Log log = LogFactory.getLog(CmsLink.class);
- private BundleContext bundleContext ;
+ private BundleContext bundleContext;
private String label;
private String custom;
/** @return {@link Composite} with a single {@link Label} child. */
@Override
public Control createUi(final Composite parent, Node context) {
+ if (image != null && (imageWidth == null || imageHeight == null)) {
+ throw new CmsException("Image is not properly configured."
+ + " Make sure bundleContext property is set and init() method has been called.");
+ }
+
Composite comp = new Composite(parent, SWT.BOTTOM);
comp.setLayout(CmsUtils.noSpaceGridLayout());
Label link = new Label(comp, SWT.NONE);
link.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
- GridData layoutData = new GridData(SWT.CENTER, verticalAlignment, true,
- true);
+ GridData layoutData = new GridData(SWT.CENTER, verticalAlignment, true, true);
if (image != null) {
layoutData.heightHint = imageHeight;
if (label == null)
// label
StringBuilder labelText = new StringBuilder();
if (target != null) {
- labelText
- .append("<a style='color:inherit;text-decoration:inherit;' href=\"");
+ labelText.append("<a style='color:inherit;text-decoration:inherit;' href=\"");
// if (!isUrl)
// labelText.append('#');
labelText.append(target);
if (image != null) {
registerImageIfNeeded();
String imageLocation = RWT.getResourceManager().getLocation(image);
- labelText.append("<img width='").append(imageWidth)
- .append("' height='").append(imageHeight)
+ labelText.append("<img width='").append(imageWidth).append("' height='").append(imageHeight)
.append("' src=\"").append(imageLocation).append("\"/>");
// final Image img = loadImage(parent.getDisplay());
} else if ("center".equals(vAlign)) {
verticalAlignment = SWT.CENTER;
} else {
- throw new CmsException("Unsupported vertical allignment " + vAlign
- + " (must be: top, bottom or center)");
+ throw new CmsException("Unsupported vertical allignment " + vAlign + " (must be: top, bottom or center)");
}
}
}