blob: 43f5d339e70c05d5f1292fd8b1169de2afde573c [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.wizard.ui.allinonedsl;
import java.awt.Desktop;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.net.URI;
import org.eclipse.osbp.wizard.ui.AllInOneDSLsNewProjectWizard;
import org.eclipse.osbp.wizard.ui.basic.BasicNewProjectWizardPage;
import org.eclipse.osbp.wizard.ui.basic.CommonProjectWizardTranslator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
/**
* The Class AllInOneDSLsNewProjectRuntimePage.
* <br>
* Displays the urls for the applications and provides clickable links.
*/
public class AllInOneDSLsNewProjectRuntimePage extends BasicNewProjectWizardPage {
/**
* The listener interface for receiving webLink events.
* The class that is interested in processing a webLink
* event implements this interface, and the object created
* with that class is registered with a component using the
* component's <code>addWebLinkListener<code> method. When
* the webLink event occurs, that object's appropriate
* method is invoked.
*
* @see WebLinkEvent
*/
public class WebLinkListener implements Listener {
/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
@Override
public void handleEvent(Event event) {
try {
Desktop.getDesktop().browse(new URI(event.text));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Instantiates a new all in one DS ls new project runtime page.
*
* @param wizard the wizard
* @param pageName the page name
*/
public AllInOneDSLsNewProjectRuntimePage(final AllInOneDSLsNewProjectWizard wizard, String pageName) {
super(wizard, pageName);
}
@Override
protected final void createProjectNameGroup(Composite parent) {
AllInOneDSLsNewProjectWizard wizard = (AllInOneDSLsNewProjectWizard) super.wizard;
// new project label
int totalMemoryMB = (int)(Runtime.getRuntime().maxMemory() / (1024 * 1024));
int totalPhysicalMB = totalMemoryMB;
java.lang.management.OperatingSystemMXBean systemMxBean = ManagementFactory.getOperatingSystemMXBean();
try {
Class c = systemMxBean.getClass();
Method m = c.getDeclaredMethod("getTotalPhysicalMemorySize");
m.setAccessible(true);
Object l = m.invoke(systemMxBean);
if (l instanceof Long) {
totalPhysicalMB = (int)(((Long)l) / (1024 * 1024));
}
}
catch (Exception e) {
e.printStackTrace();
}
wizard.projectInfo.setTotalPhysicalMemoryInMB(totalPhysicalMB);
Label totalMemoryLabel = new Label(projectGroup, SWT.NONE);
totalMemoryLabel.setText(wizard.translator.getDocumentation(this,"labelTotalMemory"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
totalMemoryLabel.setFont(parent.getFont());
// new project name entry field
Text totalMemory = new Text(projectGroup, SWT.BORDER);
totalMemory.setLayoutData(data);
totalMemory.setFont(parent.getFont());
totalMemory.setEditable(false);
totalMemory.setText(""+totalPhysicalMB);
// new project label
Label xmsSizeLabel = new Label(projectGroup, SWT.NONE);
xmsSizeLabel.setText(wizard.translator.getDocumentation(this,"labelXmsSize"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
xmsSizeLabel.setFont(parent.getFont());
// new project name entry field
wizard.xmsSize = new Text(projectGroup, SWT.BORDER);
wizard.xmsSize.setLayoutData(data);
wizard.xmsSize.setFont(parent.getFont());
wizard.xmsSize.setEditable(true);
wizard.xmsSize.setText(wizard.projectInfo.getXmsSizeInMB());
// new project label
Label xmxSizeLabel = new Label(projectGroup, SWT.NONE);
xmxSizeLabel.setText(wizard.translator.getDocumentation(this,"labelXmxSize"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
xmxSizeLabel.setFont(parent.getFont());
// new project name entry field
wizard.xmxSize = new Text(projectGroup, SWT.BORDER);
wizard.xmxSize.setLayoutData(data);
wizard.xmxSize.setFont(parent.getFont());
wizard.xmxSize.setEditable(true);
wizard.xmxSize.setText(wizard.projectInfo.getXmxSizeInMB());
// new project label
Label productPortNoLabel = new Label(projectGroup, SWT.NONE);
productPortNoLabel.setText(wizard.translator.getDocumentation(this,"labelProductPortNo"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
productPortNoLabel.setFont(parent.getFont());
// new project name entry field
wizard.productPortNo = new Text(projectGroup, SWT.BORDER);
wizard.productPortNo.setLayoutData(data);
wizard.productPortNo.setFont(parent.getFont());
wizard.productPortNo.setEditable(true);
wizard.productPortNo.setText(wizard.projectInfo.getProductPortNo());
// new project label
Label productDesktopUrlPathLabel = new Label(projectGroup, SWT.NONE);
productDesktopUrlPathLabel.setText(wizard.translator.getDocumentation(this,"labelProductDesktopUrlPath"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
productDesktopUrlPathLabel.setFont(parent.getFont());
// new project name entry field
wizard.productDesktopUrlPath = new Text(projectGroup, SWT.BORDER);
wizard.productDesktopUrlPath.setLayoutData(data);
wizard.productDesktopUrlPath.setFont(parent.getFont());
wizard.productDesktopUrlPath.setEditable(true);
wizard.productDesktopUrlPath.setText(wizard.projectInfo.getProductDesktopUrlPath());
// new project label
Label productMobileUrlPathLabel = new Label(projectGroup, SWT.NONE);
productMobileUrlPathLabel.setText(wizard.translator.getDocumentation(this,"labelProductMobileUrlPath"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
productMobileUrlPathLabel.setFont(parent.getFont());
// new project name entry field
wizard.productMobileUrlPath = new Text(projectGroup, SWT.BORDER);
wizard.productMobileUrlPath.setLayoutData(data);
wizard.productMobileUrlPath.setFont(parent.getFont());
wizard.productMobileUrlPath.setEditable(false);
wizard.productMobileUrlPath.setText(wizard.projectInfo.getProductMobileUrlPath());
// new project label
Label productLocalDesktopLink = new Label(projectGroup, SWT.NONE);
productLocalDesktopLink.setText(wizard.translator.getDocumentation(this,"labelProductLocalDesktopLink"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
productLocalDesktopLink.setFont(parent.getFont());
// new project name entry field
wizard.productLocalDesktopLink = new Link(projectGroup, SWT.NONE);
wizard.productLocalDesktopLink.setLayoutData(data);
wizard.productLocalDesktopLink.setFont(parent.getFont());
wizard.productLocalDesktopLink.setText(wizard.projectInfo.getProductLocalDesktopLink());
wizard.productLocalDesktopLink.addListener(SWT.Selection, new WebLinkListener());
// new project label
Label productLocalMobileLink = new Label(projectGroup, SWT.NONE);
productLocalMobileLink.setText(wizard.translator.getDocumentation(this,"labelProductLocalMobileLink"));
// IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
productLocalMobileLink.setFont(parent.getFont());
// new project name entry field
wizard.productLocalMobileLink = new Link(projectGroup, SWT.NONE);
wizard.productLocalMobileLink.setLayoutData(data);
wizard.productLocalMobileLink.setFont(parent.getFont());
wizard.productLocalMobileLink.setText(wizard.projectInfo.getProductLocalMobileLink());
wizard.productLocalMobileLink.addListener(SWT.Selection, new WebLinkListener());
}
}