Author: dmaliarevich
Date: 2009-12-18 14:59:06 -0500 (Fri, 18 Dec 2009)
New Revision: 19477
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/
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
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XTable.java
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties
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/VpeTemplateManager.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/jira/browse/JBIDE-2795, import/export unknown tags templates
wizards were started.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XTable.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XTable.java 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XTable.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -88,7 +88,7 @@
for (int i = 0; i < k; i++) {
TableColumn c = new TableColumn(table, SWT.NONE);
c.setText(provider.getColumnName(i));
- layoutData = new ColumnWeightData(widths[i], Boolean.TRUE.booleanValue());
+ layoutData = new ColumnWeightData(widths[i], true);
layout.addColumnData(layoutData);
}
table.setHeaderVisible(isHeaderVisible);
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -107,7 +107,7 @@
String s = null;
/*
*
https://jira.jboss.org/jira/browse/JBIDE-3211
- * Storing project preferences to project scope in .settings
+ * Reading preferences from project scope from .settings
*/
IScopeContext projectScope = new ProjectScope(resource.getProject());
IEclipsePreferences root = projectScope
@@ -123,30 +123,30 @@
s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
}
}
- if (s == null || s.length() == 0) {
- /*
- * Old preferences format property value.
- */
- String old = null;
- try {
- old = resource.getPersistentProperty(getPropertyName());
- } catch (CoreException e) {
+ if (s == null || s.length() == 0) {
/*
- * Ignore, there is no properties for this resource.
+ * Old preferences format property value.
*/
- }
- if (old == null || old.length() == 0) {
- return new String[0];
+ String old = null;
+ try {
+ old = resource.getPersistentProperty(getPropertyName());
+ } catch (CoreException e) {
+ /*
+ * Ignore, there is no properties for this resource.
+ */
+ }
+ if (old == null || old.length() == 0) {
+ return new String[0];
+ } else {
+ /*
+ * If there is property stored in the old preferences format
+ * return this value.
+ */
+ return decodeResourceString(old);
+ }
} else {
- /*
- * If there is property stored in the old preferences format
- * return this value.
- */
- return decodeResourceString(old);
+ return decodeResourceString(s);
}
- } else {
- return decodeResourceString(s);
- }
}
//Fix for JBIDE-2979
@@ -193,8 +193,8 @@
private boolean setDeclaredResources(IResource resource, ResourceReference[] entries,
int scope, int depth) {
/*
- *
https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
- * Reading preferences from project scope from .settings
+ *
https://jira.jboss.org/jira/browse/JBIDE-3211
+ * Storing project preferences to project scope in .settings
*/
IScopeContext projectScope = new ProjectScope(resource.getProject());
IEclipsePreferences root = projectScope
@@ -256,47 +256,47 @@
TreeMap allExternalResources = null;
private TreeMap getAllExternalResources() {
- if (allExternalResources == null) {
- allExternalResources = new TreeMap();
- /*
- * Property value
- */
- String s = null;
-
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
- * Reading global preferences from instance scope.
- */
- IScopeContext instanceContext = new InstanceScope();
- Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
- if (null != root) {
- Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
- s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
- }
- /*
- * If there is property stored in the old preferences format
- * and there are no other properties old value will be returned
- */
- if (s != null && s.length() > 0) {
- parseExternalResources(s);
- } else {
- /*
- * Old preferences format property value.
- */
- String old = null;
- try {
- old = ModelPlugin.getWorkspace().getRoot().getPersistentProperty(getPropertyName());
- } catch (CoreException e) {
+ if (allExternalResources == null) {
+ allExternalResources = new TreeMap();
/*
- * Ignore, there is no properties for this resource.
+ * Property value
*/
- }
- if (old != null && old.length() > 0) {
- parseExternalResources(old);
- }
+ String s = null;
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-3211
+ * Reading global preferences from instance scope.
+ */
+ IScopeContext instanceContext = new InstanceScope();
+ Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
+ if (null != root) {
+ Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
+ s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
+ }
+ /*
+ * If there is property stored in the old preferences format and
+ * there are no other properties old value will be returned
+ */
+ if (s != null && s.length() > 0) {
+ parseExternalResources(s);
+ } else {
+ /*
+ * Old preferences format property value.
+ */
+ String old = null;
+ try {
+ old = ModelPlugin.getWorkspace().getRoot()
+ .getPersistentProperty(getPropertyName());
+ } catch (CoreException e) {
+ /*
+ * Ignore, there is no properties for this resource.
+ */
+ }
+ if (old != null && old.length() > 0) {
+ parseExternalResources(old);
+ }
+ }
}
- }
- return allExternalResources;
+ return allExternalResources;
}
private void parseExternalResources(String s) {
@@ -313,34 +313,34 @@
}
private void setAllExternalResources() {
- StringBuffer sb = new StringBuffer();
- Iterator it = allExternalResources.keySet().iterator();
- while (it.hasNext()) {
- String path = it.next().toString();
- String list = (String) allExternalResources.get(path);
- if (path != null && list != null && new File(path).exists()) {
- if (sb.length() > 0)
- sb.append('#');
- sb.append(path).append('=').append(list);
+ StringBuffer sb = new StringBuffer();
+ Iterator it = allExternalResources.keySet().iterator();
+ while (it.hasNext()) {
+ String path = it.next().toString();
+ String list = (String) allExternalResources.get(path);
+ if (path != null && list != null && new File(path).exists()) {
+ if (sb.length() > 0)
+ sb.append('#');
+ sb.append(path).append('=').append(list);
+ }
}
- }
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
- * Storing global preferences to instance scope to
- * ${workspace}\.metadata\.plugins\org.eclipse.core.runtime\
- * .settings\org.jboss.tools.common.model.prefs
- */
- IScopeContext instanceContext = new InstanceScope();
- Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
- if (null != root) {
- Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
- node.put(getPropertyName().getLocalName(), sb.toString());
- try {
- root.flush();
- } catch (BackingStoreException e) {
- ResourceReferencePlugin.getPluginLog().logError(e);
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-3211
+ * Storing global preferences to instance scope to
+ * ${workspace}\.metadata\.plugins\org.eclipse.core.runtime\
+ * .settings\org.jboss.tools.common.model.prefs
+ */
+ IScopeContext instanceContext = new InstanceScope();
+ Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
+ if (null != root) {
+ Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
+ node.put(getPropertyName().getLocalName(), sb.toString());
+ try {
+ root.flush();
+ } catch (BackingStoreException e) {
+ ResourceReferencePlugin.getPluginLog().logError(e);
+ }
}
- }
}
public ResourceReference[] getAllResources(IPath path) {
@@ -393,12 +393,16 @@
int checkScope = path.equals(Platform.getLocation()) ? ResourceReference.GLOBAL_SCOPE :
ResourceReference.FILE_SCOPE;
b = setDeclaredResources(path, entries, checkScope, 0);
- if(b) changed = path;
+ if(b) {
+ changed = path;
+ }
IPath parent = path.removeLastSegments(1);
int depth = 0;
while(parent != null && parent.segmentCount() > 1) {
b = setDeclaredResources(parent, entries, ResourceReference.FOLDER_SCOPE, depth);
- if(b) changed = parent;
+ if(b) {
+ changed = parent;
+ }
parent = parent.removeLastSegments(1);
depth++;
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties 2009-12-18 18:39:49 UTC (rev
19476)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties 2009-12-18 19:59:06 UTC (rev
19477)
@@ -9,3 +9,7 @@
PreferencePage_ElVariables=El Variables
visualEditorImpl_name=XulRunner Visual Editor
PreferencePage_VpeEditor=Visual Page Editor
+exportUnknownTagsTemplatesWizardName=Export unknown tags templates wizard
+exportUnknownTagsTemplatesWizardDescription=Export unknown tags templates to the external
file
+importUnknownTagsTemplatesWizardName=Import unknown tags templates wizard
+importUnknownTagsTemplatesWizardDescription=Import unknown tags templates from the
external file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2009-12-18 18:39:49 UTC (rev 19476)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2009-12-18 19:59:06 UTC (rev 19477)
@@ -121,4 +121,32 @@
</dynamic>
</menuContribution>
</extension>
+
+ <extension
+ point="org.eclipse.ui.exportWizards">
+ <wizard
+
id="org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesWizard"
+
class="org.jboss.tools.vpe.editor.wizards.ExportUnknownTagsTemplatesWizard"
+ name="%exportUnknownTagsTemplatesWizardName"
+ icon="icons/">
+ <description>
+ %exportUnknownTagsTemplatesWizardDescription
+ </description>
+ </wizard>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <wizard
+
id="org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesWizard"
+
class="org.jboss.tools.vpe.editor.wizards.ImportUnknownTagsTemplatesWizard"
+ name="%importUnknownTagsTemplatesWizardName"
+ icon="icons/">
+ <description>
+ %importUnknownTagsTemplatesWizardDescription
+ </description>
+ </wizard>
+ </extension>
+
+
</plugin>
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 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/TemplatesPreferencePage.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -30,7 +30,8 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.messages.VpeUIMessages;
-public class TemplatesPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage, CommandBarListener {
+public class TemplatesPreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage, CommandBarListener {
static String EDIT = VpeUIMessages.TemplatesPreferencePage_Edit;
static String REMOVE = VpeUIMessages.TemplatesPreferencePage_Remove;
protected TemplatesTableProvider tableProvider;// = new TemplatesTableProvider();
@@ -40,7 +41,8 @@
protected boolean changed;
public TemplatesPreferencePage() {
- noDefaultAndApplyButton();
+// noDefaultAndApplyButton();
+ setPreferenceStore(getPreferenceStore());
init();
}
@@ -95,7 +97,9 @@
update();
}
public boolean performOk() {
- if(changed)VpeTemplateManager.getInstance().setAnyTemplates(dataList);
+ if(changed) {
+ VpeTemplateManager.getInstance().setAnyTemplates(dataList);
+ }
return super.performOk();
}
@@ -103,7 +107,9 @@
VpeAnyData data = (VpeAnyData)dataList.get(index);
VpeEditAnyDialog editDialog = new VpeEditAnyDialog(getShell(), data);
editDialog.open();
- if(data.isChanged()) changed = true;
+ if(data.isChanged()){
+ changed = true;
+ }
}
void remove(int index) {
@@ -112,7 +118,9 @@
}
public void update() {
- if(table != null) table.update();
+ if(table != null){
+ table.update();
+ }
updateBars();
}
@@ -122,6 +130,7 @@
}
private boolean canModify() {
- return table.getSelectionIndex() >= 0;
+ return (table.getSelectionIndex() >= 0);
}
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -53,7 +53,8 @@
= "templates/vpe-templates-auto.xml"; //$NON-NLS-1$
static final String TEMPLATES_FOLDER = File.separator + "templates" +
File.separator; //$NON-NLS-1$
public static final String VPE_PREFIX = "vpe:"; //$NON-NLS-1$
-
+ public static final String TAG_TEMPLATES = VPE_PREFIX + "templates";
//$NON-NLS-1$
+
static final String TAG_LIST = VPE_PREFIX + "list"; //$NON-NLS-1$
static final String ATTR_LIST_ORDERED = "ordered"; //$NON-NLS-1$
static final String[] ATTR_LIST_PROPERTIES = {
@@ -82,7 +83,6 @@
};
static final String TAG_TEMPLATES_LIST = VPE_PREFIX + "templates-list";
//$NON-NLS-1$
- static final String TAG_TEMPLATES = VPE_PREFIX + "templates"; //$NON-NLS-1$
static final String TAG_TEMPLATE_TAGLIB = VPE_PREFIX + "template-taglib";
//$NON-NLS-1$
static final String TAG_TAG = VPE_PREFIX + "tag"; //$NON-NLS-1$
static final String TAG_IF = VPE_PREFIX + "if"; //$NON-NLS-1$
@@ -768,13 +768,12 @@
return null;
}
-
- public void setAnyTemplates(List<VpeAnyData> templates) {
+ public void setAnyTemplates(List<VpeAnyData> templates, IPath path) {
if (templates != null) {
Set<String> prefixSet = new HashSet<String>();
Element root = XMLUtilities.createDocumentElement(TAG_TEMPLATES);
Document document = root.getOwnerDocument();
-
+
for (Iterator<VpeAnyData> iter = templates.iterator(); iter.hasNext();) {
VpeAnyData data = iter.next();
root.appendChild(createNewTagElement(document, data));
@@ -784,9 +783,8 @@
prefixSet.add(prefix);
}
}
-
+
try {
- IPath path = getAutoTemplates();
// fixed bug [EFWPE-869] - uncomment this line
XMLUtilities.serialize(root, path.toOSString());
} catch(IOException e) {
@@ -794,6 +792,16 @@
}
}
}
+
+ public void setAnyTemplates(List<VpeAnyData> templates) {
+ IPath path;
+ try {
+ path = getAutoTemplates();
+ setAnyTemplates(templates, path);
+ } catch (IOException e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
static public Element createNewTagElement(Document document, VpeAnyData data) {
Element newTagElement = document.createElement(TAG_TAG);
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizard.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -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 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();
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * 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.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+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.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+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.messages.VpeUIMessages;
+import org.jboss.tools.vpe.resref.core.ReferenceWizardPage;
+
+/**
+ * Page for exporting unknown tags templates.
+ *
+ * @author dmaliarevich
+ */
+public class ExportUnknownTagsTemplatesWizardPage extends WizardExportResourcesPage {
+
+ private static final String[] COLUMNS_NAMES = new String[] {
+ "", //$NON-NLS-1$
+ VpeUIMessages.TemplatesTableProvider_TagName,
+ VpeUIMessages.TemplatesTableProvider_TagForDisplay,
+ VpeUIMessages.TemplatesTableProvider_URI,
+ VpeUIMessages.TemplatesTableProvider_Children};
+ private static final int[] COLUMNS_WIDTHS = new int[] {
+ 15, 50, 50, 90, 30
+ };
+
+ private String pathString;
+ private Table tagsTable;
+// private TableViewer tableViewer;
+ private List<VpeAnyData> tagsList;
+ private Button selectAllButton;
+ private Button deselectAllButton;
+
+ /**
+ * 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(2, 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, 1, 2));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+// tableViewer = new TableViewer(tagsTable, SWT.MULTI | SWT.H_SCROLL
+// | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ /*
+ * 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
+ */
+ updateTagsTable();
+ /*
+ * Adding checkbox to the first column
+ */
+// CellEditor[] cellEditors = { new CheckboxCellEditor(tagsTable),
+// new TextCellEditor(tagsTable), new TextCellEditor(tagsTable),
+// new TextCellEditor(tagsTable), new TextCellEditor(tagsTable) };
+// tableViewer.setCellEditors(cellEditors);
+// tableViewer.refresh();
+
+ /*
+ * Add buttons
+ */
+ selectAllButton = new Button(composite, SWT.NONE);
+ selectAllButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
+ selectAllButton.setText(VpeUIMessages.SELECT_ALL);
+
+ deselectAllButton = new Button(composite, SWT.NONE);
+ deselectAllButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
+ deselectAllButton.setText(VpeUIMessages.DESELECT_ALL);
+
+ /*
+ * Make buttons equal size
+ */
+// selectAllButton.setSize(deselectAllButton.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ /*
+ * Adding event listeners to the buttons
+ */
+ selectAllButton.addListener(SWT.Modify, this);
+ selectAllButton.addListener(SWT.Selection, this);
+ deselectAllButton.addListener(SWT.Modify, this);
+ deselectAllButton.addListener(SWT.Selection, this);
+
+ /*
+ * Add path output and browse button
+ */
+ final Text pathText = new Text(composite, SWT.BORDER);
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
+ pathText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ pathString = ((Text)e.getSource()).getText();
+ setPageComplete(isPageComplete());
+ }
+ });
+
+ Button browseButton = new Button(composite, SWT.NONE);
+ browseButton.setText(VpeUIMessages.BROWSE_BUTTON_TEXT);
+ browseButton.setLayoutData(new GridData(SWT.NONE, SWT.NONE, 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();
+ pathText.setText(pathString);
+ setPageComplete(isPageComplete());
+ }
+ }
+ });
+
+ /*
+ * Finishing the initialization
+ */
+ updateWidgetEnablements();
+ setPageComplete(determinePageCompletion());
+ setErrorMessage(null); // should not initially have error message
+
+ setControl(composite);
+ }
+
+ @Override
+ protected void createDestinationGroup(Composite parent) {
+ /*
+ * Create nothing
+ */
+ }
+
+ private void updateTagsTable() {
+ if(tagsTable == null || tagsTable.isDisposed()) {
+ return;
+ }
+ int selectionIndex = tagsTable.getSelectionIndex();
+ TableItem tableItem = null;
+ 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 5 columns with checkbox in the first column.
+ */
+ String[] itemColumnsData = new String[tagsTable.getColumnCount()];
+ itemColumnsData[0] = ""; //$NON-NLS-1$
+ for (int j = 1; j < itemColumnsData.length; j++) {
+ /*
+ * Getting values from tagList
+ */
+ itemColumnsData[j] = toVisualValue(getValueAt(i, (j-1)));
+ }
+ /*
+ * Set cells text
+ */
+ tableItem.setText(itemColumnsData);
+ /*
+ * Adding checkbox to the first column
+ */
+// TableEditor editor = new TableEditor(tagsTable);
+// Button check = new Button(tagsTable, SWT.CHECK);
+// check.setBackground(tagsTable.getBackground());
+// editor.minimumWidth = check.getSize().x;
+// editor.grabHorizontal = true;
+// editor.setEditor(check, tableItem, 0);
+ }
+
+ /*
+ * 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;
+ if (source == selectAllButton) {
+ /*
+ * Handle select all event
+ */
+
+ } else if (source == deselectAllButton) {
+ /*
+ * Handle deselect all event
+ */
+
+ } else {
+ /*
+ * Handle chekbox event
+ */
+
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ /*
+ * Later page should be complete some tags are selected.
+ */
+ boolean isPageComplete = false;
+ if ((pathString != null) && !"".equalsIgnoreCase(pathString)) {
//$NON-NLS-1$
+ 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;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizard.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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() {
+
+ }
+
+ 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 false;
+ }
+
+ @Override
+ public boolean performFinish() {
+ return false;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.viewers.ITreeContentProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardResourceImportPage;
+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 {
+
+ /**
+ * 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
+ 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/messages/VpeUIMessages.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-12-18
19:59:06 UTC (rev 19477)
@@ -138,4 +138,14 @@
public static String VISUAL_APPEARANCE_GROUP_TITLE;
public static String CONFIRMATION_GROUP_TITLE;
public static String TABS_GROUP_TITLE;
+ public static String IMPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE;
+ public static String EXPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE;
+ public static String EXPORT_UNKNOWN_TAGS_PAGE_TITLE;
+ public static String EXPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION;
+ public static String IMPORT_UNKNOWN_TAGS_PAGE_TITLE;
+ public static String IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION;
+ public static String SELECT_ALL;
+ public static String DESELECT_ALL;
+ public static String BROWSE_BUTTON_TEXT;
+
}
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 2009-12-18
18:39:49 UTC (rev 19476)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-12-18
19:59:06 UTC (rev 19477)
@@ -119,4 +119,15 @@
SPLITTING_VERT_TOP_SOURCE=Vertical splitting with Source Editor on the top
SPLITTING_VERT_TOP_VISUAL=Vertical splitting with Visual Editor on the top
SPLITTING_HORIZ_LEFT_SOURCE=Horizontal splitting with Source Editor to the left
-SPLITTING_HORIZ_LEFT_VISUAL=Horizontal splitting with Visual Editor to the left
\ No newline at end of file
+SPLITTING_HORIZ_LEFT_VISUAL=Horizontal splitting with Visual Editor to the left
+
+# Import/Export Unknown Tags Templates Messages
+IMPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE=Import unknown tags templates wizard page
+EXPORT_UNKNOWN_TAGS_TEMPLATES_WIZARD_PAGE=Export unknown tags templates wizard page
+SELECT_ALL=Select All
+DESELECT_ALL=Deselect All
+BROWSE_BUTTON_TEXT=Browse...
+EXPORT_UNKNOWN_TAGS_PAGE_TITLE=Export unknown tags templates wizard
+EXPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION=Export unknown tags templates to external file
+IMPORT_UNKNOWN_TAGS_PAGE_TITLE=Import unknown tags templates wizard
+IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION=Import unknown tags templates from external file
\ No newline at end of file