Skip to content

Commit

Permalink
EXM-46209: CR -> avoid exceptions on constructors, create a separate …
Browse files Browse the repository at this point in the history
…method to throw the exception
  • Loading branch information
AlexSmarandache15 committed Oct 2, 2024
1 parent d342f7b commit 0c458e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void actionPerformed(ActionEvent e) {
LOGGER.debug("Advanced pull action invoked");
}
AdvancedPullDialog pullToConfigDialog = new AdvancedPullDialog(gitController);
pullToConfigDialog.setVisible(true);
pullToConfigDialog.showDialog();
if(pullToConfigDialog.getResult() == OKCancelDialog.RESULT_OK) {
PullConfig pullConfig = pullToConfigDialog.getPullConfig();
if(pullConfig != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void actionPerformed(ActionEvent arg0) {
*/
private void setRemote() {
try {
new CurrentBranchRemotesDialog();
new CurrentBranchRemotesDialog().showDialog();
} catch(RemoteNotFoundException ex) {
if(ex.getStatus() == RemoteNotFoundException.STATUS_REMOTE_NOT_EXISTS) {
OKCancelDialog addRemoteDialog = new AddRemoteDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,24 @@ public class AdvancedPullDialog extends OKCancelDialog {

/**
* Constructor.
*
* @throws RemoteNotFoundException This exception appear when a remote is not found.
*/
public AdvancedPullDialog(final GitController gitCtrl) throws RemoteNotFoundException {
public AdvancedPullDialog(final GitController gitCtrl) {
super((JFrame) PluginWorkspaceProvider.getPluginWorkspace().getParentFrame(),
TRANSLATOR.getTranslation(Tags.PULL),
true);

this.gitCtrl = gitCtrl;
currentBranch = gitCtrl.getGitAccess().getBranchInfo().getBranchName();
}


/**
* This message shows the dialog.
*
* @throws RemoteNotFoundException When the remote repository or branches cannot be found.
*/
public void showDialog() throws RemoteNotFoundException {

setOkButtonText(TRANSLATOR.getTranslation(Tags.PULL_CHANGES));

RemotesViewUtil.installRemoteBranchesRenderer(remoteBranchItems);
Expand All @@ -120,6 +128,7 @@ public AdvancedPullDialog(final GitController gitCtrl) throws RemoteNotFoundExce
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

this.setResizable(false);
setVisible(true);
}


Expand Down Expand Up @@ -272,7 +281,7 @@ public void actionPerformed(ActionEvent e) {
@Override
protected void doOK() {
RemoteBranch currentSelectedBranch = (RemoteBranch) remoteBranchItems.getSelectedItem();
if(!currentSelectedBranch.isUndefined()) {
if(!RemoteBranch.UNDEFINED_BRANCH.equals(currentSelectedBranch)) {
pullConfig = PullConfig
.builder()
.branchName(Optional.of(currentSelectedBranch.getBranchFullName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ public CurrentBranchRemotesDialog() throws RemoteNotFoundException {

setOkButtonText(TRANSLATOR.getTranslation(Tags.TRACK_BRANCH));
currentBranch = GitAccess.getInstance().getBranchInfo().getBranchName();
}


/**
* This message shows the dialog.
*
* @throws RemoteNotFoundException When the remote repository or branches cannot be found.
*/
public void showDialog() throws RemoteNotFoundException {
try {
RemotesViewUtil.installRemoteBranchesRenderer(remoteBranchItems);
RemotesViewUtil.addRemoteBranches(remoteBranchItems, currentBranch);
Expand All @@ -95,8 +103,8 @@ public CurrentBranchRemotesDialog() throws RemoteNotFoundException {

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

this.setVisible(true);
this.setResizable(false);
this.setVisible(true);
}


Expand Down

0 comments on commit 0c458e9

Please sign in to comment.