Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite125879

Browse files
author
zhourenjian
committed
1. Add ALAA options
2. Fixed bug that SWT_LIBRARY is not widely supported except VE is installed.3. Fixed bug that exporting Java2Script projects from update manager installed Java2Script environment may result in errors4. Add "Powered by Java2Script" in generated page
1 parent10e9965 commite125879

File tree

10 files changed

+561
-59
lines changed

10 files changed

+561
-59
lines changed

‎sources/net.sf.j2s.ui/plugin.xml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
<plugin>
44
<extension-pointid="externalResourceProvider"name="External Resource Provider"schema="schema/externalResourceProvider.exsd"/>
55

6+
<extension
7+
point="org.eclipse.jdt.core.classpathVariableInitializer">
8+
<classpathVariableInitializer
9+
class="net.sf.j2s.ui.variables.SWTVariableInitializer"
10+
variable="ECLIPSE_SWT"/>
11+
</extension>
12+
613
<extension
714
point="org.eclipse.ui.views">
815
<category

‎sources/net.sf.j2s.ui/src/net/sf/j2s/ui/launching/IJ2SLauchingConfiguration.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ public interface IJ2SLauchingConfiguration {
66
publicstaticfinalStringFAST_VIEW_J2S_CONSOLE ="fast.view.j2s.console";
77
publicstaticfinalStringMAXIMIZE_J2S_CONSOLE ="maximize.j2s.console";
88

9+
publicstaticfinalStringUSE_GLOBAL_ALAA_URL ="use.global.alaa.url";
10+
publicstaticfinalStringGLOBAL_J2SLIB_URL ="global.j2slib.url";
11+
publicstaticfinalStringGLOBAL_BINARY_URL ="global.bin.url";
12+
913
publicstaticfinalStringUSE_XHTML_HEADER ="use.xhtml.header";
1014
publicstaticfinalStringTAIL_BODY_HTML ="tail.body.html";
1115
publicstaticfinalStringHEAD_BODY_HTML ="head.body.html";

‎sources/net.sf.j2s.ui/src/net/sf/j2s/ui/launching/J2SConsoleOptionsTab.java‎

Lines changed: 205 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
packagenet.sf.j2s.ui.launching;
22

3+
importjava.io.File;
4+
importjava.io.FileInputStream;
5+
importjava.io.FileNotFoundException;
6+
importjava.io.IOException;
7+
importjava.util.Properties;
38
importnet.sf.j2s.ui.Java2ScriptUIPlugin;
49
importnet.sf.j2s.ui.preferences.PreferenceConstants;
10+
importnet.sf.j2s.ui.property.FileUtil;
11+
importnet.sf.j2s.ui.resources.ExternalResources;
12+
importorg.eclipse.core.resources.ResourcesPlugin;
513
importorg.eclipse.core.runtime.CoreException;
614
importorg.eclipse.debug.core.ILaunchConfiguration;
715
importorg.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
816
importorg.eclipse.debug.ui.AbstractLaunchConfigurationTab;
17+
importorg.eclipse.jdt.core.IJavaModel;
18+
importorg.eclipse.jdt.core.IJavaProject;
19+
importorg.eclipse.jdt.core.JavaCore;
20+
importorg.eclipse.jdt.core.JavaModelException;
921
importorg.eclipse.jdt.internal.debug.ui.JavaDebugImages;
22+
importorg.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
1023
importorg.eclipse.jface.preference.IPreferenceStore;
1124
importorg.eclipse.swt.SWT;
25+
importorg.eclipse.swt.events.FocusAdapter;
26+
importorg.eclipse.swt.events.FocusEvent;
27+
importorg.eclipse.swt.events.FocusListener;
28+
importorg.eclipse.swt.events.ModifyEvent;
29+
importorg.eclipse.swt.events.ModifyListener;
1230
importorg.eclipse.swt.events.SelectionAdapter;
1331
importorg.eclipse.swt.events.SelectionEvent;
1432
importorg.eclipse.swt.graphics.Font;
@@ -18,18 +36,32 @@
1836
importorg.eclipse.swt.widgets.Button;
1937
importorg.eclipse.swt.widgets.Composite;
2038
importorg.eclipse.swt.widgets.Group;
39+
importorg.eclipse.swt.widgets.Label;
40+
importorg.eclipse.swt.widgets.Text;
2141

2242
publicclassJ2SConsoleOptionsTabextendsAbstractLaunchConfigurationTab {
2343

24-
privateButtonbtnInner;
44+
ButtonbtnInner;
2545

26-
privateButtonbtnCompatiable;
46+
ButtonbtnCompatiable;
2747

28-
privateButtonbtnCompatiableRawJS;// whether import or include mozilla.addon.js
48+
ButtonbtnCompatiableRawJS;// whether import or include mozilla.addon.js
2949

30-
privateButtonbtnFastView;
50+
ButtonbtnFastView;
3151

32-
privateButtonbtnMaximize;
52+
ButtonbtnMaximize;
53+
54+
ButtonbtnUseGlobalURL;
55+
56+
ButtonbtnExternal;
57+
58+
LabellblJ2SLib;
59+
60+
TexttxtJ2SLib;
61+
62+
LabellblBin;
63+
64+
TexttxtBin;
3365

3466
publicJ2SConsoleOptionsTab() {
3567
super();
@@ -50,13 +82,13 @@ public void createControl(Composite parent) {
5082
group.setFont(font);
5183
layout =newGridLayout();
5284
group.setLayout(layout);
53-
group.setLayoutData(newGridData(GridData.FILL_BOTH));
85+
group.setLayoutData(newGridData(GridData.FILL_HORIZONTAL));
5486

55-
StringcontrolName ="Console Misc Options";
87+
StringcontrolName ="Java2ScriptConsole Misc Options";
5688
group.setText(controlName);
5789

58-
btnInner =newButton(group,SWT.CHECK);
59-
btnInner.setText("View Java2Script application inJ2Sconsole");
90+
btnInner =newButton(group,SWT.RADIO);
91+
btnInner.setText("InnerJ2SConsole");
6092
btnInner.addSelectionListener(newSelectionAdapter() {
6193
publicvoidwidgetSelected(SelectionEvente) {
6294
updateLaunchConfigurationDialog();
@@ -87,16 +119,26 @@ public void widgetSelected(SelectionEvent e) {
87119
}
88120
});
89121

90-
btnCompatiable =newButton(group,SWT.CHECK);
91-
btnCompatiable.setText("Generate codes with Mozilla Addon compatiabilities");
122+
btnExternal =newButton(group,SWT.RADIO);
123+
btnExternal.setText("Registered external browsers, like Firefox, IE");
124+
btnExternal.addSelectionListener(newSelectionAdapter() {
125+
publicvoidwidgetSelected(SelectionEvente) {
126+
updateLaunchConfigurationDialog();
127+
btnFastView.setEnabled(btnInner.getSelection());
128+
btnMaximize.setEnabled(btnInner.getSelection());
129+
}
130+
});
131+
132+
btnCompatiable =newButton(comp,SWT.CHECK);
133+
btnCompatiable.setText("Generate codes with Mozilla Add-on supports");
92134
btnCompatiable.addSelectionListener(newSelectionAdapter() {
93135
publicvoidwidgetSelected(SelectionEvente) {
94136
updateLaunchConfigurationDialog();
95137
btnCompatiableRawJS.setEnabled(btnCompatiable.getSelection());
96138
}
97139
});
98140

99-
btnCompatiableRawJS =newButton(group,SWT.CHECK);
141+
btnCompatiableRawJS =newButton(comp,SWT.CHECK);
100142
GridDatagdjs =newGridData();
101143
gdjs.horizontalIndent =32;
102144
btnCompatiableRawJS.setLayoutData(gdjs);
@@ -106,6 +148,56 @@ public void widgetSelected(SelectionEvent e) {
106148
updateLaunchConfigurationDialog();
107149
}
108150
});
151+
152+
btnUseGlobalURL =newButton(comp,SWT.CHECK);
153+
btnUseGlobalURL.setText("Use global *.js URL");
154+
btnUseGlobalURL.addSelectionListener(newSelectionAdapter() {
155+
publicvoidwidgetSelected(SelectionEvente) {
156+
updateLaunchConfigurationDialog();
157+
booleanselection =btnUseGlobalURL.getSelection();
158+
lblJ2SLib.setEnabled(selection);
159+
lblBin.setEnabled(selection);
160+
txtJ2SLib.setEnabled(selection);
161+
txtBin.setEnabled(selection);
162+
}
163+
});
164+
165+
CompositetxtComp =newComposite(comp,SWT.NONE);
166+
GridDatagdtxt =newGridData();
167+
gdtxt.horizontalIndent =32;
168+
txtComp.setLayoutData(gdtxt);
169+
txtComp.setLayout(newGridLayout(2,false));
170+
171+
lblJ2SLib =newLabel(txtComp,SWT.NONE);
172+
lblJ2SLib.setText("J2SLib base URL:");
173+
174+
txtJ2SLib =newText(txtComp,SWT.BORDER);
175+
GridDatagdtxt1 =newGridData();
176+
gdtxt1.widthHint =240;
177+
txtJ2SLib.setLayoutData(gdtxt1);
178+
FocusListenerfocusListener =newFocusAdapter() {
179+
publicvoidfocusGained(FocusEvente) {
180+
// select txt
181+
((Text)e.widget).selectAll();
182+
}
183+
};
184+
ModifyListenermodifyListener =newModifyListener() {
185+
publicvoidmodifyText(ModifyEvente) {
186+
updateLaunchConfigurationDialog();
187+
}
188+
};
189+
txtJ2SLib.addFocusListener(focusListener);
190+
txtJ2SLib.addModifyListener(modifyListener);
191+
192+
lblBin =newLabel(txtComp,SWT.NONE);
193+
lblBin.setText("Binary folder URL:");
194+
195+
txtBin =newText(txtComp,SWT.BORDER);
196+
GridDatagdtxt2 =newGridData();
197+
gdtxt2.widthHint =240;
198+
txtBin.setLayoutData(gdtxt2);
199+
txtBin.addFocusListener(focusListener);
200+
txtBin.addModifyListener(modifyListener);
109201
}
110202

111203
publicvoidsetDefaults(ILaunchConfigurationWorkingCopyconfiguration) {
@@ -129,6 +221,16 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
129221

130222
configuration.setAttribute(
131223
IJ2SLauchingConfiguration.J2S_MOZILLA_ADDON_COMPATIABLE_RAW_JS,true);
224+
225+
configuration.setAttribute(
226+
IJ2SLauchingConfiguration.USE_GLOBAL_ALAA_URL,false);
227+
228+
configuration.setAttribute(
229+
IJ2SLauchingConfiguration.GLOBAL_J2SLIB_URL,
230+
"http://archive.java2script.org/" +getCurrentReleaseAlias(configuration) +"/");
231+
232+
configuration.setAttribute(
233+
IJ2SLauchingConfiguration.GLOBAL_BINARY_URL,getCurrentBinPath(configuration));
132234
}
133235

134236
publicvoidinitializeFrom(ILaunchConfigurationconfiguration) {
@@ -148,6 +250,7 @@ public void initializeFrom(ILaunchConfiguration configuration) {
148250
booleanexternal =configuration.getAttribute(
149251
IJ2SLauchingConfiguration.VIEW_IN_INNER_J2S_CONSOLE,preferred);
150252
btnInner.setSelection(external);
253+
btnExternal.setSelection(!external);
151254
btnFastView.setEnabled(external);
152255
btnMaximize.setEnabled(external);
153256

@@ -158,11 +261,95 @@ public void initializeFrom(ILaunchConfiguration configuration) {
158261
btnCompatiable.setSelection(compatiable);
159262
btnCompatiableRawJS.setEnabled(compatiable);
160263

264+
booleanuseGlobal =configuration.getAttribute(
265+
IJ2SLauchingConfiguration.USE_GLOBAL_ALAA_URL,false);
266+
btnUseGlobalURL.setSelection(useGlobal);
267+
lblJ2SLib.setEnabled(useGlobal);
268+
lblBin.setEnabled(useGlobal);
269+
txtJ2SLib.setEnabled(useGlobal);
270+
txtBin.setEnabled(useGlobal);
271+
272+
txtJ2SLib.setText(configuration.getAttribute(
273+
IJ2SLauchingConfiguration.GLOBAL_J2SLIB_URL,
274+
"http://archive.java2script.org/" +getCurrentReleaseAlias(configuration) +"/"));
275+
276+
txtBin.setText(configuration.getAttribute(
277+
IJ2SLauchingConfiguration.GLOBAL_BINARY_URL,getCurrentBinPath(configuration)));
278+
161279
}catch (CoreExceptione) {
162280
e.printStackTrace();
163281
}
164282
}
165283

284+
privateStringgetCurrentBinPath(ILaunchConfigurationconfiguration) {
285+
IJavaModeljavaModel =JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
286+
try {
287+
StringprojectName =configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
288+
if ((projectName ==null) || (projectName.trim().length() <1)) {
289+
returnnull;
290+
}
291+
IJavaProjectjavaProject =javaModel.getJavaProject(projectName);
292+
if ((javaProject ==null) || !javaProject.exists()) {
293+
returnnull;
294+
}
295+
Stringpath =javaProject.getOutputLocation().toString();
296+
intidx =path.indexOf('/',2);
297+
StringrelativePath ="";
298+
if (idx != -1) {
299+
relativePath =path.substring(idx +1);
300+
}
301+
returnrelativePath;
302+
}catch (JavaModelExceptione) {
303+
e.printStackTrace();
304+
}catch (CoreExceptione) {
305+
e.printStackTrace();
306+
}
307+
return"bin/";
308+
}
309+
privateStringgetCurrentJ2SLibPath(FileworkingDir) {
310+
String[][]allResources =ExternalResources.getAllResources();
311+
Stringj2sLibPath =null;
312+
if (allResources !=null &&allResources.length !=0 &&allResources[0].length !=0) {
313+
if ((allResources[0][0]).startsWith("|")) {
314+
allResources[0][0] =FileUtil.toRelativePath(allResources[0][0].substring(1),
315+
workingDir.getAbsolutePath());;
316+
}
317+
j2sLibPath =allResources[0][0].substring(0,allResources[0][0].lastIndexOf("/") +1);
318+
}else {
319+
j2sLibPath ="../net.sf.j2s.lib/j2slib/";
320+
}
321+
returnj2sLibPath;
322+
}
323+
privateStringgetCurrentReleaseAlias(ILaunchConfigurationconfiguration) {
324+
FileworkingDir =null;
325+
try {
326+
workingDir =J2SLaunchingUtil.getWorkingDirectory(configuration);
327+
Stringj2sLibPath =getCurrentJ2SLibPath(workingDir);
328+
329+
Filej2slibFolder =newFile(workingDir.getAbsolutePath(),j2sLibPath);
330+
Filej2sRelease =newFile(j2slibFolder,".release");
331+
Propertiesrelease =newProperties();
332+
Stringalias ="1.0.0";
333+
Stringversion ="20070304";
334+
release.put("alias",alias);
335+
release.put("version",version);
336+
if (j2sRelease.exists()) {
337+
try {
338+
release.load(newFileInputStream(j2sRelease));
339+
}catch (FileNotFoundExceptione) {
340+
e.printStackTrace();
341+
}catch (IOExceptione) {
342+
e.printStackTrace();
343+
}
344+
alias =release.getProperty("alias");
345+
version =release.getProperty("version");
346+
}
347+
returnalias;
348+
}catch (CoreExceptione) {
349+
e.printStackTrace();
350+
return"1.0.0";
351+
}
352+
}
166353
publicvoidperformApply(ILaunchConfigurationWorkingCopyconfiguration) {
167354
configuration.setAttribute(IJ2SLauchingConfiguration.FAST_VIEW_J2S_CONSOLE,
168355
btnFastView.getSelection());
@@ -174,6 +361,12 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
174361
IJ2SLauchingConfiguration.J2S_MOZILLA_ADDON_COMPATIABLE,btnCompatiable.getSelection());
175362
configuration.setAttribute(
176363
IJ2SLauchingConfiguration.J2S_MOZILLA_ADDON_COMPATIABLE_RAW_JS,btnCompatiableRawJS.getSelection());
364+
configuration.setAttribute(
365+
IJ2SLauchingConfiguration.USE_GLOBAL_ALAA_URL,btnUseGlobalURL.getSelection());
366+
configuration.setAttribute(
367+
IJ2SLauchingConfiguration.GLOBAL_J2SLIB_URL,txtJ2SLib.getText());
368+
configuration.setAttribute(
369+
IJ2SLauchingConfiguration.GLOBAL_BINARY_URL,txtBin.getText());
177370
}
178371

179372
publicStringgetName() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp