Skip to content

Commit dadf90b

Browse files
committed
FISH-6772 : showing the default console in Eclipse 2023 version
1 parent 836b970 commit dadf90b

1 file changed

Lines changed: 44 additions & 32 deletions

File tree

  • bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/handlers

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/handlers/MigrateHandler.java

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@
3232
import org.eclipse.jface.viewers.IStructuredSelection;
3333
import org.eclipse.swt.widgets.DirectoryDialog;
3434
import org.eclipse.swt.widgets.Shell;
35+
import org.eclipse.ui.IWorkbenchPage;
36+
import org.eclipse.ui.PartInitException;
3537
import org.eclipse.ui.PlatformUI;
3638
import org.eclipse.ui.console.ConsolePlugin;
3739
import org.eclipse.ui.console.IConsole;
40+
import org.eclipse.ui.console.IConsoleConstants;
41+
import org.eclipse.ui.console.IConsoleView;
3842
import org.eclipse.ui.console.MessageConsole;
3943
import org.eclipse.ui.console.MessageConsoleStream;
4044
import org.eclipse.ui.handlers.HandlerUtil;
@@ -113,38 +117,46 @@ private IStructuredSelection getSelection(ExecutionEvent event) {
113117
return null;
114118
}
115119

116-
private int runMvnCommand(String srcProjectPath, String srcPath, String targetPath) {
117-
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
118-
119-
MessageConsole console = new MessageConsole("Maven Command Console", null);
120-
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console});
121-
122-
MessageConsoleStream consoleStream = console.newMessageStream();
123-
124-
try {
125-
List<String> command = new ArrayList<>();
126-
command.add(getMvnCommand());
127-
command.add(getTransformCommand());
128-
command.add("-DselectedSource=" + srcPath);
129-
command.add("-DselectedTarget=" + targetPath);
130-
ProcessBuilder builder = new ProcessBuilder(command);
131-
builder.environment().put("PATH", System.getenv("PATH"));
132-
builder.directory(new File(srcProjectPath));
133-
builder.redirectErrorStream(true);
134-
Process process = builder.start();
135-
136-
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
137-
String line = null;
138-
while ((line = reader.readLine()) != null) {
139-
consoleStream.println(line);
140-
}
141-
142-
return process.waitFor();
143-
} catch (IOException | InterruptedException e) {
144-
MessageDialog.openError(shell, "Error", "An error occurred while running the Maven command: " + e.getMessage());
145-
return -1;
146-
}
147-
}
120+
private int runMvnCommand(String srcProjectPath, String srcPath, String targetPath) {
121+
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
122+
123+
MessageConsole console = new MessageConsole("Maven Command Console", null);
124+
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
125+
IConsoleView consoleView = null;
126+
127+
try {
128+
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
129+
consoleView = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
130+
console.activate();
131+
consoleView.display(console);
132+
133+
MessageConsoleStream consoleStream = console.newMessageStream();
134+
135+
List<String> command = new ArrayList<>();
136+
command.add(getMvnCommand());
137+
command.add(getTransformCommand());
138+
command.add("-DselectedSource=" + srcPath);
139+
command.add("-DselectedTarget=" + targetPath);
140+
ProcessBuilder builder = new ProcessBuilder(command);
141+
builder.environment().put("PATH", System.getenv("PATH"));
142+
builder.directory(new File(srcProjectPath));
143+
builder.redirectErrorStream(true);
144+
Process process = builder.start();
145+
146+
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
147+
String line = null;
148+
while ((line = reader.readLine()) != null) {
149+
consoleStream.println(line);
150+
}
151+
152+
return process.waitFor();
153+
} catch (IOException | InterruptedException | PartInitException e) {
154+
MessageDialog.openError(shell, "Error",
155+
"An error occurred while running the Maven command: " + e.getMessage());
156+
return -1;
157+
}
158+
}
159+
148160

149161
private String getTransformCommand() {
150162
return String.format("%s:%s:%s:run",

0 commit comments

Comments
 (0)