From bfd6650197bcaabdd6ae7453a10b2912997588c2 Mon Sep 17 00:00:00 2001 From: Neil Guzman Date: Fri, 6 Dec 2013 12:25:17 -0500 Subject: RPM: createrepo update command Same as execute but calls --update. Added button on form pages. Change-Id: Iee3ad1c3569cc3f473263c2d643916162d1940ec Signed-off-by: Neil Guzman Reviewed-on: https://git.eclipse.org/r/19451 Reviewed-by: Alexander Kurtakov IP-Clean: Alexander Kurtakov Tested-by: Alexander Kurtakov --- .../icons/refresh.gif | Bin 0 -> 327 bytes .../plugin.properties | 3 +- .../plugin.xml | 23 +++++- .../handler/CreaterepoCommandHandler.java | 78 +++++++++++++++++++++ .../handler/CreaterepoExecuteCommandHandler.java | 71 ------------------- .../createrepo/CreaterepoPreferenceConstants.java | 3 + .../rpm/createrepo/CreaterepoProject.java | 19 +++++ 7 files changed, 123 insertions(+), 74 deletions(-) create mode 100644 rpm/org.eclipse.linuxtools.rpm.createrepo/icons/refresh.gif create mode 100644 rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoCommandHandler.java delete mode 100644 rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoExecuteCommandHandler.java diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/refresh.gif b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/refresh.gif new file mode 100644 index 0000000000..3ca04d06ff Binary files /dev/null and b/rpm/org.eclipse.linuxtools.rpm.createrepo/icons/refresh.gif differ diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties index 3b2549f5b4..417a89cc75 100644 --- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties +++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties @@ -18,4 +18,5 @@ contentType.name = Repo File Content Type delta.preference.name = Deltas nature.name = Createrepo Nature -execute.command = Execute Command +execute.command = Execute +update.command = Update diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml index 617bc9da06..e516a4d3b2 100644 --- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml +++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml @@ -54,11 +54,25 @@ + + + + + tooltip="%main.name"> + + @@ -67,12 +81,17 @@ + + diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoCommandHandler.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoCommandHandler.java new file mode 100644 index 0000000000..b37173376d --- /dev/null +++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoCommandHandler.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.jobs.Job; +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.linuxtools.rpm.createrepo.CreaterepoUtils; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.MessageConsoleStream; +import org.eclipse.ui.ide.ResourceUtil; + +/** + * Handle the execution of the Update and Execute button. + */ +public class CreaterepoCommandHandler extends AbstractHandler { + + /* + * (non-Javadoc) + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + final String executionType = event.getParameter("executionType"); //$NON-NLS-1$ + try { + IWorkbench wb = PlatformUI.getWorkbench(); + IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage(); + IEditorInput editorInput = wbPage.getActiveEditor().getEditorInput(); + IResource resource = ResourceUtil.getResource(editorInput); + final CreaterepoProject project = new CreaterepoProject(resource.getProject()); + Job executeCreaterepo = new Job(Messages.Createrepo_jobName) { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + monitor.beginTask(Messages.CreaterepoProject_executeCreaterepo, IProgressMonitor.UNKNOWN); + MessageConsoleStream os = CreaterepoUtils.findConsole(Messages.CreaterepoProject_consoleName) + .newMessageStream(); + if (executionType.equals("refresh")) { //$NON-NLS-1$ + return project.update(os); + } else { + return project.createrepo(os); + } + } catch (CoreException e) { + Activator.logError(Messages.Createrepo_errorExecuting, e); + } finally { + monitor.done(); + } + return null; + } + }; + executeCreaterepo.setUser(true); + executeCreaterepo.schedule(); + } catch (CoreException e) { + Activator.logError(Messages.CreaterepoProject_executeCreaterepo, e); + } + return null; + } + +} diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoExecuteCommandHandler.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoExecuteCommandHandler.java deleted file mode 100644 index 36949cf6eb..0000000000 --- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/handler/CreaterepoExecuteCommandHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.handler; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.Job; -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.linuxtools.rpm.createrepo.CreaterepoUtils; -import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoConstants; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.console.MessageConsoleStream; -import org.eclipse.ui.ide.ResourceUtil; - -public class CreaterepoExecuteCommandHandler extends AbstractHandler { - - /* - * (non-Javadoc) - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - try { - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage(); - IEditorInput editorInput = wbPage.getActiveEditor().getEditorInput(); - IResource resource = ResourceUtil.getResource(editorInput); - final CreaterepoProject project = new CreaterepoProject(resource.getProject()); - Job executeCreaterepo = new Job(Messages.Createrepo_jobName) { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - monitor.beginTask(Messages.CreaterepoProject_executeCreaterepo, IProgressMonitor.UNKNOWN); - MessageConsoleStream os = CreaterepoUtils.findConsole(Messages.CreaterepoProject_consoleName) - .newMessageStream(); - return project.createrepo(os); - } catch (CoreException e) { - Activator.logError(Messages.Createrepo_errorExecuting, e); - } finally { - monitor.done(); - } - return null; - } - }; - executeCreaterepo.setUser(true); - executeCreaterepo.schedule(); - } catch (CoreException e) { - Activator.logError(Messages.CreaterepoProject_executeCreaterepo, e); - } - return null; - } - -} diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java index 0fb1398521..59f5f0edaa 100644 --- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java +++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java @@ -47,6 +47,9 @@ public final class CreaterepoPreferenceConstants { /****/ public static final String PREF_VERBOSE = "verbose"; //$NON-NLS-1$ /****/ public static final String PREF_PROFILE = "profile"; //$NON-NLS-1$ + // Misc + /****/ public static final String PREF_UPDATE = "update"; //$NON-NLS-1$ + /* * Preference Values. */ 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 ea8aca42a4..bfff0d5e2f 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 @@ -151,6 +151,25 @@ public class CreaterepoProject { return result; } + /** + * Execute the createrepo command with a call to update. + * + * @param os Direct execution stream to this. + * @return The status of the execution. + * @throws CoreException Thrown when failure to execute command. + */ + public IStatus update(OutputStream os) throws CoreException { + if (!getContentFolder().exists()) { + createContentFolder(); + } + Createrepo createrepo = new Createrepo(); + List commands = getCommandArguments(); + commands.add(ICreaterepoConstants.DASH.concat(CreaterepoPreferenceConstants.PREF_UPDATE)); + IStatus result = createrepo.execute(os, this, commands); + getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); + return result; + } + /** * Get the project. * -- cgit v1.2.3