Revision 464

tmp/org.txm.xmleditor.rcp/.project (revision 464)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>XmlEditorRCP</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.xmleditor.rcp/src/org/txm/xmleditor/OpenXMLEditor.java (revision 464)
1
package org.txm.xmleditor;
2

  
3
import java.io.File;
4
import java.net.URI;
5

  
6
import org.eclipse.core.commands.AbstractHandler;
7
import org.eclipse.core.commands.ExecutionEvent;
8
import org.eclipse.core.commands.ExecutionException;
9
import org.eclipse.core.filesystem.EFS;
10
import org.eclipse.core.filesystem.IFileStore;
11
import org.eclipse.core.resources.IStorage;
12
import org.eclipse.core.runtime.Path;
13
import org.eclipse.equinox.internal.ds.storage.file.FileStorage;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.widgets.FileDialog;
19
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.ui.IStorageEditorInput;
21
import org.eclipse.ui.IWorkbenchPage;
22
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.PartInitException;
24
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.handlers.HandlerUtil;
26
import org.eclipse.ui.ide.FileStoreEditorInput;
27
import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart;
28
import org.txm.Toolbox;
29
import org.txm.core.preferences.TBXPreferences;
30
import org.txm.core.preferences.TXMPreferences;
31
import org.txm.rcp.Messages;
32
import org.txm.rcp.StatusLine;
33
import org.txm.rcp.TXMWindows;
34
import org.txm.rcp.swt.dialog.LastOpened;
35
import org.txm.utils.logger.Log;
36

  
37
import xmleditorrcp.XMLEditorMessages;
38

  
39
public class OpenXMLEditor  extends AbstractHandler {
40

  
41
	public static final String ID = "org.txm.xmleditor.OpenXMLEditor"; //$NON-NLS-1$
42
	public static String lastopenedfile;
43
	
44
	@Override
45
	public Object execute(ExecutionEvent event) throws ExecutionException {
46
		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
47
				.getShell();
48
		String txmhome = TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE);
49
		String filename = event
50
				.getParameter("org.txm.rcpapplication.commands.commandParameter2"); //$NON-NLS-1$
51
		if (filename != null && !filename.matches("") && !filename.matches(" ")) { //$NON-NLS-1$ //$NON-NLS-2$
52
			String filepath = txmhome + "/scripts/" + filename; //$NON-NLS-1$ 
53
			openfile(new File(filepath));
54
			return null;
55
		}
56

  
57
		File file = null;
58
		ISelection selection = HandlerUtil.getCurrentSelection(event);
59
		if (selection != null & selection instanceof IStructuredSelection) {
60
			IStructuredSelection strucSelection = (IStructuredSelection) selection;
61
			for (Object o : strucSelection.toList()) {
62
				if(o != null && o instanceof File) {
63
					file = (File)o;
64
					break;
65
				}
66
			}
67
		}
68

  
69
		if (file == null) {
70

  
71
			FileDialog dialog = new FileDialog(shell, SWT.OPEN);
72
			if (LastOpened.getFile(ID) != null) {
73
				dialog.setFilterPath(LastOpened.getFolder(ID));
74
				dialog.setFileName(LastOpened.getFile(ID));
75
			} else {
76
				dialog.setFilterPath(txmhome);
77
			}
78
			if (dialog.open() == null) return null;
79
			String filepath = dialog.getFilterPath()
80
					+ "/" + dialog.getFileName(); //$NON-NLS-1$
81
			lastopenedfile = filepath;
82
			LastOpened.set(ID, dialog.getFilterPath(), dialog.getFileName());
83
			openfile(new File(filepath));
84
		} else {
85
			if (file.isDirectory()) {
86
				FileDialog dialog = new FileDialog(shell, SWT.OPEN);
87
				dialog.setFilterPath(file.getAbsolutePath());
88
				dialog.open();
89
				String filepath = dialog.getFilterPath()
90
						+ "/" + dialog.getFileName(); //$NON-NLS-1$
91
				openfile(new File(filepath));
92
			} else {
93
				openfile(file);
94
			}
95
		}
96

  
97
		return null;
98
	}
