use of java.awt.Cursor in project JMRI by JMRI.
the class RosterFrame method startProgrammer.
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
if (inStartProgrammer) {
log.debug("Call to start programmer has been called twice when the first call hasn't opened");
return;
}
if (!checkIfEntrySelected()) {
return;
}
try {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
inStartProgrammer = true;
String title = re.getId();
JFrame progFrame = null;
if (edit.isSelected()) {
progFrame = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {
@Override
protected JPanel getModePane() {
return null;
}
};
} else if (service.isSelected()) {
progFrame = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePanel.getProgrammer()) {
};
} else if (ops.isSelected()) {
int address = Integer.parseInt(re.getDccAddress());
boolean longAddr = re.isLongAddress();
Programmer pProg = InstanceManager.getDefault(AddressedProgrammerManager.class).getAddressedProgrammer(longAddr, address);
progFrame = new PaneOpsProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", pProg);
}
if (progFrame == null) {
return;
}
progFrame.pack();
progFrame.setVisible(true);
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
inStartProgrammer = false;
}
use of java.awt.Cursor in project pcgen by PCGen.
the class InitiativePlugin method fileOpen.
/**
* Handles the clicking of the <b>Add </b> button on the GUI.
*/
public void fileOpen() {
JFileChooser chooser = ImagePreview.decorateWithImagePreview(new JFileChooser());
File defaultFile = new File(PCGenSettings.getPcgDir());
if (defaultFile.exists()) {
chooser.setCurrentDirectory(defaultFile);
}
// TODO should probably handle zip pcg
String[] pcgs = { "pcg", "pcp" };
String[] init = { "gmi", "init" };
FileFilter ff = new FileNameExtensionFilter("Initiative Export", init);
chooser.addChoosableFileFilter(ff);
chooser.addChoosableFileFilter(new FileNameExtensionFilter("PCGen File", pcgs));
chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
chooser.setFileFilter(ff);
chooser.setMultiSelectionEnabled(true);
Cursor originalCursor = theView.getCursor();
theView.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int option = chooser.showOpenDialog(theView);
if (option == JFileChooser.APPROVE_OPTION) {
File[] pcFiles = chooser.getSelectedFiles();
for (File pcFile : pcFiles) {
if (PCGFile.isPCGenCharacterOrPartyFile(pcFile)) {
messageHandler.handleMessage(new RequestOpenPlayerCharacterMessage(this, pcFile, false));
//loadPCG(pcFiles[i]);
} else if (pcFile.toString().endsWith(".init") || pcFile.toString().endsWith(".gmi")) {
loadINIT(pcFile);
}
}
/* loop through selected files */
theView.refreshTable();
} else {
/* this means the file is invalid */
}
theView.setCursor(originalCursor);
}
use of java.awt.Cursor in project pcgen by PCGen.
the class PCGTrackerPlugin method handleOpen.
/**
* Handles the clicking of the <b>Add</b> button on the GUI.
*/
public void handleOpen() {
File defaultFile = new File(PCGenSettings.getPcgDir());
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(defaultFile);
String[] pcgs = { FILENAME_PCG, FILENAME_PCP };
FileFilter ff = new FileNameExtensionFilter(LanguageBundle.getString("in_pcgen_file"), //$NON-NLS-1$
pcgs);
chooser.addChoosableFileFilter(ff);
chooser.setFileFilter(ff);
chooser.setMultiSelectionEnabled(true);
Component component = GMGenSystem.inst;
Cursor originalCursor = component.getCursor();
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int option = chooser.showOpenDialog(GMGenSystem.inst);
if (option == JFileChooser.APPROVE_OPTION) {
for (File selectedFile : chooser.getSelectedFiles()) {
if (PCGFile.isPCGenCharacterOrPartyFile(selectedFile)) {
messageHandler.handleMessage(new RequestOpenPlayerCharacterMessage(this, selectedFile, false));
}
}
} else {
/* this means the file is invalid */
}
GMGenSystem.inst.setCursor(originalCursor);
}
use of java.awt.Cursor in project pcgen by PCGen.
the class NotesView method handleOpen.
/**
* {@literal handle File->Open.} Will open any .gmn files, and import them into your
* notes structure
*/
public void handleOpen() {
// TODO fix
String sFile = SettingsHandler.getGMGenOption(OPTION_NAME_LASTFILE, System.getProperty("user.dir"));
File defaultFile = new File(sFile);
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(defaultFile);
chooser.addChoosableFileFilter(NotesPlugin.getFileType());
chooser.setFileFilter(NotesPlugin.getFileType());
chooser.setMultiSelectionEnabled(true);
Component component = GMGenSystem.inst;
Cursor originalCursor = component.getCursor();
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int option = chooser.showOpenDialog(GMGenSystem.inst);
if (option == JFileChooser.APPROVE_OPTION) {
for (File noteFile : chooser.getSelectedFiles()) {
SettingsHandler.setGMGenOption(OPTION_NAME_LASTFILE, noteFile.toString());
if (noteFile.toString().endsWith(EXTENSION)) {
openGMN(noteFile);
}
}
}
GMGenSystem.inst.setCursor(originalCursor);
refreshTree();
}
use of java.awt.Cursor in project adempiere by adempiere.
the class PDFViewerBean method setCurrentPage.
public void setCurrentPage(int page) {
if (page < 1 || page > decoder.getPageCount()) {
return;
}
final Cursor oldCursor = getCursor();
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
decoder.setPageParameters(zoomFactors[scaleStep], page);
decoder.decodePage(page);
setRotation(decoder.getPdfPageData().getRotation(page));
currentPage = page;
} catch (Exception e) {
e.printStackTrace();
return;
} finally {
setCursor(oldCursor);
}
goFirstAction.setEnabled(currentPage > 1);
goPreviousAction.setEnabled(currentPage > 1);
goNextAction.setEnabled(currentPage < decoder.getPageCount());
goLastAction.setEnabled(currentPage < decoder.getPageCount());
pageField.setText(Integer.toString(currentPage));
}
Aggregations