Search in sources :

Example 1 with C8oBrowser

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);
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) ExpandItem(org.eclipse.swt.widgets.ExpandItem) GridData(org.eclipse.swt.layout.GridData) Rectangle(org.eclipse.swt.graphics.Rectangle) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 2 with C8oBrowser

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);
}
Also used : C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 3 with C8oBrowser

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();
    });
}
Also used : JsObject(com.teamdev.jxbrowser.js.JsObject) Frame(com.teamdev.jxbrowser.frame.Frame) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) JSONException(org.codehaus.jettison.json.JSONException) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) File(java.io.File)

Example 4 with C8oBrowser

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();
    });
}
Also used : JsObject(com.teamdev.jxbrowser.js.JsObject) Frame(com.teamdev.jxbrowser.frame.Frame) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) JSONException(org.codehaus.jettison.json.JSONException) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) File(java.io.File)

Example 5 with C8oBrowser

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;
                }
            }
        }
    }
}
Also used : CouchVariable(com.twinsoft.convertigo.beans.transactions.couchdb.CouchVariable) Listener(org.eclipse.swt.widgets.Listener) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event)

Aggregations

C8oBrowser (com.twinsoft.convertigo.eclipse.swt.C8oBrowser)9 GridData (org.eclipse.swt.layout.GridData)7 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 ControlAdapter (org.eclipse.swt.events.ControlAdapter)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 PartInitException (org.eclipse.ui.PartInitException)3 Frame (com.teamdev.jxbrowser.frame.Frame)2 JsObject (com.teamdev.jxbrowser.js.JsObject)2 DatabaseObjectFoundException (com.twinsoft.convertigo.engine.DatabaseObjectFoundException)2 File (java.io.File)2 JSONException (org.codehaus.jettison.json.JSONException)2 CoreException (org.eclipse.core.runtime.CoreException)2 CLabel (org.eclipse.swt.custom.CLabel)2 ExpandAdapter (org.eclipse.swt.events.ExpandAdapter)2 ExpandEvent (org.eclipse.swt.events.ExpandEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2