Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions platform/applemenu/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,4 @@
<project name="platform/applemenu" basedir="." default="build">
<import file="../../nbbuild/templates/projectized.xml"/>

<available property="desktop.classes.available" classname="java.awt.desktop.AppEvent"/>
<target name="build-init" depends="projectized.build-init" unless="desktop.classes.available">
<mkdir dir="${build.dir}/desktop-classes-src" />
<unzip src="external/applemenu-external-desktop-classes-8.2.zip" dest="${build.dir}/desktop-classes-src"/>
<mkdir dir="${build.dir}/desktop-classes-classes" />
<javac srcdir="${build.dir}/desktop-classes-src" destdir="${build.dir}/desktop-classes-classes"
source="1.8" target="1.8">
</javac>
</target>

</project>

This file was deleted.

18 changes: 0 additions & 18 deletions platform/applemenu/external/binaries-list

This file was deleted.

39 changes: 0 additions & 39 deletions platform/applemenu/external/orange-extensions-1.3.1-license.txt

This file was deleted.

5 changes: 1 addition & 4 deletions platform/applemenu/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
# under the License.

javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.8
javac.release=17
nbm.needs.restart=true
is.eager=true
cp.extra=external/orange-extensions-1.3.1.jar
bootclasspath.prepend=${build.dir}/desktop-classes-classes

29 changes: 3 additions & 26 deletions platform/applemenu/src/org/netbeans/modules/applemenu/Install.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.awt.AWTEvent;
import java.awt.Toolkit;
import java.lang.reflect.*;
import org.openide.modules.ModuleInstall;
import org.openide.util.Utilities;

