// But staleness in this view is not detected for some reason
}
@Override
public void actionPerformed(ActionEvent e) {
View housedView = isHousing ?
housing.getContentArea().getHousedViewManifestation() :
view.getHousedViewManifestation();
// Should not be null per canHandle, but check for safety
if (housedView != null) {
boolean doRefresh = true;
// Give the user an opportunity to cancel the refresh if it would
// overwrite unsaved changes.
if (housedView.getManifestedComponent().isDirty()) {
Map<String, Object> hints = new HashMap<String, Object>();
hints.put(WindowManagerImpl.MESSAGE_TYPE, OptionBox.WARNING_MESSAGE);
hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
hints.put(WindowManagerImpl.PARENT_COMPONENT, housing);
String ok = BUNDLE.getString("RefreshAction.ok"); //NOI18N
String cancel = BUNDLE.getString("RefreshAction.cancel"); //NOI18N
String input = PlatformAccess.getPlatform().getWindowManager().showInputDialog(
BUNDLE.getString("RefreshAction.title"), //NOI18N
BUNDLE.getString("RefreshAction.warning"), //NOI18N
new String[]{ok, cancel},
ok,
hints);
doRefresh = ok.equals(input);
}
// Perform the refresh by re-creating view
if (doRefresh) {
// Update component from persistence
AbstractComponent comp = housedView.getManifestedComponent();
comp = PlatformAccess.getPlatform().getPersistenceProvider().getComponent(comp.getComponentId());
housedView.setManifestedComponent(comp);
// Re-create view
ViewInfo vi = housedView.getInfo();
if (isHousing) {
View newView = vi.createView(comp);
housing.getContentArea().setOwnerComponentCanvasManifestation(newView);
} else {
housedView.setManifestedComponent(comp);
view.setHousedViewManifestation(vi);
}