Lines 19-24
Link Here
|
19 |
import org.eclipse.jface.action.ActionContributionItem; |
19 |
import org.eclipse.jface.action.ActionContributionItem; |
20 |
import org.eclipse.jface.action.IAction; |
20 |
import org.eclipse.jface.action.IAction; |
21 |
import org.eclipse.swt.internal.Callback; |
21 |
import org.eclipse.swt.internal.Callback; |
|
|
22 |
import org.eclipse.swt.internal.carbon.EventRecord; |
22 |
import org.eclipse.swt.internal.carbon.HICommand; |
23 |
import org.eclipse.swt.internal.carbon.HICommand; |
23 |
import org.eclipse.swt.internal.carbon.OS; |
24 |
import org.eclipse.swt.internal.carbon.OS; |
24 |
import org.eclipse.swt.widgets.Display; |
25 |
import org.eclipse.swt.widgets.Display; |
Lines 85-90
Link Here
|
85 |
public void run() { |
86 |
public void run() { |
86 |
hookApplicationMenu(display); |
87 |
hookApplicationMenu(display); |
87 |
hookToolbarButtonCallback(); |
88 |
hookToolbarButtonCallback(); |
|
|
89 |
hookApplescriptCallback(); |
88 |
hookWorkbenchListener(); |
90 |
hookWorkbenchListener(); |
89 |
// modify all shells opened on startup |
91 |
// modify all shells opened on startup |
90 |
IWorkbenchWindow[] windows = PlatformUI.getWorkbench() |
92 |
IWorkbenchWindow[] windows = PlatformUI.getWorkbench() |
Lines 96-102
Link Here
|
96 |
}); |
98 |
}); |
97 |
} |
99 |
} |
98 |
|
100 |
|
99 |
/** |
101 |
protected void hookApplescriptCallback() { |
|
|
102 |
Object target = new Object() { |
103 |
public int applescriptProc(int nextHandler, int inEvent, |
104 |
int userData) { |
105 |
boolean doRelease = false; |
106 |
int err = OS.noErr; |
107 |
EventRecord eventRecord = new EventRecord(); |
108 |
|
109 |
if (doRelease = OS.IsEventInQueue(OS.GetMainEventQueue(), |
110 |
inEvent)) { |
111 |
|
112 |
OS.RetainEvent(inEvent); |
113 |
OS.RemoveEventFromQueue(OS.GetMainEventQueue(), inEvent); |
114 |
} |
115 |
|
116 |
OS.ConvertEventRefToEventRecord(inEvent, eventRecord); |
117 |
err = OS.AEProcessAppleEvent(eventRecord); |
118 |
if (doRelease) |
119 |
OS.ReleaseEvent(inEvent); |
120 |
return err; |
121 |
} |
122 |
|
123 |
}; |
124 |
final Callback commandCallback = new Callback(target, |
125 |
"applescriptProc", 3); //$NON-NLS-1$ |
126 |
int commandProc = commandCallback.getAddress(); |
127 |
if (commandProc == 0) { |
128 |
commandCallback.dispose(); |
129 |
return; // give up |
130 |
} |
131 |
|
132 |
int[] mask = new int[] { OS.kEventClassAppleEvent, OS.kEventAppleEvent }; |
133 |
OS.InstallEventHandler(OS.GetApplicationEventTarget(), commandProc, |
134 |
mask.length / 2, mask, 0, null); |
135 |
|
136 |
Object openAppleScriptHandler = new Object() { |
137 |
public int handle(int inEvent, int outEvent, int ref) { |
138 |
System.out.println("Handled."); //$NON-NLS-1$ |
139 |
return OS.noErr; |
140 |
} |
141 |
}; |
142 |
final Callback appleScriptCallback = new Callback(openAppleScriptHandler, "handle", 3); //$NON-NLS-1$ |
143 |
int openAppleScriptProc = appleScriptCallback.getAddress(); |
144 |
if (openAppleScriptProc == 0) { |
145 |
appleScriptCallback.dispose(); |
146 |
return; // give up |
147 |
} |
148 |
OS.AEInstallEventHandler(AppleScriptConstants.kCoreEventClass, AppleScriptConstants.kAEOpenApplication, openAppleScriptProc, 0, false); |
149 |
} |
150 |
|
151 |
/** |
100 |
* Hooks a listener that tweaks newly opened workbench window shells with |
152 |
* Hooks a listener that tweaks newly opened workbench window shells with |
101 |
* the proper OS flags. |
153 |
* the proper OS flags. |
102 |
* |
154 |
* |