use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class ResolveAmbiguous method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 1;
Label label = new Label(container, SWT.NULL);
label.setText(JdtUiMessages.ResolveAmbiguous_message);
table = new Table(container, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
createTableColumns(table);
TableItem ti = null;
Iterator<Map.Entry<String, EntityInfo>> it = data.getEntities().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, EntityInfo> entry = it.next();
if (entry.getValue().isAbstractFlag()) {
continue;
}
// collectModification(bufferManager, entry.getKey(), entry.getValue());
Iterator<Map.Entry<String, RefEntityInfo>> referencesIt = entry.getValue().getReferences().entrySet().iterator();
while (referencesIt.hasNext()) {
Map.Entry<String, RefEntityInfo> entryRef = referencesIt.next();
RefEntityInfo rei = entryRef.getValue();
ti = new TableItem(table, SWT.NONE);
ti.setData(rei);
ti.setText(COLUMN_CLASS, entry.getKey());
String shortName = getShortName(rei.fullyQualifiedName);
// $NON-NLS-1$
ti.setText(COLUMN_PROPERTY, shortName + " " + entryRef.getKey());
ti.setText(COLUMN_TYPE, Utils.refTypeToStr(rei.refType));
if (null != rei.mappedBy) {
ti.setText(COLUMN_RELATED, rei.mappedBy);
} else {
ti.setText(COLUMN_RELATED, JdtUiMessages.ResolveAmbiguous_empty);
}
ti.setText(COLUMN_OWNER, Utils.ownerTypeToStr(rei.owner));
}
}
//
editorType = new TableEditor(table);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editorType.horizontalAlignment = SWT.LEFT;
editorType.grabHorizontal = true;
editorType.minimumWidth = 50;
//
editorRel = new TableEditor(table);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editorRel.horizontalAlignment = SWT.LEFT;
editorRel.grabHorizontal = true;
editorRel.minimumWidth = 50;
//
editorOwner = new TableEditor(table);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editorOwner.horizontalAlignment = SWT.LEFT;
editorOwner.grabHorizontal = true;
editorOwner.minimumWidth = 50;
// editing the second column
table.addSelectionListener(new TableSelectionListener());
GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
data.heightHint = convertHeightInCharsToPixels(10);
table.setLayoutData(data);
setControl(container);
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class JPAMapToolActor method updateOpen.
/**
* update compilation unit of currently opened editor
* @param depth - process depth
*/
public void updateOpen(int depth) {
IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null) {
return;
}
IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
if (page == null) {
return;
}
IEditorPart editor = page.getActiveEditor();
if (editor instanceof CompilationUnitEditor) {
CompilationUnitEditor cue = (CompilationUnitEditor) editor;
ICompilationUnit cu = (ICompilationUnit) cue.getViewPartInput();
if (cu != null) {
addCompilationUnit(cu);
collector.initCollector();
collector.collect(cu, depth);
collector.resolveRelations();
if (collector.getNonInterfaceCUNumber() > 0) {
Map<String, EntityInfo> mapCUs_Info = collector.getMapCUs_Info();
IStructuredSelection selection2Update = createSelection2Update();
processor.modify(mapCUs_Info, true, selection2Update);
} else {
MessageDialog.openInformation(getShell(), JdtUiMessages.JPAMapToolActor_message_title, JdtUiMessages.JPAMapToolActor_message);
}
}
}
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class AllEntitiesInfoCollector method collect.
/**
* start to collect information from particular entity class and
* its dependencies
* @param icu - startup point entity compilation unit
* @param depth - process depth
*/
public void collect(ICompilationUnit icu, int depth) {
if (icu == null || depth < 0) {
return;
}
org.eclipse.jdt.core.dom.CompilationUnit cu = Utils.getCompilationUnit(icu, true);
if (cu == null) {
return;
}
if (cu.types() == null || cu.types().size() == 0) {
return;
}
boolean hasTypeDeclaration = false;
Iterator<?> it = cu.types().iterator();
while (it.hasNext()) {
Object tmp = it.next();
if (tmp instanceof TypeDeclaration) {
hasTypeDeclaration = true;
break;
}
}
if (!hasTypeDeclaration) {
// ignore EnumDeclaration & AnnotationTypeDeclaration
return;
}
IJavaProject javaProject = icu.getJavaProject();
// $NON-NLS-1$
String projectName = (javaProject != null) ? javaProject.getProject().getName() : "";
ArrayList<String> fullyQualifiedNames = new ArrayList<String>();
// TODO: should inspect all types in cu? so next method to get fullyQualifiedName:
if (cu.getTypeRoot() == null || cu.getTypeRoot().findPrimaryType() == null) {
it = cu.types().iterator();
while (it.hasNext()) {
Object tmp = it.next();
if (tmp instanceof TypeDeclaration) {
fullyQualifiedNames.add(((TypeDeclaration) tmp).resolveBinding().getBinaryName());
}
}
} else {
fullyQualifiedNames.add(cu.getTypeRoot().findPrimaryType().getFullyQualifiedName());
}
Iterator<String> itFQNames = fullyQualifiedNames.iterator();
while (itFQNames.hasNext()) {
String fullyQualifiedName = itFQNames.next();
if (!mapCUs_Info.containsKey(projectName + "/" + fullyQualifiedName)) {
// $NON-NLS-1$
CollectEntityInfo finder = new CollectEntityInfo(fullyQualifiedName);
cu.accept(finder);
EntityInfo result = finder.getEntityInfo();
if (result != null) {
result.adjustParameters();
result.setJavaProjectName(projectName);
// $NON-NLS-1$
mapCUs_Info.put(projectName + "/" + fullyQualifiedName, result);
if (depth > 0) {
Iterator<String> itDep = result.getDependences();
while (itDep.hasNext()) {
String fullyQualifiedNameTmp = itDep.next();
collect(fullyQualifiedNameTmp, projectName, depth - 1);
}
}
}
}
}
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class AllEntitiesInfoCollector method getNonAbstractCUNumber.
public int getNonAbstractCUNumber() {
Iterator<Map.Entry<String, EntityInfo>> it = null;
int nonAbstractCUNumber = 0;
// generate RefFieldInfoMap (for simple process)
it = mapCUs_Info.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, EntityInfo> entry = it.next();
EntityInfo entryInfo = entry.getValue();
if (!entryInfo.isAbstractFlag()) {
nonAbstractCUNumber++;
}
}
return nonAbstractCUNumber;
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class AllEntitiesInfoCollector method getNonInterfaceCUNumber.
public int getNonInterfaceCUNumber() {
Iterator<Map.Entry<String, EntityInfo>> it = null;
int nonInterfaceCUNumber = 0;
// generate RefFieldInfoMap (for simple process)
it = mapCUs_Info.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, EntityInfo> entry = it.next();
EntityInfo entryInfo = entry.getValue();
if (!entryInfo.isInterfaceFlag()) {
nonInterfaceCUNumber++;
}
}
return nonInterfaceCUNumber;
}
Aggregations