aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-11-07 16:28:41 (EST)
committerAlexander Kurtakov2013-11-20 11:05:29 (EST)
commit14f3c54426122f417c33856f97c2291ed82f4011 (patch)
tree8cbd2f41e55b329243252f395874a501ee6e348a
parent2ce22c4cdd342b82d8c684fe2a76f787ccfd55fa (diff)
downloadorg.eclipse.linuxtools-14f3c54426122f417c33856f97c2291ed82f4011.zip
org.eclipse.linuxtools-14f3c54426122f417c33856f97c2291ed82f4011.tar.gz
org.eclipse.linuxtools-14f3c54426122f417c33856f97c2291ed82f4011.tar.bz2
RPM: createrepo new project wizardrefs/changes/97/18197/12
Add new project wizard. Creating a createrepo project will initialize the project with an empty content folder (place to store the *.rpms and repodata folder) and a simply intiialized .repo file with the mandatory options needed for a repository. Change-Id: Ia5a953c45430a7e89bcac825b91e67ffbaa64389 Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/18197 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF5
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/build.properties4
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/icons/newgroup_wiz.gifbin0 -> 366 bytes
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties4
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml29
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/pom.xml26
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java16
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java81
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties46
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageOne.java38
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageTwo.java195
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoWizard.java166
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java97
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectCreator.java52
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/ICreaterepoConstants.java35
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/IRepoFileConstants.java38
16 files changed, 829 insertions, 3 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF b/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF
index 5fce951..4a41977 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF
@@ -3,9 +3,12 @@ Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.linuxtools.rpm.createrepo;singleton:=true
Bundle-Version: 1.0.0.qualifier
+Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.internal.rpm.createrepo.Activator
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.8.101",
+ org.eclipse.ui.ide;bundle-version="3.9.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/build.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/build.properties
index 7d0d2b8..86176b2 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/build.properties
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/build.properties
@@ -12,4 +12,6 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.properties
+ plugin.properties,\
+ plugin.xml,\
+ icons/,
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/newgroup_wiz.gif b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/newgroup_wiz.gif
new file mode 100644
index 0000000..756342f
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/newgroup_wiz.gif
Binary files differ
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
index 7f665ff..0748954 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
@@ -10,3 +10,7 @@
###############################################################################
Bundle-Name = RPM Createrepo Plug-in
Bundle-Vendor = Eclipse Linux Tools
+
+editor.name = Repo Metadata Editor
+category.name = Createrepo
+wizard.name = Createrepo Wizard
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
new file mode 100644
index 0000000..6c4e1a1
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2013 Red Hat, Inc. and others.
+ All rights reserved. This program andthe 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:
+ Neil Guzman - initial API and implementation
+-->
+<plugin>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.eclipse.linuxtools.rpm.createrepo"
+ name="%category.name">
+ </category>
+ <wizard
+ category="org.eclipse.linuxtools.rpm.createrepo"
+ class="org.eclipse.linuxtools.internal.rpm.createrepo.wizard.CreaterepoWizard"
+ icon="icons/newgroup_wiz.gif"
+ id="org.eclipse.linuxtools.internal.rpm.createrepo.wizard.CreaterepoWizard"
+ name="%wizard.name"
+ project="true">
+ </wizard>
+ </extension>
+</plugin>
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/pom.xml b/rpm/org.eclipse.linuxtools.rpm.createrepo/pom.xml
new file mode 100644
index 0000000..062ea8c
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2013 Red Hat, Inc.
+
+ 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
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>linuxtools-rpm-parent</artifactId>
+ <groupId>org.eclipse.linuxtools.rpm</groupId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.linuxtools.rpm.createrepo</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Linux Tools RPM Createrepo Plug-in</name>
+
+</project>
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java
index 83bb1f1..53e4368 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java
@@ -10,11 +10,13 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.rpm.createrepo;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
- * The activator class controls the plug-in life cycle
+ * The activator class controls the plug-in life cycle.
*/
public class Activator extends AbstractUIPlugin {
@@ -57,4 +59,16 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ /**
+ * Log an error.
+ *
+ * @param message A human-readable message.
+ * @param exception The exception to log.
+ */
+ public static void logError(String message, Throwable exception) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message,
+ exception);
+ getDefault().getLog().log(status);
+ }
+
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java
new file mode 100644
index 0000000..101d87f
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages displayed across the plugin.
+ */
+public final class Messages {
+
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.rpm.createrepo.messages"; //$NON-NLS-1$
+
+ // CreaterepoWizard
+ /****/
+ public static String CreaterepoWizard_errorCreatingProject;
+ /****/
+ public static String CreaterepoWizard_openFileOnCreation;
+ /****/
+ public static String CreaterepoWizard_errorOpeningNewlyCreatedFile;
+ /****/
+ public static String CreaterepoWizard_errorCreatingFolder;
+
+ // CreaterepoNewWizardPageOne
+ /****/
+ public static String CreaterepoNewWizardPageOne_wizardPageName;
+ /****/
+ public static String CreaterepoNewWizardPageOne_wizardPageTitle;
+ /****/
+ public static String CreaterepoNewWizardPageOne_wizardPageDescription;
+
+ // CreaterepoNewWizardPageTwo
+ /****/
+ public static String CreaterepoNewWizardPageTwo_wizardPageName;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_wizardPageTitle;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_wizardPageDescription;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_labelID;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_labelName;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_labelURL;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_errorID;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_errorName;
+ /****/
+ public static String CreaterepoNewWizardPageTwo_errorURL;
+
+ // CreaterepoProjectCreator
+ /****/
+ public static String CreaterepoProjectCreator_errorSettingProjectLocation;
+
+ // CreaterepoProject
+ /****/
+ public static String CreaterepoProject_executeCreaterepo;
+ /****/
+ public static String CreaterepoProject_consoleName;
+ /****/
+ public static String CreaterepoProject_errorExecuting;
+ /****/
+ public static String CreaterepoProject_errorSettingPreferences;
+ /****/
+ public static String CreaterepoProject_errorGettingFile;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties
new file mode 100644
index 0000000..d74d76f
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties
@@ -0,0 +1,46 @@
+###############################################################################
+# Copyright (c) 2013 Red Hat Inc. and others.
+# 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:
+# Neil Guzman - initial API and implementation
+###############################################################################
+# CreaterepoWizard
+CreaterepoWizard_errorCreatingProject=Error while trying to create the project.
+CreaterepoWizard_openFileOnCreation=Opening the newly created repomd.xml file...
+CreaterepoWizard_errorOpeningNewlyCreatedFile=Error while trying to open the newly created \
+ repomd.xml file.
+CreaterepoWizard_errorCreatingFolder=Error while trying to create the folder.
+
+# CreaterepoNewWizardPageOne
+CreaterepoNewWizardPageOne_wizardPageName=New Createrepo Project
+CreaterepoNewWizardPageOne_wizardPageTitle=Create a new repository
+CreaterepoNewWizardPageOne_wizardPageDescription=This will create an xml-based rpm \
+ metadata repository from a set of rpms.
+
+# CreaterepoNewWizardPageTwo
+CreaterepoNewWizardPageTwo_wizardPageName=New Repo File
+CreaterepoNewWizardPageTwo_wizardPageTitle=Create a new repo file for the repository
+CreaterepoNewWizardPageTwo_wizardPageDescription=This will create a .repo file which \
+ will contain information on the repository.
+CreaterepoNewWizardPageTwo_labelID=&Repo ID:
+CreaterepoNewWizardPageTwo_labelName=&Name:
+CreaterepoNewWizardPageTwo_labelURL=&Base URL:
+CreaterepoNewWizardPageTwo_errorID=The repository ID is invalid. Make sure it is a single string.
+CreaterepoNewWizardPageTwo_errorName=The name of the repository is invalid. Make sure it is not empty
+CreaterepoNewWizardPageTwo_errorURL=The base URL is invalid. Make sure it has a valid protocol (http://, \
+ ftp://, file://)
+
+# CreaterepoProjectCreator
+CreaterepoProjectCreator_errorSettingProjectLocation=Error while trying to set the location of \
+ the project.
+
+# CreaterepoProject
+CreaterepoProject_executeCreaterepo=Executing createrepo...
+CreaterepoProject_consoleName=Createrepo Console
+CreaterepoProject_errorExecuting=Error executing the createrepo command: {0}
+CreaterepoProject_errorSettingPreferences=Error occured while trying to set the project preferences.
+CreaterepoProject_errorGettingFile=Error occured while trying to get the contents of the file.
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageOne.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageOne.java
new file mode 100644
index 0000000..528d277
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageOne.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo.wizard;
+
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * The sole purpose of this page is to create a new project for createrepo.
+ */
+public class CreaterepoNewWizardPageOne extends
+ WizardNewProjectCreationPage {
+
+ /*
+ * TODO: add in working sets
+ */
+
+ /**
+ * Constructor for CreaterepoWizardPage. Will set the page name, title, and
+ * description.
+ *
+ * @param pageName The wizard page's name.
+ */
+ public CreaterepoNewWizardPageOne(String pageName) {
+ super(pageName);
+ setTitle(Messages.CreaterepoNewWizardPageOne_wizardPageTitle);
+ setDescription(Messages.CreaterepoNewWizardPageOne_wizardPageDescription);
+ }
+
+} \ No newline at end of file
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageTwo.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageTwo.java
new file mode 100644
index 0000000..6d4cec8
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageTwo.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo.wizard;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoConstants;
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class CreaterepoNewWizardPageTwo extends WizardPage {
+
+ private Text repositoryIDTxt;
+ private Text repositoryNameTxt;
+ private Text repositoryBaseURLTxt;
+
+ /**
+ * Constructor for CreaterepoWizardPage. Will set the page name, title, and
+ * description.
+ *
+ * @param pageName The wizard page's name.
+ */
+ public CreaterepoNewWizardPageTwo(String pageName) {
+ super(pageName);
+ setTitle(Messages.CreaterepoNewWizardPageTwo_wizardPageTitle);
+ setDescription(Messages.CreaterepoNewWizardPageTwo_wizardPageDescription);
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ GridData layoutData = new GridData();
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.grabExcessVerticalSpace = true;
+ layoutData.horizontalAlignment = GridData.FILL;
+ layoutData.verticalAlignment = GridData.FILL;
+ container.setLayout(layout);
+ container.setLayoutData(layoutData);
+
+ // composite to hold the required information
+ Composite information = new Composite(container, SWT.NONE);
+ layout = new GridLayout(2, false);
+ layoutData = new GridData();
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.horizontalAlignment = GridData.FILL;
+ layoutData.verticalAlignment = GridData.CENTER;
+ information.setLayoutData(layoutData);
+ information.setLayout(layout);
+
+ // listen on modifying the Text widgets
+ ModifyListener modifyListner = new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(isValid());
+ }
+ };
+ repositoryIDTxt = createTextFieldWithLabel(information, Messages.CreaterepoNewWizardPageTwo_labelID);
+ repositoryIDTxt.addModifyListener(modifyListner);
+ repositoryNameTxt = createTextFieldWithLabel(information, Messages.CreaterepoNewWizardPageTwo_labelName);
+ repositoryNameTxt.addModifyListener(modifyListner);
+ repositoryBaseURLTxt = createTextFieldWithLabel(information, Messages.CreaterepoNewWizardPageTwo_labelURL);
+ repositoryBaseURLTxt.addModifyListener(modifyListner);
+ setControl(container);
+ }
+
+ /**
+ * Create a text field with a label.
+ *
+ * @param parent The parent of the text field and label.
+ * @param labelName The name on the label.
+ * @return The newly created text field.
+ */
+ protected Text createTextFieldWithLabel(Composite parent, String labelName) {
+ GridData layoutData = new GridData();
+ // create the label
+ Label respositoryBaseURLLbl = new Label(parent, SWT.NONE);
+ respositoryBaseURLLbl.setText(labelName);
+ layoutData = new GridData();
+ layoutData.horizontalAlignment = GridData.BEGINNING;
+ layoutData.verticalAlignment = GridData.CENTER;
+ // create the text field
+ Text textField = new Text(parent, SWT.BORDER | SWT.SINGLE);
+ layoutData = new GridData();
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.horizontalAlignment = GridData.FILL;
+ layoutData.verticalAlignment = GridData.CENTER;
+ textField.setLayoutData(layoutData);
+ return textField;
+ }
+
+ /**
+ * Check to see if all the text fields are valid. Otherwise, set error
+ * messages appropriately.
+ *
+ * @return True if all the text fields are valid, false otherwise.
+ */
+ protected boolean isValid() {
+ if (!validateID()) {
+ setErrorMessage(Messages.CreaterepoNewWizardPageTwo_errorID);
+ }
+ if (repositoryNameTxt.getText().trim().isEmpty()) {
+ setErrorMessage(Messages.CreaterepoNewWizardPageTwo_errorName);
+ }
+ if (!validateURL()) {
+ setErrorMessage(Messages.CreaterepoNewWizardPageTwo_errorURL);
+ }
+ if (validateID() && validateURL() && !repositoryNameTxt.getText().trim().isEmpty()) {
+ setErrorMessage(null);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check if the ID is valid. It is valid if it is a single string and
+ * not empty.
+ *
+ * @return True if the ID is valid, false otherwise.
+ */
+ private boolean validateID() {
+ // check if repository ID is a single string
+ String tmpRepoID = repositoryIDTxt.getText().trim();
+ Pattern singleStringPattern = Pattern.compile("\\b(\\S+)\\b", //$NON-NLS-1$
+ Pattern.CASE_INSENSITIVE);
+ Matcher singleStringMatcher = singleStringPattern.matcher(tmpRepoID);
+ if (singleStringMatcher.matches()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the URL is valid. It is valid if it contains a valid protocol and link.
+ *
+ * @return True if the URL is valid, false otherwise.
+ */
+ private boolean validateURL() {
+ // check if baseURL is a valid URL
+ String tmpRepoURL = repositoryBaseURLTxt.getText().trim();
+ // TODO: possibly validate if pointing to something that exists (not really necessary, but nice)
+ try {
+ new URL(tmpRepoURL);
+ return true;
+ } catch (MalformedURLException e) {
+ return false;
+ }
+ }
+
+ public String getRepositoryID() {
+ if (repositoryIDTxt == null) {
+ return ICreaterepoConstants.EMPTY_STRING;
+ }
+ return repositoryIDTxt.getText().trim();
+ }
+
+ public String getRepositoryName() {
+ if (repositoryNameTxt == null) {
+ return ICreaterepoConstants.EMPTY_STRING;
+ }
+ return repositoryNameTxt.getText().trim();
+ }
+
+ public String getRepositoryURL() {
+ if (repositoryBaseURLTxt == null) {
+ return ICreaterepoConstants.EMPTY_STRING;
+ }
+ return repositoryBaseURLTxt.getText().trim();
+ }
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoWizard.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoWizard.java
new file mode 100644
index 0000000..0dfd146
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoWizard.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo.wizard;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProjectCreator;
+import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoConstants;
+import org.eclipse.linuxtools.rpm.createrepo.IRepoFileConstants;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * This wizard will guide the user to creating a createrepo project. It will
+ * allow the user to initialize their .repo file.
+ */
+public class CreaterepoWizard extends Wizard implements INewWizard {
+
+ private CreaterepoNewWizardPageOne pageOne;
+ private CreaterepoNewWizardPageTwo pageTwo;
+ private IProject project;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setNeedsProgressMonitor(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ super.addPages();
+ pageOne = new CreaterepoNewWizardPageOne(
+ Messages.CreaterepoNewWizardPageOne_wizardPageName);
+ addPage(pageOne);
+ pageTwo = new CreaterepoNewWizardPageTwo(
+ Messages.CreaterepoNewWizardPageTwo_wizardPageName);
+ addPage(pageTwo);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ @Override
+ public boolean canFinish() {
+ return getContainer().getCurrentPage() == pageTwo && pageTwo.isPageComplete();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException {
+ createProject(monitor);
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Activator.logError(Messages.CreaterepoWizard_errorCreatingProject, e);
+ } catch (InterruptedException e) {
+ Activator.logError(Messages.CreaterepoWizard_errorCreatingProject, e);
+ }
+ return true;
+ }
+
+ /**
+ * Create a createrepo project that contains an empty content folder and
+ * a quickly initialized .repo file with the mandatory options.
+ *
+ * @param monitor The progress monitor.
+ */
+ protected void createProject(IProgressMonitor monitor) {
+ try {
+ // create the project
+ project = CreaterepoProjectCreator.create(pageOne.getProjectName(),
+ pageOne.getLocationPath(), monitor);
+ // get a handle on the content folder
+ IFolder folder = project
+ .getFolder(ICreaterepoConstants.CONTENT_FOLDER);
+ if (!folder.exists()) {
+ folder.create(false, true, monitor);
+ }
+ // get a handle on the .repo file
+ String fileName = pageTwo.getRepositoryID().concat("."+ICreaterepoConstants. //$NON-NLS-1$
+ REPO_FILE_EXTENSION);
+ final IFile file = project.getFile(fileName);
+ final String repoFileContents = initializeRepoContents(pageTwo.getRepositoryID(),
+ pageTwo.getRepositoryName(), pageTwo.getRepositoryURL());
+ InputStream stream = new ByteArrayInputStream(repoFileContents.getBytes());
+ if (file.exists()) {
+ file.setContents(stream, true, true, monitor);
+ } else {
+ file.create(stream, true, monitor);
+ }
+ monitor.worked(1);
+ monitor.setTaskName(Messages.CreaterepoWizard_openFileOnCreation);
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, true);
+ } catch (PartInitException e) {
+ Activator.logError(
+ Messages.CreaterepoWizard_errorOpeningNewlyCreatedFile, e);
+ }
+ }
+ });
+ monitor.worked(1);
+ } catch (CoreException e) {
+ Activator.logError(Messages.CreaterepoWizard_errorCreatingProject, e);
+ }
+ }
+
+ /**
+ * Helper method to initialize the contents of the .repo file.
+ *
+ * @param id The unique repository ID.
+ * @param name A human readable string that describes the repository.
+ * @param url A URL pointing to the repodata folder.
+ * @return
+ */
+ private String initializeRepoContents(String id, String name, String url) {
+ String contents = String.format("[%s]\n", id); //$NON-NLS-1$
+ contents = contents.concat(String.format("%s=%s\n", IRepoFileConstants.NAME, name)); //$NON-NLS-1$
+ contents = contents.concat(String.format("%s=%s\n", IRepoFileConstants.BASE_URL, url)); //$NON-NLS-1$
+ return contents;
+ }
+
+} \ No newline at end of file
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java
new file mode 100644
index 0000000..f0b1078
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.rpm.createrepo;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+/**
+ * This class will contain the current project and basic operations of the
+ * createrepo command.
+ */
+public class CreaterepoProject {
+
+ private IProject project;
+ private IFolder content;
+ private IFile repoFile;
+
+ private IProgressMonitor monitor;
+
+ /**
+ * Default constructor.
+ *
+ * @param project The project.
+ * @throws CoreException Thrown when unable to initialize project.
+ */
+ public CreaterepoProject(IProject project) throws CoreException {
+ this.project = project;
+ monitor = new NullProgressMonitor();
+ intitialize();
+ // if something is deleted from the project while outside of eclipse,
+ // the tree/preferences will be updated accordingly after refreshing
+ getProject().refreshLocal(IResource.DEPTH_ONE, monitor);
+ }
+
+ /**
+ * Initialize the createrepo project by creating the content folder if it doesn't
+ * yet exist.
+ *
+ * @throws CoreException Thrown when unable to create the folders.
+ */
+ private void intitialize() throws CoreException {
+ content = getProject().getFolder(ICreaterepoConstants.CONTENT_FOLDER);
+ if (!content.exists()) {
+ content.create(false, true, monitor);
+ }
+ // tries to check if a .repo file already exists in the project
+ for (IResource child : getProject().members()) {
+ String extension = child.getFileExtension();
+ if (extension != null && extension.equals(ICreaterepoConstants.REPO_FILE_EXTENSION)) {
+ // assumes that there will only be 1 .repo file in the folder
+ repoFile = (IFile) child;
+ }
+ // if no repo file then keep it null
+ }
+ }
+
+ /**
+ * Get the project.
+ *
+ * @return The project.
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
+ * Get the content folder.
+ *
+ * @return The content folder.
+ */
+ public IFolder getContentFolder() {
+ return content;
+ }
+
+ /**
+ * Get the .repo file.
+ *
+ * @return The .repo file.
+ */
+ public IFile getRepoFile() {
+ return repoFile;
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectCreator.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectCreator.java
new file mode 100644
index 0000000..1453242
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectCreator.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.rpm.createrepo;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Utility class to help create a createrepo project.
+ */
+public class CreaterepoProjectCreator {
+
+ /**
+ * Create a createrepo project given a project name and the progress
+ * monitor. The new project will contain an empty repodata folder.
+ *
+ * @param projectName The name of the project.
+ * @param locationPath The location path of the project
+ * @param monitor The progress monitor.
+ * @return The newly created project.
+ * @throws CoreException Thrown when creating a project fails.
+ */
+ public static IProject create(String projectName, IPath locationPath,
+ IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(projectName);
+ IProjectDescription description = ResourcesPlugin.getWorkspace()
+ .newProjectDescription(projectName);
+ if (!Platform.getLocation().equals(locationPath)) {
+ description.setLocation(locationPath);
+ }
+ project.create(description, monitor);
+ project.open(monitor);
+ new CreaterepoProject(project);
+ return project;
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/ICreaterepoConstants.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/ICreaterepoConstants.java
new file mode 100644
index 0000000..1aa3235
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/ICreaterepoConstants.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.rpm.createrepo;
+
+
+/**
+ * Common constants used in createrepo.
+ */
+public interface ICreaterepoConstants {
+
+ /**
+ * The folder which contains the repodata folder as well as the
+ * RPMs.
+ */
+ String CONTENT_FOLDER = "content"; //$NON-NLS-1$
+
+ /**
+ * The file extension of RPM files.
+ */
+ String REPO_FILE_EXTENSION = "repo"; //$NON-NLS-1$
+
+ /**
+ * An empty string.
+ */
+ String EMPTY_STRING = ""; //$NON-NLS-1$
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/IRepoFileConstants.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/IRepoFileConstants.java
new file mode 100644
index 0000000..53c77a7
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/IRepoFileConstants.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. and others.
+ * 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.rpm.createrepo;
+
+/**
+ * Valid options available in the repo file.
+ */
+public interface IRepoFileConstants {
+
+ /*
+ * Mandatory options
+ */
+
+ /**
+ * A unique identifier for the repository.
+ */
+ String ID = "id"; //$NON-NLS-1$
+
+ /**
+ * A human-readable string describing the repository.
+ */
+ String NAME = "name"; //$NON-NLS-1$
+
+ /**
+ * The location of the repodata folder. It can point locally (file://),
+ * remotely (http://), or via ftp (ftp://).
+ */
+ String BASE_URL = "baseurl"; //$NON-NLS-1$
+
+}