use of org.eclipse.wst.server.core.IRuntimeType in project liferay-ide by liferay.
the class CustomJspPage method _getExistLiferay70Runtime.
private IRuntime _getExistLiferay70Runtime() {
Set<IRuntime> liferayRuntimes = ServerUtil.getAvailableLiferayRuntimes();
for (IRuntime liferayRuntime : liferayRuntimes) {
File customJspFile = liferayRuntime.getLocation().toFile();
IRuntimeType runtimeType = liferayRuntime.getRuntimeType();
if (runtimeType.getId().equals("com.liferay.ide.server.portal.runtime") && customJspFile.exists()) {
return liferayRuntime;
}
}
return null;
}
use of org.eclipse.wst.server.core.IRuntimeType in project liferay-ide by liferay.
the class ServerUtil method getRuntime.
public static IRuntimeWorkingCopy getRuntime(String runtimeTypeId, IPath location) {
IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeId);
try {
// $NON-NLS-1$
IRuntime runtime = runtimeType.createRuntime("runtime", null);
IRuntimeWorkingCopy runtimeWC = runtime.createWorkingCopy();
// $NON-NLS-1$
runtimeWC.setName("Runtime");
runtimeWC.setLocation(location);
return runtimeWC;
} catch (CoreException e) {
e.printStackTrace();
}
return null;
}
use of org.eclipse.wst.server.core.IRuntimeType in project liferay-ide by liferay.
the class LiferayRuntimeStubDelegate method getTempRuntime.
protected IRuntimeWorkingCopy getTempRuntime() {
if (tempRuntime == null && getRuntime().getLocation() != null) {
IRuntimeType runtimeType = ServerCore.findRuntimeType(getRuntimeStubTypeId());
try {
// $NON-NLS-1$
tempRuntime = runtimeType.createRuntime(getRuntimeStubTypeId() + "-stub", new NullProgressMonitor());
tempRuntime.setLocation(getRuntime().getLocation());
} catch (CoreException e) {
// $NON-NLS-1$
LiferayServerCore.logError("Error creating runtime", e);
}
}
if (tempRuntime.getLocation() == null || !(tempRuntime.getLocation().equals(getRuntime().getLocation()))) {
tempRuntime.setLocation(getRuntime().getLocation());
}
return tempRuntime;
}
use of org.eclipse.wst.server.core.IRuntimeType in project liferay-ide by liferay.
the class LiferayServerCore method saveGlobalRuntimeSettings.
private synchronized void saveGlobalRuntimeSettings(IRuntime runtime) {
final IRuntimeType runtimeType = runtime.getRuntimeType();
if (runtimeType != null && runtimeType.getId().startsWith("com.liferay")) {
try {
LiferayCore.GLOBAL_SETTINGS_PATH.toFile().mkdirs();
final File runtimesGlobalFile = LiferayCore.GLOBAL_SETTINGS_PATH.append("runtimes.xml").toFile();
final Set<IMemento> existing = new HashSet<IMemento>();
if (runtimesGlobalFile.exists()) {
try {
try (InputStream newInputStream = Files.newInputStream(runtimesGlobalFile.toPath())) {
IMemento existingMemento = XMLMemento.loadMemento(newInputStream);
if (existingMemento != null) {
IMemento[] children = existingMemento.getChildren("runtime");
if (ListUtil.isNotEmpty(children)) {
for (IMemento child : children) {
final IPath loc = Path.fromPortableString(child.getString("location"));
if (loc != null && loc.toFile().exists()) {
boolean duplicate = ServerCore.findRuntime(child.getString("id")) != null;
if (!duplicate) {
existing.add(child);
}
}
}
}
}
}
} catch (Exception e) {
}
}
final Map<String, IMemento> mementos = new HashMap<String, IMemento>();
final XMLMemento runtimeMementos = XMLMemento.createWriteRoot("runtimes");
for (IMemento exist : existing) {
final IMemento copy = runtimeMementos.createChild("runtime");
copyMemento(exist, copy);
mementos.put(copy.getString("id"), copy);
}
for (IRuntime r : ServerCore.getRuntimes()) {
if (mementos.get(r.getId()) == null && r.getRuntimeType() != null) {
final IMemento rMemento = runtimeMementos.createChild("runtime");
if (addRuntimeToMemento(r, rMemento)) {
mementos.put(r.getId(), rMemento);
}
}
}
final OutputStream fos = Files.newOutputStream(runtimesGlobalFile.toPath());
runtimeMementos.save(fos);
} catch (Exception e) {
LiferayServerCore.logError("Unable to save global runtime settings", e);
}
}
}
use of org.eclipse.wst.server.core.IRuntimeType in project liferay-ide by liferay.
the class LiferayRuntimeStubComposite method createControl.
protected void createControl(Composite parent) {
setLayout(new GridLayout(2, false));
setLayoutData(new GridData(GridData.FILL_BOTH));
setBackground(parent.getBackground());
Label lblName = new Label(this, SWT.NONE);
lblName.setText(Msgs.name);
new Label(this, SWT.NONE);
textName = new Text(this, SWT.BORDER);
textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
runtimeWC.setName(textName.getText());
validate();
}
});
createSpacer();
Label lblRuntimeStubType = new Label(this, SWT.NONE);
lblRuntimeStubType.setText(Msgs.liferayBundleType);
createSpacer();
comboRuntimeStubType = new Combo(this, SWT.READ_ONLY);
comboRuntimeStubType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
createSpacer();
final Label lblInstall = new Label(this, SWT.WRAP);
lblInstall.setText(Msgs.liferayBundleDirectory);
new Label(this, SWT.NONE);
textInstallDir = new Text(this, SWT.BORDER);
textInstallDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
comboRuntimeStubType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = comboRuntimeStubType.getSelectionIndex();
ILiferayRuntimeStub selectedStub = LiferayServerCore.getRuntimeStubs()[index];
LiferayRuntimeStubDelegate delegate = getStubDelegate();
delegate.setRuntimeStubTypeId(selectedStub.getRuntimeStubTypeId());
String stubTypeId = selectedStub.getRuntimeStubTypeId();
IRuntimeType runtimeType = ServerCore.findRuntimeType(stubTypeId);
for (IRuntime runtime : ServerCore.getRuntimes()) {
if (runtime.getRuntimeType().equals(runtimeType)) {
textInstallDir.setText(runtime.getLocation().toOSString());
}
}
validate();
}
});
textInstallDir.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
textInstallDirChanged(textInstallDir.getText());
}
});
Button btnBrowse = new Button(this, SWT.NONE);
btnBrowse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
btnBrowse.setText(Msgs.browse);
btnBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
DirectoryDialog dialog = new DirectoryDialog(LiferayRuntimeStubComposite.this.getShell());
dialog.setMessage(Msgs.selectRuntimeStubDirectory);
dialog.setFilterPath(textInstallDir.getText());
String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
textInstallDir.setText(selectedDirectory);
}
}
});
new Label(this, SWT.NONE);
Dialog.applyDialogFont(this);
textName.forceFocus();
}
Aggregations