Skip to content

Commit

Permalink
Fix for issue apache#3169 : No more project reload after env change
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Nov 15, 2023
1 parent 6811da6 commit a2e5075
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public void applyCustomActionLogging(HopGuiWorkflowActionContext context) {
debugLevel = new ActionDebugLevel();
}

ActionDebugLevelDialog dialog = new ActionDebugLevelDialog(hopGui.getDisplay().getActiveShell(), debugLevel);
ActionDebugLevelDialog dialog = new ActionDebugLevelDialog(hopGui.getActiveShell(), debugLevel);
if (dialog.open()) {
DebugLevelUtil.storeActionDebugLevel(
debugGroupAttributesMap, action.toString(), debugLevel);
}

workflowMeta.setChanged();
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error changing action log settings", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error changing action log settings", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public void applyCustomTransformLogging(HopGuiPipelineTransformContext context)

IRowMeta inputRowMeta = pipelineMeta.getPrevTransformFields(variables, transformMeta);
TransformDebugLevelDialog dialog =
new TransformDebugLevelDialog(hopGui.getDisplay().getActiveShell(), debugLevel, inputRowMeta);
new TransformDebugLevelDialog(hopGui.getActiveShell(), debugLevel, inputRowMeta);
if (dialog.open()) {
DebugLevelUtil.storeTransformDebugLevel(
debugGroupAttributesMap, transformMeta.getName(), debugLevel);
}

pipelineMeta.setChanged();
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error changing transform log settings", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error changing transform log settings", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void editProject() {
try {
Project project = projectConfig.loadProject(hopGui.getVariables());
ProjectDialog projectDialog =
new ProjectDialog(hopGui.getDisplay().getActiveShell(), project, projectConfig, hopGui.getVariables(), true);
new ProjectDialog(hopGui.getActiveShell(), project, projectConfig, hopGui.getVariables(), true);
if (projectDialog.open() != null) {
config.addProjectConfig(projectConfig);

Expand Down Expand Up @@ -169,7 +169,7 @@ public void editProject() {
}
} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.EditProject.Error.Dialog.Header"),
BaseMessages.getString(
PKG, "ProjectGuiPlugin.EditProject.Error.Dialog.Message", projectName),
Expand All @@ -178,7 +178,7 @@ public void editProject() {
}

private boolean askAboutProjectRefresh(HopGui hopGui) {
MessageBox box = new MessageBox(hopGui.getDisplay().getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
MessageBox box = new MessageBox(hopGui.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.ReloadProject.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.ReloadProject.Dialog.Message"));
int answer = box.open();
Expand Down Expand Up @@ -282,7 +282,7 @@ public void selectProject() {
}
} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeProject.Error.Dialog.Header"),
BaseMessages.getString(
PKG, "ProjectGuiPlugin.ChangeProject.Error.Dialog.Message", projectName),
Expand Down Expand Up @@ -319,7 +319,7 @@ public void addNewProject() {
project.setParentProjectName(config.getStandardParentProject());

ProjectDialog projectDialog =
new ProjectDialog(hopGui.getDisplay().getActiveShell(), project, projectConfig, variables, false);
new ProjectDialog(hopGui.getActiveShell(), project, projectConfig, variables, false);
String projectName = projectDialog.open();
if (projectName != null) {
config.addProjectConfig(projectConfig);
Expand All @@ -334,7 +334,7 @@ public void addNewProject() {
project.saveToFile();
} else {
// If projects exists load configuration
MessageBox box = new MessageBox(hopGui.getDisplay().getActiveShell(), SWT.ICON_QUESTION | SWT.OK);
MessageBox box = new MessageBox(hopGui.getActiveShell(), SWT.ICON_QUESTION | SWT.OK);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Header"));
box.setMessage(
BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Message"));
Expand Down Expand Up @@ -421,7 +421,7 @@ public void addNewProject() {

} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Header"),
BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Message"),
e);
Expand Down Expand Up @@ -553,7 +553,7 @@ public void editEnvironment() {

try {
LifecycleEnvironmentDialog dialog =
new LifecycleEnvironmentDialog(hopGui.getDisplay().getActiveShell(), environment, hopGui.getVariables());
new LifecycleEnvironmentDialog(hopGui.getActiveShell(), environment, hopGui.getVariables());
if (dialog.open() != null) {
config.addEnvironment(environment);
ProjectsConfigSingleton.saveConfig();
Expand All @@ -573,7 +573,7 @@ public void editEnvironment() {
}
} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Header"),
BaseMessages.getString(
PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Message", environmentName),
Expand Down Expand Up @@ -619,7 +619,7 @@ public void selectEnvironment() {
}
} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.ChangeEnvironment.Error.Dialog.Header"),
BaseMessages.getString(
PKG, "ProjectGuiPlugin.ChangeEnvironment.Error.Dialog.Message", environmentName),
Expand Down Expand Up @@ -650,7 +650,7 @@ public void addNewEnvironment() {
LifecycleEnvironment environment =
new LifecycleEnvironment(null, "", projectName, new ArrayList<>());
LifecycleEnvironmentDialog dialog =
new LifecycleEnvironmentDialog(hopGui.getDisplay().getActiveShell(), environment, hopGui.getVariables());
new LifecycleEnvironmentDialog(hopGui.getActiveShell(), environment, hopGui.getVariables());
String environmentName = dialog.open();
if (environmentName != null) {
config.addEnvironment(environment);
Expand All @@ -667,7 +667,7 @@ public void addNewEnvironment() {
}
} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Header"),
BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Message"),
e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void callExtensionPoint(ILogChannel logChannelInterface, IVariables varia
logChannelInterface.logBasic("No last projects history found");
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error initializing the Projects system", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error initializing the Projects system", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void callExtensionPoint(
if (inputLocation != null) {
PipelineUnitTestSetLocationDialog dialog =
new PipelineUnitTestSetLocationDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
variables,
hopGui.getMetadataProvider(),
inputLocation,
Expand All @@ -121,7 +121,7 @@ public void callExtensionPoint(
if (goldenLocation != null) {
PipelineUnitTestSetLocationDialog dialog =
new PipelineUnitTestSetLocationDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
variables,
hopGui.getMetadataProvider(),
goldenLocation,
Expand Down Expand Up @@ -162,7 +162,7 @@ public void callExtensionPoint(
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error editing location", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error editing location", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public boolean editMetadata() {
}
return GuiContextUtil.getInstance()
.handleActionSelection(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
"Select the " + hopMetadata.name() + " to edit",
new GuiContextHandler("HopGuiMetadataContext", actions));

} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error editing metadata", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error editing metadata", e);
return false;
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public boolean deleteMetadata() {
new GuiContextHandler("HopGuiMetadaContext", actions));

} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error deleting metadata", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error deleting metadata", e);
return false;
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public boolean editMetadata(String elementName) {
}

} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error editing metadata", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error editing metadata", e);
return false;
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ public void editWithEditor(String name) {
perspective.setActiveEditor(editor);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error editing metadata", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error editing metadata", e);
}
}

Expand Down Expand Up @@ -462,7 +462,7 @@ public T newMetadataWithEditor() {

return element;
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error creating new metadata element", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error creating new metadata element", e);
return null;
}
}
Expand Down
9 changes: 9 additions & 0 deletions ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,15 @@ public void replaceKeyboardShortcutListeners(Control control, HopGuiKeyHandler k
}
}

public Shell getActiveShell() {
Shell active = display.getActiveShell();
if (active!=null) {
return active;
} else {
return shell;
}
}

/**
* Gets metadataProvider
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void openLastFiles() {
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error opening file '" + filename + "'", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error opening file '" + filename + "'", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void fileOpen() {
}
fileOpen(hopGui.getVariables().resolve(filename));
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error opening file", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error opening file", e);
}
}

Expand Down Expand Up @@ -164,7 +164,7 @@ public String fileSaveAs() {

return filename;
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error saving file", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error saving file", e);
return null;
}
}
Expand All @@ -186,7 +186,7 @@ public void fileSave() {
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error saving file", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error saving file", e);
}
}

Expand All @@ -199,7 +199,7 @@ public boolean fileClose() {
perspective.remove(typeHandler);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error saving/closing file", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error saving/closing file", e);
}
return false;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ public void fileOpenRecent() {
hopGui.fileDelegate.fileOpen(filename);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error getting list of recently opened files", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error getting list of recently opened files", e);
}
}

Expand Down Expand Up @@ -345,7 +345,7 @@ public void exportToSvg() {
FileObject file = HopVfs.getFileObject(realFilename);
if (file.exists()) {
MessageBox box =
new MessageBox(hopGui.getDisplay().getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
new MessageBox(hopGui.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("File exists");
box.setMessage("This file already exists. Do you want to overwrite it?");
int answer = box.open();
Expand All @@ -366,7 +366,7 @@ public void exportToSvg() {
}

} catch (Exception e) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error exporting to SVG", e);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error exporting to SVG", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ private boolean showTransformOutputData(TransformMeta dataTransformMeta, RowBuff

PreviewRowsDialog previewRowsDialog =
new PreviewRowsDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
variables,
SWT.NONE,
dataTransformMeta.getName(),
Expand All @@ -1224,7 +1224,7 @@ private boolean showTransformOutputData(TransformMeta dataTransformMeta, RowBuff
previewRowsDialog.open();
} catch (Exception ex) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(), "Error", "Error showing preview dialog", ex);
hopGui.getActiveShell(), "Error", "Error showing preview dialog", ex);
}
}
}
Expand Down Expand Up @@ -3378,7 +3378,7 @@ public void drawPipelineImage(GC swtGc, int width, int height) {

} catch (Exception e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(), "Error", "Error drawing pipeline image", e);
hopGui.getActiveShell(), "Error", "Error drawing pipeline image", e);
}
} finally {
gc.dispose();
Expand Down Expand Up @@ -3693,7 +3693,7 @@ public boolean editProperties(
return false;
}

Shell shell = hopGui.getDisplay().getActiveShell();
Shell shell = hopGui.getActiveShell();
if (shell == null) {
shell = hopGui.getShell();
}
Expand Down Expand Up @@ -3827,7 +3827,7 @@ public boolean isCloseable() {
String filename =
BaseDialog.presentFileDialog(
true,
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
fileType.getFilterExtensions(),
fileType.getFilterNames(),
true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void toClipboard(String clipText) {
GuiResource.getInstance().toClipboard(clipText);
} catch (Throwable e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "HopGui.Dialog.ExceptionCopyToClipboard.Title"),
BaseMessages.getString(PKG, "HopGui.Dialog.ExceptionCopyToClipboard.Message"),
e);
Expand All @@ -75,7 +75,7 @@ public String fromClipboard() {
return GuiResource.getInstance().fromClipboard();
} catch (Throwable e) {
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "HopGui.Dialog.ExceptionPasteFromClipboard.Title"),
BaseMessages.getString(PKG, "HopGui.Dialog.ExceptionPasteFromClipboard.Message"),
e);
Expand Down Expand Up @@ -273,7 +273,7 @@ private void pasteNoXmlContent(PipelineMeta pipelineMeta, String clipboardConten
// "Error pasting transforms...",
// "I was unable to paste transforms to this pipeline"
new ErrorDialog(
hopGui.getDisplay().getActiveShell(),
hopGui.getActiveShell(),
BaseMessages.getString(PKG, "HopGui.Dialog.UnablePasteTransforms.Title"),
BaseMessages.getString(PKG, "HopGui.Dialog.UnablePasteTransforms.Message"),
e);
Expand Down Expand Up @@ -338,7 +338,7 @@ public void copySelected(

toClipboard(xml.toString());
} catch (Exception ex) {
new ErrorDialog(hopGui.getDisplay().getActiveShell(), "Error", "Error encoding to XML", ex);
new ErrorDialog(hopGui.getActiveShell(), "Error", "Error encoding to XML", ex);
}
}

Expand Down
Loading

0 comments on commit a2e5075

Please sign in to comment.