Skip to main content
summaryrefslogtreecommitdiffstats
blob: 87d55d5de8d4b63255f267c51fd40041dc58a73f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 * Copyright (c) 2008 SAP AG and others.
 * 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:
 * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.dialogs;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
import org.eclipse.swt.widgets.Shell;

public class DependencyConflictResolveDialog extends MessageDialogWithToggle {
	
	public static final int BTN_ID_OK = 0;
	public static final int BTN_ID_CANCEL = 1;
	
	public static final int DLG_TYPE_1 = 1;
	public static final int DLG_TYPE_2 = 2;
	
	public static final String DONT_SHOW_AGAIN = "DependencyConflictResolveDialog.DONT_SHOW_AGAIN";  //$NON-NLS-1$
	
	public DependencyConflictResolveDialog(Shell parentShell, 
			int dlgType) {
		
		super(parentShell, 
				J2EEUIMessages.getResourceString(J2EEUIMessages.DEPENDENCY_CONFLICT_TITLE), 
				null, 
				J2EEUIMessages.getResourceString((dlgType == DLG_TYPE_1) ? 
						J2EEUIMessages.DEPENDENCY_CONFLICT_MSG_1 :
						J2EEUIMessages.DEPENDENCY_CONFLICT_MSG_2)
						
				, MessageDialog.WARNING,
				
				new String[] { J2EEUIMessages.OK_BUTTON, 
					J2EEUIMessages.CANCEL_BUTTON }, 
				BTN_ID_CANCEL,
				J2EEUIMessages.getResourceString(J2EEUIMessages.DO_NOT_SHOW_WARNING_AGAIN),
				false);
	}
		
	@Override
	public int open() {
		if (getPrefStore().getBoolean(DONT_SHOW_AGAIN))
			return BTN_ID_OK;
		setToggleState(getPrefStore().getBoolean(DONT_SHOW_AGAIN));
		return super.open();
	}
	
	@Override
	public boolean close() {
		getPrefStore().setValue(DONT_SHOW_AGAIN, getToggleState());
		return super.close();
	}
	
	@Override
	public IPreferenceStore getPrefStore() {
		return J2EEUIPlugin.getDefault().getPreferenceStore();
	}
}

Back to the top