-
Notifications
You must be signed in to change notification settings - Fork 8
Add cli config tol eclipse #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
84a3111
Update XrayGlobalConfiguration.java
eyalk007 d7c8617
Update XrayGlobalConfiguration.java
eyalk007 50f9ed6
Create CliDriverWrapper.java
eyalk007 e1bd060
added error handeling
eyalk007 4ee7be3
fix up bugs
eyalk007 87a12ad
fix up bugs
eyalk007 98a868a
added the appropriate error handling
eyalk007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
bundle/src/main/java/com/jfrog/ide/eclipse/configuration/CliDriverWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.jfrog.ide.eclipse.configuration; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import org.eclipse.jface.dialogs.ErrorDialog; | ||
| import org.eclipse.swt.widgets.Display; | ||
| import org.eclipse.swt.widgets.Shell; | ||
| import org.eclipse.core.runtime.IStatus; | ||
| import org.eclipse.core.runtime.Status; | ||
|
|
||
| import com.jfrog.ide.common.configuration.JfrogCliDriver; | ||
| import com.jfrog.ide.eclipse.log.Logger; | ||
|
|
||
| public class CliDriverWrapper { | ||
|
|
||
| private static CliDriverWrapper instance; | ||
|
|
||
| public static final String CLIENT_ID_SERVER = "eclipse"; | ||
| public static final String CLI_VERSION = "2.74.1"; | ||
| public static final Path HOME_PATH = Paths.get(System.getProperty("user.home"), ".jfrog-eclipse-plugin"); | ||
|
|
||
| private JfrogCliDriver cliDriver; | ||
|
|
||
| private CliDriverWrapper() { | ||
| try { | ||
| Files.createDirectories(HOME_PATH); | ||
| } catch (Exception e) { | ||
| showCliError("An error occurred while creating the JFrog Eclipse plugin directory:",e); | ||
| } | ||
| // Initialize the cliDriver and download CLI if needed | ||
| this.cliDriver = new JfrogCliDriver(null, Logger.getInstance()); | ||
| try { | ||
| this.cliDriver.downloadCliIfNeeded(HOME_PATH.toString(), CLI_VERSION); | ||
| } catch (IOException e) { | ||
| showCliError("An error occurred while downloading the JFrog cli:",e); | ||
| } | ||
| } | ||
|
|
||
| public static CliDriverWrapper getInstance() { | ||
| if (instance == null) { | ||
| synchronized (CliDriverWrapper.class) { | ||
| if (instance == null) { | ||
| instance = new CliDriverWrapper(); | ||
| } | ||
| } | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| public JfrogCliDriver getCliDriver() { | ||
| return cliDriver; | ||
| } | ||
|
|
||
| public void showCliError(String errorTitle,Exception e) { | ||
| Logger.getInstance().error(e.getMessage(), e); | ||
| IStatus status = new Status(IStatus.ERROR, "jfrog-eclipse-plugin",e.getMessage(), e); | ||
|
|
||
| // Run UI-related code on the main UI thread | ||
| Display.getDefault().asyncExec(() -> { | ||
| Shell shell = Display.getDefault().getActiveShell(); | ||
| if (shell != null) { | ||
| ErrorDialog.openError(shell, "Error", errorTitle, status); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can maybe save all the error texts in a const and call to it.
i dont really care but we can do that if you want