Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No option to create preference dialog boxs' export/import button without the help button #2625

Open
1 task done
rraghav29 opened this issue Dec 13, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@rraghav29
Copy link

In the org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.java class, method: createHelpControl(Composite parent):
The method calls another method
addButtonsToHelpControl(Control control). This method is responsible for creating the import/export buttons in the preference dialog box. There is no provision to just create the import/export buttons without the help button.

Suggesting the addition of import/export buttons without the help button.
Screenshot:
image

Code snippet:
@OverRide
protected Control createHelpControl(Composite parent) {
Control control = super.createHelpControl(parent);
addButtonsToHelpControl(control);
return control;
}

protected void addButtonsToHelpControl(Control control) {
	Composite parent = control.getParent();
	if (control instanceof ToolBar) {
		ToolBar toolBar = (ToolBar) control;

		ToolItem importButton = new ToolItem(toolBar, SWT.PUSH);
		importImage = WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_PREF_IMPORT).createImage();
		importButton.setImage(importImage);
		importButton.setToolTipText(WorkbenchMessages.Preference_import);
		importButton.addListener(SWT.Selection, e -> openImportWizard(parent));

		ToolItem exportButton = new ToolItem(toolBar, SWT.PUSH);
		exportImage = WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_PREF_EXPORT).createImage();
		exportButton.setImage(exportImage);
		exportButton.setToolTipText(WorkbenchMessages.Preference_export);
		exportButton.addListener(SWT.Selection, e -> openExportWizard(parent));
	} else if (control instanceof Link) {
		Composite linkParent = control.getParent();
		Link importLink = new Link(linkParent, SWT.WRAP | SWT.NO_FOCUS);
		((GridLayout) parent.getLayout()).numColumns++;
		importLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
		importLink.setText(" <a>" + WorkbenchMessages.Preference_import + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
		importLink.addListener(SWT.Selection, e -> openImportWizard(parent));

		Link exportLink = new Link(linkParent, SWT.WRAP | SWT.NO_FOCUS);
		((GridLayout) parent.getLayout()).numColumns++;
		exportLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
		exportLink.setText(" <a>" + WorkbenchMessages.Preference_export + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
		exportLink.addListener(SWT.Selection, e -> openExportWizard(parent));
	}
}

Tested under this environment:

  • OS & version: Windows 10
  • Eclipse IDE/Platform version (as shown in Help > About): Version: 2025-03 (4.35) Build id: I20241212-1800

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.

@rraghav29 rraghav29 added the bug Something isn't working label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant