forked from java-decompiler/jd-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes java-decompiler#48, adds "UI > Main window > Single instance" t…
…o preferences
- Loading branch information
Showing
8 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...rc/main/groovy/jd/gui/service/preferencespanel/UISingleInstancePreferencesProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2008-2015 Emmanuel Dupuy | ||
* This program is made available under the terms of the GPLv3 License. | ||
*/ | ||
|
||
package jd.gui.service.preferencespanel | ||
|
||
import jd.gui.spi.PreferencesPanel | ||
|
||
import javax.swing.* | ||
import java.awt.* | ||
|
||
/** | ||
* JTabbedPane.WRAP_TAB_LAYOUT is not supported by Aqua L&F. | ||
* This panel is not activated on Mac OSX. | ||
*/ | ||
class UISingleInstancePreferencesProvider extends JPanel implements PreferencesPanel { | ||
|
||
static final String SINGLE_INSTANCE = 'UIMainWindowPreferencesProvider.singleInstance' | ||
|
||
JCheckBox singleInstanceTabsCheckBox | ||
|
||
UISingleInstancePreferencesProvider() { | ||
super(new GridLayout(0,1)) | ||
|
||
singleInstanceTabsCheckBox = new JCheckBox('Single instance') | ||
|
||
add(singleInstanceTabsCheckBox) | ||
} | ||
|
||
// --- PreferencesPanel --- // | ||
String getPreferencesGroupTitle() { 'User Interface' } | ||
String getPreferencesPanelTitle() { 'Main window' } | ||
|
||
public void init(Color errorBackgroundColor) {} | ||
|
||
public boolean isActivated() { | ||
System.getProperty('os.name').toLowerCase().contains('mac os') == false | ||
} | ||
|
||
void loadPreferences(Map<String, String> preferences) { | ||
singleInstanceTabsCheckBox.selected = 'true'.equals(preferences.get(SINGLE_INSTANCE)) | ||
} | ||
|
||
void savePreferences(Map<String, String> preferences) { | ||
preferences.put(SINGLE_INSTANCE, Boolean.toString(singleInstanceTabsCheckBox.selected)) | ||
} | ||
|
||
boolean arePreferencesValid() { true } | ||
|
||
void addPreferencesChangeListener(PreferencesPanel.PreferencesPanelChangeListener listener) {} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/groovy/jd/gui/util/net/InterProcessCommunications.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2008-2015 Emmanuel Dupuy | ||
* This program is made available under the terms of the GPLv3 License. | ||
*/ | ||
|
||
package jd.gui.util.net | ||
|
||
class InterProcessCommunications { | ||
|
||
protected static final int PORT = 2015_6 | ||
|
||
void listen(Closure closure) throws Exception { | ||
def listener = new ServerSocket(PORT) | ||
|
||
new Thread().start { | ||
while (true) { | ||
listener.accept().withCloseable { Socket socket -> | ||
closure(new ObjectInputStream(socket.inputStream).readObject()) | ||
} | ||
} | ||
} | ||
} | ||
|
||
void send(Object obj) { | ||
new Socket(InetAddress.localHost, PORT).withCloseable { Socket socket -> | ||
new ObjectOutputStream(socket.outputStream).writeObject(obj) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/src/main/resources/META-INF/services/jd.gui.spi.PreferencesPanel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
jd.gui.service.preferencespanel.UISingleInstancePreferencesProvider | ||
jd.gui.service.preferencespanel.UITabsPreferencesProvider |