Author: mareshkau
Date: 2010-10-05 11:35:02 -0400 (Tue, 05 Oct 2010)
New Revision: 25494
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/icons/externalize.png
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/externalize.png
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/JavaSource/demo/Messages_en_US.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
Log:
https://jira.jboss.org/browse/JBIDE-7060
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -15,7 +15,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -38,7 +38,7 @@
* Returns the locale for given {@code editor}, or {@code null} if it
* can not determine it.
*/
- public Locale getLocale(StructuredTextEditor editor) {
+ public Locale getLocale(ITextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IProject project = ((IFileEditorInput)editorInput)
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/JavaSource/demo/Messages_en_US.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/JavaSource/demo/Messages_en_US.properties 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/JavaSource/demo/Messages_en_US.properties 2010-10-05
15:35:02 UTC (rev 25494)
@@ -1,3 +1,5 @@
header=US Hello Demo Application
prompt_message=US Name:
hello_message=US Hello
+
+Resource_Test_Page=Resource Test Page
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/icons/externalize.png
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/icons/externalize.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2010-10-05 15:23:45 UTC
(rev 25493)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2010-10-05 15:35:02 UTC
(rev 25494)
@@ -16,6 +16,6 @@
proposalCategory.xmlEL= JBoss JSF/SEAM EL Proposals
proposalCategory.xmlTag= JBoss JSF/SEAM Tag Proposals
-Show.Selection.Bar=Show Selection Bar
Toggle.Selection.Bar=Toggle Selection Bar
+Externalize.Selected.Property=Externalize Strings...
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-10-05 15:23:45 UTC (rev
25493)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-10-05 15:35:02 UTC (rev
25494)
@@ -308,7 +308,7 @@
</menuContribution>
<menuContribution
locationURI="menu:navigate?endof=show.ext">
- <command label="%Show.Selection.Bar"
+ <command label="%Toggle.Selection.Bar"
commandId="org.jboss.tools.jst.jsp.commands.showSelectionBar"
id="org.jboss.tools.jst.jsp.menus.showSelectionBar"
style="toggle"
@@ -346,6 +346,32 @@
id="org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem">
</dynamic>
</menuContribution>
+ <menuContribution
+ locationURI="menu:sourceMenuId?after=OccurencesFile">
+ <command label="%Externalize.Selected.Property"
+ commandId="org.jboss.tools.jst.jsp.commands.i18"
+ id="org.jboss.tools.jst.jsp.menus.i18"
+ mnemonic="S">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+ <toolbar
+ id="org.jboss.tools.jst.jsp.toolbars.sampleToolbar">
+ <command
+ commandId="org.jboss.tools.jst.jsp.commands.i18"
+ icon="icons/externalize.png"
+ id="org.jboss.tools.jst.jsp.toolbars.i18"
+ tooltip="%Externalize.Selected.Property">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
+ </visibleWhen>
+ </command>
+ </toolbar>
+ </menuContribution>
</extension>
@@ -456,6 +482,10 @@
<reference
definitionId="org.jboss.tools.ui.structuredEditor"/>
</enabledWhen>
</handler>
+ <handler
+ class="org.jboss.tools.jst.jsp.i18n.handlers.I18Handler"
+ commandId="org.jboss.tools.jst.jsp.commands.i18">
+ </handler>
</extension>
<extension point="org.eclipse.core.expressions.definitions">
@@ -722,6 +752,11 @@
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
+ <command
+ categoryId="org.jboss.tools.jst.jsp.commands.category"
+ id="org.jboss.tools.jst.jsp.commands.i18"
+ name="%Externalize.Selected.Property">
+ </command>
</extension>
<extension
point="org.eclipse.ui.bindings">
@@ -737,6 +772,12 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+6">
</key>
+ <key
+ commandId="org.jboss.tools.jst.jsp.commands.i18"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+7">
+ </key>
</extension>
<extension
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -34,6 +34,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
import org.jboss.tools.common.el.core.model.ELExpression;
@@ -64,7 +65,7 @@
};
private BundleMapListener[] bundleMapListeners = new BundleMapListener[0];
- private StructuredTextEditor editor;
+ private ITextEditor editor;
private String[] javaSources;
/*
@@ -79,7 +80,7 @@
XModelTreeListener modelListener = new ML();
- public void init(StructuredTextEditor editor){
+ public void init(ITextEditor editor){
this.editor = editor;
IEditorInput input = editor.getEditorInput();
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 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.jst.jsp.i18n;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-
-public class ExternalizeStringsAction extends Action {
-
- private JSPMultiPageEditor editor;
-
- public ExternalizeStringsAction() {
- super();
- editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- }
-
- @Override
- public void run() {
- ISelection sel = editor.getSelectionProvider().getSelection();
-
- if ((sel instanceof TextSelection)
- && (sel instanceof IStructuredSelection)
- && (((IStructuredSelection) sel).size() == 1)) {
- /*
- * Pass null for Bundle Map that it will be created by the page itself.
- */
- ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- new ExternalizeStringsWizard(editor.getSourceEditor(), null));
- dlg.open();
- } else {
- MessageDialog.openWarning(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
- JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION);
- }
- }
-
-}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 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.jst.jsp.i18n;
-
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.swt.widgets.Menu;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-
-public class ExternalizeStringsContributionItem extends ActionContributionItem {
-
- /**
- * Instantiates a new externalize strings contribution item.
- * Default constructor is used to create
- * source editor context menu from plugin.xml
- */
- public ExternalizeStringsContributionItem() {
- super(new ExternalizeStringsAction());
- }
-
- @Override
- public void fill(Menu parent, int index) {
- /*
- * Simply sets the title
- */
- getAction().setText(JstUIMessages.EXTERNALIZE_STRINGS);
- super.fill(parent, index);
- }
-
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -19,7 +19,7 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -29,12 +29,12 @@
public String ExternalizeStringsWizardPageName =
"ExternalizeStringsWizardPage"; //$NON-NLS-1$
public String NewFileCreationPageName = "NewFileCreationPage"; //$NON-NLS-1$
- StructuredTextEditor editor = null;
+ ITextEditor editor = null;
BundleMap bm = null;
ExternalizeStringsWizardPage page1 = null;
WizardNewFileCreationPage page2 = null;
- public ExternalizeStringsWizard(StructuredTextEditor editor, BundleMap bm) {
+ public ExternalizeStringsWizard(ITextEditor editor, BundleMap bm) {
super();
setHelpAvailable(false);
setWindowTitle(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -59,8 +59,8 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
import org.eclipse.wst.xml.core.internal.document.NodeImpl;
@@ -97,7 +97,7 @@
private final char[] LINE_DELEMITERS = new char[] {'\r', '\n',
'\t'};
private final int DIALOG_WIDTH = 450;
private final int DIALOG_HEIGHT = 650;
- private StructuredTextEditor editor;
+ private ITextEditor editor;
private Text propsKey;
private Text propsValue;
private Button newFile;
@@ -113,7 +113,7 @@
private Table tagsTable;
- public ExternalizeStringsWizardPage(String pageName, StructuredTextEditor editor,
BundleMap bm) {
+ public ExternalizeStringsWizardPage(String pageName, ITextEditor editor, BundleMap bm)
{
/*
* Setting dialog Title, Description, Image.
*/
@@ -732,7 +732,7 @@
* @param editor the source editor
* @return the new bundle map
*/
- private BundleMap createBundleMap(StructuredTextEditor editor) {
+ private BundleMap createBundleMap(ITextEditor editor) {
String uri = null;
String prefix = null;
int hash;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -12,7 +12,7 @@
import java.util.Locale;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
/**
* This interface is intended for creation extensions of {@code localeProvider}
@@ -25,7 +25,7 @@
* Returns the locale for given {@code editor}. Implementations
* may return {@code null} if they can not determine the locale.
*/
- Locale getLocale(StructuredTextEditor editor);
+ Locale getLocale(ITextEditor editor);
/**
* Shows the string representation of the locale
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -17,19 +17,16 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
/**
@@ -77,7 +74,7 @@
* {@code localeProvider} extensions. Returns the default
* system locale if nothing found (never returns {@code null}).
*/
- public Locale getLocale(StructuredTextEditor editor) {
+ public Locale getLocale(ITextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IProject project = ((IFileEditorInput)editorInput)
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jst.jsp.i18n.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsDialog;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizard;
+import org.w3c.dom.Attr;
+
+/**
+ * Externalization command handler
+ * @author mareshkau
+ *
+ */
+public class I18Handler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ IEditorPart activeEditor= PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(activeEditor instanceof ITextEditor){
+ ITextEditor txtEditor = (ITextEditor) activeEditor;
+ ISelection selection = txtEditor.getSelectionProvider().getSelection();
+ return getExternalizeStringsCommandEnabled(selection);
+ }
+ return false;
+ }
+ /**
+ * Calculates the state of ext command
+ * @param selection
+ * @return
+ */
+ private static boolean getExternalizeStringsCommandEnabled(ISelection selection) {
+ boolean enabled=false;
+ String stringToUpdate = ""; //$NON-NLS-1$
+ if ((selection instanceof TextSelection)
+ && (selection instanceof IStructuredSelection)
+ && (((IStructuredSelection) selection).size() == 1)) {
+ String text = ""; //$NON-NLS-1$
+ TextSelection textSelection = null;
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ textSelection = (TextSelection) selection;
+ text = textSelection.getText();
+ Object selectedElement = structuredSelection.getFirstElement();
+ /*
+ * When selected text is empty parse selected element and find a
+ * string to replace..
+ */
+ if ((text.trim().length() == 0)) {
+ if (selectedElement instanceof org.w3c.dom.Text) {
+ /*
+ * ..it could be a plain text
+ */
+ org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
+ if (textNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = textNode.getNodeValue();
+ }
+ } else if (selectedElement instanceof Attr) {
+ /*
+ * ..or an attribute's value
+ */
+ Attr attrNode = (Attr) selectedElement;
+ if (attrNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = attrNode.getNodeValue();
+ }
+ }
+ } else {
+ stringToUpdate = text;
+ }
+ }
+ if ((stringToUpdate.length() > 0)) {
+ enabled=true;
+ }
+ return enabled;
+ }
+
+ /**
+ * the command has been executed, so extract extract the needed information
+ * from the application context.
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
+
+ if(activeEditor instanceof ITextEditor){
+ ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ new ExternalizeStringsWizard((ITextEditor)activeEditor,
+ null));
+ dlg.open();
+ }
+ return null;
+ }
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -10,10 +10,8 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.jspeditor;
-import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
-
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.SafeRunnable;
@@ -28,7 +26,6 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Item;
@@ -39,6 +36,7 @@
import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.INestableKeyBindingService;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
@@ -59,6 +57,7 @@
private ArrayList nestedEditors = new ArrayList(3);
private SelectionBar selectionBar;
+
protected JSPMultiPageEditorPart() {
super();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -11,6 +11,9 @@
package org.jboss.tools.jst.jsp.jspeditor;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.MenuManager;
@@ -31,6 +34,11 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.KeyBindingService;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PopupMenuExtender;
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/externalize.png
===================================================================
(Binary files differ)
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -234,10 +234,6 @@
this.visualEditor = visualEditor;
visualEditor.setController(this);
bundleMap.init(sourceEditor);
- /*
- * Update the toolbar item state
- */
- updateExternalizeStringsToolbarIconState();
pageContext = new VpePageContext(bundleMap, editPart);
domMapping = new VpeDomMapping(pageContext);
sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
@@ -2238,13 +2234,7 @@
// synced = false;
return;
}
-
/*
- * Enable/disable "Externalize strings" toolbar icon
- */
- updateExternalizeStringsToolbarIconState();
-
- /*
* Update Text Formatting Toolbar state
*/
if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
@@ -2518,16 +2508,6 @@
public ISelectionManager getSelectionManager() {
return selectionManager;
}
-
- /**
- * Update Externalize Strings toolbar icon state.
- * <p>
- * Enables the button when suitable text is selected.
- * Disabled otherwise.
- */
- public void updateExternalizeStringsToolbarIconState() {
- visualEditor.updateExternalizeStringsToolbarIconState();
- }
public IZoomEventManager getZoomEventManager() {
return zoomEventManager;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-10-05
15:23:45 UTC (rev 25493)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-10-05
15:35:02 UTC (rev 25494)
@@ -124,7 +124,7 @@
public static final String ICON_NON_VISUAL_TAGS =
"icons/non-visusal-tags.gif"; //$NON-NLS-1$
public static final String ICON_TEXT_FORMATTING = "icons/text-formatting.gif";
//$NON-NLS-1$
public static final String ICON_BUNDLE_AS_EL= "icons/bundle-as-el.gif";
//$NON-NLS-1$
- public static final String ICON_EXTERNALIZE_STRINGS= "icons/externalize.png";
//$NON-NLS-1$
+// public static final String ICON_EXTERNALIZE_STRINGS=
"icons/externalize.png"; //$NON-NLS-1$
//static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
private XulRunnerEditor xulRunnerEditor;
@@ -153,7 +153,7 @@
private Action showNonVisualTagsAction;
private Action showTextFormattingAction;
private Action showBundleAsELAction;
- private Action externalizeStringsAction;
+// private Action externalizeStringsAction;
static {
/*
@@ -450,27 +450,27 @@
/*
* Create EXTERNALIZE STRINGS tool bar item
*/
- externalizeStringsAction = new Action(JstUIMessages.EXTERNALIZE_STRINGS,
- IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- /*
- * Externalize strings action.
- * Show a dialog to add properties key and value.
- * When selection is correct show the dialog
- * otherwise the toolbar icon will be disabled.
- */
- ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- new ExternalizeStringsWizard(controller.getSourceEditor(),
- controller.getPageContext().getBundle()));
- dlg.open();
- }
- };
- externalizeStringsAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
- ICON_EXTERNALIZE_STRINGS));
- externalizeStringsAction.setToolTipText(JstUIMessages.EXTERNALIZE_STRINGS);
- toolBarManager.add(externalizeStringsAction);
+// externalizeStringsAction = new Action(JstUIMessages.EXTERNALIZE_STRINGS,
+// IAction.AS_PUSH_BUTTON) {
+// @Override
+// public void run() {
+// /*
+// * Externalize strings action.
+// * Show a dialog to add properties key and value.
+// * When selection is correct show the dialog
+// * otherwise the toolbar icon will be disabled.
+// */
+// ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
+// PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+// new ExternalizeStringsWizard(controller.getSourceEditor(),
+// controller.getPageContext().getBundle()));
+// dlg.open();
+// }
+// };
+// externalizeStringsAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+// ICON_EXTERNALIZE_STRINGS));
+// externalizeStringsAction.setToolTipText(JstUIMessages.EXTERNALIZE_STRINGS);
+// toolBarManager.add(externalizeStringsAction);
updateToolbarItemsAccordingToPreferences();
toolBarManager.update(true);
@@ -488,7 +488,7 @@
showNonVisualTagsAction = null;
showTextFormattingAction = null;
showBundleAsELAction = null;
- externalizeStringsAction = null;
+// externalizeStringsAction = null;
}
});
return verBar;
@@ -1100,55 +1100,55 @@
}
- /**
- * Update Externalize Strings toolbar icon state.
- * <p>
- * Enables the button when suitable text is selected.
- * Disabled otherwise.
- */
- public void updateExternalizeStringsToolbarIconState() {
- StructuredTextEditor editor = controller.getSourceEditor();
- ISelection sel = editor.getSelectionProvider().getSelection();
- String stringToUpdate = Constants.EMPTY;
- if ((sel instanceof TextSelection)
- && (sel instanceof IStructuredSelection)
- && (((IStructuredSelection) sel).size() == 1)) {
- String text = Constants.EMPTY;
- TextSelection textSelection = null;
- IStructuredSelection structuredSelection = (IStructuredSelection) sel;
- textSelection = (TextSelection) sel;
- text = textSelection.getText();
- Object selectedElement = structuredSelection.getFirstElement();
- /*
- * When selected text is empty parse selected element and find a
- * string to replace..
- */
- if ((text.trim().length() == 0)) {
- if (selectedElement instanceof org.w3c.dom.Text) {
- /*
- * ..it could be a plain text
- */
- org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
- if (textNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = textNode.getNodeValue();
- }
- } else if (selectedElement instanceof Attr) {
- /*
- * ..or an attribute's value
- */
- Attr attrNode = (Attr) selectedElement;
- if (attrNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = attrNode.getNodeValue();
- }
- }
- } else {
- stringToUpdate = text;
- }
- }
- if ((stringToUpdate.length() > 0)) {
- externalizeStringsAction.setEnabled(true);
- } else {
- externalizeStringsAction.setEnabled(false);
- }
- }
+// /**
+// * Update Externalize Strings toolbar icon state.
+// * <p>
+// * Enables the button when suitable text is selected.
+// * Disabled otherwise.
+// */
+// public void updateExternalizeStringsToolbarIconState() {
+// StructuredTextEditor editor = controller.getSourceEditor();
+// ISelection sel = editor.getSelectionProvider().getSelection();
+// String stringToUpdate = Constants.EMPTY;
+// if ((sel instanceof TextSelection)
+// && (sel instanceof IStructuredSelection)
+// && (((IStructuredSelection) sel).size() == 1)) {
+// String text = Constants.EMPTY;
+// TextSelection textSelection = null;
+// IStructuredSelection structuredSelection = (IStructuredSelection) sel;
+// textSelection = (TextSelection) sel;
+// text = textSelection.getText();
+// Object selectedElement = structuredSelection.getFirstElement();
+// /*
+// * When selected text is empty parse selected element and find a
+// * string to replace..
+// */
+// if ((text.trim().length() == 0)) {
+// if (selectedElement instanceof org.w3c.dom.Text) {
+// /*
+// * ..it could be a plain text
+// */
+// org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
+// if (textNode.getNodeValue().trim().length() > 0) {
+// stringToUpdate = textNode.getNodeValue();
+// }
+// } else if (selectedElement instanceof Attr) {
+// /*
+// * ..or an attribute's value
+// */
+// Attr attrNode = (Attr) selectedElement;
+// if (attrNode.getNodeValue().trim().length() > 0) {
+// stringToUpdate = attrNode.getNodeValue();
+// }
+// }
+// } else {
+// stringToUpdate = text;
+// }
+// }
+// if ((stringToUpdate.length() > 0)) {
+// externalizeStringsAction.setEnabled(true);
+// } else {
+// externalizeStringsAction.setEnabled(false);
+// }
+// }
}