KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > UIQueryFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ltk.internal.ui.refactoring;
12
13 import org.eclipse.swt.widgets.Shell;
14
15 import org.eclipse.core.runtime.IAdaptable;
16
17 import org.eclipse.ltk.core.refactoring.IValidationCheckResultQuery;
18 import org.eclipse.ltk.core.refactoring.IValidationCheckResultQueryFactory;
19
20 public class UIQueryFactory implements IValidationCheckResultQueryFactory {
21
22     private IValidationCheckResultQueryFactory fCoreQueryFactory;
23     
24     public UIQueryFactory(IValidationCheckResultQueryFactory coreFactory) {
25         fCoreQueryFactory= coreFactory;
26     }
27     
28     public IValidationCheckResultQuery create(IAdaptable context) {
29         if (context != null) {
30             Shell parent= (Shell)context.getAdapter(Shell.class);
31             if (parent != null) {
32                 String JavaDoc title= (String JavaDoc)context.getAdapter(String JavaDoc.class);
33                 if (title != null) {
34                     return new ValidationCheckResultQuery(parent, title);
35                 }
36             }
37         }
38         return fCoreQueryFactory.create(context);
39     }
40 }
41
Popular Tags