diff options
Diffstat (limited to 'org.eclipse.tips.ui')
5 files changed, 137 insertions, 41 deletions
diff --git a/org.eclipse.tips.ui/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.tips.ui/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..088036331 --- /dev/null +++ b/org.eclipse.tips.ui/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,59 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 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 |