Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Jongman2018-05-22 12:47:59 +0000
committerWim Jongman2018-05-22 16:04:31 +0000
commit7dfa43e9de078f3f2d95ef3986b720fd58a1dd56 (patch)
tree82a8ae6d6396ec3424a732873086ad626ff8f84f
parentc81f8a9f764d378df043daa823fd77920cf46765 (diff)
downloadeclipse.platform.ua-I20180526-1500.tar.gz
eclipse.platform.ua-I20180526-1500.tar.xz
eclipse.platform.ua-I20180526-1500.zip
* Set2 - Included memory leak updated tests * Position is now default for Dialog * Passed IDialogSettings to remember position and size * Added AbstractUIPlugin class to fetch dialog setttings Change-Id: I03933e6f7b90d6ed97c3393fdc15086a7886a51b Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
-rw-r--r--org.eclipse.tips.ide/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java2
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Plugin.java25
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TwitterTipProvider.java4
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/JsonTestProvider.java6
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/twittertips.json105
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java12
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java33
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java28
9 files changed, 191 insertions, 26 deletions
diff --git a/org.eclipse.tips.ide/META-INF/MANIFEST.MF b/org.eclipse.tips.ide/META-INF/MANIFEST.MF
index d0887fdde..964c226aa 100644
--- a/org.eclipse.tips.ide/META-INF/MANIFEST.MF
+++ b/org.eclipse.tips.ide/META-INF/MANIFEST.MF
@@ -14,3 +14,5 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.108.0",
Export-Package: org.eclipse.tips.ide.internal;x-internal:=true
Automatic-Module-Name: org.eclipse.tips.ide
Bundle-Vendor: %Bundle-Vendor
+Bundle-Activator: org.eclipse.tips.ide.internal.Plugin
+Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java
index 69064a165..9a5cdbbcd 100644
--- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java
+++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java
@@ -105,7 +105,7 @@ public class IDETipManager extends DefaultTipManager {
fSourceProviderAdded = true;
}
fReadTips = TipsPreferences.getReadState();
- return super.open(startUp);
+ return super.open(startUp, Plugin.getInstance().getDialogSettings());
}
/**
diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Plugin.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Plugin.java
new file mode 100644
index 000000000..e8a4c45f9
--- /dev/null
+++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Plugin.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Remain Software
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * wim.jongman@remainsoftware.com - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tips.ide.internal;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class Plugin extends AbstractUIPlugin {
+ private static Plugin instance;
+
+ public Plugin() {
+ instance = this;
+ }
+
+ public static AbstractUIPlugin getInstance() {
+ return instance;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TwitterTipProvider.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TwitterTipProvider.java
index 3904b6a8e..4ee31bde5 100644
--- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TwitterTipProvider.java
+++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TwitterTipProvider.java
@@ -23,7 +23,7 @@ import org.osgi.framework.Bundle;
public class TwitterTipProvider extends JsonTipProvider {
public TwitterTipProvider() throws MalformedURLException {
- URL resource = getClass().getResource("twittertips.json"); // $NON-NLS-0$
+ URL resource = getClass().getResource("twittertips.json"); // $NON-NLS-1$
if (resource != null) {
setJsonUrl(resource.toString());
}
@@ -31,7 +31,7 @@ public class TwitterTipProvider extends JsonTipProvider {
@Override
public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) {
- Bundle bundle = Platform.getBundle("org.eclipse.jdt.ui"); // $NON-NLS-0$
+ Bundle bundle = Platform.getBundle("org.eclipse.jdt.ui"); // $NON-NLS-1$
if (bundle != null) {
return super.loadNewTips(pMonitor);
}
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/JsonTestProvider.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/JsonTestProvider.java
index 8c5829a26..5f2673bc8 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/JsonTestProvider.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/JsonTestProvider.java
@@ -11,13 +11,17 @@
package org.eclipse.tips.core;
import java.net.MalformedURLException;
+import java.net.URL;
import org.eclipse.tips.json.JsonTipProvider;
public class JsonTestProvider extends JsonTipProvider {
public JsonTestProvider() throws MalformedURLException {
- setJsonUrl("https://raw.githubusercontent.com/wimjongman/jsontips/master/photon/m3tips.json");
+ URL resource = getClass().getResource("twittertips.json"); // $NON-NLS-1$
+ if (resource != null) {
+ setJsonUrl(resource.toString());
+ }
}
@Override
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/twittertips.json b/org.eclipse.tips.tests/src/org/eclipse/tips/core/twittertips.json
new file mode 100644
index 000000000..89bf85206
--- /dev/null
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/twittertips.json
@@ -0,0 +1,105 @@
+{
+ "provider": {
+ "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gQdDgUFxygUawAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAJeklEQVRo3u2YW4hdVxnHf2vtvc9lzpnJZC7JJE0mk6Yk6f1erWBFBFsVFUEUq8UiiL6qT7744ItQEMGigiCVQiG+SKmILa2tok1K75c0vaVp2maSJpOZ6ZzrPnut9X0+7HPOnJmmndROwEoWbPZt7cX//33/77IXnB/nx/lxfpwf58c5HKpqVLWoqkONdmdivdc355rAHX86sHWp0b7tdK21M7K2s3msemRq09i9P7j5sjfXY/34XBN47MU3N2c+fLeZ+ouTJFYnetzGyRHg40HgxHxN4igKSbGAiayppZmcXGjoeq3/gQT+es89l9fmTxfiYqKV4QrFYsnExQLiPGm7TavdJk1TXTh1kqltO6K9V1771uU3XHdycA1rLcYaBcWgRBi1Zv2Ue0YCs2+8buq1+jeW5l65fev0eKVYTEKcFDQuxDayESIJ3iU4XyaEIJ32sG03TSFNF5+eO7Xwx4nJjU8ZY3R1lCmgur4ePiOBrTMXTj6z/+Gfb9pSunBiaiNJIcFgwViMASWACqoCqthoghNvzZu5ueYn50/ODk9MbvwJcLqPetUQ1XMroece+/eXjTY2T27dFFdGhoECmKhrTgX1gAM6oBlEytYZpZMtcer44QubTZ3uETjdNtmmqsF0XaFAIJF1J/D2kcPGO3/L4UMvJLNHX791196porCBNB0lisoYG2OMQVEkZATXwrsazqUEVyeyDvFNlhYWZ44fO/ntv+zbt3Nq2DQfeaOz5/7X/XAQJVYw4srbo7mbnvjHw6WRLbue27Nnx5EehkOHXjWXXLJb/6s6sP+hB6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vCFr16TPfjSlN2+dxu1ekc1iAkD1gqysmXQFelxpXfQ5X8EHfROELzPcJ02LkspGa1XKkO//voXd//5jFsma4B/z/b63x489D3ioV8pVCDfA9IVaYr3brbp6icmJz3wWPr/FgaMURGxSWLrkTU/+tJnZ+56P3BPHVow114yts6bkefH//n46S8fTx7af9x8LMHvu++V5MN+Y/+XCExvH/HnNfhxG/8BVNCkBLE3Vt8AAAAASUVORK5CYII=",
+ "description": "Eclipse IDE Twitter Tip Collection",
+ "variables": {
+ "baseUrl": "http://www.eclipse.org/downloads/download.php?r=1&file=/eclipse/tips/org.eclipse.jdt.tips.user"
+ },
+ "tips": [{
+ "date": "2018-01-05",
+ "subject": "The 'Extract class...' refactoring (from Alt+Shift+T) extracts a group of fields into a separate class and replaces all occurrences to fit the new structure. See example. #EclipseTips https://t.co/tEI7ic7C1g",
+ "aspect-ratio": "2.0",
+ "url": "${baseUrl}/content/949238007051235328/949238007051235328.html"
+ }, {
+ "date": "2018-01-09",
+ "subject": "Use the 'new' template for quick object creation. #speed #EclipseTips https://t.co/yI33PEmfkm",
+ "aspect-ratio": "2.0",
+ "url": "${baseUrl}/content/950773930775793664/950773930775793664.html"
+ }, {
+ "date": "2017-12-15",
+ "subject": "You don't need to know which module contains a class in #Java9 Ctrl-1 can identify the module and add it for you! #EclipseTips https://t.co/OGjB3V7vJJ",
+ "aspect-ratio": "2.4",
+ "url": "${baseUrl}/content/941624342282108929/941624342282108929.html"
+ }, {
+ "date": "2017-12-14",
+ "subject": "Need to check for null? Use the ifnull template and don't slow down! #productivity #EclipseTips https://t.co/FrDemG6rPS",
+ "aspect-ratio": "2.1",
+ "url": "${baseUrl}/content/941264226940850177/941264226940850177.html"
+ }, {
+ "date": "2017-11-06",
+ "subject": "You can directly use a CSV file as a parameter source in #JUnit5 parameterized tests. Very handy to feed a large nr of cases! #EclipseTips https://t.co/FDMPAzR2em",
+ "aspect-ratio": "2.2",
+ "url": "${baseUrl}/content/927527210772258816/927527210772258816.html"
+ }, {
+ "date": "2017-11-16",
+ "subject": "Enjoy the Edit -> Block Selection (Alt+Shift+A) while working on your #Java9 https://t.co/txMxd39pJ0 #EclipseTips https://t.co/X63mh9uDd7",
+ "aspect-ratio": "1.7",
+ "url": "${baseUrl}/content/931124796502536192/931124796502536192.html"
+ }, {
+ "date": "2017-10-18",
+ "subject": "In #JUnit5 parameterized tests also accept CSV literals (and files) as a source of parameters. Quite handy to feed your tests! #EclipseTips https://t.co/T7Lphj5eyl",
+ "aspect-ratio": "1.9",
+ "url": "${baseUrl}/content/920608130274381825/920608130274381825.html"
+ }, {
+ "date": "2017-09-19",
+ "subject": "You can use methods returning #Java streams as a source of parameters in #JUnit5 tests. Use @MethodSource as shown below. #EclipseTips https://t.co/Jr1o00YEof",
+ "aspect-ratio": "1.9",
+ "url": "${baseUrl}/content/910089046600425472/910089046600425472.html"
+ }, {
+ "date": "2017-08-30",
+ "subject": "Put your cursor on a class name (or method) and press Shift+F2 to jump to the web version of your library's Javadoc! #EclipseTips https://t.co/vpUavzUgk6",
+ "aspect-ratio": "1.7",
+ "url": "${baseUrl}/content/902851499503607808/902851499503607808.html"
+ }, {
+ "date": "2017-07-24",
+ "subject": "Use the 'Quick Access' box (Ctrl+3) extensively to be more productive. Just type what you want and you'll probably find it. #EclipseTips https://t.co/KQB2i4BuDU",
+ "aspect-ratio": "1.6",
+ "url": "${baseUrl}/content/889435990976323584/889435990976323584.html"
+ }, {
+ "date": "2017-07-11",
+ "subject": "Always safer to 'Invert equals' on literal strings in order to avoid the horrible NullPointerException! Ctrl+1 does it for you. #EclipseTips https://t.co/DmjMWgiySM",
+ "aspect-ratio": "1.9",
+ "url": "${baseUrl}/content/884689449917050880/884689449917050880.html"
+ }, {
+ "date": "2017-07-21",
+ "subject": "Private methods in interfaces will be allowed in #Java9. Here's an example use case with a shared 'worker' method. #EclipseTips https://t.co/cdRcETAmMV",
+ "aspect-ratio": "1.2",
+ "url": "${baseUrl}/content/888360858119745536/888360858119745536.html"
+ }, {
+ "date": "2017-06-13",
+ "subject": "Whatever element you have selected, code or item, 'Show in...' (Alt+Shift+W) command pops up useful views for various details! #EclipseTips https://t.co/6GVpSPKOdT",
+ "aspect-ratio": "1.2",
+ "url": "${baseUrl}/content/874600197195796482/874600197195796482.html"
+ }, {
+ "date": "2017-06-01",
+ "subject": "Often you want to move lines up/down. Press Alt+Up/Dn to move the lines along with the cursor. Indenting is corrected for you. #EclipseTips https://t.co/5tnaajebZf",
+ "aspect-ratio": "1.3",
+ "url": "${baseUrl}/content/870170548722184192/870170548722184192.html"
+ }, {
+ "date": "2017-05-04",
+ "subject": "If you want to know where and how a variable was declared just press Shift while hovering and you'll get it in-place! #EclipseTips https://t.co/4Vpz4JKW0w",
+ "aspect-ratio": "1.8",
+ "url": "${baseUrl}/content/860125970556223489/860125970556223489.html"
+ }, {
+ "date": "2017-05-16",
+ "subject": "Here's our Edit -> Toggle Block Selection tool (or just hit Shift+Alt+A) in action. Very useful! #productivity #EclipseTips https://t.co/myMI2oaLLG",
+ "aspect-ratio": "1.5",
+ "url": "${baseUrl}/content/864423629697822720/864423629697822720.html"
+ }, {
+ "date": "2017-04-20",
+ "subject": "The 'enclosing' selection (Alt+Shift+Up/Dn) is a great shortcut. Selects the enclosing structure, e.g. var->if->method->class #EclipseTips https://t.co/joGBu9IzdB",
+ "aspect-ratio": "2.0",
+ "url": "${baseUrl}/content/855062302655209472/855062302655209472.html"
+ }, {
+ "date": "2017-04-25",
+ "subject": "Ever looked at a #Java method thinking 'what does this one do'? Press Shift while hovering it and it will show implementation in-place! #Tip https://t.co/5Qym5CkcJN",
+ "aspect-ratio": "2.1",
+ "url": "${baseUrl}/content/856867463409041410/856867463409041410.html"
+ }, {
+ "date": "2018-03-22",
+ "subject": "#Java10 is out. Time to play with 'var'. Try it out with @EclipseJavaIDE and its new quick assists (Ctrl+1). https://t.co/iUJcGjV1Ts #EclipseTips https://t.co/HfJqlymzZb",
+ "aspect-ratio": "4.2",
+ "url": "${baseUrl}/content/976836214857740288/976836214857740288.html"
+ }]
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
index bca0a2179..bb4c0319a 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
@@ -15,7 +15,6 @@ import java.net.MalformedURLException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.graphics.DeviceData;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tips.core.ITipManager;
@@ -25,6 +24,7 @@ import org.eclipse.tips.core.TipProvider;
import org.eclipse.tips.core.internal.TipManager;
import org.eclipse.tips.ui.internal.TipDialog;
import org.eclipse.tips.ui.internal.util.ResourceManager;
+import org.eclipse.tips.ui.internal.util.SWTResourceManager;
/**
* Class to manage the tip providers and start the tip of the day UI.
@@ -63,15 +63,14 @@ public class SleakTipManager extends TipManager {
DeviceData data = new DeviceData();
data.tracking = true;
Display display = new Display(data);
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
new Sleak().open();
- TipDialog tipDialog = new TipDialog(shell, SleakTipManager.this, TipDialog.DEFAULT_STYLE);
- shell.addDisposeListener(pE -> dispose());
+ TipDialog tipDialog = new TipDialog(null, SleakTipManager.this, TipDialog.DEFAULT_STYLE, null);
tipDialog.open();
+ Shell shell = tipDialog.getShell();
+ shell.addDisposeListener(pE -> dispose());
shell.pack();
shell.open();
- while (!shell.isDisposed()) {
+ while (!display.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
@@ -111,6 +110,7 @@ public class SleakTipManager extends TipManager {
@Override
public void dispose() {
+ SWTResourceManager.dispose();
ResourceManager.dispose();
super.dispose();
}
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
index 7744ed654..4968986fc 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
@@ -11,6 +11,7 @@
package org.eclipse.tips.ui.internal;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tips.core.ITipManager;
import org.eclipse.tips.core.internal.LogUtil;
@@ -25,19 +26,29 @@ public abstract class DefaultTipManager extends TipManager {
private TipDialog fTipDialog;
+ @Override
+ public ITipManager open(boolean startUp) {
+ return open(startUp, null);
+ }
+
/**
- * Opens the Tip of the Day dialog. Subclasses may override if they want to
- * present the Tips in a different way, e.g. in a view.
+ * Alternative open method that receives an {@link IDialogSettings} class to
+ * store the width and height and possibly other dialog settings. Subclasses may
+ * override if they want to present the Tips in a different way, e.g. in a view.
*
- * @param startUp When called from a startup situation, true must be passed for
- * <code>pStartup</code>. If in a manual starting situation,
- * false must be passed. This enables the manager to decide to
- * skip opening the dialog at startup (e.g., no new tip items).
+ * @param startUp When called from a startup situation, true must be
+ * passed for <code>pStartup</code>. If in a manual
+ * starting situation, false must be passed. This enables
+ * the manager to decide to skip opening the dialog at
+ * startup (e.g., no new tip items).
+ * @param dialogSettings An object to store various dialog settings. May be
+ * null;
+ *
+ * @return this tip manager.
+ * @see #open()
*
- * @see #isOpen()
*/
- @Override
- public ITipManager open(boolean startUp) {
+ public ITipManager open(boolean startUp, IDialogSettings dialogSettings) {
if (isOpen() && !isDialogOpen()) {
setOpen(false);
} else if (isOpen() && isDialogOpen()) {
@@ -58,8 +69,8 @@ public abstract class DefaultTipManager extends TipManager {
}
setOpen(true);
-
- fTipDialog = new TipDialog(Display.getCurrent().getActiveShell(), this, TipDialog.DEFAULT_STYLE);
+ fTipDialog = new TipDialog(Display.getCurrent().getActiveShell(), this, TipDialog.DEFAULT_STYLE,
+ dialogSettings);
fTipDialog.open();
fTipDialog.getShell().addDisposeListener(pE -> {
dispose();
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 dc13405b9..b6506df0b 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
@@ -11,6 +11,7 @@
package org.eclipse.tips.ui.internal;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@@ -36,27 +37,43 @@ public class TipDialog extends Dialog {
private TipManager fTipManager;
private TipComposite fTipComposite;
private int fShellStyle;
+ private IDialogSettings fDialogSettings;
- public TipDialog(Shell parentShell, TipManager tipManager, int shellStyle) {
+ public TipDialog(Shell parentShell, TipManager tipManager, int shellStyle, IDialogSettings dialogSettings) {
super(parentShell);
fTipManager = tipManager;
+ fDialogSettings = dialogSettings;
fShellStyle = (shellStyle == DEFAULT_STYLE) ? (SWT.RESIZE | SWT.SHELL_TRIM) : shellStyle;
}
@Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ return fDialogSettings;
+ }
+
+ @Override
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(Messages.TipDialog_0);
fTipComposite.addDisposeListener(event -> close());
return area;
}
+// private Point getLocation() {
+// Shell parentShell = getParentShell();
+// if (parentShell == null) {
+// return null;
+// }
+// int absx = parentShell.getSize().x / 2 - getShell().getSize().x / 2;
+// int absy = parentShell.getSize().y / 2 - getShell().getSize().y / 2;
+// absy = absy > 20 ? 20 : absy;
+// return new Point(parentShell.getLocation().x + absx, parentShell.getLocation().y + absy);
+// }
+
@Override
protected void createButtonsForButtonBar(Composite pParent) {
}
@@ -64,10 +81,11 @@ public class TipDialog extends Dialog {
@Override
protected Control createButtonBar(Composite pParent) {
Control bar = super.createButtonBar(pParent);
- fixLayout((Composite) bar);
+ // fixLayout((Composite) bar);
+ bar.setLayoutData(GridDataFactory.swtDefaults().hint(1, 1).create());
return bar;
}
-
+
@Override
protected int getShellStyle() {
return fShellStyle;

Back to the top