Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.browser; singleton:=true
Bundle-Version: 3.8.600.qualifier
Bundle-Version: 3.8.700.qualifier
Bundle-Activator: org.eclipse.ui.internal.browser.WebBrowserUIPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ public BrowserDescriptorDialog(Shell parentShell) {
protected void configureShell(Shell shell) {
super.configureShell(shell);

if (isEdit)
if (isEdit) {
shell.setText(Messages.editExternalBrowser);
else
} else {
shell.setText(Messages.createBrowser);
}
}

protected Text createText(Composite comp, String txt, final StringModifyListener listener, boolean multiLine) {
Expand All @@ -91,8 +92,9 @@ protected Text createText(Composite comp, String txt, final StringModifyListener
});
}
// final Text text = SWTUtil.createMultilineText(comp, style);
if (txt != null)
if (txt != null) {
text.setText(txt);
}

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
data.widthHint = 450;
Expand All @@ -104,8 +106,9 @@ protected Text createText(Composite comp, String txt, final StringModifyListener
}

text.setLayoutData(data);
if (listener != null)
if (listener != null) {
text.addModifyListener(e -> listener.valueChanged(text.getText()));
}
return text;
}

Expand Down Expand Up @@ -145,8 +148,9 @@ protected Control createDialogArea(Composite parent) {
dialog.setFileName(fname);
fname = dialog.open();

if (fname != null)
if (fname != null) {
browserLocationTextfield.setText(fname);
}
}));

SWTUtil.createLabel(composite, Messages.parameters).setFont(font);
Expand Down Expand Up @@ -184,11 +188,13 @@ protected void okPressed() {
}

private void setOKButtonEnabled(boolean curIsEnabled) {
if (okButton == null)
if (okButton == null) {
okButton = getButton(IDialogConstants.OK_ID);
}

if (okButton != null)
if (okButton != null) {
okButton.setEnabled(curIsEnabled);
}
}

@Override
Expand All @@ -202,12 +208,14 @@ protected void validateFields() {
boolean valid = true;

String name = browserNameTextfield.getText();
if (name == null || name.trim().length() < 1)
if (name == null || name.trim().length() < 1) {
valid = false;
}

String location = browserLocationTextfield.getText();
if (location == null || location.trim().length() < 1)
if (location == null || location.trim().length() < 1) {
valid = false;
}

setOKButtonEnabled(valid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public BrowserDescriptorWorkingCopy(BrowserDescriptor browser) {

@Override
public void setName(String name) {
if (name == null)
if (name == null) {
throw new IllegalArgumentException();
}
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class BrowserExt implements IBrowserExt {
private static final String ATTR_FACTORY_CLASS = "factoryclass"; //$NON-NLS-1$

private IConfigurationElement element;
private final IConfigurationElement element;

private BrowserFactory delegate;

Expand All @@ -50,8 +50,9 @@ public String getId() {
@Override
public String getName() {
String label = element.getAttribute("name"); //$NON-NLS-1$
if (label == null)
if (label == null) {
return "n/a"; //$NON-NLS-1$
}
return label;
}

Expand All @@ -68,8 +69,9 @@ public String getExecutable() {
@Override
public String getOS() {
String os = element.getAttribute("os"); //$NON-NLS-1$
if (os == null)
if (os == null) {
os = ""; //$NON-NLS-1$
}
return os;
}

Expand All @@ -92,8 +94,9 @@ public String[] getDefaultLocations() {
protected BrowserFactory getDelegate() {
if (delegate == null) {
if (element.getAttribute(ATTR_FACTORY_CLASS) == null
|| element.getAttribute(ATTR_FACTORY_CLASS).isEmpty())
|| element.getAttribute(ATTR_FACTORY_CLASS).isEmpty()) {
return null;
}

try {
delegate = (BrowserFactory) element
Expand All @@ -118,8 +121,9 @@ protected BrowserFactory getDelegate() {
@Override
public boolean isAvailable() {
if (delegate == null && (element.getAttribute(ATTR_FACTORY_CLASS) == null
|| element.getAttribute(ATTR_FACTORY_CLASS).isEmpty()))
|| element.getAttribute(ATTR_FACTORY_CLASS).isEmpty())) {
return true;
}

try {
return getDelegate().isAvailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public BrowserLauncher() {
public void open(IPath file) {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
try {
if (WebBrowserPreference.getBrowserChoice()== WebBrowserPreference.INTERNAL)
if (WebBrowserPreference.getBrowserChoice()== WebBrowserPreference.INTERNAL) {
support.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR,
file.toPortableString(), null, null).openURL(file.toFile().toURI().toURL());
else
} else {
support.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR,
DefaultBrowserSupport.SHARED_ID, null, null).openURL(file.toFile().toURI().toURL());
}
}
catch (MalformedURLException e) {
// ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public class BrowserManager extends Observable {
protected List<IBrowserDescriptor> browsers;
protected IBrowserDescriptor currentBrowser;

private IPreferenceChangeListener pcl;
private final IPreferenceChangeListener pcl;
protected boolean ignorePreferenceChanges = false;

protected static BrowserManager instance;

public static BrowserManager getInstance() {
if (instance == null)
if (instance == null) {
instance = new BrowserManager();
}
return instance;
}

Expand All @@ -66,8 +67,9 @@ private BrowserManager() {
}

protected static void safeDispose() {
if (instance == null)
if (instance == null) {
return;
}
instance.dispose();
}

Expand All @@ -82,8 +84,9 @@ public IBrowserDescriptorWorkingCopy createExternalWebBrowser() {
}

public List<IBrowserDescriptor> getWebBrowsers() {
if (browsers == null)
if (browsers == null) {
loadBrowsers();
}
return new ArrayList<>(browsers);
}

Expand All @@ -101,8 +104,9 @@ public void loadBrowsers() {
IMemento memento = XMLMemento.createReadRoot(reader);

IMemento system = memento.getChild("system"); //$NON-NLS-1$
if (system != null && WebBrowserUtil.canUseSystemBrowser())
if (system != null && WebBrowserUtil.canUseSystemBrowser()) {
browsers.add(new SystemBrowserDescriptor());
}

IMemento[] children = memento.getChildren("external"); //$NON-NLS-1$
int size = children.length;
Expand Down Expand Up @@ -131,8 +135,9 @@ public void loadBrowsers() {
saveBrowsers();
}

if (currentBrowser == null && browsers.size() > 0)
if (currentBrowser == null && browsers.size() > 0) {
currentBrowser = browsers.get(0);
}
setChanged();
notifyObservers();
}
Expand All @@ -145,8 +150,7 @@ protected void saveBrowsers() {
Iterator<IBrowserDescriptor> iterator = browsers.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof BrowserDescriptor) {
BrowserDescriptor browser = (BrowserDescriptor) obj;
if (obj instanceof BrowserDescriptor browser) {
IMemento child = memento.createChild("external"); //$NON-NLS-1$
browser.save(child);
} else if (obj instanceof SystemBrowserDescriptor) {
Expand Down Expand Up @@ -194,49 +198,59 @@ protected void addDefaultBrowsers() {

// by default, if internal is there, that is current, else set the first
// external one
if (!browsers.isEmpty() && currentBrowser == null)
if (!browsers.isEmpty() && currentBrowser == null) {
currentBrowser = browsers.get(0);
}
}

protected void addBrowser(IBrowserDescriptor browser) {
if (browsers == null)
if (browsers == null) {
loadBrowsers();
if (!browsers.contains(browser))
}
if (!browsers.contains(browser)) {
browsers.add(browser);
if (browsers.size() == 1)
}
if (browsers.size() == 1) {
setCurrentWebBrowser(browser);
}
}

protected void removeWebBrowser(IBrowserDescriptor browser) {
if (browsers == null)
if (browsers == null) {
loadBrowsers();
}
browsers.remove(browser);

if (currentBrowser == null || currentBrowser.equals(browser)) {
currentBrowser = null;
if (browsers.size() > 0)
if (browsers.size() > 0) {
currentBrowser = browsers.get(0);
}
}
}

public IBrowserDescriptor getCurrentWebBrowser() {
if (browsers == null)
if (browsers == null) {
loadBrowsers();
}

if (currentBrowser == null && browsers.size() > 0)
if (currentBrowser == null && browsers.size() > 0) {
return browsers.get(0);
}

return currentBrowser;
}

public void setCurrentWebBrowser(IBrowserDescriptor wb) {
if (wb == null)
if (wb == null) {
throw new IllegalArgumentException();
}

if (browsers.contains(wb))
if (browsers.contains(wb)) {
currentBrowser = wb;
else
} else {
throw new IllegalArgumentException();
}
saveBrowsers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class BrowserText {
private String url;

private FallbackScrolledComposite scomp;
private final FallbackScrolledComposite scomp;

private Label title;

Expand All @@ -46,15 +46,15 @@ public class BrowserText {

protected Link link;

private BrowserViewer viewer;
private final BrowserViewer viewer;

private Button button;

private Text exception;

private boolean expanded;

private Throwable ex;
private final Throwable ex;

class ReflowScrolledComposite extends FallbackScrolledComposite {
public ReflowScrolledComposite(Composite parent, int style) {
Expand Down Expand Up @@ -140,10 +140,11 @@ protected void toggleException() {
}

private void updateButtonText() {
if (expanded)
if (expanded) {
button.setText(Messages.BrowserText_button_collapse);
else
} else {
button.setText(Messages.BrowserText_button_expand);
}
}

protected void updateWidth(Composite parent) {
Expand All @@ -158,14 +159,16 @@ protected void updateWidth(Composite parent) {

private void updateWidth(Control c, int width) {
GridData gd = (GridData) c.getLayoutData();
if (gd != null)
if (gd != null) {
gd.widthHint = width - 10;
}
}

protected void doOpenExternal() {
IBrowserViewerContainer container = viewer.getContainer();
if (container != null)
if (container != null) {
container.openInExternalBrowser(url);
}
}

public Control getControl() {
Expand Down
Loading
Loading