@Override public boolean savePart(MPart part, boolean confirm) { if (!part.isDirty()) { return true; } if (saveHandler != null) { return saveHandler.save(part, confirm); } Object client = part.getObject(); try { ContextInjectionFactory.invoke(client, Persist.class, part.getContext()); } catch (InjectionException e) { log( "Failed to persist contents of part", "Failed to persist contents of part ({0})", //$NON-NLS-1$ //$NON-NLS-2$ part.getElementId(), e); return false; } catch (RuntimeException e) { log( "Failed to persist contents of part via DI", //$NON-NLS-1$ "Failed to persist contents of part ({0}) via DI", part.getElementId(), e); //$NON-NLS-1$ return false; } return true; }
public void testCreateView() { final MWindow window = createWindowWithOneView("Part Name"); MApplication application = ApplicationFactoryImpl.eINSTANCE.createApplication(); application.getChildren().add(window); application.setContext(appContext); appContext.set(MApplication.class.getName(), application); wb = new E4Workbench(application, appContext); wb.createAndRunUI(window); MPartSashContainer container = (MPartSashContainer) window.getChildren().get(0); MPartStack stack = (MPartStack) container.getChildren().get(0); MPart part = (MPart) stack.getChildren().get(0); CTabFolder folder = (CTabFolder) stack.getWidget(); CTabItem item = folder.getItem(0); assertEquals("Part Name", item.getText()); assertFalse(part.isDirty()); part.setDirty(true); assertEquals("*Part Name", item.getText()); part.setDirty(false); assertEquals("Part Name", item.getText()); }
@Override public Collection<MPart> getDirtyParts() { List<MPart> dirtyParts = new ArrayList<>(); for (MPart part : getParts()) { if (part.isDirty()) { dirtyParts.add(part); } } return dirtyParts; }