[Esbox-commits] r35 - in trunk/org.indt.esbox.ui: .
src/org/indt/esbox/ui src/org/indt/esbox/ui/properties
carolina at garage.maemo.org
carolina at garage.maemo.org
Tue Oct 2 17:14:17 EEST 2007
Author: carolina
Date: 2007-10-02 17:14:16 +0300 (Tue, 02 Oct 2007)
New Revision: 35
Added:
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/properties/
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/properties/ESboxProjectPropertyPage.java
Modified:
trunk/org.indt.esbox.ui/plugin.xml
Log:
[Task 485] Create properties pages
Now ESbox have a properties page.
Modified: trunk/org.indt.esbox.ui/plugin.xml
===================================================================
--- trunk/org.indt.esbox.ui/plugin.xml 2007-10-01 22:49:35 UTC (rev 34)
+++ trunk/org.indt.esbox.ui/plugin.xml 2007-10-02 14:14:16 UTC (rev 35)
@@ -12,9 +12,30 @@
icon="icons/maemo_project.png"
id="org.indt.esbox.ui.wizards.ESboxProjectWizard"
name="C/C++ Maemo Project">
+ </wizard>
+ <wizard
+ name="Creating Targets"
+ icon="icons/maemo_project.png"
+ class="org.indt.esbox.ui.scratchbox.targets.wizards.NewTargetWizard"
+ id="org.indt.esbox.ui.scratchbox.targets.wizards.NewTargetWizard">
</wizard>
+
</extension>
+
<extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.indt.esbox.ui.properties.ESboxProjectPropertyPage"
+ id="org.indt.esbox.ui.esboxProjectPropertyPage"
+ name="ESbox"
+ nameFilter="*">
+ <filter
+ name="nature"
+ value="org.indt.esbox.core.ESboxNature">
+ </filter>
+ </page>
+ </extension>
+ <extension
point="org.eclipse.cdt.core.templates">
<template
id="org.indt.esbox.ui.template.executable.emptyproject"
Added: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/properties/ESboxProjectPropertyPage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/properties/ESboxProjectPropertyPage.java 2007-10-01 22:49:35 UTC (rev 34)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/properties/ESboxProjectPropertyPage.java 2007-10-02 14:14:16 UTC (rev 35)
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * 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:
+ * Carolina Nogueira de Souza (carolina at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+
+package org.indt.esbox.ui.properties;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.indt.esbox.core.ESboxProjectProperties;
+import org.indt.esbox.core.maemosdk.MaemoSDKEngine;
+import org.indt.esbox.core.maemosdk.MaemoSDKInfo;
+import org.indt.esbox.core.platform.PlatformEngine;
+import org.indt.esbox.core.platform.PlatformInfo;
+
+/**
+ * This class implements the properties page of a ESbox project
+ */
+public class ESboxProjectPropertyPage extends PropertyPage {
+
+
+ /**
+ * Combo box with the list of known platforms
+ */
+ private Combo platforms;
+
+ /**
+ * Combo box with the list of known versions
+ */
+ private Combo maemoSDK;
+
+ private Text sdk;
+
+ private static final String SDK = "SDK";
+
+ protected Control createContents(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ Group groupTarget = new Group(composite, SWT.NONE);
+ groupTarget.setText("Target Name");
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ groupTarget.setLayoutData(data);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ groupTarget.setLayout(layout);
+
+ createLabel(groupTarget, "Target:", 1);
+ sdk = new Text(groupTarget, SWT.READ_ONLY | SWT.BORDER | SWT.SINGLE);
+ sdk.setText(SDK);
+
+ createLabel(groupTarget, "Platform:", 1);
+ platforms = createCombo(groupTarget, 3);
+
+ createLabel(groupTarget, "Version:", 1);
+ maemoSDK = createCombo2(groupTarget, 3);
+
+ return composite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ performApply();
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performApply()
+ */
+
+ public void performApply() {
+ IProject project = getProject();
+
+ String platform = platforms.getItem(platforms.getSelectionIndex());
+ String sdk = maemoSDK.getItem(maemoSDK.getSelectionIndex());
+
+ //ESboxProjectProperties.setTargetName(project, SDK);
+ ESboxProjectProperties.setMaemoSDK(project, sdk);
+ ESboxProjectProperties.setPlatform(project, platform);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ platforms.select(0);
+ maemoSDK.select(maemoSDK.getItemCount() - 1);
+
+ IProject project = getProject();
+ String platform = platforms.getItem(platforms.getSelectionIndex());
+ String sdk = maemoSDK.getItem(maemoSDK.getSelectionIndex());
+
+ //ESboxProjectProperties.setTargetName(project, SDK);
+ ESboxProjectProperties.setMaemoSDK(project, sdk);
+ ESboxProjectProperties.setPlatform(project, platform);
+ }
+
+ /**
+ * Utility method that creates a label instance
+ * and sets the default layout data.
+ *
+ * @param parent the parent for the new label
+ * @param text the text for the new label
+ * @return the new label
+ */
+ protected Label createLabel(Composite parent, String text, int span) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(text);
+ GridData data = new GridData();
+ data.horizontalSpan = span;
+ data.horizontalAlignment = GridData.FILL;
+ label.setLayoutData(data);
+
+ return label;
+ }
+
+ /**
+ * Create a text field specific for this application
+ *
+ * @param parent the parent of the new text field
+ * @return the new text field
+ */
+ protected Text createTextField(Composite parent, int span) {
+ Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
+ return layoutTextField(text, span);
+ }
+
+ /**
+ * Layout a text field specific for this application
+ *
+ * @param parent the parent of the new text field
+ * @return the new text field
+ */
+ protected Text layoutTextField(Text text, int span) {
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.verticalAlignment = GridData.CENTER;
+ data.grabExcessVerticalSpace = false;
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ data.horizontalSpan = span;
+ text.setLayoutData(data);
+ return text;
+ }
+
+ /**
+ * Utility method that creates a combo box
+ *
+ * @param parent the parent for the new label
+ * @return the new widget
+ */
+ protected Combo createCombo2(Composite parent, int span) {
+ Combo combo = new Combo(parent, SWT.READ_ONLY);
+ GridData data = new GridData();
+ combo.setLayoutData(data);
+
+ List<MaemoSDKInfo> maemoSDKList = MaemoSDKEngine.getInstance().getMaemoSDKS();
+
+
+ String selected = ESboxProjectProperties.getMaemoSDK(getProject());
+ if (selected != null)
+ for(MaemoSDKInfo maemoSDKInfo: maemoSDKList) {
+ combo.add(maemoSDKInfo.getVersion());
+ if (maemoSDKInfo.getVersion() == selected)
+ combo.select(combo.indexOf(maemoSDKInfo.getVersion()));
+ }
+ else
+ for(MaemoSDKInfo maemoSDKInfo: maemoSDKList)
+ combo.add(maemoSDKInfo.getVersion());
+
+ return combo;
+ }
+
+
+
+ /**
+ * Utility method that creates a combo box
+ *
+ * @param parent the parent for the new label
+ * @return the new widget
+ */
+ protected Combo createCombo(Composite parent, int span) {
+ Combo combo = new Combo(parent, SWT.READ_ONLY);
+ GridData data = new GridData();
+
+ combo.setLayoutData(data);
+
+ List<PlatformInfo> platformList = PlatformEngine.getInstance().getPlatforms();
+
+ String selected = ESboxProjectProperties.getPlatform(getProject());
+ if (selected != null)
+ for(PlatformInfo platformInfo: platformList) {
+ combo.add(platformInfo.getName());
+ if (platformInfo.getName() == selected)
+ combo.select(combo.indexOf(platformInfo.getName()));
+ }
+ else
+ for(PlatformInfo platformInfo: platformList)
+ combo.add(platformInfo.getName());
+
+ return combo;
+ }
+
+ private IProject getProject() {
+ IResource resource = (IResource)getElement().getAdapter(IResource.class);
+ IProject project = (IProject)resource;
+ return project;
+ }
+}
+
+
More information about the Esbox-commits
mailing list