You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/04/29 16:51:06 UTC
svn commit: r1477113 [8/18] - in
/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide:
./ core/ core/builder/ core/codeassist/ core/extensions/ core/packages/
core/parser/ core/search/ debug/ debug/ui/ debug/ui/handlers/ debug/ui...
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/Messages.java Mon Apr 29 14:50:56 2013
@@ -17,54 +17,54 @@
* under the License.
*/
-package org.apache.uima.textmarker.ide.formatter.preferences;
+package org.apache.uima.ruta.ide.formatter.preferences;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.apache.uima.textmarker.ide.formatter.preferences.messages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.apache.uima.ruta.ide.formatter.preferences.messages"; //$NON-NLS-1$
- // public static String TextMarkerFormatterBlankLinesPage_afterGlobalStatements;
- // public static String TextMarkerFormatterBlankLinesPage_befireFirstDeclaration;
- // public static String TextMarkerFormatterBlankLinesPage_beforeBlockDeclarations;
- // public static String TextMarkerFormatterBlankLinesPage_betweenBlocks;
- public static String TextMarkerFormatterBlankLinesPage_blankLinesBeforeDeclarations;
+ // public static String RutaFormatterBlankLinesPage_afterGlobalStatements;
+ // public static String RutaFormatterBlankLinesPage_befireFirstDeclaration;
+ // public static String RutaFormatterBlankLinesPage_beforeBlockDeclarations;
+ // public static String RutaFormatterBlankLinesPage_betweenBlocks;
+ public static String RutaFormatterBlankLinesPage_blankLinesBeforeDeclarations;
- public static String TextMarkerFormatterBlankLinesPage_beforeDeclarations;
+ public static String RutaFormatterBlankLinesPage_beforeDeclarations;
- // public static String TextMarkerFormatterBlankLinesPage_existingBlankLines;
- // public static String TextMarkerFormatterBlankLinesPage_numberOfEmptyLinesToPreserve;
- // public static String TextMarkerFormatterCommentsPage_commentFormatting;
- // public static String TextMarkerFormatterCommentsPage_enableCommentWrapping;
- // public static String TextMarkerFormatterCommentsPage_maximumLineWidthForComments;
- public static String TextMarkerFormatterLineWrappingPage_maximumLineLenght;
+ // public static String RutaFormatterBlankLinesPage_existingBlankLines;
+ // public static String RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve;
+ // public static String RutaFormatterCommentsPage_commentFormatting;
+ // public static String RutaFormatterCommentsPage_enableCommentWrapping;
+ // public static String RutaFormatterCommentsPage_maximumLineWidthForComments;
+ public static String RutaFormatterLineWrappingPage_maximumLineLenght;
- public static String TextMarkerFormatterLineWrappingPage_generalWrapping;
+ public static String RutaFormatterLineWrappingPage_generalWrapping;
- public static String TextMarkerFormatterIndentationTabPage_statementsWithinBlockBody;
+ public static String RutaFormatterIndentationTabPage_statementsWithinBlockBody;
- public static String TextMarkerFormatterIndentationTabPage_assignmentsWithinCreateAction;
+ public static String RutaFormatterIndentationTabPage_assignmentsWithinCreateAction;
- public static String TextMarkerFormatterIndentationTabPage_generalSettings;
+ public static String RutaFormatterIndentationTabPage_generalSettings;
- public static String TextMarkerFormatterIndentationTabPage_indentationCharacter;
+ public static String RutaFormatterIndentationTabPage_indentationCharacter;
- public static String TextMarkerFormatterIndentationTabPage_indentationSize;
+ public static String RutaFormatterIndentationTabPage_indentationSize;
- public static String TextMarkerFormatterIndentationTabPage_indentWithinBlocks;
+ public static String RutaFormatterIndentationTabPage_indentWithinBlocks;
- public static String TextMarkerFormatterIndentationTabPage_indentWithinCreateActions;
+ public static String RutaFormatterIndentationTabPage_indentWithinCreateActions;
- public static String TextMarkerFormatterIndentationTabPage_tabSize;
+ public static String RutaFormatterIndentationTabPage_tabSize;
- public static String TextMarkerFormatterModifyDialog_blankLines;
+ public static String RutaFormatterModifyDialog_blankLines;
- // public static String TextMarkerFormatterModifyDialog_comments;
- public static String TextMarkerFormatterModifyDialog_indentation;
+ // public static String RutaFormatterModifyDialog_comments;
+ public static String RutaFormatterModifyDialog_indentation;
- public static String TextMarkerFormatterModifyDialog_lineWrapping;
+ public static String RutaFormatterModifyDialog_lineWrapping;
- public static String TextMarkerFormatterModifyDialog_TextMarkerFormatter;
+ public static String RutaFormatterModifyDialog_RutaFormatter;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterBlankLinesPage.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+public class RutaFormatterBlankLinesPage extends FormatterModifyTabPage {
+
+ /**
+ * @param dialog
+ */
+ public RutaFormatterBlankLinesPage(IFormatterModifyDialog dialog) {
+ super(dialog);
+ }
+
+ @Override
+ protected void createOptions(IFormatterControlManager manager, Composite parent) {
+ Group emptyLinesGroup = SWTFactory.createGroup(parent,
+ Messages.RutaFormatterBlankLinesPage_blankLinesBeforeDeclarations, 2, 1,
+ GridData.FILL_HORIZONTAL);
+ manager.createNumber(emptyLinesGroup,
+ RutaFormatterConstants.LINES_BEFORE_LONG_DECLARATIONS,
+ Messages.RutaFormatterBlankLinesPage_beforeDeclarations);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_BLOCK,
+ // Messages.RutaFormatterBlankLinesPage_betweenBlocks);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_CLASS,
+ // Messages.RutaFormatterBlankLinesPage_betweenClasses);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_METHOD,
+ // Messages.RutaFormatterBlankLinesPage_betweenMethods);
+ // //
+ // Group emptyLinesInternalGroup = SWTFactory.createGroup(parent,
+ // Messages.RutaFormatterBlankLinesPage_blankLinesWithingClassModuleDeclarations, 2, 1,
+ // GridData.FILL_HORIZONTAL);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_FIRST,
+ // Messages.RutaFormatterBlankLinesPage_befireFirstDeclaration);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_MODULE,
+ // Messages.RutaFormatterBlankLinesPage_beforeNestedModuleDeclarations);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_CLASS,
+ // Messages.RutaFormatterBlankLinesPage_beforeNestedClassDeclarations);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_METHOD,
+ // Messages.RutaFormatterBlankLinesPage_beforeMethodDeclarations);
+ // //
+ // Group preserveGroup = SWTFactory.createGroup(parent,
+ // Messages.RutaFormatterBlankLinesPage_existingBlankLines, 2, 1,
+ // GridData.FILL_HORIZONTAL);
+ // manager.createNumber(preserveGroup,
+ // RutaFormatterConstants.LINES_PRESERVE,
+ // Messages.RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve);
+ }
+
+ @Override
+ protected URL getPreviewContent() {
+ return getClass().getResource("blank-lines-preview.tm"); //$NON-NLS-1$
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterIndentationTabPage.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.preferences.FormatterMessages;
+import org.eclipse.dltk.ui.util.SWTFactory;
+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.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+
+public class RutaFormatterIndentationTabPage extends FormatterModifyTabPage {
+
+ /**
+ * @param dialog
+ */
+ public RutaFormatterIndentationTabPage(IFormatterModifyDialog dialog) {
+ super(dialog);
+ }
+
+ private Combo tabPolicy;
+
+ private Text indentSize;
+
+ private Text tabSize;
+
+ private final String[] tabPolicyItems = new String[] { CodeFormatterConstants.SPACE,
+ CodeFormatterConstants.TAB, CodeFormatterConstants.MIXED };
+
+ private class TabPolicyListener extends SelectionAdapter implements
+ IFormatterControlManager.IInitializeListener {
+
+ private final IFormatterControlManager manager;
+
+ public TabPolicyListener(IFormatterControlManager manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = tabPolicy.getSelectionIndex();
+ if (index >= 0) {
+ final boolean tabMode = CodeFormatterConstants.TAB.equals(tabPolicyItems[index]);
+ manager.enableControl(indentSize, !tabMode);
+ }
+ }
+
+ public void initialize() {
+ final boolean tabMode = CodeFormatterConstants.TAB.equals(manager
+ .getString(RutaFormatterConstants.FORMATTER_TAB_CHAR));
+ manager.enableControl(indentSize, !tabMode);
+ }
+
+ }
+
+ private TabPolicyListener tabPolicyListener;
+
+ @Override
+ protected void createOptions(final IFormatterControlManager manager, Composite parent) {
+ Group tabPolicyGroup = SWTFactory.createGroup(parent,
+ Messages.RutaFormatterIndentationTabPage_generalSettings, 2, 1,
+ GridData.FILL_HORIZONTAL);
+ tabPolicy = manager.createCombo(tabPolicyGroup,
+ RutaFormatterConstants.FORMATTER_TAB_CHAR,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_policy, tabPolicyItems);
+ tabPolicyListener = new TabPolicyListener(manager);
+ tabPolicy.addSelectionListener(tabPolicyListener);
+ manager.addInitializeListener(tabPolicyListener);
+ indentSize = manager.createNumber(tabPolicyGroup,
+ RutaFormatterConstants.FORMATTER_INDENTATION_SIZE,
+ FormatterMessages.IndentationTabPage_general_group_option_indent_size);
+ tabSize = manager.createNumber(tabPolicyGroup, RutaFormatterConstants.FORMATTER_TAB_SIZE,
+ FormatterMessages.IndentationTabPage_general_group_option_tab_size);
+ tabSize.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ int index = tabPolicy.getSelectionIndex();
+ if (index >= 0) {
+ final boolean tabMode = CodeFormatterConstants.TAB.equals(tabPolicyItems[index]);
+ if (tabMode) {
+ indentSize.setText(tabSize.getText());
+ }
+ }
+ }
+ });
+ //
+ Group indentGroup = SWTFactory.createGroup(parent,
+ Messages.RutaFormatterIndentationTabPage_indentWithinBlocks, 1, 1,
+ GridData.FILL_HORIZONTAL);
+ manager.createCheckbox(indentGroup, RutaFormatterConstants.INDENT_BLOCK,
+ Messages.RutaFormatterIndentationTabPage_statementsWithinBlockBody);
+ Group indentBlocks = SWTFactory.createGroup(parent,
+ Messages.RutaFormatterIndentationTabPage_indentWithinCreateActions, 1, 1,
+ GridData.FILL_HORIZONTAL);
+ manager.createCheckbox(indentBlocks, RutaFormatterConstants.INDENT_STRUCTURE,
+ Messages.RutaFormatterIndentationTabPage_assignmentsWithinCreateAction);
+ }
+
+ @Override
+ protected URL getPreviewContent() {
+ return getClass().getResource("indentation-preview.tm");
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterLineWrappingPage.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import java.net.URL;
+
+import org.apache.uima.ruta.ide.formatter.RutaFormatterConstants;
+import org.eclipse.dltk.ui.formatter.FormatterModifyTabPage;
+import org.eclipse.dltk.ui.formatter.IFormatterControlManager;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialog;
+import org.eclipse.dltk.ui.util.SWTFactory;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+public class RutaFormatterLineWrappingPage extends FormatterModifyTabPage {
+
+ /**
+ * @param dialog
+ */
+ public RutaFormatterLineWrappingPage(IFormatterModifyDialog dialog) {
+ super(dialog);
+ }
+
+ @Override
+ protected void createOptions(IFormatterControlManager manager, Composite parent) {
+ Group emptyLinesGroup = SWTFactory.createGroup(parent,
+ Messages.RutaFormatterLineWrappingPage_generalWrapping, 2, 1,
+ GridData.FILL_HORIZONTAL);
+ manager.createNumber(emptyLinesGroup, RutaFormatterConstants.MAX_LINE_LENGTH,
+ Messages.RutaFormatterLineWrappingPage_maximumLineLenght);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_BLOCK,
+ // Messages.RutaFormatterBlankLinesPage_betweenBlocks);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_CLASS,
+ // Messages.RutaFormatterBlankLinesPage_betweenClasses);
+ // manager.createNumber(emptyLinesGroup,
+ // RutaFormatterConstants.LINES_FILE_BETWEEN_METHOD,
+ // Messages.RutaFormatterBlankLinesPage_betweenMethods);
+ // //
+ // Group emptyLinesInternalGroup = SWTFactory.createGroup(parent,
+ // Messages.RutaFormatterBlankLinesPage_blankLinesWithingClassModuleDeclarations, 2, 1,
+ // GridData.FILL_HORIZONTAL);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_FIRST,
+ // Messages.RutaFormatterBlankLinesPage_befireFirstDeclaration);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_MODULE,
+ // Messages.RutaFormatterBlankLinesPage_beforeNestedModuleDeclarations);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_CLASS,
+ // Messages.RutaFormatterBlankLinesPage_beforeNestedClassDeclarations);
+ // manager.createNumber(emptyLinesInternalGroup,
+ // RutaFormatterConstants.LINES_BEFORE_METHOD,
+ // Messages.RutaFormatterBlankLinesPage_beforeMethodDeclarations);
+ // //
+ // Group preserveGroup = SWTFactory.createGroup(parent,
+ // Messages.RutaFormatterBlankLinesPage_existingBlankLines, 2, 1,
+ // GridData.FILL_HORIZONTAL);
+ // manager.createNumber(preserveGroup,
+ // RutaFormatterConstants.LINES_PRESERVE,
+ // Messages.RutaFormatterBlankLinesPage_numberOfEmptyLinesToPreserve);
+ }
+
+ @Override
+ protected URL getPreviewContent() {
+ return getClass().getResource("wrapping-preview.tm"); //$NON-NLS-1$
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/preferences/RutaFormatterModifyDialog.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.formatter.preferences;
+
+import org.eclipse.dltk.ui.formatter.FormatterModifyDialog;
+import org.eclipse.dltk.ui.formatter.IFormatterModifyDialogOwner;
+import org.eclipse.dltk.ui.formatter.IScriptFormatterFactory;
+
+public class RutaFormatterModifyDialog extends FormatterModifyDialog {
+
+ /**
+ * @param parent
+ */
+ public RutaFormatterModifyDialog(IFormatterModifyDialogOwner dialogOwner,
+ IScriptFormatterFactory formatterFactory) {
+ super(dialogOwner, formatterFactory);
+ setTitle(Messages.RutaFormatterModifyDialog_RutaFormatter);
+ }
+
+ @Override
+ protected void addPages() {
+ addTabPage(Messages.RutaFormatterModifyDialog_indentation,
+ new RutaFormatterIndentationTabPage(this));
+ addTabPage(Messages.RutaFormatterModifyDialog_blankLines,
+ new RutaFormatterBlankLinesPage(this));
+ addTabPage(Messages.RutaFormatterModifyDialog_lineWrapping,
+ new RutaFormatterLineWrappingPage(this));
+ // addTabPage(Messages.RutaFormatterModifyDialog_comments,
+ // new RutaFormatterCommentsPage(this));
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstall.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.dltk.launching.AbstractInterpreterInstall;
+import org.eclipse.dltk.launching.IInterpreterInstallType;
+import org.eclipse.dltk.launching.IInterpreterRunner;
+
+public class GenericRutaInstall extends AbstractInterpreterInstall {
+
+ public GenericRutaInstall(IInterpreterInstallType type, String id) {
+ super(type, id);
+ }
+
+ @Override
+ public String getBuiltinModuleContent(String name) {
+ InputStream stream = GenericRutaInstall.class.getResourceAsStream("builtins.tm");
+ if (stream == null) {
+ return "PACKAGE org.apache.uima.tm;\n";
+ }
+ BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+ StringBuffer buf = new StringBuffer();
+ try {
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ buf.append(line);
+ buf.append('\n');
+ }
+ } catch (IOException e) {
+ RutaIdePlugin.error(e);
+ }
+ return buf.toString();
+ }
+
+ @Override
+ public String[] getBuiltinModules() {
+ return new String[] { "builtins.tm" };
+ }
+
+
+ @Override
+ public IInterpreterRunner getInterpreterRunner(String mode) {
+ IInterpreterRunner runner = super.getInterpreterRunner(mode);
+ if (runner != null) {
+ return runner;
+ }
+
+ if (mode.equals(ILaunchManager.RUN_MODE)) {
+ return new RutaInterpreterRunner(this);
+ }
+ return null;
+ }
+
+ public String getNatureId() {
+ return RutaNature.NATURE_ID;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/GenericRutaInstallType.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.dltk.core.environment.IDeployment;
+import org.eclipse.dltk.core.environment.IFileHandle;
+import org.eclipse.dltk.internal.launching.AbstractInterpreterInstallType;
+import org.eclipse.dltk.launching.EnvironmentVariable;
+import org.eclipse.dltk.launching.IInterpreterInstall;
+import org.eclipse.dltk.launching.LibraryLocation;
+
+public class GenericRutaInstallType extends AbstractInterpreterInstallType {
+
+ public static final String DBGP_FOR_TM_BUNDLE_ID = "org.apache.uima.ruta.ide.interpreter.dbgp";
+
+ public static final String EMBEDDED_TM_BUNDLE_ID = "org.apache.uima.ruta.ide.interpreter";
+
+ public String getNatureId() {
+ return RutaNature.NATURE_ID;
+ }
+
+ public String getName() {
+ return "Generic Ruta Install";
+ }
+
+ @Override
+ public LibraryLocation[] getDefaultLibraryLocations(IFileHandle installLocation,
+ EnvironmentVariable[] variables, IProgressMonitor monitor) {
+ return new LibraryLocation[0];
+ }
+
+ private static String[] possibleExes = { "tm" };
+
+ @Override
+ protected String getPluginId() {
+ return RutaIdePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String[] getPossibleInterpreterNames() {
+ return possibleExes;
+ }
+
+ @Override
+ protected IInterpreterInstall doCreateInterpreterInstall(String id) {
+ return new GenericRutaInstall(this, id);
+ }
+
+ @Override
+ protected void filterEnvironment(Map environment) {
+ environment.remove("TMLIBPATH");
+ environment.remove("DISPLAY");
+ }
+
+ @Override
+ public IStatus validateInstallLocation(IFileHandle installLocation) {
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected IPath createPathFile(IDeployment deployment) throws IOException {
+ throw new RuntimeException("This method should not be used");
+ }
+
+ @Override
+ protected String[] parsePaths(String result) {
+ ArrayList<String> paths = new ArrayList<String>();
+ String subs = null;
+ int index = 0;
+ while (index < result.length()) {
+ while (index < result.length() && Character.isWhitespace(result.charAt(index)))
+ index++;
+ if (index == result.length())
+ break;
+
+ if (result.charAt(index) == '{') {
+ int start = index;
+ while (index < result.length() && result.charAt(index) != '}')
+ index++;
+ if (index == result.length())
+ break;
+ subs = result.substring(start + 1, index);
+ } else {
+ int start = index;
+ while (index < result.length() && result.charAt(index) != ' ')
+ index++;
+ subs = result.substring(start, index);
+ }
+
+ paths.add(subs);
+ index++;
+ }
+
+ return (String[]) paths.toArray(new String[paths.size()]);
+ }
+
+ @Override
+ protected ILog getLog() {
+ return RutaIdePlugin.getDefault().getLog();
+ }
+
+}
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IConfigurableRunner.java Mon Apr 29 14:50:56 2013
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.uima.textmarker.ide.launching;
+package org.apache.uima.ruta.ide.launching;
public interface IConfigurableRunner {
- public void setRunnerConfig(ITextMarkerInterpreterRunnerConfig config);
+ public void setRunnerConfig(IRutaInterpreterRunnerConfig config);
}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/IRutaInterpreterRunnerConfig.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.launching;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+
+public interface IRutaInterpreterRunnerConfig {
+
+ public String getRunnerClassName(InterpreterConfig config, ILaunch launch, IJavaProject project);
+
+ public String[] computeClassPath(InterpreterConfig config, ILaunch launch, IJavaProject project)
+ throws Exception;
+
+ public String[] getProgramArguments(InterpreterConfig config, ILaunch launch, IJavaProject project);
+
+ public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig, InterpreterConfig iconfig,
+ ILaunch launch, IJavaProject project);
+}
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationLaunchConfigurationDelegate.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.uima.textmarker.ide.launching;
+package org.apache.uima.ruta.ide.launching;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -51,14 +51,14 @@ public class JavaLocalApplicationLaunchC
dbgpService = DLTKDebugPlugin.getDefault().getDbgpService();
IScriptDebugTarget target = new ScriptDebugTarget(
- "org.apache.uima.textmarker.ide.debug.textmarkerModel", dbgpService, "hello", launch,
+ "org.apache.uima.ruta.ide.debug.rutaModel", dbgpService, "hello", launch,
null);
IOConsole cs = new IOConsole("aa", null);
ScriptStreamProxy proxy = new ScriptStreamProxy(cs);
target.setStreamProxy(proxy);
launch.addDebugTarget(target);
final ISourceLocator sourceLocator = launch.getSourceLocator();
- final TextMarkerSourceLookupDirector l = new TextMarkerSourceLookupDirector();
+ final RutaSourceLookupDirector l = new RutaSourceLookupDirector();
launch.setSourceLocator(new ISourceLocator() {
public Object getSourceElement(IStackFrame stackFrame) {
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationTabGroup.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationTabGroup.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationTabGroup.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/JavaLocalApplicationTabGroup.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.uima.textmarker.ide.launching;
+package org.apache.uima.ruta.ide.launching;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaDebuggingEngineSelector.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaDebuggingEngineSelector.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaDebuggingEngineSelector.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaDebuggingEngineSelector.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.debug.RutaDebugConstants;
+import org.eclipse.dltk.core.DLTKIdContributionSelector;
+import org.eclipse.dltk.core.PreferencesLookupDelegate;
+
+public class RutaDebuggingEngineSelector extends DLTKIdContributionSelector {
+ @Override
+ protected String getSavedContributionId(PreferencesLookupDelegate delegate) {
+ return delegate.getString(RutaIdePlugin.PLUGIN_ID,
+ RutaDebugConstants.DEBUGGING_ENGINE_ID_KEY);
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaInterpreterRunner.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.cas.impl.XmiCasSerializer;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.ruta.action.LogAction;
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaCorePreferences;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLSerializer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.launching.AbstractInterpreterRunner;
+import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate;
+import org.eclipse.dltk.launching.IInterpreterInstall;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.xml.sax.SAXException;
+
+public class RutaInterpreterRunner extends AbstractInterpreterRunner implements
+ IConfigurableRunner {
+
+ public static final IRutaInterpreterRunnerConfig DEFAULT_CONFIG = new IRutaInterpreterRunnerConfig() {
+
+ public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig, InterpreterConfig iconfig,
+ ILaunch launch, IJavaProject project) {
+ System.out.println("adjust runner");
+ }
+
+ public String[] computeClassPath(InterpreterConfig config, ILaunch launch, IJavaProject project)
+ throws Exception {
+ return RutaInterpreterRunner.getClassPath(project);
+ }
+
+ public String[] getProgramArguments(InterpreterConfig config, ILaunch launch,
+ IJavaProject project) {
+ return new String[0];
+ }
+
+ public String getRunnerClassName(InterpreterConfig config, ILaunch launch, IJavaProject project) {
+ return "RutaRunner";
+ }
+
+ };
+
+ private IRutaInterpreterRunnerConfig config = DEFAULT_CONFIG;
+
+ @Override
+ public void run(InterpreterConfig config, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ doRunImpl(config, launch, this.config, monitor);
+ }
+
+ private static Handler initConsoleLink(String module) {
+ final MessageConsole console;
+ final MessageConsoleStream out;
+ console = findConsole(module);
+ out = console.newMessageStream();
+
+ Handler handler = new Handler() {
+
+ @Override
+ public void publish(LogRecord record) {
+ String message = record.getMessage();
+ if (message.equals("\\n")) {
+ out.println();
+ }
+ String[] split = message.split("\\\\n");
+ for (String string : split) {
+ out.println(string);
+ }
+ console.activate();
+ }
+
+ @Override
+ public void flush() {
+
+ }
+
+ @Override
+ public void close() throws SecurityException {
+
+ }
+ };
+ Logger.getLogger(LogAction.LOGGER_NAME).addHandler(handler);
+ return handler;
+ }
+
+ private static void clearConsoleLink(Handler handler) {
+ Logger.getLogger(LogAction.LOGGER_NAME).removeHandler(handler);
+ }
+
+ private static MessageConsole findConsole(String name) {
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ for (int i = 0; i < existing.length; i++)
+ if (name.equals(existing[i].getName()))
+ return (MessageConsole) existing[i];
+ MessageConsole myConsole = new MessageConsole(name, null);
+ conMan.addConsoles(new IConsole[] { myConsole });
+ return myConsole;
+ }
+
+ public static List<File> getFiles(File dir, boolean recusive) {
+ List<File> result = new ArrayList<File>();
+ for (File each : dir.listFiles()) {
+ // TODO: find a solution for this hotfix
+ if (each.getName().endsWith(".svn")) {
+ continue;
+ }
+ result.add(each);
+ if (each.isDirectory() && recusive) {
+ result.addAll(getFiles(each, recusive));
+ }
+ }
+ return result;
+ }
+
+ public static void doRunImpl(InterpreterConfig config, ILaunch launch,
+ IRutaInterpreterRunnerConfig iconfig, IProgressMonitor monitor)
+ throws CoreException {
+ String launchMode = launch.getLaunchMode();
+ IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(launch
+ .getLaunchConfiguration());
+
+ IPath projectPath = proj.getResource().getLocation();
+ IPath inputDirPath = projectPath.append(RutaProjectUtils.getDefaultInputLocation());
+ IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
+ String engine = RutaProjectUtils.getEngineDescriptorPath(config.getScriptFilePath(),
+ proj.getProject()).toPortableString();
+ IPath rootPath = RutaProjectUtils.getDescriptorRootPath(proj.getProject());
+
+ File inputDir = inputDirPath.makeAbsolute().toFile();
+ File outputDir = outputDirPath.makeAbsolute().toFile();
+
+ if(!inputDir.exists()) {
+ inputDir.mkdirs();
+ IFolder folder = proj.getProject().getFolder(RutaProjectUtils.getDefaultInputLocation());
+ folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ IFolder outputFolder = proj.getProject().getFolder(RutaProjectUtils.getDefaultOutputLocation());
+ if(!outputDir.exists()) {
+ outputDir.mkdirs();
+ outputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ IPreferenceStore store = RutaIdePlugin.getDefault().getPreferenceStore();
+ boolean clearOutput = store.getBoolean(RutaCorePreferences.PROJECT_CLEAR_OUTPUT);
+ if(clearOutput) {
+ List<File> outputFiles = getFiles(outputDir, false);
+ for (File file : outputFiles) {
+ file.delete();
+ }
+ outputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ List<File> inputFiles = getFiles(inputDir, false);
+
+ int ticks = (inputFiles.size() * 2) + 1;
+ SubProgressMonitor mon = new SubProgressMonitor(monitor, ticks);
+
+ mon.setTaskName("Initializing");
+ Handler handler = initConsoleLink(config.getScriptFilePath().lastSegment());
+
+ CAS cas = null;
+
+ AnalysisEngine ae = null;
+ try {
+ File specFile = new File(engine);
+ XMLInputSource in = new XMLInputSource(specFile);
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+ ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
+ resMgr.setDataPath(rootPath.toPortableString());
+ ae = UIMAFramework.produceAnalysisEngine(specifier, resMgr, null);
+ } catch (Exception e) {
+ String message = e.getMessage();
+ DLTKCore.error(message, e);
+ clearConsoleLink(handler);
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e));
+ }
+
+ try {
+ if ("debug".equals(launchMode)) {
+ ae.setConfigParameterValue(RutaEngine.CREATE_DEBUG_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_MATCH_DEBUG_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_PROFILING_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_STATISTIC_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_CREATED_BY_INFO, true);
+ ae.reconfigure();
+ }
+ } catch (Exception e) {
+ clearConsoleLink(handler);
+ String message = e.getMessage();
+ DLTKCore.error(message, e);
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e));
+ }
+ mon.worked(1);
+ for (File each : inputFiles) {
+
+ mon.setTaskName("Processing " + each.getName());
+ if(mon.isCanceled()) {
+ break;
+ }
+ try {
+ if (cas == null) {
+ cas = ae.newCAS();
+ } else {
+ cas.reset();
+ }
+ if (each.getName().endsWith("xmi")) {
+ XmiCasDeserializer.deserialize(new FileInputStream(each), cas, true);
+ } else {
+ cas.setDocumentText(getText(each));
+ }
+
+ if(mon.isCanceled()) {
+ break;
+ }
+
+ RutaEngine.removeSourceDocumentInformation(cas);
+ RutaEngine.addSourceDocumentInformation(cas, each);
+
+ ae.process(cas);
+
+ mon.worked(1);
+
+ if(mon.isCanceled()) {
+ break;
+ }
+
+ File outputFile = new File(outputDir, each.getName() + ".xmi");
+ mon.setTaskName("Saving " + outputFile.getName());
+ writeXmi(cas, outputFile);
+ mon.worked(1);
+ } catch (Exception e) {
+ if (cas != null) {
+ cas.release();
+ }
+ if (ae != null) {
+ ae.destroy();
+ }
+ clearConsoleLink(handler);
+ String message = e.getMessage();
+ DLTKCore.error(message, e);
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e));
+ }
+ }
+ if (cas != null) {
+ cas.release();
+ }
+ if (ae != null) {
+ ae.destroy();
+ }
+ IFolder folder = outputFolder;
+ folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ clearConsoleLink(handler);
+ mon.done();
+ }
+
+ private static String getText(File each) {
+ try {
+ return org.apache.uima.pear.util.FileUtil.loadTextFile(each, "UTF-8");
+ } catch (IOException e) {
+ DLTKCore.error(e.getMessage(), e);
+ }
+ return "";
+ }
+
+ private static void writeXmi(CAS aCas, File name) throws IOException, SAXException {
+ FileOutputStream out = null;
+
+ try {
+ // write XMI
+ out = new FileOutputStream(name);
+ XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
+ XMLSerializer xmlSer = new XMLSerializer(out, false);
+ ser.serialize(aCas, xmlSer.getContentHandler());
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ public static String[] getClassPath(IJavaProject myJavaProject) {
+ String[] newClassPath = new String[0];// classPath.length + 2];
+ return newClassPath;
+ }
+
+ protected static String[] computeBaseClassPath(IJavaProject myJavaProject) throws CoreException {
+ if (!myJavaProject.exists())
+ return new String[0];
+ return JavaRuntime.computeDefaultRuntimeClassPath(myJavaProject);
+ }
+
+ protected String constructProgramString(InterpreterConfig config) {
+ return "";
+ }
+
+ public RutaInterpreterRunner(IInterpreterInstall install) {
+ super(install);
+ }
+
+ @Override
+ protected String getProcessType() {
+ return RutaLaunchConfigurationConstants.ID_TM_PROCESS_TYPE;
+ }
+
+ public void setRunnerConfig(IRutaInterpreterRunnerConfig config) {
+ this.config = config;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationConstants.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationConstants.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
+
+public class RutaLaunchConfigurationConstants extends ScriptLaunchConfigurationConstants {
+ protected RutaLaunchConfigurationConstants() {
+
+ }
+
+ public static final String ID_TM_SCRIPT = "org.apache.uima.ruta.ide.launching.RutaLaunchConfigurationType"; //$NON-NLS-1$
+
+ public static final String ID_TM_PROCESS_TYPE = "rutaInterpreter"; //$NON-NLS-1$
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,347 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaCorePreferences;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.launching.JavaLaunchDelegate;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.osgi.framework.Bundle;
+
+public class RutaLaunchConfigurationDelegate extends JavaLaunchDelegate {
+
+ private String mode;
+
+ @Override
+ public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
+ StringBuilder cmdline = new StringBuilder();
+ IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(configuration);
+
+ String mainScriptAttribute = configuration.getAttribute("mainScript", "");
+
+ String encoding = proj.getProject().getDefaultCharset();
+ String view = configuration.getAttribute(RutaLaunchConstants.VIEW, CAS.NAME_DEFAULT_SOFA);
+ if (StringUtils.isBlank(view)) {
+ view = CAS.NAME_DEFAULT_SOFA;
+ }
+ boolean recursive = configuration.getAttribute(RutaLaunchConstants.RECURSIVE, false);
+
+ IResource member = proj.getProject().findMember(mainScriptAttribute);
+ IPath projectPath = proj.getResource().getLocation();
+ IPath inputDirPath = projectPath.append(RutaProjectUtils.getDefaultInputLocation());
+ IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
+ String engine = RutaProjectUtils.getEngineDescriptorPath(member.getLocation(),
+ proj.getProject()).toPortableString();
+ String input = configuration.getAttribute(RutaLaunchConstants.INPUT_FOLDER,
+ inputDirPath.toPortableString());
+ if (StringUtils.isBlank(input)) {
+ input = inputDirPath.toPortableString();
+ }
+ String output = configuration.getAttribute(RutaLaunchConstants.OUTPUT_FOLDER,
+ outputDirPath.toPortableString());
+ if (StringUtils.isBlank(output)) {
+ output = outputDirPath.toPortableString();
+ }
+
+ cmdline.append(RutaLaunchConstants.ARG_DESCRIPTOR + " ");
+ cmdline.append(engine + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_INPUT_FOLDER + " ");
+ cmdline.append(makeAbsolute(input, configuration) + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_OUTPUT_FOLDER + " ");
+ cmdline.append(makeAbsolute(output, configuration) + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_MODE + " ");
+ cmdline.append(mode + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_ENCODING + " ");
+ cmdline.append(encoding + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_VIEW + " ");
+ cmdline.append(view + " ");
+
+ cmdline.append(RutaLaunchConstants.ARG_RECURSIVE + " ");
+ cmdline.append(recursive + " ");
+
+ return cmdline.toString();
+ }
+
+ private String makeAbsolute(String input, ILaunchConfiguration configuration)
+ throws CoreException {
+ IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(input);
+ if (member != null) {
+ return member.getLocation().toPortableString();
+ }
+ return input;
+ }
+
+ @Override
+ public String getMainTypeName(ILaunchConfiguration configuration) throws CoreException {
+ return "org.apache.uima.ruta.ide.launching.RutaLauncher";
+ }
+
+ @Override
+ public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
+ RutaIdePlugin d = RutaIdePlugin.getDefault();
+ List<String> extendedClasspath = new ArrayList<String>();
+ Collections.addAll(extendedClasspath, super.getClasspath(configuration));
+
+ // Normal mode, add the launcher plugin and uima runtime jar to the classpath
+ if (!Platform.inDevelopmentMode()) {
+ try {
+ // Add this plugin jar to the classpath
+ extendedClasspath.add(d.pluginIdToJarPath(RutaIdePlugin.PLUGIN_ID));
+
+ // UIMA jar should be added the end of the class path, because user uima jars
+ // (maybe a different version) should appear first on the class path
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.ruta.engine"));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ IStatus.OK, "Failed to compose classpath!", e));
+ }
+ }
+ // When running inside eclipse with PDE in development mode the plugins
+ // are not installed inform of jar files and the classes must be loaded
+ // from the target/classes folder or target/org.apache.uima.runtime.*.jar file
+ else {
+ try {
+ extendedClasspath
+ .add(d.pluginIdToJarPath(RutaIdePlugin.PLUGIN_ID) + "target/classes");
+ Bundle bundle = RutaIdePlugin.getDefault().getBundle("org.apache.uima.runtime");
+ if (bundle != null) {
+ Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
+ if (jarEnum == null) {
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
+ }
+ while (jarEnum != null && jarEnum.hasMoreElements()) {
+ URL element = (URL) jarEnum.nextElement();
+ extendedClasspath.add(FileLocator.toFileURL(element).getFile());
+ }
+ }
+
+ Bundle bundle2 = RutaIdePlugin.getDefault().getBundle(
+ "org.apache.uima.ruta.engine");
+ if (bundle2 != null) {
+ Enumeration<?> jarEnum = bundle2.findEntries("/", "*.jar", true);
+ while (jarEnum != null && jarEnum.hasMoreElements()) {
+ URL element = (URL) jarEnum.nextElement();
+ extendedClasspath.add(FileLocator.toFileURL(element).getFile());
+ }
+ }
+
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ IStatus.OK, "Failed to compose classpath!", e));
+ }
+ }
+
+ Collection<String> dependencies = getDependencies(configuration);
+ extendedClasspath.addAll(dependencies);
+
+ Collection<String> extensions = getExtensions(configuration);
+ extendedClasspath.addAll(extensions);
+
+ return extendedClasspath.toArray(new String[extendedClasspath.size()]);
+ }
+
+ private Collection<String> getExtensions(ILaunchConfiguration configuration) throws CoreException {
+ RutaIdePlugin d = RutaIdePlugin.getDefault();
+ Collection<String> result = new TreeSet<String>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "actionExtension").getExtensions();
+ for (IExtension each : extensions) {
+ String namespaceIdentifier = each.getNamespaceIdentifier();
+ try {
+ if (!Platform.inDevelopmentMode()) {
+ result.add(d.pluginIdToJarPath(namespaceIdentifier));
+ } else {
+ result.add(d.pluginIdToJarPath(namespaceIdentifier)+ "target/classes");
+ result.add(d.pluginIdToJarPath(namespaceIdentifier)+ "bin");
+ }
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdePlugin.PLUGIN_ID,
+ IStatus.OK, "Failed to extend classpath with " + namespaceIdentifier + "!", e));
+ }
+ }
+ return result;
+ }
+
+ private Collection<String> getDependencies(ILaunchConfiguration configuration)
+ throws CoreException {
+ Collection<String> result = new TreeSet<String>();
+
+ IScriptProject scriptProject = AbstractScriptLaunchConfigurationDelegate
+ .getScriptProject(configuration);
+ IProject[] referencedProjects = scriptProject.getProject().getReferencedProjects();
+ for (IProject eachProject : referencedProjects) {
+ // for each java project
+ extendClasspathWithProject(result, eachProject, new HashSet<IProject>());
+ }
+ return result;
+ }
+
+ private void extendClasspathWithProject(Collection<String> result, IProject project,
+ Collection<IProject> visited) throws CoreException, JavaModelException {
+ IProjectNature nature = project.getNature(RutaProjectUtils.JAVANATURE);
+ if (nature != null) {
+ JavaProject javaProject = (JavaProject) JavaCore.create(project);
+
+ // add output, e.g., target/classes
+ IPath readOutputLocation = javaProject.readOutputLocation();
+ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
+ result.add(folder.getLocation().toPortableString());
+
+ IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
+ for (IClasspathEntry each : rawClasspath) {
+ int entryKind = each.getEntryKind();
+ IPath path = each.getPath();
+ if (entryKind == IClasspathEntry.CPE_PROJECT) {
+ IProject p = RutaProjectUtils.getProject(path);
+ if (!visited.contains(p)) {
+ visited.add(p);
+ extendClasspathWithProject(result, p, visited);
+ }
+ } else if (entryKind != IClasspathEntry.CPE_SOURCE) {
+ String segment = path.segment(0);
+ if (!segment.equals("org.eclipse.jdt.launching.JRE_CONTAINER")) {
+ IClasspathEntry[] resolveClasspath = javaProject
+ .resolveClasspath(new IClasspathEntry[] { each });
+ for (IClasspathEntry eachResolved : resolveClasspath) {
+ if (eachResolved.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IProject p = RutaProjectUtils.getProject(eachResolved.getPath());
+ if (!visited.contains(p)) {
+ visited.add(p);
+ extendClasspathWithProject(result, p, visited);
+ }
+ } else {
+ result.add(eachResolved.getPath().toPortableString());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException {
+ this.mode = mode;
+ IResource ouputFolder = null;
+ IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(configuration);
+ IPath projectPath = proj.getResource().getLocation();
+ IPath outputDirPath = projectPath.append(RutaProjectUtils.getDefaultOutputLocation());
+ String outputFolderPath = configuration.getAttribute(
+ RutaLaunchConstants.ARG_OUTPUT_FOLDER, outputDirPath.toPortableString());
+ if (outputFolderPath.length() != 0) {
+ IPath path = Path.fromPortableString(outputFolderPath);
+ ouputFolder = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
+ }
+ boolean recursive = configuration.getAttribute(RutaLaunchConstants.RECURSIVE, false);
+ clearOutputFolder(new File(ouputFolder.getLocation().toPortableString()), recursive);
+
+ // String[] args = getProgramArguments(configuration).split(" ");
+ // try {
+ // RutaLauncher.main(args);
+ // } catch (Exception e1) {
+ // e1.printStackTrace();
+ // }
+
+ super.launch(configuration, mode, launch, monitor);
+
+ while (!launch.isTerminated()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+ }
+
+ if (ouputFolder != null) {
+ ouputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ }
+
+ private void clearOutputFolder(File outputDir, boolean recursive) {
+ IPreferenceStore store = RutaIdePlugin.getDefault().getPreferenceStore();
+ boolean clearOutput = store.getBoolean(RutaCorePreferences.PROJECT_CLEAR_OUTPUT);
+ if (clearOutput) {
+ List<File> outputFiles = getFiles(outputDir, recursive);
+ for (File file : outputFiles) {
+ file.delete();
+ }
+ }
+ }
+
+ private static List<File> getFiles(File dir, boolean recusive) {
+ List<File> result = new ArrayList<File>();
+ for (File each : dir.listFiles()) {
+ // TODO: find a solution for this hotfix
+ if (each.getName().endsWith(".svn")) {
+ continue;
+ }
+ result.add(each);
+ if (each.isDirectory() && recusive) {
+ result.addAll(getFiles(each, recusive));
+ }
+ }
+ return result;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegateOld.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegateOld.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegateOld.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegateOld.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.launching;
+
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate;
+import org.eclipse.dltk.launching.IInterpreterRunner;
+import org.eclipse.dltk.launching.InterpreterConfig;
+
+
+public class RutaLaunchConfigurationDelegateOld extends
+ AbstractScriptLaunchConfigurationDelegate {
+
+ @Override
+ protected void runRunner(ILaunchConfiguration configuration, IInterpreterRunner runner,
+ InterpreterConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ if (runner instanceof IConfigurableRunner) {
+ IRutaInterpreterRunnerConfig runnerConfig = getConfig();
+ if (runnerConfig != null) {
+ IConfigurableRunner rc = (IConfigurableRunner) runner;
+ rc.setRunnerConfig(runnerConfig);
+ }
+ }
+ runner.run(config, launch, monitor);
+ }
+
+ public IRutaInterpreterRunnerConfig getConfig() {
+ return null;
+ }
+
+ @Override
+ public String getLanguageId() {
+ return RutaNature.NATURE_ID;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConstants.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConstants.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+public class RutaLaunchConstants {
+
+ public static final String ARG_INPUT_FOLDER = "-inputFolder";
+
+ public static final String ARG_OUTPUT_FOLDER = "-outputFolder";
+
+ public static final String ARG_DESCRIPTOR = "-descriptor";
+
+ public static final String ARG_RECURSIVE = "-inputRecursive";
+
+ public static final String ARG_MODE = "-mode";
+
+ public static final String ARG_VIEW = "-view";
+
+ public static final String ARG_ENCODING = "-encoding";
+
+ public static final String INPUT_FOLDER = "org.apache.uima.ruta.ide.launching.inputFolder";
+
+ public static final String OUTPUT_FOLDER = "org.apache.uima.ruta.ide.launching.outputFolder";
+
+ public static final String RECURSIVE = "org.apache.uima.ruta.ide.launching.recursive";
+
+ public static final String VIEW = "org.apache.uima.ruta.ide.launching.view";
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLauncher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLauncher.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLauncher.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaLauncher.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.cas.impl.XmiCasSerializer;
+import org.apache.uima.resource.ResourceConfigurationException;
+import org.apache.uima.ruta.engine.Ruta;
+import org.apache.uima.ruta.engine.RutaEngine;
+import org.apache.uima.util.FileUtils;
+import org.apache.uima.util.XMLSerializer;
+import org.apache.uima.util.impl.ProcessTrace_impl;
+import org.xml.sax.SAXException;
+
+public class RutaLauncher {
+
+ private static File descriptor;
+
+ private static File inputFolder;
+
+ private static File outputFolder = null;
+
+ private static boolean inputRecursive = false;
+
+ private static String inputEncoding = java.nio.charset.Charset.defaultCharset().name();
+
+ private static String launchMode = "run";
+
+ private static String view = null;
+
+ private static boolean parseCmdLineArgs(String[] args) {
+ int index = 0;
+ int count = 0;
+ while (index < args.length) {
+ String each = args[index++];
+ if (RutaLaunchConstants.ARG_INPUT_FOLDER.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ count++;
+ inputFolder = new File(args[index++]);
+ } else if (RutaLaunchConstants.ARG_OUTPUT_FOLDER.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ outputFolder = new File(args[index++]);
+ } else if (RutaLaunchConstants.ARG_DESCRIPTOR.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ count++;
+ descriptor = new File(args[index++]);
+ } else if (RutaLaunchConstants.ARG_RECURSIVE.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ inputRecursive = Boolean.parseBoolean(args[index++]);
+ } else if (RutaLaunchConstants.ARG_RECURSIVE.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ inputEncoding = args[index++];
+ } else if (RutaLaunchConstants.ARG_MODE.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ launchMode = args[index++];
+ } else if (RutaLaunchConstants.ARG_VIEW.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ view = args[index++];
+ }
+ }
+ return count == 2;
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (!parseCmdLineArgs(args)) {
+ throw new IllegalArgumentException("Passed arguments are invalid!");
+ }
+
+ AnalysisEngine ae = Ruta
+ .wrapAnalysisEngine(descriptor.toURL(), view, true, inputEncoding);
+ configure(ae);
+ CAS cas = ae.newCAS();
+
+ List<File> inputFiles = getFiles(inputFolder, inputRecursive);
+ for (File file : inputFiles) {
+ processFile(file, ae, cas);
+ }
+
+ ae.collectionProcessComplete(new ProcessTrace_impl());
+ cas.release();
+ ae.destroy();
+ }
+
+ private static void processFile(File file, AnalysisEngine ae, CAS cas) throws IOException,
+ AnalysisEngineProcessException, SAXException {
+ if (view != null) {
+ boolean found = false;
+ Iterator<CAS> viewIterator = cas.getViewIterator();
+ while (viewIterator.hasNext()) {
+ CAS each = (CAS) viewIterator.next();
+ String viewName = each.getViewName();
+ if (viewName.equals(view)) {
+ cas = cas.getView(view);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ cas = cas.createView(view);
+ }
+
+ }
+ if (file.getName().endsWith(".xmi")) {
+ XmiCasDeserializer.deserialize(new FileInputStream(file), cas, true);
+ } else {
+ String document = FileUtils.file2String(file, inputEncoding);
+ cas.setDocumentText(document);
+ }
+ ae.process(cas);
+ if (outputFolder != null) {
+ File outputFile = getOutputFile(file, inputFolder, outputFolder);
+ writeXmi(cas, outputFile);
+ }
+ cas.reset();
+ }
+
+ private static void configure(AnalysisEngine ae) throws ResourceConfigurationException {
+ if ("debug".equals(launchMode)) {
+ ae.setConfigParameterValue(RutaEngine.CREATE_DEBUG_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_MATCH_DEBUG_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_PROFILING_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_STATISTIC_INFO, true);
+ ae.setConfigParameterValue(RutaEngine.CREATE_CREATED_BY_INFO, true);
+ }
+ ae.reconfigure();
+
+ }
+
+ private static List<File> getFiles(File dir, boolean recusive) {
+ List<File> result = new ArrayList<File>();
+ for (File each : dir.listFiles()) {
+ // TODO: find a solution for this hotfix
+ if (each.isHidden()) {
+ continue;
+ }
+ result.add(each);
+ if (each.isDirectory() && recusive) {
+ result.addAll(getFiles(each, recusive));
+ }
+ }
+ return result;
+ }
+
+ private static void writeXmi(CAS cas, File file) throws IOException, SAXException {
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(file);
+ XmiCasSerializer ser = new XmiCasSerializer(cas.getTypeSystem());
+ XMLSerializer xmlSer = new XMLSerializer(out, false);
+ ser.serialize(cas, xmlSer.getContentHandler());
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private static File getOutputFile(File inputFile, File inputFolder, File outputFolder) {
+ URI relativize = inputFolder.toURI().relativize(inputFile.toURI());
+ String path = relativize.getPath();
+ if (!path.endsWith(".xmi")) {
+ path += ".xmi";
+ }
+ File result = new File(outputFolder, path);
+ result.getParentFile().mkdirs();
+ return result;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaSourceLookupDirector.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaSourceLookupDirector.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaSourceLookupDirector.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/launching/RutaSourceLookupDirector.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.launching;
+
+import java.io.File;
+import java.net.URI;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.dltk.internal.debug.core.model.ScriptStackFrame;
+
+public class RutaSourceLookupDirector implements IPersistableSourceLocator {
+
+ public RutaSourceLookupDirector() {
+ }
+
+ public Object getSourceElement(IStackFrame stackFrame) {
+ if (stackFrame instanceof ScriptStackFrame) {
+ ScriptStackFrame sf = (ScriptStackFrame) stackFrame;
+ URI uri = sf.getFileName();
+
+ String pathname = uri.getPath();
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ pathname = pathname.substring(1);
+ }
+
+ File file = new File(pathname);
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IContainer container = root.getContainerForLocation(new Path(file.getParent()));
+
+ if (container != null) {
+ IResource resource = container.findMember(file.getName());
+
+ if (resource instanceof IFile) {
+ return resource;
+ }
+ } else {
+ return file;
+ }
+ }
+
+ return null;
+ }
+
+ public String getMemento() throws CoreException {
+ return null;
+ }
+
+ public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException {
+
+ }
+
+ public void initializeFromMemento(String memento) throws CoreException {
+
+ }
+}