use of org.apache.hop.ui.core.metadata.MetadataEditor 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);
}
}
}
}
use of org.apache.hop.ui.core.metadata.MetadataEditor 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.core.metadata.MetadataEditor 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;
}
}
Aggregations