-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNewVersionWindow.java
More file actions
168 lines (137 loc) · 5.77 KB
/
Copy pathNewVersionWindow.java
File metadata and controls
168 lines (137 loc) · 5.77 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package com.application.areca.launcher.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import com.application.areca.ArecaURLs;
import com.application.areca.launcher.ArecaUserPreferences;
import com.application.areca.launcher.gui.common.AbstractWindow;
import com.application.areca.launcher.gui.common.ArecaImages;
import com.application.areca.launcher.gui.common.SavePanel;
import com.application.areca.launcher.gui.composites.Anchor;
import com.application.areca.launcher.gui.resources.ResourceManager;
/**
* <BR>
* @author Olivier PETRUCCI
* @author bugtamer
* <BR>
*
*/
/*
Copyright 2005-2015, Olivier PETRUCCI.
Copyright 2024, bugtamer.
This file is part of Areca.
Areca is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Areca is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Areca; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
public class NewVersionWindow
extends AbstractWindow {
private static final int widthHint = computeWidth(400);
private static final int heightHint = computeHeight(150);
private static final ResourceManager RM = ResourceManager.instance();
private String message;
private String title;
private boolean locked;
private boolean validated= false;
private Button checkNewVersions;
public NewVersionWindow(String message, boolean newVersion) {
super();
this.message = message;
if (newVersion) {
this.title = RM.getLabel("common.newversion.title");
locked = false;
} else {
this.title = RM.getLabel("common.versionok.title");
locked = true;
}
}
protected Control createContents(Composite parent) {
application.enableWaitCursor();
Composite ret = new Composite(parent, SWT.NONE);
try {
GridLayout layout = new GridLayout(2, false);
ret.setLayout(layout);
Label icon = new Label(ret, SWT.NONE);
icon.setImage(ArecaImages.ICO_BIG);
GridData dt = new GridData(SWT.CENTER, SWT.TOP, false, false, 1, 2);
icon.setLayoutData(dt);
Composite content = new Composite(ret, SWT.NONE);
content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Text txt = configurePanel(content, SWT.WRAP);
txt.setText(message);
checkNewVersions = new Button(ret, SWT.CHECK);
checkNewVersions.setText(RM.getLabel("preferences.checkversions.label"));
checkNewVersions.setToolTipText(RM.getLabel("preferences.checkversions.tt"));
checkNewVersions.setSelection(ArecaUserPreferences.isCheckNewVersions());
checkNewVersions.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
final String label = RM.getLabel("preferences.checkversions.official.site.label");
final Link lnk = Anchor.build(ret, ArecaURLs.ARECA_URL, label);
GridData dt3 = new GridData(SWT.CENTER, SWT.BOTTOM, false, false);
lnk.setLayoutData(dt3);
SavePanel pnlSave;
if (! locked) {
pnlSave = new SavePanel(RM.getLabel("common.yes.label"), RM.getLabel("common.no.label"), this);
pnlSave.setShowCancel(true);
} else {
pnlSave = new SavePanel(RM.getLabel("common.close.label"), this);
pnlSave.setShowCancel(false);
}
pnlSave.buildComposite(ret).setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
ret.pack();
} finally {
application.disableWaitCursor();
}
return ret;
}
private Text configurePanel(Composite composite, int style) {
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
GridData dt = new GridData();
dt.grabExcessHorizontalSpace = true;
dt.grabExcessVerticalSpace = true;
dt.verticalAlignment = SWT.FILL;
dt.horizontalAlignment = SWT.FILL;
dt.heightHint = heightHint;
dt.widthHint = widthHint;
Text content = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | style);
content.setEditable(false);
content.setLayoutData(dt);
return content;
}
protected boolean checkBusinessRules() {
return true;
}
public String getTitle() {
return title;
}
protected void cancelChanges() {
ArecaUserPreferences.setCheckNewVersion(checkNewVersions.getSelection());
super.cancelChanges();
}
protected void saveChanges() {
ArecaUserPreferences.setCheckNewVersion(checkNewVersions.getSelection());
validated = ! locked;
this.close();
}
protected void updateState(boolean rulesSatisfied) {
}
public boolean isValidated() {
return validated;
}
}