JBoss Tools SVN: r23601 - in trunk/seam/tests/org.jboss.tools.seam.core.test: src/org/jboss/tools/seam/core/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 11:21:51 -0400 (Tue, 20 Jul 2010)
New Revision: 23601
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZ.component.xml
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZImpl.java
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6610
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZ.component.xml
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZ.component.xml (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZ.component.xml 2010-07-20 15:21:51 UTC (rev 23601)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="xyz" class="demo.XYZImpl" scope="application"
+ auto-create="true"
+ xmlns="http://jboss.com/products/seam/components"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd"/>
\ No newline at end of file
Property changes on: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZ.component.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZImpl.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZImpl.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZImpl.java 2010-07-20 15:21:51 UTC (rev 23601)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package demo;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.*;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+
+public class XYZImpl {
+
+}
Property changes on: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/JavaSource/demo/XYZImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2010-07-20 15:20:15 UTC (rev 23600)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2010-07-20 15:21:51 UTC (rev 23601)
@@ -465,6 +465,10 @@
assertNotNull(myUser);
Set<ISeamXmlComponentDeclaration> xml = myUser.getXmlDeclarations();
assertEquals(1, xml.size());
+
+ //6 XYZ.component.xml declares component xyz.
+ ISeamComponent xyz = seamProject.getComponent("xyz");
+ assertNotNull(xyz);
}
/**
15 years, 9 months
JBoss Tools SVN: r23600 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 11:20:15 -0400 (Tue, 20 Jul 2010)
New Revision: 23600
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
Log:
https://jira.jboss.org/browse/JBIDE-6610
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2010-07-20 14:35:26 UTC (rev 23599)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2010-07-20 15:20:15 UTC (rev 23600)
@@ -54,11 +54,8 @@
IPath webinf = null;
public IPath[] getPathsToVisit() {
- IPath[] dest = new IPath[srcs.length + (webinf==null?0:1)];
- System.arraycopy(srcs, 0, dest, 0, srcs.length);
- if(webinf!=null) {
- dest[srcs.length] = webinf;
- }
+ IPath[] dest = new IPath[1];
+ dest[0] = p.getProject().getFullPath();
return dest;
}
@@ -84,6 +81,7 @@
public boolean visit(IResource resource) {
if(resource instanceof IFile) {
IFile f = (IFile)resource;
+ if(!shouldVisitFile(f)) return false;
for (int i = 0; i < FILE_SCANNERS.length; i++) {
IFileScanner scanner = FILE_SCANNERS[i];
if(scanner.isRelevant(f)) {
@@ -104,8 +102,9 @@
// System.out.println("Time=" + timeUsed);
}
}
+ return true;
}
- return true;
+ return shouldVisitFolder(resource);
}
static long timeUsed = 0;
@@ -150,11 +149,7 @@
case IResourceDelta.CHANGED:
if(resource instanceof IFile) {
IFile f = (IFile)resource;
- for (int i = 0; i < outs.length; i++) {
- if(outs[i].isPrefixOf(resource.getFullPath())) {
- return false;
- }
- }
+ if(!shouldVisitFile(f)) return false;
for (int i = 0; i < FILE_SCANNERS.length; i++) {
IFileScanner scanner = FILE_SCANNERS[i];
if(scanner.isRelevant(f)) {
@@ -177,26 +172,7 @@
}
}
if(resource instanceof IFolder) {
- IPath path = resource.getFullPath();
- for (int i = 0; i < outs.length; i++) {
- if(outs[i].isPrefixOf(path)) {
- return false;
- }
- }
- for (int i = 0; i < srcs.length; i++) {
- if(srcs[i].isPrefixOf(path) || path.isPrefixOf(srcs[i])) {
- return true;
- }
- }
- if(webinf != null) {
- if(webinf.isPrefixOf(path) || path.isPrefixOf(webinf)) {
- return true;
- }
- }
- if(resource == resource.getProject()) {
- return true;
- }
- return false;
+ return shouldVisitFolder(resource);
}
//return true to continue visiting children.
return true;
@@ -207,4 +183,36 @@
return true;
}
+ boolean shouldVisitFile(IResource resource) {
+ for (int i = 0; i < outs.length; i++) {
+ if(outs[i].isPrefixOf(resource.getFullPath())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ boolean shouldVisitFolder(IResource resource) {
+ IPath path = resource.getFullPath();
+ for (int i = 0; i < outs.length; i++) {
+ if(outs[i].isPrefixOf(path)) {
+ return false;
+ }
+ }
+ for (int i = 0; i < srcs.length; i++) {
+ if(srcs[i].isPrefixOf(path) || path.isPrefixOf(srcs[i])) {
+ return true;
+ }
+ }
+ if(webinf != null) {
+ if(webinf.isPrefixOf(path) || path.isPrefixOf(webinf)) {
+ return true;
+ }
+ }
+ if(resource == resource.getProject()) {
+ return true;
+ }
+ return false;
+ }
+
}
15 years, 9 months
JBoss Tools SVN: r23599 - in trunk/seam/tests/org.jboss.tools.seam.xml.test: src/org/jboss/tools/seam/xml/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 10:35:26 -0400 (Tue, 20 Jul 2010)
New Revision: 23599
Added:
trunk/seam/tests/org.jboss.tools.seam.xml.test/projects/Test/XYZ.component.xml
Modified:
trunk/seam/tests/org.jboss.tools.seam.xml.test/src/org/jboss/tools/seam/xml/test/SeamXMLModelTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6610
Added: trunk/seam/tests/org.jboss.tools.seam.xml.test/projects/Test/XYZ.component.xml
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.xml.test/projects/Test/XYZ.component.xml (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.xml.test/projects/Test/XYZ.component.xml 2010-07-20 14:35:26 UTC (rev 23599)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="xyz" class="demo.XYZImpl" scope="application"
+ auto-create="true"
+ xmlns="http://jboss.com/products/seam/components"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd"/>
\ No newline at end of file
Property changes on: trunk/seam/tests/org.jboss.tools.seam.xml.test/projects/Test/XYZ.component.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/tests/org.jboss.tools.seam.xml.test/src/org/jboss/tools/seam/xml/test/SeamXMLModelTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.xml.test/src/org/jboss/tools/seam/xml/test/SeamXMLModelTest.java 2010-07-20 14:23:32 UTC (rev 23598)
+++ trunk/seam/tests/org.jboss.tools.seam.xml.test/src/org/jboss/tools/seam/xml/test/SeamXMLModelTest.java 2010-07-20 14:35:26 UTC (rev 23599)
@@ -64,6 +64,12 @@
//TODO continue test
}
+
+ public void testComponentFile() {
+ XModelObject fileObject = getComponent22Object();
+ String entity = fileObject.getModelEntity().getName();
+ assertEquals("File XYZ.component.xml is incorrectly parsed by XModel.", SeamComponentConstants.ENT_SEAM_COMPONENT_FILE_22, entity);
+ }
protected XModelObject getComponents22Object() {
assertNotNull(getTestProject());
@@ -74,6 +80,15 @@
}
+ protected XModelObject getComponent22Object() {
+ assertNotNull(getTestProject());
+ IFile f = project.getFile(new Path("XYZ.component.xml"));
+ assertNotNull(f);
+ assertTrue(f.exists());
+ return EclipseResourceUtil.createObjectForResource(f);
+
+ }
+
public void testNavigationPagesComponent() {
XModelObject fileObject = getComponents22Object();
assertNotNull("Cannot create XModel object for file components22.xml.", fileObject);
15 years, 9 months
JBoss Tools SVN: r23598 - trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 10:23:32 -0400 (Tue, 20 Jul 2010)
New Revision: 23598
Modified:
trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java
Log:
https://jira.jboss.org/browse/JBIDE-6610
Modified: trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java 2010-07-20 14:22:38 UTC (rev 23597)
+++ trunk/seam/plugins/org.jboss.tools.seam.xml/src/org/jboss/tools/seam/xml/components/model/SeamComponentsEntityRecognizer.java 2010-07-20 14:23:32 UTC (rev 23598)
@@ -40,7 +40,8 @@
if(PUBLIC_ID_11.equals(publicId)) return ENT_SEAM_COMPONENTS_11;
return null;
}
- if(!isComponentsSchema(body)) {
+ boolean isSingleComponent = isSingleComponent(body);
+ if(!isComponentsSchema(body) && !isSingleComponent) {
return null;
}
@@ -51,7 +52,6 @@
int k = body.indexOf("\"", j + 1); //$NON-NLS-1$
if(k < 0) return null;
String schemaLocation = body.substring(j + 1, k);
- boolean isSingleComponent = isSingleComponent(body);
int i12 = schemaLocation.indexOf("1.2"); //$NON-NLS-1$
if(i12 >= 0) {
15 years, 9 months
JBoss Tools SVN: r23597 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 10:22:38 -0400 (Tue, 20 Jul 2010)
New Revision: 23597
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
https://jira.jboss.org/browse/JBIDE-6610
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2010-07-20 14:21:33 UTC (rev 23596)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2010-07-20 14:22:38 UTC (rev 23597)
@@ -154,7 +154,8 @@
}
LoadedDeclarations ds = new LoadedDeclarations();
- if(o.getModelEntity().getName().equals("FileSeamComponent12")) { //$NON-NLS-1$
+ String fileEntity = o.getModelEntity().getName();
+ if(fileEntity.startsWith("FileSeamComponent") && !fileEntity.startsWith("FileSeamComponents")) { //$NON-NLS-1$
parseComponent(o, source, nm, sp, ds);
return ds;
}
15 years, 9 months
JBoss Tools SVN: r23596 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-07-20 10:21:33 -0400 (Tue, 20 Jul 2010)
New Revision: 23596
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java
Log:
https://jira.jboss.org/browse/JBIDE-6631 , only templates from the preference page will be exported.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2010-07-20 14:08:18 UTC (rev 23595)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2010-07-20 14:21:33 UTC (rev 23596)
@@ -153,9 +153,11 @@
}
public boolean finish() {
- List<VpeAnyData> templates = VpeTemplateManager.getInstance().getAnyTemplates();
IPath path = new Path(pathString);
- VpeTemplateManager.getInstance().setAnyTemplates(templates, path);
+ /*
+ * Export the current list to the specified location.
+ */
+ VpeTemplateManager.getInstance().setAnyTemplates(tagsList, path);
return true;
}
15 years, 9 months
JBoss Tools SVN: r23595 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-07-20 10:08:18 -0400 (Tue, 20 Jul 2010)
New Revision: 23595
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
Log:
fix https://jira.jboss.org/browse/JBIDE-6604
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2010-07-20 13:45:50 UTC (rev 23594)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2010-07-20 14:08:18 UTC (rev 23595)
@@ -57,6 +57,7 @@
private CSSStyleSheet styleSheet = null;
private static final String COPY_SUFFIX = "_copy"; //$NON-NLS-1$
+ private static final String CHARSET = "@CHARSET"; //$NON-NLS-1$
private boolean copy = false;
// workaround for JBIDE-4407
@@ -325,7 +326,8 @@
if ((rules != null) && (rules.getLength() > 0)) {
final CSSRule rule = rules.item(rules.getLength() - 1);
final String text = rule.getCssText();
- if ((text != null) && (!text.endsWith(Constants.RIGHT_BRACE))) {
+ if (text != null && !text.toUpperCase().startsWith(CHARSET) &&
+ !text.endsWith(Constants.RIGHT_BRACE)) {
rule.setCssText(text + "\n" + Constants.RIGHT_BRACE); //$NON-NLS-1$
}
}
15 years, 9 months
JBoss Tools SVN: r23594 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/preferences and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-07-20 09:45:50 -0400 (Tue, 20 Jul 2010)
New Revision: 23594
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportImportUnknownTagsTemplatesWizardDialog.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizard.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizard.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizardPage.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesPreferencePage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateData.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/VpeImportExportWizardsUtils.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
Log:
https://jira.jboss.org/browse/JBIDE-6631 , Import/Export buttons were added.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2010-07-20 13:45:50 UTC (rev 23594)
@@ -132,7 +132,7 @@
point="org.eclipse.ui.exportWizards">
<wizard
id="org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesWizard"
- class="org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesWizard"
+ class="org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesMenuWizard"
name="%exportUnknownTagsTemplatesWizardName"
icon="$nl$/resources/org/jboss/tools/vpe/wizards/icons/export_wizard.gif">
<description>
@@ -145,7 +145,7 @@
point="org.eclipse.ui.importWizards">
<wizard
id="org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesWizard"
- class="org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesWizard"
+ class="org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesMenuWizard"
name="%importUnknownTagsTemplatesWizardName"
icon="resources/org/jboss/tools/vpe/wizards/icons/import_wizard.gif">
<description>
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesPreferencePage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesPreferencePage.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesPreferencePage.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -39,10 +39,15 @@
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
import org.jboss.tools.vpe.editor.template.VpeAnyData;
import org.jboss.tools.vpe.editor.template.VpeEditAnyDialog;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.wizards.ExportImportUnknownTagsTemplatesWizardDialog;
+import org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesWizard;
+import org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesWizard;
+import org.jboss.tools.vpe.editor.wizards.VpeImportExportWizardsUtils;
import org.jboss.tools.vpe.messages.VpeUIMessages;
public class TemplatesPreferencePage extends PreferencePage implements
@@ -59,6 +64,8 @@
private Button addButton;
private Button editButton;
private Button removeButton;
+ private Button exportButton;
+ private Button importButton;
private List<VpeAnyData> tagsList;
protected boolean tagListWasChanged;
@@ -93,7 +100,7 @@
tagsTable = new Table(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
TableLayout layout = new TableLayout();
tagsTable.setLayout(layout);
- tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 5));
tagsTable.setHeaderVisible(true);
tagsTable.setLinesVisible(true);
@@ -110,7 +117,7 @@
/*
* Fill the table with stored tags
*/
- updateTagsTable();
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
/*
* Add buttons
@@ -127,6 +134,14 @@
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
removeButton.setText(VpeUIMessages.TemplatesPreferencePage_Remove);
+ exportButton = new Button(composite, SWT.BUTTON1);
+ exportButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
+ exportButton.setText(VpeUIMessages.TemplatesPreferencePage_Export);
+
+ importButton = new Button(composite, SWT.BUTTON1);
+ importButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
+ importButton.setText(VpeUIMessages.TemplatesPreferencePage_Import);
+
/*
* Adding event listeners to the buttons
*/
@@ -136,119 +151,14 @@
editButton.addListener(SWT.Selection, this);
removeButton.addListener(SWT.Modify, this);
removeButton.addListener(SWT.Selection, this);
-
+ exportButton.addListener(SWT.Modify, this);
+ exportButton.addListener(SWT.Selection, this);
+ importButton.addListener(SWT.Modify, this);
+ importButton.addListener(SWT.Selection, this);
+
return composite;
}
-
- /**
- * Updates tags table according to the current <code>tagList</code>.
- */
- private void updateTagsTable() {
- /*
- * If widget is null or disposed - exit.
- */
- if(tagsTable == null || tagsTable.isDisposed() || tagsList == null) {
- return;
- }
- /*
- * Remember selection index.
- */
- int selectionIndex = tagsTable.getSelectionIndex();
- /*
- * Clear all previously saved items.
- */
- tagsTable.clearAll();
- tagsTable.update();
-
- /*
- * Recreate table items
- */
- TableItem tableItem = null;
- /*
- * Sort the templates
- */
- Collections.sort(tagsList, new Comparator<VpeAnyData>() {
- public int compare(VpeAnyData o1, VpeAnyData o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }
- });
- for (int i = 0; i < tagsList.size(); i++) {
- if(tagsTable.getItemCount() > i) {
- /*
- * Use existed items
- */
- tableItem = tagsTable.getItem(i);
- } else {
- /*
- * Add necessary item
- */
- tableItem = new TableItem(tagsTable, SWT.BORDER, i);
- }
- /*
- * Fill in columns.
- * Tags table has 4 columns.
- */
- String[] itemColumnsData = new String[tagsTable.getColumnCount()];
- for (int j = 0; j < itemColumnsData.length; j++) {
- /*
- * Getting values from tagList
- */
- itemColumnsData[j] = toVisualValue(getValueAt(i, (j)));
- }
- /*
- * Set cells text
- */
- tableItem.setText(itemColumnsData);
- }
-
- /*
- * Restoring selection index
- */
- if (selectionIndex > 0 ) {
- try {
- tagsTable.setSelection(selectionIndex);
- } catch (SWTException e) {
- /*
- * Do nothing
- */
- }
- }
- }
- public String getValueAt(int row, int column) {
- String result = "List is empty"; //$NON-NLS-1$
- if (null != tagsList) {
- VpeAnyData tagItem = (VpeAnyData)tagsList.get(row);
- switch(column){
- case 0:
- result = tagItem.getName();
- break;
- case 1:
- result = tagItem.getTagForDisplay();
- break;
- case 2:
- result = tagItem.getUri();
- break;
- case 3:
- if(tagItem.isChildren()) {
- result = VpeUIMessages.TemplatesTableProvider_Yes;
- } else {
- result = VpeUIMessages.TemplatesTableProvider_No;
- }
- break;
- }
- }
- return result;
- }
-
- private String toVisualValue(String v) {
- if(v == null) return ""; //$NON-NLS-1$
- if(v.indexOf('\n') >= 0) v = v.replace('\n', ' ');
- if(v.indexOf('\t') >= 0) v = v.replace('\t', ' ');
- if(v.indexOf('\r') >= 0) v = v.replace('\r', ' ');
- return v;
- }
-
public void handleEvent(Event event) {
Widget source = event.widget;
int selectIndex = tagsTable.getSelectionIndex();
@@ -296,7 +206,30 @@
tagsTable.remove(selectIndex);
tagsList.remove(selectIndex);
tagListWasChanged = true;
+ if (selectIndex > 0) {
+ tagsTable.setSelection(selectIndex - 1);
+ }
}
+ } else if (source == exportButton) {
+ /*
+ * Export templates
+ */
+ ExportImportUnknownTagsTemplatesWizardDialog dlg = new ExportImportUnknownTagsTemplatesWizardDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ new ExportUnknownTagsTemplatesWizard(tagsList));
+ dlg.open();
+ } else if (source == importButton) {
+ /*
+ * Import templates
+ */
+ ExportImportUnknownTagsTemplatesWizardDialog dlg = new ExportImportUnknownTagsTemplatesWizardDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ new ImportUnknownTagsTemplatesWizard(tagsList));
+ dlg.open();
+ /*
+ * Re-initialize tags list from the file
+ */
+ tagsList.addAll(dlg.getImportedList());
} else {
/*
* Handle default event
@@ -305,7 +238,7 @@
/*
* Update tags table with the new templates.
*/
- updateTagsTable();
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
}
@Override
@@ -330,7 +263,7 @@
* due to URI changes
*/
tagsList = VpeTemplateManager.getInstance().getAnyTemplates();
- updateTagsTable();
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
}
@Override
@@ -340,7 +273,7 @@
* Update visual table.
*/
tagsList = VpeTemplateManager.getInstance().getAnyTemplates();
- updateTagsTable();
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -115,6 +115,13 @@
return false;
}
VpeAnyData other = (VpeAnyData) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
if (tagForDisplay == null) {
if (other.tagForDisplay != null) {
return false;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateData.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateData.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -13,7 +13,7 @@
public class VpeTemplateData {
private boolean changed = false;
- private String name;
+ protected String name;
private boolean caseSensitive = false;
private boolean children = false;
private boolean modify = false;
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportImportUnknownTagsTemplatesWizardDialog.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportImportUnknownTagsTemplatesWizardDialog.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportImportUnknownTagsTemplatesWizardDialog.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+
+public class ExportImportUnknownTagsTemplatesWizardDialog extends WizardDialog {
+
+ public ExportImportUnknownTagsTemplatesWizardDialog(Shell parentShell,
+ IWizard newWizard) {
+ super(parentShell, newWizard);
+ setHelpAvailable(false);
+ }
+
+ @Override
+ public void setMinimumPageSize(int minWidth, int minHeight) {
+ super.setMinimumPageSize(500, 400);
+ }
+
+ public List<VpeAnyData> getImportedList() {
+ if (getWizard() instanceof ImportUnknownTagsTemplatesWizard) {
+ return ((ImportUnknownTagsTemplatesWizard)getWizard()).getImportedList();
+ } else {
+ return new ArrayList<VpeAnyData>();
+ }
+ }
+}
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizard.java (from rev 23485, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizard.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizard.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+/**
+ * Wizard that exports Unknown Tags Templates from Preference Page
+ * to the vpe-templates-auto.xml file.
+ *
+ * @author dmaliarevich
+ */
+public class ExportUnknownTagsTemplatesMenuWizard extends Wizard implements
+ IExportWizard {
+
+ private IStructuredSelection selection;
+ private ExportUnknownTagsTemplatesMenuWizardPage mainPage;
+
+ /**
+ * Constructor
+ */
+ public ExportUnknownTagsTemplatesMenuWizard() {
+ setWindowTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ mainPage = new ExportUnknownTagsTemplatesMenuWizardPage(
+ VpeUIMessages.EXPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
+ selection);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ return mainPage.finish();
+ }
+
+}
\ No newline at end of file
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizardPage.java (from rev 23524, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizardPage.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesMenuWizardPage.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.SWT;
+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.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.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardExportResourcesPage;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
+
+/**
+ * Page for exporting unknown tags templates.
+ *
+ * @author dmaliarevich
+ */
+public class ExportUnknownTagsTemplatesMenuWizardPage extends
+ WizardExportResourcesPage implements VpeImportExportWizardPage {
+
+ private String pathString;
+ private Table tagsTable;
+ private List<VpeAnyData> tagsList;
+
+ /**
+ * Constructor
+ *
+ * @param pageName
+ * @param selection
+ */
+ public ExportUnknownTagsTemplatesMenuWizardPage(String pageName,
+ IStructuredSelection selection) {
+ super(pageName, selection);
+ setTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ setDescription(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
+ setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
+ /*
+ * Initialize tags list
+ */
+ tagsList = VpeTemplateManager.getInstance().getAnyTemplates();
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ /*
+ * Create main composite element with grid layout.
+ * Two columns.
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ composite.setFont(parent.getFont());
+
+ /*
+ * Create datatable with the list of unknown tags
+ */
+ tagsTable = new Table(composite, SWT.BORDER);
+ TableLayout layout = new TableLayout();
+ tagsTable.setLayout(layout);
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+
+ /*
+ * Create columns in the table
+ */
+ ColumnLayoutData columnLayoutData;
+ for (int i = 0; i < COLUMNS_NAMES.length; i++) {
+ TableColumn column = new TableColumn(tagsTable, SWT.NONE);
+ column.setText(COLUMNS_NAMES[i]);
+ columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
+ layout.addColumnData(columnLayoutData);
+ }
+ /*
+ * Fill the table with stored tags
+ */
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
+
+ /*
+ * Add label
+ */
+ Label fileNamaLabel = new Label(composite, SWT.NONE);
+ fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
+ fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
+ /*
+ * Add output path
+ */
+ final Text pathText = new Text(composite, SWT.BORDER);
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
+ pathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ pathString = ((Text)e.getSource()).getText();
+ setPageComplete(isPageComplete());
+ }
+ });
+ /*
+ * Add browse button
+ */
+ Button browseButton = new Button(composite, SWT.NONE);
+ browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
+ browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), SWT.NONE);
+ String path = dialog.open();
+ if (path != null) {
+ File file = new File(path);
+ pathString = file.toString();
+ /*
+ * Then modifyText event will be dispatched.
+ */
+ pathText.setText(pathString);
+ }
+ }
+ });
+
+ /*
+ * Finishing the initialization
+ */
+ updateWidgetEnablements();
+ setPageComplete(determinePageCompletion());
+ setErrorMessage(null); // should not initially have error message
+
+ setControl(composite);
+ }
+
+ @Override
+ protected void createDestinationGroup(Composite parent) {
+ /*
+ * Create nothing
+ */
+ }
+
+ public void handleEvent(Event event) {
+ /*
+ * Do nothing
+ */
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean isPageComplete = false;
+ if ((pathString != null)
+ && !Constants.EMPTY.equalsIgnoreCase(pathString)
+ && (Path.ROOT.isValidPath(pathString))) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+ public boolean finish() {
+ List<VpeAnyData> templates = VpeTemplateManager.getInstance().getAnyTemplates();
+ IPath path = new Path(pathString);
+ VpeTemplateManager.getInstance().setAnyTemplates(templates, path);
+ return true;
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -1,61 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.wizards;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.IExportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-/**
- * Wizard that exports Unknown Tags Templates from Preference Page
- * to the vpe-templates-auto.xml file.
- *
- * @author dmaliarevich
- */
-public class ExportUnknownTagsTemplatesWizard extends Wizard implements
- IExportWizard {
-
- private IStructuredSelection selection;
- private ExportUnknownTagsTemplatesWizardPage mainPage;
-
- /**
- * Constructor
- */
- public ExportUnknownTagsTemplatesWizard() {
- setWindowTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
- }
-
- public void init(IWorkbench workbench, IStructuredSelection selection) {
-
- }
-
- @Override
- public void addPages() {
- super.addPages();
- mainPage = new ExportUnknownTagsTemplatesWizardPage(
- VpeUIMessages.EXPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
- selection);
- addPage(mainPage);
- }
-
- @Override
- public boolean canFinish() {
- return mainPage.isPageComplete();
- }
-
- @Override
- public boolean performFinish() {
- return mainPage.finish();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+public class ExportUnknownTagsTemplatesWizard extends Wizard {
+
+ private ExportUnknownTagsTemplatesWizardPage mainPage;
+ private List<VpeAnyData> currentList;
+
+ /**
+ * Constructor
+ */
+ public ExportUnknownTagsTemplatesWizard(List<VpeAnyData> currentList) {
+ setWindowTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ this.currentList = currentList;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ mainPage = new ExportUnknownTagsTemplatesWizardPage(
+ VpeUIMessages.EXPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
+ currentList);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ return mainPage.finish();
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -1,191 +1,162 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.wizards;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.swt.SWT;
-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.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.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.WizardExportResourcesPage;
-import org.jboss.tools.vpe.editor.template.VpeAnyData;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.Constants;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
-
-/**
- * Page for exporting unknown tags templates.
- *
- * @author dmaliarevich
- */
-public class ExportUnknownTagsTemplatesWizardPage extends
- WizardExportResourcesPage implements VpeImportExportWizardPage {
-
- private String pathString;
- private Table tagsTable;
- private List<VpeAnyData> tagsList;
-
- /**
- * Constructor
- *
- * @param pageName
- * @param selection
- */
- public ExportUnknownTagsTemplatesWizardPage(String pageName,
- IStructuredSelection selection) {
- super(pageName, selection);
- setTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
- setDescription(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
- setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
- /*
- * Initialize tags list
- */
- tagsList = VpeTemplateManager.getInstance().getAnyTemplates();
- }
-
- @Override
- public void createControl(Composite parent) {
- /*
- * Create main composite element with grid layout.
- * Two columns.
- */
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(3, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- composite.setFont(parent.getFont());
-
- /*
- * Create datatable with the list of unknown tags
- */
- tagsTable = new Table(composite, SWT.BORDER);
- TableLayout layout = new TableLayout();
- tagsTable.setLayout(layout);
- tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
- tagsTable.setHeaderVisible(true);
- tagsTable.setLinesVisible(true);
-
- /*
- * Create columns in the table
- */
- ColumnLayoutData columnLayoutData;
- for (int i = 0; i < COLUMNS_NAMES.length; i++) {
- TableColumn column = new TableColumn(tagsTable, SWT.NONE);
- column.setText(COLUMNS_NAMES[i]);
- columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
- layout.addColumnData(columnLayoutData);
- }
- /*
- * Fill the table with stored tags
- */
- VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
-
- /*
- * Add label
- */
- Label fileNamaLabel = new Label(composite, SWT.NONE);
- fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
- fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
- /*
- * Add output path
- */
- final Text pathText = new Text(composite, SWT.BORDER);
- pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
- pathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- pathString = ((Text)e.getSource()).getText();
- setPageComplete(isPageComplete());
- }
- });
- /*
- * Add browse button
- */
- Button browseButton = new Button(composite, SWT.NONE);
- browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
- browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(), SWT.NONE);
- String path = dialog.open();
- if (path != null) {
- File file = new File(path);
- pathString = file.toString();
- /*
- * Then modifyText event will be dispatched.
- */
- pathText.setText(pathString);
- }
- }
- });
-
- /*
- * Finishing the initialization
- */
- updateWidgetEnablements();
- setPageComplete(determinePageCompletion());
- setErrorMessage(null); // should not initially have error message
-
- setControl(composite);
- }
-
- @Override
- protected void createDestinationGroup(Composite parent) {
- /*
- * Create nothing
- */
- }
-
- public void handleEvent(Event event) {
- /*
- * Do nothing
- */
- }
-
- @Override
- public boolean isPageComplete() {
- boolean isPageComplete = false;
- if ((pathString != null)
- && !Constants.EMPTY.equalsIgnoreCase(pathString)
- && (Path.ROOT.isValidPath(pathString))) {
- isPageComplete = true;
- }
- return isPageComplete;
- }
-
- public boolean finish() {
- List<VpeAnyData> templates = VpeTemplateManager.getInstance().getAnyTemplates();
- IPath path = new Path(pathString);
- VpeTemplateManager.getInstance().setAnyTemplates(templates, path);
- return true;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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.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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
+
+public class ExportUnknownTagsTemplatesWizardPage extends WizardPage implements
+ VpeImportExportWizardPage {
+
+ private String pathString;
+ private Table tagsTable;
+ private List<VpeAnyData> tagsList;
+
+ protected ExportUnknownTagsTemplatesWizardPage(String pageName, List<VpeAnyData> currentList) {
+ super(pageName);
+ setTitle(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ setDescription(VpeUIMessages.EXPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
+ setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
+ /*
+ * Initialize tags list
+ */
+ tagsList = currentList;
+ }
+
+ public void createControl(Composite parent) {
+ /*
+ * Create main composite element with grid layout.
+ * Two columns.
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ composite.setFont(parent.getFont());
+
+ /*
+ * Create datatable with the list of unknown tags
+ */
+ tagsTable = new Table(composite, SWT.BORDER);
+ TableLayout layout = new TableLayout();
+ tagsTable.setLayout(layout);
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+
+ /*
+ * Create columns in the table
+ */
+ ColumnLayoutData columnLayoutData;
+ for (int i = 0; i < COLUMNS_NAMES.length; i++) {
+ TableColumn column = new TableColumn(tagsTable, SWT.NONE);
+ column.setText(COLUMNS_NAMES[i]);
+ columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
+ layout.addColumnData(columnLayoutData);
+ }
+ /*
+ * Fill the table with stored tags
+ */
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
+
+ /*
+ * Add label
+ */
+ Label fileNamaLabel = new Label(composite, SWT.NONE);
+ fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
+ fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
+ /*
+ * Add output path
+ */
+ final Text pathText = new Text(composite, SWT.BORDER);
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
+ pathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ pathString = ((Text)e.getSource()).getText();
+ setPageComplete(isPageComplete());
+ }
+ });
+ /*
+ * Add browse button
+ */
+ Button browseButton = new Button(composite, SWT.NONE);
+ browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
+ browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), SWT.NONE);
+ String path = dialog.open();
+ if (path != null) {
+ File file = new File(path);
+ pathString = file.toString();
+ /*
+ * Then modifyText event will be dispatched.
+ */
+ pathText.setText(pathString);
+ }
+ }
+ });
+
+ /*
+ * Finishing the initialization
+ */
+ setPageComplete(isPageComplete());
+ setErrorMessage(null); // should not initially have error message
+
+ setControl(composite);
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean isPageComplete = false;
+ if ((pathString != null)
+ && !Constants.EMPTY.equalsIgnoreCase(pathString)
+ && (Path.ROOT.isValidPath(pathString))) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+ public boolean finish() {
+ List<VpeAnyData> templates = VpeTemplateManager.getInstance().getAnyTemplates();
+ IPath path = new Path(pathString);
+ VpeTemplateManager.getInstance().setAnyTemplates(templates, path);
+ return true;
+ }
+
+}
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizard.java (from rev 23524, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizard.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizard.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+/**
+ *
+ * Wizard that imports Unknown Tags Templates from external xml file.
+ *
+ * @author dmaliarevich
+ */
+public class ImportUnknownTagsTemplatesMenuWizard extends Wizard implements
+ IImportWizard {
+
+ private IStructuredSelection selection;
+ private ImportUnknownTagsTemplatesMenuWizardPage mainPage;
+
+ /**
+ * Constructor
+ */
+ public ImportUnknownTagsTemplatesMenuWizard() {
+ super();
+ setWindowTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ setWindowTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ mainPage = new ImportUnknownTagsTemplatesMenuWizardPage(
+ VpeUIMessages.IMPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
+ selection);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ return mainPage.finish();
+ }
+
+}
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizardPage.java (from rev 23524, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizardPage.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesMenuWizardPage.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.SWT;
+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.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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardResourceImportPage;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
+
+/**
+ * Page for importing unknown tags templates.
+ *
+ * @author dmaliarevich
+ */
+public class ImportUnknownTagsTemplatesMenuWizardPage extends
+ WizardResourceImportPage implements VpeImportExportWizardPage {
+
+ private String pathString;
+ private Table tagsTable;
+ private List<VpeAnyData> tagsList;
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * @param selection
+ */
+ public ImportUnknownTagsTemplatesMenuWizardPage(String name,
+ IStructuredSelection selection) {
+ super(name, selection);
+ setTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ setDescription(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
+ setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ /*
+ * Create main composite element with grid layout.
+ * Two columns.
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ composite.setFont(parent.getFont());
+
+ /*
+ * Add label
+ */
+ Label fileNamaLabel = new Label(composite, SWT.NONE);
+ fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
+ fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
+ /*
+ * Add output path
+ */
+ final Text pathText = new Text(composite, SWT.BORDER);
+ pathText.setEditable(true);
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
+ pathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ pathString = ((Text)e.getSource()).getText();
+ IPath enteredPath = null;
+ /*
+ * Load templates if the path is valid
+ */
+ if ((Path.ROOT.isValidPath(pathString))
+ && (enteredPath = Path.fromOSString(pathString)).toFile().exists()) {
+ /*
+ * Load tags list from the specified location.
+ */
+ tagsList = VpeTemplateManager.getInstance()
+ .getAnyTemplates(enteredPath);
+
+ } else {
+ /*
+ * Reset taglist, show empty table
+ */
+ if (tagsList != null) {
+ tagsList.clear();
+ }
+ }
+ /*
+ * Update table tags list based on the loaded file.
+ */
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
+ /*
+ * Check if the page is complete.
+ */
+ setPageComplete(isPageComplete());
+ }
+ });
+ /*
+ * Add browse button
+ */
+ Button browseButton = new Button(composite, SWT.NONE);
+ browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
+ browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), SWT.NONE);
+ String path = dialog.open();
+ if (path != null) {
+ File file = new File(path);
+ pathString = file.toString();
+ /*
+ * Then modifyText event will be dispatched.
+ */
+ pathText.setText(pathString);
+ }
+ }
+ });
+
+ /*
+ * Create datatable with the list of unknown tags
+ */
+ tagsTable = new Table(composite, SWT.BORDER);
+ TableLayout layout = new TableLayout();
+ tagsTable.setLayout(layout);
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+
+ /*
+ * Create columns in the table
+ */
+ ColumnLayoutData columnLayoutData;
+ for (int i = 0; i < COLUMNS_NAMES.length; i++) {
+ TableColumn column = new TableColumn(tagsTable, SWT.NONE);
+ column.setText(COLUMNS_NAMES[i]);
+ columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
+ layout.addColumnData(columnLayoutData);
+ }
+
+ /*
+ * Finishing the initialization
+ */
+ setErrorMessage(null); // should not initially have error message
+ setControl(composite);
+
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean isPageComplete = false;
+ if ((pathString != null)
+ && !Constants.EMPTY.equalsIgnoreCase(pathString)
+ && (Path.ROOT.isValidPath(pathString))
+ && ((Path.fromOSString(pathString)).toFile().exists())) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+ public boolean finish() {
+ /*
+ * Currently used templates list
+ */
+ List<VpeAnyData> currentList = VpeTemplateManager.getInstance().getAnyTemplates();
+
+ /*
+ * Uploading will add only missing templates.
+ * So here all duplicated templates will be deleted from the tagsList.
+ */
+ Iterator<VpeAnyData> iterator = tagsList.iterator();
+ while (iterator.hasNext()) {
+ VpeAnyData loadedTemplate = (VpeAnyData) iterator.next();
+ for (VpeAnyData currentTemplate : currentList) {
+ if (loadedTemplate.equals(currentTemplate)) {
+ iterator.remove();
+ }
+ }
+ }
+ /*
+ * Add unique templates to the current list.
+ */
+ if (currentList.addAll(tagsList)) {
+ /*
+ * Store loaded templates to the default auto-templates location.
+ */
+ VpeTemplateManager.getInstance().setAnyTemplates(currentList);
+ } else {
+ /*
+ * Log WARNING if the operation could not be performed.
+ */
+ VpePlugin.getDefault().logWarning(VpeUIMessages.NONE_TEMPLATES_WERE_ADDED);
+ }
+ return true;
+ }
+
+ @Override
+ protected void createSourceGroup(Composite parent) {
+ /*
+ * Create nothing.
+ */
+ }
+
+ @Override
+ protected ITreeContentProvider getFileProvider() {
+ return null;
+ }
+
+ @Override
+ protected ITreeContentProvider getFolderProvider() {
+ return null;
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -1,62 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.wizards;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-/**
- *
- * Wizard that imports Unknown Tags Templates from external xml file.
- *
- * @author dmaliarevich
- */
-public class ImportUnknownTagsTemplatesWizard extends Wizard implements
- IImportWizard {
-
- private IStructuredSelection selection;
- private ImportUnknownTagsTemplatesWizardPage mainPage;
-
- /**
- * Constructor
- */
- public ImportUnknownTagsTemplatesWizard() {
- setWindowTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
- }
-
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.selection = selection;
- setWindowTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
- }
-
- @Override
- public void addPages() {
- super.addPages();
- mainPage = new ImportUnknownTagsTemplatesWizardPage(
- VpeUIMessages.IMPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
- selection);
- addPage(mainPage);
- }
-
- @Override
- public boolean canFinish() {
- return mainPage.isPageComplete();
- }
-
- @Override
- public boolean performFinish() {
- return mainPage.finish();
- }
-
-}
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+public class ImportUnknownTagsTemplatesWizard extends Wizard {
+
+ private ImportUnknownTagsTemplatesWizardPage mainPage;
+ private List<VpeAnyData> importedList = new ArrayList<VpeAnyData>();
+ private List<VpeAnyData> currentList;
+
+ public ImportUnknownTagsTemplatesWizard(List<VpeAnyData> currentList) {
+ super();
+ setWindowTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ this.currentList = currentList;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ mainPage = new ImportUnknownTagsTemplatesWizardPage(
+ VpeUIMessages.IMPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE,
+ currentList);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ boolean pageFinished = mainPage.finish();
+ if (pageFinished) {
+ importedList = mainPage.getImportedList();
+ }
+ return pageFinished;
+ }
+
+ public List<VpeAnyData> getImportedList() {
+ return importedList;
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -1,245 +1,207 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.wizards;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.swt.SWT;
-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.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.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.WizardResourceImportPage;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.template.VpeAnyData;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.Constants;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
-
-/**
- * Page for importing unknown tags templates.
- *
- * @author dmaliarevich
- */
-public class ImportUnknownTagsTemplatesWizardPage extends
- WizardResourceImportPage implements VpeImportExportWizardPage {
-
- private String pathString;
- private Table tagsTable;
- private List<VpeAnyData> tagsList;
-
- /**
- * Constructor
- *
- * @param name
- * @param selection
- */
- public ImportUnknownTagsTemplatesWizardPage(String name,
- IStructuredSelection selection) {
- super(name, selection);
- setTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
- setDescription(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
- setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
- }
-
- @Override
- public void createControl(Composite parent) {
- /*
- * Create main composite element with grid layout.
- * Two columns.
- */
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(3, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- composite.setFont(parent.getFont());
-
- /*
- * Add label
- */
- Label fileNamaLabel = new Label(composite, SWT.NONE);
- fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
- fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
- /*
- * Add output path
- */
- final Text pathText = new Text(composite, SWT.BORDER);
- pathText.setEditable(true);
- pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
- pathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- pathString = ((Text)e.getSource()).getText();
- IPath enteredPath = null;
- /*
- * Load templates if the path is valid
- */
- if ((Path.ROOT.isValidPath(pathString))
- && (enteredPath = Path.fromOSString(pathString)).toFile().exists()) {
- /*
- * Load tags list from the specified location.
- */
- tagsList = VpeTemplateManager.getInstance()
- .getAnyTemplates(enteredPath);
-
- } else {
- /*
- * Reset taglist, show empty table
- */
- if (tagsList != null) {
- tagsList.clear();
- }
- }
- /*
- * Update table tags list based on the loaded file.
- */
- VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
- /*
- * Check if the page is complete.
- */
- setPageComplete(isPageComplete());
- }
- });
- /*
- * Add browse button
- */
- Button browseButton = new Button(composite, SWT.NONE);
- browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
- browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell(), SWT.NONE);
- String path = dialog.open();
- if (path != null) {
- File file = new File(path);
- pathString = file.toString();
- /*
- * Then modifyText event will be dispatched.
- */
- pathText.setText(pathString);
- }
- }
- });
-
- /*
- * Create datatable with the list of unknown tags
- */
- tagsTable = new Table(composite, SWT.BORDER);
- TableLayout layout = new TableLayout();
- tagsTable.setLayout(layout);
- tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
- tagsTable.setHeaderVisible(true);
- tagsTable.setLinesVisible(true);
-
- /*
- * Create columns in the table
- */
- ColumnLayoutData columnLayoutData;
- for (int i = 0; i < COLUMNS_NAMES.length; i++) {
- TableColumn column = new TableColumn(tagsTable, SWT.NONE);
- column.setText(COLUMNS_NAMES[i]);
- columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
- layout.addColumnData(columnLayoutData);
- }
-
- /*
- * Finishing the initialization
- */
- setErrorMessage(null); // should not initially have error message
- setControl(composite);
-
- }
-
- @Override
- public boolean isPageComplete() {
- boolean isPageComplete = false;
- if ((pathString != null)
- && !Constants.EMPTY.equalsIgnoreCase(pathString)
- && (Path.ROOT.isValidPath(pathString))
- && ((Path.fromOSString(pathString)).toFile().exists())) {
- isPageComplete = true;
- }
- return isPageComplete;
- }
-
- public boolean finish() {
- /*
- * Currently used templates list
- */
- List<VpeAnyData> currentList = VpeTemplateManager.getInstance().getAnyTemplates();
-
- /*
- * Uploading will add only missing templates.
- * So here all duplicated templates will be deleted from the tagsList.
- */
- Iterator<VpeAnyData> iterator = tagsList.iterator();
- while (iterator.hasNext()) {
- VpeAnyData loadedTemplate = (VpeAnyData) iterator.next();
- for (VpeAnyData currentTemplate : currentList) {
- if (loadedTemplate.equals(currentTemplate)) {
- iterator.remove();
- }
- }
- }
- /*
- * Add unique templates to the current list.
- */
- if (currentList.addAll(tagsList)) {
- /*
- * Store loaded templates to the default auto-templates location.
- */
- VpeTemplateManager.getInstance().setAnyTemplates(currentList);
- } else {
- /*
- * Log WARNING if the operation could not be performed.
- */
- VpePlugin.getDefault().logWarning(VpeUIMessages.NONE_TEMPLATES_WERE_ADDED);
- }
- return true;
- }
-
- @Override
- protected void createSourceGroup(Composite parent) {
- /*
- * Create nothing.
- */
- }
-
- @Override
- protected ITreeContentProvider getFileProvider() {
- return null;
- }
-
- @Override
- protected ITreeContentProvider getFolderProvider() {
- return null;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.wizards;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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.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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.template.VpeAnyData;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
+
+public class ImportUnknownTagsTemplatesWizardPage extends WizardPage implements
+ VpeImportExportWizardPage {
+
+ private String pathString;
+ private Table tagsTable;
+ private List<VpeAnyData> tagsList;
+ private List<VpeAnyData> currentList;
+ private List<VpeAnyData> importedList = new ArrayList<VpeAnyData>();
+
+ protected ImportUnknownTagsTemplatesWizardPage(String pageName, List<VpeAnyData> currentList) {
+ super(pageName);
+ this.currentList = currentList;
+ setTitle(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_TITLE);
+ setDescription(VpeUIMessages.IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION);
+ setImageDescriptor(ReferenceWizardPage.getImageDescriptor());
+ }
+
+ public void createControl(Composite parent) {
+ /*
+ * Create main composite element with grid layout.
+ * Two columns.
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ composite.setFont(parent.getFont());
+
+ /*
+ * Add label
+ */
+ Label fileNamaLabel = new Label(composite, SWT.NONE);
+ fileNamaLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
+ fileNamaLabel.setText(VpeUIMessages.FILE_NAME_LABEL);
+ /*
+ * Add output path
+ */
+ final Text pathText = new Text(composite, SWT.BORDER);
+ pathText.setEditable(true);
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
+ pathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ pathString = ((Text)e.getSource()).getText();
+ IPath enteredPath = null;
+ /*
+ * Load templates if the path is valid
+ */
+ if ((Path.ROOT.isValidPath(pathString))
+ && (enteredPath = Path.fromOSString(pathString)).toFile().exists()) {
+ /*
+ * Load tags list from the specified location.
+ */
+ tagsList = VpeTemplateManager.getInstance()
+ .getAnyTemplates(enteredPath);
+
+ } else {
+ /*
+ * Reset taglist, show empty table
+ */
+ if (tagsList != null) {
+ tagsList.clear();
+ }
+ }
+ /*
+ * Update table tags list based on the loaded file.
+ */
+ VpeImportExportWizardsUtils.updateTagsTable(tagsTable, tagsList, true);
+ /*
+ * Check if the page is complete.
+ */
+ setPageComplete(isPageComplete());
+ }
+ });
+ /*
+ * Add browse button
+ */
+ Button browseButton = new Button(composite, SWT.NONE);
+ browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
+ browseButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(), SWT.NONE);
+ String path = dialog.open();
+ if (path != null) {
+ File file = new File(path);
+ pathString = file.toString();
+ /*
+ * Then modifyText event will be dispatched.
+ */
+ pathText.setText(pathString);
+ }
+ }
+ });
+
+ /*
+ * Create datatable with the list of unknown tags
+ */
+ tagsTable = new Table(composite, SWT.BORDER);
+ TableLayout layout = new TableLayout();
+ tagsTable.setLayout(layout);
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+
+ /*
+ * Create columns in the table
+ */
+ ColumnLayoutData columnLayoutData;
+ for (int i = 0; i < COLUMNS_NAMES.length; i++) {
+ TableColumn column = new TableColumn(tagsTable, SWT.NONE);
+ column.setText(COLUMNS_NAMES[i]);
+ columnLayoutData = new ColumnWeightData(COLUMNS_WIDTHS[i], true);
+ layout.addColumnData(columnLayoutData);
+ }
+
+ /*
+ * Finishing the initialization
+ */
+ setErrorMessage(null); // should not initially have error message
+ setControl(composite);
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean isPageComplete = false;
+ if ((pathString != null)
+ && !Constants.EMPTY.equalsIgnoreCase(pathString)
+ && (Path.ROOT.isValidPath(pathString))
+ && ((Path.fromOSString(pathString)).toFile().exists())) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+
+
+ public boolean finish() {
+ /*
+ * Uploading will add only missing templates.
+ * So here all duplicated templates will be deleted from the tagsList.
+ */
+ importedList.clear();
+ importedList.addAll(tagsList);
+ Iterator<VpeAnyData> iterator = importedList.iterator();
+ while (iterator.hasNext()) {
+ VpeAnyData loadedTemplate = (VpeAnyData) iterator.next();
+ for (VpeAnyData currentTemplate : currentList) {
+ if (loadedTemplate.equals(currentTemplate)) {
+ iterator.remove();
+ }
+ }
+ }
+ /*
+ * Add unique templates to the current list.
+ */
+ return true;
+ }
+
+ public List<VpeAnyData> getImportedList() {
+ return importedList;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/VpeImportExportWizardsUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/VpeImportExportWizardsUtils.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/VpeImportExportWizardsUtils.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.wizards;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.swt.SWT;
@@ -33,27 +35,30 @@
/*
* Return when visual table hasn't been initialized.
*/
- if(tagsTable == null || tagsTable.isDisposed()) {
+ if(tagsTable == null || tagsTable.isDisposed() || tagsList == null) {
return;
}
/*
+ * Remember current selection index
+ * and restore it at the end.
+ */
+ int selectionIndex = tagsTable.getSelectionIndex();
+ /*
* Clear current visual table.
*/
if (clearTagsTable) {
tagsTable.clearAll();
+ tagsTable.update();
}
+ TableItem tableItem = null;
/*
- * Return when tags templates list hasn't been initialized.
+ * Sort the templates
*/
- if (tagsList == null) {
- return;
- }
- /*
- * Remember current selection index
- * and restore it at the end.
- */
- int selectionIndex = tagsTable.getSelectionIndex();
- TableItem tableItem = null;
+ Collections.sort(tagsList, new Comparator<VpeAnyData>() {
+ public int compare(VpeAnyData o1, VpeAnyData o2) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+ });
for (int i = 0; i < tagsList.size(); i++) {
if(tagsTable.getItemCount() > i) {
/*
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-07-20 13:45:50 UTC (rev 23594)
@@ -91,6 +91,8 @@
public static String TemplatesPreferencePage_Add;
public static String TemplatesPreferencePage_Edit;
public static String TemplatesPreferencePage_Remove;
+ public static String TemplatesPreferencePage_Export;
+ public static String TemplatesPreferencePage_Import;
public static String TemplatesTableProvider_Children;
public static String TemplatesTableProvider_No;
public static String TemplatesTableProvider_TagForDisplay;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-07-20 13:24:47 UTC (rev 23593)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-07-20 13:45:50 UTC (rev 23594)
@@ -70,9 +70,11 @@
MenuCreationHelper_Paste=Paste
MenuCreationHelper_Test=Test
SelectionBar_MoreNodes=More Nodes...
-TemplatesPreferencePage_Add=Add
-TemplatesPreferencePage_Edit=Edit
+TemplatesPreferencePage_Add=Add...
+TemplatesPreferencePage_Edit=Edit...
TemplatesPreferencePage_Remove=Remove
+TemplatesPreferencePage_Export=Export...
+TemplatesPreferencePage_Import=Import...
TemplatesTableProvider_Children=Children
TemplatesTableProvider_No=no
TemplatesTableProvider_TagForDisplay=Tag for Display
15 years, 9 months
JBoss Tools SVN: r23593 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 09:24:47 -0400 (Tue, 20 Jul 2010)
New Revision: 23593
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
Log:
https://jira.jboss.org/browse/JBIDE-6643
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-07-20 13:13:30 UTC (rev 23592)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-07-20 13:24:47 UTC (rev 23593)
@@ -94,7 +94,7 @@
ILLEGAL_INJECTING_USERTRANSACTION_TYPE=Java EE component class has an injection point of type UserTransaction and qualifier @Default, and may not validly make use of the JTA UserTransaction according to the Java EE platform specification
ILLEGAL_INJECTING_INJECTIONPOINT_TYPE=Java EE component class supporting injection that is not a bean has an injection point of type InjectionPoint and qualifier @Default
-ILLEGAL_QUALIFIER_IN_STEREOTYPE=Stereotype declares any qualifier annotation other than @Named
+ILLEGAL_QUALIFIER_IN_STEREOTYPE=Stereotypes cannot declare qualifier annotations (except @Named)
#Messages for Progress Monitor
SEARCHING_RESOURCES=project "{0}"; searching resources for validation (CDI Validator).
15 years, 9 months
JBoss Tools SVN: r23592 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: resources/tck/tests/jbt/validation/annotations and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-07-20 09:13:30 -0400 (Tue, 20 Jul 2010)
New Revision: 23592
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6637
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java 2010-07-20 13:13:30 UTC (rev 23592)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.annotations.qualifier.broken;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Documented
+@Qualifier
+@Inherited
+@interface Hairy_MissingRetention
+{
+
+ public boolean clipped();
+
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java 2010-07-20 13:13:30 UTC (rev 23592)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.annotations.qualifier.broken;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+@Inherited
+@interface Hairy_MissingTarget
+{
+
+ public boolean clipped();
+
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java 2010-07-20 13:13:30 UTC (rev 23592)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.validation.annotations.qualifier.broken;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+@Inherited
+@interface Hairy_WrongTarget
+{
+
+ public boolean clipped();
+
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-07-20 13:07:57 UTC (rev 23591)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-07-20 13:13:30 UTC (rev 23592)
@@ -1391,6 +1391,21 @@
assertMarkerIsCreated(file, CDIValidationMessages.OBSERVER_IN_DECORATOR, 14);
}
+ public void testQualifierWithMissingTarget() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java");
+ assertMarkerIsCreated(file, CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE.substring(0, 56) + ".*", 36);
+ }
+
+ public void testQualifierWithMissingRetention() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingRetention.java");
+ assertMarkerIsCreated(file, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE, 36);
+ }
+
+ public void testQualifierWithWrongTarget() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_WrongTarget.java");
+ assertMarkerIsCreated(file, CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE.substring(0, 56) + ".*", 32);
+ }
+
/**
* 10.4.3. Conditional observer methods
* - bean with scope @Dependent has an observer method declared notifyObserver=IF_EXISTS
@@ -1423,6 +1438,7 @@
}
private static String convertMessageToPatern(String message) {
- return message.replace("[", "\\[").replace("]", "\\]").replace("<", "\\<").replace(">", "\\>").replace("(", "\\(").replace(")", "\\)");
+ return message.replace("[", "\\[").replace("]", "\\]").replace("<", "\\<").replace(">", "\\>").replace("(", "\\(").replace(")", "\\)")
+ .replace("{", "\\{").replace("}", "\\}").replace("'", "\\'");
}
}
\ No newline at end of file
15 years, 9 months