use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.
the class MantleTabPanel method closeTab.
public void closeTab(final PentahoTab closeTab, final boolean invokePreTabCloseHook) {
if (closeTab.getContent() instanceof IFrameTabPanel) {
final Element frameElement = ((IFrameTabPanel) closeTab.getContent()).getFrame().getElement();
String frameId = frameElement.getAttribute("id").replaceAll("\"", "\\\"");
// #a"b1494409287116 need to be escaped to #a\"b1494409287116.
if (frameId.indexOf("\"") != -1) {
frameId = frameId.replaceAll("\"", "");
frameElement.setAttribute("id", frameId);
}
final String finalFrameId = frameId;
if (invokePreTabCloseHook && hasUnsavedChanges(frameElement)) {
// prompt user
VerticalPanel vp = new VerticalPanel();
// $NON-NLS-1$
vp.add(new Label(Messages.getString("confirmTabClose")));
final PromptDialogBox confirmDialog = new PromptDialogBox(Messages.getString("confirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
confirmDialog.setCallback(new IDialogCallback() {
public void cancelPressed() {
}
public void okPressed() {
fireCloseTab(finalFrameId);
((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
clearClosingFrame(frameElement);
MantleTabPanel.super.closeTab(closeTab, invokePreTabCloseHook);
if (getTabCount() == 0) {
allTabsClosed();
Widget selectTabContent = null;
if (getTab(getSelectedTabIndex()) != null) {
selectTabContent = getTab(getSelectedTabIndex()).getContent();
}
List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
}
}
});
confirmDialog.center();
return;
}
fireCloseTab(finalFrameId);
((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
clearClosingFrame(frameElement);
}
super.closeTab(closeTab, invokePreTabCloseHook);
// since we can't entirely reclaim the frame resources held, keep some around
// so we can minimize the extra leakage caused by constantly created more
// let's only keep 5 of these guys around so at least some of the resources
// can be cleaned up (maybe just wishful thinking)
Widget w = closeTab.getContent();
if (w instanceof IFrameTabPanel && freeFrames.size() < 5) {
// wipe out any file info so it doesn't impact future usages of this frame
SolutionFileInfo sfi = null;
IFrameTabPanel iFrameTabPanel = (IFrameTabPanel) w;
iFrameTabPanel.setFileInfo(sfi);
freeFrames.add(iFrameTabPanel);
}
if (getTabCount() == 0) {
allTabsClosed();
Widget selectTabContent = null;
if (getTab(getSelectedTabIndex()) != null) {
selectTabContent = getTab(getSelectedTabIndex()).getContent();
}
List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
}
}
use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.
the class MantleTabPanel method enableContentEdit.
public void enableContentEdit(boolean enable) {
IFrameTabPanel panel = getCurrentFrame();
if (panel != null) {
panel.setEditEnabled(enable);
Widget selectTabContent = null;
if (getTab(getSelectedTabIndex()) != null) {
selectTabContent = getTab(getSelectedTabIndex()).getContent();
}
List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserUndefinedEvent(selectTabContent, selectedItems));
}
}
use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.
the class MantleTabPanel method closeTab.
/**
* Called by JSNI call from parameterized xaction prompt pages to "cancel". The only 'key' to pass up is the URL. To
* handle the possibility of multiple tabs with the same url, this method first checks the assumption that the current
* active tab initiates the call. Otherwise it checks from tail up for the first tab with a matching url and closes
* that one. *
*
* @param url
*/
private void closeTab(String url) {
int curpos = getSelectedTabIndex();
if (StringUtils.isEmpty(url)) {
// and then remove
if (curpos >= 0 && getTabCount() > 0) {
closeTab(curpos, true);
}
}
PentahoTab pt = getTab(curpos);
if (pt != null && pt.getContent() != null) {
IFrameTabPanel curPanel = (IFrameTabPanel) getTab(curpos).getContent();
if (url.contains(curPanel.getUrl())) {
closeTab(curpos, true);
}
for (int i = getTabCount() - 1; i >= 0; i--) {
curPanel = (IFrameTabPanel) getTab(i).getContent();
if (url.contains(curPanel.getUrl())) {
closeTab(i, true);
break;
}
}
}
if (getTabCount() == 0) {
allTabsClosed();
}
}
use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.
the class MantleModel method handleSolutionBrowserEvent.
private void handleSolutionBrowserEvent(Widget panel, FileItem selectedFileItem) {
this.selectedFileItem = selectedFileItem;
setPropertiesEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
setSaveEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
setSaveAsEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
boolean saveEnabled = false;
boolean editIsEnabled = false;
boolean editSelected = false;
boolean printVisible = false;
JavaScriptObject callback = null;
if (panel != null && panel instanceof IFrameTabPanel) {
IFrameTabPanel tbp = (IFrameTabPanel) panel;
saveEnabled = tbp.isSaveEnabled();
editIsEnabled = tbp.isEditEnabled();
editSelected = tbp.isEditSelected();
printVisible = tbp.isPrintVisible();
}
setSaveEnabled(saveEnabled);
setSaveAsEnabled(saveEnabled);
setContentEditEnabled(editIsEnabled);
setContentEditSelected(editSelected);
setPrintVisible(printVisible);
setCallback(callback);
this.showNavigatorSelected = SolutionBrowserPanel.getInstance().isNavigatorShowing();
setShowBrowserSelected(this.showNavigatorSelected);
}
use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.
the class MantleTab method openTabInNewWindow.
public void openTabInNewWindow() {
if (getContent() instanceof IFrameTabPanel) {
VerticalPanel vp = new VerticalPanel();
// $NON-NLS-1$
vp.add(new Label(Messages.getString("openWindowQuestion")));
final MantleDialogBox openNewWindowConfirmDialog = new MantleDialogBox(Messages.getString("openWindowConfirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
openNewWindowConfirmDialog.hide();
}
public void okPressed() {
((IFrameTabPanel) getContent()).openTabInNewWindow();
openNewWindowConfirmDialog.hide();
}
};
openNewWindowConfirmDialog.setCallback(callback);
openNewWindowConfirmDialog.center();
}
}
Aggregations