Author: elvisisking
Date: 2009-09-04 16:57:55 -0400 (Fri, 04 Sep 2009)
New Revision: 1194
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/DnaPreferencePage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/ExtensionEditor.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/NewFileExtensionDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/PrefUtils.java
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
Log:
Added a DNA preference page where the user can enter file extensions. Any file with a
matching extension will not be included in any publishing operation.
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-09-03 20:55:13 UTC (rev
1193)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-09-04 20:57:55 UTC (rev
1194)
@@ -131,4 +131,13 @@
<toc file="docs/toc.xml" primary="true" />
</extension>
+<!-- Preference Page -->
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ name="%dnaCategory"
+
class="org.jboss.dna.web.jcr.rest.client.swt.preferences.DnaPreferencePage"
+ id="dnaPreferencePage">
+ </page>
+ </extension>
</plugin>
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -112,4 +112,15 @@
*/
String DNA_PUBLISHING_JOB_FAMILY = "dna.publishing.job.family";
//$NON-NLS-1$
+ //
+ // Preferences
+ //
+
+ /**
+ * A preference for a list of file extensions that will not be part of publishing
operations.
+ *
+ * @since 0.6
+ */
+ String FILTERED_FILE_EXTENSIONS_PREFERENCE =
"dna.preference.filteredFileExtensions"; //$NON-NLS-1$
+
}
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -48,6 +48,11 @@
public static I18n dnaConsoleName;
public static I18n dnaConsoleProblemCreatingHyperlinkMsg;
public static I18n dnaConsoleFilePathNotFoundMsg;
+
+ public static I18n dnaPreferencePageFilteredFileExtensionsDescription;
+ public static I18n dnaPreferencePageFilteredFileExtensionsLabel;
+ public static I18n dnaPreferencePageFilteredFileExtensionsMessage;
+ public static I18n dnaPreferencePageFilteredFileExtensionsTitle;
public static I18n editServerActionText;
public static I18n editServerActionToolTip;
@@ -55,6 +60,9 @@
public static I18n errorDialogTitle;
public static I18n missingImage;
+
+ public static I18n newFileExtensionDialogLabel;
+ public static I18n newFileExtensionDialogTitle;
public static I18n newServerActionText;
public static I18n newServerActionToolTip;
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties 2009-09-04
20:57:55 UTC (rev 1194)
@@ -40,11 +40,19 @@
dnaConsoleName = DNA
dnaConsoleProblemCreatingHyperlinkMsg = Unexpected problem creating hyperlink in DNA
Console view
dnaConsoleFilePathNotFoundMsg = A hyperlink could not be created in the DNA Message
Console because the file path of "{0}" could not be found.
+
+dnaPreferencePageFilteredFileExtensionsDescription = Add, remove, or edit the filtered
file extensions. Files with matching extensions will NOT be published to DNA
repositories.
+dnaPreferencePageFilteredFileExtensionsLabel = Filtered File Extensions:
+dnaPreferencePageFilteredFileExtensionsMessage = DNA
+dnaPreferencePageFilteredFileExtensionsTitle = DNA Filtered File Extensions
errorDialogTitle = Error
missingImage = The following image cannot be found "{0}"
+newFileExtensionDialogLabel = File Extension:
+newFileExtensionDialogTitle = New Filtered File Extension
+
newServerActionText = New Server
newServerActionToolTip = Create a new server
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -23,6 +23,16 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
@@ -44,6 +54,24 @@
//
===========================================================================================================================
/**
+ * @param tokens the tokens being combined into one value
+ * @param delimiter the character inserted to separate each token
+ * @return the tokens separated by the delimiter
+ * @since 0.6
+ */
+ public static String combineTokens( String[] tokens,
+ char delimiter ) {
+ CheckArg.isNotNull(tokens, "tokens"); //$NON-NLS-1$
+ StringBuilder value = new StringBuilder();
+
+ for (String token : tokens) {
+ value.append(token).append(delimiter);
+ }
+
+ return value.toString();
+ }
+
+ /**
* Sizes the shell to the minimum of it's current size or the width and height
display percentages.
*
* @param shell the shell being resized (if necessary) and located
@@ -113,6 +141,33 @@
}
/**
+ * @param container the project or folder whose files are being requested
+ * @param recurse the flag indicating if child containers should be traversed
+ * @return the list of files contained in the specified container (never
<code>null</code>)
+ * @throws CoreException if there is a problem finding the files
+ * @since 0.6
+ */
+ public static List<IFile> findFiles( IContainer container,
+ boolean recurse ) throws CoreException {
+ List<IFile> result = new ArrayList<IFile>();
+
+ for (IResource member : container.members()) {
+ if (recurse && (member instanceof IContainer)) {
+ // don't select closed projects
+ if ((member instanceof IProject) && !((IProject)member).isOpen())
{
+ continue;
+ }
+
+ result.addAll(findFiles((IContainer)member, recurse));
+ } else if ((member instanceof IFile) &&
((IFile)member).getLocation().toFile().exists()) {
+ result.add((IFile)member);
+ }
+ }
+
+ return result;
+ }
+
+ /**
* The OK status does not have an image.
*
* @param status the status whose image is being requested (never
<code>null</code>)
@@ -139,6 +194,32 @@
}
/**
+ * @param string the string whose tokens are being requested (may be
<code>null</code>)
+ * @param delimiters the delimiters that separate the tokens (never
<code>null</code>)
+ * @param removeDuplicates a flag indicating if duplicate tokens should be removed
+ * @return the tokens (never <code>null</code>)
+ * @since 0.6
+ */
+ public static String[] getTokens( String string,
+ String delimiters,
+ boolean removeDuplicates ) {
+ CheckArg.isNotNull(delimiters, "delimiters"); //$NON-NLS-1$
+
+ if (string == null) {
+ return new String[0];
+ }
+
+ Collection<String> tokens = removeDuplicates ? new TreeSet<String>()
: new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(string, delimiters);
+
+ while (st.hasMoreTokens()) {
+ tokens.add(st.nextToken());
+ }
+
+ return tokens.toArray(new String[tokens.size()]);
+ }
+
+ /**
* The image can be used to decorate an existing image.
*
* @param status the status whose image overlay is being requested (never
<code>null</code>)
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/DnaPreferencePage.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/DnaPreferencePage.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/DnaPreferencePage.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -0,0 +1,177 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.swt.preferences;
+
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_IMAGE_16x;
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.dnaPreferencePageFilteredFileExtensionsDescription;
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.dnaPreferencePageFilteredFileExtensionsMessage;
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.dnaPreferencePageFilteredFileExtensionsTitle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+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.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+
+/**
+ * The <code>DnaPreferencePage</code> is the UI for managing all DNA-related
preferences.
+ *
+ * @since 0.6
+ */
+public final class DnaPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The editor used to manage the list of file extensions.
+ *
+ * @since 0.6
+ */
+ private ExtensionEditor editor;
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ * @since 0.6
+ */
+ @Override
+ protected Control createContents( Composite parent ) {
+ Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayout(new GridLayout(2, false));
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ // create the editor
+ this.editor = new ExtensionEditor(panel);
+ this.editor.setPreferenceStore(getPreferenceStore());
+ this.editor.getListControl(panel).setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true));
+
+ // populate the editor
+ this.editor.load();
+
+ return panel;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
+ * @since 0.6
+ */
+ @Override
+ public String getDescription() {
+ return dnaPreferencePageFilteredFileExtensionsDescription.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getImage()
+ * @since 0.6
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getDefault().getImage(DNA_IMAGE_16x);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
+ * @since 0.6
+ */
+ @Override
+ public String getMessage() {
+ return dnaPreferencePageFilteredFileExtensionsMessage.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
+ * @since 0.6
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return PrefUtils.getPreferenceStore();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
+ * @since 0.6
+ */
+ @Override
+ public String getTitle() {
+ return dnaPreferencePageFilteredFileExtensionsTitle.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ * @since 0.6
+ */
+ @Override
+ public void init( IWorkbench workbench ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ * @since 0.6
+ */
+ @Override
+ protected void performDefaults() {
+ this.editor.loadDefault();
+ super.performDefaults();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ * @since 0.6
+ */
+ @Override
+ public boolean performOk() {
+ this.editor.store();
+ return super.performOk();
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/DnaPreferencePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/ExtensionEditor.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/ExtensionEditor.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/ExtensionEditor.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -0,0 +1,110 @@
+package org.jboss.dna.web.jcr.rest.client.swt.preferences;
+
+import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.FILTERED_FILE_EXTENSIONS_PREFERENCE;
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.dnaPreferencePageFilteredFileExtensionsLabel;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
+
+/**
+ * The <code>ExtensionEditor</code> is an editor for managing a set of file
extensions.
+ *
+ * @since 0.6
+ */
+public final class ExtensionEditor extends ListEditor {
+
+ //
=======================================================================================================================
+ // Constants
+ //
=======================================================================================================================
+
+ /**
+ * The delimiter used to separate file extensions when saved to the preference
store.
+ *
+ * @since 0.6
+ */
+ private static final char DELIM = ',';
+
+ //
=======================================================================================================================
+ // Fields
+ //
=======================================================================================================================
+
+ /**
+ * The current set of file extensions.
+ *
+ * @since 0.6
+ */
+ private final Set<String> extensions;
+
+ //
=======================================================================================================================
+ // Constructors
+ //
=======================================================================================================================
+
+ /**
+ * @param parent the parent control
+ * @since 0.6
+ */
+ public ExtensionEditor( Composite parent ) {
+ super(FILTERED_FILE_EXTENSIONS_PREFERENCE,
dnaPreferencePageFilteredFileExtensionsLabel.text(), parent);
+ this.extensions = new TreeSet<String>();
+ }
+
+ //
=======================================================================================================================
+ // Methods
+ //
=======================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
+ * @since 0.6
+ */
+ @Override
+ protected String createList( String[] items ) {
+ return Utils.combineTokens(items, DELIM);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.ListEditor#getNewInputObject()
+ * @since 0.6
+ */
+ @Override
+ protected String getNewInputObject() {
+ NewFileExtensionDialog dialog = new NewFileExtensionDialog(getShell());
+
+ if (dialog.open() == Window.OK) {
+ String extension = dialog.getFileExtension();
+
+ // add new extension
+ if (extension != null) {
+ this.extensions.add(extension);
+ return extension;
+ }
+ }
+
+ // user canceled dialog
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
+ * @since 0.6
+ */
+ @Override
+ protected String[] parseString( String stringList ) {
+ String[] values = Utils.getTokens(stringList, Character.toString(DELIM), true);
+
+ this.extensions.clear();
+ this.extensions.addAll(Arrays.asList(values));
+
+ return values;
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/ExtensionEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/NewFileExtensionDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/NewFileExtensionDialog.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/NewFileExtensionDialog.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -0,0 +1,156 @@
+package org.jboss.dna.web.jcr.rest.client.swt.preferences;
+
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.newFileExtensionDialogLabel;
+import static
org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n.newFileExtensionDialogTitle;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A <code>NewFileExtensionDialog</code> allows the user to enter a file
extension that they wish to be filtered out of all
+ * publishing operations.
+ *
+ * @since 0.6
+ */
+public final class NewFileExtensionDialog extends Dialog implements ModifyListener,
VerifyListener {
+
+ //
=======================================================================================================================
+ // Fields
+ //
=======================================================================================================================
+
+ /**
+ * The contents of the extension text field.
+ *
+ * @since 0.6
+ */
+ private String extension;
+
+ //
=======================================================================================================================
+ // Constructors
+ //
=======================================================================================================================
+
+ /**
+ * @param parentShell the parent shell
+ * @since 0.6
+ */
+ protected NewFileExtensionDialog( Shell parentShell ) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ //
=======================================================================================================================
+ // Methods
+ //
=======================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ * @since 0.6
+ */
+ @Override
+ protected void configureShell( Shell newShell ) {
+ newShell.setText(newFileExtensionDialogTitle.text());
+ super.configureShell(newShell);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int,
java.lang.String, boolean)
+ * @since 0.6
+ */
+ @Override
+ protected Button createButton( Composite parent,
+ int id,
+ String label,
+ boolean defaultButton ) {
+ Button button = super.createButton(parent, id, label, defaultButton);
+
+ // disable OK button initially
+ if (id == OK) {
+ button.setEnabled(false);
+ }
+
+ return button;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ * @since 0.6
+ */
+ @Override
+ protected Control createDialogArea( Composite parent ) {
+ Composite panel = (Composite)super.createDialogArea(parent);
+ Composite pnlEditor = new Composite(panel, SWT.NONE);
+ pnlEditor.setLayout(new GridLayout(2, false));
+ pnlEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label label = new Label(pnlEditor, SWT.NONE);
+ label.setText(newFileExtensionDialogLabel.text());
+
+ Text textField = new Text(pnlEditor, SWT.BORDER);
+ textField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ textField.addVerifyListener(this);
+ textField.addModifyListener(this);
+
+ return panel;
+ }
+
+ /**
+ * @return the file extension or <code>null</code> if dialog was
canceled
+ * @since 0.6
+ */
+ public String getFileExtension() {
+ if (getReturnCode() == OK) {
+ return this.extension;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ * @since 0.6
+ */
+ @Override
+ public void modifyText( ModifyEvent event ) {
+ // disable OK button if text field does not have any characters
+ this.extension = ((Text)event.widget).getText();
+ boolean enable = (this.extension.length() != 0);
+
+ if (getButton(OK).getEnabled() != enable) {
+ getButton(OK).setEnabled(enable);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
+ * @since 0.6
+ */
+ @Override
+ public void verifyText( VerifyEvent event ) {
+ // only allow letters, numbers, backspace, and delete
+ if (!Character.isLetterOrDigit(event.character) && (event.character !=
'\b') && (event.character != '\u007F')) {
+ event.doit = false;
+ }
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/NewFileExtensionDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/PrefUtils.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/PrefUtils.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/PrefUtils.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -0,0 +1,100 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.swt.preferences;
+
+import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.FILTERED_FILE_EXTENSIONS_PREFERENCE;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
+
+/**
+ * The <code>PrefUtils</code> class provides common utilities relating to
preferences. This class assumes the Eclipse runtime
+ * platform is running.
+ *
+ * @since 0.6
+ */
+public final class PrefUtils {
+
+ //
=======================================================================================================================
+ // Class Methods
+ //
=======================================================================================================================
+
+ /**
+ * @return the file extensions being filtered out of publishing operations (never
null)
+ * @since 0.6
+ */
+ public static String[] getFilteredFileExtensions() {
+ return getListPropertyValue(FILTERED_FILE_EXTENSIONS_PREFERENCE, ',',
true);
+ }
+
+ /**
+ * @param propertyId the property name whose list values are being requested
+ * @param delimiter the character separating the items in the property value
+ * @param removeDuplicates a flag indicating if duplicate items should be removed
+ * @return the property value items (never <code>null</code>)
+ * @since 0.6
+ */
+ public static String[] getListPropertyValue( String propertyId,
+ char delimiter,
+ boolean removeDuplicates ) {
+ CheckArg.isNotNull(propertyId, "propertyId"); //$NON-NLS-1$
+ return Utils.getTokens(getPreferenceStore().getString(propertyId),
Character.toString(delimiter), removeDuplicates);
+ }
+
+ /**
+ * @return the plugin preference store
+ * @since 0.6
+ */
+ public static IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * @param propertyId the property name being set (never
<code>null</code>)
+ * @param items the items used to create the property value (never
<code>null</code>)
+ * @param delimiter the character to use to separate the items
+ * @since 0.6
+ */
+ public static void setListPropertyValue( String propertyId,
+ String[] items,
+ char delimiter ) {
+ CheckArg.isNotNull(propertyId, "propertyId"); //$NON-NLS-1$
+ CheckArg.isNotNull(items, "items"); //$NON-NLS-1$
+ getPreferenceStore().setValue(propertyId, Utils.combineTokens(items,
delimiter));
+ }
+
+ //
=======================================================================================================================
+ // Constructors
+ //
=======================================================================================================================
+
+ /**
+ * Don't allow construction.
+ *
+ * @since 0.6
+ */
+ private PrefUtils() {
+ // nothing to do
+ }
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/preferences/PrefUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -162,22 +162,24 @@
public Object[] getChildren( Object parentElement ) {
assert (parentElement instanceof IDnaObject);
- try {
- if ((parentElement instanceof Server) && (getServerManager() !=
null)) {
- return
getServerManager().getRepositories((Server)parentElement).toArray();
+ if (getServerManager() != null) {
+ try {
+ if ((parentElement instanceof Server) &&
getServerManager().ping((Server)parentElement).isOk()) {
+ return
getServerManager().getRepositories((Server)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg =
RestClientI18n.serverManagerGetRepositoriesExceptionMsg.text(((Server)parentElement).getShortDescription());
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
}
- } catch (Exception e) {
- String msg =
RestClientI18n.serverManagerGetRepositoriesExceptionMsg.text(((Server)parentElement).getShortDescription());
- Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
- }
- try {
- if ((parentElement instanceof Repository) && (getServerManager() !=
null)) {
- return
getServerManager().getWorkspaces((Repository)parentElement).toArray();
+ try {
+ if (parentElement instanceof Repository) {
+ return
getServerManager().getWorkspaces((Repository)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg =
RestClientI18n.serverManagerGetWorkspacesExceptionMsg.text();
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
}
- } catch (Exception e) {
- String msg = RestClientI18n.serverManagerGetWorkspacesExceptionMsg.text();
- Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
}
return new Object[0];
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-09-03
20:55:13 UTC (rev 1193)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-09-04
20:57:55 UTC (rev 1194)
@@ -64,7 +64,9 @@
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
import org.jboss.dna.web.jcr.rest.client.swt.actions.NewServerAction;
+import org.jboss.dna.web.jcr.rest.client.swt.preferences.PrefUtils;
import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
@@ -90,33 +92,6 @@
//
===========================================================================================================================
/**
- * @param container the project or folder whose files are being requested
- * @param recurse the flag indicating if child containers should be traversed
- * @return the list of files contained in the specified container (never
<code>null</code>)
- * @throws CoreException if there is a problem finding the files
- * @since 0.6
- */
- private static List<IFile> findFiles( IContainer container,
- boolean recurse ) throws CoreException {
- List<IFile> result = new ArrayList<IFile>();
-
- for (IResource member : container.members()) {
- if (recurse && (member instanceof IContainer)) {
- // don't publish closed projects
- if ((member instanceof IProject) && !((IProject)member).isOpen())
{
- continue;
- }
-
- result.addAll(findFiles((IContainer)member, recurse));
- } else if ((member instanceof IFile) &&
((IFile)member).getLocation().toFile().exists()) {
- result.add((IFile)member);
- }
- }
-
- return result;
- }
-
- /**
* Processes the specified list of files and for (1) each file found adds it to the
result and (2) for each project or folder
* adds all contained files. For projects and folders processing will be recursive
based on saved wizard settings.
*
@@ -220,14 +195,14 @@
Map<IContainer, List<IFile>> parentMap =
projectMap.get(project);
if (parentMap == null) {
- result.addAll(findFiles(project, recurse));
+ result.addAll(Utils.findFiles(project, recurse));
} else {
// process folders with no folder entries
for (IContainer folder : parentMap.keySet()) {
List<IFile> files = parentMap.get(folder);
if (files == null) {
- result.addAll(findFiles(folder, recurse));
+ result.addAll(Utils.findFiles(folder, recurse));
}
}
}
@@ -282,6 +257,13 @@
private List<IFile> files;
/**
+ * Indicates if the selected files should be filtered based on their file extension.
+ *
+ * @since 0.6
+ */
+ private boolean filterFiles = true;
+
+ /**
* The control containing all the files being published or unpublished.
*
* @since 0.6
@@ -371,7 +353,8 @@
public PublishPage( Type type,
List<IResource> resources ) throws CoreException {
super(PublishPage.class.getSimpleName());
- setTitle((type == Type.PUBLISH) ? RestClientI18n.publishPagePublishTitle.text() :
RestClientI18n.publishPageUnpublishTitle.text());
+ setTitle((type == Type.PUBLISH) ? RestClientI18n.publishPagePublishTitle.text()
+ :
RestClientI18n.publishPageUnpublishTitle.text());
setPageComplete(false);
this.type = type;
@@ -577,7 +560,8 @@
* @since 0.6
*/
void updateInitialMessage() {
- String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
+ :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
if (msg.equals(getMessage())) {
updateState();
@@ -700,18 +684,37 @@
* Populates the list of files to be published based on the recurse flag and the list
of workspace selected resources.
* Pre-condition is that {@link #processResources(List, boolean)} has been called.
*
+ * @return the number of files filtered out
* @since 0.6
*/
- private void loadFiles() {
- String[] data = new String[this.files.size()];
- int i = 0;
+ private int loadFiles() {
+ this.lstResources.removeAll();
+ String[] filteredExtensions = null;
+ int numFiltered = 0;
+
+ if (this.filterFiles) {
+ filteredExtensions = PrefUtils.getFilteredFileExtensions();
+ }
+
+ LOADING:
for (IResource resource : this.files) {
- data[i] = resource.getFullPath().toString();
- ++i;
+ String filePath = resource.getFullPath().toString();
+
+ // filter if necessary
+ if (filteredExtensions != null) {
+ for (String ext : filteredExtensions) {
+ if (filePath.endsWith('.' + ext)) {
+ ++numFiltered;
+ continue LOADING; // don't add file
+ }
+ }
+ }
+
+ this.lstResources.add(filePath);
}
- this.lstResources.setItems(data);
+ return numFiltered;
}
/**
@@ -934,7 +937,8 @@
// set initial message
if (this.status.isOk()) {
- String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
+ :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
setMessage(msg, IMessageProvider.NONE);
} else {
setMessage(this.status.getMessage(), IMessageProvider.ERROR);
@@ -998,19 +1002,24 @@
Severity severity = Severity.ERROR;
if ((this.resources == null) || this.resources.isEmpty() || this.files.isEmpty())
{
- msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPageNoResourcesToPublishStatusMsg.text() :
RestClientI18n.publishPageNoResourcesToUnpublishStatusMsg.text());
+ msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPageNoResourcesToPublishStatusMsg.text()
+ :
RestClientI18n.publishPageNoResourcesToUnpublishStatusMsg.text());
} else if (this.server == null) {
int count = this.cbxServer.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableServersStatusMsg.text() :
RestClientI18n.publishPageMissingServerStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableServersStatusMsg.text()
+ :
RestClientI18n.publishPageMissingServerStatusMsg.text());
} else if (this.repository == null) {
int count = this.cbxRepository.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableRepositoriesStatusMsg.text() :
RestClientI18n.publishPageMissingRepositoryStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableRepositoriesStatusMsg.text()
+ :
RestClientI18n.publishPageMissingRepositoryStatusMsg.text());
} else if (this.workspace == null) {
int count = this.cbxWorkspace.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableWorkspacesStatusMsg.text() :
RestClientI18n.publishPageMissingWorkspaceStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableWorkspacesStatusMsg.text()
+ :
RestClientI18n.publishPageMissingWorkspaceStatusMsg.text());
} else {
severity = Severity.OK;
- msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
+ :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
}
this.status = new Status(severity, msg, null);