Author: elvisisking
Date: 2011-04-15 12:44:43 -0400 (Fri, 15 Apr 2011)
New Revision: 30595
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
Removed:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java
Log:
JBIDE-7857 ModeShape preferences should match the "Team"->"Ignored
Resources." Removed the file and folder name prefernces and added an ignored
resources preference. The prefernce page was changed to match the "Team"
preference page look and behavior.
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2011-04-15
16:44:43 UTC (rev 30595)
@@ -20,6 +20,7 @@
.
Export-Package: javax.jcr.nodetype,
org.jboss.tools.modeshape.rest,
+ org.jboss.tools.modeshape.rest.preferences,
org.modeshape.common.i18n,
org.modeshape.web.jcr.rest.client,
org.modeshape.web.jcr.rest.client.domain
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2011-04-15
16:44:43 UTC (rev 30595)
@@ -14,7 +14,7 @@
contextMenu.label = ModeShape
decorator.description = Decorates objects in the ModeShape View
decorator.label = ModeShape View Decorator
-fileFiltersPreferencePage = File Filters
+ignoredResourcesPreferencePage = Ignored Resources
modeShapeCategory = ModeShape
preferenceInitializer = Preference Initializer for default values
publishCommand.name = Publish
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2011-04-15
16:44:43 UTC (rev 30595)
@@ -209,14 +209,14 @@
</page>
</extension>
-<!-- File Filters Preference Page -->
+<!-- Ignored Resources Preference Page -->
<extension
point="org.eclipse.ui.preferencePages">
<page
- name="%fileFiltersPreferencePage"
+ name="%ignoredResourcesPreferencePage"
category="modeShapePreferencePage"
-
class="org.jboss.tools.modeshape.rest.preferences.FileFiltersPreferencePage"
- id="modeShapeFileFiltersPreferencePage">
+
class="org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesPreferencePage"
+ id="modeShapeIgnoredResourcesPreferencePage">
</page>
<!-- Preference Initializer -->
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/IUiConstants.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -90,27 +90,27 @@
* The message console help context.
*/
String MESSAGE_CONSOLE_HELP_CONTEXT = HELP_CONTEXT_PREFIX +
"messageConsoleHelpContext"; //$NON-NLS-1$
-
+
/**
* The preference pages help context.
*/
String PREFERENCE_PAGE_HELP_CONTEXT = HELP_CONTEXT_PREFIX +
"preferencesHelpContext"; //$NON-NLS-1$
-
+
/**
* The publish and unpublish dialog help context.
*/
String PUBLISH_DIALOG_HELP_CONTEXT = HELP_CONTEXT_PREFIX +
"publishDialogHelpContext"; //$NON-NLS-1$
-
+
/**
* The server wizard and dialog page help context.
*/
String SERVER_DIALOG_HELP_CONTEXT = HELP_CONTEXT_PREFIX +
"serverDialogHelpContext"; //$NON-NLS-1$
-
+
/**
* The server view help context.
*/
String SERVER_VIEW_HELP_CONTEXT = HELP_CONTEXT_PREFIX +
"serverViewHelpContext"; //$NON-NLS-1$
-
+
}
/**
@@ -122,22 +122,18 @@
* A preference that indicates if the ModeShape server should use resource
versioning. If versioning is not used, only one
* copy of the resource will be persisted.
*/
- String ENABLE_RESOURCE_VERSIONING =
"modeShape.preference.filteredFileExtensions"; //$NON-NLS-1$
+ String ENABLE_RESOURCE_VERSIONING =
"modeShape.preference.enableResourceVersioning"; //$NON-NLS-1$
/**
- * A preference for a list of file extensions that will not be part of publishing
operations.
+ * A preference for a list of ignored resource patterns. Files or folders whose
name matches on of the patterns will not be
+ * part of publishing operations.
*/
- String FILTERED_FILE_EXTENSIONS_PREFERENCE =
"modeShape.preference.filteredFileExtensions"; //$NON-NLS-1$
+ String IGNORED_RESOURCES_PREFERENCE =
"modeShape.preference.ignoredResources"; //$NON-NLS-1$
/**
- * A preference for a list of folder names whose contents will not be part of
publishing operations.
+ * The ignored resources preference page ID.
*/
- String FILTERED_FOLDER_NAMES_PREFERENCE =
"modeShape.preference.filteredFolderNames"; //$NON-NLS-1$
-
- /**
- * The file and folder preference page ID.
- */
- String FILTERS_PREFERENCE_PAGE_ID =
"modeShapeFileFiltersPreferencePage"; //$NON-NLS-1$
+ String IGNORED_RESOURCES_PREFERENCE_PAGE_ID =
"modeShapeIgnoredResourcesPreferencePage"; //$NON-NLS-1$
/**
* The main ModeShape preference page ID.
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -38,19 +38,15 @@
public static I18n errorRestoringServerRegistry;
public static I18n errorSavingServerRegistry;
- public static I18n fileFiltersPreferencePageDescription;
- public static I18n fileFiltersPreferencePageFilteredFileExtensionsLabel;
- public static I18n fileFiltersPreferencePageFilteredFolderNamesLabel;
- public static I18n fileFiltersPreferencePageMessage;
- public static I18n fileFiltersPreferencePageTitle;
+ public static I18n ignoredResourcesPreferencePageDescription;
+ public static I18n ignoredResourcesPreferencePageLabel;
+ public static I18n ignoredResourcesPreferencePageMessage;
+ public static I18n ignoredResourcesPreferencePageTitle;
public static I18n missingImage;
- public static I18n newFilteredFileExtensionDialogLabel;
- public static I18n newFilteredFileExtensionDialogTitle;
-
- public static I18n newFilteredFolderNameDialogLabel;
- public static I18n newFilteredFolderNameDialogTitle;
+ public static I18n newIgnoredResourceDialogLabel;
+ public static I18n newIgnoredResourceDialogTitle;
public static I18n newItemDialogValueExists;
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2011-04-15
16:44:43 UTC (rev 30595)
@@ -30,19 +30,15 @@
errorRestoringServerRegistry = Error trying to restore the server registry from file
"{0}"
errorSavingServerRegistry = Error trying to save the server registry to "{0}"
-fileFiltersPreferencePageDescription = Add or remove file extensions and folder names.
Files with a matching file extension or files that are contained in a folder with a
matching name will NOT be published to or unpublished from repositories.
-fileFiltersPreferencePageFilteredFileExtensionsLabel = Filtered File Extensions:
-fileFiltersPreferencePageFilteredFolderNamesLabel = Filtered Folder Names:
-fileFiltersPreferencePageMessage = File Filters
-fileFiltersPreferencePageTitle = File Filters
+ignoredResourcesPreferencePageDescription = Use this page to specify a list of file and
folder name patterns to exclude from publishing operations. \n\nIgnore Patterns:
+ignoredResourcesPreferencePageLabel = Ignore Patterns:
+ignoredResourcesPreferencePageMessage = Ignored Resources
+ignoredResourcesPreferencePageTitle = Ignored Resources
missingImage = The following image cannot be found "{0}"
-newFilteredFileExtensionDialogLabel = File extension:
-newFilteredFileExtensionDialogTitle = New Filtered File Extension
-
-newFilteredFolderNameDialogLabel = Folder name:
-newFilteredFolderNameDialogTitle = New Filtered Folder Name
+newIgnoredResourceDialogLabel = Enter a file name or folder name (* = any string, ? = and
character):
+newIgnoredResourceDialogTitle = New Ignore Pattern
newItemDialogValueExists = Value already exists
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/Utils.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -12,11 +12,9 @@
package org.jboss.tools.modeshape.rest;
import static org.jboss.tools.modeshape.rest.IUiConstants.PLUGIN_ID;
+
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
@@ -27,28 +25,7 @@
public final class Utils {
- //
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
/**
- * @param tokens the tokens being combined into one value (never
<code>null</code>)
- * @param delimiter the character inserted to separate each token
- * @return the tokens separated by the delimiter
- */
- public static String combineTokens( String[] tokens,
- char delimiter ) {
- CheckArg.isNotNull(tokens, "tokens");
- StringBuilder value = new StringBuilder();
-
- for (String token : tokens) {
- value.append(token).append(delimiter);
- }
-
- return value.toString();
- }
-
- /**
* Converts the non-Eclipse status severity to an Eclipse severity level. An {@link
Status.Severity#UNKNOWN unknown status} is
* converted to {@link IStatus#CANCEL cancel}.
*
@@ -84,7 +61,7 @@
* @return the Eclipse status object (never <code>null</code>)
*/
public static IStatus convert( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
return new org.eclipse.core.runtime.Status(convertSeverity(status.getSeverity()),
PLUGIN_ID, status.getMessage(),
status.getException());
}
@@ -96,7 +73,7 @@
* @return the image or <code>null</code> if no associated image for the
status severity
*/
public static Image getImage( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
String imageId = null;
if (status.isError()) {
@@ -115,38 +92,13 @@
}
/**
- * @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>)
- */
- public static String[] getTokens( String string,
- String delimiters,
- boolean removeDuplicates ) {
- CheckArg.isNotNull(delimiters, "delimiters");
-
- 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>)
* @return the image descriptor or <code>null</code> if none found for
the status severity
*/
public static ImageDescriptor getOverlayImage( Status status ) {
- CheckArg.isNotNull(status, "status");
+ CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
String imageId = null;
if (status.isError()) {
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,16 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse jobs package defines the Eclipse jobs that are
needed to publish, unpublish, and manage
+ * the server registry.
+ */
+package org.jboss.tools.modeshape.rest.jobs;
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FileFiltersPreferencePage.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -1,180 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
-import static
org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PREFERENCE_PAGE_HELP_CONTEXT;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageDescription;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageMessage;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageTitle;
-
-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.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.jboss.tools.modeshape.rest.Activator;
-
-/**
- * The <code>FileFiltersPreferencePage</code> is the UI for managing all file
extension and folder name filter preferences.
- */
-public final class FileFiltersPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
-
- /**
- * The editor used to manage the list of filtered file extensions.
- */
- private FilteredFileExtensionEditor extensionsEditor;
-
- /**
- * The editor used to manage the list of filtered folder names.
- */
- private FilteredFoldersEditor foldersEditor;
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- @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 filtered extensions editor
- this.extensionsEditor = new FilteredFileExtensionEditor(panel);
- this.extensionsEditor.setPreferenceStore(getPreferenceStore());
- this.extensionsEditor.getListControl(panel).setLayoutData(new GridData(SWT.FILL,
SWT.FILL, true, true));
-
- // populate the extensions editor
- this.extensionsEditor.load();
-
- // create the filtered folders editor
- this.foldersEditor = new FilteredFoldersEditor(panel);
- this.foldersEditor.setPreferenceStore(getPreferenceStore());
- this.foldersEditor.getListControl(panel).setLayoutData(new GridData(SWT.FILL,
SWT.FILL, true, true));
-
- // populate the folders editor
- this.foldersEditor.load();
-
- // register with the help system
- IWorkbenchHelpSystem helpSystem =
Activator.getDefault().getWorkbench().getHelpSystem();
- helpSystem.setHelp(panel, PREFERENCE_PAGE_HELP_CONTEXT);
-
- return panel;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
- */
- @Override
- public String getDescription() {
- return fileFiltersPreferencePageDescription.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getImage()
- */
- @Override
- public Image getImage() {
- return Activator.getDefault().getImage(ModeShape_IMAGE_16x);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
- */
- @Override
- public String getMessage() {
- return fileFiltersPreferencePageMessage.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
- */
- @Override
- public IPreferenceStore getPreferenceStore() {
- return PrefUtils.getPreferenceStore();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
- */
- @Override
- public String getTitle() {
- return fileFiltersPreferencePageTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- @Override
- public void init( IWorkbench workbench ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- @Override
- protected void performDefaults() {
- this.extensionsEditor.loadDefault();
- this.foldersEditor.loadDefault();
- super.performDefaults();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
- @Override
- public boolean performOk() {
- this.extensionsEditor.store();
- this.foldersEditor.store();
- return super.performOk();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
- */
- @Override
- public void setVisible( boolean visible ) {
- super.setVisible(visible);
-
- if (visible) {
- this.extensionsEditor.setFocus();
- }
- }
-
-}
Deleted:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFileExtensionEditor.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -1,97 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FILE_EXTENSIONS_PREFERENCE;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageFilteredFileExtensionsLabel;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFileExtensionDialogLabel;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFileExtensionDialogTitle;
-
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.modeshape.rest.Utils;
-
-/**
- * The <code>FilteredFileExtensionEditor</code> is an editor for managing a
set of filtered file extensions.
- */
-public final class FilteredFileExtensionEditor extends SortedListEditor implements
VerifyListener {
-
- /**
- * The filter that removes resources, with specific file extensions, from publishing
operations (never <code>null</code>).
- */
- private final PublishingFileFilter filter;
-
- /**
- * @param parent the parent control
- */
- public FilteredFileExtensionEditor( Composite parent ) {
- super(FILTERED_FILE_EXTENSIONS_PREFERENCE,
fileFiltersPreferencePageFilteredFileExtensionsLabel.text(), parent);
- this.filter = new PublishingFileFilter();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
- */
- @Override
- protected String createList( String[] items ) {
- return Utils.combineTokens(items, this.filter.getFileExtensionDelimiter());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogLabel()
- */
- @Override
- protected String getNewItemDialogLabel() {
- return newFilteredFileExtensionDialogLabel.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogTitle()
- */
- @Override
- protected String getNewItemDialogTitle() {
- return newFilteredFileExtensionDialogTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
- */
- @Override
- protected String[] parseString( String stringList ) {
- return Utils.getTokens(stringList,
Character.toString(this.filter.getFileExtensionDelimiter()), true);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
- */
- @Override
- public void verifyText( VerifyEvent event ) {
- for (char c : this.filter.getFileExtensionInvalidCharacters().toCharArray()) {
- if (c == event.character) {
- event.doit = false;
- break;
- }
- }
- }
-
-}
Deleted:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/FilteredFoldersEditor.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -1,97 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FOLDER_NAMES_PREFERENCE;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.fileFiltersPreferencePageFilteredFolderNamesLabel;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFolderNameDialogLabel;
-import static
org.jboss.tools.modeshape.rest.RestClientI18n.newFilteredFolderNameDialogTitle;
-
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.modeshape.rest.Utils;
-
-/**
- * The <code>FilteredFoldersEditor</code> is an editor for managing a set of
folder names.
- */
-public final class FilteredFoldersEditor extends SortedListEditor implements
VerifyListener {
-
- /**
- * The filter that removes resources, contained in specific folders, from publishing
operations (never <code>null</code>).
- */
- private final PublishingFileFilter filter;
-
- /**
- * @param parent the parent control
- */
- public FilteredFoldersEditor( Composite parent ) {
- super(FILTERED_FOLDER_NAMES_PREFERENCE,
fileFiltersPreferencePageFilteredFolderNamesLabel.text(), parent);
- this.filter = new PublishingFileFilter();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
- */
- @Override
- protected String createList( String[] items ) {
- return Utils.combineTokens(items, this.filter.getFolderNameDelimiter());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogLabel()
- */
- @Override
- protected String getNewItemDialogLabel() {
- return newFilteredFolderNameDialogLabel.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.rest.preferences.SortedListEditor#getNewItemDialogTitle()
- */
- @Override
- protected String getNewItemDialogTitle() {
- return newFilteredFolderNameDialogTitle.text();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
- */
- @Override
- protected String[] parseString( String stringList ) {
- return Utils.getTokens(stringList,
Character.toString(this.filter.getFolderNameDelimiter()), true);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
- */
- @Override
- public void verifyText( VerifyEvent event ) {
- for (char c : this.filter.getFolderNameInvalidCharacters().toCharArray()) {
- if (c == event.character) {
- event.doit = false;
- break;
- }
- }
- }
-
-}
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,539 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.IGNORED_RESOURCES_PREFERENCE;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageLabel;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.newIgnoredResourceDialogLabel;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.newIgnoredResourceDialogTitle;
+
+import java.util.Collection;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Rectangle;
+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.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.jboss.tools.modeshape.rest.Activator;
+import org.jboss.tools.modeshape.rest.RestClientI18n;
+
+/**
+ * The <code>IgnoredResourcesEditor</code> is an editor for managing a set of
ignored resources.
+ */
+public final class IgnoredResourcesEditor extends FieldEditor {
+
+ private Button btnAdd;
+
+ private Button btnRemove;
+
+ /**
+ * The data model (never <code>null</code>).
+ */
+ private IgnoredResourcesModel model;
+
+ private TableViewer viewer;
+
+ /**
+ * @param parent the parent control
+ */
+ public IgnoredResourcesEditor( Composite parent ) {
+ super(IGNORED_RESOURCES_PREFERENCE, ignoredResourcesPreferencePageLabel.text(),
parent);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+ */
+ @Override
+ protected void adjustForNumColumns( int numColumns ) {
+ Control control = getLabelControl();
+ ((GridData)control.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)this.viewer.getControl().getLayoutData()).horizontalSpan = numColumns
- 1;
+ }
+
+ /**
+ * Creates a push button.
+ *
+ * @param parent the parent control
+ * @param key the resource name used to supply the button's label text
+ * @return the button (never <code>null</code>)
+ */
+ private Button createPushButton( Composite parent,
+ String key ) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(JFaceResources.getString(key));
+ button.setFont(parent.getFont());
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ int widthHint = convertHorizontalDLUsToPixels(button,
IDialogConstants.BUTTON_WIDTH);
+ data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
true).x);
+ button.setLayoutData(data);
+ return button;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite,
int)
+ */
+ @Override
+ protected void doFillIntoGrid( Composite parent,
+ int numColumns ) {
+ // create table
+ this.viewer = new TableViewer(parent, (SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL |
SWT.FULL_SELECTION | SWT.BORDER));
+
+ this.viewer.setContentProvider(new IStructuredContentProvider() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return getPatterns().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( Viewer viewer,
+ Object oldInput,
+ Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // sort the table rows by resource name pattern
+ this.viewer.setComparator(new ViewerComparator() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public int compare( Viewer viewer,
+ Object e1,
+ Object e2 ) {
+ ResourcePattern pattern1 = (ResourcePattern)e1;
+ ResourcePattern pattern2 = (ResourcePattern)e2;
+
+ return pattern1.getPattern().compareTo(pattern2.getPattern());
+ }
+ });
+
+ this.viewer.setLabelProvider(new LabelProvider() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( Object element ) {
+ return ((ResourcePattern)element).getPattern();
+ }
+ });
+
+ Table table = this.viewer.getTable();
+ table.setLayout(new TableLayout());
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ table.addListener(SWT.Selection, new Listener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent( Event event ) {
+ if (event.detail == SWT.CHECK) {
+ handlePatternChecked((TableItem)event.item);
+ } else {
+ handlePatternSelected();
+ }
+ }
+ });
+
+ // create buttons
+ Composite pnlButtons = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ pnlButtons.setLayout(layout);
+ pnlButtons.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ this.btnAdd = createPushButton(pnlButtons,
"ListEditor.add");//$NON-NLS-1$
+ this.btnAdd.addSelectionListener(new SelectionAdapter() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleAddPressed();
+ }
+ });
+
+ this.btnRemove = createPushButton(pnlButtons,
"ListEditor.remove");//$NON-NLS-1$
+ this.btnRemove.setEnabled(false);
+ this.btnRemove.addSelectionListener(new SelectionAdapter() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleRemovePressed();
+ }
+ });
+
+ this.model = new IgnoredResourcesModel(); // model must be created before
setInput is called
+ this.viewer.setInput(this); // doesn't matter what you pass in
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+ */
+ @Override
+ protected void doLoad() {
+ // load model from current preference value and refresh UI
+ String prefValue = getPreferenceStore().getString(getPreferenceName());
+ this.model.load(prefValue);
+ refreshUi();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+ */
+ @Override
+ protected void doLoadDefault() {
+ // load model from default preference value and refresh UI
+ String prefValue = getPreferenceStore().getDefaultString(getPreferenceName());
+ this.model.load(prefValue);
+ refreshUi();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#doStore()
+ */
+ @Override
+ protected void doStore() {
+ getPreferenceStore().setValue(getPreferenceName(), this.model.createList());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ Collection<ResourcePattern> getPatterns() {
+ return this.model.getPatterns();
+ }
+
+ /**
+ * Handler for when add button is pressed.
+ */
+ void handleAddPressed() {
+ // display dialog to get new pattern from user
+ NewPatternDialog dialog = new NewPatternDialog(this.btnAdd.getShell(),
getPatterns());
+
+ if (dialog.open() == Window.OK) {
+ // update model and UI
+ this.model.addPattern(new ResourcePattern(dialog.getNewPattern(), true));
+ refreshUi();
+ }
+ }
+
+ /**
+ * @param item the item whose checked state has been changed (may not be
<code>null</code>)
+ */
+ void handlePatternChecked( TableItem item ) {
+ ResourcePattern pattern = (ResourcePattern)item.getData();
+ pattern.setEnabled(item.getChecked());
+ }
+
+ /**
+ * Handler for when pattern is selected.
+ */
+ void handlePatternSelected() {
+ IStructuredSelection selection =
(IStructuredSelection)this.viewer.getSelection();
+ boolean enable = !selection.isEmpty();
+
+ if (this.btnRemove.getEnabled() != enable) {
+ this.btnRemove.setEnabled(enable);
+ }
+ }
+
+ /**
+ * Handler for when the remove button is pressed.
+ */
+ void handleRemovePressed() {
+ assert (!this.viewer.getSelection().isEmpty());
+ Object pattern =
((IStructuredSelection)this.viewer.getSelection()).getFirstElement();
+ this.model.removePattern((ResourcePattern)pattern);
+ refreshUi();
+ }
+
+ /**
+ * Updates the check state of each table item to reflect the appropriate value in the
model.
+ */
+ private void initializeCheckBoxStates() {
+ for (TableItem item : this.viewer.getTable().getItems()) {
+ ResourcePattern pattern = (ResourcePattern)item.getData();
+
+ if (pattern.isEnabled()) {
+ item.setChecked(true);
+ }
+ }
+ }
+
+ /**
+ * Refreshes the viewer.
+ */
+ private void refreshUi() {
+ this.viewer.refresh();
+ initializeCheckBoxStates();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.FieldEditor#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ this.viewer.getControl().setFocus();
+ }
+
+ /**
+ * A <code>NewPatternDialog</code> allows the user to enter a pattern.
+ */
+ class NewPatternDialog extends Dialog implements ModifyListener {
+
+ /**
+ * The existing ignored resource patterns.
+ */
+ private final Collection<ResourcePattern> existingPatterns;
+
+ /**
+ * A message for the user.
+ */
+ private CLabel lblMessage;
+
+ /**
+ * The contents of the new pattern text field.
+ */
+ private String newPattern;
+
+ /**
+ * @param parentShell the parent shell (can be <code>null</code>)
+ * @param existingPatterns the existing patterns (can be
<code>null</code> or empty)
+ */
+ public NewPatternDialog( Shell parentShell,
+ Collection<ResourcePattern> existingPatterns ) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.existingPatterns = existingPatterns;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( Shell newShell ) {
+ newShell.setText(newIgnoredResourceDialogTitle.text());
+ super.configureShell(newShell);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int,
java.lang.String, boolean)
+ */
+ @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)
+ */
+ @Override
+ protected Control createDialogArea( Composite parent ) {
+ Composite panel = (Composite)super.createDialogArea(parent);
+ Composite pnlEditor = new Composite(panel, SWT.NONE);
+ pnlEditor.setLayout(new GridLayout());
+ pnlEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label label = new Label(pnlEditor, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false));
+ label.setText(newIgnoredResourceDialogLabel.text());
+
+ Text textField = new Text(pnlEditor, SWT.BORDER);
+ textField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ textField.addModifyListener(this);
+ textField.addVerifyListener(new VerifyListener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
+ */
+ @Override
+ public void verifyText( VerifyEvent e ) {
+ // don't allow slashes as input
+ if (e.text.contains("\\") ||
e.text.contains("/")) { //$NON-NLS-1$ //$NON-NLS-2$
+ e.doit = false;
+ }
+ }
+ });
+
+ // add image and message labels
+ this.lblMessage = new CLabel(pnlEditor, SWT.NONE);
+ this.lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true,
false));
+ ((GridData)this.lblMessage.getLayoutData()).horizontalSpan = 2;
+
+ return panel;
+ }
+
+ /**
+ * @return the new pattern name or <code>null</code> if the dialog
was canceled
+ */
+ public String getNewPattern() {
+ if (getReturnCode() == OK) {
+ return this.newPattern;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+
+ // resize shell to be twice the width needed for the title (without this the
title maybe cropped)
+ int width = (4 *
convertWidthInCharsToPixels(newIgnoredResourceDialogTitle.text().length()));
+ Rectangle rectangle = getShell().getBounds();
+ getShell().setBounds(rectangle.x, rectangle.y, width, rectangle.height);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( ModifyEvent event ) {
+ // clear message
+ this.lblMessage.setImage(null);
+ this.lblMessage.setText(""); //$NON-NLS-1$
+
+ // enable/disable OK button
+ this.newPattern = ((Text)event.widget).getText();
+
+ // make sure at least one character entered
+ boolean enable = (this.newPattern.length() != 0);
+
+ // make sure value is not a disallowed value
+ if (enable && (this.existingPatterns != null)) {
+ for (ResourcePattern pattern : this.existingPatterns) {
+ if (this.newPattern.equals(pattern.getPattern())) {
+ enable = false;
+
this.lblMessage.setImage(Activator.getDefault().getSharedImage(ISharedImages.IMG_OBJS_INFO_TSK));
+
this.lblMessage.setText(RestClientI18n.newItemDialogValueExists.text());
+ break;
+ }
+ }
+ }
+
+ // set enabled state if different than current state
+ if (getButton(OK).getEnabled() != enable) {
+ getButton(OK).setEnabled(enable);
+ }
+ }
+
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.modeshape.common.util.CheckArg;
+
+/**
+ * The <code>IgnoredResourcesModel</code> class is used to keep track of
ignored resources patterns used for resources publishing
+ * operations.
+ */
+public final class IgnoredResourcesModel {
+
+ /**
+ * Delimiter used when creating a single string representative of all patterns. Also
used when parsing.
+ *
+ * @see #createList()
+ * @see #load(String)
+ */
+ private final static char DELIMITER = '\n';
+
+ /**
+ * Combines the ignored resource patterns into a single string. This method is the
converse of <code>load</code>.
+ *
+ * @param patterns the patterns that will be combined into a string representation
(never <code>null</code>)
+ * @return the string representation of the specified patterns (never
<code>null</code> but can be empty)
+ */
+ public static String createList( ResourcePattern... patterns ) {
+ StringBuilder value = new StringBuilder();
+
+ for (ResourcePattern pattern : patterns) {
+
value.append(pattern.getPattern()).append(DELIMITER).append(pattern.isEnabled()).append(DELIMITER);
+ }
+
+ return value.toString();
+ }
+
+ /**
+ * @param stringList a string representation of zero or more patterns (may be
<code>null</code> or empty)
+ * @return the patterns parsed from the string (never <code>null</code>
but can be empty)
+ */
+ public ResourcePattern[] parseList( String stringList ) {
+ if ((stringList != null) && !stringList.equals("")) {
//$NON-NLS-1$
+ StringTokenizer st = new StringTokenizer(stringList,
Character.toString(DELIMITER));
+ ResourcePattern[] patterns = new ResourcePattern[(st.countTokens() > 0) ?
(st.countTokens() / 2) : 0];
+ int i = 0;
+
+ while (st.hasMoreTokens()) {
+ String pattern = st.nextToken();
+ boolean enabled = Boolean.parseBoolean(st.nextToken());
+ patterns[i++] = new ResourcePattern(pattern, enabled);
+ }
+
+ return patterns;
+ }
+
+ return new ResourcePattern[0];
+ }
+
+ /**
+ * The patterns included in this model (never <code>null</code>).
+ */
+ private final Set<ResourcePattern> patterns = new
HashSet<ResourcePattern>();
+
+ /**
+ * Adds the specified pattern if one with that same pattern does not already exist.
+ *
+ * @param pattern the pattern being added (may not be <code>null</code>)
+ */
+ public void addPattern( ResourcePattern pattern ) {
+ CheckArg.isNotNull(pattern, "pattern"); //$NON-NLS-1$
+ this.patterns.add(pattern);
+ }
+
+ /**
+ * Combines the ignored resource patterns into a single string. This method is the
converse of <code>load</code>.
+ *
+ * @return the combined string (never <code>null</code> but can be
empty)
+ * @see #load(String)
+ */
+ public String createList() {
+ return createList(this.patterns.toArray(new
ResourcePattern[this.patterns.size()]));
+ }
+
+ /**
+ * @return an unmodifiable collection of patterns contained in this model (never
<code>null</code>)
+ */
+ public Collection<ResourcePattern> getPatterns() {
+ return Collections.unmodifiableCollection(this.patterns);
+ }
+
+ /**
+ * Clears the current patterns and loads new patterns by parsing the specified
string.
+ *
+ * @param stringList a string representation of zero or more patterns (may be
<code>null</code> or empty)
+ */
+ public void load( String stringList ) {
+ this.patterns.clear();
+
+ // parse list into new patterns
+ ResourcePattern[] temp = parseList(stringList);
+
+ if (temp.length != 0) {
+ this.patterns.addAll(Arrays.asList(temp));
+ }
+ }
+
+ /**
+ * @param pattern the pattern being removed if it exists in the model (may not be
<code>null</code>)
+ */
+ public void removePattern( ResourcePattern pattern ) {
+ CheckArg.isNotNull(pattern, "pattern"); //$NON-NLS-1$
+ this.patterns.remove(pattern);
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,164 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
+import static
org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PREFERENCE_PAGE_HELP_CONTEXT;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageDescription;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageMessage;
+import static
org.jboss.tools.modeshape.rest.RestClientI18n.ignoredResourcesPreferencePageTitle;
+
+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.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.jboss.tools.modeshape.rest.Activator;
+
+/**
+ * The <code>IgnoredResourcesPreferencePage</code> is the UI for managing all
ignored file extension and folder names.
+ */
+public final class IgnoredResourcesPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
+
+ /**
+ * The editor used to manage the list of ignored file extensions and folder names.
+ */
+ private IgnoredResourcesEditor ignoredResourcesEditor;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @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 filtered extensions editor
+ this.ignoredResourcesEditor = new IgnoredResourcesEditor(panel);
+ this.ignoredResourcesEditor.setPreferenceStore(getPreferenceStore());
+
+ // populate the extensions editor
+ this.ignoredResourcesEditor.load();
+
+ // register with the help system
+ IWorkbenchHelpSystem helpSystem =
Activator.getDefault().getWorkbench().getHelpSystem();
+ helpSystem.setHelp(panel, PREFERENCE_PAGE_HELP_CONTEXT);
+
+ return panel;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return ignoredResourcesPreferencePageDescription.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getDefault().getImage(ModeShape_IMAGE_16x);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return ignoredResourcesPreferencePageMessage.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
+ */
+ @Override
+ public String getTitle() {
+ return ignoredResourcesPreferencePageTitle.text();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ @Override
+ public void init( IWorkbench workbench ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ this.ignoredResourcesEditor.loadDefault();
+ super.performDefaults();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ this.ignoredResourcesEditor.store();
+ return super.performOk();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ @Override
+ public void setVisible( boolean visible ) {
+ super.setVisible(visible);
+
+ if (visible) {
+ this.ignoredResourcesEditor.setFocus();
+ }
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ModeShapePreferencePage.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -109,7 +109,7 @@
*/
@Override
public IPreferenceStore getPreferenceStore() {
- return PrefUtils.getPreferenceStore();
+ return Activator.getDefault().getPreferenceStore();
}
/**
Deleted:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PrefUtils.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -1,64 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. 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.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.Utils;
-import org.modeshape.common.util.CheckArg;
-
-/**
- * The <code>PrefUtils</code> class provides common utilities relating to
preferences. This class assumes the Eclipse runtime
- * platform is running.
- */
-public final class PrefUtils {
-
- /**
- * @param propertyId the property name whose list values are being requested (never
<code>null</code>)
- * @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>)
- */
- 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
- */
- 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
- */
- 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));
- }
-
- /**
- * Don't allow construction.
- */
- private PrefUtils() {
- // nothing to do
- }
-}
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilter.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -11,171 +11,58 @@
*/
package org.jboss.tools.modeshape.rest.preferences;
-import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FILE_EXTENSIONS_PREFERENCE;
-import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.FILTERED_FOLDER_NAMES_PREFERENCE;
-import static org.jboss.tools.modeshape.rest.RestClientI18n.preferenceNotFound;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.jboss.tools.modeshape.rest.Activator;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.web.jcr.rest.client.Status;
-import org.modeshape.web.jcr.rest.client.Status.Severity;
/**
- * The <code>PublishingFileFilter</code> is a file filter that uses the
preferences when filtering files.
+ * The <code>PublishingFileFilter</code> is a resource name filter.
*/
public final class PublishingFileFilter {
/**
- * The preference name for the delimiter that separates filtered file extensions when
the preference value is stored.
+ * @param text the text being tested against the pattern (may not be
<code>null</code> or empty)
+ * @param pattern the pattern used (may not be <code>null</code> or
empty)
+ * @return <code>true</code> if the text is matched by the pattern
*/
- private static final String FILE_EXT_DELIMITER_PREF_NAME =
"fileExtension.delimiter"; //$NON-NLS-1$
+ public static boolean matches( String text,
+ String pattern ) {
+ final String regex = pattern.replace("?",
".?").replace("*", ".*?"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+ return text.matches(regex);
+ }
/**
- * The preference name for characters that are <strong>NOT</strong>
allowed to appear in a file extension.
+ * The data model (never <code>null</code>).
*/
- private static final String FILE_EXT_INVALID_CHARS_PREF_NAME =
"fileExtension.invalidChars"; //$NON-NLS-1$
+ private final IgnoredResourcesModel model;
/**
- * The preference name for the delimiter that separates filtered folder names when
the preference value is stored.
+ * @param model the data model (may not be <code>null</code>)
*/
- private static final String FOLDER_NAME_DELIMITER_PREF_NAME =
"folderName.delimiter"; //$NON-NLS-1$
+ public PublishingFileFilter( IgnoredResourcesModel model ) {
+ CheckArg.isNotNull(model, "model"); //$NON-NLS-1$
+ this.model = model;
+ }
/**
- * The preference name for characters that are <strong>NOT</strong>
allowed to appear in a folder name.
- */
- private static final String FOLDER_NAME_INVALID_CHARS_PREF_NAME =
"folderName.invalidChars"; //$NON-NLS-1$
-
- /**
- * @param resource the resource being tested (never <code>null</code>)
+ * @param resource the resource being tested (may not be
<code>null</code>)
* @return <code>true</code> if the resource should be included (i.e., it
is not filtered out)
*/
public boolean accept( IResource resource ) {
CheckArg.isNotNull(resource, "resource"); //$NON-NLS-1$
+ final String name = resource.getName();
- if ((resource instanceof IFolder) || (resource instanceof IProject)) {
- String name = resource.getName();
-
- // see if folder name has been filtered
- for (String filteredName : getFilteredFolderNames()) {
- if (filteredName.equals(name)) {
- return false;
- }
+ for (ResourcePattern pattern : model.getPatterns()) {
+ if (pattern.isEnabled() && matches(name, pattern.getPattern())) {
+ return false;
}
-
- // check parent
- if (resource.getParent() != null) {
- return accept(resource.getParent());
- }
- } else if (resource instanceof IFile) {
- // see if file extension has been filtered
- for (String extension : getFilteredFileExtensions()) {
- if (resource.getFullPath().toString().endsWith('.' + extension))
{
- return false;
- }
- }
-
- // check parent
- if (resource.getParent() != null) {
- return accept(resource.getParent());
- }
}
-
- return true;
- }
-
- /**
- * The delimiter that separates filtered file extensions when the preference value is
stored.
- *
- * @return the file extension separator character
- */
- public char getFileExtensionDelimiter() {
- String value =
PrefUtils.getPreferenceStore().getDefaultString(FILE_EXT_DELIMITER_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value.charAt(0);
+
+ if (resource.getParent() == null) {
+ return true;
}
- // no value found so log and give a default value
- value = ","; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR,
preferenceNotFound.text(FILE_EXT_DELIMITER_PREF_NAME, value), null));
- return value.charAt(0);
+ // check parents
+ return accept(resource.getParent());
}
- /**
- * The characters that are <strong>NOT</strong> allowed to appear in a
file extension.
- *
- * @return the invalid file extension characters (never <code>null</code>
or empty)
- */
- public String getFileExtensionInvalidCharacters() {
- String value =
PrefUtils.getPreferenceStore().getDefaultString(FILE_EXT_INVALID_CHARS_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value;
- }
-
- // no value found so log and give a default value
- value = "*?<>|/\\:;."; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR,
-
preferenceNotFound.text(FILE_EXT_INVALID_CHARS_PREF_NAME, value),
- null));
- return value;
- }
-
- /**
- * @return the file extensions being filtered out of publishing operations (never
<code>null</code> but can be empty)
- */
- public String[] getFilteredFileExtensions() {
- return PrefUtils.getListPropertyValue(FILTERED_FILE_EXTENSIONS_PREFERENCE,
getFileExtensionDelimiter(), true);
- }
-
- /**
- * @return the folder names being filtered out of publishing operations (never
<code>null</code> but can be empty)
- */
- public String[] getFilteredFolderNames() {
- return PrefUtils.getListPropertyValue(FILTERED_FOLDER_NAMES_PREFERENCE,
getFolderNameDelimiter(), true);
- }
-
- /**
- * The delimiter that separates filtered folder names when the preference value is
stored.
- *
- * @return the folder name separator character
- */
- public char getFolderNameDelimiter() {
- String value =
PrefUtils.getPreferenceStore().getDefaultString(FOLDER_NAME_DELIMITER_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value.charAt(0);
- }
-
- // no value found so log and give a default value
- value = ","; //$NON-NLS-1$
- Activator.getDefault()
- .log(new Status(Severity.ERROR,
preferenceNotFound.text(FOLDER_NAME_DELIMITER_PREF_NAME, value), null));
- return value.charAt(0);
- }
-
- /**
- * The characters that are <strong>NOT</strong> allowed to appear in a
folder name (never <code>null</code> but can be empty).
- *
- * @return the invalid folder name characters (never <code>null</code> or
empty)
- */
- public String getFolderNameInvalidCharacters() {
- String value =
PrefUtils.getPreferenceStore().getDefaultString(FOLDER_NAME_INVALID_CHARS_PREF_NAME);
-
- if ((value != null) && (value.length() > 0)) {
- return value;
- }
-
- // no value found so log and give a default value
- value = "*?<>|/\\:;"; //$NON-NLS-1$
- Activator.getDefault().log(new Status(Severity.ERROR,
-
preferenceNotFound.text(FOLDER_NAME_INVALID_CHARS_PREF_NAME, value),
- null));
- return value;
- }
-
}
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import org.modeshape.common.util.CheckArg;
+
+/**
+ * A <code>ResourcePattern</code> is a resource name pattern that is used to
determine if a resource shoiuld be include in
+ * publishing operations. Wildcards (*, ?) are allowed.
+ */
+public final class ResourcePattern {
+
+ /**
+ * The name pattern (may not be <code>null</code>).
+ */
+ private final String pattern;
+
+ /**
+ * Indicates if the patter is enabled. Default is {@value} .
+ */
+ private boolean enabled;
+
+ /**
+ * @param pattern the resource name pattern (may not be <code>null</code>
or empty)
+ * @param enabled <code>true</code> if the pattern should be enabled
+ */
+ public ResourcePattern( String pattern,
+ boolean enabled ) {
+ CheckArg.isNotEmpty(pattern, "pattern"); //$NON-NLS-1$
+ this.pattern = pattern;
+ this.enabled = enabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || !getClass().equals(obj.getClass())) {
+ return false;
+ }
+
+ return this.pattern.equals(((ResourcePattern)obj).pattern);
+ }
+
+ /**
+ * @return the resource name pattern (never <code>null</code>)
+ */
+ public String getPattern() {
+ return this.pattern;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.pattern.hashCode();
+ }
+
+ /**
+ * @return <code>true</code> if pattern is enabled
+ */
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ /**
+ * @param enabled <code>true</code> if pattern should be enabled
+ */
+ public void setEnabled( boolean enabled ) {
+ this.enabled = enabled;
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/ResourcePattern.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/SortedListEditor.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -1,383 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
- *
- * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
- */
-package org.jboss.tools.modeshape.rest.preferences;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.ListEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Rectangle;
-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;
-import org.eclipse.ui.ISharedImages;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.RestClientI18n;
-import org.modeshape.common.util.CheckArg;
-
-/**
- * A preference list string value editor that sorts its entries each time a
- * value is added.
- */
-public abstract class SortedListEditor extends ListEditor {
-
- /**
- * Indicates if duplicate values are allowed.
- */
- private boolean allowDuplicates;
-
- /**
- * The listener verifying input characters.
- */
- private VerifyListener verifyListener;
-
- /**
- * Duplicate items are not allowed.
- *
- * @param name
- * the name of the preference this field editor works on
- * @param labelText
- * the label text of the field editor
- * @param parent
- * the parent of the field editor's control
- */
- public SortedListEditor(String name, String labelText, Composite parent) {
- super(name, labelText, parent);
- }
-
- private void disableUpDownButtons() {
- // disable up button
- Button button = getUpButton();
-
- if (button.getEnabled()) {
- button.setEnabled(false);
- }
-
- // disable down button
- button = getDownButton();
-
- if (button.getEnabled()) {
- button.setEnabled(false);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.preference.ListEditor#getButtonBoxControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public Composite getButtonBoxControl(Composite parent) {
- Composite buttonBox = super.getButtonBoxControl(parent);
- getUpButton().setVisible(false);
- getDownButton().setVisible(false);
- disableUpDownButtons();
- return buttonBox;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#getNewInputObject()
- */
- @Override
- protected final String getNewInputObject() {
- NewItemDialog dialog = new NewItemDialog(getShell(), getNewItemDialogTitle(),
getNewItemDialogLabel(),
- this.verifyListener);
- if (!this.allowDuplicates) {
- dialog.setDisallowedValues(getList().getItems());
- }
-
- if (dialog.open() == Window.OK) {
- String newItem = dialog.getNewItem();
-
- // add new item, sort, and update list
- if (newItem != null) {
- getList().add(newItem);
- String[] items = getList().getItems();
- Arrays.sort(items);
- getList().setItems(items);
- }
- }
-
- // always return null because we have already updated the list
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#selectionChanged()
- */
- @Override
- protected void selectionChanged() {
- super.selectionChanged();
- disableUpDownButtons();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#setEnabled(boolean,
- * org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void setEnabled(boolean enabled, Composite parent) {
- super.setEnabled(enabled, parent);
- disableUpDownButtons();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.preference.ListEditor#setFocus()
- */
- @Override
- public void setFocus() {
- if ((getList() == null) || getList().getItemCount() == 0) {
- getAddButton().setFocus();
- } else {
- super.setFocus();
- }
- }
-
- /**
- * @return the localized dialog title used when a new item is added (may not
- * be <code>null</code>)
- */
- protected abstract String getNewItemDialogTitle();
-
- /**
- * @return the localized label on the new item dialog that identifies the
- * type of the new item (may not be <code>null</code>)
- */
- protected abstract String getNewItemDialogLabel();
-
- /**
- * @param verifyListener
- * a listener that verifies input from the user of a new item
- * entry (can be <code>null</code>)
- */
- protected void setVerifyListener(VerifyListener verifyListener) {
- this.verifyListener = verifyListener;
- }
-
- /**
- * A <code>NewItemDialog</code> allows the user to enter a text value.
- * Caller can optionally furnish a list of disallowed values.
- */
- class NewItemDialog extends Dialog implements ModifyListener {
-
- /**
- * The label describing the new item.
- */
- private final String label;
-
- /**
- * A list of disallowed values. If <code>null</code> any non-empty value
- * is allowed.
- */
- private String[] disallowedValues;
-
- /**
- * A message for the user.
- */
- private CLabel lblMessage;
-
- /**
- * The contents of the new item text field.
- */
- private String newItem;
-
- /**
- * The dialog title.
- */
- private final String title;
-
- /**
- * The listener verifying input characters.
- */
- private final VerifyListener verifyListener;
-
- /**
- * @param parentShell
- * the parent shell (may be <code>null</code>)
- * @param title
- * the localized dialog title (never <code>null</code>)
- * @param label
- * the localized label (never <code>null</code>)
- * @param verifyListener
- * a listener that validates input characters (may be
- * <code>null</code>)
- */
- public NewItemDialog(Shell parentShell, String title, String label, VerifyListener
verifyListener) {
- super(parentShell);
-
- CheckArg.isNotNull(title, "title"); //$NON-NLS-1$
- CheckArg.isNotNull(label, "label"); //$NON-NLS-1$
-
- this.title = title;
- this.label = label;
- this.verifyListener = verifyListener;
-
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- newShell.setText(this.title);
- super.configureShell(newShell);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite,
- * int, java.lang.String, boolean)
- */
- @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)
- */
- @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.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false));
- label.setText(this.label);
-
- Text textField = new Text(pnlEditor, SWT.BORDER);
- textField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- textField.addModifyListener(this);
-
- // add listener if necessary
- if (this.verifyListener != null) {
- textField.addVerifyListener(this.verifyListener);
- }
-
- // add image and message labels
- this.lblMessage = new CLabel(pnlEditor, SWT.NONE);
- this.lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- ((GridData) this.lblMessage.getLayoutData()).horizontalSpan = 2;
-
- return panel;
- }
-
- /**
- * @return the new item or <code>null</code> if the dialog was canceled
- */
- public String getNewItem() {
- if (getReturnCode() == OK) {
- return this.newItem;
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
- */
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
-
- // resize shell to be twice the width needed for the title (without
- // this the title maybe cropped)
- int width = (2 * convertWidthInCharsToPixels(this.title.length()));
- Rectangle rectangle = getShell().getBounds();
- getShell().setBounds(rectangle.x, rectangle.y, width, rectangle.height);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- @Override
- public void modifyText(ModifyEvent event) {
- // clear message
- this.lblMessage.setImage(null);
- this.lblMessage.setText(""); //$NON-NLS-1$
-
- // enable/disable OK button
- this.newItem = ((Text) event.widget).getText();
-
- // make sure at least one character entered
- boolean enable = (this.newItem.length() != 0);
-
- // make sure value is not a disallowed value
- if (enable && (this.disallowedValues != null)) {
- for (String disallowedValue : this.disallowedValues) {
- if (this.newItem.equals(disallowedValue)) {
- enable = false;
- this.lblMessage
-
.setImage(Activator.getDefault().getSharedImage(ISharedImages.IMG_OBJS_INFO_TSK));
- this.lblMessage.setText(RestClientI18n.newItemDialogValueExists.text());
- break;
- }
- }
- }
-
- // set enabled state if different than current state
- if (getButton(OK).getEnabled() != enable) {
- getButton(OK).setEnabled(enable);
- }
- }
-
- /**
- * A list of values that are not allowed as an input.
- *
- * @param disallowedValues
- * the list of values which are not allowed (can be
- * <code>null</code> or empty)
- */
- public void setDisallowedValues(String[] disallowedValues) {
- if ((disallowedValues == null) || (disallowedValues.length == 0)) {
- this.disallowedValues = null;
- } else {
- this.disallowedValues = disallowedValues;
- }
- }
-
- }
-}
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,15 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. 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.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse preferences package is responsible for managing
preferences.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
\ No newline at end of file
Property changes on:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/preferences/prefs.properties 2011-04-15
16:44:43 UTC (rev 30595)
@@ -10,14 +10,10 @@
# individual contributors.
#
-# This properties file is read in by PreferenceInitializer and contains preference
default values. The delimiter values are used
-# when the preference values are stored and the valid character values are used by the
field editors when they validate user input.
+# This properties file is read in by PreferenceInitializer and contains preference
default values.
-fileExtension.delimiter = ,
-fileExtension.invalidChars = *?<>|/\:;.
-
-folderName.delimiter = ,
-folderName.invalidChars = *?<>|/\:;
-
# indicates if ModeShape server should version resources
-enableVersioning = false
\ No newline at end of file
+modeShape.preference.enableResourceVersioning = true
+
+# default ignored resources patterns
+modeShape.preference.ignoredResources = .svn\ntrue\n.project\ntrue\n
\ No newline at end of file
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -13,6 +13,7 @@
import static
org.jboss.tools.modeshape.rest.IUiConstants.HelpContexts.PUBLISH_DIALOG_HELP_CONTEXT;
import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.ENABLE_RESOURCE_VERSIONING;
+import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.IGNORED_RESOURCES_PREFERENCE;
import static
org.jboss.tools.modeshape.rest.IUiConstants.Preferences.MAIN_PREFERENCE_PAGE_ID;
import java.util.ArrayList;
@@ -56,6 +57,7 @@
import org.jboss.tools.modeshape.rest.WorkspaceArea;
import org.jboss.tools.modeshape.rest.actions.NewServerAction;
import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
+import org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesModel;
import org.jboss.tools.modeshape.rest.preferences.PublishingFileFilter;
import org.modeshape.common.util.CheckArg;
import org.modeshape.web.jcr.rest.client.Status;
@@ -404,8 +406,10 @@
this.type = type;
this.resources = resources;
- // filter should not be cached as preferences may change
- this.filter = (filterFiles ? new PublishingFileFilter() : null);
+ // load filter with current preference value
+ IgnoredResourcesModel model = new IgnoredResourcesModel();
+
model.load(Activator.getDefault().getPreferenceStore().getString(IGNORED_RESOURCES_PREFERENCE));
+ this.filter = (filterFiles ? new PublishingFileFilter(model) : null);
}
private void constructLocationPanel(Composite parent) {
Added:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class IgnoredResourcesModelTest {
+
+ private final static int NUM_PATTERNS = 10;
+
+ private final static ResourcePattern[] ENABLED_PATTERNS = new
ResourcePattern[NUM_PATTERNS];
+
+ private final static ResourcePattern[] DISABLED_PATTERNS = new
ResourcePattern[NUM_PATTERNS];
+
+ static {
+ for (int i = 0; i < NUM_PATTERNS; ++i) {
+ ENABLED_PATTERNS[i] = new ResourcePattern(i + "*.class", true);
//$NON-NLS-1$
+ DISABLED_PATTERNS[i] = new ResourcePattern(i + "*.class", false);
//$NON-NLS-1$
+ }
+ }
+
+ private IgnoredResourcesModel model;
+
+ @Before
+ public void beforeEach() {
+ this.model = new IgnoredResourcesModel();
+ }
+
+ @Test
+ public void shouldClearPatternsWhenLoading() {
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS));
+ this.model.load(IgnoredResourcesModel.createList(ENABLED_PATTERNS));
+ assertThat(this.model.getPatterns().size(), is(NUM_PATTERNS));
+ }
+
+ @Test
+ public void shouldHaveNoPatternsAfterConstruction() {
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldLoadEmptyString() {
+ this.model.load(""); //$NON-NLS-1$
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldLoadNullString() {
+ this.model.load(null);
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldNotLoadSamePatternTwice() {
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS[0]));
+ this.model.load(IgnoredResourcesModel.createList(DISABLED_PATTERNS[0]));
+ assertThat(this.model.getPatterns().size(), is(1));
+
+ this.model.load(IgnoredResourcesModel.createList(ENABLED_PATTERNS[0]));
+ assertThat(this.model.getPatterns().size(), is(1));
+ }
+
+ @Test
+ public void shouldAddNewPattern() {
+ final ResourcePattern rp = DISABLED_PATTERNS[0];
+ this.model.addPattern(rp);
+ assertThat(this.model.getPatterns().size(), is(1));
+ assertThat(this.model.getPatterns().iterator().next(), sameInstance(rp));
+ }
+
+ @Test
+ public void shouldRemovePattern() {
+ final ResourcePattern rp = DISABLED_PATTERNS[0];
+ this.model.addPattern(rp);
+ this.model.removePattern(rp);
+ assertThat(this.model.getPatterns().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldAllowRemoveOfPatternNotInModel() {
+ this.model.removePattern(DISABLED_PATTERNS[0]);
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/IgnoredResourcesModelTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class PublishingFileFilterTest {
+
+ private static final String PARTS_PROJECT = "PartsProject"; //$NON-NLS-1$
+
+ @Test
+ public void shouldMatchPartsProject() {
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "PartsProject"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Parts*"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*Parts*"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "?arts*"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Part?*"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Part?*t"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*Project"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "P*r*s*r*j*c*"),
is(true)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "?a?t?P?o?e?t"),
is(true)); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldNotMatchPartsProject() {
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "
PartsProject"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "PartsProject
"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT,
"PartsProject2"), is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "artsProject2"),
is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "Parts?"),
is(false)); //$NON-NLS-1$
+ assertThat(PublishingFileFilter.matches(PARTS_PROJECT, "*artsP*2"),
is(false)); //$NON-NLS-1$
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/PublishingFileFilterTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.rest.preferences;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class ResourcePatternTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldNotAllowNullPattern() {
+ new ResourcePattern(null, true);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldNotAllowEmptyPattern() {
+ new ResourcePattern("", true); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldBeEqualWhenPatternsAreEqual() {
+ String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp1 = new ResourcePattern(pattern, true);
+ ResourcePattern rp2 = new ResourcePattern(pattern, false);
+ assertThat(rp1.equals(rp2), is(true));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenComparingWithNull() {
+ ResourcePattern rp = new ResourcePattern("mypattern", true);
//$NON-NLS-1$
+ assertThat(rp.equals(null), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenPatternsAreNotEqual() {
+ ResourcePattern rp1 = new ResourcePattern("mypattern", true);
//$NON-NLS-1$
+ ResourcePattern rp2 = new ResourcePattern(rp1.getPattern() + "abc",
false); //$NON-NLS-1$
+ assertThat(rp1.equals(rp2), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualWhenComparingWithDifferentClass() {
+ String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp = new ResourcePattern(pattern, true);
+ assertThat(rp.equals(pattern), is(false));
+ }
+
+ @Test
+ public void shouldSetPatternCorrectly() {
+ String pattern = "mypattern"; //$NON-NLS-1$
+ ResourcePattern rp = new ResourcePattern(pattern, true);
+ assertThat(rp.getPattern(), is(pattern));
+ }
+
+ @Test
+ public void shouldSetEnabledStateCorrectlyAtConstruction() {
+ boolean enabled = true;
+ ResourcePattern rp = new ResourcePattern("mypattern", enabled);
//$NON-NLS-1$
+ assertThat(rp.isEnabled(), is(enabled));
+
+ enabled = !enabled;
+ rp = new ResourcePattern("mypattern", enabled); //$NON-NLS-1$
+ assertThat(rp.isEnabled(), is(enabled));
+ }
+
+ @Test
+ public void shouldSetEnabledStateCorrectly() {
+ boolean enabled = true;
+ ResourcePattern rp = new ResourcePattern("mypattern", enabled);
//$NON-NLS-1$
+ rp.setEnabled(!enabled);
+ assertThat(rp.isEnabled(), is(!enabled));
+
+ rp = new ResourcePattern("mypattern", !enabled); //$NON-NLS-1$
+ rp.setEnabled(enabled);
+ assertThat(rp.isEnabled(), is(enabled));
+ }
+
+}
Property changes on:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/preferences/ResourcePatternTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java 2011-04-15
16:39:28 UTC (rev 30594)
+++
branches/jbosstools-3.2.x/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/test/AllTests.java 2011-04-15
16:44:43 UTC (rev 30595)
@@ -3,11 +3,15 @@
import org.jboss.tools.modeshape.rest.PersistedServerTest;
import org.jboss.tools.modeshape.rest.ServerManagerTest;
import org.jboss.tools.modeshape.rest.ServerRegistryEventTest;
+import org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesModelTest;
+import org.jboss.tools.modeshape.rest.preferences.PublishingFileFilterTest;
+import org.jboss.tools.modeshape.rest.preferences.ResourcePatternTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-@RunWith( Suite.class )
-(a)Suite.SuiteClasses( {PersistedServerTest.class, ServerManagerTest.class,
ServerRegistryEventTest.class} )
+(a)RunWith(Suite.class)
+(a)Suite.SuiteClasses({ IgnoredResourcesModelTest.class, PersistedServerTest.class,
PublishingFileFilterTest.class,
+ ResourcePatternTest.class, ServerManagerTest.class, ServerRegistryEventTest.class
})
public class AllTests {
// nothing to do
}