Skip to content

Commit

Permalink
Refactoring of Strings for QuickFixWizard
Browse files Browse the repository at this point in the history
  • Loading branch information
sebHollersbacher authored and oberlehner committed Sep 23, 2024
1 parent 9d96b52 commit 2fd29a4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ public final class Messages extends NLS {

public static String InfoPropertySection_Combo_Text_CountDESC;

public static String QuickFixDialog_Title;

public static String QuickFixDialog_NoResolutionsFound;

public static String QuickFixDialog_NoResolutionsFoundForMultiSelection;

public static String QuickFixDialog_Message;

public static String QuickFixDialog_SelectAll;

public static String QuickFixDialog_DeselectAll;

public static String QuickFixDialog_Resolutions_List_Title;

public static String QuickFixDialog_Problems_List_Title;

public static String QuickFixDialog_Problems_List_Location;

public static String QuickFixDialog_Problems_List_Resource;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*******************************************************************************/
package org.eclipse.fordiac.ide.application.handlers;

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -27,6 +28,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.fordiac.ide.application.Messages;
import org.eclipse.fordiac.ide.application.wizards.QuickFixWizardDialog;
import org.eclipse.fordiac.ide.gef.annotation.FordiacAnnotationUtil;
import org.eclipse.fordiac.ide.gef.annotation.FordiacMarkerGraphicalAnnotationModel;
Expand Down Expand Up @@ -68,8 +70,15 @@ public Object execute(final ExecutionEvent event) {
}

if (resolutionsMap.isEmpty()) {
MessageDialog.openInformation(shell, "Quick Fix", //$NON-NLS-1$
"The selected problems do not have a common applicable quick fix."); //$NON-NLS-1$
if (selectedMarkers.length == 1) {
MessageDialog.openInformation(shell, Messages.QuickFixDialog_Title,
MessageFormat.format(Messages.QuickFixDialog_NoResolutionsFound,
selectedMarkers[0].getAttribute(IMarker.MESSAGE, ""))); //$NON-NLS-1$

} else {
MessageDialog.openInformation(shell, Messages.QuickFixDialog_Title,
Messages.QuickFixDialog_NoResolutionsFoundForMultiSelection);
}
} else {
QuickFixWizardDialog.openDialog(shell, selectedMarkers, resolutions, resolutionsMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,13 @@ InfoPropertySection_Combo_Text_SortBy=Sort by:
InfoPropertySection_Combo_Text_Name=Name
InfoPropertySection_Combo_Text_CountASC=Count ASC
InfoPropertySection_Combo_Text_CountDESC=Count DESC
QuickFixDialog_Title=Quick Fix
QuickFixDialog_NoResolutionsFound=No fixes available for ''{0}''.
QuickFixDialog_NoResolutionsFoundForMultiSelection=The selected problems do not have a common applicable quick fix.
QuickFixDialog_Message=Select the fix for ''{0}''.
QuickFixDialog_SelectAll=Select All
QuickFixDialog_DeselectAll=Deselect All
QuickFixDialog_Resolutions_List_Title=Select a fix:
QuickFixDialog_Problems_List_Title=Problems:
QuickFixDialog_Problems_List_Location=Location
QuickFixDialog_Problems_List_Resource=Resource
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
package org.eclipse.fordiac.ide.application.wizards;

import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;

import org.eclipse.core.resources.IMarker;
import org.eclipse.fordiac.ide.application.Messages;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
Expand Down Expand Up @@ -55,16 +57,14 @@

public class QuickFixWizardDialog {

private static final String TITLE = "Quick Fix"; //$NON-NLS-1$

private QuickFixWizardDialog() {
}

public static int openDialog(final Shell parentShell, final IMarker[] selectedMarkers,
final IMarkerResolution[] resolutions, final Map<IMarkerResolution, Collection<IMarker>> resolutionMap) {
final QuickFixWizardPage wizardPage = new QuickFixWizardPage(selectedMarkers, resolutions, resolutionMap);
final QuickFixWizard wizard = new QuickFixWizard(wizardPage);
wizard.setWindowTitle(TITLE);
wizard.setWindowTitle(Messages.QuickFixDialog_Title);

final WizardDialog dialog = new WizardDialog(parentShell, wizard);
return dialog.open();
Expand All @@ -75,7 +75,7 @@ private static class QuickFixWizard extends Wizard {

public QuickFixWizard(final QuickFixWizardPage wizardPage) {
setDefaultPageImageDescriptor(
ImageDescriptor.createFromFile(IDE.class, "/icons/full/wizban/quick_fix.png")); //$NON-NLS-1$ );
ImageDescriptor.createFromFile(IDE.class, "/icons/full/wizban/quick_fix.png")); //$NON-NLS-1$
this.wizardPage = wizardPage;
addPage(wizardPage);
}
Expand All @@ -101,13 +101,6 @@ public boolean performFinish() {
}

private static class QuickFixWizardPage extends WizardPage {
private static final String RESOURCE_COLUMN_TEXT = "Resource"; //$NON-NLS-1$
private static final String LOCATION_COLUMN_TEXT = "Location"; //$NON-NLS-1$
private static final String SELECT_ALL_BUTTON_TEXT = "Select All"; //$NON-NLS-1$
private static final String DESELECT_ALL_BUTTON_TEXT = "Deselect All"; //$NON-NLS-1$
private static final String RESOLUTION_LABEL_TEXT = "Select a fix:"; //$NON-NLS-1$
private static final String MARKERS_LABEL_TEXT = "Problems:"; //$NON-NLS-1$

private static final Image ERROR_IMG = ImageDescriptor
.createFromFile(IDE.class, "/icons/full/obj16/error_tsk.png").createImage(); //$NON-NLS-1$

Expand All @@ -120,13 +113,14 @@ private static class QuickFixWizardPage extends WizardPage {

protected QuickFixWizardPage(final IMarker[] initialMarkers, final IMarkerResolution[] resolutions,
final Map<IMarkerResolution, Collection<IMarker>> resolutionsMap) {
super(TITLE);
super(Messages.QuickFixDialog_Title);
this.initialMarkers = initialMarkers;
this.resolutions = resolutions;
this.resolutionMap = resolutionsMap;

setTitle(TITLE);
setMessage(String.format("Select the fix for '%s'", initialMarkers[0].getAttribute(IMarker.MESSAGE, ""))); //$NON-NLS-1$ //$NON-NLS-2$
setTitle(Messages.QuickFixDialog_Title);
setMessage(MessageFormat.format(Messages.QuickFixDialog_Message,
initialMarkers[0].getAttribute(IMarker.MESSAGE, ""))); //$NON-NLS-1$
}

@Override
Expand All @@ -142,14 +136,14 @@ public void createControl(final Composite parent) {
selectResolutionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
selectResolutionComposite.setLayout(new GridLayout());
Label label = new Label(selectResolutionComposite, SWT.NONE);
label.setText(RESOLUTION_LABEL_TEXT);
label.setText(Messages.QuickFixDialog_Resolutions_List_Title);
createResolutionList(selectResolutionComposite);

final Composite selectMarkerComposite = new Composite(pageComposite, SWT.NONE);
selectMarkerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
selectMarkerComposite.setLayout(new GridLayout(2, false));
label = new Label(selectMarkerComposite, SWT.NONE);
label.setText(MARKERS_LABEL_TEXT);
label.setText(Messages.QuickFixDialog_Problems_List_Title);
new Label(selectMarkerComposite, SWT.NONE);
createMarkerList(selectMarkerComposite);

Expand Down Expand Up @@ -228,7 +222,7 @@ private void createTableColumns() {

layout.addColumnData(new ColumnWeightData(70, true));
TableColumn tableColumn = new TableColumn(table, SWT.NONE, 0);
tableColumn.setText(LOCATION_COLUMN_TEXT);
tableColumn.setText(Messages.QuickFixDialog_Problems_List_Location);
TableViewerColumn tableViewerColumn = new TableViewerColumn(markersTable, tableColumn);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
Expand All @@ -239,7 +233,7 @@ public String getText(final Object element) {

layout.addColumnData(new ColumnWeightData(30, true));
tableColumn = new TableColumn(table, SWT.NONE, 0);
tableColumn.setText(RESOURCE_COLUMN_TEXT);
tableColumn.setText(Messages.QuickFixDialog_Problems_List_Resource);
tableViewerColumn = new TableViewerColumn(markersTable, tableColumn);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
Expand All @@ -265,7 +259,7 @@ private void createTableButtons(final Composite control) {

final Button selectAll = new Button(buttonComposite, SWT.PUSH);
selectAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
selectAll.setText(SELECT_ALL_BUTTON_TEXT);
selectAll.setText(Messages.QuickFixDialog_SelectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
Expand All @@ -276,7 +270,7 @@ public void widgetSelected(final SelectionEvent event) {

final Button deselectAll = new Button(buttonComposite, SWT.PUSH);
deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
deselectAll.setText(DESELECT_ALL_BUTTON_TEXT);
deselectAll.setText(Messages.QuickFixDialog_DeselectAll);
deselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
Expand Down

0 comments on commit 2fd29a4

Please sign in to comment.