Search in sources :

Example 1 with INamedEditPart

use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart in project webtools.sourceediting by eclipse.

the class LabelEditManager method initCellEditor.

protected void initCellEditor() {
    Text text = (Text) getCellEditor().getControl();
    Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
    if (label != null) {
        scaledFont = label.getFont();
        Color color = label.getBackgroundColor();
        text.setBackground(color);
        String initialLabelText = label.getText();
        getCellEditor().setValue(initialLabelText);
    } else {
        scaledFont = label.getParent().getFont();
        text.setBackground(label.getParent().getBackgroundColor());
    }
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, data.getHeight());
    label.getParent().translateToAbsolute(fontSize);
    data.setHeight(fontSize.height);
    scaledFont = new Font(null, data);
    text.setFont(scaledFont);
    // text.selectAll();
    // Hook the cell editor's copy/paste actions to the actionBars so that they can
    // be invoked via keyboard shortcuts.
    actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(actionBars);
    actionHandler = new CellEditorActionHandler(actionBars);
    actionHandler.addCellEditor(getCellEditor());
    actionBars.updateActionBars();
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.draw2d.Label) INamedEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) Font(org.eclipse.swt.graphics.Font)

Example 2 with INamedEditPart

use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart in project webtools.sourceediting by eclipse.

the class TopLevelNameDirectEditManager method initCellEditor.

protected void initCellEditor() {
    Text text = (Text) getCellEditor().getControl();
    Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
    if (label != null) {
        scaledFont = label.getFont();
        Color color = label.getBackgroundColor();
        text.setBackground(color);
        String initialLabelText = component.getName();
        getCellEditor().setValue(initialLabelText);
    } else {
        scaledFont = label.getParent().getFont();
        text.setBackground(label.getParent().getBackgroundColor());
    }
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, data.getHeight());
    label.getParent().translateToAbsolute(fontSize);
    data.setHeight(fontSize.height);
    scaledFont = new Font(null, data);
    text.setFont(scaledFont);
    // text.selectAll();
    // Hook the cell editor's copy/paste actions to the actionBars so that they
    // can
    // be invoked via keyboard shortcuts.
    actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(actionBars);
    actionHandler = new CellEditorActionHandler(actionBars);
    actionHandler.addCellEditor(getCellEditor());
    actionBars.updateActionBars();
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.draw2d.Label) INamedEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) Font(org.eclipse.swt.graphics.Font)

Aggregations

Label (org.eclipse.draw2d.Label)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Color (org.eclipse.swt.graphics.Color)2 Font (org.eclipse.swt.graphics.Font)2 FontData (org.eclipse.swt.graphics.FontData)2 Text (org.eclipse.swt.widgets.Text)2 CellEditorActionHandler (org.eclipse.ui.part.CellEditorActionHandler)2 INamedEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart)2