Author: dmaliarevich
Date: 2010-10-08 06:35:05 -0400 (Fri, 08 Oct 2010)
New Revision: 25642
Added:
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
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
Log:
https://jira.jboss.org/browse/JBIDE-7222 , Adding ExternalizeStrings dialog to the VPE
context menu (2).
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java 2010-10-08
10:35:05 UTC (rev 25642)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
+ /*
+ * 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);
+ }
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java 2010-10-08
10:35:05 UTC (rev 25642)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java 2010-10-08
10:08:40 UTC (rev 25641)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java 2010-10-08
10:35:05 UTC (rev 25642)
@@ -22,6 +22,7 @@
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem;
import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsUtils;
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.editor.VpeEditorPart;
@@ -92,10 +93,10 @@
*
https://jira.jboss.org/browse/JBIDE-7222
* Adding ExternalizeStrings dialog to the VPE context menu
*/
-// if (ExternalizeStringsUtils.isSelectionCorrect(
-// vpeMenuUtil.getSelection())) {
-// menuManager.add(new ExternalizeStringsContributionItem());
-// }
+ if (ExternalizeStringsUtils.isSelectionCorrect(
+ vpeMenuUtil.getSelection())) {
+ menuManager.add(new ExternalizeStringsContributionItem());
+ }
addSeparator();
if (topLevelMenu) {
addZoomActions();