use of com.twinsoft.convertigo.eclipse.swt.C8oBrowser in project convertigo by convertigo.
the class ObjectsExplorerComposite method initialize.
/**
* This method initializes this
*/
protected void initialize() {
layout(true);
layout(true, true);
setLayout(new GridLayout(3, true));
GridData gridData;
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = 2;
gridData.verticalAlignment = GridData.BEGINNING;
gridData.grabExcessVerticalSpace = true;
scrolledComposite = new ScrolledComposite(this, SWT.V_SCROLL);
scrolledComposite.setLayoutData(gridData);
helpBrowser = new C8oBrowser(this, SWT.MULTI | SWT.WRAP);
helpBrowser.setUseExternalBrowser(true);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.grabExcessHorizontalSpace = true;
helpBrowser.setLayoutData(gridData);
GridLayout gridLayout = new GridLayout(3, true);
gridLayout.verticalSpacing = 10;
gridLayout.horizontalSpacing = 10;
// retrieve 'project' technology
technology = DboUtils.getTechnology(parentObject, databaseObjectClass);
getDisplay().asyncExec(() -> {
// find associated database objects
findDatabaseObjects();
for (ExpandItem expandItem : bar.getItems()) {
/* update the item's height if needed in response to changes*/
final ExpandItem item = expandItem;
final Composite composite = (Composite) expandItem.getControl();
composite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Point size = composite.getSize();
Point size2 = composite.computeSize(size.x, SWT.DEFAULT);
item.setHeight(size2.y);
}
});
}
scrolledComposite.setContent(bar);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle r = scrolledComposite.getClientArea();
scrolledComposite.setMinSize(bar.computeSize(r.width, SWT.DEFAULT));
}
});
if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
}
layout(true);
});
}
use of com.twinsoft.convertigo.eclipse.swt.C8oBrowser in project convertigo by convertigo.
the class MobileDebugView method createPartControl.
@Override
public void createPartControl(Composite parent) {
c8oBrowser = new C8oBrowser(parent, SWT.MULTI | SWT.WRAP);
c8oBrowser.setLayout(new FillLayout());
c8oBrowser.setZoomEnabled(false);
if (!onActivated(getSite().getPage().getActiveEditor())) {
parent.getDisplay().asyncExec(() -> {
c8oBrowser.setText("<html><head><style>html {color: $foreground$; background-color: $background$; font-family: sans-serif }</style></head>" + "<body>" + "<center>" + "Please click on an application viewer in the right pane to enable a <br />" + "debuging session. </br>" + "</center>" + "</body>" + "</html>");
});
}
getSite().getPage().addPartListener(this);
}
use of com.twinsoft.convertigo.eclipse.swt.C8oBrowser in project convertigo by convertigo.
the class ApplicationComponentEditor method createBrowser.
private void createBrowser(Composite parent) {
browserScroll = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
browserScroll.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
browserScroll.setExpandHorizontal(true);
browserScroll.setExpandVertical(true);
Composite canvas = new Composite(browserScroll, SWT.NONE);
browserScroll.setContent(canvas);
GridLayout gl = new GridLayout(1, false);
gl.marginBottom = gl.marginTop = gl.marginLeft = gl.marginRight = gl.marginHeight = gl.marginWidth = gl.horizontalSpacing = gl.verticalSpacing = 0;
canvas.setLayout(gl);
c8oBrowser = new C8oBrowser(canvas, SWT.NONE, applicationEditorInput.application.getProject());
browserGD = new GridData(SWT.CENTER, SWT.CENTER, true, true);
c8oBrowser.setLayoutData(browserGD);
browser = c8oBrowser.getBrowser();
debugUrl = c8oBrowser.getDebugUrl();
browserInterface = new ApplicationComponentBrowserImpl();
browser.set(InjectJsCallback.class, params -> {
String url = params.frame().browser().url();
if (baseUrl != null && url.startsWith(baseUrl)) {
try {
Frame frame = params.frame();
JsObject sessionStorage = frame.executeJavaScript("sessionStorage");
frame.executeJavaScript("sessionStorage.setItem('_c8ocafsession_storage_mode', 'session');\n" + "navigator.__defineGetter__('userAgent', function(){ return '" + deviceOS.agent() + "'});\n" + IOUtils.toString(getClass().getResourceAsStream("inject.js"), "UTF-8"));
sessionStorage.call("setItem", "_c8ocafsession_storage_mode", "session");
if (!dataset.equals("none")) {
String json = FileUtils.readFileToString(new File(datasetDir, dataset + ".json"), "UTF-8");
sessionStorage.call("setItem", "_c8ocafsession_storage_data", json);
} else {
sessionStorage.call("setItem", "_c8ocafsession_storage_data", null);
}
JsObject window = frame.executeJavaScript("window");
window.putProperty("java", browserInterface);
} catch (Exception e) {
Engine.logStudio.info("onScriptContextCreate failed for '" + url + "' with baseUrl '" + baseUrl + "': " + e.getMessage());
}
}
// browser.setZoomLevel(zoomFactor.zoomLevel());
return Response.proceed();
});
browser.set(ShowContextMenuCallback.class, (params, tell) -> {
com.teamdev.jxbrowser.ui.Point location = params.location();
highlightPoint(location.x(), location.y());
tell.close();
});
browser.engine().permissions().set(RequestPermissionCallback.class, (params, tell) -> {
tell.grant();
});
}
use of com.twinsoft.convertigo.eclipse.swt.C8oBrowser in project convertigo by convertigo.
the class ApplicationComponentEditor method createBrowser.
private void createBrowser(Composite parent) {
browserScroll = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
browserScroll.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
browserScroll.setExpandHorizontal(true);
browserScroll.setExpandVertical(true);
Composite canvas = new Composite(browserScroll, SWT.NONE);
browserScroll.setContent(canvas);
GridLayout gl = new GridLayout(1, false);
gl.marginBottom = gl.marginTop = gl.marginLeft = gl.marginRight = gl.marginHeight = gl.marginWidth = gl.horizontalSpacing = gl.verticalSpacing = 0;
canvas.setLayout(gl);
c8oBrowser = new C8oBrowser(canvas, SWT.NONE, applicationEditorInput.application.getProject());
browserGD = new GridData(SWT.CENTER, SWT.CENTER, true, true);
c8oBrowser.setLayoutData(browserGD);
browser = c8oBrowser.getBrowser();
debugUrl = c8oBrowser.getDebugUrl();
browserInterface = new ApplicationComponentBrowserImpl();
browser.set(InjectJsCallback.class, params -> {
String url = params.frame().browser().url();
if (baseUrl != null && url.startsWith(baseUrl)) {
try {
Frame frame = params.frame();
JsObject sessionStorage = frame.executeJavaScript("sessionStorage");
frame.executeJavaScript("sessionStorage.setItem('_c8ocafsession_storage_mode', 'session');\n" + "navigator.__defineGetter__('userAgent', function(){ return '" + deviceOS.agent() + "'});\n" + IOUtils.toString(getClass().getResourceAsStream("inject.js"), "UTF-8"));
sessionStorage.call("setItem", "_c8ocafsession_storage_mode", "session");
if (!dataset.equals("none")) {
String json = FileUtils.readFileToString(new File(datasetDir, dataset + ".json"), "UTF-8");
sessionStorage.call("setItem", "_c8ocafsession_storage_data", json);
} else {
sessionStorage.call("setItem", "_c8ocafsession_storage_data", null);
}
JsObject window = frame.executeJavaScript("window");
window.putProperty("java", browserInterface);
} catch (Exception e) {
Engine.logStudio.info("onScriptContextCreate failed for '" + url + "' with baseUrl '" + baseUrl + "': " + e.getMessage());
}
}
// browser.setZoomLevel(zoomFactor.zoomLevel());
return Response.proceed();
});
browser.set(ShowContextMenuCallback.class, (params, tell) -> {
com.teamdev.jxbrowser.ui.Point location = params.location();
highlightPoint(location.x(), location.y());
tell.close();
});
browser.engine().permissions().set(RequestPermissionCallback.class, (params, tell) -> {
tell.grant();
});
}
use of com.twinsoft.convertigo.eclipse.swt.C8oBrowser in project convertigo by convertigo.
the class CouchVariablesComposite method addToComposite.
private void addToComposite(Group choosenGroup, final String name, final String description, final boolean isMultiValued) {
boolean isNotChecked = true;
if (allVariables != null) {
isNotChecked = !isChecked(allVariables, name);
}
if (isNotChecked) {
final Button checkBtn = new Button(choosenGroup, SWT.CHECK);
checkBtn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
if (checkBtn.getSelection()) {
selectedVariable.add(new CouchVariable(name, description, isMultiValued));
} else {
selectedVariable.remove(getIndex(name, selectedVariable));
}
}
});
Label labelName = new Label(choosenGroup, SWT.NONE);
FontData fontData = labelName.getFont().getFontData()[0];
Font font = new Font(this.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
labelName.setFont(font);
String label = name;
if (label.startsWith("p_") || label.startsWith("q_")) {
label = name.substring(2);
}
if (isMultiValued) {
label += " [ ]";
}
labelName.setText(label);
C8oBrowser browserDescription = new C8oBrowser(choosenGroup, SWT.MULTI | SWT.WRAP);
browserDescription.setUseExternalBrowser(true);
if (SwtUtils.isDark()) {
browserDescription.setBackground(getParent().getBackground());
}
GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, true);
gd.minimumHeight = 60;
browserDescription.setLayoutData(gd);
browserDescription.setText("<html>" + "<head>" + "<script type=\"text/javascript\">" + "document.oncontextmenu = new Function(\"return false\");" + "</script>" + "<style type=\"text/css\">" + "body {" + "margin: auto;" + "height: 60px;" + "display: table-cell;" + "vertical-align: middle;" + "font-family: Tahoma new, sans-serif;" + "font-size: 0.7em;" + "overflow-y: auto;" + "color: $foreground$;" + "background-color: $background$ } \n" + "a { color: $link$; }" + "</style></head><body>" + description + "</body></html>");
parametersCouch.add(name);
Control[] children = choosenGroup.getChildren();
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Label) {
String lab = ((Label) children[i]).getText();
if (label.compareTo(lab) < 0) {
labelName.moveAbove(children[i - 1]);
checkBtn.moveAbove(labelName);
browserDescription.moveBelow(labelName);
break;
}
}
}
}
}
Aggregations