Author: timotei
Date: Sat Jul 30 10:01:40 2011
New Revision: 50488
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50488&view=rev
Log:
eclipse plugin: Implement the import project wizard
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectPage.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectWizard.java
Modified:
trunk/utils/umc_dev/org.wesnoth/plugin.xml
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/action/ImportMap.java
Modified: trunk/utils/umc_dev/org.wesnoth/plugin.xml
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/plugin.xml?rev=50488&r1=50487&r2=50488&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/plugin.xml (original)
+++ trunk/utils/umc_dev/org.wesnoth/plugin.xml Sat Jul 30 10:01:40 2011
@@ -810,5 +810,22 @@
genModel = "org/wesnoth/WML.genmodel" />
</extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <category
+ id="org.wesnoth.importWizards"
+ name="Wesnoth">
+ </category>
+ <wizard
+ category="org.wesnoth.importWizards"
+ class="org.wesnoth.importWizards.ImportProjectWizard"
+ icon="icons/wesnoth-icon_16.png"
+ id="org.wesnoth.projectImportWizard"
+ name="Import Wesnoth Project">
+ <description>
+ Import a directory as a wesnoth project
+ </description>
+ </wizard>
+ </extension>
</plugin>
Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/action/ImportMap.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/action/ImportMap.java?rev=50488&r1=50487&r2=50488&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/action/ImportMap.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/action/ImportMap.java Sat
Jul 30 10:01:40 2011
@@ -11,7 +11,6 @@
import org.eclipse.jface.action.IAction;
import org.wesnoth.utils.MapUtils;
-
public class ImportMap extends ObjectActionDelegate
{
/**
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectPage.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectPage.java?rev=50488&view=auto
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectPage.java
(added)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectPage.java
Sat Jul 30 10:01:40 2011
@@ -1,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by Timotei Dolean <[email protected]>
+ *
+ * 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
+
*******************************************************************************/
+package org.wesnoth.importWizards;
+
+import java.io.File;
+
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.wesnoth.installs.WesnothInstallsUtils;
+import org.wesnoth.wizards.WizardPageTemplate;
+
+public class ImportProjectPage extends WizardPageTemplate
+{
+ private DirectoryFieldEditor projectPathField_;
+ private Text txtProjectName_;
+ private Combo cmbInstalls_;
+
+ protected ImportProjectPage( )
+ {
+ super( "importProjectPage0" );
+
+ setTitle( "Import directory as wesnoth project" );
+ setMessage( "Import a directory as a wesnoth project." );
+ setPageComplete( false );
+ }
+
+ @Override
+ public void createControl( Composite parent )
+ {
+ super.createControl( parent );
+ Composite container = new Composite(parent, SWT.NULL);
+ setControl( container );
+
+ ModifyListener listener = new ModifyListener( ) {
+
+ @Override
+ public void modifyText( ModifyEvent e )
+ {
+ updatePageIsComplete();
+ }
+ };
+
+ projectPathField_ = new DirectoryFieldEditor( "project_path",
+ "Directory to import:", container );
+ projectPathField_.getTextControl( container ).addModifyListener(
listener );
+
+ Label lblNewLabel = new Label(container, SWT.NONE);
+ lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
false, 1, 1));
+ lblNewLabel.setText("Project Name:");
+
+ txtProjectName_ = new Text(container, SWT.BORDER);
+ txtProjectName_.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true,
false, 2, 1));
+ txtProjectName_.addModifyListener( listener );
+
+ Label lblWesnothInstall = new Label(container, SWT.NONE);
+ lblWesnothInstall.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
false, false, 1, 1));
+ lblWesnothInstall.setText("Wesnoth install:");
+
+ cmbInstalls_ = new Combo(container, SWT.READ_ONLY);
+ cmbInstalls_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false, 2, 1));
+ WesnothInstallsUtils.fillComboWithInstalls( cmbInstalls_ );
+ }
+
+ protected void updatePageIsComplete()
+ {
+ setPageComplete(
+ ! txtProjectName_.getText( ).isEmpty( ) &&
+ new File( projectPathField_.getStringValue( ) ).exists( ) );
+ }
+
+ /**
+ * Returns the imported project's path
+ * @return A string with the project path
+ */
+ public String getProjectPath( )
+ {
+ return projectPathField_.getStringValue( );
+ }
+
+ /**
+ * Returns the imported project's name
+ * @return A string with the imported project's name
+ */
+ public String getProjectName( )
+ {
+ return txtProjectName_.getText( );
+ }
+
+ /**
+ * Returns the selected install name
+ * @return A string with the selected install name
+ */
+ public String getSelectedInstallName()
+ {
+ return cmbInstalls_.getText( );
+ }
+}
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectWizard.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectWizard.java?rev=50488&view=auto
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectWizard.java
(added)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/importWizards/ImportProjectWizard.java
Sat Jul 30 10:01:40 2011
@@ -1,0 +1,55 @@
+package org.wesnoth.importWizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.IImportWizard;
+import org.wesnoth.Logger;
+import org.wesnoth.projects.ProjectUtils;
+import org.wesnoth.wizards.WizardTemplate;
+
+public class ImportProjectWizard extends WizardTemplate implements
IImportWizard
+{
+ private ImportProjectPage page0_;
+
+ public ImportProjectWizard()
+ {
+
+ }
+
+ @Override
+ public void addPages()
+ {
+ super.addPages( );
+
+ page0_ = new ImportProjectPage( );
+ addPage( page0_ );
+ }
+
+ @Override
+ public boolean performFinish()
+ {
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ {
+ ProjectUtils.createWesnothProject( page0_.getProjectName( ),
+ page0_.getProjectPath( ),
page0_.getSelectedInstallName(),
+ monitor );
+ monitor.done();
+ }
+ };
+ try
+ {
+ getContainer().run(false, false, op);
+ } catch (InterruptedException e)
+ {
+ return false;
+ } catch (InvocationTargetException e)
+ {
+ Logger.getInstance().logException(e);
+ }
+ return true;
+ }
+}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits