[jbosstools-commits] JBoss Tools SVN: r23594 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/preferences and 3 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 20 09:45:51 EDT 2010
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
More information about the jbosstools-commits
mailing list