|
Lines 9-15
Link Here
|
| 9 |
*******************************************************************************/ |
9 |
*******************************************************************************/ |
| 10 |
package org.eclipse.jpt.jpa.ui.internal.details; |
10 |
package org.eclipse.jpt.jpa.ui.internal.details; |
| 11 |
|
11 |
|
|
|
12 |
import org.eclipse.core.resources.IFile; |
| 12 |
import org.eclipse.jdt.core.IJavaProject; |
13 |
import org.eclipse.jdt.core.IJavaProject; |
|
|
14 |
import org.eclipse.jdt.core.IType; |
| 15 |
import org.eclipse.jpt.common.core.internal.utility.JDTTools; |
| 16 |
import org.eclipse.jpt.common.core.internal.utility.PlatformTools; |
| 13 |
import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; |
17 |
import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages; |
| 14 |
import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane; |
18 |
import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserComboPane; |
| 15 |
import org.eclipse.jpt.common.ui.internal.widgets.Pane; |
19 |
import org.eclipse.jpt.common.ui.internal.widgets.Pane; |
|
Lines 18-28
Link Here
|
| 18 |
import org.eclipse.jpt.common.utility.model.value.ListValueModel; |
22 |
import org.eclipse.jpt.common.utility.model.value.ListValueModel; |
| 19 |
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel; |
23 |
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel; |
| 20 |
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; |
24 |
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; |
|
|
25 |
import org.eclipse.jpt.jpa.core.context.PersistentType; |
| 21 |
import org.eclipse.jpt.jpa.core.context.RelationshipMapping; |
26 |
import org.eclipse.jpt.jpa.core.context.RelationshipMapping; |
|
|
27 |
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; |
| 22 |
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; |
28 |
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds; |
|
|
29 |
import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin; |
| 30 |
import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager; |
| 23 |
import org.eclipse.osgi.util.NLS; |
31 |
import org.eclipse.osgi.util.NLS; |
| 24 |
import org.eclipse.swt.widgets.Composite; |
32 |
import org.eclipse.swt.widgets.Composite; |
|
|
33 |
import org.eclipse.ui.IWorkbenchPage; |
| 34 |
import org.eclipse.ui.PartInitException; |
| 35 |
import org.eclipse.ui.PlatformUI; |
| 25 |
import org.eclipse.ui.forms.widgets.Hyperlink; |
36 |
import org.eclipse.ui.forms.widgets.Hyperlink; |
|
|
37 |
import org.eclipse.ui.ide.IDE; |
| 26 |
|
38 |
|
| 27 |
/** |
39 |
/** |
| 28 |
* target entity hyperlink label, combo and browse button |
40 |
* target entity hyperlink label, combo and browse button |
|
Lines 132-135
Link Here
|
| 132 |
} |
144 |
} |
| 133 |
return JptCommonUiMessages.DefaultEmpty; |
145 |
return JptCommonUiMessages.DefaultEmpty; |
| 134 |
} |
146 |
} |
|
|
147 |
|
| 148 |
/* |
| 149 |
* Duplicate persistent type case is not handled so the opened mapping file could be |
| 150 |
* any one of the existent mapping files that has the persistent type. |
| 151 |
* User needs to solve the duplicate problem to open the mapping file he wants to open. |
| 152 |
*/ |
| 153 |
protected void hyperLinkSelected() { |
| 154 |
String className = this.getFullyQualifiedClassName(); |
| 155 |
if (className != null) { |
| 156 |
PersistentType pType = this.getSubject().getPersistenceUnit().getPersistentType(className); |
| 157 |
if (pType instanceof OrmPersistentType) { |
| 158 |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
| 159 |
IFile file = ((OrmPersistentType)pType).getParent().getParent().getXmlResource().getFile(); |
| 160 |
openInEditor(page, file); |
| 161 |
setSelectionInEditor(page, pType); |
| 162 |
} else { |
| 163 |
IType type = JDTTools.findType(this.getJavaProject(), className); |
| 164 |
if (type != null) { |
| 165 |
openInEditor(type); |
| 166 |
} else { |
| 167 |
createType(); |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* Open the file in an editor of the active workbench page |
| 175 |
* @param page |
| 176 |
* @param file |
| 177 |
*/ |
| 178 |
private void openInEditor(IWorkbenchPage page, IFile file) { |
| 179 |
try { |
| 180 |
IDE.openEditor(page, file); |
| 181 |
} catch (PartInitException ex) { |
| 182 |
JptJpaUiPlugin.instance().logError(ex); |
| 183 |
} |
| 184 |
} |
| 185 |
/** |
| 186 |
* Set the selection to the persistent type in the editor |
| 187 |
* @param page |
| 188 |
* @param persistentType |
| 189 |
*/ |
| 190 |
|
| 191 |
private void setSelectionInEditor(IWorkbenchPage page, PersistentType persistentType) { |
| 192 |
JpaSelectionManager selectionManager = PlatformTools.getAdapter(page, JpaSelectionManager.class); |
| 193 |
selectionManager.setSelection(persistentType); |
| 194 |
} |
| 135 |
} |
195 |
} |