-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLE-921: Overhaul dialogs and handle cases
Overhaul the dialogs to also show information when the suggestion change cannot be applied. Handle the cases differently when the user cancels the action, when the suggestion cannot be applied.
- Loading branch information
Showing
9 changed files
with
209 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
49 changes: 49 additions & 0 deletions
49
...eclipse.ui/src/org/sonarlint/eclipse/ui/internal/dialog/FixSuggestionAvailableDialog.java
This file contains 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,49 @@ | ||
/* | ||
* SonarLint for Eclipse | ||
* Copyright (C) 2015-2024 SonarSource SA | ||
* [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonarlint.eclipse.ui.internal.dialog; | ||
|
||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.sonarlint.eclipse.core.analysis.SonarLintLanguage; | ||
|
||
/** Version of the dialog where the fix suggestion is available! */ | ||
public class FixSuggestionAvailableDialog extends AbstractFixSuggestionDialog { | ||
public FixSuggestionAvailableDialog(Shell parentShell, @Nullable SonarLintLanguage language, String explanation, | ||
String textLeft, String textRight, int changeIndex, int absoluteNumberOfChanges) { | ||
super(parentShell, language, explanation, textLeft, textRight, changeIndex, absoluteNumberOfChanges); | ||
} | ||
|
||
/** | ||
* "Apply Changes" -> applies the change and moves on to the next one | ||
* "Decline Changes" -> does not apply the change, but moves on to the next one | ||
* "Cancel" -> cancels the whole process, nothing will be further applied | ||
* | ||
* The order is based on how it will be displayed in dialog. The first one is always the most right one (because of | ||
* the "true") and the others are aligned to its left from left to right! | ||
*/ | ||
@Override | ||
protected void createButtonsForButtonBar(Composite parent) { | ||
createButton(parent, IDialogConstants.OK_ID, "Apply Changes", true); | ||
createButton(parent, IDialogConstants.CANCEL_ID, "Cancel", false); | ||
createButton(parent, IDialogConstants.SKIP_ID, "Decline Changes", false); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...lipse.ui/src/org/sonarlint/eclipse/ui/internal/dialog/FixSuggestionUnavailableDialog.java
This file contains 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,60 @@ | ||
/* | ||
* SonarLint for Eclipse | ||
* Copyright (C) 2015-2024 SonarSource SA | ||
* [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonarlint.eclipse.ui.internal.dialog; | ||
|
||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.custom.CLabel; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.sonarlint.eclipse.core.analysis.SonarLintLanguage; | ||
import org.sonarlint.eclipse.ui.internal.SonarLintImages; | ||
|
||
/** Version of the dialog where the fix suggestion is not available due to it not being found! */ | ||
public class FixSuggestionUnavailableDialog extends AbstractFixSuggestionDialog { | ||
public FixSuggestionUnavailableDialog(Shell parentShell, @Nullable SonarLintLanguage language, String explanation, | ||
String textLeft, String textRight, int changeIndex, int absoluteNumberOfChanges) { | ||
super(parentShell, language, explanation, textLeft, textRight, changeIndex, absoluteNumberOfChanges); | ||
} | ||
|
||
/** | ||
* "Proceed" -> does not apply the change and moves on to the next one | ||
* "Cancel" -> cancels the whole process, nothing will be further applied | ||
* | ||
* The order is based on how it will be displayed in dialog. The first one is always the most right one (because of | ||
* the "true") and the others are aligned to its left from left to right! | ||
*/ | ||
@Override | ||
protected void createButtonsForButtonBar(Composite parent) { | ||
createButton(parent, IDialogConstants.OK_ID, "Proceed", true); | ||
createButton(parent, IDialogConstants.CANCEL_ID, "Cancel", false); | ||
} | ||
|
||
@Override | ||
protected void addLabel(Composite container) { | ||
var label = new CLabel(container, SWT.WRAP); | ||
label.setText("This change suggestion is not applicable as the current code cannot be found in the file."); | ||
// INFO: When resized to be too small, this icon won't be shown anymore! | ||
label.setImage(SonarLintImages.IMG_WARNING); | ||
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.