Author: dmaliarevich
Date: 2010-01-15 11:17:29 -0500 (Fri, 15 Jan 2010)
New Revision: 19778
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/VpeTemplateData.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/ImportUnknownTagsTemplatesWizardPage.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 wizards were updated.
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-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAnyData.java 2010-01-15
16:17:29 UTC (rev 19778)
@@ -85,4 +85,51 @@
this.style = style;
}
+
+ @Override
+ public String toString() {
+ return "VpeAnyData [name=" + super.getName() + ", uri=" + uri
//$NON-NLS-1$ //$NON-NLS-2$
+ + ", tagForDisplay=" + tagForDisplay + ", value=" + value
//$NON-NLS-1$ //$NON-NLS-2$
+ + ", style=" + style + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((tagForDisplay == null) ? 0 : tagForDisplay.hashCode());
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ VpeAnyData other = (VpeAnyData) obj;
+ if (tagForDisplay == null) {
+ if (other.tagForDisplay != null) {
+ return false;
+ }
+ } else if (!tagForDisplay.equals(other.tagForDisplay)) {
+ return false;
+ }
+ if (uri == null) {
+ if (other.uri != null) {
+ return false;
+ }
+ } else if (!uri.equals(other.uri)) {
+ return false;
+ }
+ return true;
+ }
+
}
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-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateData.java 2010-01-15
16:17:29 UTC (rev 19778)
@@ -76,4 +76,42 @@
}
return null;
}
+
+ @Override
+ public String toString() {
+ return "VpeTemplateData [caseSensitive=" + caseSensitive + ",
changed=" //$NON-NLS-1$ //$NON-NLS-2$
+ + changed + ", children=" + children + ", modify=" + modify
//$NON-NLS-1$ //$NON-NLS-2$
+ + ", name=" + name + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ VpeTemplateData other = (VpeTemplateData) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
}
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-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ExportUnknownTagsTemplatesWizardPage.java 2010-01-15
16:17:29 UTC (rev 19778)
@@ -47,6 +47,7 @@
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;
@@ -58,21 +59,17 @@
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
+ 50, 50, 90, 40
};
private String pathString;
private Table tagsTable;
-// private TableViewer tableViewer;
private List<VpeAnyData> tagsList;
- private Button selectAllButton;
- private Button deselectAllButton;
/**
* Constructor
@@ -109,11 +106,10 @@
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.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
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
*/
@@ -128,44 +124,12 @@
* 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.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
pathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
pathString = ((Text)e.getSource()).getText();
@@ -175,7 +139,7 @@
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.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
@@ -227,29 +191,19 @@
}
/*
* 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++) {
+ for (int j = 0; j < itemColumnsData.length; j++) {
/*
* Getting values from tagList
*/
- itemColumnsData[j] = toVisualValue(getValueAt(i, (j-1)));
+ itemColumnsData[j] = toVisualValue(getValueAt(i, j));
}
/*
* 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);
+
}
/*
@@ -301,23 +255,9 @@
}
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
- */
-
- }
+ /*
+ * Do nothing
+ */
}
@Override
@@ -326,7 +266,7 @@
* Later page should be complete some tags are selected.
*/
boolean isPageComplete = false;
- if ((pathString != null) && !"".equalsIgnoreCase(pathString)) {
//$NON-NLS-1$
+ if ((pathString != null) && !Constants.EMPTY.equalsIgnoreCase(pathString)) {
isPageComplete = true;
}
return isPageComplete;
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-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/wizards/ImportUnknownTagsTemplatesWizardPage.java 2010-01-15
16:17:29 UTC (rev 19778)
@@ -11,9 +11,9 @@
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;
@@ -39,8 +39,10 @@
import org.eclipse.swt.widgets.Widget;
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;
@@ -54,21 +56,17 @@
WizardResourceImportPage {
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
+ 50, 50, 90, 40
};
private String pathString;
private Table tagsTable;
-// private TableViewer tableViewer;
private List<VpeAnyData> tagsList;
- private Button selectAllButton;
- private Button deselectAllButton;
/**
@@ -104,7 +102,7 @@
*/
final Text pathText = new Text(composite, SWT.BORDER);
pathText.setEditable(false);
- pathText.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
+ pathText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
pathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
pathString = ((Text)e.getSource()).getText();
@@ -114,7 +112,7 @@
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.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(PlatformUI.getWorkbench()
@@ -133,10 +131,6 @@
*/
updateTagsTable();
/*
- * Store loaded templates to the default auto-templates location.
- */
- VpeTemplateManager.getInstance().setAnyTemplates(tagsList);
- /*
* Check if the page is complete.
*/
setPageComplete(isPageComplete());
@@ -150,7 +144,7 @@
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.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
tagsTable.setHeaderVisible(true);
tagsTable.setLinesVisible(true);
@@ -166,25 +160,6 @@
}
/*
- * 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);
-
- /*
- * 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);
-
- /*
* Finishing the initialization
*/
setErrorMessage(null); // should not initially have error message
@@ -212,29 +187,18 @@
}
/*
* 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++) {
+ for (int j = 0; j < itemColumnsData.length; j++) {
/*
* Getting values from tagList
*/
- itemColumnsData[j] = toVisualValue(getValueAt(i, (j-1)));
+ itemColumnsData[j] = toVisualValue(getValueAt(i, j));
}
/*
* 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);
}
/*
@@ -285,33 +249,13 @@
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$
+ if ((pathString != null) && !Constants.EMPTY.equalsIgnoreCase(pathString)) {
isPageComplete = true;
}
return isPageComplete;
@@ -319,9 +263,28 @@
public boolean finish() {
- List<VpeAnyData> templates =
VpeTemplateManager.getInstance().getAnyTemplates();
- IPath path = new Path(pathString);
- VpeTemplateManager.getInstance().setAnyTemplates(templates, path);
+ /*
+ * Currently used templates list
+ */
+ List<VpeAnyData> currentList =
VpeTemplateManager.getInstance().getAnyTemplates();
+
+ Iterator<VpeAnyData> iterator = tagsList.iterator();
+ while (iterator.hasNext()) {
+ VpeAnyData loadedTemplate = (VpeAnyData) iterator.next();
+ for (VpeAnyData currentTemplate : currentList) {
+ if (loadedTemplate.equals(currentTemplate)) {
+ iterator.remove();
+ }
+ }
+ }
+ /*
+ * Store loaded templates to the default auto-templates location.
+ */
+ if (currentList.addAll(tagsList)) {
+ VpeTemplateManager.getInstance().setAnyTemplates(currentList);
+ } else {
+ VpePlugin.getDefault().logError(VpeUIMessages.ERROR_ON_IMPORT_TAG_TEMPLATES);
+ }
return true;
}
@@ -342,6 +305,4 @@
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 2010-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-01-15
16:17:29 UTC (rev 19778)
@@ -151,5 +151,6 @@
public static String SELECT_ALL;
public static String DESELECT_ALL;
public static String BROWSE_BUTTON_TEXT;
+ public static String ERROR_ON_IMPORT_TAG_TEMPLATES;
}
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-01-15
16:08:11 UTC (rev 19777)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-01-15
16:17:29 UTC (rev 19778)
@@ -137,4 +137,5 @@
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
+IMPORT_UNKNOWN_TAGS_PAGE_DESCRIPTION=Import unknown tags templates from external file
+ERROR_ON_IMPORT_TAG_TEMPLATES=Error while importing unknown tag templates.
\ No newline at end of file