diff --git a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF index 48e98d476..e87fb863a 100644 --- a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF @@ -40,7 +40,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.tools.templates.freemarker, org.eclipse.embedcdt.ui, org.eclipse.ltk.ui.refactoring, - org.eclipse.ltk.core.refactoring + org.eclipse.ltk.core.refactoring, + org.eclipse.ui.browser Automatic-Module-Name: com.espressif.idf.ui Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/bundles/com.espressif.idf.ui/plugin.xml b/bundles/com.espressif.idf.ui/plugin.xml index 3278f574d..6470feb0e 100644 --- a/bundles/com.espressif.idf.ui/plugin.xml +++ b/bundles/com.espressif.idf.ui/plugin.xml @@ -609,7 +609,7 @@ name="%editor.name.0"> \n" + + "\n" + + "\n" + + " \n" + + " \n" + + " IDF Component Registry\n" + + " \n" + + "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + "\n" + + "\n" + + ""; + + public void createBrowser(Composite composite) throws ClassNotFoundException + { + Browser browser = new Browser(composite, SWT.NONE); + browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + browser.setText(htmltext, true); + + } +} \ No newline at end of file diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/browser/ComponentsBrowserEditor.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/browser/ComponentsBrowserEditor.java new file mode 100644 index 000000000..eca8e6dc8 --- /dev/null +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/browser/ComponentsBrowserEditor.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved. + * Use is subject to license terms. + *******************************************************************************/ +package com.espressif.idf.ui.browser; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.MultiPageEditorPart; + +import com.espressif.idf.core.logging.Logger; + +public class ComponentsBrowserEditor extends MultiPageEditorPart +{ + public static String EDITOR_ID = "com.espressif.idf.ui.installComponents"; //$NON-NLS-1$ + + private IFile componentsJsonFile; + private IProject project; + + public ComponentsBrowserEditor() + { + } + + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException + { + super.init(site, input); + FileEditorInput editorInput = (FileEditorInput) getEditorInput(); + componentsJsonFile = editorInput.getFile(); + project = componentsJsonFile.getProject(); + setPartName(project.getName()); + + } + + @Override + protected void createPages() + { + String osString = componentsJsonFile.getLocation().toOSString(); + Logger.log("Editor input:" + osString); //$NON-NLS-1$ + + try + { + createComponentsInstallPage(); + } + catch ( + IOException + | ClassNotFoundException e) + { + Logger.log(e); + } + } + + private void createComponentsInstallPage() throws IOException, ClassNotFoundException + { + Composite parent = new Composite(getContainer(), SWT.NONE); + parent.setLayout(new FillLayout(SWT.VERTICAL)); + ScrolledComposite scrolledComposite = new ScrolledComposite(parent, + SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FILL); + scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL)); + scrolledComposite.setAlwaysShowScrollBars(true); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + scrolledComposite.addListener(SWT.Resize, event -> { + int width = scrolledComposite.getClientArea().width; + scrolledComposite.setMinSize(parent.computeSize(width, SWT.DEFAULT, true)); + }); + Composite subContainer = new Composite(scrolledComposite, SWT.NONE); + GridLayout gridLayout = new GridLayout(1, true); + subContainer.setLayout(gridLayout); + + new ComponentBrowser().createBrowser(subContainer); + + scrolledComposite.setContent(subContainer); + + int index = addPage(parent); + setPageText(index, "Install Components"); //$NON-NLS-1$ + } + + @Override + public void doSave(IProgressMonitor monitor) + { + } + + @Override + public void doSaveAs() + { + } + + @Override + public boolean isDirty() + { + return false; + } + + @Override + public boolean isSaveAsAllowed() + { + return false; + } + + @Override + public void setFocus() + { + } + + @Override + public void dispose() + { + super.dispose(); + } +}