use of org.eclipse.swt.browser.Browser in project netxms by netxms.
the class BrowserView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
browser = new Browser(parent, SWT.NONE);
browser.addLocationListener(new LocationListener() {
@Override
public void changing(LocationEvent event) {
setPartName(String.format(Messages.get().BrowserView_PartName_Changing, event.location));
actionStop.setEnabled(true);
}
@Override
public void changed(LocationEvent event) {
setPartName(String.format(Messages.get().BrowserView_PartName_Changed, getTitle(browser.getText(), event.location)));
actionStop.setEnabled(false);
}
});
createActions();
contributeToActionBars();
}
use of org.eclipse.swt.browser.Browser in project rap by entirej.
the class EJRWTHtmlTableBlockRendererDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
Composite layoutBody;
if (mainScreenProperties.getDisplayFrame()) {
if (mainScreenProperties.getFrameTitle() != null && mainScreenProperties.getFrameTitle().length() > 0) {
layoutBody = new Group(parent, SWT.NONE);
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.BORDER);
}
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
layoutBody.setLayout(new FillLayout());
if (System.getProperty("os.name").toLowerCase().indexOf("win") > -1) {
Label label = new Label(layoutBody, SWT.NONE);
label.setText("HTML Table Block");
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
EJDevItemGroupDisplayProperties displayProperties = null;
if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
}
EJFrameworkExtensionProperties blockRendererProperties = mainScreenProperties.getBlockProperties().getBlockRendererProperties();
boolean addHeader = true;
StringBuilder header = new StringBuilder();
if (blockRendererProperties != null) {
addHeader = blockRendererProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true);
}
int cellPadding = blockDisplayProperties.getBlockRendererProperties().getIntProperty(CELL_PADDING_PROPERTY, 0);
String paddingStyle = null;
if (cellPadding > 0) {
String str = String.valueOf(cellPadding);
paddingStyle = String.format("padding: %spx %spx %spx %spx; ", str, str, str, str);
}
if (displayProperties != null) {
for (final EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
if (screenItem.isSpacerItem()) {
continue;
}
if (addHeader) {
String styleClass = "default_all";
EJFrameworkExtensionProperties rendererProperties = screenItem.getBlockItemDisplayProperties().getItemRendererProperties();
header.append("<th ");
String alignment = "left";
String alignmentProperty = rendererProperties.getStringProperty("ALIGNMENT");
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals("JUSTIFY")) {
alignment = "justify";
} else if (alignmentProperty.equals("RIGHT")) {
alignment = "right";
} else if (alignmentProperty.equals("CENTER")) {
alignment = "center";
}
}
String valueVA = blockDisplayProperties.getBlockRendererProperties().getStringProperty(HEADER_VA);
if (valueVA != null && valueVA.length() > 0) {
styleClass = valueVA;
valueVA = rendererProperties.getStringProperty(HEADER_VA);
if (valueVA != null && valueVA.length() > 0)
styleClass = valueVA;
}
header.append(String.format(" class=\"%s\" ", styleClass));
if (alignment != null) {
header.append(String.format(" align=\'%s\'", alignment));
}
if (paddingStyle != null) {
header.append(String.format(" style=\'%s\'", paddingStyle));
}
header.append("> ");
header.append(screenItem.getLabel());
header.append("</th>");
}
}
final Browser browser = new Browser(layoutBody, SWT.NONE);
StringBuilder builder = new StringBuilder();
{
builder.append("<html>");
builder.append(getStyleDef(blockDisplayProperties.getEntireJProperties()));
builder.append("<div id=\"table\" style=\"float:left;width:100%;height:100%; overflow:auto\">");
{
EJDevBlockDisplayProperties blockProperties = blockDisplayProperties;
int cellSpacing = blockProperties.getBlockRendererProperties().getIntProperty(CELL_SPACING_PROPERTY, 0);
builder.append("<table border=0 cellspacing=").append(cellSpacing).append(" width=\"100%\" >");
{
int charHeight = (Display.getDefault().getSystemFont()).getFontData()[0].getHeight();
;
String trDef = String.format("<tr style=\"height: %spx\">", String.valueOf(charHeight));
if (addHeader) {
builder.append(header.toString());
}
int lastRowSpan = 0;
String oddVA = "default_all";
String valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_ODD_VA);
if (valueVA != null && valueVA.length() > 0) {
oddVA = valueVA;
}
String evenVA = "default_all";
valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_EVEN_VA);
if (valueVA != null && valueVA.length() > 0) {
evenVA = valueVA;
}
int rowid = 0;
for (int k = 0; k < 4; k++) {
rowid++;
if (lastRowSpan > 1) {
for (int i = 1; i < lastRowSpan; i++) {
builder.append(trDef).append("</tr>");
}
lastRowSpan = 0;
}
builder.append(trDef);
for (final EJDevScreenItemDisplayProperties item : displayProperties.getAllItemDisplayProperties()) {
String styleClass = (rowid % 2) != 0 ? oddVA : evenVA;
String alignment = null;
float width = -1;
EJFrameworkExtensionProperties rendererProperties = ((EJDevMainScreenItemDisplayProperties) item).getBlockRendererRequiredProperties();
builder.append(String.format("<td class=\"%s\" ", styleClass));
if (paddingStyle != null) {
builder.append(String.format(" style=\'%s\'", paddingStyle));
}
if (width == -1) {
width = rendererProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
}
if (width > 0) {
Font font = browser.getFont();
if (font != null) {
float avgCharWidth = getAvgCharWidth(font);
if (avgCharWidth > 0) {
if (width != 1) {
// add +1 padding
width = ((int) (((width + 1) * avgCharWidth)));
}
}
}
builder.append(String.format(" width=%s ", width));
}
if (alignment == null) {
String alignmentProperty = item.getBlockItemDisplayProperties().getItemRendererProperties().getStringProperty("ALIGNMENT");
alignment = "left";
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals("JUSTIFY")) {
alignment = "justify";
} else if (alignmentProperty.equals("RIGHT")) {
alignment = "right";
} else if (alignmentProperty.equals("CENTER")) {
alignment = "center";
}
}
}
if (alignment != null) {
builder.append(String.format(" align=\'%s\'", alignment));
}
builder.append(">");
// builder.append(String.format("<p class=\"default %s\">",
// styleClass));
String text = item.getReferencedItemName();
builder.append(text);
builder.append("</td>");
}
builder.append("</tr>");
}
}
builder.append("</table>");
}
builder.append("</<div>");
builder.append("</html>");
}
browser.setText(builder.toString());
}
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
use of org.eclipse.swt.browser.Browser in project core by jcryptool.
the class BrowserView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 2;
parent.setLayout(gridLayout);
controls = new Controls(parent, SWT.NONE, this);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.heightHint = 28;
controls.setLayoutData(gridData);
browser = new Browser(parent, SWT.NONE);
browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
browser.setUrl(BROWSER_HOME);
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
history.put(browser.getUrl(), browser.getUrl());
controls.getUrlField().setItems(history.values().toArray(new String[0]));
controls.getUrlField().setText(browser.getUrl());
controls.getBackButton().setEnabled(browser.isBackEnabled());
controls.getForwardButton().setEnabled(browser.isForwardEnabled());
controls.animateReloadButton(false);
}
public void changing(LocationEvent event) {
controls.animateReloadButton(true);
}
});
browser.addStatusTextListener(new StatusTextListener() {
public void changed(StatusTextEvent event) {
status.setText(event.text);
}
});
status = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);
status.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, // $NON-NLS-1$
"org.jcryptool.webbrowser.webBrowserView");
}
use of org.eclipse.swt.browser.Browser in project mdw-designer by CenturyLinkCloud.
the class PropertyEditor method createBrowser.
private Composite createBrowser(Composite parent) {
Composite composite = new Composite(parent, SWT.BORDER | this.style);
composite.setLayout(new FillLayout());
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = COLUMNS;
gridData.verticalIndent = 5;
composite.setLayoutData(gridData);
new Browser(composite, SWT.NONE);
return composite;
}
use of org.eclipse.swt.browser.Browser in project mdw-designer by CenturyLinkCloud.
the class PropertyEditor method updateWidget.
public void updateWidget(String value) {
String newValue = value == null ? "" : value;
if (type.equals(TYPE_TEXT))
((Text) widget).setText(newValue);
else if (type.equals(TYPE_COMBO))
((Combo) widget).setText(newValue);
else if (type.equals(TYPE_IMAGE_COMBO))
((ImageCombo) widget).setText(newValue);
else if (type.equals(TYPE_INFO))
((Label) widget).setText(newValue);
else if (type.equals(TYPE_PICKLIST))
((ListComposer) widget).setInput(newValue);
else if (type.equals(TYPE_RADIO))
updateRadioButtons(newValue);
else if (type.equals(TYPE_TIMER))
updateTimerInterval(newValue);
else if (type.equals(TYPE_SPINNER))
((Spinner) widget).setSelection(newValue.length() == 0 ? 0 : Integer.parseInt(newValue));
else if (type.equals(TYPE_CHECKBOX))
((Button) widget).setSelection(Boolean.parseBoolean(newValue));
else if (type.equals(TYPE_SWITCH))
((SwitchButton) widget).setSelection(Boolean.parseBoolean(newValue));
else if (type.equals(TYPE_DATE_PICKER)) {
try {
Calendar calendar = Calendar.getInstance();
if (newValue.length() == 0) {
((DatePicker) widget).setSelection(null);
} else {
calendar.setTime(new SimpleDateFormat(DATE_FORMAT).parse(newValue));
((DatePicker) widget).setSelection(calendar);
}
} catch (ParseException ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
} else if (type.equals(TYPE_BAM_MESSAGE)) {
BamEventComposer bamComposer = (BamEventComposer) widget;
bamComposer.setElement(getElement());
bamComposer.setInput(valueConverter.toModelValue(newValue));
} else if (type.equals(TYPE_PARAMETERIZED_COMBO)) {
((ParameterizedCombo) widget).setInput(valueConverter.toModelValue(newValue));
} else if (type.equals(TYPE_WEB)) {
Composite c = (Composite) widget;
Browser browser = (Browser) c.getChildren()[0];
if (newValue.startsWith("http://") || newValue.startsWith("https://"))
browser.setUrl(newValue);
else
browser.setText(newValue);
}
}
Aggregations