Search in sources :

Example 1 with Border

use of org.eclipse.draw2d.Border in project tdi-studio-se by Talend.

the class ZoneContentLayout method layout.

@Override
public void layout(IFigure parent) {
    Rectangle vBounds = null;
    if (parent.getParent() instanceof Viewport) {
        vBounds = ((Viewport) parent.getParent()).getBounds();
    }
    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
        hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
        wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    List children = parent.getChildren();
    int numChildren = children.size();
    Rectangle clientArea = transposer.t(parent.getClientArea());
    int x = clientArea.x;
    int y = clientArea.y;
    int availableHeight = clientArea.height;
    Dimension[] prefSizes = new Dimension[numChildren];
    Dimension[] minSizes = new Dimension[numChildren];
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int prefMinSumHeight = 0;
    int connSize = 0;
    // boolean isLookupConnMax = true;
    for (int i = 0; i < numChildren; i++) {
        child = (IFigure) children.get(i);
        prefSizes[i] = transposer.t(getChildPreferredSize(child, wHint, hHint));
        minSizes[i] = transposer.t(getChildMinimumSize(child, wHint, hHint));
        totalHeight += prefSizes[i].height;
        totalMinHeight += minSizes[i].height;
        if (child instanceof AbstractTableContainer) {
            connSize = getLookupConnectionSize((AbstractTableContainer) child);
        }
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;
    int defaultSize = DEFAULT_OFFSET;
    for (int i = 0; i < numChildren; i++) {
        int amntShrinkCurrentHeight = 0;
        int prefHeight = prefSizes[i].height;
        int minHeight = minSizes[i].height;
        int prefWidth = prefSizes[i].width;
        int minWidth = minSizes[i].width;
        child = (IFigure) children.get(i);
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        if (connSize > 0) {
            newBounds = new Rectangle(x + (connSize - 1) * defaultSize, y, prefWidth, prefHeight);
        }
        Border border = parent.getBorder();
        Insets insets = border.getInsets(child);
        if (vBounds != null) {
            newBounds.width = vBounds.width - insets.left - insets.right;
            if (connSize > 0) {
                newBounds.width = newBounds.width - (connSize - 1) * defaultSize;
            }
        }
        newBounds.height -= amntShrinkCurrentHeight;
        child.setBounds(transposer.t(newBounds));
        prefMinSumHeight -= (prefHeight - minHeight);
        y += newBounds.height + spacing;
    }
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Viewport(org.eclipse.draw2d.Viewport) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTableContainer(org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer) Border(org.eclipse.draw2d.Border) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with Border

use of org.eclipse.draw2d.Border in project tdi-studio-se by Talend.

the class TalendDrawerFigure method getTitleBorder.

protected Border getTitleBorder() {
    Insets insets = cssStyleSetting.getTitleMarginBorder().getInsets(null);
    Border talendTitleBorder = new MarginBorder(insets.top, insets.left + customizedCSSStyleSetting.getXOffset() * childLevel, insets.bottom, insets.right);
    return talendTitleBorder;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) MarginBorder(org.eclipse.draw2d.MarginBorder) Border(org.eclipse.draw2d.Border) MarginBorder(org.eclipse.draw2d.MarginBorder)

Example 3 with Border

use of org.eclipse.draw2d.Border in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    super.selectionChanged(part, selection);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    JobSettingsView view = (JobSettingsView) page.findView(JobSettingsView.ID);
    getDiagramEditorInput().getItem().getProperty().eAdapters().remove(dirtyListener);
    if (view == null) {
        return;
    }
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    Object firstElement = ((IStructuredSelection) selection).getFirstElement();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    } else if (firstElement instanceof RepositoryNode) {
        return;
    }
    // for Find Assignment
    if (((IStructuredSelection) selection).size() > 0) {
        DiagramEditPart diagramEditPart = getDiagramEditPart();
        if (diagramEditPart instanceof BusinessProcessEditPart) {
            BusinessProcessEditPart processPart = (BusinessProcessEditPart) diagramEditPart;
            for (Object object : processPart.getChildren()) {
                if (object instanceof BusinessItemShapeEditPart) {
                    BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) object;
                    IFigure figure = shapEditPart.getFigure();
                    for (Object child : figure.getChildren()) {
                        if (child instanceof BusinessItemShapeFigure) {
                            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                            Border border = shapFigure.getBorder();
                            if (border != null) {
                                shapFigure.setDrawFrame(false);
                                shapFigure.revalidate();
                                shapFigure.repaint();
                            }
                        }
                    }
                }
            }
        }
    }
    // to refresh the jobsettings view
    if (((IStructuredSelection) selection).size() > 1) {
        view.cleanDisplay();
    } else {
        if (firstElement instanceof BusinessItemShapeEditPart || firstElement instanceof BaseBusinessItemRelationShipEditPart || firstElement instanceof NoteEditPart || firstElement instanceof NoteAttachmentEditPart) {
            view.refresh(false, firstElement);
        } else if (firstElement instanceof BusinessProcessEditPart || firstElement instanceof CompartmentEditPart) {
            view.refresh(true, this);
        }
    }
    getDiagramEditorInput().getItem().getProperty().eAdapters().add(dirtyListener);
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) CompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart) NoteEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) NoteAttachmentEditPart(org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Border(org.eclipse.draw2d.Border) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with Border

use of org.eclipse.draw2d.Border in project dbeaver by serge-rider.

the class FigureEditorLocator method relocate.

/**
 * expands the size of the control by 1 pixel in each direction
 */
@Override
public void relocate(CellEditor celleditor) {
    Border border = figure.getBorder();
    // Insets insets = border.getInsets(figure);
    Dimension borderSize = border.getPreferredSize(figure);
    Text text = (Text) celleditor.getControl();
    Rectangle rect = figure.getBounds().getCopy();
    figure.translateToAbsolute(rect);
    text.setBackground(figure.getBackgroundColor());
    text.setBounds(rect.x + borderSize.width, rect.y + borderSize.height, rect.width - borderSize.width * 2, rect.height - borderSize.height * 2);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) Border(org.eclipse.draw2d.Border)

Example 5 with Border

use of org.eclipse.draw2d.Border in project dbeaver by dbeaver.

the class FigureEditorLocator method relocate.

/**
 * expands the size of the control by 1 pixel in each direction
 */
@Override
public void relocate(CellEditor celleditor) {
    Border border = figure.getBorder();
    // Insets insets = border.getInsets(figure);
    Dimension borderSize = border.getPreferredSize(figure);
    Text text = (Text) celleditor.getControl();
    Rectangle rect = figure.getBounds().getCopy();
    figure.translateToAbsolute(rect);
    text.setBackground(figure.getBackgroundColor());
    text.setBounds(rect.x + borderSize.width, rect.y + borderSize.height, rect.width - borderSize.width * 2, rect.height - borderSize.height * 2);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) Border(org.eclipse.draw2d.Border)

Aggregations

Border (org.eclipse.draw2d.Border)5 Dimension (org.eclipse.draw2d.geometry.Dimension)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 IFigure (org.eclipse.draw2d.IFigure)2 Insets (org.eclipse.draw2d.geometry.Insets)2 Text (org.eclipse.swt.widgets.Text)2 List (java.util.List)1 MarginBorder (org.eclipse.draw2d.MarginBorder)1 Viewport (org.eclipse.draw2d.Viewport)1 CompartmentEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart)1 DiagramEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart)1 NoteEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart)1 NoteAttachmentEditPart (org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 BaseBusinessItemRelationShipEditPart (org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart)1 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)1 BusinessItemShapeFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure)1 BusinessProcessEditPart (org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart)1