99

  
100
	private boolean openfile(File file) {
101
		//XMLMultiPageEditorPart editorInput = new ConcordancesEditorInput(corpus, null);
102
		Log.info(XMLEditorMessages.OpenXMLEditor_1);
103
		IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(
104
				file.toURI());
105

  
106
		URI _uri = file.toURI();
107
		new Path(_uri.getPath());
108

  
109
		FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);
110
		IWorkbenchWindow window = PlatformUI.getWorkbench()
111
				.getActiveWorkbenchWindow();
112
		IWorkbenchPage page = window.getActivePage();
113

  
114
		String ID = "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart"; //$NON-NLS-1$
115
		try {
116
			StatusLine.setMessage(XMLEditorMessages.OpenXMLEditor_3);
117
			page.openEditor(editorInput, ID); //$NON-NLS-1$
118
		} catch (PartInitException e) {
119
			System.out.println(XMLEditorMessages.OpenXMLEditor_4+e);
120
		}
121
		return true;
122
	}
123
}
0 124

  
tmp/org.txm.xmleditor.rcp/src/xmleditorrcp/messages_fr.properties (revision 464)
1
OpenXMLEditor_1=Ouverture de l'?diteur XML...
2
OpenXMLEditor_3=Ouverture de l'?diteur XML...
3
OpenXMLEditor_4=Erreur : 
0 4

  
tmp/org.txm.xmleditor.rcp/src/xmleditorrcp/Activator.java (revision 464)
1
package xmleditorrcp;
2

  
3
import org.eclipse.jface.resource.ImageDescriptor;
4
import org.eclipse.ui.plugin.AbstractUIPlugin;
5
import org.osgi.framework.BundleContext;
6

  
7
/**
8
 * The activator class controls the plug-in life cycle
9
 */
10
public class Activator extends AbstractUIPlugin {
11

  
12
	// The plug-in ID
13
	public static final String PLUGIN_ID = "XmlEditorRCP"; //$NON-NLS-1$
14

  
15
	// The shared instance
16
	private static Activator plugin;
17
	
18
	/**
19
	 * The constructor
20
	 */
21
	public Activator() {
22
	}
23

  
24
	/*
25
	 * (non-Javadoc)
26
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
27
	 */
28
	public void start(BundleContext context) throws Exception {
29
		super.start(context);
30
//		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
31
//		PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
32
//		System.out.println("REMOVE PAGE: org.eclipse.team.svn.ui.SVNTeamPreferences");
33
//		pm.remove("org.eclipse.team.svn.ui.SVNTeamPreferences"); //$NON-NLS-1$
34

  
35
//		//Remove RCP Web browser preference page
36
//		IPreferenceNode[] arr = pm.getRootSubNodes();
37
//		for(IPreferenceNode pn : arr){
38
//			//		    System.out.println("Label:" + pn.getLabelText() + " ID:" + pn.getId()+" Type: "+pn.getClass());
39
//			//		    for (IPreferenceNode subn : pn.getSubNodes()) {
40
//			//		    	System.out.println(" SLabel:" + subn.getLabelText() + " ID:" + subn.getId());
41
//			//		    }
42
//			if ("org.eclipse.ui.preferencePages.Workbench".equals(pn.getId())) {
43
//				WorkbenchPreferenceNode pwn = (WorkbenchPreferenceNode)pn;
44
//				pwn.remove("org.eclipse.ui.browser.preferencePage");
45
//			}
46
//		}
47
		//page.hideActionSet("org.eclipse.team.svn.ui.SVNTeamPreferences"); //$NON-NLS-1$
48
		// Validation
49
	 	//page.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation"); //$NON-NLS-1$
50
		plugin = this;
51
	}
52

  
53
	/*
54
	 * (non-Javadoc)
55
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
56
	 */
57
	public void stop(BundleContext context) throws Exception {
58
		plugin = null;
59
		super.stop(context);
60
	}
61

  
62
	/**
63
	 * Returns the shared instance
64
	 *
65
	 * @return the shared instance
66
	 */
67
	public static Activator getDefault() {
68
		return plugin;
69
	}
70

  
71
	/**
72
	 * Returns an image descriptor for the image file at the given
73
	 * plug-in relative path
74
	 *
75
	 * @param path the path
76
	 * @return the image descriptor
77
	 */
78
	public static ImageDescriptor getImageDescriptor(String path) {
79
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
80
	}
81
}
0 82

  
tmp/org.txm.xmleditor.rcp/src/xmleditorrcp/XMLEditorMessages.java (revision 464)
1
package xmleditorrcp;
2

  
3
import org.eclipse.osgi.util.NLS;
4

  
5
public class XMLEditorMessages extends NLS {
6
	private static final String BUNDLE_NAME = "xmleditorrcp.messages"; //$NON-NLS-1$
7
	public static String OpenXMLEditor_1;
8
	public static String OpenXMLEditor_3;
9
	public static String OpenXMLEditor_4;
10
	static {
11
		// initialize resource bundle
12
		NLS.initializeMessages(BUNDLE_NAME, XMLEditorMessages.class);
13
	}
14

  
15
	private XMLEditorMessages() {
16
	}
17
}
0 18

  
tmp/org.txm.xmleditor.rcp/src/xmleditorrcp/messages.properties (revision 464)
1
OpenXMLEditor_1=Open XML Editor...
2
OpenXMLEditor_3=Opening XML editor...
3
OpenXMLEditor_4=Error: 
0 4

  
tmp/org.txm.xmleditor.rcp/bin/xmleditorrcp/messages_fr.properties (revision 464)
1
OpenXMLEditor_1=Ouverture de l'?diteur XML...
2
OpenXMLEditor_3=Ouverture de l'?diteur XML...
3
OpenXMLEditor_4=Erreur : 
tmp/org.txm.xmleditor.rcp/bin/xmleditorrcp/messages.properties (revision 464)
1
OpenXMLEditor_1=Open XML Editor...
2
OpenXMLEditor_3=Opening XML editor...
3
OpenXMLEditor_4=Error: 
tmp/org.txm.xmleditor.rcp/build.properties (revision 464)
1
source.. = src/
2
output.. = bin/
3
bin.includes = plugin.xml,\
4
               META-INF/,\
