Revision a9ee1fff
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchBar.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.navigation.search; |
11 | 11 |
|
12 |
import java.util.List; |
|
13 |
|
|
12 | 14 |
import javax.annotation.PostConstruct; |
13 | 15 |
import javax.inject.Inject; |
14 | 16 |
|
... | ... | |
16 | 18 |
import org.eclipse.e4.ui.model.application.MApplication; |
17 | 19 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
18 | 20 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
21 |
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement; |
|
19 | 22 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
20 | 23 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
21 | 24 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
... | ... | |
44 | 47 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
45 | 48 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
46 | 49 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
50 |
import eu.etaxonomy.taxeditor.navigation.AppModelId; |
|
47 | 51 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
48 | 52 |
import eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4; |
49 | 53 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
... | ... | |
226 | 230 |
*/ |
227 | 231 |
private void openSearchResultsView(IFindTaxaAndNamesConfigurator configurator) { |
228 | 232 |
boolean openResultInSeparateWindows = PreferencesUtil.getPreferenceStore().getBoolean((IPreferenceKeys.SEARCH_OPEN_RESULTS_IN_SEPARATE_WINDOWS)); |
229 |
String partId = "eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4"; |
|
230 |
|
|
231 |
MPart part = partService.findPart(partId); |
|
233 |
String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_NAVIGATION_SEARCH_E4_SEARCHRESULTVIEWE4; |
|
234 |
|
|
235 |
MPart part = null; |
|
236 |
List<MPart> resultViews = modelService.findElements(application, partId, MPart.class, null); |
|
237 |
for (MPart mPart : resultViews) { |
|
238 |
if(mPart.getObject()!=null && mPart.isToBeRendered()){ |
|
239 |
part = mPart; |
|
240 |
break; |
|
241 |
} |
|
242 |
} |
|
243 |
if(part==null){ |
|
244 |
part = partService.findPart(partId); |
|
245 |
} |
|
232 | 246 |
if(openResultInSeparateWindows && part.getObject()!=null){ |
247 |
MPartStack resultViewPartStack = getSearchResulPartStack(partId); |
|
233 | 248 |
part = partService.createPart(partId); |
234 | 249 |
//FIXME E4 this part stack id has to re-used or a adapted after migration |
235 |
MPartStack editorAreaPartStack = WorkbenchUtility.getPartStack(NAVIGATION_STACK_ID, application, modelService); |
|
236 |
if(editorAreaPartStack!=null){ |
|
237 |
editorAreaPartStack.getChildren().add(part); |
|
250 |
if(resultViewPartStack==null){ |
|
251 |
resultViewPartStack = WorkbenchUtility.getPartStack(NAVIGATION_STACK_ID, application, modelService); |
|
252 |
} |
|
253 |
if(resultViewPartStack!=null){ |
|
254 |
resultViewPartStack.getChildren().add(part); |
|
238 | 255 |
} |
239 | 256 |
} |
240 | 257 |
part = partService.showPart(part, PartState.ACTIVATE); |
241 | 258 |
SearchResultViewE4 resultView = (SearchResultViewE4)part.getObject(); |
242 | 259 |
resultView.performSearch(configurator); |
260 |
} |
|
243 | 261 |
|
262 |
private MPartStack getSearchResulPartStack(String partId){ |
|
263 |
List<MPartStack> elements = modelService.findElements(application, null, MPartStack.class, null); |
|
264 |
for (MPartStack partStack : elements) { |
|
265 |
List<MStackElement> children = partStack.getChildren(); |
|
266 |
for (MStackElement mStackElement : children) { |
|
267 |
if(mStackElement.getElementId().equals(partId)){ |
|
268 |
return partStack; |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
return null; |
|
244 | 273 |
} |
245 | 274 |
|
246 | 275 |
/** |
Also available in: Unified diff
ref #6990 open search result view in correct part stack