use of org.apache.hop.ui.hopgui.file.empty.EmptyFileType in project hop by apache.
the class ExplorerPerspective method onTabClose.
protected void onTabClose(CTabFolderEvent event) {
CTabItem tabItem = (CTabItem) event.item;
ExplorerFile file = (ExplorerFile) tabItem.getData();
if (file.getFileTypeHandler().isCloseable()) {
files.remove(file);
tabItem.dispose();
// Refresh tree to remove bold
//
this.refresh();
//
if (tabFolder.getItemCount() == 0) {
HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
}
updateGui();
} else {
// Ignore event if canceled
event.doit = false;
}
}
use of org.apache.hop.ui.hopgui.file.empty.EmptyFileType in project hop by apache.
the class HopGui method open.
/**
* Build the shell
*/
protected void open() {
shell.setImage(GuiResource.getInstance().getImageHopUiTaskbar());
shell.setText(BaseMessages.getString(PKG, "HopGui.Application.Name"));
addMainMenu();
addMainToolbar();
addPerspectivesToolbar();
addMainPerspectivesComposite();
handleFileCapabilities(new EmptyFileType(), false, false, false);
loadPerspectives();
replaceKeyboardShortcutListeners(this);
shell.addListener(SWT.Close, this::closeEvent);
BaseTransformDialog.setSize(shell);
// Open the Hop GUI shell
//
shell.open();
if (EnvironmentUtils.getInstance().isWeb()) {
shell.setMaximized(true);
}
display.asyncExec(() -> {
openingLastFiles = true;
//
try {
ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopGuiStart.id, this);
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error calling extension point '" + HopExtensionPoint.HopGuiStart.id + "'", e);
}
//
if (openingLastFiles) {
auditDelegate.openLastFiles();
}
});
// On RAP, return here otherwise UIThread doesn't get terminated properly.
if (EnvironmentUtils.getInstance().isWeb()) {
return;
}
boolean retry = true;
while (retry) {
try {
//
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
retry = false;
} catch (Throwable throwable) {
System.err.println("Error in the Hop GUI : " + throwable.getMessage() + Const.CR + Const.getClassicStackTrace(throwable));
}
}
display.dispose();
}
use of org.apache.hop.ui.hopgui.file.empty.EmptyFileType in project hop by apache.
the class MetadataPerspective method remove.
@Override
public boolean remove(IHopFileTypeHandler typeHandler) {
if (typeHandler instanceof MetadataEditor) {
MetadataEditor<?> editor = (MetadataEditor<?>) typeHandler;
if (editor.isCloseable()) {
editors.remove(editor);
for (CTabItem item : tabFolder.getItems()) {
if (editor.equals(item.getData())) {
item.dispose();
}
}
// Refresh tree to remove bold
//
this.refresh();
//
if (tabFolder.getItemCount() == 0) {
HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
}
}
}
return false;
}
use of org.apache.hop.ui.hopgui.file.empty.EmptyFileType in project hop by apache.
the class MetadataPerspective method onTabClose.
protected void onTabClose(CTabFolderEvent event) {
CTabItem tabItem = (CTabItem) event.item;
MetadataEditor<?> editor = (MetadataEditor<?>) tabItem.getData();
if (editor.isCloseable()) {
editors.remove(editor);
tabItem.dispose();
// Refresh tree to remove bold
//
this.refresh();
//
if (tabFolder.getItemCount() == 0) {
HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
}
} else {
// Ignore event if canceled
event.doit = false;
}
}
use of org.apache.hop.ui.hopgui.file.empty.EmptyFileType in project hop by apache.
the class HopDataOrchestrationPerspective method handleTabCloseEvent.
private void handleTabCloseEvent(CTabFolderEvent event) {
// A tab is closed. We need to handle this gracefully.
// - Look up which tab it is
// - Look up which file it contains
// - Save the file if it was changed
// - Remove the tab and file from the list
//
CTabItem tabItem = (CTabItem) event.item;
int tabIndex = tabFolder.indexOf(tabItem);
TabItemHandler tabItemHandler = findTabItemHandler(tabItem);
if (tabItemHandler == null) {
hopGui.getLog().logError("Tab item handler not found for tab item " + tabItem.toString());
return;
}
IHopFileTypeHandler typeHandler = tabItemHandler.getTypeHandler();
boolean isRemoved = remove(typeHandler);
// Ignore event if canceled
if (!isRemoved) {
event.doit = false;
return;
}
//
if (tabIndex >= 0) {
// Remove the index from the tab selection history
//
int historyIndex = tabSelectionHistory.indexOf(tabIndex);
while (historyIndex >= 0) {
if (historyIndex <= tabSelectionIndex) {
tabSelectionIndex--;
}
tabSelectionHistory.remove(historyIndex);
// Search again
historyIndex = tabSelectionHistory.indexOf(tabIndex);
}
// Compress the history: 2 the same files visited after each other become one.
//
Stack<Integer> newHistory = new Stack<>();
Integer previous = null;
for (int i = 0; i < tabSelectionHistory.size(); i++) {
Integer index = tabSelectionHistory.get(i);
if (previous == null || previous != index) {
newHistory.add(index);
} else {
if (tabSelectionIndex >= i) {
tabSelectionIndex--;
}
}
previous = index;
}
tabSelectionHistory = newHistory;
//
for (int i = 0; i < tabSelectionHistory.size(); i++) {
int index = tabSelectionHistory.get(i);
if (index > tabIndex) {
tabSelectionHistory.set(i, index--);
}
}
//
if (tabSelectionIndex < 0) {
tabSelectionIndex = 0;
} else if (tabSelectionIndex >= tabSelectionHistory.size()) {
tabSelectionIndex = tabSelectionHistory.size() - 1;
}
if (!tabSelectionHistory.isEmpty()) {
Integer activeIndex = tabSelectionHistory.get(tabSelectionIndex);
if (activeIndex < items.size()) {
activeItem = items.get(activeIndex);
tabFolder.setSelection(activeIndex);
activeItem.getTypeHandler().updateGui();
}
}
//
if (tabFolder.getItemCount() == 0) {
HopGui.getInstance().handleFileCapabilities(new EmptyFileType(), false, false, false);
}
}
}
Aggregations