Expand All @@ -32,7 +31,6 @@
*/
public class Install extends ModuleInstall {
private CtrlClickHack listener;
private Class adapter;

@Override
public void restored () {
Expand All @@ -43,39 +41,18 @@ public void restored () {
if (System.getProperty(pn) == null) {
System.setProperty(pn, "true"); // NOI18N
}
if (!installAdapter("org.netbeans.modules.applemenu.NbApplicationAdapterJDK8")) { // NOI18N
// JDK 8 failed, try JDK 9
installAdapter("org.netbeans.modules.applemenu.NbApplicationAdapterJDK9"); // NOI18N
}
NbApplicationAdapter.install();
}
}

private boolean installAdapter(String className) {
try {
adapter = Class.forName(className);
Method m = adapter.getDeclaredMethod("install", new Class[0] ); // NOI18N
m.invoke(adapter, new Object[0]);
return true;
}catch (NoClassDefFoundError e) {
}catch (ClassNotFoundException e) {
}catch (Exception e) {
}
return false;
}

@Override
public void uninstalled () {
if (listener != null) {
Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
listener = null;
}
if (Utilities.isMac() && adapter != null) {
try {
Method m = adapter.getDeclaredMethod("uninstall", new Class[0] ); // NOI18N
m.invoke(adapter, new Object[0]);
} catch (NoClassDefFoundError e) {
} catch (Exception e) {
}
if (Utilities.isMac()) {
NbApplicationAdapter.uninstall();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.netbeans.modules.applemenu;

import java.awt.Desktop;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import java.awt.desktop.AboutEvent;
import java.awt.desktop.AboutHandler;
import java.awt.desktop.OpenFilesEvent;
import java.awt.desktop.OpenFilesHandler;
import java.awt.desktop.PreferencesEvent;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.QuitEvent;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitResponse;

import java.awt.event.ActionEvent;
import java.io.File;
Expand All @@ -44,29 +53,41 @@
import org.openide.windows.WindowSystemEvent;
import org.openide.windows.WindowSystemListener;

/** Adapter class which intercepts action events and passes them to the
* correct action instance as defined in the system filesystem.
/**
* Adapter class which intercepts action events and passes them to the correct
* action instance as defined in the system filesystem.
*
* @author Tim Boudreau
* @author Tim Boudreau
*/
final class NbApplicationAdapter implements AboutHandler, OpenFilesHandler, PreferencesHandler, QuitHandler {

abstract class NbApplicationAdapter {

NbApplicationAdapter() {
private NbApplicationAdapter() {
}

static void install() {
try {
Desktop app = Desktop.getDesktop();
NbApplicationAdapter al = new NbApplicationAdapter();

app.setAboutHandler(al);
app.setOpenFileHandler(al);
app.setPreferencesHandler(al);
app.setQuitHandler(al);
} catch (Throwable ex) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, ex);
}

WindowManager.getDefault().addWindowSystemListener(new WindowSystemListener() {

@Override
public void beforeLoad(WindowSystemEvent event) {
WindowManager.getDefault().removeWindowSystemListener(this);
try {
Frame main = WindowManager.getDefault().getMainWindow();
((RootPaneContainer)main).getRootPane().putClientProperty("apple.awt.fullscreenable", true); // NOI18N
} catch( Throwable e ) {
Logger.getLogger(NbApplicationAdapter.class.getName()).log(Level.FINE,
"Error while setting up full screen support.", e );//NOI18N
((RootPaneContainer) main).getRootPane().putClientProperty("apple.awt.fullscreenable", true); // NOI18N
} catch (Throwable e) {
Logger.getLogger(NbApplicationAdapter.class.getName()).log(Level.FINE,
"Error while setting up full screen support.", e);//NOI18N
}
}

Expand All @@ -84,15 +105,50 @@ public void afterSave(WindowSystemEvent event) {
});
}

void handleAbout() {
static void uninstall() {
try {
Desktop app = Desktop.getDesktop();

app.setAboutHandler(null);
app.setOpenFileHandler(null);
app.setPreferencesHandler(null);
app.setQuitHandler(null);
} catch (Throwable ex) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, ex);
}
}

@Override
public void handleAbout(AboutEvent e) {
handleAbout();
}

@Override
public void openFiles(OpenFilesEvent e) {
openFiles(e.getFiles());
}

@Override
public void handlePreferences(PreferencesEvent e) {
handlePreferences();
}

@Override
public void handleQuitRequestWith(QuitEvent e, QuitResponse response) {
handleQuit();
//need to do this otherwise the user will never be able to quit again
response.cancelQuit();
}

private void handleAbout() {
//#221571 - check if About window is showing already
Window[] windows = Dialog.getWindows();
if( null != windows ) {
for( Window w : windows ) {
if( w instanceof JDialog ) {
if (null != windows) {
for (Window w : windows) {
if (w instanceof JDialog) {
JDialog dlg = (JDialog) w;
if( Boolean.TRUE.equals(dlg.getRootPane().getClientProperty("nb.about.dialog") ) ) { //NOI18N
if( dlg.isVisible() ) {
if (Boolean.TRUE.equals(dlg.getRootPane().getClientProperty("nb.about.dialog"))) { //NOI18N
if (dlg.isVisible()) {
dlg.toFront();
return;
}
Expand All @@ -102,15 +158,15 @@ void handleAbout() {
}
performAction("Help", "org.netbeans.core.actions.AboutAction"); // NOI18N
}
void openFiles(List<File> files) {

private void openFiles(List<File> files) {
for (File f : files) {
if (f.exists() && !f.isDirectory()) {
FileObject obj = FileUtil.toFileObject(f);
if (obj != null) {
try {
DataObject dob = DataObject.find(obj);
OpenCookie oc = dob.getLookup().lookup (OpenCookie.class);
OpenCookie oc = dob.getLookup().lookup(OpenCookie.class);
if (oc != null) {
oc.open();
} else {
Expand All @@ -131,14 +187,15 @@ void openFiles(List<File> files) {
}
}
}
public void handlePreferences() {

private void handlePreferences() {
performAction("Window", "org.netbeans.modules.options.OptionsWindowAction"); // NOI18N
}
public void handleQuit() {

private void handleQuit() {
performAction("System", "org.netbeans.core.actions.SystemExit"); // NOI18N
}

private boolean performAction(String category, String id) {
Action a = Actions.forID(category, id);
if (a == null) {
Expand All @@ -153,5 +210,5 @@ private boolean performAction(String category, String id) {
return false;
}
}

}
Loading