本文整理汇总了Java中org.jdesktop.application.ApplicationContext类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationContext类的具体用法?Java ApplicationContext怎么用?Java ApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationContext类属于org.jdesktop.application包,在下文中一共展示了ApplicationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defineUI
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void defineUI ()
{
ApplicationContext applicationContext = OMR.gui.getApplication().getContext();
component.setLayout(new BorderLayout());
// Progress bar
progressBar.setPreferredSize(new Dimension(90, 20));
progressBar.setName("progressBar");
progressBar.setToolTipText("Used memory / Global memory");
progressBar.setStringPainted(true);
component.add(progressBar, BorderLayout.CENTER);
// Garbage collector button
JButton button = new JButton(applicationContext.getActionMap(this).get("collectGarbage"));
button.setBorder(UIUtil.getToolBorder());
component.add(button, BorderLayout.EAST);
// Remember the default foreground color
defaultForeground = progressBar.getForeground();
// Resource injection
ResourceMap resource = applicationContext.getResourceMap(getClass());
resource.injectComponents(component);
}
示例2: install
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
public static synchronized void install(final ApplicationContext context) {
//TODO this should be one per context
if (!installed) {
context.addPropertyChangeListener("focusOwner", new PropertyChangeListener() {
private StyledTextActions textActions = new StyledTextActions(context);
public void propertyChange(PropertyChangeEvent evt) {
textActions.updateFocusOwner((JComponent) evt.getOldValue(),
(JComponent) evt.getNewValue());
}
});
installed = true;
}
}
示例3: prepareWindow
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
* Prepares the given window. Injects properties from app context.
* Restores session state if appropriate. Registers listeners to try and
* track session state.
*
* @param root
*/
protected void prepareWindow(Window root) {
configureWindow(root);
// If the window's size doesn't appear to have been set, do it
if ((root.getWidth() == 0) || (root.getHeight() == 0)) {
root.pack();
if (!root.isLocationByPlatform()) {
Component owner = (root != getMainFrame()) ? getMainFrame()
: null;
root.setLocationRelativeTo(owner); // center the window
}
}
// Restore session state
String filename = sessionFilename(root);
if (filename != null) {
try {
ApplicationContext ac = getContext();
ac.getSessionStorage().restore(root, filename);
} catch (Exception e) {
logger.log(Level.WARNING, "couldn't restore sesssion", e);
}
}
root.addWindowListener(getDialogListener());
}
示例4: makeAutoBackup
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
* This method starts a background thread that creates an automatic backup
* of the current main data file. the file is saved to the same directory as
* the main data file, just changing the extenstion to ".zkb3".
* <br><br>
* This method is called when we have changes that are not save, e.g. after
* the methods {@link #newEntry() newEntry()} or
* {@link #editEntry() editEntry()}.
*/
private void makeAutoBackup() {
// if
// - task is already running, or
// - no backup necessary
// - or an save-operation is in progress...
// ...then do nothing.
if (isAutoBackupRunning() || !isBackupNecessary() || isSaving) {
return;
}
// check for autobackup
if (settings.getAutoBackup() && (settings.getFilePath() != null)) {
Task cabT = autoBackupTask();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(cabT);
tM.setForegroundTask(cabT);
} else {
setAutoBackupRunning(false);
}
}
示例5: updateDisplay
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
* This method updates the display, i.e. receiving the entry-structure from
* the jTree and displays all those entries in html-formatting in the
* jEditorPane.
*/
private synchronized void updateDisplay() {
// when the display is up to date, do nothing here...
if (!isNeedsUpdate()) {
return;
}
// cancel already running task if necessary, so we don't have more parallel tasks running
if (cDisplayTask != null) {
cDisplayTask.cancel(true);
}
// if task is already running, leave...
if (cDisplayTaskIsRunning) {
return;
}
Task cdT = displayTask();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(cdT);
tM.setForegroundTask(cdT);
}
示例6: defineUI
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void defineUI ()
{
ApplicationContext applicationContext = MainGui.getInstance()
.getContext();
component.setLayout(new BorderLayout());
// Progress bar
progressBar.setPreferredSize(new Dimension(90, 20));
progressBar.setName("progressBar");
progressBar.setToolTipText("Used memory / Global memory");
progressBar.setStringPainted(true);
component.add(progressBar, BorderLayout.CENTER);
// Garbage collector button
JButton button = new JButton(
applicationContext.getActionMap(this).get("collectGarbage"));
button.setBorder(UIUtil.getToolBorder());
component.add(button, BorderLayout.EAST);
// Remember the default foreground color
defaultForeground = progressBar.getForeground();
// Resource injection
ResourceMap resource = applicationContext.getResourceMap(getClass());
resource.injectComponents(component);
}
示例7: saveDatabaseSettings
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void saveDatabaseSettings(String sessionName) throws IOException {
String ext = "";
if (sessionName != null) {
ext = "[" + sessionName + "]";
}
ApplicationContext ctxt = EDACCApp.getApplication().getContext();
Map<String, String> map = (Map<String, String>) ctxt.getLocalStorage().load(connection_settings_filename);
if (map == null) {
map = new HashMap<String, String>();
}
map.put("hostname" + ext, txtHostname.getText());
map.put("database" + ext, txtDatabase.getText());
map.put("port" + ext, txtPort.getText());
map.put("username" + ext, txtUsername.getText());
map.put("max_connections" + ext, txtMaxConnections.getText());
map.put("secured_connection" + ext, chkUseSSL.isSelected() ? "true" : "false");
map.put("use_compression" + ext, chkCompress.isSelected() ? "true" : "false");
map.put("save_password" + ext, chkSavePassword.isSelected() ? "true" : "false");
if (chkSavePassword.isSelected()) {
map.put("password" + ext, txtPassword.getText());
} else {
map.put("password" + ext, "");
}
ctxt.getLocalStorage().save(map, connection_settings_filename);
}
示例8: removeSavedDatabaseSession
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void removeSavedDatabaseSession(String sessionName) throws IOException {
String ext = "";
if (sessionName != null) {
ext = "[" + sessionName + "]";
}
ApplicationContext ctxt = EDACCApp.getApplication().getContext();
Map<String, String> map = (Map<String, String>) ctxt.getLocalStorage().load(connection_settings_filename);
if (map == null) {
return;
}
map.remove("hostname" + ext);
map.remove("database" + ext);
map.remove("port" + ext);
map.remove("username" + ext);
map.remove("max_connections" + ext);
map.remove("secured_connection" + ext);
map.remove("use_compression" + ext);
map.remove("save_password" + ext);
map.remove("password" + ext);
ctxt.getLocalStorage().save(map, connection_settings_filename);
}
示例9: reloadSessionNames
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void reloadSessionNames() throws IOException {
ApplicationContext ctxt = EDACCApp.getApplication().getContext();
Map<String, String> map = (Map<String, String>) ctxt.getLocalStorage().load(connection_settings_filename);
if (map == null) {
map = new HashMap<String, String>();
}
List<String> sessions = new LinkedList<String>();
for (String key : map.keySet()) {
if (key.startsWith("hostname") && key.length() >= 10) {
String name = key.substring(9, key.length()-1);
sessions.add(name);
}
}
Collections.sort(sessions);
listSavedSessions.setListData(sessions.toArray());
}
示例10: StyledTextActions
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
@SuppressWarnings("serial")
StyledTextActions(ApplicationContext context) {
this.context = context;
markerAction = new javax.swing.AbstractAction() {
public void actionPerformed(ActionEvent e) {
}
};
textComponentCaretListener = new TextComponentCaretListener();
textComponentPCL = new TextComponentPCL();
installProxyActions();
}
示例11: startTask
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
public void startTask() {
// start the background task manually
Task fdeT = findDoubleEntries();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(fdeT);
tM.setForegroundTask(fdeT);
}
示例12: startTask
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
*
*/
private void startTask() {
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
tM = appC.getTaskMonitor();
tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(foregroundTask);
tM.setForegroundTask(foregroundTask);
}
示例13: showAuthors
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
* This method creates the quickinput-list for authors by calling a
* background task which does this work...
*/
@Action
public final synchronized void showAuthors() {
// when authorlist is uptodate, leave...
if (authorListUpToDate) {
// select added authors if we have some
selectNewAddedAuthors();
return;
}
// en/disable keyword quick-input function depending on the amount of keywords
int aucount = dataObj.getCount(Daten.AUCOUNT);
jTextFieldFilterAuthorlist.setEnabled(aucount > 0);
// disbale button, will only be enabled on selection
// jButtonAddAuthors.setEnabled(false);
// when we have no authors at all, quit
if (aucount < 1) {
return;
}
// leave method when task is already running...
if (qiAuthorTaskIsRunning) {
return;
}
// set upto-date-indicator to false, otherwise the thread will not be executed
authorListUpToDate = false;
// when opening this dialog, automatically create the author list
Task qiauT = quickInputAuthor();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(qiauT);
tM.setForegroundTask(qiauT);
}
示例14: fillBibtexTable
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
private void fillBibtexTable() {
if (jRadioButtonSourceFile.isSelected()) {
// retrieve currently attached file
File currentlyattachedfile = bibtexObj.getCurrentlyAttachedFile();
// if we have no currently attached bibtex-file, or the currently attached bibtex-file
// differs from the new selected file of the user, open the bibtex-file now
if ((null == currentlyattachedfile) || (!currentlyattachedfile.toString().equals(bibtexObj.getFilePath().toString()))) {
// open selected file, using the character encoding of the related reference-manager (i.e.
// the programme that has exported the bib-tex-file).
bibtexObj.openAttachedFile(Constants.BIBTEX_ENCODINGS[jComboBoxEncoding.getSelectedIndex()], false);
// retrieve currently attached bibtex-file
currentlyattachedfile = bibtexObj.getCurrentlyAttachedFile();
}
// set filepath to textfield
jTextFieldBibtexFilepath.setText((currentlyattachedfile != null && currentlyattachedfile.exists()) ? currentlyattachedfile.toString() : "");
}
// block all components
setComponentsBlocked(true);
// reset linked list
linkedtablelist = null;
// start the background task manually
Task impBibT = startImport();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(impBibT);
tM.setForegroundTask(impBibT);
}
示例15: filterLinks
import org.jdesktop.application.ApplicationContext; //导入依赖的package包/类
/**
* This method filters the entries in the jTableLinks depending on the selected keyword(s)
* of the jListKeywords.<br><br>
* This method is called when the user selects an entry from the list jListKeywords.
* We then want to filter the list
* with links/references to other entries (jTableLinks) to show only those links (entries)
* that are related to the selected keywords.<br><br>
* Futhermore, we want to offer logical-and and logical-or combination of the keywords,
* i.e. showing either entries that contain ALL selected keywords or AT LEAST ONE of
* the selected keywords.
*/
private synchronized void filterLinks() {
// if no data available, leave method
if (data.getCount(Daten.ZKNCOUNT)<1) {
return;
}
// if the link-table is not shown, leave
if (jTabbedPaneMain.getSelectedIndex()!=TAB_LINKS) {
return;
}
// if no selections made, or all values de-selected, leave method
// and show all links instead
if (jListEntryKeywords.getSelectedIndices().length<1) {
showLinks();
return;
}
// when thread is already running, do nothing...
if (createFilterLinksIsRunning) {
return;
}
// clear table
DefaultTableModel tm = (DefaultTableModel) jTableLinks.getModel();
// reset the table
tm.setRowCount(0);
// tell user that we are doing something...
statusMsgLabel.setText(getResourceMap().getString("createLinksMsg"));
// create task
Task cflT = createFilterLinks();
// get the application's context...
ApplicationContext appC = Application.getInstance().getContext();
// ...to get the TaskMonitor and TaskService
TaskMonitor tM = appC.getTaskMonitor();
TaskService tS = appC.getTaskService();
// with these we can execute the task and bring it to the foreground
// i.e. making the animated progressbar and busy icon visible
tS.execute(cflT);
tM.setForegroundTask(cflT);
}