1
/*******************************************************************************
2
* Copyright (c) 2000, 2010 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - initial API and implementation
10
*******************************************************************************/
12
package org.eclipse.cdt.make.internal.ui;
14
import org.eclipse.jface.dialogs.IDialogSettings;
15
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.widgets.Shell;
19
* Helper class for dealing with setting and restoring dialog settings.
21
* @deprecated as of CDT 4.0. This tab used in preference pages
22
* for 3.X style projects.
25
public class DialogSettingsHelper {
28
* Persists the location and dimensions of the shell in the
29
* Debug UI Plugin dialog settings under the provided dialog settings section name
31
* @param shell The shell whose geometry is to be stored
32
* @param dialogSettingsSectionName The name of the dialog settings section
34
public static void persistShellGeometry(Shell shell, String dialogSettingsSectionName) {
35
Point shellLocation = shell.getLocation();
36
Point shellSize = shell.getSize();
37
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
38
settings.put(IMakeUIPreferenceConstants.DIALOG_ORIGIN_X, shellLocation.x);
39
settings.put(IMakeUIPreferenceConstants.DIALOG_ORIGIN_Y, shellLocation.y);
40
settings.put(IMakeUIPreferenceConstants.DIALOG_WIDTH, shellSize.x);
41
settings.put(IMakeUIPreferenceConstants.DIALOG_HEIGHT, shellSize.y);
44
private static IDialogSettings getDialogSettings(String dialogSettingsSectionName) {
45
IDialogSettings settings = MakeUIPlugin.getDefault().getDialogSettings();
46
IDialogSettings section = settings.getSection(dialogSettingsSectionName);
47
if (section == null) {
48
section = settings.addNewSection(dialogSettingsSectionName);
54
* Returns the initial size which is the larger of the <code>initialSize</code> or
55
* the size persisted in the Debug UI Plugin dialog settings under the provided dialog setttings section name.
56
* If no size is persisted in the settings, the <code>initialSize</code> is returned.
58
* @param initialSize The initialSize to compare against
59
* @param dialogSettingsSectionName The name of the dialog settings section
60
* @return the initial size
62
public static Point getInitialSize(String dialogSettingsSectionName, Point initialSize) {
63
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
66
x = settings.getInt(IMakeUIPreferenceConstants.DIALOG_WIDTH);
67
y = settings.getInt(IMakeUIPreferenceConstants.DIALOG_HEIGHT);
68
return new Point(Math.max(x, initialSize.x), Math.max(y, initialSize.y));
69
} catch (NumberFormatException e) {
75
* Returns the initial location which is persisted in the Debug UI Plugin dialog settings
76
* under the provided dialog setttings section name.
77
* If location is not persisted in the settings, the <code>null</code> is returned.
79
* @param dialogSettingsSectionName The name of the dialog settings section
80
* @return The initial location or <code>null</code>
82
public static Point getInitialLocation(String dialogSettingsSectionName) {
83
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
85
int x= settings.getInt(IMakeUIPreferenceConstants.DIALOG_ORIGIN_X);
86
int y= settings.getInt(IMakeUIPreferenceConstants.DIALOG_ORIGIN_Y);
87
return new Point(x,y);
88
} catch (NumberFormatException e) {