@Override public MTrimBar getTrim(MTrimmedWindow window, SideValue sv) { List<MTrimBar> bars = window.getTrimBars(); for (MTrimBar bar : bars) { if (bar.getSide() == sv) { return bar; } } // Didn't find a trim bar for the side, make one MTrimBar newBar = BasicFactoryImpl.eINSTANCE.createTrimBar(); // Assign default ids to the trim bars to match legacy eclipse if (sv == SideValue.TOP) { newBar.setElementId("org.eclipse.ui.main.menu"); // $NON-NLS-1$ } else if (sv == SideValue.BOTTOM) { newBar.setElementId("org.eclipse.ui.trim.status"); // $NON-NLS-1$ } else if (sv == SideValue.LEFT) { newBar.setElementId("org.eclipse.ui.trim.vertical1"); // $NON-NLS-1$ } else if (sv == SideValue.RIGHT) { newBar.setElementId("org.eclipse.ui.trim.vertical2"); // $NON-NLS-1$ } newBar.setSide(sv); window.getTrimBars().add(newBar); return newBar; }
private void testTrimContainer_Side( SideValue applicationState, SideValue userChange, SideValue newApplicationState) { MApplication application = createApplication(); MTrimmedWindow window = createTrimmedWindow(application); MTrimBar trimBar = BasicFactoryImpl.eINSTANCE.createTrimBar(); trimBar.setSide(applicationState); window.getTrimBars().add(trimBar); saveModel(); ModelReconciler reconciler = createModelReconciler(); reconciler.recordChanges(application); trimBar.setSide(userChange); Object serialize = reconciler.serialize(); application = createApplication(); window = (MTrimmedWindow) application.getChildren().get(0); trimBar = window.getTrimBars().get(0); trimBar.setSide(newApplicationState); Collection<ModelDelta> deltas = constructDeltas(application, serialize); assertEquals(newApplicationState, trimBar.getSide()); applyAll(deltas); if (userChange == applicationState) { // no change from the user, the new state is applied assertEquals(newApplicationState, trimBar.getSide()); } else { // user change must override application state assertEquals(userChange, trimBar.getSide()); } }