synchronized private void layoutTrim(MTrimBar trimBar) { Composite comp = (Composite) trimBar.getWidget(); if (comp == null || comp.isDisposed()) return; if (layoutJob == null) { layoutJob = new LayoutJob(); layoutJob.barsToLayout.add(trimBar); comp.getDisplay().asyncExec(layoutJob); } else if (!layoutJob.barsToLayout.contains(trimBar)) { layoutJob.barsToLayout.add(trimBar); } }
public void run() { layoutJob = null; if (barsToLayout.size() == 0) return; for (MTrimBar bar : barsToLayout) { Composite trimCtrl = (Composite) bar.getWidget(); if (trimCtrl != null && !trimCtrl.isDisposed()) trimCtrl.layout(); } } }
@Override public void run() { layoutJob = null; if (barsToLayout.isEmpty()) return; for (MTrimBar bar : barsToLayout) { Composite trimCtrl = (Composite) bar.getWidget(); if (trimCtrl != null && !trimCtrl.isDisposed()) trimCtrl.layout(); } } }
synchronized private void layoutTrim(MTrimBar trimBar) { Composite comp = (Composite) trimBar.getWidget(); if (comp == null || comp.isDisposed()) return; if (layoutJob == null) { layoutJob = new LayoutJob(); layoutJob.barsToLayout.add(trimBar); comp.getDisplay().asyncExec(layoutJob); } else if (!layoutJob.barsToLayout.contains(trimBar)) { layoutJob.barsToLayout.add(trimBar); } }
@Override public boolean changed(IEclipseContext context) { if (!trimModel.isToBeRendered() || !trimModel.isVisible() || trimModel.getWidget() == null) { return false; } boolean rc = ContributionsAnalyzer.isVisible( contribution, eContext); for (MTrimElement child : toRemove) { child.setToBeRendered(rc); } return true; } });
@Override public boolean changed(IEclipseContext context) { if (!trimModel.isToBeRendered() || !trimModel.isVisible() || trimModel.getWidget() == null) { return false; } boolean rc = ContributionsAnalyzer.isVisible( contribution, eContext); for (MTrimElement child : toRemove) { child.setToBeRendered(rc); } return true; } });
public static boolean processAddition(final MTrimBar trimBar, MTrimContribution contribution, List<MTrimElement> contributions, HashSet<String> existingToolbarIds) { int idx = getIndex(trimBar, contribution.getPositionInParent()); if (idx == -1) { return false; } for (MTrimElement item : contribution.getChildren()) { if (item instanceof MToolBar && existingToolbarIds.contains(item.getElementId())) { // skip this, it's already there continue; } MTrimElement copy = (MTrimElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addTrimContribution " + copy, trimBar.getWidget(), trimBar); //$NON-NLS-1$ } trimBar.getChildren().add(idx++, copy); contributions.add(copy); if (copy instanceof MToolBar && copy.getElementId() != null) { existingToolbarIds.add(copy.getElementId()); } } return true; }
private int getFixedSides() { Composite trimComp = (Composite) bar.getWidget(); Rectangle trimBounds = trimComp.getBounds(); Point trimCenter = new Point(trimBounds.width / 2, trimBounds.height / 2); // adjusted to // (0,0) Control trimCtrl = (Control) toolControl.getWidget(); Rectangle ctrlBounds = trimCtrl.getBounds(); Point ctrlCenter = new Point(ctrlBounds.x + (ctrlBounds.width / 2), ctrlBounds.y + (ctrlBounds.height / 2)); if (bar.getSide() == SideValue.LEFT) { int verticalValue = ctrlCenter.y < trimCenter.y ? SWT.TOP : SWT.BOTTOM; return SWT.LEFT | verticalValue; } else if (bar.getSide() == SideValue.RIGHT) { int verticalValue = ctrlCenter.y < trimCenter.y ? SWT.TOP : SWT.BOTTOM; return SWT.RIGHT | verticalValue; } else if (bar.getSide() == SideValue.TOP) { int horizontalValue = ctrlCenter.x < trimCenter.x ? SWT.LEFT : SWT.RIGHT; return SWT.TOP | horizontalValue; } else if (bar.getSide() == SideValue.BOTTOM) { int horizontalValue = ctrlCenter.x < trimCenter.x ? SWT.LEFT : SWT.RIGHT; return SWT.BOTTOM | horizontalValue; } return SWT.BOTTOM | SWT.RIGHT; }
private int getFixedSides() { MUIElement tcParent = toolControl.getParent(); if (!(tcParent instanceof MTrimBar)) { return 0; } MTrimBar bar = (MTrimBar) tcParent; Composite trimComp = (Composite) bar.getWidget(); Rectangle trimBounds = trimComp.getBounds(); Point trimCenter = new Point(trimBounds.width / 2, trimBounds.height / 2); // adjusted to // (0,0) Control trimCtrl = (Control) toolControl.getWidget(); Rectangle ctrlBounds = trimCtrl.getBounds(); Point ctrlCenter = new Point(ctrlBounds.x + (ctrlBounds.width / 2), ctrlBounds.y + (ctrlBounds.height / 2)); if (bar.getSide() == SideValue.LEFT) { int verticalValue = ctrlCenter.y < trimCenter.y ? SWT.TOP : SWT.BOTTOM; return SWT.LEFT | verticalValue; } else if (bar.getSide() == SideValue.RIGHT) { int verticalValue = ctrlCenter.y < trimCenter.y ? SWT.TOP : SWT.BOTTOM; return SWT.RIGHT | verticalValue; } else if (bar.getSide() == SideValue.TOP) { int horizontalValue = ctrlCenter.x < trimCenter.x ? SWT.LEFT : SWT.RIGHT; return SWT.TOP | horizontalValue; } else if (bar.getSide() == SideValue.BOTTOM) { int horizontalValue = ctrlCenter.x < trimCenter.x ? SWT.LEFT : SWT.RIGHT; return SWT.BOTTOM | horizontalValue; } return SWT.BOTTOM | SWT.RIGHT; }
private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) return null; TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimPos); if (trimCtrl == null) return null; if (trimCtrl == dragElement.getWidget()) return dragElement; // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info)) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) return null; return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }
private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) { return null; } TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimComp, trimPos); if (trimCtrl == null || dragElement.getWidget() == null) { return null; } if (trimCtrl == dragElement.getWidget()) { return dragElement; } // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info) && trimElement != null) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) { return null; } return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }
if (bar.getWidget() == null) {
if (bar.getWidget() == null) {