diff options
author | Wim Jongman | 2018-03-04 22:29:36 +0000 |
---|---|---|
committer | Wim Jongman | 2018-03-05 20:59:45 +0000 |
commit | 418bf286735930af524f38210db5aa204612ee28 (patch) | |
tree | 09cfbad201cd50b4d35379b6c43bd4ca4815b340 /org.eclipse.tips.ui/src/org | |
parent | f25308346936ce81c106c66ef764d11fa8a39d35 (diff) | |
download | eclipse.platform.ua-418bf286735930af524f38210db5aa204612ee28.tar.gz eclipse.platform.ua-418bf286735930af524f38210db5aa204612ee28.tar.xz eclipse.platform.ua-418bf286735930af524f38210db5aa204612ee28.zip |
531983: [Tips] Use Dialog instead of ShellS4_8_0_M6I20180311-2000I20180310-1500I20180309-2000I20180308-0630I20180307-2000I20180307-1025I20180307-0900I20180307-0825I20180307-0800I20180306-2000I20180306-0800
Removed warning and added save actions for project
Fixed
Change-Id: If6a6d169a0963ad044db3ebe9d3413e9cdd10dd2
Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
Diffstat (limited to 'org.eclipse.tips.ui/src/org')
4 files changed, 78 insertions, 41 deletions
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/DefaultTipManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/DefaultTipManager.java index f32d420b0..48b6159dd 100644 --- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/DefaultTipManager.java +++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/DefaultTipManager.java @@ -40,7 +40,7 @@ public abstract class DefaultTipManager extends TipManager { */ @Override public TipManager open(boolean startUp) { - if (fOpen && (fTipDialog == null || fTipDialog.isDisposed())) { + if (fOpen && (fTipDialog == null || fTipDialog.getShell() == null || fTipDialog.getShell().isDisposed())) { fOpen = false; } try { @@ -55,14 +55,14 @@ public abstract class DefaultTipManager extends TipManager { } fTipDialog = new TipDialog(Display.getCurrent().getActiveShell(), this, TipDialog.DEFAULT_STYLE); - fTipDialog.addDisposeListener(pE -> { + fTipDialog.open(); + fTipDialog.getShell().addDisposeListener(pE -> { try { dispose(); } finally { fOpen = false; } }); - fTipDialog.open(); fOpen = true; return this; } diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java index 02f8fdb8b..a1ecb3eb7 100644 --- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java +++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java @@ -237,7 +237,7 @@ public class Slider extends Composite { public Slider setTipManager(TipManager tipManager) { fTipManager = tipManager; fTipManager.getListenerManager().addProviderListener(fProviderListener); - fIconSize = 48; + fIconSize = 48; load(); return this; } @@ -321,8 +321,12 @@ public class Slider extends Composite { private void paintButton(GC gc, Composite providerButton, TipProvider provider) { gc.setAdvanced(true); if (fSelectedProvider.equals(provider)) { + gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); + gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); gc.drawRectangle(0, 0, fIconSize + 3, fIconSize + 3); } else { + gc.setForeground(fLeftButton.getForeground()); + gc.setBackground(fLeftButton.getBackground()); boolean mouseIn = getDisplay().getCursorControl() == providerButton; if (mouseIn) { gc.drawRectangle(0, 0, fIconSize + 3, fIconSize + 3); @@ -378,18 +382,15 @@ public class Slider extends Composite { image = new Image(getDisplay(), data); GC gc = new GC(image); gc.setAdvanced(true); -// if (fTipManager.mustServeReadTips()) { -// gc.setBackground(theme.getColor(TipTheme.COLOR_BADGE_TIPCOUNT_BACKGROUND)); -// } else { -// gc.setBackground(theme.getColor(TipTheme.COLOR_BADGE_UNREAD_BACKGROUND)); -// } + if (fTipManager.mustServeReadTips()) { + gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN)); + } else { + gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED)); + } + gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); + gc.setFont(SWTResourceManager.getBoldFont(gc.getFont())); gc.setAlpha(210); gc.setTextAntialias(SWT.ON); -// if (fTipManager.mustServeReadTips()) { -// gc.setForeground(theme.getColor(TipTheme.COLOR_BADGE_TIPCOUNT_FOREGROUND)); -// } else { -// gc.setForeground(theme.getColor(TipTheme.COLOR_BADGE_UNREAD_FOREGROUND)); -// } if (tipCount > 9) { gc.fillOval(0, 0, textExtent.x + 8, textExtent.y + 5); gc.drawText(tipCount + "", 4, 2, true); diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java index 2262da568..57f81b032 100644 --- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java +++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java @@ -204,6 +204,7 @@ public class TipComposite extends Composite implements ProviderSelectionListener }); fEmptyActionComposite = new Composite(actionComposite, SWT.NONE); + fEmptyActionComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); fPreviousTipButton = new Button(buttonBar, SWT.NONE); fPreviousTipButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java index a31398a8d..fe76b7886 100644 --- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java +++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java @@ -10,50 +10,85 @@ *******************************************************************************/ package org.eclipse.tips.ui.internal; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.tips.core.TipManager; -public class TipDialog extends Shell { +/** + * The dialog containing the tips. + * + */ +public class TipDialog extends Dialog { /** - * When passed as style, the default style will be used. + * When passed as style, the default style will be used which is + * <p> + * (SWT.RESIZE | SWT.SHELL_TRIM) */ public static final int DEFAULT_STYLE = -1; private TipManager fTipManager; private TipComposite fTipComposite; + private int fShellStyle; - /** - * Creates the Tip Dialog. - * - * @param display - * the {@link Display} - * @param tipManager - * the {@link TipManager} - * @param style - * the {@link Shell} style or {@link #DEFAULT_STYLE} for - * <code>SWT.DIALOG_TRIM | SWT.RESIZE | SWT.CLOSE</code> - */ - public TipDialog(Shell display, TipManager tipManager, int style) { - super(display, style == DEFAULT_STYLE ? SWT.DIALOG_TRIM | SWT.RESIZE | SWT.CLOSE : style); + public TipDialog(Shell parentShell, TipManager tipManager, int shellStyle) { + super(parentShell); fTipManager = tipManager; - setLayout(new FillLayout(SWT.HORIZONTAL)); - fTipComposite = new TipComposite(this, SWT.NONE); - pack(); - setLocation(getShell().getMonitor().getClientArea().width / 2 - getSize().x / 2, - getShell().getMonitor().getClientArea().height / 2 - getSize().y / 2); - setText("Tip of the Day"); + fShellStyle = (shellStyle == DEFAULT_STYLE) ? (SWT.RESIZE | SWT.SHELL_TRIM) : shellStyle; } @Override - public void open() { - super.open(); - fTipComposite.setTipManager(fTipManager); + protected Control createDialogArea(Composite parent) { + fixLayout(parent); + Composite area = (Composite) super.createDialogArea(parent); + fixLayout(area); + fTipComposite = new TipComposite(area, SWT.NONE); + fixLayout(fTipComposite); + getShell().setLocation(getShell().getMonitor().getClientArea().width / 2 - parent.getSize().x / 2, + getShell().getMonitor().getClientArea().height / 2 - parent.getSize().y / 2); + getShell().setText("Tip of the Day"); + fTipComposite.addDisposeListener(event -> close()); + return area; + } + + @Override + protected void createButtonsForButtonBar(Composite pParent) { + } + + @Override + protected Control createButtonBar(Composite pParent) { + Control bar = super.createButtonBar(pParent); + fixLayout((Composite) bar); + return bar; + } + + @Override + protected int getShellStyle() { + return fShellStyle; + } + + private void fixLayout(Composite parent) { + ((GridLayout) parent.getLayout()).marginHeight = 0; + ((GridLayout) parent.getLayout()).marginBottom = 0; + ((GridLayout) parent.getLayout()).marginLeft = 0; + ((GridLayout) parent.getLayout()).marginRight = 0; + ((GridLayout) parent.getLayout()).marginWidth = 0; + ((GridLayout) parent.getLayout()).marginTop = 0; + GridDataFactory.fillDefaults().grab(true, true).applyTo(parent); } @Override - protected void checkSubclass() { + public int open() { + setBlockOnOpen(false); + int result = super.open(); + if (result == Window.OK) { + fTipComposite.setTipManager(fTipManager); + } + return result; } }
\ No newline at end of file |