use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopGuiPipelineTransformContext method openReferencedObject.
public static final void openReferencedObject(PipelineMeta pipelineMeta, IVariables variables, ITransformMeta iTransformMeta, String objectDescription, int index) {
HopGui hopGui = HopGui.getInstance();
try {
IHasFilename hasFilename = iTransformMeta.loadReferencedObject(index, pipelineMeta.getMetadataProvider(), variables);
if (hasFilename != null) {
String filename = variables.resolve(hasFilename.getFilename());
// Is this object already loaded?
//
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
TabItemHandler tabItemHandler = perspective.findTabItemHandlerWithFilename(filename);
if (tabItemHandler != null) {
perspective.switchToTab(tabItemHandler);
} else {
hopGui.fileDelegate.fileOpen(filename);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error opening referenced object '" + objectDescription + "'", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopGuiFileDelegate method closeAllFiles.
public void closeAllFiles() {
for (IHopPerspective perspective : hopGui.getPerspectiveManager().getPerspectives()) {
List<TabItemHandler> tabItemHandlers = perspective.getItems();
if (tabItemHandlers != null) {
// Copy the list to avoid changing the list we're editing (closing items)
//
List<TabItemHandler> handlers = new ArrayList<>(tabItemHandlers);
for (TabItemHandler tabItemHandler : handlers) {
IHopFileTypeHandler typeHandler = tabItemHandler.getTypeHandler();
typeHandler.close();
}
}
}
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopDataOrchestrationPerspective method initialize.
@Override
public void initialize(HopGui hopGui, Composite parent) {
this.hopGui = hopGui;
this.parent = parent;
PropsUi props = PropsUi.getInstance();
composite = new Composite(parent, SWT.NONE);
FormLayout layout = new FormLayout();
layout.marginRight = props.getMargin();
layout.marginBottom = props.getMargin();
composite.setLayout(layout);
FormData formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.top = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.bottom = new FormAttachment(100, 0);
composite.setLayoutData(formData);
// A tab folder covers the complete area...
//
tabFolder = new CTabFolder(composite, SWT.MULTI | SWT.BORDER);
props.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
FormData fdLabel = new FormData();
fdLabel.left = new FormAttachment(0, 0);
fdLabel.right = new FormAttachment(100, 0);
fdLabel.top = new FormAttachment(0, 0);
fdLabel.bottom = new FormAttachment(100, 0);
tabFolder.setLayoutData(fdLabel);
tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {
@Override
public void close(CTabFolderEvent event) {
handleTabCloseEvent(event);
}
});
tabFolder.addListener(SWT.Selection, event -> handleTabSelectionEvent(event));
// Create tab item context menu
Menu menu = new Menu(tabFolder);
tabFolder.setMenu(menu);
tabFolder.addListener(SWT.MenuDetect, event -> handleTabMenuDetectEvent(event));
// Create menu item
MenuItem miClose = new MenuItem(menu, SWT.NONE);
miClose.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.Close.Button.Text"));
miClose.addListener(SWT.Selection, event -> {
if (activeItem != null) {
activeItem.getTypeHandler().close();
}
});
MenuItem miCloseOthers = new MenuItem(menu, SWT.NONE);
miCloseOthers.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.CloseOther.Button.Text"));
miCloseOthers.addListener(SWT.Selection, event -> {
TabItemHandler currentItem = activeItem;
items.forEach(item -> {
if (!item.equals(currentItem)) {
// FIXME: Works only if you activate the item
activeItem = item;
item.getTypeHandler().close();
}
});
});
MenuItem miCloseAll = new MenuItem(menu, SWT.NONE);
miCloseAll.setText(BaseMessages.getString(PKG, "DataOrchestrationPerspective.CloseAll.Button.Text"));
miCloseAll.addListener(SWT.Selection, event -> items.forEach(item -> {
// FIXME: Works only if you activate the item
activeItem = item;
item.getTypeHandler().close();
}));
// Support reorder tab item
new TabFolderReorder(tabFolder);
HopGuiKeyHandler.getInstance().addParentObjectToHandle(this);
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopDataOrchestrationPerspective method addWorkflow.
/**
* Add a new workflow tab to the tab folder...
*
* @param workflowMeta
* @return The file type handler
*/
public IHopFileTypeHandler addWorkflow(HopGui hopGui, WorkflowMeta workflowMeta, HopWorkflowFileType workflowFile) throws HopException {
CTabItem tabItem = new CTabItem(tabFolder, SWT.CLOSE);
tabItem.setImage(GuiResource.getInstance().getImageWorkflow());
HopGuiWorkflowGraph workflowGraph = new HopGuiWorkflowGraph(tabFolder, hopGui, tabItem, this, workflowMeta, workflowFile);
tabItem.setControl(workflowGraph);
// Update the internal variables (file specific) in the workflow graph variables
//
workflowMeta.setInternalHopVariables(workflowGraph.getVariables());
// Update the variables using the list of parameters
//
hopGui.setParametersAsVariablesInUI(workflowMeta, workflowGraph.getVariables());
// Set the tab name
//
updateTabLabel(tabItem, workflowMeta.getFilename(), workflowMeta.getName());
// Switch to the tab
tabFolder.setSelection(tabItem);
activeItem = new TabItemHandler(tabItem, workflowGraph);
items.add(activeItem);
//
while (tabSelectionHistory.size() - 1 > tabSelectionIndex) {
tabSelectionHistory.pop();
}
int tabIndex = tabFolder.indexOf(tabItem);
tabSelectionHistory.add(tabIndex);
tabSelectionIndex = tabSelectionHistory.size() - 1;
try {
ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), workflowGraph.getVariables(), HopExtensionPoint.HopGuiNewWorkflowTab.id, workflowGraph);
} catch (Exception e) {
throw new HopException("Error calling extension point plugin for plugin id " + HopExtensionPoint.HopGuiNewWorkflowTab.id + " trying to handle a new workflow tab", e);
}
workflowGraph.setFocus();
return workflowGraph;
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopGuiWorkflowActionContext method openReferencedObject.
public static final void openReferencedObject(WorkflowMeta workflowMeta, IVariables variables, IAction action, String objectDescription, int index) {
HopGui hopGui = HopGui.getInstance();
try {
IHasFilename hasFilename = action.loadReferencedObject(index, workflowMeta.getMetadataProvider(), variables);
if (hasFilename != null) {
String filename = variables.resolve(hasFilename.getFilename());
// Is this object already loaded?
//
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
TabItemHandler tabItemHandler = perspective.findTabItemHandlerWithFilename(filename);
if (tabItemHandler != null) {
perspective.switchToTab(tabItemHandler);
} else {
hopGui.fileDelegate.fileOpen(filename);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error opening referenced object '" + objectDescription + "'", e);
}
}
Aggregations