5
               .,\
6
               OSGI-INF/l10n/bundle.properties
0 7

  
tmp/org.txm.xmleditor.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 464)
1
#Properties file for XmlEditorRCP
2
command.name = Ouvrir un fichier XML
3
command.label = ?diteur XML
4
command.tooltip = Ouvre le fichier s?lectionner dans l'?diteur XML
5
activity.name = disable activity
6
Bundle-Name = ?diteur XML
0 7

  
tmp/org.txm.xmleditor.rcp/OSGI-INF/l10n/bundle.properties (revision 464)
1
#Properties file for XmlEditorRCP
2
command.name = Open XML File...
3
command.label = XmlEditor
4
command.tooltip = Open the selected file with the XML editor
5
activity.name = disable activity
6
Bundle-Name = XmlEditorRCP
0 7

  
tmp/org.txm.xmleditor.rcp/plugin.xml (revision 464)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.commands">
6
      <command
7
            categoryId="org.txm.rcpapplication.category.txm"
8
            defaultHandler="org.txm.xmleditor.OpenXMLEditor"
9
            id="org.txm.xmleditor.OpenXMLEditor"
10
            name="%command.name">
11
      </command>
12
   </extension>
13
   <extension
14
         point="org.eclipse.ui.menus">
15
      <menuContribution
16
            locationURI="menu:menu.file?after=file.open">
17
         <command
18
               commandId="org.txm.xmleditor.OpenXMLEditor"
19
               style="push">
20
         </command>
21
      </menuContribution>
22
      <menuContribution
23
            locationURI="menu:menu.help.plugins">
24
         <command
25
               commandId="org.txm.rcpapplication.commands.OpenBrowser"
26
               label="%command.label"
27
               style="push">
28
            <parameter
29
                  name="org.txm.rcpapplication.commands.commandParameter2"
30
                  value="https://groupes.renater.fr/wiki/txm-users/public/extensions#xmleditor">
31
            </parameter>
32
         </command>
33
      </menuContribution>
34
      <menuContribution
35
            locationURI="popup:org.txm.rcpapplication.views.fileexplorer.Explorer">
