use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopWorkflowFileType method openFile.
@Override
public IHopFileTypeHandler openFile(HopGui hopGui, String filename, IVariables parentVariableSpace) throws HopException {
try {
// This file is opened in the data orchestration perspective
//
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
perspective.activate();
// See if the same workflow isn't already open.
// Other file types we might allow to open more than once but not workflows for now.
//
TabItemHandler tabItemHandlerWithFilename = perspective.findTabItemHandlerWithFilename(filename);
if (tabItemHandlerWithFilename != null) {
// Same file so we can simply switch to it.
// This will prevent confusion.
//
perspective.switchToTab(tabItemHandlerWithFilename);
return tabItemHandlerWithFilename.getTypeHandler();
}
// Load the workflow from file
//
WorkflowMeta workflowMeta = new WorkflowMeta(parentVariableSpace, filename, hopGui.getMetadataProvider());
// Pass the MetaStore for reference lookups
//
workflowMeta.setMetadataProvider(hopGui.getMetadataProvider());
// Keep track of open...
//
AuditManager.registerEvent(HopNamespace.getNamespace(), "file", filename, "open");
// Inform those that want to know about it that we loaded a pipeline
//
ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), parentVariableSpace, "WorkflowAfterOpen", workflowMeta);
//
return perspective.addWorkflow(hopGui, workflowMeta, this);
} catch (Exception e) {
throw new HopException("Error opening workflow file '" + filename + "'", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopDataOrchestrationPerspective method addPipeline.
/**
* Add a new pipeline tab to the tab folder...
*
* @param pipelineMeta
* @return
*/
public IHopFileTypeHandler addPipeline(HopGui hopGui, PipelineMeta pipelineMeta, HopPipelineFileType pipelineFile) throws HopException {
CTabItem tabItem = new CTabItem(tabFolder, SWT.CLOSE);
tabItem.setImage(GuiResource.getInstance().getImagePipeline());
HopGuiPipelineGraph pipelineGraph = new HopGuiPipelineGraph(tabFolder, hopGui, tabItem, this, pipelineMeta, pipelineFile);
tabItem.setControl(pipelineGraph);
// Set the tab name
//
updateTabLabel(tabItem, pipelineMeta.getFilename(), pipelineMeta.getName());
// Update the internal variables (file specific) in the pipeline graph variables
//
pipelineMeta.setInternalHopVariables(pipelineGraph.getVariables());
// Update the variables using the list of parameters
//
hopGui.setParametersAsVariablesInUI(pipelineMeta, pipelineGraph.getVariables());
// Switch to the tab
tabFolder.setSelection(tabItem);
activeItem = new TabItemHandler(tabItem, pipelineGraph);
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(), pipelineGraph.getVariables(), HopExtensionPoint.HopGuiNewPipelineTab.id, pipelineGraph);
} catch (Exception e) {
throw new HopException("Error calling extension point plugin for plugin id " + HopExtensionPoint.HopGuiNewPipelineTab.id + " trying to handle a new pipeline tab", e);
}
pipelineGraph.adjustScrolling();
pipelineGraph.setFocus();
return pipelineGraph;
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopDataOrchestrationPerspective method getSearchables.
@Override
public List<ISearchable> getSearchables() {
List<ISearchable> searchables = new ArrayList<>();
for (final TabItemHandler item : items) {
// The type handler is the pipeline or workflow
//
IHopFileTypeHandler typeHandler = item.getTypeHandler();
searchables.add(new ISearchable() {
@Override
public String getLocation() {
return "Data orchestration perspective in tab : " + item.getTabItem().getText();
}
@Override
public String getName() {
return typeHandler.getName();
}
@Override
public String getType() {
return typeHandler.getFileType().getName();
}
@Override
public String getFilename() {
return typeHandler.getFilename();
}
@Override
public Object getSearchableObject() {
return typeHandler.getSubject();
}
@Override
public ISearchableCallback getSearchCallback() {
return (searchable, searchResult) -> {
activate();
switchToTab(item);
};
}
});
}
return searchables;
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopDataOrchestrationPerspective method remove.
/**
* Remove the file type handler from this perspective, from the tab folder. This simply tries to
* remove the item, does not
*
* @param typeHandler The file type handler to remove
* @return true if the handler was removed from the perspective, false if it wasn't (cancelled,
* not possible, ...)
*/
@Override
public boolean remove(IHopFileTypeHandler typeHandler) {
TabItemHandler tabItemHandler = findTabItemHandler(typeHandler);
if (tabItemHandler == null) {
return false;
}
if (typeHandler.isCloseable()) {
// Remove the tab item handler from the list
// Then close the tab item...
//
items.remove(tabItemHandler);
CTabItem tabItem = tabItemHandler.getTabItem();
tabItem.dispose();
// Also remove the keyboard shortcuts for this handler
//
HopGuiKeyHandler.getInstance().removeParentObjectToHandle(typeHandler);
hopGui.getMainHopGuiComposite().setFocus();
if (typeHandler.getSubject() != null) {
if (typeHandler.getSubject() instanceof PipelineMeta) {
try {
ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), hopGui.getVariables(), HopExtensionPoint.HopGuiPipelineAfterClose.id, typeHandler.getSubject());
} catch (Exception e) {
hopGui.getLog().logError("Error calling extension point 'HopGuiPipelineAfterClose'", e);
}
} else if (typeHandler.getSubject() instanceof WorkflowMeta) {
try {
ExtensionPointHandler.callExtensionPoint(hopGui.getLog(), hopGui.getVariables(), HopExtensionPoint.HopGuiWorkflowAfterClose.id, typeHandler.getSubject());
} catch (Exception e) {
hopGui.getLog().logError("Error calling extension point 'HopGuiWorkflowAfterClose'", e);
}
}
}
return true;
}
return false;
}
use of org.apache.hop.ui.hopgui.perspective.TabItemHandler in project hop by apache.
the class HopGuiAuditDelegate method writeLastOpenFiles.
/**
* Remember all the open files per perspective
*/
public void writeLastOpenFiles() {
if (!hopGui.getProps().openLastFile()) {
return;
}
List<IHopPerspective> perspectives = hopGui.getPerspectiveManager().getPerspectives();
for (IHopPerspective perspective : perspectives) {
IHopFileTypeHandler activeFileTypeHandler = perspective.getActiveFileTypeHandler();
List<TabItemHandler> tabItems = perspective.getItems();
if (tabItems != null) {
// This perspective has the ability to handle multiple files.
// Lets's save the files in the given order...
//
AuditStateMap auditStateMap = new AuditStateMap();
List<String> files = new ArrayList<>();
for (TabItemHandler tabItem : tabItems) {
IHopFileTypeHandler typeHandler = tabItem.getTypeHandler();
String filename = typeHandler.getFilename();
String name = typeHandler.getName();
if (StringUtils.isNotEmpty(filename)) {
// Regular filename
//
files.add(filename);
// Also save the state : active, zoom, ...
//
Map<String, Object> stateProperties = typeHandler.getStateProperties();
boolean active = activeFileTypeHandler != null && activeFileTypeHandler.getFilename() != null && activeFileTypeHandler.getFilename().equals(filename);
stateProperties.put(STATE_PROPERTY_ACTIVE, active);
auditStateMap.add(new AuditState(filename, stateProperties));
} else if (typeHandler instanceof MetadataEditor<?>) {
//
if (StringUtils.isNotEmpty(name)) {
// Metadata saved by name
// We also need to store the metadata type...
//
MetadataEditor<?> metadataEditor = (MetadataEditor<?>) typeHandler;
IHopMetadata metadata = metadataEditor.getMetadata();
Class<? extends IHopMetadata> metadataClass = metadata.getClass();
// Save as METADATA:className:name
//
files.add(METADATA_FILENAME_PREFIX + metadataClass.getName() + ":" + name);
}
}
}
AuditList auditList = new AuditList(files);
try {
AuditManager.getActive().storeList(HopNamespace.getNamespace(), perspective.getId(), auditList);
AuditManager.getActive().saveAuditStateMap(HopNamespace.getNamespace(), perspective.getId(), auditStateMap);
} catch (Exception e) {
hopGui.getLog().logError("Error writing audit list of perspective " + perspective.getId(), e);
}
}
}
}
Aggregations