[Esbox-commits] r24 - in
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui: . scratchbox
scratchbox/targets scratchbox/targets/wizards
scratchbox/targets/wizards/sbrsh wizards
raul at garage.maemo.org
raul at garage.maemo.org
Mon Oct 1 15:20:15 EEST 2007
Author: raul
Date: 2007-10-01 15:20:14 +0300 (Mon, 01 Oct 2007)
New Revision: 24
Added:
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/IValidatePage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/NewTargetWizard.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetListener.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCPUMethod.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCompilerPage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardDevkitsPage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardNamePage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardPageFactory.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationNFSServer.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationTargetDevice.java
Removed:
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/sbrsh/
Modified:
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/ESboxCommonProjectWizard.java
Log:
target wizards moved to others paths.
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/IValidatePage.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/IValidatePage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+/**
+ * A ValidateWizardPage must validade the information on it, so that the
+ * wizard can continue. For example, if the name of a target must be specified
+ * and the user don't do it, the wizard can't continue.
+ *
+ */
+public interface IValidatePage {
+
+ /**
+ * Performes the action related to some validation action.
+ * @return true, if the content of the page is correct; false, otherwise.
+ */
+ public boolean validatePage();
+
+}
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/NewTargetWizard.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/NewTargetWizard.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ScratchboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.ui.UIActivator;
+import org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+
+/**
+ * The target wizard provides a easy way to create a target
+ * for Scratchbox. As Scratchbox target configuration, the user
+ * can configure your target.
+ *
+ */
+public class NewTargetWizard extends Wizard implements INewWizard {
+
+ private ISelection selection;
+
+ protected WizardPage targetNamePage;
+ protected WizardPage compilerNamePage;
+ protected WizardPage devkitsName;
+ protected WizardPage cpuMethodName;
+ protected WizardPage sbrshConfigTargetDevice;
+ protected WizardPage sbrshConfigNFSServer;
+ protected IProject generatedProject;
+
+
+ /**
+ * Constructs a new target wizard.
+ */
+ public NewTargetWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ setWindowTitle("New Target");
+ ImageDescriptor image = UIActivator.getImageDescriptor("./icons/sample.gif");
+ setDefaultPageImageDescriptor(image);
+ initPages();
+ }
+
+ /**
+ * Inicializes the content of the pages.
+ */
+ private void initPages() {
+ targetNamePage = TargetWizardPageFactory.getInstance().createNamePage();
+ compilerNamePage = TargetWizardPageFactory.getInstance().createCompilerPage();
+ devkitsName = TargetWizardPageFactory.getInstance().createDevkitsPage();
+ cpuMethodName = TargetWizardPageFactory.getInstance().createCPUMethod();
+ sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance().createSbrshConfigDeviceTargetPage();
+ sbrshConfigNFSServer = TargetWizardPageFactory.getInstance().createSbrshConfigNFSSServer();
+ addPage(targetNamePage);
+ addPage(compilerNamePage);
+ addPage(devkitsName);
+ addPage(cpuMethodName);
+ addPage(sbrshConfigTargetDevice);
+ addPage(sbrshConfigNFSServer);
+ }
+
+ public boolean canFinish() {
+ boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
+ boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice).canFinish();
+ boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer).canFinish();
+ boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
+
+ if (sbrshConfigAccepted && NFSServer)
+ return true;
+ if (sbrshConfigAccepted && !configDevice )
+ return false;
+ if (!sbrshConfigAccepted && cpuPage )
+ return true;
+ return false;
+ }
+
+ @Override
+ public IWizardPage getNextPage(IWizardPage page) {
+ if(page == cpuMethodName) {
+ boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
+ if(!sbrshConfigAccepted) // user does not want to configure sbrsh
+ return null;
+ else // user wants to configure sbrsh
+ return super.getNextPage(page);
+ }
+ return super.getNextPage(page);
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizard#performFinish()
+ */
+ public boolean performFinish() {
+ String targetName = getTargetNameSelected();
+ String compilerName = getCompilerNameSelected();
+ String devkits = getDevkitsSelected();
+ String cpuMethod = getCputranspSelected();
+ try {
+ ScratchboxFacade.getInstance().createTarget(targetName, compilerName, devkits, cpuMethod);
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get create target " + targetName, e);
+ return false;
+ }
+
+ boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
+ if (sbrshConfigAccepted) {
+ configureSbrshService();
+ showsDialog();
+ }
+
+ //showMessage("Do you wish to extract a rootstrap on the target?");
+ //showMessage("Do you wish to install files to the target?");
+ return true;
+ }
+
+ /**
+ * Return the name of the target to be created.
+ * @return the name of the target to be created.
+ */
+ private String getTargetNameSelected() {
+ return ((TargetWizardNamePage) targetNamePage).text.getText();
+ }
+
+ /**
+ * Return the compiler name of the target to be created.
+ * @return the compiler name of the target to be created.
+ */
+ private String getCompilerNameSelected() {
+ TableItem item = ((TargetWizardCompilerPage) compilerNamePage).table.getSelection()[0];
+ return item.getText();
+ }
+
+ /**
+ * Return the devkits selected.
+ * @return the devkits selected.
+ */
+ private String getDevkitsSelected() {
+ String devkits = "";
+ TableItem devkitsSelected[] = ((TargetWizardDevkitsPage) devkitsName).table
+ .getSelection();
+ String separator = "";
+ for (int i = 0; i < devkitsSelected.length; i++) {
+ TableItem devkit = devkitsSelected[i];
+ devkits += separator + devkit.getText();
+ separator = ":";
+ }
+ return devkits;
+ }
+
+ /**
+ * Return the cputransp name of the target to be created.
+ * @return the cputransp name of the target to be created.
+ */
+ private String getCputranspSelected() {
+ TableItem item = ((TargetWizardCPUMethod) cpuMethodName).table.getSelection()[0];
+ return item.getText();
+ }
+
+ /**
+ * Configure sbrsh service.
+ */
+ private void configureSbrshService() {
+ String targetName = getTargetNameSelected();
+ String deviceTargetAddr = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceAddr();
+ String nfsHostname = ((SbrshConfigurationNFSServer)sbrshConfigNFSServer).getNFSHostname();
+
+ try {
+ ScratchboxFacade.getInstance().configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot configure sbrsh", e);
+ }
+ }
+
+
+ /**
+ * Add user at access list of the sbrshd running at the target device.
+ */
+ private void addUser() {
+ String deviceTargetIP = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceIP();
+ String username = System.getProperty("user.name");
+
+ try {
+ String localAddr = getLocalIP();
+ ScratchboxFacade.getInstance().addSbrshAccessList(deviceTargetIP, username, localAddr);
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot add user to the access list of sbrshd at the target device", e);
+ } catch (UnknownHostException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get local IP address", e);
+ }
+ }
+
+ /**
+ * Shows the dialog to ask the user if s/he wants to add his/herself to the acess list of the
+ * sbrshd.
+ */
+ private void showsDialog() {
+ String deviceTargetAddr = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceIP();
+ String text = "Do you what to add yourself to the access list of the sbrshd running at target device? \n";
+ text += "(This requires that "+ deviceTargetAddr +" has ssh daemon running and sbrshd already installed, and that you have root acess).";
+ boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
+ if(userAddedAtAccessList) {
+ addUser();
+ }
+ }
+
+ /**
+ * Display a dialog to ask what in string text
+ * @return the answer (yes or no)
+ */
+ private boolean showMessage(String text) {
+ return MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
+ }
+
+ /**
+ * Get the local IP address.
+ * @return the local IP address.
+ * @throws UnknownHostException
+ */
+ private String getLocalIP() throws UnknownHostException {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if
+ * we can initialize from it.
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+}
\ No newline at end of file
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetListener.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetListener.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.util.EventListener;
+
+/**
+ * Listener interested in some modification on targets.
+ */
+public interface TargetListener extends EventListener {
+
+ /**
+ * Notifies whenever a new target is added by the user.
+ */
+ public void targetAdded();
+
+ /**
+ * Notifies whenever a target is removed.
+ */
+ public void targetRemoved();
+
+ /**
+ * Notifies whenever a target is choosen.
+ * @param name the name of the target choosen.
+ */
+ public void targetChoosen(String name);
+}
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCPUMethod.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCPUMethod.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ScratchboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+import org.indt.esbox.ui.UIActivator;
+
+/**
+ * This pages shows the CPU-transparency method that the user can choose for his/her
+ * target. The CPU-transparency method provides a way so that the user can execute the
+ * executable.
+ *
+ */
+public class TargetWizardCPUMethod extends WizardPage implements IValidatePage {
+
+ protected Table table;
+ private boolean sbrshConfigure;
+
+ private static final String SBRSH = "sbrsh";
+
+ /**
+ * Creates a NewTargetWizardCPUMethod
+ */
+ protected TargetWizardCPUMethod() {
+ super("CPU-Transparency Method");
+ setTitle("CPU-Transparency Method");
+ setDescription("Select CPU-transparency method");
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ parent.setBounds(new Rectangle(600, 600, 600, 600));
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+ Label label = new Label(composite,SWT.LEFT);
+ label.setText("CPU-Transparency Methods"); //$NON-NLS-1$
+
+ table = new Table(composite, SWT.MULTI| SWT.BORDER | SWT.V_SCROLL);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ table.setLinesVisible(true);
+ //table.setSize(50, 50);
+ table.setHeaderVisible(false);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ for(TableItem item: table.getSelection())
+ if (item.getText().endsWith(TargetWizardCPUMethod.SBRSH)) // sbrsh was selected
+ acceptSbrshConfigure();
+ else { // sbrsh was not selected
+ setSbrshConfigure(false);
+ }
+ validatePage();
+ }
+ });
+
+ inicializeTable();
+ table.redraw();
+ setControl(composite);
+ }
+
+
+ private void setSbrshConfigure(boolean value) {
+ sbrshConfigure = value;
+ }
+
+ public boolean getSbrshConfigure() {
+ return sbrshConfigure;
+ }
+
+ /**
+ * Display a dialog to ask the user if s/he wants to configure sbrsh for the
+ * new target.
+ * @return true, if the user wants to configure sbrsh for the new target; false, otherwise.
+ */
+ public void acceptSbrshConfigure() {
+ String text = "Do you wish to configure sbrsh for your new target?";
+ sbrshConfigure = MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
+ }
+
+
+ public boolean canFinish() {
+ return isPageComplete();
+ }
+
+ /**
+ * Inicializes the contents of the table.
+ */
+ private void inicializeTable() {
+ List<String> targetMethod = null;
+ try {
+ targetMethod = ScratchboxFacade.getInstance().getCputransp();
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get list of CPU-Transparency Method", e);
+ return;
+ }
+
+ TableItem item = null;
+ for (String cputransp : targetMethod) {
+ item = new TableItem(table,SWT.NONE);
+ item.setText(cputransp);
+ }
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ setPageComplete(true);
+ return true;
+ }
+}
\ No newline at end of file
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCompilerPage.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardCompilerPage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ScratchboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+
+import org.indt.esbox.ui.UIActivator;
+
+/**
+ * This pages shows the compilers that the user can choose for his/her
+ * target. The compilers are disposed as a list with checkbox, so the user
+ * can select only one.
+ *
+ */
+public class TargetWizardCompilerPage extends WizardPage implements IValidatePage {
+
+ protected Table table;
+
+ /**
+ * Constructs a NewTargetWizardCompilerPage
+ */
+ protected TargetWizardCompilerPage() {
+ super("Compiler");
+ setTitle("Compiler");
+ setDescription("Select compiler");
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Label label = new Label(composite,SWT.LEFT);
+ label.setText("Compilers");
+
+ table = new Table(composite,SWT.SINGLE | SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ table.setLinesVisible(true);
+ table.setHeaderVisible(false);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ validatePage();
+ }
+ });
+
+ inicializeTable();
+
+ setControl(composite);
+ }
+
+ /**
+ * Inicializes the contents of the table.
+ */
+ private void inicializeTable() {
+ List<String> compilers = null;
+ try {
+ compilers = ScratchboxFacade.getInstance().getCompilers();
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get list of compilers", e);
+ return;
+ }
+
+ TableItem item = null;
+ for (String compilerName : compilers) {
+ item = new TableItem(table, SWT.NONE);
+ item.setText(compilerName);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ setPageComplete(true);
+ return true;
+ }
+
+}
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardDevkitsPage.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardDevkitsPage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ScratchboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+
+import org.indt.esbox.ui.UIActivator;
+
+/**
+ * This pages shows the devkits that the user can choose for his/her
+ * target.
+ *
+ */
+public class TargetWizardDevkitsPage extends WizardPage implements IValidatePage {
+
+ protected Table table;
+
+ /**
+ * Constructs a NewTargetWizardDevkitsPage.
+ */
+ protected TargetWizardDevkitsPage() {
+ super("Devkit");
+ setTitle("Devkit");
+ setDescription("Select devkits");
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Label label = new Label(composite,SWT.LEFT);
+ label.setText("Devkits");
+
+ table = new Table(composite,SWT.MULTI | SWT.CHECK | SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ table.setHeaderVisible(false);
+ table.setLinesVisible(true);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ validatePage();
+ }
+ });
+
+ inicializeTable();
+
+ setControl(composite);
+ }
+
+ /**
+ * Inicializes the contents of the table.
+ */
+ private void inicializeTable() {
+ TableItem item = null;
+ List<String> devkits = null;
+ try {
+ devkits = ScratchboxFacade.getInstance().getDevkits();
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get list of devkits", e);
+ return;
+ }
+ for (String devkit : devkits) {
+ item = new TableItem(table, SWT.NONE);
+ item.setText(devkit);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ TableItem[] items = table.getItems();
+ boolean noneSelected = false;
+ boolean pageOK = false;
+ //verifies if at least one option was checked.
+ for (int i = 0; i < items.length; i++) {
+ TableItem item = items[i];
+ if(item.getChecked()) {
+ pageOK = true;
+ break;
+ }
+ }
+ //verifies if the options were choosen properly.
+ for (int i = 0; i < items.length; i++) {
+ TableItem item = items[i];
+ //verifies if any item was selected.
+ if(item.getChecked()) {
+ //verifies if "none" was selected.
+ if(item.getText().equals("none")) {
+ noneSelected = true;
+ //the user cant select another devkit if "none" was selected.
+ } else {
+ pageOK = !noneSelected;
+ }
+ }
+ }
+ if(noneSelected && !pageOK) {
+ setErrorMessage("Selected corrects devkits.");
+ } else {
+ String msg = pageOK ? null : "Select at least one option";
+ setErrorMessage(msg);
+ }
+ setPageComplete(pageOK);
+ return pageOK;
+ }
+}
\ No newline at end of file
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardNamePage.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardNamePage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ScratchboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxFacade;
+
+import org.indt.esbox.ui.UIActivator;
+
+/**
+ * The user insert the name for the target. This name must be unique.
+ */
+public class TargetWizardNamePage extends WizardPage implements IValidatePage, TargetListener {
+
+ private List<String> targets;
+
+ protected Text text;
+
+ /**
+ * Constructs a NewTargetWizardNamePage.
+ */
+ protected TargetWizardNamePage() {
+ super("Target Name");
+ setTitle("Target Name");
+ setDescription("Enter name for the new target");
+ this.targetAdded();
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Label label = new Label(composite, SWT.LEFT);
+ label.setText("Target Name:");
+
+ text = new Text(composite, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ text.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent event) {
+ validatePage();
+ }
+
+ public void keyReleased(KeyEvent event) {
+ validatePage();
+ }
+ });
+
+ setControl(composite);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ String value = text.getText();
+ if(value.length() >= 1) {
+ setPageComplete(true);
+ } else {
+ setPageComplete(false);
+ }
+ boolean isValid = false;
+ isValid = verifyName();
+ setPageComplete(isValid);
+ return isValid;
+ }
+
+ /**
+ * Verify if the name of the target exists previously.
+ *
+ * @return
+ * true, if the name of the target have been defined already; false, otherwise.
+ */
+ private boolean verifyName() {
+ String targetName = text.getText().trim();
+ if(targets.contains(targetName)) {
+ setErrorMessage("This target name is already defined.");
+ return false;
+ } else {
+ setErrorMessage(null);
+ return true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.TargetWizardListener#targetAdded()
+ */
+ public void targetAdded() {
+ updateTargetList();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see dee.nokia.esbox.plugin.ui.internal.wizard.targets.TargetListener#targetRemoved()
+ */
+ public void targetRemoved() {
+ updateTargetList();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see dee.nokia.esbox.plugin.ui.internal.wizard.targets.TargetListener#targetChoosen(java.lang.String)
+ */
+ public void targetChoosen(String name) {
+ // for this wizard page, this action doesnt matter.
+ }
+
+ /**
+ * Update the list of target on Scratchbox. This process is done
+ * because the wizard needs to know the target to control the creation of
+ * new targets.
+ */
+ private void updateTargetList() {
+ try {
+ List<String> targetsOnSbox = ScratchboxFacade.getInstance().getTargets();
+ targets = new ArrayList<String>();
+ for (String target : targetsOnSbox) {
+ targets.add(target);
+ }
+ } catch (ScratchboxException e) {
+ ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Cannot get list of targets", e);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardPageFactory.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/TargetWizardPageFactory.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+/**
+ * Factory that creates all pages of the new target wizard.
+ *
+ */
+public class TargetWizardPageFactory {
+
+ private static TargetWizardPageFactory singleton = null;
+
+ /**
+ * Construtor
+ */
+ private TargetWizardPageFactory() {
+
+ }
+
+ /**
+ * Returns only one instance of TargetWizardPageFactory object.
+ * @return only one instance of TargetWizardPageFactory object.
+ */
+ public static TargetWizardPageFactory getInstance() {
+ if(singleton == null)
+ singleton = new TargetWizardPageFactory();
+ return singleton;
+ }
+
+ /**
+ * Creates a new name page.
+ * @return a new name page.
+ */
+ public WizardPage createNamePage() {
+ return new TargetWizardNamePage();
+ }
+
+ /**
+ * Creates a new compiler page.
+ * @return a new compiler page.
+ */
+ public WizardPage createCompilerPage() {
+ return new TargetWizardCompilerPage();
+ }
+
+ /**
+ * Creates a new CPU-method transparency page.
+ * @return a new CPU-method transparency page.
+ */
+ public WizardPage createCPUMethod() {
+ return new TargetWizardCPUMethod();
+ }
+
+ /**
+ * Creates a new devkit page.
+ * @return a new devkit page.
+ */
+ public WizardPage createDevkitsPage() {
+ return new TargetWizardDevkitsPage();
+ }
+
+ /**
+ * Create a new page to configure sbrsh device target.
+ * @return a new page to configure sbrsh device target.
+ */
+ public WizardPage createSbrshConfigDeviceTargetPage() {
+ return new SbrshConfigurationTargetDevice();
+ }
+
+ /**
+ * Create a new page to configure sbrsh nfs server.
+ * @return a new page to configure sbrsh nfs server.
+ */
+ public WizardPage createSbrshConfigNFSSServer() {
+ return new SbrshConfigurationNFSServer();
+ }
+}
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationNFSServer.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/sbrsh/SbrshConfigurationNFSServer.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/sbrsh/SbrshConfigurationNFSServer.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationNFSServer.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.indt.esbox.ui.scratchbox.targets.wizards.IValidatePage;
+
+/**
+ * A page for configuration of the NFS server.
+ */
+public class SbrshConfigurationNFSServer extends WizardPage implements KeyListener, IValidatePage {
+
+ private Text hostname;
+ private Text hostnameAddr;
+
+ /**
+ * Constructs a SbrshConfigurationNFSServer.
+ */
+ public SbrshConfigurationNFSServer() {
+ super("sbrsh.config.nfs.server"); //$NON-NLS-1$
+ setTitle("Sbrsh Configuration");
+ setDescription("NFS Server Configuration");
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Label description = new Label(composite,SWT.NONE);
+ description.setText("Enter hostname of NFS server");
+
+ hostname = new Text(composite, SWT.BORDER | SWT.LEFT);
+ hostname.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostname.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent event) {
+ validatePage();
+ }
+ public void keyReleased(KeyEvent event) {
+ //validatePage();
+ }
+ });
+
+
+ Composite addressComposite = new Composite(parent,SWT.NONE);
+ addressComposite.setLayout(new GridLayout(1,false));
+
+ hostnameAddr = new Text(addressComposite, SWT.BORDER | SWT.CENTER);
+ hostnameAddr.setTextLimit(40);
+
+ GridData newdata = new GridData(GridData.FILL);
+ newdata.grabExcessHorizontalSpace = true;
+ newdata.widthHint = 100;
+
+ hostnameAddr.setLayoutData(newdata);
+ setControl(composite);
+ }
+
+ public boolean canFinish() {
+ return isPageComplete();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ setPageComplete(true);
+ return true;
+ }
+
+
+ /**
+ * Verifies the values of the insert texts.
+ */
+ private void verifyValues() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyPressed(KeyEvent e) {
+ verifyValues();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ verifyValues();
+
+ }
+
+ /**
+ * Return the NFS hostname server.
+ * @return the NFS hostname server.
+ */
+ public String getNFSHostname() {
+ return hostname.getText();
+ }
+}
+
Copied: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationTargetDevice.java (from rev 12, trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/sbrsh/SbrshConfigurationTargetDevice.java)
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/sbrsh/SbrshConfigurationTargetDevice.java 2007-09-28 13:58:16 UTC (rev 12)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/scratchbox/targets/wizards/sbrsh/SbrshConfigurationTargetDevice.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.indt.esbox.ui.scratchbox.targets.wizards.sbrsh;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.indt.esbox.ui.scratchbox.targets.wizards.IValidatePage;
+
+/**
+ * A page for configuration of the device IP.
+ */
+public class SbrshConfigurationTargetDevice extends WizardPage implements KeyListener, IValidatePage {
+
+ protected Text[] targetAddress;
+ protected Text targetPortNumber;
+
+ protected final int TEXT_LIMIT_IP = 3;
+ protected final int TEXT_LIMIT_PORT = 4;
+ protected final int SIZE_ADDR = 4;
+ protected final int WIDTH_HINT = 40;
+
+ /**
+ * Constructs a SbrshConfigurationDeviceIP.
+ */
+ public SbrshConfigurationTargetDevice() {
+ super("sbrsh.config.target.device");
+ setTitle("Sbrsh Configuration");
+ setDescription("Target Device Name Configuration");
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Label description = new Label(composite,SWT.NONE);
+ description.setText("Enter hostname and port(optional) of the target device.");
+
+ initInputComponents(composite);
+
+ setControl(composite);
+ }
+
+ /**
+ * Init the GUI components.
+ * @param parent the parent composite.
+ */
+ protected void initInputComponents(Composite parent) {
+ Composite addressComposite = new Composite(parent,SWT.NONE);
+ addressComposite.setLayout(new GridLayout(10,false));
+
+ Label text = new Label(addressComposite, SWT.NONE);
+ text.setText("Target Device Address:");
+
+ GridData newdata;
+
+ targetAddress = new Text[SIZE_ADDR];
+ for (int i = 0; i < targetAddress.length; i++) {
+ targetAddress[i] = new Text(addressComposite, SWT.BORDER | SWT.CENTER);
+ targetAddress[i].setTextLimit(TEXT_LIMIT_IP);
+
+ newdata = new GridData(GridData.FILL);
+ newdata.grabExcessHorizontalSpace = true;
+ newdata.widthHint = WIDTH_HINT;
+
+ targetAddress[i].setLayoutData(newdata);
+ targetAddress[i].addKeyListener(this);
+ if(i < targetAddress.length - 1) {
+ Label point = new Label(addressComposite, SWT.NONE);
+ point.setText(".");
+ }
+ }
+ Label colon = new Label(addressComposite, SWT.NONE);
+ colon.setText(":");
+
+ targetPortNumber = new Text(addressComposite, SWT.BORDER | SWT.CENTER);
+ targetPortNumber.setTextLimit(TEXT_LIMIT_PORT);
+
+ newdata = new GridData(GridData.FILL);
+ newdata.grabExcessHorizontalSpace = true;
+ newdata.widthHint = WIDTH_HINT + 10;
+
+ targetPortNumber.setLayoutData(newdata);
+ targetPortNumber.addKeyListener(this);
+ }
+
+
+ public boolean canFinish() {
+ return isPageComplete();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
+ */
+ public boolean validatePage() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyPressed(KeyEvent e) {
+ verifyValues(e);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ verifyValues(e);
+ }
+
+ /**
+ * Verifies the values at the text.
+ * @param e the key event generated by the modification of any text.
+ */
+ private void verifyValues(KeyEvent e) {
+ String messageAddress = verifyAddress();
+ if(messageAddress == null) {
+ setErrorMessage(null);
+ setPageComplete(true);
+ } else {
+ setErrorMessage(messageAddress);
+ setPageComplete(false);
+ }
+ }
+
+ /**
+ * Verifies if the IP address inserted by the user is correct.
+ * @return true, if the IP address is correct; false, otherwise.
+ */
+ protected String verifyAddress() {
+ for (int i = 0; i < targetAddress.length; i++) {
+ try {
+ int value = Integer.parseInt(targetAddress[i].getText().trim());
+ if(value < 0 || value > 255) {
+ return "Insert a correct IP address.";
+ }
+ } catch (NumberFormatException nfe) {
+ return "Insert a correct value";
+ }
+ }
+
+ String portValue = targetPortNumber.getText().trim();
+ // value for port was inserted
+ if(!portValue.equals("")) {
+ try {
+ int value = Integer.parseInt(portValue);
+ if(value < 1 || value > 9999) {
+ return "Insert a correct value for port.";
+ }
+ } catch (NumberFormatException nfe) {
+ return "Insert a correct value";
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the target device IP inserted by user.
+ * @return the target device ip.
+ */
+ public String getTargetDeviceIP() {
+ final String SEPARATOR = ".";
+ String address = "";
+ String delimiter = "";
+ for (int i = 0; i < targetAddress.length; i++) {
+ address += delimiter + targetAddress[i].getText();
+ delimiter = SEPARATOR;
+ }
+ return address;
+ }
+
+ /**
+ * Return the target device address. The address has the IP and port number.
+ * @return the target device address.
+ */
+ public String getTargetDeviceAddr() {
+ String address = getTargetDeviceIP();
+ String port = getPort();
+ if(!port.equals("")) {
+ address += ":" + port;
+ }
+ return address;
+ }
+
+ /**
+ * Return the port number of the target device.
+ * @return the port number of target device.
+ */
+ public String getPort() {
+ return targetPortNumber.getText();
+ }
+
+}
\ No newline at end of file
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/ESboxCommonProjectWizard.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/ESboxCommonProjectWizard.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/ESboxCommonProjectWizard.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -442,7 +442,8 @@
protected void doPostProcess(IProject prj) {
configureScratchbox();
- configureTemplate();
+ if (newProject != null)
+ configureTemplate();
}
private void configureScratchbox() {
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/IValidatePage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,40 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-/**
- * A ValidateWizardPage must validade the information on it, so that the
- * wizard can continue. For example, if the name of a target must be specified
- * and the user don't do it, the wizard can't continue.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public interface IValidatePage {
-
- /**
- * Performes the action related to some validation action.
- * @return true, if the content of the page is correct; false, otherwise.
- */
- public boolean validatePage();
-
-}
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/NewTargetWizard.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,273 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-package org.indt.esbox.ui.wizards;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxFacade;
-import org.indt.esbox.ui.UIActivator;
-import org.indt.esbox.ui.wizards.sbrsh.SbrshConfigurationNFSServer;
-import org.indt.esbox.ui.wizards.sbrsh.SbrshConfigurationTargetDevice;
-
-
-/**
- * The target wizard provides a easy way to create a target
- * for Scratchbox. As Scratchbox target configuration, the user
- * can configure your target.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class NewTargetWizard extends Wizard implements INewWizard {
-
- private ISelection selection;
-
- protected WizardPage targetNamePage;
- protected WizardPage compilerNamePage;
- protected WizardPage devkitsName;
- protected WizardPage cpuMethodName;
- protected WizardPage sbrshConfigTargetDevice;
- protected WizardPage sbrshConfigNFSServer;
- protected IProject generatedProject;
-
-
- /**
- * Constructs a new target wizard.
- */
- public NewTargetWizard() {
- super();
- setNeedsProgressMonitor(true);
- setWindowTitle("New Target");
- ImageDescriptor image = UIActivator.getImageDescriptor("./icons/sample.gif");
- setDefaultPageImageDescriptor(image);
- initPages();
- }
-
- /**
- * Inicializes the content of the pages.
- */
- private void initPages() {
- targetNamePage = TargetWizardPageFactory.getInstance().createNamePage();
- compilerNamePage = TargetWizardPageFactory.getInstance().createCompilerPage();
- devkitsName = TargetWizardPageFactory.getInstance().createDevkitsPage();
- cpuMethodName = TargetWizardPageFactory.getInstance().createCPUMethod();
- sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance().createSbrshConfigDeviceTargetPage();
- sbrshConfigNFSServer = TargetWizardPageFactory.getInstance().createSbrshConfigNFSSServer();
- addPage(targetNamePage);
- addPage(compilerNamePage);
- addPage(devkitsName);
- addPage(cpuMethodName);
- addPage(sbrshConfigTargetDevice);
- addPage(sbrshConfigNFSServer);
- }
-
- public boolean canFinish() {
- boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
- boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice).canFinish();
- boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer).canFinish();
- boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
-
- if (sbrshConfigAccepted && NFSServer)
- return true;
- if (sbrshConfigAccepted && !configDevice )
- return false;
- if (!sbrshConfigAccepted && cpuPage )
- return true;
- return false;
- }
-
- @Override
- public IWizardPage getNextPage(IWizardPage page) {
- if(page == cpuMethodName) {
- boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
- if(!sbrshConfigAccepted) // user does not want to configure sbrsh
- return null;
- else // user wants to configure sbrsh
- return super.getNextPage(page);
- }
- return super.getNextPage(page);
- }
-
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- String targetName = getTargetNameSelected();
- String compilerName = getCompilerNameSelected();
- String devkits = getDevkitsSelected();
- String cpuMethod = getCputranspSelected();
- try {
- ScratchboxFacade.getInstance().createTarget(targetName, compilerName, devkits, cpuMethod);
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get create target " + targetName, e);
- return false;
- }
-
- boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName).getSbrshConfigure();
- if (sbrshConfigAccepted) {
- configureSbrshService();
- showsDialog();
- }
-
- //showMessage("Do you wish to extract a rootstrap on the target?");
- //showMessage("Do you wish to install files to the target?");
- return true;
- }
-
- /**
- * Return the name of the target to be created.
- * @return the name of the target to be created.
- */
- private String getTargetNameSelected() {
- return ((TargetWizardNamePage) targetNamePage).text.getText();
- }
-
- /**
- * Return the compiler name of the target to be created.
- * @return the compiler name of the target to be created.
- */
- private String getCompilerNameSelected() {
- TableItem item = ((TargetWizardCompilerPage) compilerNamePage).table.getSelection()[0];
- return item.getText();
- }
-
- /**
- * Return the devkits selected.
- * @return the devkits selected.
- */
- private String getDevkitsSelected() {
- String devkits = "";
- TableItem devkitsSelected[] = ((TargetWizardDevkitsPage) devkitsName).table
- .getSelection();
- String separator = "";
- for (int i = 0; i < devkitsSelected.length; i++) {
- TableItem devkit = devkitsSelected[i];
- devkits += separator + devkit.getText();
- separator = ":";
- }
- return devkits;
- }
-
- /**
- * Return the cputransp name of the target to be created.
- * @return the cputransp name of the target to be created.
- */
- private String getCputranspSelected() {
- TableItem item = ((TargetWizardCPUMethod) cpuMethodName).table.getSelection()[0];
- return item.getText();
- }
-
- /**
- * Configure sbrsh service.
- */
- private void configureSbrshService() {
- String targetName = getTargetNameSelected();
- String deviceTargetAddr = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceAddr();
- String nfsHostname = ((SbrshConfigurationNFSServer)sbrshConfigNFSServer).getNFSHostname();
-
- try {
- ScratchboxFacade.getInstance().configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot configure sbrsh", e);
- }
- }
-
-
- /**
- * Add user at access list of the sbrshd running at the target device.
- */
- private void addUser() {
- String deviceTargetIP = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceIP();
- String username = System.getProperty("user.name");
-
- try {
- String localAddr = getLocalIP();
- ScratchboxFacade.getInstance().addSbrshAccessList(deviceTargetIP, username, localAddr);
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot add user to the access list of sbrshd at the target device", e);
- } catch (UnknownHostException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get local IP address", e);
- }
- }
-
- /**
- * Shows the dialog to ask the user if s/he wants to add his/herself to the acess list of the
- * sbrshd.
- */
- private void showsDialog() {
- String deviceTargetAddr = ((SbrshConfigurationTargetDevice)sbrshConfigTargetDevice).getTargetDeviceIP();
- String text = "Do you what to add yourself to the access list of the sbrshd running at target device? \n";
- text += "(This requires that "+ deviceTargetAddr +" has ssh daemon running and sbrshd already installed, and that you have root acess).";
- boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
- if(userAddedAtAccessList) {
- addUser();
- }
- }
-
- /**
- * Display a dialog to ask what in string text
- * @return the answer (yes or no)
- */
- private boolean showMessage(String text) {
- return MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
- }
-
- /**
- * Get the local IP address.
- * @return the local IP address.
- * @throws UnknownHostException
- */
- private String getLocalIP() throws UnknownHostException {
- return InetAddress.getLocalHost().getHostAddress();
- }
-
- /**
- * We will accept the selection in the workbench to see if
- * we can initialize from it.
- * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.selection = selection;
- }
-}
\ No newline at end of file
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetListener.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,50 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import java.util.EventListener;
-
-/**
- * Listener interested in some modification on targets.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public interface TargetListener extends EventListener {
-
- /**
- * Notifies whenever a new target is added by the user.
- */
- public void targetAdded();
-
- /**
- * Notifies whenever a target is removed.
- */
- public void targetRemoved();
-
- /**
- * Notifies whenever a target is choosen.
- * @param name the name of the target choosen.
- */
- public void targetChoosen(String name);
-}
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCPUMethod.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,156 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxFacade;
-import org.indt.esbox.ui.UIActivator;
-
-/**
- * This pages shows the CPU-transparency method that the user can choose for his/her
- * target. The CPU-transparency method provides a way so that the user can execute the
- * executable.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class TargetWizardCPUMethod extends WizardPage implements IValidatePage {
-
- protected Table table;
- private boolean sbrshConfigure;
-
- private static final String SBRSH = "sbrsh";
-
- /**
- * Creates a NewTargetWizardCPUMethod
- */
- protected TargetWizardCPUMethod() {
- super("CPU-Transparency Method");
- setTitle("CPU-Transparency Method");
- setDescription("Select CPU-transparency method");
- setPageComplete(false);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- parent.setBounds(new Rectangle(600, 600, 600, 600));
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
- Label label = new Label(composite,SWT.LEFT);
- label.setText("CPU-Transparency Methods"); //$NON-NLS-1$
-
- table = new Table(composite, SWT.MULTI| SWT.BORDER | SWT.V_SCROLL);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- table.setLinesVisible(true);
- //table.setSize(50, 50);
- table.setHeaderVisible(false);
- table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- for(TableItem item: table.getSelection())
- if (item.getText().endsWith(TargetWizardCPUMethod.SBRSH)) // sbrsh was selected
- acceptSbrshConfigure();
- else { // sbrsh was not selected
- setSbrshConfigure(false);
- }
- validatePage();
- }
- });
-
- inicializeTable();
- table.redraw();
- setControl(composite);
- }
-
-
- private void setSbrshConfigure(boolean value) {
- sbrshConfigure = value;
- }
-
- public boolean getSbrshConfigure() {
- return sbrshConfigure;
- }
-
- /**
- * Display a dialog to ask the user if s/he wants to configure sbrsh for the
- * new target.
- * @return true, if the user wants to configure sbrsh for the new target; false, otherwise.
- */
- public void acceptSbrshConfigure() {
- String text = "Do you wish to configure sbrsh for your new target?";
- sbrshConfigure = MessageDialog.openQuestion(getShell(),"Scratchbox Configuration",text);
- }
-
-
- public boolean canFinish() {
- return isPageComplete();
- }
-
- /**
- * Inicializes the contents of the table.
- */
- private void inicializeTable() {
- List<String> targetMethod = null;
- try {
- targetMethod = ScratchboxFacade.getInstance().getCputransp();
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get list of CPU-Transparency Method", e);
- return;
- }
-
- TableItem item = null;
- for (String cputransp : targetMethod) {
- item = new TableItem(table,SWT.NONE);
- item.setText(cputransp);
- }
- }
-
-
-
- /*
- * (non-Javadoc)
- * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
- */
- public boolean validatePage() {
- setPageComplete(true);
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardCompilerPage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,120 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import java.util.List;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxFacade;
-
-import org.indt.esbox.ui.UIActivator;
-
-/**
- * This pages shows the compilers that the user can choose for his/her
- * target. The compilers are disposed as a list with checkbox, so the user
- * can select only one.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class TargetWizardCompilerPage extends WizardPage implements IValidatePage {
-
- protected Table table;
-
- /**
- * Constructs a NewTargetWizardCompilerPage
- */
- protected TargetWizardCompilerPage() {
- super("Compiler");
- setTitle("Compiler");
- setDescription("Select compiler");
- setPageComplete(false);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
-
- Label label = new Label(composite,SWT.LEFT);
- label.setText("Compilers");
-
- table = new Table(composite,SWT.SINGLE | SWT.BORDER);
- table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- table.setLinesVisible(true);
- table.setHeaderVisible(false);
- table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- validatePage();
- }
- });
-
- inicializeTable();
-
- setControl(composite);
- }
-
- /**
- * Inicializes the contents of the table.
- */
- private void inicializeTable() {
- List<String> compilers = null;
- try {
- compilers = ScratchboxFacade.getInstance().getCompilers();
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get list of compilers", e);
- return;
- }
-
- TableItem item = null;
- for (String compilerName : compilers) {
- item = new TableItem(table, SWT.NONE);
- item.setText(compilerName);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
- */
- public boolean validatePage() {
- setPageComplete(true);
- return true;
- }
-
-}
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardDevkitsPage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,148 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import java.util.List;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxFacade;
-
-import org.indt.esbox.ui.UIActivator;
-
-/**
- * This pages shows the devkits that the user can choose for his/her
- * target.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class TargetWizardDevkitsPage extends WizardPage implements IValidatePage {
-
- protected Table table;
-
- /**
- * Constructs a NewTargetWizardDevkitsPage.
- */
- protected TargetWizardDevkitsPage() {
- super("Devkit");
- setTitle("Devkit");
- setDescription("Select devkits");
- setPageComplete(false);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
-
- Label label = new Label(composite,SWT.LEFT);
- label.setText("Devkits");
-
- table = new Table(composite,SWT.MULTI | SWT.CHECK | SWT.BORDER);
- table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
- table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- validatePage();
- }
- });
-
- inicializeTable();
-
- setControl(composite);
- }
-
- /**
- * Inicializes the contents of the table.
- */
- private void inicializeTable() {
- TableItem item = null;
- List<String> devkits = null;
- try {
- devkits = ScratchboxFacade.getInstance().getDevkits();
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get list of devkits", e);
- return;
- }
- for (String devkit : devkits) {
- item = new TableItem(table, SWT.NONE);
- item.setText(devkit);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
- */
- public boolean validatePage() {
- TableItem[] items = table.getItems();
- boolean noneSelected = false;
- boolean pageOK = false;
- //verifies if at least one option was checked.
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- if(item.getChecked()) {
- pageOK = true;
- break;
- }
- }
- //verifies if the options were choosen properly.
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- //verifies if any item was selected.
- if(item.getChecked()) {
- //verifies if "none" was selected.
- if(item.getText().equals("none")) {
- noneSelected = true;
- //the user cant select another devkit if "none" was selected.
- } else {
- pageOK = !noneSelected;
- }
- }
- }
- if(noneSelected && !pageOK) {
- setErrorMessage("Selected corrects devkits.");
- } else {
- String msg = pageOK ? null : "Select at least one option";
- setErrorMessage(msg);
- }
- setPageComplete(pageOK);
- return pageOK;
- }
-}
\ No newline at end of file
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardNamePage.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,168 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxFacade;
-
-import org.indt.esbox.ui.UIActivator;
-
-/**
- * The user insert the name for the target. This name must be unique.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class TargetWizardNamePage extends WizardPage implements IValidatePage, TargetListener {
-
- private List<String> targets;
-
- protected Text text;
-
- /**
- * Constructs a NewTargetWizardNamePage.
- */
- protected TargetWizardNamePage() {
- super("Target Name");
- setTitle("Target Name");
- setDescription("Enter name for the new target");
- this.targetAdded();
- setPageComplete(false);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
-
- Label label = new Label(composite, SWT.LEFT);
- label.setText("Target Name:");
-
- text = new Text(composite, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- text.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent event) {
- validatePage();
- }
-
- public void keyReleased(KeyEvent event) {
- validatePage();
- }
- });
-
- setControl(composite);
- }
-
- /*
- * (non-Javadoc)
- * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage#perfomeAction()
- */
- public boolean validatePage() {
- String value = text.getText();
- if(value.length() >= 1) {
- setPageComplete(true);
- } else {
- setPageComplete(false);
- }
- boolean isValid = false;
- isValid = verifyName();
- setPageComplete(isValid);
- return isValid;
- }
-
- /**
- * Verify if the name of the target exists previously.
- *
- * @return
- * true, if the name of the target have been defined already; false, otherwise.
- */
- private boolean verifyName() {
- String targetName = text.getText().trim();
- if(targets.contains(targetName)) {
- setErrorMessage("This target name is already defined.");
- return false;
- } else {
- setErrorMessage(null);
- return true;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see br.edu.ufcg.dee.omapsdk.properties.target.wizard.TargetWizardListener#targetAdded()
- */
- public void targetAdded() {
- updateTargetList();
- }
-
- /*
- * (non-Javadoc)
- * @see dee.nokia.esbox.plugin.ui.internal.wizard.targets.TargetListener#targetRemoved()
- */
- public void targetRemoved() {
- updateTargetList();
- }
-
- /*
- * (non-Javadoc)
- * @see dee.nokia.esbox.plugin.ui.internal.wizard.targets.TargetListener#targetChoosen(java.lang.String)
- */
- public void targetChoosen(String name) {
- // for this wizard page, this action doesnt matter.
- }
-
- /**
- * Update the list of target on Scratchbox. This process is done
- * because the wizard needs to know the target to control the creation of
- * new targets.
- */
- private void updateTargetList() {
- try {
- List<String> targetsOnSbox = ScratchboxFacade.getInstance().getTargets();
- targets = new ArrayList<String>();
- for (String target : targetsOnSbox) {
- targets.add(target);
- }
- } catch (ScratchboxException e) {
- ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
- errorLogger.logAndShowError("Cannot get list of targets", e);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java 2007-10-01 12:17:12 UTC (rev 23)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/TargetWizardPageFactory.java 2007-10-01 12:20:14 UTC (rev 24)
@@ -1,104 +0,0 @@
-/**
- * ESbox is an Integrated Development Environment based on Eclipse plataform.
- * It offers several useful features to support the development of Embedded Applications.
- * Copyright (C) 2007 Embedded and Pervasive Computing Laboratory
-
- * This application is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-**/
-
-package org.indt.esbox.ui.wizards;
-
-import org.eclipse.jface.wizard.WizardPage;
-
-import org.indt.esbox.ui.wizards.sbrsh.SbrshConfigurationNFSServer;
-import org.indt.esbox.ui.wizards.sbrsh.SbrshConfigurationTargetDevice;
-
-/**
- * Factory that creates all pages of the new target wizard.
- *
- * @author Raul Fernandes Herbster - raulherbster at gmail dot com
- * @author Carolina Nogueira de Souza
- *
- */
-public class TargetWizardPageFactory {
-
- private static TargetWizardPageFactory singleton = null;
-
- /**
- * Construtor
- */
- private TargetWizardPageFactory() {
-
- }
-
- /**
- * Returns only one instance of TargetWizardPageFactory object.
- * @return only one instance of TargetWizardPageFactory object.
- */
- public static TargetWizardPageFactory getInstance() {
- if(singleton == null)
- singleton = new TargetWizardPageFactory();
- return singleton;
- }
-
- /**
- * Creates a new name page.
- * @return a new name page.
- */
- public WizardPage createNamePage() {
- return new TargetWizardNamePage();
- }
-
- /**
- * Creates a new compiler page.
- * @return a new compiler page.
- */
- public WizardPage createCompilerPage() {
- return new TargetWizardCompilerPage();
- }
-
- /**
- * Creates a new CPU-method transparency page.
- * @return a new CPU-method transparency page.
- */
- public WizardPage createCPUMethod() {
- return new TargetWizardCPUMethod();
- }
-
- /**
- * Creates a new devkit page.
- * @return a new devkit page.
- */
- public WizardPage createDevkitsPage() {
- return new TargetWizardDevkitsPage();
- }
-
- /**
- * Create a new page to configure sbrsh device target.
- * @return a new page to configure sbrsh device target.
- */
- public WizardPage createSbrshConfigDeviceTargetPage() {
- return new SbrshConfigurationTargetDevice();
- }
-
- /**
- * Create a new page to configure sbrsh nfs server.
- * @return a new page to configure sbrsh nfs server.
- */
- public WizardPage createSbrshConfigNFSSServer() {
- return new SbrshConfigurationNFSServer();
- }
-}
More information about the Esbox-commits
mailing list