Search in sources :

Example 1 with RefEntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method updateEditorRel.

public void updateEditorRel(TableItem item) {
    // Clean up any previous editor control
    Control oldEditorRel = editorRel.getEditor();
    if (oldEditorRel != null) {
        oldEditorRel.dispose();
    }
    CCombo comboRel = new CCombo(table, SWT.NONE);
    comboRel.setEditable(false);
    Color bkgnd = table.getBackground();
    comboRel.setBackground(bkgnd);
    comboRel.add(JdtUiMessages.ResolveAmbiguous_empty);
    String fullyQualifiedName = item.getText(0);
    RefEntityInfo rei = (RefEntityInfo) item.getData();
    Set<RefFieldInfo> setRefEntityInfo = findRelatedRefFieldInfos(fullyQualifiedName, rei);
    Iterator<RefFieldInfo> itTmp = setRefEntityInfo.iterator();
    while (itTmp.hasNext()) {
        RefFieldInfo rfi = itTmp.next();
        comboRel.add(rfi.fieldId);
    }
    if (null != rei.mappedBy) {
        comboRel.setText(rei.mappedBy);
    } else {
        comboRel.setText(JdtUiMessages.ResolveAmbiguous_empty);
    }
    comboRel.addModifyListener(editorRelModifyListener);
    // comboRel.selectAll();
    // comboRel.setFocus();
    editorRel.setEditor(comboRel, item, COLUMN_RELATED);
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) Color(org.eclipse.swt.graphics.Color) RefFieldInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo)

Example 2 with RefEntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo 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);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) TableEditor(org.eclipse.swt.custom.TableEditor) RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) GridLayout(org.eclipse.swt.layout.GridLayout) RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) GridData(org.eclipse.swt.layout.GridData) Map(java.util.Map)

Example 3 with RefEntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method updateTI.

public void updateTI(TableItem ti) {
    if (ti == null) {
        return;
    }
    RefEntityInfo rei = (RefEntityInfo) ti.getData();
    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));
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo)

Example 4 with RefEntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method findRelatedRefFieldInfos.

protected Set<RefFieldInfo> findRelatedRefFieldInfos(String fullyQualifiedName, RefEntityInfo rei) {
    String fullyQualifiedName2 = rei.fullyQualifiedName;
    EntityInfo entryInfo2 = data.getEntities().get(fullyQualifiedName2);
    Set<RefFieldInfo> setRefEntityInfo = entryInfo2.getRefFieldInfoSet(fullyQualifiedName);
    return setRefEntityInfo;
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) RefFieldInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo)

Example 5 with RefEntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method updateEditorType.

public void updateEditorType(TableItem item) {
    // Clean up any previous editor control
    Control oldEditorType = editorType.getEditor();
    if (oldEditorType != null) {
        oldEditorType.dispose();
    }
    // The control that will be the editor must be a child of the Table
    CCombo comboType = new CCombo(table, SWT.NONE);
    comboType.setEditable(false);
    Color bkgnd = table.getBackground();
    comboType.setBackground(bkgnd);
    RefEntityInfo rei = (RefEntityInfo) item.getData();
    comboType.add(Utils.refTypeToStr(RefType.ONE2ONE));
    comboType.add(Utils.refTypeToStr(RefType.ONE2MANY));
    comboType.add(Utils.refTypeToStr(RefType.MANY2ONE));
    comboType.add(Utils.refTypeToStr(RefType.MANY2MANY));
    comboType.add(Utils.refTypeToStr(RefType.UNDEF));
    comboType.setText(Utils.refTypeToStr(rei.refType));
    comboType.addModifyListener(editorTypeModifyListener);
    // comboType.selectAll();
    comboType.setFocus();
    editorType.setEditor(comboType, item, COLUMN_TYPE);
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) Color(org.eclipse.swt.graphics.Color)

Aggregations

RefEntityInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo)10 EntityInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo)4 RefFieldInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo)4 CCombo (org.eclipse.swt.custom.CCombo)3 Color (org.eclipse.swt.graphics.Color)3 Control (org.eclipse.swt.widgets.Control)3 Map (java.util.Map)2 ArrayType (org.eclipse.jdt.core.dom.ArrayType)2 MarkerAnnotation (org.eclipse.jdt.core.dom.MarkerAnnotation)2 MemberValuePair (org.eclipse.jdt.core.dom.MemberValuePair)2 NormalAnnotation (org.eclipse.jdt.core.dom.NormalAnnotation)2 NumberLiteral (org.eclipse.jdt.core.dom.NumberLiteral)2 SimpleType (org.eclipse.jdt.core.dom.SimpleType)2 Type (org.eclipse.jdt.core.dom.Type)2 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)2 FieldGetterType (org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo.FieldGetterType)2 OwnerType (org.hibernate.eclipse.jdt.ui.internal.jpa.common.OwnerType)2 RefColumnInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefColumnInfo)2 RefType (org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType)2 TreeMap (java.util.TreeMap)1