- 浏览: 54512 次
- 性别:
- 来自: 沈阳
-
最新评论
-
imu2008:
嗯,此方法可用。好文。mark
rcp中新建工程没有图标解决方案 -
553563608:
今天也遇到这个问题了,,,,
这个方法可以解决。。。
rcp中新建工程没有图标解决方案 -
zhaozhongwei:
这个就不清楚了,我们也是两个文件啊。我很久没搞gmf了
关于gmf copy/paste 的解决方案 -
popjxc:
我下了你的代码,发现copy paste后,原来复制的是一个n ...
关于gmf copy/paste 的解决方案 -
赤道螞蟻:
你這不是用附件的方式傳的圖片嗎? 沒有什麽新招?
用java mail发送包含图片的html
I ran a query
to see all the bugs fixed in the
Eclipse Platform in 3.6; it is a long list (4309 and counting). Felipe gets
credit for the oldest bug fixed
(raised in 2001), but
in a close second is bug 4922
(raised only a day later).
This bug is about opening files in eclipse
from the command line. Fixing it required a coordinated effort between Platform
UI, SWT
, and the Equinox launcher
. A lot of the credit
for what was done goes to Kevin Barnes.
This post is an effort to explain some of
the technical details of what is going here.
On the Mac...
: On the mac all we do is
handle the apple event "kAEOpenDocuments
", most of the rest of
this post doesn't apply to the mac.
Windows and GTK...
Everything below
applies to Windows and GTK, though there are some differences in the
implementation details.
On
Motif...
Sorry, this doesn't work on motif.
The Launcher
Everything starts in the eclipse launcher. We added a few new command line options:
- --launcher.openFile : obvious enough, specifies the file we want to open.
-
--launcher.defaultAction
: less obvious,
specifies the action to take when the launcher is started without any '-'
arguments on the command line. Currently the only support value is
"openFile
".
-
--launcher.timeout
: a timeout value for
how long we should spend trying to communicate with an already running eclipse
before we give up and just open a new eclipse instance. Default is 60
(seconds).
The first argument is obvious enough, open the specified file in eclipse.
eclipse --launcher.openFile myFile.txt
This is great, but it is a bit much to type on the command line and is not quite enough to make everyone happy. We introduced the "default action" argument. This goes in the eclipse.ini file, the value should be "openFile ":
... -showsplash org.eclipse.platform --launcher.defaultAction openFile -vmargs -Xms256m -Xmx768m
This tells the launcher that if it is called with a command line that only contains arguments that don't start with "- ", then those arguments should be treated as if they followed "--launcher.openFile ".
eclipse myFile.txt
This is the kind of command line the launcher will receive on windows when you double click a file that is associated with eclipse, or you select files and choose "Open With" or "Send To " Eclipse.
Relative paths
will be resolved first against the current working directory, and second against
the eclipse program directory.
Talking to SWT
The launcher talks
to SWT through the use of a hidden window. The launcher and SWT both need to agree on
the name of this window
. This allows the launcher to find an already running
eclipse and tell it to open the file. Any RCP application will need to ensure
they get this right for things to work.
The launcher bases this on its "official
name". The official name can be set with the -name
argument. If -name
is not set, then the official
name is derived from the launcher executable, the extension is removed and the
first letter is capitalized: rcp.exe
becomes Rcp
.
SWT bases this on the value set with the
Display.setAppName()
function.
Normally, this is set by the Workbench when it creates the display and the value
is the "appName" taken from the product extension point.
Listening to SWT
To take advantage
of this, an RCP Application will need to register a listener for the
SWT.OpenDocument event. It should register this listener before calling PlatformUI.createAndRunWorkbench
so
that the listener is in place before the workbench starts running the event
loop.
The event loop will start running while the
splash screen is still up, so events may arrive before the workbench is ready to
actually open an editor for the file. This means that the listener should save
the file paths it gets from the OpenDocument events so they can be opened at
some later time. WorkbenchAdvisor#eventLoopIdle
can be
a good place to check for saved open file events.
Implementation details
Here is an overview of the flow of events in the launcher when processing --launcher.openFile on windows.
- Get the Official Name. As mentioned above, this is the "-name" argument, or
derived from the executable name. For this explanation, we will be using "OfficialName
".
- Create and lock a mutex
named
"SWT_Mutex_OfficialName".
- If multiple files are selected and opened on windows, then a seperate eclipse process will be created for each one. The mutex allows us to ensure only one eclipse instance is actually started.
- One process will win the race to acquire the mutex, at this point, there will be no eclipse instance running that has the SWT window available. This process will start normally and eventually create the SWT window at which point it will release the mutex.
- All the other processes wait trying to acquire the mutex, once the original process releases it, they will be able to find the SWT window and post their open file message there.
- Each process only waits for --launcher.timeout seconds (default 60 seconds) before giving up and just starting its own full eclipse instance.
- Find the window named "SWT_Window_OfficialName"
- If no such window exists, we are the first eclipse instance. In this case, we set a timer to look again later and then proceed with starting eclipse.
- The timer fires every second for --launcher.timeout seconds.
- If we don't find the SWT window before the timeout (perhaps it took too long
for the workbench to create the display), then we will be unable to open the
file.
- Send a message to the SWT window
- Once we've found the SWT window, we create a custom message named "SWT_OPENDOC". We send this message with wParam & lParam specifying a shared memory id.
- We write to the name of the file to open into shared memory, and when SWT receives the SWT_OPENDOC message, it uses that id to read the shared memory.
- The launcher has long used shared memory on all platforms for the splash screen, restarts and exit messages.
- Once SWT reads the file name from shared memory, it posts its own SWT.OpenDocument event.
On GTK, things happen in a similar manner with a few differences:
- We use semaphores
.
- Semaphores are not cleaned up automatically if the process exits
unexpectedly. So we try to hold the semaphore for as short a time as possible
and we install SIGINT and SIGQUIT signal handlers for the time we hold the
semaphore.
- The launcher creates a hidden GTK window named
SWT_Window_LauncherOfficalName
which is used in the same way as
the mutex on windows. This lets us avoid holding the semaphore for an extended
time while the first eclipse process starts up.
- Semaphores are not cleaned up automatically if the process exits
unexpectedly. So we try to hold the semaphore for as short a time as possible
and we install SIGINT and SIGQUIT signal handlers for the time we hold the
semaphore.
- We use a property
instead of a message.
- The property is named org.eclipse.swt.filePath.message .
- The value is a colon separate list of file paths to open. Shared memory is not used like it is on windows.
发表评论
-
How to Debug and Detect Deadlocks
2010-12-01 15:04 1068Deadlocks in 2 minutes ... -
Run FindBugs from your Eclipse RCP headless build
2010-12-01 14:53 1037Running FindBugs from Eclipse R ... -
Markers and Annotations in Eclipse for Error Feedback(forward)
2010-12-01 14:39 1621Motto: Ninety per cent ... -
Testing declarative Eclipse expressions(forward)
2010-11-19 08:32 1096Our Eclipse-based product plugs ... -
Release engineer vs dependency management: Basing RCP Product and headless build
2010-11-02 23:32 902http://www.bonitasoft.org/blog/ ... -
Unit testing puzzle – How can I verify that System.exit() gets called?
2010-08-14 08:17 0Sounds strange – yes, very ... -
Invoking an Eclipse Wizard programmatically
2010-07-23 09:45 0Sometimes I find the need to ... -
A testing strategy for multiple inheritance in EMF generated code.
2010-07-23 09:12 0I recently became a comittter ... -
Can we build it? Yes we can!(FW)
2010-07-16 11:05 0Thomas Hallgren, Michal Ruzicka ... -
eclipse headless
2010-06-16 17:37 1506java -jar <eclipse-install ... -
Generating p2 meta data from command line
2010-06-11 12:08 816Many times when working with ... -
http://cvalcarcel.wordpress.com/
2010-04-09 03:00 0http://cvalcarcel.wordpress.com ... -
HOWTO: Build Plugin & Feature Projects, Then Run Their Unit Tests w/ Tycho ::GEF
2010-04-03 14:30 01. Check out entire source tree ... -
Tip: How to Debug SWT components in Modal Dialogs(转发)
2010-04-03 14:22 0SWT and JFace components, and e ... -
action
2010-03-24 17:22 0这两天在改一个bug,跟action有关的,以前一直也没好好弄 ... -
SWT: Drop an Outlook Email(转发)
2010-03-18 14:43 1898I wanted to drop an outlook ema ... -
终于成为eclipse的committer了
2010-03-16 16:33 3219虽然以前也是committer,但是是个非常小的工程还是卵化期 ... -
Animated GIF in TableViewer
2010-03-02 12:23 0I'm quite attached to TableVie ... -
extend jdt with ot
2010-02-28 11:56 0extend jdt with ot http://blog ... -
RCP Update: No more "jammern" with InstallJammer
2010-01-29 14:44 0Wow, I got a lot of feedback be ...
相关推荐
From the command line, cd into the appfuse directory and type "mvn idea:idea". Get a cup of coffee or soda (or even better, a beer!) while you wait for Maven to download all the dependencies. After...
The second mode is the Prototype mode which is used solely for generating MEGA Analysis Options (.mao) files that specify analysis settings when using MEGA from a command shell The command-line ...
Add new command line argument "-r" for opening files recursively (with wildcard characters). Fix the crash bug while setting current document as Objective-C source code. Fix rename not replacing ...
We are often asked if it is possible to run an UltraEdit macro or script on a file from the command line. The answer is yes - and it's not only possible, it's extremely simple! Using find/replace ...
command line option is used. Release 5.3 build 1014 WIN32 release 30 January 2008 - Corrected a problem where the loopback sound test could run out of memory if run for several days. Release 5.3 ...
The program begins by opening a word list text file, specified by a command line parameter. The program outputs an error message and terminates if it cannot open the specified word list text file. A ...
package is different from the '-A' command line flag option described under Compressed .ZIP Distribution. Example: To extract INF files using the '-A' flag described below, the installation ...
Opening, searching in, and closing dozens of files isn’t fun, and the task becomes more and more challenging as the number of files increases. Because the problem involves searching through CSV and ...
The program begins by opening a word list text file, specified by a command line parameter. The program outputs an error message and terminates if it cannot open the specified word list text file. A ...
From the command line, navigate to your source code directory and invoke the `lint` executable with your configuration file and source files: ``` lint -f my_config.gsl src/*.c src/*.cpp ``` This ...
Typical services include executing a new program, opening a file, reading a file, allocating a region of memory, getting the current time of day, and so on. The focus of this text is to describe the ...
Undoubtedly, Microsoft Word is the best choice for writing documents, but you have to use different tools to create CHM help files and online documents. However, what bothers you most is not using how...
Using the twill command line program 155 Using twill in a TestCase 159 Summary 167 Chapter 6: Django Debugging Overview 169 Django debug settings 170 The DEBUG and TEMPLATE_DEBUG settings 170 ...
The problem is that opening one or more Word Excel attachments may cause the attachments to be accidentally trashed and disappear from in the attachment pane The problem source is that myBase by ...
When I load the WW project in my Visual C# 2005 Express Edition , I get the following error when I open WorldWind.cs. I can open the code but the designer refuses to open it. The designer cannot ...
They can be downloaded from the download section where you can find the other translation files, or right here June 7 2017:Cheat Engine 6.7 Released: Cheat Engine 6.7 has been released. New lua ...
When enabled the folder history when opening and saving files is project specific. When disabled, the general history will be used. Project file browser preference. When enabled the project has its ...
back-end, allowing online access to one’s data from anywhere in the world. HTTP headers were leveraged to provide the continuity of a user session on top of this stateless protocol, opening the ...