Skip to content

Commit cf03ec7

Browse files
committed
Add default message if no LAS is selected
When no preview is selected, an empty group is shown. In such a case, a label should be created, telling the user to select a LaF.
1 parent d12a13f commit cf03ec7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/preferences/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class Messages extends NLS {
4242
public static String LafPreferencePage_editCategoryMessage;
4343
public static String LafPreferencePage_editCategoryTitle;
4444
public static String LafPreferencePage_expandAllButton;
45+
public static String LafPreferencePage_noSelection;
4546
public static String LafPreferencePage_preview;
4647
public static String LafPreferencePage_previewButton;
4748
public static String LafPreferencePage_previewCheck;

org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/preferences/laf/LafPreferencePage.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.eclipse.jface.viewers.ViewerDropAdapter;
5151
import org.eclipse.jface.window.Window;
5252
import org.eclipse.swt.SWT;
53+
import org.eclipse.swt.custom.CLabel;
5354
import org.eclipse.swt.dnd.ByteArrayTransfer;
5455
import org.eclipse.swt.dnd.DND;
5556
import org.eclipse.swt.dnd.DragSourceAdapter;
@@ -92,6 +93,7 @@
9293
*/
9394
public class LafPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IPreferenceConstants {
9495
// constants
96+
private static final int DEFAULT_PREVIEW_MARGIN = 50;
9597
private static final Image CATEGORY_IMAGE = CoreImages.getSharedImage(CoreImages.FOLDER_OPEN);
9698
private static final Image LAF_ITEM_IMAGE = Activator.getImage("info/laf/laf.png");
9799
// variables
@@ -163,6 +165,7 @@ protected Control createContents(Composite parent) {
163165
GridDataFactory.create(m_previewGroup).grabH().fill();
164166
m_previewGroup.setText(Messages.LafPreferencePage_preview);
165167
m_previewGroup.setLayout(new FillLayout());
168+
updatePreview0();
166169
}
167170
// return back LAF
168171
container.addDisposeListener(e -> {
@@ -548,7 +551,10 @@ private void updatePreview0() {
548551
}
549552
LafInfo selectedLAF = getSelectedLAF();
550553
if (selectedLAF == null) {
551-
// nothing selected
554+
CLabel nothingSelected = new CLabel(m_previewGroup, SWT.CENTER);
555+
nothingSelected.setText(Messages.LafPreferencePage_noSelection);
556+
nothingSelected.setMargins(0, DEFAULT_PREVIEW_MARGIN, 0, DEFAULT_PREVIEW_MARGIN);
557+
m_previewGroup.requestLayout();
552558
return;
553559
}
554560
m_previewGroup.getParent().layout(true);

org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/preferences/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ LafPreferencePage_editButton=Edit...
3636
LafPreferencePage_editCategoryMessage=Enter new category name:
3737
LafPreferencePage_editCategoryTitle=Category
3838
LafPreferencePage_expandAllButton=Expand All
39+
LafPreferencePage_noSelection=Select LookAndFeel for preview
3940
LafPreferencePage_preview=Preview:
4041
LafPreferencePage_previewButton=Push Button
4142
LafPreferencePage_previewCheck=CheckBox

0 commit comments

Comments
 (0)