Skip to content

Commit

Permalink
add help buttons for .bnd and .bndrun editor
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Rueger <[email protected]>
  • Loading branch information
chrisrueger committed Oct 30, 2023
1 parent dbde546 commit 98cf605
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
54 changes: 45 additions & 9 deletions bndtools.core/src/bndtools/editor/common/Buttons.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bndtools.core.ui.icons.Icons;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.program.Program;
import org.eclipse.ui.ISharedImages;
Expand All @@ -12,30 +13,65 @@
*/
public final class Buttons {

public static final Action HELP_BTN_REPOSITORIES = createHelpButton(
public static final Action HELP_BTN_REPOSITORIES = createHelpButton(
"https://bndtools.org/manual/repositories-view.html",
"The Repositories View provides a user-friendly interface to inspect and manage the bundle repositories that are available to your Bndtools projects. Click to open manual in the browser.");

public static final Action HELP_BTN_BNDTOOLS_EXPLORER = createHelpButton(
public static final Action HELP_BTN_BNDTOOLS_EXPLORER = createHelpButton(
"https://bndtools.org/manual/packageexplorer.html",
"The explorer provides an overview of the projects and their contents and allows advanced filtering. Click to open manual in the browser.");

public static final Action HELP_BTN_RESOLUTION_VIEW = createHelpButton(
public static final Action HELP_BTN_RESOLUTION_VIEW = createHelpButton(
"https://bndtools.org/manual/resolution-view.html",
"The Resolution view shows the requirements and capabilities of one or multiple selected items, be they bnd.bnd files, JAR files, or entries in the Repositories view. Click to open manual in the browser.");
"The Resolution view shows the requirements and capabilities of one or multiple selected items, be they bnd.bnd files, JAR files, or entries in the Repositories view. This is useful for understanding dependencies as it provides information about what requirements are matched with what capabilities from the included resources. Click to open manual in the browser.");

public static final Action HELP_BTN_BND_EDITOR = createHelpButton(
"https://bndtools.org/manual/bndeditor.html",
"This editor allows to edit bnd.bnd files, which define OSGi bundle metadata and build instructions for Java projects, encompassing sections for builtpath, imports, exports, bundle headers, and instructions to control the generation of the resulting OSGi bundle.");

public static final ActionContributionItem HELP_BTN_BND_EDITOR_RUN = createHelpButtonWithText(
"https://bndtools.org/manual/bndeditor.html#run", "Help",
"The bnd editor for .bndrun files facilitates dependency management, automated resolution of required bundles, configuration of JVM and framework properties, direct launching of OSGi instances for testing, and the export of run configurations as executable JARs.");

/**
* Creates a help button with icon and tooltip.
*
* @param url
* @param tooltipText
* @return
*/
private static Action createHelpButton(String url, String tooltipText) {
Action helpAction = new Action("Help", IAction.AS_PUSH_BUTTON) {
Action btn = new Action("Help", IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
Program.launch(url);
}
};
helpAction.setEnabled(true);
helpAction.setToolTipText(tooltipText);
helpAction.setImageDescriptor(Icons.desc(ISharedImages.IMG_LCL_LINKTO_HELP));
btn.setEnabled(true);
btn.setToolTipText(tooltipText);
btn.setImageDescriptor(Icons.desc(ISharedImages.IMG_LCL_LINKTO_HELP));

return btn;
}

/**
* Creates a helpbutton with icon, text and tooltip.
*
* @param url
* @param buttonText
* @param tooltipText
* @return
*/
private static ActionContributionItem createHelpButtonWithText(String url, String buttonText, String tooltipText) {
Action btn = createHelpButton(url, tooltipText);
btn.setText(buttonText);

// the ActionContributionItem is required to display text below the icon
// of the button
ActionContributionItem helpContrib = new ActionContributionItem(btn);
helpContrib.setMode(ActionContributionItem.MODE_FORCE_TEXT);

return helpAction;
return helpContrib;
}

private Buttons() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bndtools.core.ui.ExtendedFormEditor;
import org.bndtools.core.ui.IFormPageFactory;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
Expand All @@ -26,6 +27,7 @@
import aQute.bnd.build.model.BndEditModel;
import aQute.bnd.build.model.clauses.ExportedPackage;
import aQute.bnd.build.model.clauses.ImportPattern;
import bndtools.editor.common.Buttons;
import bndtools.editor.common.MDSashForm;
import bndtools.editor.contents.BundleCalculatedImportsPart;
import bndtools.editor.contents.GeneralInfoPart;
Expand Down Expand Up @@ -69,6 +71,12 @@ protected void createFormContent(IManagedForm managedForm) {
ScrolledForm scrolledForm = managedForm.getForm();
scrolledForm.setText("Bundle Content");

// buttons top of form
IToolBarManager toolbar = scrolledForm.getForm()
.getToolBarManager();
toolbar.add(Buttons.HELP_BTN_BND_EDITOR);
toolbar.update(true);

Form form = scrolledForm.getForm();
toolkit.decorateFormHeading(form);
form.addMessageHyperlinkListener(new MessageHyperlinkAdapter(getEditor()));
Expand Down
4 changes: 4 additions & 0 deletions bndtools.core/src/bndtools/editor/pages/ProjectRunPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import aQute.bnd.build.Workspace;
import aQute.bnd.build.model.BndEditModel;
import bndtools.central.Central;
import bndtools.editor.common.Buttons;
import bndtools.editor.common.MDSashForm;
import bndtools.editor.project.AvailableBundlesPart;
import bndtools.editor.project.RepositorySelectionPart;
Expand Down Expand Up @@ -142,6 +143,9 @@ protected void createFormContent(IManagedForm managedForm) {
form.getToolBarManager()
.add(exportContrib);

form.getToolBarManager()
.add(Buttons.HELP_BTN_BND_EDITOR_RUN);

form.getToolBarManager()
.update(true);

Expand Down

0 comments on commit 98cf605

Please sign in to comment.