aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-11-14 14:25:12 (EST)
committerAlexander Kurtakov2013-11-20 11:12:51 (EST)
commit1ac3b4d6f2269ee022e3ed0e3d6ee512d8c4695a (patch)
tree7dfda04c98960c86c4b4681619268b8d71a8468b
parent14f3c54426122f417c33856f97c2291ed82f4011 (diff)
downloadorg.eclipse.linuxtools-1ac3b4d6f2269ee022e3ed0e3d6ee512d8c4695a.zip
org.eclipse.linuxtools-1ac3b4d6f2269ee022e3ed0e3d6ee512d8c4695a.tar.gz
org.eclipse.linuxtools-1ac3b4d6f2269ee022e3ed0e3d6ee512d8c4695a.tar.bz2
RPM: createrepo form editorrefs/changes/03/18403/7
Add form editor with 3 pages: page to manage RPMs to create a repository for, page to manage the repo metadata or customize the command (could--and probably should--be put into a preference page), and lastly a page to edit the .repo file. This patch lacks most functionality and just contains what the pages might look like. The most the repository page could do is to fill the tree with RPMs found in the content folder. Change-Id: I083ad8de7ba7af5e61d6d51bc857c7d650a29876 Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/18403 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/icons/repository_rep.gifbin0 -> 545 bytes
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/icons/run_exc.gifbin0 -> 379 bytes
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties5
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml43
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java12
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java34
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/ImportRPMsPage.java297
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/MainOverviewPage.java68
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/RepoFormEditor.java132
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties31
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/wizard/CreaterepoNewWizardPageTwo.java5
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java22
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/ICreaterepoConstants.java5
14 files changed, 637 insertions, 22 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 4a41977..f38a9a4 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/META-INF/MANIFEST.MF
@@ -9,6 +9,9 @@ Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.8.101",
- org.eclipse.ui.ide;bundle-version="3.9.1"
+ org.eclipse.ui.ide;bundle-version="3.9.1",
+ org.eclipse.ui.editors;bundle-version="3.8.100",
+ org.eclipse.ui.forms;bundle-version="3.6.1",
+ org.eclipse.ui.console;bundle-version="3.5.200"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/repository_rep.gif b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/repository_rep.gif
new file mode 100644
index 0000000..0470e15
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/repository_rep.gif
Binary files differ
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/run_exc.gif b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/run_exc.gif
new file mode 100644
index 0000000..57f4102
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/run_exc.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 0748954..e1fc8c1 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
@@ -11,6 +11,9 @@
Bundle-Name = RPM Createrepo Plug-in
Bundle-Vendor = Eclipse Linux Tools
-editor.name = Repo Metadata Editor
+editor.name = Repo Editor
category.name = Createrepo
wizard.name = Createrepo Wizard
+contentType.name = Repo File Content Type
+
+execute.command = Execute Command
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
index 6c4e1a1..40c2110 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
@@ -26,4 +26,47 @@
project="true">
</wizard>
</extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.linuxtools.internal.rpm.createrepo.form.RepoFormEditor"
+ default="true"
+ icon="icons/repository_rep.gif"
+ id="org.eclipse.linuxtools.rpm.createrepo.repoEditor"
+ name="%editor.name">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.linuxtools.rpm.createrepo.repoContent">
+ </contentTypeBinding>
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.text"
+ file-extensions="repo"
+ id="org.eclipse.linuxtools.rpm.createrepo.repoContent"
+ name="%contentType.name"
+ priority="high">
+ </content-type>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:formsToolbar">
+ <command
+ commandId="org.eclipse.linuxtools.rpm.createrepo.executeCommand"
+ icon="icons/run_exc.gif"
+ style="push"
+ tooltip="%execute.command">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.linuxtools.rpm.createrepo.executeCommand"
+ name="%execute.command">
+ </command>
+ </extension>
</plugin>
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 53e4368..06147c0 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
@@ -12,6 +12,7 @@ package org.eclipse.linuxtools.internal.rpm.createrepo;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -60,6 +61,17 @@ public class Activator extends AbstractUIPlugin {
}
/**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
* Log an error.
*
* @param message A human-readable message.
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
index 101d87f..7ea69f7 100644
--- 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
@@ -26,8 +26,6 @@ public final class Messages {
public static String CreaterepoWizard_openFileOnCreation;
/****/
public static String CreaterepoWizard_errorOpeningNewlyCreatedFile;
- /****/
- public static String CreaterepoWizard_errorCreatingFolder;
// CreaterepoNewWizardPageOne
/****/
@@ -57,21 +55,37 @@ public final class Messages {
/****/
public static String CreaterepoNewWizardPageTwo_errorURL;
- // CreaterepoProjectCreator
+ // RepoFormEditor
+ /****/
+ public static String RepoFormEditor_errorInitializingForm;
/****/
- public static String CreaterepoProjectCreator_errorSettingProjectLocation;
+ public static String RepoFormEditor_errorInitializingProject;
- // CreaterepoProject
+ // ImportRPMsPage
+ /****/
+ public static String ImportRPMsPage_title;
+ /****/
+ public static String ImportRPMsPage_formHeaderText;
+ /****/
+ public static String ImportRPMsPage_sectionTitle;
/****/
- public static String CreaterepoProject_executeCreaterepo;
+ public static String ImportRPMsPage_sectionInstruction;
/****/
- public static String CreaterepoProject_consoleName;
+ public static String ImportRPMsPage_buttonImportRPMs;
/****/
- public static String CreaterepoProject_errorExecuting;
+ public static String ImportRPMsPage_buttonRemoveRPMs;
+ /****/
+ public static String ImportRPMsPage_buttonDeleteRPMs;
+ /****/
+ public static String ImportRPMsPage_buttonCreateRepo;
+ /****/
+ public static String ImportRPMsPage_errorRefreshingTree;
+
+ // MainOverviewPage
/****/
- public static String CreaterepoProject_errorSettingPreferences;
+ public static String MainOverviewPage_title;
/****/
- public static String CreaterepoProject_errorGettingFile;
+ public static String MainOverviewPage_formHeaderText;
static {
// initialize resource bundle
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/ImportRPMsPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/ImportRPMsPage.java
new file mode 100644
index 0000000..201eb4f
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/ImportRPMsPage.java
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * 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.form;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProject;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * This page will allow the user to import RPMs from either the
+ * file system or the workspace. The RPMs imported will be the
+ * RPMs used when executing the createrepo command.
+ */
+public class ImportRPMsPage extends FormPage {
+
+ private CreaterepoProject project;
+
+ private FormToolkit toolkit;
+ private ScrolledForm form;
+
+ private Composite buttonList;
+ private Tree tree;
+
+ private static final String MENU_URI = "toolbar:formsToolbar"; //$NON-NLS-1$
+ private static final String HEADER_ICON = "/icons/repository_rep.gif"; //$NON-NLS-1$
+
+ /**
+ * Default constructor.
+ *
+ * @param editor The editor.
+ * @param project The project.
+ */
+ public ImportRPMsPage(FormEditor editor, CreaterepoProject project) {
+ super(editor, Messages.ImportRPMsPage_title, Messages.ImportRPMsPage_title);
+ this.project = project;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ // setting up the form page
+ super.createFormContent(managedForm);
+ GridLayout layout = new GridLayout();
+ GridData data = new GridData();
+ toolkit = managedForm.getToolkit();
+ form = managedForm.getForm();
+ form.setText(Messages.ImportRPMsPage_formHeaderText);
+ form.setImage(Activator.getImageDescriptor(HEADER_ICON).createImage());
+ ToolBarManager toolbarManager = (ToolBarManager) form.getToolBarManager();
+ toolkit.decorateFormHeading(form.getForm());
+
+ // add the menuContribution from MANIFEST.MF to the form
+ IMenuService menuService = (IMenuService) getSite().getService(IMenuService.class);
+ menuService.populateContributionManager(toolbarManager, MENU_URI);
+ toolbarManager.update(true);
+
+ layout = new GridLayout(2, true);
+ layout.marginWidth = 6; layout.marginHeight = 12;
+ form.getBody().setLayout(layout);
+
+ // Section and its client area to manage importing the RPMs
+ Section rpmSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION
+ | Section.TITLE_BAR);
+ layout = new GridLayout();
+ rpmSection.setText(Messages.ImportRPMsPage_sectionTitle);
+ rpmSection.setDescription(Messages.ImportRPMsPage_sectionInstruction);
+ rpmSection.setLayoutData(expandComposite());
+
+ // the client area containing the tree + buttons
+ Composite sectionClient = toolkit.createComposite(rpmSection);
+ layout = new GridLayout(2, false);
+ layout.marginWidth = 1; layout.marginHeight = 7;
+ sectionClient.setLayout(layout);
+ tree = toolkit.createTree(sectionClient, SWT.BORDER | SWT.MULTI | SWT.HORIZONTAL
+ | SWT.VERTICAL | SWT.LEFT_TO_RIGHT | SWT.SMOOTH);
+ tree.setLayoutData(expandComposite());
+
+ buttonList = toolkit.createComposite(sectionClient);
+ layout = new GridLayout();
+ data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
+ layout.marginWidth = 0; layout.marginHeight = 0;
+ buttonList.setLayout(layout);
+ buttonList.setLayoutData(data);
+
+ createPushButton(buttonList, Messages.ImportRPMsPage_buttonImportRPMs,
+ toolkit).addSelectionListener(new ImportButtonListener());
+ createPushButton(buttonList, Messages.ImportRPMsPage_buttonRemoveRPMs,
+ toolkit).addSelectionListener(new RemoveButtonListener());
+ createSpace(buttonList);
+
+ createPushButton(buttonList, Messages.ImportRPMsPage_buttonDeleteRPMs,
+ toolkit).addSelectionListener(new DeleteButtonListener());
+ createSpace(buttonList);
+
+ createPushButton(buttonList, Messages.ImportRPMsPage_buttonCreateRepo,
+ toolkit).addSelectionListener(new CreaterepoButtonListener());
+
+ refreshTree();
+ rpmSection.setClient(sectionClient);
+ managedForm.refresh();
+ }
+
+ /**
+ * Make a GridData that expands to fill both horizontally
+ * and vertically.
+ *
+ * @return The created GridData.
+ */
+ private GridData expandComposite() {
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.grabExcessHorizontalSpace = true;
+ return data;
+ }
+
+ /**
+ * Create a push style button.
+ *
+ * @param parent The parent the button will belong to.
+ * @param buttonText The text show on the button.
+ * @param toolkit The form toolkit used in creating a button.
+ * @return The button created.
+ */
+ private Button createPushButton(Composite parent, String buttonText, FormToolkit toolkit) {
+ Button button = toolkit.createButton(parent, buttonText, SWT.PUSH | SWT.FLAT
+ | SWT.CENTER | SWT.LEFT_TO_RIGHT);
+ button.setFont(parent.getFont());
+ GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ button.setLayoutData(gd);
+ return button;
+ }
+
+ /**
+ * Create space between composites, such as buttons within a button list.
+ *
+ * @param parent The composite to attach a space to.
+ */
+ private void createSpace(Composite parent) {
+ new Label(buttonList, SWT.NONE).setLayoutData(new GridData(0,0));
+ }
+
+ /**
+ * On creating the form content the tree will be populated with
+ * RPMs found in the root of the current project.
+ *
+ * @throws CoreException Thrown when getting rpms from project fails.
+ */
+ private void refreshTree() {
+ tree.removeAll();
+ try {
+ for (IResource rpm : project.getRPMs()) {
+ addItemToTree(rpm.getName());
+ }
+ } catch (CoreException e) {
+ Activator.logError(Messages.ImportRPMsPage_errorRefreshingTree, e);
+ }
+ tree.setFocus();
+ }
+
+ /**
+ * Add a new item to the tree if it does not yet exist. A null or empty
+ * string will be ignored.
+ *
+ * @param itemName The name of the new item.
+ * @return True if it does not exist and has been added, false otherwise.
+ */
+ private boolean addItemToTree(String itemName) {
+ boolean exists = false;
+ if (itemName == null || itemName.isEmpty())
+ return false;
+ // check to see if the tree item exists in the tree
+ if (tree.getItemCount() > 0) {
+ for (TreeItem item : tree.getItems()) {
+ if (item.getText().equals(itemName)) {
+ exists = true;
+ }
+ }
+ }
+ // if the tree item doesnt exists or the tree is empty
+ if (!exists || tree.getItemCount() == 0) {
+ TreeItem treeItem = new TreeItem(tree, SWT.NONE);
+ treeItem.setText(itemName);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Handle the import button execution on the Import RPMs page.
+ */
+ public class ImportButtonListener extends SelectionAdapter {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) { }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ }
+
+ /**
+ * Handle the remove button execution on the Import RPMs page.
+ */
+ public class RemoveButtonListener extends SelectionAdapter {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) { }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ }
+
+ /**
+ * Handle the delete button execution on the Import RPMs page.
+ */
+ public class DeleteButtonListener extends SelectionAdapter {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) { }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ }
+
+ /**
+ * Handle the createrepo button execution on the Import RPMs page.
+ */
+ public class CreaterepoButtonListener extends SelectionAdapter {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) { }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/MainOverviewPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/MainOverviewPage.java
new file mode 100644
index 0000000..142234c
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/MainOverviewPage.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.form;
+
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * This page will allow the user to view/edit some of the repo
+ * xml metadata (i.e., repo, revision, etc.).
+ *
+ * For now this page would allow customization of the createrepo
+ * command, but it would be better to have it done through
+ * preferences.
+ */
+public class MainOverviewPage extends FormPage {
+
+ private FormToolkit toolkit;
+ private ScrolledForm form;
+
+ private static final String MENU_URI = "toolbar:formsToolbar"; //$NON-NLS-1$
+ private static final String HEADER_ICON = "/icons/repository_rep.gif"; //$NON-NLS-1$
+
+ /** Default constructor. */
+ public MainOverviewPage(FormEditor editor) {
+ super(editor, Messages.MainOverviewPage_title, Messages.MainOverviewPage_title);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ // setting up the form page
+ super.createFormContent(managedForm);
+ toolkit = managedForm.getToolkit();
+ form = managedForm.getForm();
+ form.setText(Messages.MainOverviewPage_formHeaderText);
+ toolkit = managedForm.getToolkit();
+ form = managedForm.getForm();
+ form.setText(Messages.MainOverviewPage_formHeaderText);
+ form.setImage(Activator.getImageDescriptor(HEADER_ICON).createImage());
+ ToolBarManager toolbarManager = (ToolBarManager) form.getToolBarManager();
+ toolkit.decorateFormHeading(form.getForm());
+
+ // add the menuContribution from MANIFEST.MF to the form
+ IMenuService menuService = (IMenuService) getSite().getService(IMenuService.class);
+ menuService.populateContributionManager(toolbarManager, MENU_URI);
+ toolbarManager.update(true);
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/RepoFormEditor.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/RepoFormEditor.java
new file mode 100644
index 0000000..34b7648
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/form/RepoFormEditor.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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.form;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProject;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.ide.ResourceUtil;
+
+/**
+ * The repo file form editor will allow the user to edit the .repo
+ * file, import/remove RPMs, and customize the execution and/or
+ * the repo metadata that is generated.
+ */
+public class RepoFormEditor extends FormEditor {
+
+ private CreaterepoProject project;
+ private TextEditor editor;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+ IFile file = ResourceUtil.getFile(input);
+ setPartName(file.getName());
+ try {
+ project = new CreaterepoProject(file.getProject());
+ } catch (CoreException e) {
+ Activator.logError(Messages.RepoFormEditor_errorInitializingProject, e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ editor.doSave(monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ editor.doSaveAs();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ @Override
+ protected void addPages() {
+ createPage0();
+ createPage1();
+ createPage2();
+ }
+
+ /**
+ * Page 0 allows the user to import RPMs from the workspace or
+ * the file system.
+ */
+ void createPage0() {
+ try {
+ FormPage composite = new ImportRPMsPage(this, project);
+ addPage(composite);
+ } catch (PartInitException e) {
+ Activator.logError(Messages.RepoFormEditor_errorInitializingForm, e);
+ }
+ }
+
+ /**
+ * Page 1 allows the user to modify some of the data in the
+ * repomd.xml as well as some options when customizing the
+ * execution of the createrepo command. The default execution
+ * would satisfy most users.
+ */
+ void createPage1() {
+ try {
+ FormPage composite = new MainOverviewPage(this);
+ addPage(composite);
+ } catch (PartInitException e) {
+ Activator.logError(Messages.RepoFormEditor_errorInitializingForm, e);
+ }
+ }
+
+ /**
+ * Page 2 allows the user to view the current .repo file.
+ */
+ void createPage2() {
+ try {
+ editor = new TextEditor();
+ int index = addPage(editor, getEditorInput());
+ setPageText(index, editor.getTitle());
+ } catch (PartInitException e) {
+ Activator.logError(Messages.RepoFormEditor_errorInitializingForm, e);
+ }
+ }
+
+}
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
index d74d76f..7dcdcd3 100644
--- 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
@@ -13,7 +13,6 @@ 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
@@ -34,13 +33,25 @@ CreaterepoNewWizardPageTwo_errorName=The name of the repository is invalid. Make
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.
+# RepoFormEditor
+RepoFormEditor_errorInitializingForm=Error while trying to initialize the form page.
+RepoFormEditor_errorInitializingProject=Error initializing 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.
+# ImportRPMsPage
+ImportRPMsPage_title=Repository
+ImportRPMsPage_formHeaderText=Create Repository
+ImportRPMsPage_sectionTitle=Import RPMs to create a repository for
+ImportRPMsPage_sectionInstruction= \
+ 1. Add the RPMs to create a YUM repository the file system. \n\
+\ (via dragging from workspace or importing from the file system) \n\
+ 2. Create the repository.
+ImportRPMsPage_buttonImportRPMs=Import RPMs
+ImportRPMsPage_buttonRemoveRPMs=Remove RPMs
+ImportRPMsPage_buttonDeleteRPMs=Delete RPMs
+ImportRPMsPage_buttonCreateRepo=Create Repo
+ImportRPMsPage_errorRefreshingTree=Error while refreshing the RPM tree. Problem due to trying to get the \
+ RPMs in the content folder.
+
+# MainOverviewPage
+MainOverviewPage_title=Metadata
+MainOverviewPage_formHeaderText=Execution and Metadata
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
index 6d4cec8..a26c191 100644
--- 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
@@ -27,6 +27,11 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+/**
+ * This page allows the user to initialize the .repo file
+ * for the repository with the mandatory options: id, name, and
+ * base url.
+ */
public class CreaterepoNewWizardPageTwo extends WizardPage {
private Text repositoryIDTxt;
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
index f0b1078..fed16ed 100644
--- 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
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.linuxtools.rpm.createrepo;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -94,4 +97,23 @@ public class CreaterepoProject {
return repoFile;
}
+ /**
+ * Get the RPMs in the project.
+ *
+ * @return A list of RPMs located within the project.
+ * @throws CoreException Thrown when unable to look into the project.
+ */
+ public List<IResource> getRPMs() throws CoreException {
+ List<IResource> rpms = new ArrayList<IResource>();
+ if (getProject().members().length > 0) {
+ for (IResource child : getContentFolder().members()) {
+ String extension = child.getFileExtension();
+ if (extension != null && extension.equals(ICreaterepoConstants.RPM_FILE_EXTENSION)) {
+ rpms.add(child);
+ }
+ }
+ }
+ return rpms;
+ }
+
}
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
index 1aa3235..48d47da 100644
--- 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
@@ -28,6 +28,11 @@ public interface ICreaterepoConstants {
String REPO_FILE_EXTENSION = "repo"; //$NON-NLS-1$
/**
+ * The file extension of RPM files.
+ */
+ String RPM_FILE_EXTENSION = "rpm"; //$NON-NLS-1$
+
+ /**
* An empty string.
*/
String EMPTY_STRING = ""; //$NON-NLS-1$