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.jface/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: %pluginName
Bundle-SymbolicName: org.eclipse.jface;singleton:=true
Bundle-Version: 3.37.100.qualifier
Bundle-Version: 3.38.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jface,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jface.dialogs;

/**
* @since 3.38
*
*/
public interface IScopeChangeProvider {

/**
* Adds a listener for scope changes in this scope change provider. Has no
* effect if an identical listener is already registered.
*
* @param listener a scope changed listener
*/
void addScopeChangedListener(IScopeChangedListener listener);

/**
* Removes the given scope change listener from this page change provider. Has
* no effect if an identical listener is not registered.
*
* @param listener a scope changed listener
*/
void removeScopeChangedListener(IScopeChangedListener listener);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jface.dialogs;

/**
* A listener which is notified when the scope for the search page is changed.
*
* @see IScopeChangeProvider
* @see ScopeChangedEvent
*
* @since 3.38
*/
public interface IScopeChangedListener {
/**
* Notifies that the selected scope has changed.
*
* @param event event object describing the change
*/
void scopeChanged(ScopeChangedEvent event);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Red Hat Inc. - copied and modified from PageChangedEvent.java
*******************************************************************************/
package org.eclipse.jface.dialogs;

import java.util.EventObject;

/**
* Event object describing a page selection change. The source of these events
* is a page change provider.
*
* @see IPageChangeProvider
* @see IPageChangedListener
*
* @since 3.38
*/
public class ScopeChangedEvent extends EventObject {

private static final long serialVersionUID = -2652600407410991930L;

/**
* The changed scope.
*/
private final int scope;

/**
* Creates a new event for the given source and new scope.
*
* @param source the page change provider
* @param scope the new scope. In the JFace provided dialogs this will be an
* <code>ISearchPageContainer</code> constant.
*/
public ScopeChangedEvent(IPageChangeProvider source,
int scope) {
super(source);
this.scope = scope;
}

/**
* Returns the new scope.
*
* @return the new scope. In dialogs implemented by JFace, this will be an
* <code>ISearchPageContainer</code> constant.
*/
public int getScope() {
return scope;
}

/**
* Returns the scope change provider that is the source of this event.
*
* @return the originating scope change provider
*/
public IScopeChangeProvider getPageChangeProvider() {
return (IScopeChangeProvider) getSource();
}
}
2 changes: 1 addition & 1 deletion bundles/org.eclipse.search/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: %pluginName
Bundle-SymbolicName: org.eclipse.search; singleton:=true
Bundle-Version: 3.17.200.qualifier
Bundle-Version: 3.17.300.qualifier
Bundle-Activator: org.eclipse.search.internal.ui.SearchPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -60,7 +60,10 @@
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.IPageChangeProvider;
import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.IScopeChangeProvider;
import org.eclipse.jface.dialogs.IScopeChangedListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.dialogs.ScopeChangedEvent;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.SafeRunnable;
Expand Down Expand Up @@ -91,7 +94,8 @@
import org.eclipse.search.ui.ISearchPageScoreComputer;


public class SearchDialog extends ExtendedDialogWindow implements ISearchPageContainer, IPageChangeProvider {
public class SearchDialog extends ExtendedDialogWindow
implements ISearchPageContainer, IPageChangeProvider, IScopeChangeProvider {

// Dialog store id constants
private static final String DIALOG_NAME= "SearchDialog"; //$NON-NLS-1$
Expand Down Expand Up @@ -150,6 +154,7 @@ protected void layout(Composite composite, boolean flushCache) {
private Button fCustomizeButton;
private Button fReplaceButton;
private ListenerList<IPageChangedListener> fPageChangeListeners;
private ListenerList<IScopeChangedListener> fScopeChangeListeners;

private final IWorkbenchWindow fWorkbenchWindow;
private final ISelection fCurrentSelection;
Expand Down Expand Up @@ -706,6 +711,13 @@ public void setPerformActionEnabled(boolean state) {
*/
public void notifyScopeSelectionChanged() {
setPerformActionEnabled(fLastEnableState);
if (fScopeChangeListeners != null && !fScopeChangeListeners.isEmpty()) {
// Fires the scope change event
final ScopeChangedEvent event = new ScopeChangedEvent(this, getSelectedScope());
for (IScopeChangedListener l : fScopeChangeListeners) {
SafeRunner.run(() -> l.scopeChanged(event));
}
}
}

private Control createPageControl(Composite parent, final SearchPageDescriptor descriptor) {
Expand Down Expand Up @@ -828,4 +840,19 @@ public void run() {
}
}
}

@Override
public void addScopeChangedListener(IScopeChangedListener listener) {
if (fScopeChangeListeners == null) {
fScopeChangeListeners = new ListenerList<>();
}
fScopeChangeListeners.add(listener);
}

@Override
public void removeScopeChangedListener(IScopeChangedListener listener) {
if (fScopeChangeListeners != null) {
fScopeChangeListeners.remove(listener);
}
}
}
Loading