use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class SpoonMenuABSController method updateMenu.
public void updateMenu(Document doc) {
try {
Spoon spoon = Spoon.getInstance();
boolean createPermitted = true;
boolean executePermitted = true;
// If we are working with an Enterprise Repository
if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
Repository repo = spoon.getRepository();
// Check for ABS Security
if (repo.hasService(IAbsSecurityProvider.class)) {
IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repo.getService(IAbsSecurityProvider.class);
// Get create & execute permission
createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
EngineMetaInterface meta = spoon.getActiveMeta();
// If (meta is not null) and (meta is either a Transformation or Job)
if ((meta != null) && ((meta instanceof JobMeta) || (meta instanceof TransMeta))) {
// Main spoon toolbar
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save-as")).setDisabled(!createPermitted);
// Popup menus
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-class-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("job-class-new")).setDisabled(!createPermitted);
// Main spoon menu
// $NON-NLS-1$
((XulMenu) doc.getElementById("file-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save-as")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-close")).setDisabled(!createPermitted);
}
// Handle Execute permissions
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("process-run")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-preview")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-debug")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-replay")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-verify")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-impact")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-get-sql")).setDisabled(!executePermitted);
// Disable Show Last menu under the Action menu. Disable without execute permissions.
// $NON-NLS-1$
((XulMenu) doc.getElementById("trans-last")).setDisabled(!executePermitted);
boolean exportAllowed = createPermitted && executePermitted;
// $NON-NLS-1$
((XulMenu) doc.getElementById("file-export")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("repository-export-all")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save-as-vfs")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-cut-steps")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-copy-steps")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit.copy-file")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-paste-steps")).setDisabled(!exportAllowed);
// Schedule is a plugin
if (doc.getElementById("trans-schedule") != null) {
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-schedule")).setDisabled(!executePermitted);
}
TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
if (transGraph != null) {
XulToolbar toolbar = transGraph.getToolbar();
XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("trans-run");
XulToolbarbutton debugButton = (XulToolbarbutton) toolbar.getElementById("trans-debug");
XulToolbarbutton previewButton = (XulToolbarbutton) toolbar.getElementById("trans-preview");
XulToolbarbutton replayButton = (XulToolbarbutton) toolbar.getElementById("trans-replay");
XulToolbarbutton verifyButton = (XulToolbarbutton) toolbar.getElementById("trans-verify");
XulToolbarbutton impactButton = (XulToolbarbutton) toolbar.getElementById("trans-impact");
XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("trans-get-sql");
if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
runButton.setDisabled(!executePermitted);
}
if ((debugButton != null) && (debugButton.isDisabled() ^ !executePermitted)) {
debugButton.setDisabled(!executePermitted);
}
if ((previewButton != null) && (previewButton.isDisabled() ^ !executePermitted)) {
previewButton.setDisabled(!executePermitted);
}
if ((replayButton != null) && (replayButton.isDisabled() ^ !executePermitted)) {
replayButton.setDisabled(!executePermitted);
}
if ((verifyButton != null) && (verifyButton.isDisabled() ^ !executePermitted)) {
verifyButton.setDisabled(!executePermitted);
}
if ((impactButton != null) && (impactButton.isDisabled() ^ !executePermitted)) {
impactButton.setDisabled(!executePermitted);
}
if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
generateSqlButton.setDisabled(!executePermitted);
}
}
JobGraph jobGraph = Spoon.getInstance().getActiveJobGraph();
if (jobGraph != null) {
XulToolbar toolbar = jobGraph.getToolbar();
XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("job-run");
XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("job-get-sql");
if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
runButton.setDisabled(!executePermitted);
}
if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
generateSqlButton.setDisabled(!executePermitted);
}
}
}
}
EESpoonPlugin.updateChangedWarningDialog(createPermitted);
} catch (Exception e) {
// don't let this bomb all the way out, otherwise we'll get stuck: PDI-4670
log.logError(e.getMessage(), e);
}
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class JobFileListener method save.
public boolean save(EngineMetaInterface meta, String fname, boolean export) {
Spoon spoon = Spoon.getInstance();
EngineMetaInterface lmeta;
if (export) {
lmeta = (JobMeta) ((JobMeta) meta).realClone(false);
} else {
lmeta = meta;
}
try {
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeSave.id, lmeta);
} catch (KettleException e) {
// fails gracefully
}
boolean saveStatus = spoon.saveMeta(lmeta, fname);
if (saveStatus) {
try {
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterSave.id, lmeta);
} catch (KettleException e) {
// fails gracefully
}
}
return saveStatus;
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method hasDupeFile.
/**
* Checks if there is a duplicate file in a given directory (i.e. hidden file)
* @param path - Path to directory in which we are saving
* @param name - Name of file to save
* @param fileName - Possible duplicate file name
* @param override - True is user wants override file, false otherwise
* @return - true if a duplicate file is found, false otherwise
*/
private boolean hasDupeFile(String path, String name, String fileName, boolean override) {
try {
RepositoryDirectoryInterface repositoryDirectoryInterface = getRepository().findDirectory(path);
EngineMetaInterface meta = getSpoon().getActiveMeta();
RepositoryObjectType type = "Trans".equals(meta.getFileType()) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB;
if (getRepository().exists(name, repositoryDirectoryInterface, type)) {
return !override || !name.equals(fileName);
}
} catch (Exception e) {
System.out.println(e);
}
return false;
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class Spoon method shareObject.
protected void shareObject(SharedObjectInterface sharedObject) {
sharedObject.setShared(true);
EngineMetaInterface meta = getActiveMeta();
try {
if (meta != null) {
SharedObjects sharedObjects = null;
if (meta instanceof TransMeta) {
sharedObjects = ((TransMeta) meta).getSharedObjects();
}
if (meta instanceof JobMeta) {
sharedObjects = ((JobMeta) meta).getSharedObjects();
}
if (sharedObjects != null) {
sharedObjects.storeObject(sharedObject);
sharedObjects.saveToFile();
}
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Message"), e);
}
refreshTree();
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class Spoon method enableMenus.
public void enableMenus() {
boolean disableTransMenu = getActiveTransformation() == null;
boolean disableJobMenu = getActiveJob() == null;
boolean disableMetaMenu = getActiveMeta() == null;
boolean isRepositoryRunning = rep != null;
boolean disablePreviewButton = true;
String activePerspectiveId = null;
SpoonPerspectiveManager manager = SpoonPerspectiveManager.getInstance();
if (manager != null && manager.getActivePerspective() != null) {
activePerspectiveId = manager.getActivePerspective().getId();
}
boolean etlPerspective = false;
if (activePerspectiveId != null && activePerspectiveId.length() > 0) {
etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
}
TransGraph transGraph = getActiveTransGraph();
if (transGraph != null) {
disablePreviewButton = !(transGraph.isRunning() && !transGraph.isHalting());
}
boolean disableSave = true;
boolean disableDatabaseExplore = true;
TabItemInterface currentTab = getActiveTabitem();
if (currentTab != null && currentTab.canHandleSave()) {
disableSave = !currentTab.hasContentChanged();
}
EngineMetaInterface meta = getActiveMeta();
if (meta != null) {
disableSave = !meta.canSave();
disableDatabaseExplore = false;
}
org.pentaho.ui.xul.dom.Document doc;
if (mainSpoonContainer != null) {
doc = mainSpoonContainer.getDocumentRoot();
if (doc != null) {
if (etlPerspective) {
doc.getElementById("file").setVisible(etlPerspective);
doc.getElementById("edit").setVisible(etlPerspective);
doc.getElementById("view").setVisible(etlPerspective);
doc.getElementById("action").setVisible(etlPerspective);
doc.getElementById("tools").setVisible(etlPerspective);
doc.getElementById("help").setVisible(etlPerspective);
doc.getElementById("help-welcome").setVisible(etlPerspective);
doc.getElementById("help-plugins").setVisible(true);
}
// Only enable certain menu-items if we need to.
disableMenuItem(doc, "file-new-database", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "menubar-new-database", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "file-save", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
disableMenuItem(doc, "toolbar-file-save", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
disableMenuItem(doc, "file-save-as", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
disableMenuItem(doc, "toolbar-file-save-as", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
disableMenuItem(doc, "file-save-as-vfs", disableTransMenu && disableJobMenu && disableMetaMenu);
disableMenuItem(doc, "file-close", disableTransMenu && disableJobMenu && disableMetaMenu);
disableMenuItem(doc, "file-print", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "file-export-to-xml", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "file-export-all-to-xml", disableTransMenu && disableJobMenu);
// Disable the undo and redo menus if there is no active transformation
// or active job
// DO NOT ENABLE them otherwise ... leave that to the undo/redo settings
//
disableMenuItem(doc, UNDO_MENU_ITEM, disableTransMenu && disableJobMenu);
disableMenuItem(doc, REDO_MENU_ITEM, disableTransMenu && disableJobMenu);
disableMenuItem(doc, "edit-clear-selection", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "edit-select-all", disableTransMenu && disableJobMenu);
updateSettingsMenu(doc, disableTransMenu, disableJobMenu);
disableMenuItem(doc, "edit-settings", disableTransMenu && disableJobMenu && disableMetaMenu);
// View Menu
((XulMenuitem) doc.getElementById("view-results")).setSelected(isExecutionResultsPaneVisible());
disableMenuItem(doc, "view-results", transGraph == null && disableJobMenu);
disableMenuItem(doc, "view-zoom-in", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "view-zoom-out", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "view-zoom-100pct", disableTransMenu && disableJobMenu);
// Transformations
disableMenuItem(doc, "process-run", disableTransMenu && disablePreviewButton && disableJobMenu);
disableMenuItem(doc, "process-run-options", disableTransMenu && disablePreviewButton && disableJobMenu);
disableMenuItem(doc, "trans-replay", disableTransMenu && disablePreviewButton);
disableMenuItem(doc, "trans-preview", disableTransMenu && disablePreviewButton);
disableMenuItem(doc, "trans-debug", disableTransMenu && disablePreviewButton);
disableMenuItem(doc, "trans-verify", disableTransMenu);
disableMenuItem(doc, "trans-impact", disableTransMenu);
disableMenuItem(doc, "trans-get-sql", disableTransMenu);
disableMenuItem(doc, "trans-last-impact", disableTransMenu);
// Tools
disableMenuItem(doc, "repository-explore", !isRepositoryRunning);
disableMenuItem(doc, "tools-dabase-explore", !isRepositoryRunning && disableDatabaseExplore);
disableMenuItem(doc, "repository-clear-shared-object-cache", !isRepositoryRunning);
disableMenuItem(doc, "toolbar-expore-repository", !isRepositoryRunning);
disableMenuItem(doc, "repository-export-all", !isRepositoryRunning);
disableMenuItem(doc, "repository-import-directory", !isRepositoryRunning);
disableMenuItem(doc, "trans-last-preview", !isRepositoryRunning || disableTransMenu);
// Wizard
disableMenuItem(doc, "wizard-connection", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "wizard-copy-table", disableTransMenu && disableJobMenu);
disableMenuItem(doc, "wizard-copy-tables", isRepositoryRunning && disableTransMenu && disableJobMenu);
disableMenuItem(doc, "database-inst-dependancy", !isRepositoryRunning);
SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.MENUS_REFRESHED);
MenuManager menuManager = getMenuBarManager();
menuManager.updateAll(true);
// What steps & plugins to show?
refreshCoreObjects();
fireMenuControlers();
}
}
}
Aggregations