36
         <command
37
               commandId="org.txm.xmleditor.OpenXMLEditor"
38
               style="push"
39
               tooltip="%command.tooltip">
40
            <visibleWhen
41
                  checkEnabled="false">
42
               <reference
43
                     definitionId="OneFileSelected">
44
               </reference>
45
            </visibleWhen>
46
         </command>
47
      </menuContribution>
48
   </extension>
49
   <extension
50
         point="org.eclipse.ui.activities">
51
         
52
  <activityPatternBinding
53
        activityId="arm.activity.disabled"
54
        pattern=".*org\.eclipse\.search\..*">
55
  </activityPatternBinding>
56
  <activityPatternBinding
57
        activityId="arm.activity.disabled"
58
        pattern=".*ValidationPreferencePage.*">
59
  </activityPatternBinding>
60
  <activityPatternBinding
61
        activityId="arm.activity.disabled"
62
        pattern=".*org\.eclipse\.debug\.ui\.DebugPreferencePage.*">
63
  </activityPatternBinding>
64
      <activityPatternBinding
65
        activityId="arm.activity.disabled"
66
        pattern=".*org\.eclipse\.team\.ui\.TeamPreferences.*">
67
  </activityPatternBinding>
68
  
69
      <activity
70
            id="arm.activity.disabled"
71
            name="%activity.name">
72
            <enabledWhen>
73
        <with
74
              variable="selection">
75
           <count
76
                 value="-1">
77
           </count>
78
        </with>
79
     </enabledWhen>
80
      </activity>
81
   </extension>
82
</plugin>
0 83

  
tmp/org.txm.xmleditor.rcp/.settings/org.eclipse.jdt.core.prefs (revision 464)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.xmleditor.rcp/.classpath (revision 464)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
9
	<classpathentry kind="src" path="src"/>
10
	<classpathentry kind="output" path="bin"/>
11
</classpath>
0 12

  
tmp/org.txm.xmleditor.rcp/META-INF/MANIFEST.MF (revision 464)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: XmlEditorRCP;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: xmleditorrcp.Activator
7
Require-Bundle: org.eclipse.ui,
8
 org.eclipse.core.runtime,
9
 org.eclipse.wst.xml.ui;bundle-version="1.1.401",
10
 org.eclipse.core.filesystem;bundle-version="1.4.0",
11
 org.eclipse.ui.ide;bundle-version="3.9.0",
12
 org.eclipse.wst.sse.ui;bundle-version="1.3.200",
13
 org.eclipse.wst.sse.core;bundle-version="1.1.801",
14
 org.eclipse.wst.xml.core;bundle-version="1.1.801",
15
 org.eclipse.wst.common.uriresolver;bundle-version="1.2.100",
16
 org.eclipse.wst.common.core;bundle-version="1.2.0",
17
 org.eclipse.wst.validation;bundle-version="1.2.500",
18
 org.eclipse.wst.validation.ui;bundle-version="1.2.400",
19
 org.eclipse.search;bundle-version="3.9.0",
20
 org.eclipse.wst.common.project.facet.core;bundle-version="1.4.300",
21
 org.eclipse.wst.common.ui;bundle-version="1.1.500",
22
 org.eclipse.debug.core;bundle-version="3.8.0",
23
 org.eclipse.debug.ui;bundle-version="3.9.0",
24
 org.eclipse.wst.common.frameworks;bundle-version="1.2.200",
25
 org.eclipse.wst.common.frameworks.ui;bundle-version="1.2.201",
26
 org.apache.xml.serializer;bundle-version="2.7.1",
27
 org.eclipse.ui.views;bundle-version="3.7.0",
28
 org.eclipse.jface.text;bundle-version="3.9.2",
29
 org.eclipse.core.expressions;bundle-version="3.4.600",
30
 org.txm.core;bundle-version="0.7.0",
31
 org.txm.rcp;bundle-version="0.7.8"
32
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
33
Bundle-ActivationPolicy: lazy
34
Export-Package: org.txm.xmleditor,
35
 xmleditorrcp
36
Bundle-Vendor: Textometrie.org
0 37

  

Also available in: Unified diff