aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-12-02 14:51:20 (EST)
committerAlexander Kurtakov2013-12-05 10:49:01 (EST)
commitb81f379815b1b2a940716b54d8f2b261ffc4bd1e (patch)
treed3554afc391b7b1afb9f87f95cad4703a07ceeb6
parentfac15073fe4fac885ee6ce68c34c02a408b72dc9 (diff)
downloadorg.eclipse.linuxtools-b81f379815b1b2a940716b54d8f2b261ffc4bd1e.zip
org.eclipse.linuxtools-b81f379815b1b2a940716b54d8f2b261ffc4bd1e.tar.gz
org.eclipse.linuxtools-b81f379815b1b2a940716b54d8f2b261ffc4bd1e.tar.bz2
RPM: createrepo project property pagesrefs/changes/23/19323/4
Added project property pages. Shifted "Deltas" options from the plugin preferences to the project specific preferences. Also added a createrepo project nature so that eclipse knows when to display the project property pages (for createrepo natures & .repo files). Changed when the "content" folder is to be created only when importing RPMs or executing the createrepo command, so that when a .repo file is created in a different project, a content folder won't appear. Added an abstract class for createrepo property pages. Change-Id: I9c728ea6dcd0b0020be7d3ff676d448a3746b85c Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/19323 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/plugin.properties1
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml66
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Activator.java11
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java20
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties17
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPreferencePage.java130
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java148
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoGeneralPropertyPage.java414
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java10
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferencePage.java1
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPropertyPage.java116
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java10
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java10
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectCreator.java1
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectNature.java57
15 files changed, 854 insertions, 158 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
index 6fc7f49..3b2549f 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.properties
@@ -16,5 +16,6 @@ main.name = Createrepo
wizard.name = Createrepo Wizard
contentType.name = Repo File Content Type
delta.preference.name = Deltas
+nature.name = Createrepo Nature
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 13bdce5..617bc9d 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/plugin.xml
@@ -83,12 +83,6 @@
id="org.eclipse.linuxtools.rpm.createrepo.preferences"
name="%main.name">
</page>
- <page
- category="org.eclipse.linuxtools.rpm.createrepo.preferences"
- class="org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoDeltaPreferencePage"
- id="org.eclipse.linuxtools.rpm.createrepo.preferences.delta"
- name="%delta.preference.name">
- </page>
</extension>
<extension
point="org.eclipse.equinox.preferences.preferences">
@@ -96,4 +90,64 @@
class="org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoPreferenceInitializer">
</initializer>
</extension>
+ <extension
+ id="createreponature"
+ name="%nature.name"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.linuxtools.rpm.createrepo.CreaterepoProjectNature">
+ </run>
+ </runtime>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoGeneralPropertyPage"
+ id="org.eclipse.linuxtools.rpm.createrepo.CreaterepoGeneralPropertyPage"
+ name="%main.name">
+ <enabledWhen>
+ <or>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.linuxtools.rpm.createrepo.createreponature">
+ </test>
+ </adapt>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.name"
+ value="*.repo">
+ </test>
+ </adapt>
+ </or>
+ </enabledWhen>
+ </page>
+ <page
+ category="org.eclipse.linuxtools.rpm.createrepo.CreaterepoGeneralPropertyPage"
+ class="org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoDeltaPropertyPage"
+ id="org.eclipse.linuxtools.rpm.createrepo.CreaterepoDeltaPropertyPage"
+ name="%delta.preference.name">
+ <enabledWhen>
+ <or>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.linuxtools.rpm.createrepo.createreponature">
+ </test>
+ </adapt>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.name"
+ value="*.repo">
+ </test>
+ </adapt>
+ </or>
+ </enabledWhen>
+ </page>
+ </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 6f59663..c11d732 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
@@ -13,6 +13,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.linuxtools.rpm.createrepo.CreaterepoPreferenceConstants;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -74,6 +75,16 @@ public class Activator extends AbstractUIPlugin {
}
/**
+ * Get the enabled status of using the project specific settings of
+ * createrepo.
+ *
+ * @return True if it is being used, false otherwise.
+ */
+ public static boolean isConfEnabled() {
+ return getDefault().getPreferenceStore().getBoolean(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED);
+ }
+
+ /**
* 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 5f06d66..54097b3 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
@@ -163,17 +163,25 @@ public final class Messages {
/****/
public static String CreaterepoPreferencePage_compressionGroupLabel;
- // CreaterepoDeltaPreferencePage
+ // CreaterepoGeneralPropertyPage
/****/
- public static String CreaterepoDeltaPreferencePage_description;
+ public static String CreaterepoGeneralPropertyPage_projectSettings;
/****/
- public static String CreaterepoDeltaPreferencePage_groupLabel;
+ public static String CreaterepoGeneralPropertyPage_workspaceSettings;
+
+ // CreaterepoDeltaPropertyPage
+ /****/
+ public static String CreaterepoDeltaPropertyPage_description;
+ /****/
+ public static String CreaterepoDeltaPropertyPage_groupLabel;
+ /****/
+ public static String CreaterepoDeltaPropertyPage_booleanEnableLabel;
/****/
- public static String CreaterepoDeltaPreferencePage_booleanEnableLabel;
+ public static String CreaterepoDeltaPropertyPage_maxNumberOfDeltas;
/****/
- public static String CreaterepoDeltaPreferencePage_maxNumberOfDeltas;
+ public static String CreaterepoDeltaPropertyPage_maxDeltaSize;
/****/
- public static String CreaterepoDeltaPreferencePage_maxDeltaSize;
+ public static String CreaterepoDeltaPropertyPage_errorInvalidText;
static {
// initialize resource bundle
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 98b8da0..b6b63d0 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
@@ -101,9 +101,14 @@ CreaterepoPreferencePage_numChangelogLimit=Limit of changelog entries (0 is auto
CreaterepoPreferencePage_checksumGroupLabel=Checksum
CreaterepoPreferencePage_compressionGroupLabel=Compresion
-# CreaterepoDeltaPreferencePage
-CreaterepoDeltaPreferencePage_description=Configure delta execution properties of createrepo.
-CreaterepoDeltaPreferencePage_groupLabel=Delta options
-CreaterepoDeltaPreferencePage_booleanEnableLabel=Generate deltarpms and the delta metadata
-CreaterepoDeltaPreferencePage_maxNumberOfDeltas=The number of older versions to make deltas against:
-CreaterepoDeltaPreferencePage_maxDeltaSize=Max size of an rpm to run deltarpm against (MByte):
+# CreaterepoGeneralPropertyPage
+CreaterepoGeneralPropertyPage_projectSettings=Enable pr&oject specific settings
+CreaterepoGeneralPropertyPage_workspaceSettings=Configure Workspace Settings...
+
+# CreaterepoDeltaPropertyPage
+CreaterepoDeltaPropertyPage_description=Configure delta execution properties of createrepo.
+CreaterepoDeltaPropertyPage_groupLabel=Delta options
+CreaterepoDeltaPropertyPage_booleanEnableLabel=Generate deltarpms and the delta metadata
+CreaterepoDeltaPropertyPage_maxNumberOfDeltas=The number of older versions to make deltas against:
+CreaterepoDeltaPropertyPage_maxDeltaSize=Max size of an rpm to run deltarpm against (MByte):
+CreaterepoDeltaPropertyPage_errorInvalidText=Field must be an integer that is greater than 0 and lesser than {0}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPreferencePage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPreferencePage.java
deleted file mode 100644
index 7e01d09..0000000
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPreferencePage.java
+++ /dev/null
@@ -1,130 +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.preference;
-
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.FieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
-import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
-import org.eclipse.linuxtools.rpm.createrepo.CreaterepoPreferenceConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
-
-/**
- * Keep track of delta specific options and pass it onto the createrepo command
- * when executing.
- */
-public class CreaterepoDeltaPreferencePage extends FieldEditorPreferencePage
- implements IWorkbenchPreferencePage {
-
- private Composite parent;
- private BooleanFieldEditor bfeEnableDeltas;
- private IntegerFieldEditor ifeMaxNumDeltas;
- private IntegerFieldEditor ifeMaxSizeDeltas;
- private Group optionsGroup;
- private Composite enableContainer;
-
- public CreaterepoDeltaPreferencePage() {
- super(GRID);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- @Override
- public void init(IWorkbench workbench) {
- setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID));
- setDescription(Messages.CreaterepoDeltaPreferencePage_description);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#checkState()
- */
- @Override
- public void checkState() {
- super.checkState();
- // catches the setValidRange rule
- if (!isValid()) {
- bfeEnableDeltas.setEnabled(false, enableContainer);
- } else {
- bfeEnableDeltas.setEnabled(true, enableContainer);
- ifeMaxNumDeltas.setEnabled(bfeEnableDeltas.getBooleanValue(), optionsGroup);
- ifeMaxSizeDeltas.setEnabled(bfeEnableDeltas.getBooleanValue(), optionsGroup);
- setErrorMessage(null);
- setValid(true);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(FieldEditor.VALUE)) {
- checkState();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
- @Override
- protected void createFieldEditors() {
- parent = getFieldEditorParent();
- GridLayout layout = new GridLayout();
-
- enableContainer = new Composite(parent, SWT.SHADOW_NONE);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,1).indent(0, 20).applyTo(enableContainer);
- bfeEnableDeltas = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE,
- Messages.CreaterepoDeltaPreferencePage_booleanEnableLabel, enableContainer);
- bfeEnableDeltas.load();
- bfeEnableDeltas.setPropertyChangeListener(this);
- addField(bfeEnableDeltas);
-
- optionsGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
- optionsGroup.setText(Messages.CreaterepoDeltaPreferencePage_groupLabel);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(optionsGroup);
-
- // max deltas.
- ifeMaxNumDeltas = new IntegerFieldEditor(CreaterepoPreferenceConstants.PREF_NUM_DELTAS,
- Messages.CreaterepoDeltaPreferencePage_maxNumberOfDeltas, optionsGroup);
- ifeMaxNumDeltas.setValidRange(0, Integer.MAX_VALUE);
- ifeMaxNumDeltas.load();
- addField(ifeMaxNumDeltas);
-
- // max delta size. stored in megabytes for convenience to user
- ifeMaxSizeDeltas = new IntegerFieldEditor(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE,
- Messages.CreaterepoDeltaPreferencePage_maxDeltaSize, optionsGroup);
- ifeMaxSizeDeltas.setValidRange(0, Integer.MAX_VALUE);
- ifeMaxSizeDeltas.load();
- addField(ifeMaxSizeDeltas);
-
- // spaces around the group
- layout = (GridLayout) optionsGroup.getLayout();
- layout.marginWidth = 5;
- layout.marginHeight = 5;
- }
-
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java
new file mode 100644
index 0000000..a19a18a
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.preference;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoPreferenceConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * Project property page for configuring the delta options for a repository.
+ */
+public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
+
+ private Composite composite;
+ private BooleanFieldEditor bfeEnableDeltas;
+ private Group optionsGroup;
+ private IntegerFieldEditor ifeNumDeltas;
+ private IntegerFieldEditor ifeMaxSizeDeltas;
+
+ /**
+ * Default Constructor. Sets the description of the property page.
+ */
+ public CreaterepoDeltaPropertyPage() {
+ super(Messages.CreaterepoDeltaPropertyPage_description);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoPropertyPage#addContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Composite addContents(Composite parent) {
+ composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+
+ bfeEnableDeltas = new BooleanFieldEditor(
+ CreaterepoPreferenceConstants.PREF_DELTA_ENABLE,
+ Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel, composite);
+ bfeEnableDeltas.setPreferenceStore(preferenceStore);
+ bfeEnableDeltas.load();
+ bfeEnableDeltas.setPropertyChangeListener(this);
+
+ optionsGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+
+ layout = new GridLayout(2, false);
+ optionsGroup.setLayout(layout);
+ optionsGroup.setText(Messages.CreaterepoDeltaPropertyPage_groupLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(optionsGroup);
+
+ // max deltas.
+ ifeNumDeltas = new IntegerFieldEditor(
+ CreaterepoPreferenceConstants.PREF_NUM_DELTAS,
+ Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas, optionsGroup);
+ ifeNumDeltas.setPreferenceStore(preferenceStore);
+ ifeNumDeltas.setValidRange(0, Integer.MAX_VALUE);
+ ifeNumDeltas.load();
+ ifeNumDeltas.setPropertyChangeListener(this);
+ ifeNumDeltas.setTextLimit(String.valueOf(Integer.MAX_VALUE).length());
+
+ // max delta size. stored in megabytes for convenience to user
+ ifeMaxSizeDeltas = new IntegerFieldEditor(
+ CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE,
+ Messages.CreaterepoDeltaPropertyPage_maxDeltaSize, optionsGroup);
+ ifeMaxSizeDeltas.setPreferenceStore(preferenceStore);
+ ifeMaxSizeDeltas.setValidRange(0, Integer.MAX_VALUE);
+ ifeMaxSizeDeltas.load();
+ ifeMaxSizeDeltas.setPropertyChangeListener(this);
+ ifeMaxSizeDeltas.setTextLimit(String.valueOf(Integer.MAX_VALUE).length());
+
+ // spaces around the group
+ layout = (GridLayout) optionsGroup.getLayout();
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ toggleEnabled();
+ return composite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ public void performDefaults() {
+ bfeEnableDeltas.loadDefault();
+ ifeNumDeltas.loadDefault();
+ ifeMaxSizeDeltas.loadDefault();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE,
+ bfeEnableDeltas.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_NUM_DELTAS,
+ ifeNumDeltas.getIntValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE,
+ ifeMaxSizeDeltas.getIntValue());
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoPropertyPage#checkState()
+ */
+ @Override
+ protected void checkState() {
+ if (!ifeNumDeltas.isValid() || !ifeMaxSizeDeltas.isValid()) {
+ bfeEnableDeltas.setEnabled(false, composite);
+ setErrorMessage(ifeMaxSizeDeltas.getErrorMessage());
+ setValid(false);
+ } else {
+ bfeEnableDeltas.setEnabled(true, composite);
+ setErrorMessage(null);
+ setValid(true);
+ }
+ toggleEnabled();
+ }
+
+ /**
+ * Toggle the enabled status of the field editors dependending on the
+ * enabled status of the button.
+ */
+ private void toggleEnabled() {
+ boolean enabled = bfeEnableDeltas.getBooleanValue();
+ ifeNumDeltas.setEnabled(enabled, optionsGroup);
+ ifeMaxSizeDeltas.setEnabled(enabled, optionsGroup);
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoGeneralPropertyPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoGeneralPropertyPage.java
new file mode 100644
index 0000000..34e3a58
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoGeneralPropertyPage.java
@@ -0,0 +1,414 @@
+/*******************************************************************************
+ * 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.preference;
+
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoPreferenceConstants;
+import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoChecksums;
+import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoCompressionTypes;
+import org.eclipse.osgi.util.NLS;
+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.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * Project property page for configuring the delta options for a repository.
+ */
+public class CreaterepoGeneralPropertyPage extends CreaterepoPropertyPage {
+
+ private static final String linkTags = "<a>{0}</a>"; //$NON-NLS-1$
+
+ private Composite composite;
+
+ private Button btnProjectSettings;
+ private Link lnWorkspaceSettings;
+
+ private Group generalGroup;
+ private BooleanFieldEditor bfeIncludeChecksum;
+ private BooleanFieldEditor bfeSQLDB;
+ private BooleanFieldEditor bfeIgnoreSymlinks;
+ private BooleanFieldEditor bfePrettyXML;
+ private IntegerFieldEditor ifeSpawns;
+
+ private Group updatesGroup;
+ private BooleanFieldEditor bfeSameFilename;
+ private Label lblCheckTs;
+
+ private Group changelogGroup;
+ private IntegerFieldEditor ifeChangelogLimit;
+
+ private Composite checksumsContainer;
+ private RadioGroupFieldEditor rgfeChecksums;
+ private Composite compressContainer;
+ private RadioGroupFieldEditor rgfeCompressionTypes;
+
+ /**
+ * Default Constructor. Sets the description of the property page.
+ */
+ public CreaterepoGeneralPropertyPage() {
+ super(Messages.CreaterepoPreferencePage_description);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoPropertyPage#addContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Composite addContents(Composite parent) {
+ composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ GridData layoutData = new GridData();
+ composite.setLayout(layout);
+
+ // TODO: use BooleanFieldEditor and get it to layout properly
+ // with the link (lnWorkspaceSettings)
+ btnProjectSettings = new Button(composite, SWT.CHECK);
+ btnProjectSettings.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ toggleEnabled();
+ }
+ });
+ layoutData = new GridData();
+ layoutData.horizontalAlignment = GridData.BEGINNING;
+ layoutData.horizontalAlignment = GridData.FILL;
+ layoutData.grabExcessHorizontalSpace = true;
+ btnProjectSettings.setText(Messages.CreaterepoGeneralPropertyPage_projectSettings);
+ btnProjectSettings.setLayoutData(layoutData);
+ btnProjectSettings.setSelection(loadBoolean(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED));
+ btnProjectSettings.addSelectionListener(new SelectionAdapter() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ checkState();
+ }
+ });
+
+ lnWorkspaceSettings = new Link(composite, SWT.NONE);
+ layoutData = new GridData();
+ layoutData.horizontalAlignment = SWT.END;
+ lnWorkspaceSettings.setLayoutData(layoutData);
+ lnWorkspaceSettings.setText(NLS.bind(linkTags, Messages.CreaterepoGeneralPropertyPage_workspaceSettings));
+ lnWorkspaceSettings.setFont(parent.getFont());
+ lnWorkspaceSettings.addListener(SWT.Selection, new Listener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent(Event event) {
+ PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(getShell(),
+ CREATEREPO_PREFERENCE_ID, new String[] {CREATEREPO_PREFERENCE_ID}, null);
+ preferenceDialog.open();
+ }
+ });
+
+ // general group
+ generalGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ layout = new GridLayout(2, false);
+ generalGroup.setLayout(layout);
+ generalGroup.setText(Messages.CreaterepoPreferencePage_generalGroupLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,1).applyTo(generalGroup);
+
+ // generate unique metadata filenames
+ bfeIncludeChecksum = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME,
+ Messages.CreaterepoPreferencePage_booleanChecksumName, generalGroup);
+ bfeIncludeChecksum.fillIntoGrid(generalGroup, 2);
+ bfeIncludeChecksum.setPreferenceStore(preferenceStore);
+ bfeIncludeChecksum.setPropertyChangeListener(this);
+ bfeIncludeChecksum.load();
+
+ // generate sqlite databases
+ bfeSQLDB = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_GENERATE_DB,
+ Messages.CreaterepoPreferencePage_booleanGenerateSQLDB, generalGroup);
+ bfeSQLDB.fillIntoGrid(generalGroup, 2);
+ bfeSQLDB.setPreferenceStore(preferenceStore);
+ bfeSQLDB.setPropertyChangeListener(this);
+ bfeSQLDB.load();
+
+ // ignore symlinks for packages
+ bfeIgnoreSymlinks = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS,
+ Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks, generalGroup);
+ bfeIgnoreSymlinks.fillIntoGrid(generalGroup, 2);
+ bfeIgnoreSymlinks.setPreferenceStore(preferenceStore);
+ bfeIgnoreSymlinks.setPropertyChangeListener(this);
+ bfeIgnoreSymlinks.load();
+
+ // output files in pretty xml format
+ bfePrettyXML = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_PRETTY_XML,
+ Messages.CreaterepoPreferencePage_booleanPrettyXML, generalGroup);
+ bfePrettyXML.fillIntoGrid(generalGroup, 2);
+ bfePrettyXML.setPreferenceStore(preferenceStore);
+ bfePrettyXML.setPropertyChangeListener(this);
+ bfePrettyXML.load();
+
+ // number of workers
+ ifeSpawns = new IntegerFieldEditor(CreaterepoPreferenceConstants.PREF_WORKERS,
+ Messages.CreaterepoPreferencePage_numWorkers, generalGroup);
+ ifeSpawns.fillIntoGrid(generalGroup, 2);
+ // more than 128 is alot. limiting. (createrepo warning)
+ ifeSpawns.setValidRange(0, 128);
+ ifeSpawns.setPreferenceStore(preferenceStore);
+ ifeSpawns.setPropertyChangeListener(this);
+ ifeSpawns.load();
+ updateGroupSpacing(generalGroup);
+
+ // updates group
+ updatesGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ updatesGroup.setText(Messages.CreaterepoPreferencePage_updateGroupLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).hint(10, SWT.DEFAULT).applyTo(updatesGroup);
+
+ // don't generate repo metadata, if their timestamps are newer than its rpms
+ bfeSameFilename = new BooleanFieldEditor(CreaterepoPreferenceConstants.PREF_CHECK_TS,
+ Messages.CreaterepoPreferencePage_booleanCheckTS, updatesGroup);
+ bfeSameFilename.fillIntoGrid(updatesGroup, 2);
+ bfeSameFilename.setPreferenceStore(preferenceStore);
+ bfeSameFilename.setPropertyChangeListener(this);
+ bfeSameFilename.load();
+
+ // note of caution
+ lblCheckTs = new Label(updatesGroup, SWT.WRAP);
+ lblCheckTs.setText(Messages.CreaterepoPreferencePage_checkTSNote);
+ layoutData = new GridData();
+ layoutData.widthHint = 130;
+ layoutData.horizontalAlignment = SWT.FILL;
+ layoutData.grabExcessHorizontalSpace = true;
+ layoutData.horizontalIndent = 5;
+ lblCheckTs.setLayoutData(layoutData);
+ updateGroupSpacing(updatesGroup);
+
+ // changelog group
+ changelogGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ changelogGroup.setText(Messages.CreaterepoPreferencePage_changelogGroupLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).hint(10, SWT.DEFAULT).applyTo(changelogGroup);
+
+ // don't generate repo metadata, if their timestamps are newer than its rpms
+ ifeChangelogLimit = new IntegerFieldEditor(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT,
+ Messages.CreaterepoPreferencePage_numChangelogLimit, changelogGroup);
+ ifeChangelogLimit.fillIntoGrid(changelogGroup, 2);
+ ifeChangelogLimit.setValidRange(0, Integer.MAX_VALUE);
+ ifeChangelogLimit.setPreferenceStore(preferenceStore);
+ ifeChangelogLimit.setPropertyChangeListener(this);
+ ifeChangelogLimit.load();
+ updateGroupSpacing(changelogGroup);
+
+ checksumsContainer = new Composite(composite, SWT.NONE);
+ checksumsContainer.setLayout(new GridLayout());
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(0, 20).grab(true, false).applyTo(checksumsContainer);
+ // available checksums
+ rgfeChecksums = new RadioGroupFieldEditor(CreaterepoPreferenceConstants.PREF_CHECKSUM,
+ Messages.CreaterepoPreferencePage_checksumGroupLabel, 1, new String[][]{
+ {ICreaterepoChecksums.SHA1, ICreaterepoChecksums.SHA1},
+ {ICreaterepoChecksums.MD5, ICreaterepoChecksums.MD5},
+ {ICreaterepoChecksums.SHA256, ICreaterepoChecksums.SHA256},
+ {ICreaterepoChecksums.SHA512, ICreaterepoChecksums.SHA512}
+ }, checksumsContainer, true);
+ rgfeChecksums.setPreferenceStore(preferenceStore);
+ rgfeChecksums.setPropertyChangeListener(this);
+ rgfeChecksums.load();
+
+ compressContainer = new Composite(composite, SWT.NONE);
+ compressContainer.setLayout(new GridLayout());
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(0, 20).grab(true, false).applyTo(compressContainer);
+ // available compression types
+ rgfeCompressionTypes = new RadioGroupFieldEditor(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE,
+ Messages.CreaterepoPreferencePage_compressionGroupLabel, 1, new String[][]{
+ {ICreaterepoCompressionTypes.COMPAT, ICreaterepoCompressionTypes.COMPAT},
+ {ICreaterepoCompressionTypes.XZ, ICreaterepoCompressionTypes.XZ},
+ {ICreaterepoCompressionTypes.GZ, ICreaterepoCompressionTypes.GZ},
+ {ICreaterepoCompressionTypes.BZ2, ICreaterepoCompressionTypes.BZ2}
+ }, compressContainer, true);
+ rgfeCompressionTypes.setPreferenceStore(preferenceStore);
+ rgfeCompressionTypes.setPropertyChangeListener(this);
+ rgfeCompressionTypes.load();
+
+ toggleEnabled();
+
+ return composite;
+ }
+
+ /**
+ * Return the boolean value of the preference key.
+ *
+ * @param preferenceKey The preference key to get the boolean value of.
+ * @return The boolean value of the preference key.
+ */
+ protected boolean loadBoolean(String preferenceKey) {
+ IEclipsePreferences projectPreferences = new ProjectScope(project)
+ .getNode(Activator.PLUGIN_ID);
+ boolean value = projectPreferences.getBoolean(preferenceKey,
+ getPreferenceStore().getDefaultBoolean(preferenceKey));
+ return value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ public void performDefaults() {
+ // load the defaults UI
+ btnProjectSettings.setSelection(getPreferenceStore().getDefaultBoolean(
+ CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED));
+ bfeIncludeChecksum.loadDefault();
+ bfeSQLDB.loadDefault();
+ bfeIgnoreSymlinks.loadDefault();
+ bfePrettyXML.loadDefault();
+ ifeSpawns.loadDefault();
+ rgfeChecksums.loadDefault();
+ bfeSameFilename.loadDefault();
+ ifeChangelogLimit.loadDefault();
+ rgfeChecksums.loadDefault();
+ rgfeCompressionTypes.loadDefault();
+
+ // set the defaults preferences
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_GENERATE_DB);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_PRETTY_XML);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_WORKERS);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_CHECK_TS);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_CHECKSUM);
+ getPreferenceStore().setToDefault(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE);
+
+ toggleEnabled();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ // only save when using project specific settings
+ if (btnProjectSettings.getSelection()) {
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED, true);
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME,
+ bfeIncludeChecksum.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_GENERATE_DB,
+ bfeSQLDB.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS,
+ bfeIgnoreSymlinks.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_PRETTY_XML,
+ bfePrettyXML.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_WORKERS,
+ ifeSpawns.getIntValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_CHECK_TS,
+ bfeSameFilename.getBooleanValue());
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT,
+ ifeChangelogLimit.getIntValue());
+
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_CHECKSUM,
+ getSelectedRadioButton(rgfeChecksums.getRadioBoxControl(checksumsContainer),
+ rgfeChecksums.getPreferenceName()));
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE,
+ getSelectedRadioButton(rgfeCompressionTypes.getRadioBoxControl(compressContainer),
+ rgfeCompressionTypes.getPreferenceName()));
+ } else {
+ getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED, false);
+ }
+ return true;
+ }
+
+ /**
+ * Helper method to get the selected radio button from the radio button list.
+ * The default value of the preference key will be returned if nothing was found to be
+ * selected.
+ *
+ * @param radioBoxControl The radio button list.
+ * @param preferenceKey The preference key to get the default from.
+ * @return The selected radio button or the default value if nothing selected.
+ */
+ private String getSelectedRadioButton(Composite radioBoxControl, String preferenceKey) {
+ String defaultValue = getPreferenceStore().getDefaultString(preferenceKey);
+ Control[] children = radioBoxControl.getChildren();
+ if (children.length > 0) {
+ for (Control control : children) {
+ Button radioButton = (Button) control;
+ if (radioButton.getSelection()) {
+ return radioButton.getText();
+ }
+ }
+ }
+ return defaultValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.rpm.createrepo.preference.CreaterepoPropertyPage#checkState()
+ */
+ @Override
+ protected void checkState() {
+ // if enable project specific settings is false, then allow performOk
+ if (!btnProjectSettings.getSelection()) {
+ setErrorMessage(null);
+ setValid(true);
+ // if the spawns are invalid, disable performOk
+ } else if (!ifeSpawns.isValid()) {
+ setErrorMessage(ifeSpawns.getErrorMessage());
+ setValid(false);
+ } else if (!ifeChangelogLimit.isValid()) {
+ setErrorMessage(ifeChangelogLimit.getErrorMessage());
+ setValid(false);
+ // otherwise, allow performOk
+ } else {
+ setErrorMessage(null);
+ setValid(true);
+ }
+ toggleEnabled();
+ }
+
+ /**
+ * If "Enable project specific settings" is true, so will
+ * the options below it. The workspace settings link will be opposite
+ * to what value the checkbox is.
+ */
+ private void toggleEnabled() {
+ boolean enabled = btnProjectSettings.getSelection();
+ lnWorkspaceSettings.setEnabled(!enabled);
+ bfeIncludeChecksum.setEnabled(enabled, generalGroup);
+ bfeSQLDB.setEnabled(enabled, generalGroup);
+ bfeIgnoreSymlinks.setEnabled(enabled, generalGroup);
+ bfePrettyXML.setEnabled(enabled, generalGroup);
+ ifeSpawns.setEnabled(enabled, generalGroup);
+ rgfeChecksums.setEnabled(enabled, generalGroup);
+ bfeSameFilename.setEnabled(enabled, updatesGroup);
+ ifeChangelogLimit.setEnabled(enabled, changelogGroup);
+ rgfeChecksums.setEnabled(enabled, checksumsContainer);
+ rgfeCompressionTypes.setEnabled(enabled, compressContainer);
+ lblCheckTs.setEnabled(enabled);
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
index 8654657..09ce1fb 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
@@ -42,11 +42,6 @@ public class CreaterepoPreferenceInitializer extends
node.put(CreaterepoPreferenceConstants.PREF_CHECKSUM, CreaterepoPreferenceConstants.DEFAULT_CHECKSUM);
node.put(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE);
- // CreaterepoDeltaPreferencePage
- node.putBoolean(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE, CreaterepoPreferenceConstants.DEFAULT_DELTA_ENABLE);
- node.putInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, CreaterepoPreferenceConstants.DEFAULT_NUM_DELTAS);
- node.putInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, CreaterepoPreferenceConstants.DEFAULT_MAX_DELTA_SIZE);
-
// default preferences
IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
// CreaterepoPreferencePage
@@ -60,7 +55,10 @@ public class CreaterepoPreferenceInitializer extends
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_CHECKSUM, CreaterepoPreferenceConstants.DEFAULT_CHECKSUM);
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE);
- // CreaterepoDeltaPreferencePage
+ // CreaterepoGeneralPropertyPage
+ prefStore.setDefault(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED, CreaterepoPreferenceConstants.DEFAULT_GENERAL_ENABLED);
+
+ // CreaterepoDeltaPropertyPage
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE, CreaterepoPreferenceConstants.DEFAULT_DELTA_ENABLE);
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, CreaterepoPreferenceConstants.DEFAULT_NUM_DELTAS);
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, CreaterepoPreferenceConstants.DEFAULT_MAX_DELTA_SIZE);
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferencePage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferencePage.java
index b3066e4..351056e 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferencePage.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferencePage.java
@@ -162,6 +162,7 @@ public class CreaterepoPreferencePage extends FieldEditorPreferencePage implemen
// don't generate repo metadata, if their timestamps are newer than its rpms
ifeChangelogLimit = new IntegerFieldEditor(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT,
Messages.CreaterepoPreferencePage_numChangelogLimit, changelogGroup);
+ ifeChangelogLimit.setValidRange(0, Integer.MAX_VALUE);
ifeChangelogLimit.load();
ifeChangelogLimit.setPropertyChangeListener(this);
addField(ifeChangelogLimit);
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPropertyPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPropertyPage.java
new file mode 100644
index 0000000..3cbe644
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPropertyPage.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.preference;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * Abstract class for createrepo property pages.
+ */
+public abstract class CreaterepoPropertyPage extends PropertyPage implements IPropertyChangeListener {
+
+ protected static final String CREATEREPO_PREFERENCE_ID = "org.eclipse.linuxtools.rpm.createrepo.preferences"; //$NON-NLS-1$
+
+ protected IProject project;
+ protected IPreferenceStore preferenceStore;
+
+ /**
+ * Default constructor has no description.
+ */
+ public CreaterepoPropertyPage() {
+ this(null);
+ }
+
+ /**
+ * Constructor sets the description.
+ *
+ * @param description The description of the preference page.
+ */
+ public CreaterepoPropertyPage(String description) {
+ setDescription(description);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ if (getElement() instanceof IResource) {
+ project = ((IResource) getElement()).getProject();
+ } else {
+ Object adapter = getElement().getAdapter(IResource.class);
+ if (adapter instanceof IResource) {
+ project = ((IResource) adapter).getProject();
+ }
+ }
+ setPreferenceStore(new ScopedPreferenceStore(new ProjectScope(project),
+ Activator.PLUGIN_ID));
+ preferenceStore = getPreferenceStore();
+ return addContents(parent);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ checkState();
+ }
+ }
+
+ /**
+ * Must be implemented by the subclasses. These are the contents of the
+ * property page. Subclasses should implement this rather than createContents
+ * to add controls to the property page.
+ *
+ * @param parent The composite.
+ * @return The newly customized composite.
+ */
+ protected abstract Composite addContents(Composite parent);
+
+ /**
+ * This method will be called whenever a field editor is changed. Note that
+ * the field editor must first set the property change listener to this.
+ */
+ protected abstract void checkState();
+
+ /**
+ * Make sure there is space above the group as well as space
+ * between the contents of the group and its border.
+ *
+ * @param group The group to update the spacing of.
+ */
+ protected static void updateGroupSpacing(Group group) {
+ GridLayout layout = (GridLayout) group.getLayout();
+ GridData data = (GridData) group.getLayoutData();
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ data.verticalIndent = 20;
+ }
+
+}
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 cc730d0..8dae19e 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
@@ -34,7 +34,10 @@ public final class CreaterepoPreferenceConstants {
/****/ public static final String PREF_CHECKSUM = "checksum"; //$NON-NLS-1$
/****/ public static final String PREF_COMPRESSION_TYPE = "compress-type"; //$NON-NLS-1$
- // CreaterepoDeltaPreferencePage
+ // CreaterepoGeneralPropertyPage
+ /****/ public static final String PREF_GENERAL_ENABLED = "projectSettings"; //$NON-NLS-1$
+
+ // CreaterepoDeltaPropertyPage
/****/ public static final String PREF_DELTA_ENABLE = "deltas"; //$NON-NLS-1$
/****/ public static final String PREF_NUM_DELTAS = "num-deltas"; //$NON-NLS-1$
/****/ public static final String PREF_MAX_DELTA_SIZE = "max-delta-rpm-size"; //$NON-NLS-1$
@@ -55,7 +58,10 @@ public final class CreaterepoPreferenceConstants {
/****/ public static final String DEFAULT_CHECKSUM = ICreaterepoChecksums.SHA256;
/****/ public static final String DEFAULT_COMPRESS_TYPE = ICreaterepoCompressionTypes.COMPAT;
- // CreaterepoDeltaPreferencePage
+ // CreaterepoGeneralPropertyPage
+ /****/ public static final boolean DEFAULT_GENERAL_ENABLED = false;
+
+ // CreaterepoDeltaPropertyPage
/****/ public static final boolean DEFAULT_DELTA_ENABLE = false;
/****/ public static final int DEFAULT_NUM_DELTAS = 1;
/****/ public static final int DEFAULT_MAX_DELTA_SIZE = 10;
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 70f3c9e..538ebba 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
@@ -82,7 +82,7 @@ public class CreaterepoProject {
* @throws CoreException Thrown when unable to create the folders.
*/
private void intitialize() throws CoreException {
- createContentFolder();
+ content = getProject().getFolder(ICreaterepoConstants.CONTENT_FOLDER);
if (repoFile == null) {
for (IResource child : getProject().members()) {
String extension = child.getFileExtension();
@@ -115,7 +115,7 @@ public class CreaterepoProject {
*/
public void importRPM(File externalFile) throws CoreException {
// must put imported RPMs into the content folder; create if missing
- if (content == null) {
+ if (!getContentFolder().exists()) {
createContentFolder();
}
IFile file = getContentFolder().getFile(new Path(externalFile.getName()));
@@ -141,6 +141,9 @@ public class CreaterepoProject {
* @throws CoreException Thrown when failure to execute command.
*/
public IStatus createrepo(OutputStream os) throws CoreException {
+ if (!getContentFolder().exists()) {
+ createContentFolder();
+ }
Createrepo createrepo = new Createrepo();
IStatus result = createrepo.execute(os, this, getCommandArguments());
getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
@@ -182,6 +185,9 @@ public class CreaterepoProject {
*/
public List<IResource> getRPMs() throws CoreException {
List<IResource> rpms = new ArrayList<IResource>();
+ if (!getContentFolder().exists()) {
+ return rpms;
+ }
if (getProject().members().length > 0) {
for (IResource child : getContentFolder().members()) {
String extension = child.getFileExtension();
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
index 6dd8b3c..6458f39 100644
--- 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
@@ -47,6 +47,7 @@ public class CreaterepoProjectCreator {
if (!Platform.getLocation().equals(locationPath)) {
description.setLocation(locationPath);
}
+ description.setNatureIds(new String[] {CreaterepoProjectNature.CREATEREPO_NATURE_ID});
project.create(description, monitor);
project.open(monitor);
IFile repoFile = project.getFile(repoName);
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectNature.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectNature.java
new file mode 100644
index 0000000..1af0484
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProjectNature.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.IProjectNature;
+
+/**
+ * Project nature for createrepo plugin.
+ */
+public class CreaterepoProjectNature implements IProjectNature {
+
+ public static final String CREATEREPO_NATURE_ID = "org.eclipse.linuxtools.rpm.createrepo.createreponature"; //$NON-NLS-1$
+
+ private IProject project;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#configure()
+ */
+ @Override
+ public void configure(){/* not implemented */}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
+ @Override
+ public void deconfigure() {/* not implemented */}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#getProject()
+ */
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
+ */
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}