Java Examples for javax.help.HelpSet
The following java examples will help you to understand the usage of javax.help.HelpSet. These source code samples are taken from different open source projects.
Example 1
| Project: borg_calendar-master File: HelpLauncher.java View source code |
/**
* launch the Borg java help
*/
public static void launchHelp() throws Exception {
// Find the HelpSet file and create the HelpSet object:
String helpHS = "BorgHelp.hs";
ClassLoader cl = HelpLauncher.class.getClassLoader();
URL hsURL = HelpSet.findHelpSet(cl, helpHS);
HelpSet hs = new HelpSet(null, hsURL);
HelpBroker hb = hs.createHelpBroker();
hb.initPresentation();
hb.setDisplayed(true);
}Example 2
| Project: cl1-master File: HelpAction.java View source code |
protected void init() {
if (csh != null)
return;
URL hsURL = app.getResource(getClass().getPackage().getName().replace(".", "/") + "/help/cl1.hs");
try {
if (helpSet == null)
helpSet = new HelpSet(null, hsURL);
if (helpBroker == null)
helpBroker = helpSet.createHelpBroker();
helpBroker.setCurrentID(helpID);
csh = new CSH.DisplayHelpFromSource(helpBroker);
} catch (Exception ex) {
app.showErrorMessage("ClusterONE Help cannot be started. Please see the ClusterONE website instead.");
ex.printStackTrace();
return;
}
}Example 3
| Project: Desktop-master File: FreeplaneHelpStarter.java View source code |
/**
*
*/
public void actionPerformed(final ActionEvent e) {
final String helpHS = "org/freeplane/plugin/help/doc/freeplane.hs";
try {
final ClassLoader classLoader = this.getClass().getClassLoader();
final URL hsURL = HelpSet.findHelpSet(classLoader, helpHS);
final HelpSet hs = new HelpSet(classLoader, hsURL);
final HelpBroker hb = hs.createHelpBroker();
hb.initPresentation();
hb.setDisplayed(true);
hb.setViewDisplayed(true);
} catch (final Exception ee) {
LogUtils.severe("HelpSet " + helpHS + " not found", ee);
return;
}
}Example 4
| Project: Docear-master File: FreeplaneHelpStarter.java View source code |
/**
*
*/
public void actionPerformed(final ActionEvent e) {
final String helpHS = "org/freeplane/plugin/help/doc/freeplane.hs";
try {
final ClassLoader classLoader = this.getClass().getClassLoader();
final URL hsURL = HelpSet.findHelpSet(classLoader, helpHS);
final HelpSet hs = new HelpSet(classLoader, hsURL);
final HelpBroker hb = hs.createHelpBroker();
hb.initPresentation();
hb.setDisplayed(true);
hb.setViewDisplayed(true);
} catch (final Exception ee) {
LogUtils.severe("HelpSet " + helpHS + " not found", ee);
return;
}
}Example 5
| Project: freemind-mmx-master File: FreemindHelpStarter.java View source code |
/**
*
*/
public void startupMapHook() {
super.startupMapHook();
// Find the HelpSet file and create the HelpSet object:
String helpHS = "plugins/help/doc/freemind.hs";
try {
ClassLoader classLoader = this.getClass().getClassLoader();
URL hsURL = HelpSet.findHelpSet(classLoader, helpHS);
HelpSet hs = new HelpSet(classLoader, hsURL);
HelpBroker hb = hs.createHelpBroker();
hb.initPresentation();
hb.setDisplayed(true);
hb.setViewDisplayed(true);
} catch (Exception ee) {
freemind.main.Resources.getInstance().logException(ee);
logger.warning("HelpSet " + ee.getMessage() + ee);
logger.warning("HelpSet " + helpHS + " not found");
return;
}
}Example 6
| Project: JadexPlayer-master File: SHelp.java View source code |
/*
* Get the Jadex help broker.
*/
public static HelpBroker getJadexHelpBroker() {
if (!searched_for_help_set) {
searched_for_help_set = true;
// Create main help set and broker
try {
ClassLoader cl = SHelp.class.getClassLoader();
URL url = HelpSet.findHelpSet(cl, "jadex/tools/help/jhelpset");
ExtendedHelpSet hs = new ExtendedHelpSet(cl, url);
Dimension sd = Toolkit.getDefaultToolkit().getScreenSize();
int w = (int) (sd.getWidth() * 0.8);
int h = (int) (sd.getHeight() * 0.8);
int xs = (int) (sd.getWidth() * 0.1);
int ys = (int) (sd.getHeight() * 0.1);
HelpSet.Presentation pr = new HelpSet.Presentation("def", true, true, new Dimension(w, h), new Point(xs, ys), "Jadex Help", null, false, null);
hs.addPresentation(pr, true);
jadex_hb = hs.createHelpBroker();
} catch (Exception e) {
System.out.println("Help Set JadexHelp not found.");
} catch (ExceptionInInitializerError ex) {
System.out.println("Help set initialization error.");
}
}
return jadex_hb;
}Example 7
| Project: Captor-master File: HelpContents.java View source code |
//-------------------------------------------------------------------------
public void actionPerformed(ActionEvent e) {
ClassLoader cl;
HelpSet hs = null;
URL x[] = parseURLs();
cl = new URLClassLoader(x);
String name = "jhelpset.hs";
URL url = HelpSet.findHelpSet(cl, name);
if (url == null) {
JOptionPane.showMessageDialog(null, MyIntl.MSG70, MyIntl.MSG71, JOptionPane.ERROR_MESSAGE);
return;
}
try {
hs = new HelpSet(cl, url);
} catch (HelpSetException ex) {
JOptionPane.showMessageDialog(null, StringUtil.formatMessage(MyIntl.MSG72, url.toString()), MyIntl.MSG71, JOptionPane.ERROR_MESSAGE);
}
if (jh == null) {
jh = new JHelp(hs);
} else {
jh.setHelpSetPresentation(hs.getDefaultPresentation());
DefaultHelpModel m = new DefaultHelpModel(hs);
jh.setModel(m);
}
createFrame(hs.getTitle());
launch();
}Example 8
| Project: freehep-ncolor-pdf-master File: HelpInterfaceImpl.java View source code |
/** * Find the HelpSet and initialize the main HelpBroker (mainHB). */ private void createHelpSet() throws HelpException { Enumeration e = Application.getApplication().getHelpLocations(); while (e.hasMoreElements()) { // try // { // URL u = (URL) e.nextElement(); // if (debugHelp) System.out.print("Looking for hs at: "+u+" ... "); // mainHS = new HelpSet(null, u); // if (debugHelp) System.out.println("Success"); // break; // } // catch (HelpSetException e1) // { // if (debugHelp) System.out.println("Failed"); // } } // if (mainHS == null) throw new HelpException("No HelpSet found"); // // try // { // mainHB = (DefaultHelpBroker) mainHS.createHelpBroker(); // } // catch (Throwable x) // { // throw new HelpException("Could not create Help Broker",x); // } }
Example 9
| Project: spring-rich-client-master File: HelpContents.java View source code |
public void display(Window parent) {
if (helpFrame == null) {
helpFrame = new JFrame();
helpFrame.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
HelpSet helpSet = new HelpSet(null, helpSetPath.getURL());
JHelp jhelp = new JHelp(helpSet);
helpFrame = new JFrame("Help - " + getApplicationName());
helpFrame.getContentPane().add(jhelp);
helpFrame.setIconImage(getApplicationImage());
helpFrame.pack();
} catch (Exception e) {
e.printStackTrace();
}
helpFrame.getGlassPane().setCursor(Cursor.getDefaultCursor());
}
if (!helpFrame.isVisible()) {
WindowUtils.centerOnParent(helpFrame, parent);
helpFrame.setVisible(true);
}
if ((helpFrame.getExtendedState() & Frame.NORMAL) == 0) {
helpFrame.setExtendedState(Frame.NORMAL);
}
helpFrame.toFront();
}Example 10
| Project: springrcp-master File: HelpContents.java View source code |
public void display(Window parent) {
if (helpFrame == null) {
helpFrame = new JFrame();
helpFrame.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
HelpSet helpSet = new HelpSet(null, helpSetPath.getURL());
JHelp jhelp = new JHelp(helpSet);
helpFrame = new JFrame("Help - " + getApplicationName());
helpFrame.getContentPane().add(jhelp);
helpFrame.setIconImage(getApplicationImage());
helpFrame.pack();
} catch (Exception e) {
e.printStackTrace();
}
helpFrame.getGlassPane().setCursor(Cursor.getDefaultCursor());
}
if (!helpFrame.isVisible()) {
WindowUtils.centerOnParent(helpFrame, parent);
helpFrame.setVisible(true);
}
if ((helpFrame.getExtendedState() & Frame.NORMAL) == 0) {
helpFrame.setExtendedState(Frame.NORMAL);
}
helpFrame.toFront();
}Example 11
| Project: Valkyrie-RCP-master File: HelpContents.java View source code |
public void display(Window parent) {
if (helpFrame == null) {
helpFrame = new JFrame();
helpFrame.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
HelpSet helpSet = new HelpSet(null, helpSetPath.getURL());
JHelp jhelp = new JHelp(helpSet);
helpFrame = new JFrame("Help - " + getApplicationName());
helpFrame.getContentPane().add(jhelp);
helpFrame.setIconImage(getApplicationImage());
helpFrame.pack();
} catch (Exception e) {
e.printStackTrace();
}
helpFrame.getGlassPane().setCursor(Cursor.getDefaultCursor());
}
if (!helpFrame.isVisible()) {
WindowUtils.centerOnParent(helpFrame, parent);
helpFrame.setVisible(true);
}
if ((helpFrame.getExtendedState() & Frame.NORMAL) == 0) {
helpFrame.setExtendedState(Frame.NORMAL);
}
helpFrame.toFront();
}Example 12
| Project: zaproxy-master File: ExtensionFactory.java View source code |
/**
* If there are help files within the extension, they are loaded and merged
* with existing help files if the core help was correctly loaded.
* @param ext the extension being initialised
*/
private static void intitializeHelpSet(Extension ext) {
HelpBroker hb = ExtensionHelp.getHelpBroker();
if (hb == null) {
return;
}
URL helpSetUrl = getExtensionHelpSetUrl(ext);
if (helpSetUrl != null) {
try {
log.debug("Load help files for extension '" + ext.getName() + "' and merge with core help.");
HelpSet extHs = new HelpSet(ext.getClass().getClassLoader(), helpSetUrl);
hb.getHelpSet().add(extHs);
} catch (HelpSetException e) {
log.error("An error occured while adding help file of extension '" + ext.getName() + "': " + e.getMessage(), e);
}
}
}Example 13
| Project: consulo-master File: HelpManagerImpl.java View source code |
@Nullable private static HelpSet createHelpSet() { String urlToHelp = ApplicationInfo.getInstance().getHelpURL() + "/" + HELP_HS; HelpSet mainHelpSet = loadHelpSet(urlToHelp); if (mainHelpSet == null) return null; // merge plugins help sets IdeaPluginDescriptor[] pluginDescriptors = PluginManagerCore.getPlugins(); for (IdeaPluginDescriptor pluginDescriptor : pluginDescriptors) { HelpSetPath[] sets = pluginDescriptor.getHelpSets(); for (HelpSetPath hsPath : sets) { String url = "jar:file:///" + pluginDescriptor.getPath().getAbsolutePath() + "/help/" + hsPath.getFile() + "!"; if (!hsPath.getPath().startsWith("/")) { url += "/"; } url += hsPath.getPath(); HelpSet pluginHelpSet = loadHelpSet(url); if (pluginHelpSet != null) { mainHelpSet.add(pluginHelpSet); } } } return mainHelpSet; }
Example 14
| Project: edumips64-master File: GUIHelp.java View source code |
/**
* Shows the Edumips64 help window. If the help system was not initialized properly, shows an error dialog
* instead.
*
* @param parent
* the parent that owns this help dialog
* @param helpId
* the help ID to display (an invalid ID will result in the top level help topic being
* displayed)
*/
public static void showHelp(Window parent, String helpId) {
HSurl = Main.class.getResource(CurrentLocale.getString("HELPDIR") + "/");
String s = HSurl.getProtocol() + ":" + HSurl.getPath().replace("%20", " ");
String s1 = CurrentLocale.getString("HELPSET");
try {
URL aurl[] = GUIHelp.parseURLs(s);
URLClassLoader urlclassloader = new URLClassLoader(aurl);
url = HelpSet.findHelpSet(urlclassloader, s1);
HelpSet helpset = new HelpSet(urlclassloader, url);
helpBroker = helpset.createHelpBroker();
helpBroker.initPresentation();
helpBroker.setSize(new Dimension(800, 600));
((DefaultHelpBroker) helpBroker).setActivationWindow(parent);
helpBroker.initPresentation();
helpBroker.setSize(helpBroker.getSize());
helpBroker.setDisplayed(true);
} catch (HelpSetException helpsetexception) {
System.err.println("Could not create HelpSet for " + url);
System.err.println(helpsetexception);
} catch (BadIDException bie) {
helpBroker.setCurrentID(HELP_DEFAULT);
}
}Example 15
| Project: FreeRoute-master File: BoardMenuHelp.java View source code |
private void initialize_help(java.util.Locale p_locale) {
// try to find the helpset and create a HelpBroker object
if (BoardFrame.help_broker == null) {
String language = p_locale.getLanguage();
String helpset_name;
if (language.equalsIgnoreCase("de")) {
helpset_name = "helpset/de/Help.hs";
} else {
helpset_name = "helpset/en/Help.hs";
}
try {
URL hsURL = HelpSet.findHelpSet(this.getClass().getClassLoader(), helpset_name);
if (hsURL == null) {
FRLogger.warning("HelpSet " + helpset_name + " not found.");
} else {
BoardFrame.help_set = new HelpSet(null, hsURL);
}
} catch (HelpSetException ee) {
System.out.println("HelpSet " + helpset_name + " could not be opened.");
System.out.println(ee.getMessage());
}
if (BoardFrame.help_set != null) {
BoardFrame.help_broker = BoardFrame.help_set.createHelpBroker();
}
if (BoardFrame.help_broker != null) {
// CSH.DisplayHelpFromSource is a convenience class to display the helpset
contents_help = new CSH.DisplayHelpFromSource(BoardFrame.help_broker);
direct_help = new CSH.DisplayHelpAfterTracking(BoardFrame.help_broker);
}
}
}Example 16
| Project: Freerouting-master File: BoardMenuHelp.java View source code |
private void initialize_help(java.util.Locale p_locale) {
// try to find the helpset and create a HelpBroker object
if (BoardFrame.help_broker == null) {
String language = p_locale.getLanguage();
String helpset_name;
if (language.equalsIgnoreCase("de")) {
helpset_name = "helpset/de/Help.hs";
} else {
helpset_name = "helpset/en/Help.hs";
}
try {
URL hsURL = HelpSet.findHelpSet(this.getClass().getClassLoader(), helpset_name);
if (hsURL == null) {
FRLogger.warning("HelpSet " + helpset_name + " not found.");
} else {
BoardFrame.help_set = new HelpSet(null, hsURL);
}
} catch (HelpSetException ee) {
System.out.println("HelpSet " + helpset_name + " could not be opened.");
System.out.println(ee.getMessage());
}
if (BoardFrame.help_set != null) {
BoardFrame.help_broker = BoardFrame.help_set.createHelpBroker();
}
if (BoardFrame.help_broker != null) {
// CSH.DisplayHelpFromSource is a convenience class to display the helpset
contents_help = new CSH.DisplayHelpFromSource(BoardFrame.help_broker);
direct_help = new CSH.DisplayHelpAfterTracking(BoardFrame.help_broker);
}
}
}Example 17
| Project: NeuGen-master File: NeuGenHelp.java View source code |
/** Initialize the JavaHelp system. */
private void initHelpSystem() {
logger.info("init help");
//optimization to avoid repeated init
if (helpBroker != null && displayHelp != null) {
return;
}
//(uses the classloader mechanism)
ClassLoader loader = this.getClass().getClassLoader();
URL helpSetURL = HelpSet.findHelpSet(loader, PATH_TO_JAVA_HELP);
assert helpSetURL != null : "Cannot find help system.";
try {
HelpSet helpSet = new HelpSet(DEFAULT_CLASS_LOADER, helpSetURL);
helpBroker = helpSet.createHelpBroker();
displayHelp = new CSH.DisplayHelpFromSource(helpBroker);
} catch (HelpSetException ex) {
logger.error("Cannot create help system with: " + helpSetURL, ex);
}
assert helpBroker != null : "HelpBroker is null.";
}Example 18
| Project: alida-master File: OnlineHelpDisplayer.java View source code |
/**
* Explicitly init the helpset, i.e. set helpset prefix.
* <p>
* By default the prefix is set to 'alida', but to access MiToBo's
* helpset pages, it needs to be set to 'mitobo' prior to the first call
* to any helpset page. This routine reinitializes the helpset.
*
* @param prefix Prefix of the target helpset, i.e. 'alida' or 'mitobo'.
*/
public static void initHelpset(String prefix) {
helpHS = prefix + ".hs";
// defaultTarget = prefix + "_welcome";
defaultTarget = "welcome";
try {
ClassLoader cl = OnlineHelpDisplayer.class.getClassLoader();
URL hsURL = HelpSet.findHelpSet(cl, helpHS);
HelpSet hs = new HelpSet(null, hsURL);
hb = hs.createHelpBroker();
} catch (HelpSetException e) {
System.err.println("HelpDisplay: static init failed!!!\n" + " Could not find helpset files, switching to message frame...");
}
}Example 19
| Project: bobbin-master File: HelpViewer.java View source code |
/**
* display the java help dialog.
* @param owner the owner frame, used for centering the dialog.
*/
public static void show(Frame owner) {
JHelp helpViewer = null;
SwingHelpUtilities.setContentViewerUI("com.pironet.tda.HelpViewer");
try {
ClassLoader cl = TDA.class.getClassLoader();
URL url = HelpSet.findHelpSet(cl, "javahelp/jhelpset.hs");
helpViewer = new JHelp(new HelpSet(cl, url));
helpViewer.setToolbarDisplayed(false);
helpViewer.setCurrentID("general");
} catch (Exception e) {
}
Enumeration eNavigators = helpViewer.getHelpNavigators();
while (eNavigators.hasMoreElements()) {
JHelpNavigator nav = (JHelpNavigator) eNavigators.nextElement();
if (nav instanceof JHelpIndexNavigator) {
helpViewer.removeHelpNavigator(nav);
}
}
final JDialog helpFrame = new JDialog(owner, ResourceManager.translate("help.contents"));
try {
helpFrame.setIconImage(TDA.createImageIcon("Help.gif").getImage());
} catch (NoSuchMethodError nsme) {
}
helpFrame.setLayout(new BorderLayout());
helpFrame.getContentPane().add(helpViewer, BorderLayout.CENTER);
JButton closeButton = new JButton("Close");
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(closeButton);
helpFrame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
helpFrame.dispose();
}
});
helpFrame.getRootPane().setDefaultButton(closeButton);
helpFrame.setSize(new Dimension(900, 700));
helpFrame.setLocationRelativeTo(owner);
helpFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
helpFrame.setVisible(true);
}Example 20
| Project: ComplexRapidMiner-master File: HelpService.java View source code |
public static void setHelpSetFile(String helpSetFile) {
HelpSet helpSet;
try {
ClassLoader classLoader = HelpSet.class.getClassLoader();
URL url = HelpSet.findHelpSet(classLoader, helpSetFile);
helpSet = new HelpSet(classLoader, url);
} catch (Exception ee) {
LogService.getGlobal().logWarning("Help Set not found");
return;
}
helpViewer.setModel(new DefaultHelpModel(helpSet));
helpBroker = helpSet.createHelpBroker();
}Example 21
| Project: intellij-community-master File: HelpManagerImpl.java View source code |
public void invokeHelp(@Nullable String id) {
id = StringUtil.notNullize(id, "top");
UsageTrigger.trigger("ide.help." + id);
if (MacHelpUtil.isApplicable() && MacHelpUtil.invokeHelp(id)) {
return;
}
IdeaHelpBroker broker = SoftReference.dereference(myBrokerReference);
if (broker == null) {
HelpSet set = createHelpSet();
if (set != null) {
broker = new IdeaHelpBroker(set);
myBrokerReference = new WeakReference<>(broker);
}
}
if (broker == null) {
ApplicationInfoEx info = ApplicationInfoEx.getInstanceEx();
String minorVersion = info.getMinorVersion();
int dot = minorVersion.indexOf('.');
if (dot != -1) {
minorVersion = minorVersion.substring(0, dot);
}
String productVersion = info.getMajorVersion() + "." + minorVersion;
String url = (info.getWebHelpUrl() + "/" + productVersion + "/?" + id).replaceAll("//", "/");
if (PlatformUtils.isJetBrainsProduct()) {
String productCode = info.getBuild().getProductCode();
if (!StringUtil.isEmpty(productCode)) {
url += "&utm_source=from_product&utm_medium=help_link&utm_campaign=" + productCode + "&utm_content=" + productVersion;
}
}
BrowserUtil.browse(url);
return;
}
Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
broker.setActivationWindow(activeWindow);
try {
broker.setCurrentID(id);
} catch (BadIDException e) {
Messages.showErrorDialog(IdeBundle.message("help.topic.not.found.error", id), CommonBundle.getErrorTitle());
return;
}
broker.setDisplayed(true);
}Example 22
| Project: j-qtl-master File: ScanTwoSummaryPanel.java View source code |
/**
* take care of all of the initialization that isn't handled by the
* GUI builder
* @param availableCrosses
* the crosses that we should make available
* @param selectedScanTwoResult
* the scan one that we should select
*/
private void postGuiInit(Cross[] availableCrosses, ScanTwoResult selectedScanTwoResult) {
for (MarkerStringFormat currFormat : MarkerStringFormat.values()) {
this.markerFormatComboBox.addItem(currFormat);
}
this.scanResultsTable.setModel(new CheckableListTableModel(1));
this.scanResultsTable.addMouseListener(this.tableMouseListener);
this.thresholdTypeComboBox.addItem(ConfidenceThresholdState.NO_THRESHOLD);
this.thresholdTypeComboBox.addItem(ConfidenceThresholdState.LOD_SCORE_THRESHOLD);
// get all of the scan results
List<ScanTwoResult> allScanResults = new ArrayList<ScanTwoResult>();
for (Cross currCross : availableCrosses) {
this.crossComboBox.addItem(currCross);
allScanResults.addAll(currCross.getScanTwoResults());
}
// initialize the scan result combo box
DefaultComboBoxModel scansToSummarizeComboModel = (DefaultComboBoxModel) this.scanResultComboBox.getModel();
scansToSummarizeComboModel.removeAllElements();
for (ScanTwoResult currScanTwoResult : allScanResults) {
scansToSummarizeComboModel.addElement(currScanTwoResult);
}
if (selectedScanTwoResult != null) {
this.crossComboBox.setSelectedItem(selectedScanTwoResult.getParentCross());
this.crossSelectionChanged();
scansToSummarizeComboModel.setSelectedItem(selectedScanTwoResult);
this.rebuildSummaryTable();
}
for (ModelToOptimize modelToOptimize : ModelToOptimize.values()) {
this.modelToOptimizeComboBox.addItem(modelToOptimize);
}
this.fullAlphaSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.fullLodSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.fullVsOneAlphaSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.fullVsOneLodSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.intAlphaSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.intLodSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.addAlphaSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.addLodSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.addVsOneAlphaSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.addVsOneLodSpinnerModel.addChangeListener(this.thresholdSpinnerChangeListener);
this.fullThresholdCheckbox.addItemListener(this.thresholdCheckboxListener);
this.fullVsOneCheckbox.addItemListener(this.thresholdCheckboxListener);
this.interactionCheckbox.addItemListener(this.thresholdCheckboxListener);
this.additiveCheckBox.addItemListener(this.thresholdCheckboxListener);
this.addVsOneCheckbox.addItemListener(this.thresholdCheckboxListener);
// create the export table action
this.exportTableButton.setAction(new ExportDataTableAction(new JTableDataTable(this.scanResultsTable)));
// initialize the help stuff
HelpSet hs = QTL.getInstance().getMenubar().getHelpSet();
CSH.setHelpIDString(this.helpButton, HELP_ID_STRING);
this.helpButton.addActionListener(new CSH.DisplayHelpFromSource(hs, SecondaryWindow.class.getName(), null));
}Example 23
| Project: logisim-evolution-master File: MenuHelp.java View source code |
private void loadBroker() {
String helpUrl = Strings.get("helpsetUrl");
if (helpUrl == null) {
helpUrl = "doc/doc_en.hs";
}
if (helpSet == null || helpFrame == null || !helpUrl.equals(helpSetUrl)) {
ClassLoader loader = MenuHelp.class.getClassLoader();
try {
URL hsURL = HelpSet.findHelpSet(loader, helpUrl);
if (hsURL == null) {
disableHelp();
JOptionPane.showMessageDialog(menubar.getParentWindow(), Strings.get("helpNotFoundError"));
return;
}
helpSetUrl = helpUrl;
helpSet = new HelpSet(null, hsURL);
helpComponent = new JHelp(helpSet);
if (helpFrame == null) {
helpFrame = new LFrame();
helpFrame.setTitle(Strings.get("helpWindowTitle"));
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.getContentPane().add(helpComponent);
helpFrame.pack();
} else {
helpFrame.getContentPane().removeAll();
helpFrame.getContentPane().add(helpComponent);
helpComponent.revalidate();
}
} catch (Exception e) {
disableHelp();
e.printStackTrace();
JOptionPane.showMessageDialog(menubar.getParentWindow(), Strings.get("helpUnavailableError"));
return;
}
}
}Example 24
| Project: openflexo-master File: FlexoHelp.java View source code |
public static void reloadHelpSet(File helpSetFile) {
if (!initialized) {
logger.warning("HelpSet not initialized !");
}
if (_hs != null) {
_hs.remove(_hs);
}
_hs = null;
_hb = null;
_helpSetFile = helpSetFile;
getHelpSet();
getHelpBroker();
instance.setChanged();
instance.notifyObservers();
}Example 25
| Project: CFIDE-master File: IDEFrame.java View source code |
@Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
switch(cmd) {
case "openJar":
{
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Jar Files", "jar");
chooser.setFileFilter(filter);
int returnValue = chooser.showOpenDialog(this);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
idePanel.openJar(file.getAbsolutePath());
}
break;
}
case "openProj":
{
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("CFIDE projects", "cfide");
chooser.setFileFilter(filter);
int returnValue = chooser.showOpenDialog(this);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
idePanel.openProj(file.getAbsolutePath());
}
break;
}
case "showLoaded":
pluginViewerFrame.setVisible(true);
break;
case "help":
HelpSet helpSet = new HelpSet();
helpSet.createHelpBroker("test");
JHelp jHelp = new JHelp(helpSet);
idePanel.addTab("Help", jHelp);
idePanel.setSelectedComponent(jHelp);
// dialog.setVisible(true);
break;
case "about":
break;
case "exit":
{
System.exit(1);
break;
}
}
}Example 26
| Project: jDip-master File: Help.java View source code |
public Object construct() {
long time = System.currentTimeMillis();
HKeeper keeper = new HKeeper();
try {
final String helpFileName = Utils.getResourceBasePrefix() + HELP_FILE_NAME;
URL url = HelpSet.findHelpSet(Utils.getClassLoader(), helpFileName, Utils.getLocale());
Log.println("HelpSet URL: ", url);
keeper.helpSet = new HelpSet(null, url);
} catch (Exception e) {
Log.println("Help not available: ", e);
return null;
}
keeper.helpBroker = keeper.helpSet.createHelpBroker("main_help_window");
keeper.helpBroker.initPresentation();
Log.printTimed(time, "Help construct() complete: ");
return keeper;
}Example 27
| Project: Oberon-0-interpreter-master File: Test50.java View source code |
private HelpBroker _getHelpBroker(MainJFrame pMainJFrame_) {
HelpSet pHelpSet = null;
String sHSFile = pMainJFrame_.getInit().getHelpBrokerURL();
try {
URL urlHelpSet = new URL(sHSFile);
Util.debug(this, "_getHelpBroker(..).urlHelpSet: " + urlHelpSet);
pHelpSet = new HelpSet(null, urlHelpSet);
/*sHSFile = pMainJFrame_.getClass().getName();
int lastDot = sHSFile.lastIndexOf( '.' );
if ( lastDot == -1 ) {
sHSFile = "/doc";
} else {
sHSFile = "/"
+ sHSFile.substring( 0, lastDot )
.replace( '.', '/' );
}
sHSFile += pMainJFrame_.getInit()
.getApplicationName()
.toLower()
+ ".hs";
pHelpSet = HelpSet.findHelpSet( null, sHSFile );*/
} catch (Exception pException) {
Util.printlnErr("HelpSet " + sHSFile + " not found!");
}
HelpBroker pHelpBroker = pHelpSet.createHelpBroker();
return pHelpBroker;
}Example 28
| Project: userland-gate-master File: SystemTrayControl.java View source code |
/**
* Creates a help {@code MenuItem} object for use with the
* {@link #getTrayIcon system tray icon} popup menu.
*
* @return a {@code MenuItem}, or {@code null} to display no item
*/
protected MenuItem createHelpItem() {
MenuItem helpItem = null;
HelpSet helpSet = getPanelDescriptor().getHelpSet();
if (helpSet != null) {
final URL url = getHelpURL(helpSet);
if (url != null) {
helpItem = new MenuItem(Finder.getString("tray.popup.help"));
helpItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ClientContext context = getClientContext();
context.getHelpBroker().setCurrentURL(url);
context.showHelp();
}
});
}
}
return helpItem;
}Example 29
| Project: damp.ekeko.snippets-master File: Help.java View source code |
/** Finds default instance of the help.
*/
public static Impl getDefault() {
if (help == null) {
try {
// NOI18N
Class.forName("javax.help.HelpSet");
try {
// Avoid making any static references to javax.help.*
// (just new JavaHelp() should work, but this is a little safer):
// NOI18N
help = (Impl) Class.forName("org.netbeans.core.JavaHelp").newInstance();
} catch (Exception e) {
TopManager.getDefault().notifyException(e);
help = new XMLImpl();
}
} catch (ClassNotFoundException cnfe) {
help = new XMLImpl();
}
}
return help;
}Example 30
| Project: idart-jss-master File: GenericWelcome.java View source code |
/*
* This method creates the help frame
*/
private void createHelp() {
try {
ClassLoader cl = GenericWelcome.class.getClassLoader();
URL url = new //$NON-NLS-1$ //$NON-NLS-2$
URL(//$NON-NLS-1$ //$NON-NLS-2$
(new File(".")).toURI().toURL(), "doc" + //$NON-NLS-1$
File.separator + //$NON-NLS-1$
"jhelpset.hs");
JHelp helpViewer = null;
// Create a new JHelp object with a new HelpSet.
helpViewer = new JHelp(new HelpSet(cl, url));
// helpViewer.setCurrentID("top");
frame.setSize(800, 600);
//$NON-NLS-1$
frame.setTitle(Messages.getString("welcome.help.title"));
frame.getContentPane().add(helpViewer);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
} catch (MalformedURLException e) {
log.error("Unable to load help due to bad URL.");
} catch (HelpSetException e) {
log.error("Unable to load help.");
}
}Example 31
| Project: j-maanova-master File: Maanova.java View source code |
private void initializeHelp() {
try {
URL hsURL = HelpSet.findHelpSet(Maanova.class.getClassLoader(), "org-jax-maanova-help/hs/main.hs");
this.helpSet = new HelpSet(null, hsURL);
this.helpBroker = (DefaultHelpBroker) this.helpSet.createHelpBroker();
} catch (Exception ex) {
LOG.log(Level.WARNING, "Failed to initialize application help", ex);
}
}Example 32
| Project: oops-master File: GUI.java View source code |
private void initializeHelp() {
try {
SwingHelpUtilities.setContentViewerUI("nl.rug.ai.mas.oops.ExternalLinkContentViewerUI");
URL url = HelpSet.findHelpSet(GUI.class.getClassLoader(), "nl/rug/ai/mas/oops/OopsHelp.hs");
HelpSet hs = new HelpSet(null, url);
d_helpBroker = hs.createHelpBroker();
} catch (Exception e) {
System.err.println(e);
}
}Example 33
| Project: acs-master File: CommandCenterGui.java View source code |
protected void showHelpBrowser() {
if (helpBroker == null) {
HelpSet helpSet = controller.getHelpSet();
if (helpSet == null) {
ErrorBox.showMessageDialog(frame, "Online Help could not be loaded", true);
return;
}
helpBroker = (DefaultHelpBroker) helpSet.createHelpBroker();
}
helpBroker.setCurrentID("intro");
helpBroker.setDisplayed(true);
}Example 34
| Project: OsmUi-master File: Menu.java View source code |
public void actionPerformed(ActionEvent e) {
JHelp helpViewer = null;
try {
ClassLoader cl = Menu.class.getClassLoader();
Locale locale = Locale.getDefault();
if (locale.getLanguage() == "de") {
URL url = HelpSet.findHelpSet(cl, "jhelpset.hs");
helpViewer = new JHelp(new HelpSet(cl, url));
helpViewer.setCurrentID("Simple.Introduction");
} else {
URL url = HelpSet.findHelpSet(cl, "en.hs");
helpViewer = new JHelp(new HelpSet(cl, url));
helpViewer.setCurrentID("Simple.Introduction");
}
} catch (Exception f) {
}
JFrame frame = new JFrame();
frame.setTitle(I18N.getString("Menu.help"));
frame.setSize(800, 600);
frame.getContentPane().add(helpViewer);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}Example 35
| Project: jmeld-master File: JMeldPanel.java View source code |
public void doHelp(ActionEvent ae) {
try {
JPanel panel;
AbstractContentPanel content;
URL url;
HelpSet helpSet;
JHelpContentViewer viewer;
JHelpNavigator navigator;
NavigatorView navigatorView;
JSplitPane splitPane;
String contentId;
contentId = "HelpPanel";
if (checkAlreadyOpen(contentId)) {
return;
}
url = HelpSet.findHelpSet(getClass().getClassLoader(), "jmeld");
helpSet = new HelpSet(getClass().getClassLoader(), url);
viewer = new JHelpContentViewer(helpSet);
navigatorView = helpSet.getNavigatorView("TOC");
navigator = (JHelpNavigator) navigatorView.createNavigator(viewer.getModel());
splitPane = new JSplitPane();
splitPane.setLeftComponent(navigator);
splitPane.setRightComponent(viewer);
content = new AbstractContentPanel();
content.setId(contentId);
content.setLayout(new BorderLayout());
content.add(splitPane, BorderLayout.CENTER);
/*
content = new HelpPanel(this);
*/
getTabbedPane().addTab("Help", ImageUtil.getSmallImageIcon("stock_help-agent"), content);
getTabbedPane().setSelectedComponent(content);
} catch (Exception ex) {
ex.printStackTrace();
}
}Example 36
| Project: OWASP-WebScarab-master File: UIFramework.java View source code |
private void initHelp() {
try {
URL url = getClass().getResource("/help/jhelpset.hs");
if (url == null)
throw new NullPointerException("The help set could not be found");
HelpSet helpSet = new HelpSet(null, url);
HelpBroker helpBroker = helpSet.createHelpBroker();
contentsMenuItem.addActionListener(new CSH.DisplayHelpFromSource(helpBroker));
// for F1
helpBroker.enableHelpKey(getRootPane(), "about", helpSet);
} catch (Throwable e) {
final String[] message;
if (e instanceof NullPointerException) {
message = new String[] { "Help set not found" };
} else if (e instanceof NoClassDefFoundError) {
message = new String[] { "The JavaHelp libraries could not be found", "Please add jhall.jar to the extension directory of your Java Runtime environment" };
} else {
message = new String[] { "Unknown error: ", e.getClass().getName(), e.getMessage() };
}
for (int i = 0; i < message.length; i++) {
System.err.println(message[i]);
}
contentsMenuItem.addActionListener(new AbstractAction() {
private static final long serialVersionUID = -7470145620330176298L;
public void actionPerformed(ActionEvent evt) {
JOptionPane.showMessageDialog(UIFramework.this, message, "Help is not available", JOptionPane.ERROR_MESSAGE);
}
});
}
}Example 37
| Project: Scarab-master File: UIFramework.java View source code |
private void initHelp() {
try {
URL url = getClass().getResource("/help/jhelpset.hs");
if (url == null)
throw new NullPointerException("The help set could not be found");
HelpSet helpSet = new HelpSet(null, url);
HelpBroker helpBroker = helpSet.createHelpBroker();
contentsMenuItem.addActionListener(new CSH.DisplayHelpFromSource(helpBroker));
// for F1
helpBroker.enableHelpKey(getRootPane(), "about", helpSet);
} catch (Throwable e) {
final String[] message;
if (e instanceof NullPointerException) {
message = new String[] { "Help set not found" };
} else if (e instanceof NoClassDefFoundError) {
message = new String[] { "The JavaHelp libraries could not be found", "Please add jhall.jar to the extension directory of your Java Runtime environment" };
} else {
message = new String[] { "Unknown error: ", e.getClass().getName(), e.getMessage() };
}
for (int i = 0; i < message.length; i++) {
System.err.println(message[i]);
}
contentsMenuItem.addActionListener(new AbstractAction() {
private static final long serialVersionUID = -7470145620330176298L;
public void actionPerformed(ActionEvent evt) {
JOptionPane.showMessageDialog(UIFramework.this, message, "Help is not available", JOptionPane.ERROR_MESSAGE);
}
});
}
}Example 38
| Project: CompendiumNG-master File: ProjectCompendiumFrame.java View source code |
/**
* Draw frame contents and initialises data.
*/
public boolean initialiseFrame() {
// HELP
try {
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String helpfile = "System" + ProjectCompendium.sFS + "resources" + ProjectCompendium.sFS + "Help" + ProjectCompendium.sFS + "CompendiumHelp.hs";
File file = new File(helpfile);
if (file.exists()) {
URL url = file.toURL();
mainHS = new HelpSet(null, url);
mainHB = mainHS.createHelpBroker();
//$NON-NLS-1$
mainHB.enableHelpKey(//$NON-NLS-1$
ProjectCompendium.APP.getRootPane(), //$NON-NLS-1$
"top", //$NON-NLS-1$
null);
} else {
//$NON-NLS-1$
log.info(//$NON-NLS-1$
"Can't find help file = {}", //$NON-NLS-1$
helpfile);
}
} catch (Exception ee) {
log.error("Error...", ee);
log.info("Help Set {} not found", helpsetName, ee);
}
if (!init()) {
onExit();
}
pack();
if (FormatProperties.lastScreenWidth == -1 && FormatProperties.lastScreenHeight == -1) {
//determins the size of user screen in pixels
Toolkit tk = this.getToolkit();
Dimension screensize = tk.getScreenSize();
nScreenWidth = screensize.width;
nScreenHeight = screensize.height;
int appWidth = (new Double(nScreenWidth * 0.90)).intValue();
int appHeight = (new Double(nScreenHeight * 0.90)).intValue();
int appLocHeight = nScreenHeight / 2 - (new Double(appHeight * 0.55)).intValue();
int appLocWidth = nScreenWidth / 2 - appWidth / 2;
if (ProjectCompendium.isMac) {
setSize(appWidth, appHeight);
setLocation(0, 0);
} else {
setSize(nScreenWidth, nScreenHeight);
setLocation(appLocWidth, appLocHeight);
}
} else {
nScreenWidth = FormatProperties.lastScreenWidth;
nScreenHeight = FormatProperties.lastScreenHeight;
setSize(nScreenWidth, nScreenHeight);
setLocation(FormatProperties.lastScreenX, FormatProperties.lastScreenY);
}
if (!ProjectCompendium.isMac) {
ImageIcon imageicon = UIImages.get(IUIConstants.PC_ICON);
if (imageicon != null)
setIconImage(imageicon.getImage());
}
try {
UIReferenceNodeManager.loadReferenceNodeTypes();
} catch (Exception e) {
log.info("Exception: " + e.getMessage());
}
return true;
}Example 39
| Project: drawfbp-master File: DrawFBP.java View source code |
@SuppressWarnings("rawtypes")
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jfl) {
changeFonts();
return;
}
if (e.getSource() == jfs) {
changeFontSize();
return;
}
String s = e.getActionCommand();
if (s.equals("Open Diagram")) {
openAction(null);
return;
}
if (s.length() > 5 && s.substring(0, 5).equals("Open ")) {
// drop Open and blank
s = s.substring(5);
openAction(s);
return;
}
boolean SAVE_AS = true;
if (s.equals("Save")) {
saveAction(!SAVE_AS);
return;
}
if (s.equals("Save as...")) {
saveAction(SAVE_AS);
return;
}
if (s.equals("New Diagram")) {
int i = jtp.getTabCount();
if (i > 1 || curDiag.diagFile != null || curDiag.changed)
getNewDiag();
jtp.setSelectedIndex(curDiag.tabNum);
frame.repaint();
return;
}
// if (curDiag.compLang == null) {
for (int j = 0; j < gMenu.length; j++) {
if (e.getSource() == gMenu[j]) {
GenLang gl = genLangs[j];
defaultCompLang = gl;
properties.put("defaultCompLang", defaultCompLang.label);
propertiesChanged = true;
if (curDiag != null && curDiag.diagLang != defaultCompLang) {
curDiag.diagLang = defaultCompLang;
curDiag.changed = true;
}
changeLanguage(gl);
MyOptionPane.showMessageDialog(frame, "Language group changed to " + defaultCompLang.showLangs());
frame.repaint();
return;
}
}
if (s.equals("Generate .fbp code")) {
if (curDiag == null || curDiag.blocks.isEmpty()) {
MyOptionPane.showMessageDialog(frame, "No components specified", MyOptionPane.ERROR_MESSAGE);
return;
}
if (curDiag.title == null || curDiag.title.equals("(untitled)")) {
MyOptionPane.showMessageDialog(frame, "Untitled diagram - please do Save first", MyOptionPane.ERROR_MESSAGE);
return;
}
CodeManager mc = new CodeManager(curDiag);
if (!mc.genFbpCode())
MyOptionPane.showMessageDialog(frame, "Error in code generation", MyOptionPane.ERROR_MESSAGE);
return;
}
if (s.startsWith("Generate ")) {
if (curDiag == null || curDiag.blocks.isEmpty()) {
MyOptionPane.showMessageDialog(frame, "No components specified", MyOptionPane.ERROR_MESSAGE);
return;
}
if (curDiag.title == null || curDiag.title.equals("(untitled)")) {
MyOptionPane.showMessageDialog(frame, "Untitled diagram - please do Save first", MyOptionPane.ERROR_MESSAGE);
return;
}
CodeManager mc = new CodeManager(curDiag);
mc.genCode();
return;
}
if (s.equals("Display Generated Code")) {
File cFile = null;
GenLang gl = curDiag.diagLang;
// String ss = properties.get("currentImageDir");
String ss = properties.get(gl.netDirProp);
String name = curDiag.diagFile.getName();
if (ss == null)
ss = System.getProperty("user.home");
File file = new File(ss);
MyFileChooser fc = new MyFileChooser(file, curDiag.fCPArr[GENCODE]);
int i = name.indexOf(".drw");
ss += File.separator + name.substring(0, i) + curDiag.fCPArr[GENCODE].fileExt;
fc.setSuggestedName(ss);
// force saveAs
int returnVal = fc.showOpenDialog(true);
cFile = null;
if (returnVal == MyFileChooser.APPROVE_OPTION) {
cFile = new File(getSelFile(fc));
}
// }
if (cFile == null)
return;
if (!(cFile.exists()))
return;
CodeManager mc = new CodeManager(curDiag);
mc.display(cFile, gl);
return;
}
if (s.equals("Run Command")) {
String command = "";
readPropertiesFile();
if (null == (command = properties.get("runCommand")))
command = "echo Enter command";
String ans = (String) MyOptionPane.showInputDialog(driver.frame, "Enter or change text", "Command with no diagram name", MyOptionPane.PLAIN_MESSAGE, null, null, command);
if (ans != null && ans.length() > 0) {
command = ans;
properties.put("runCommand", command);
propertiesChanged = true;
}
Process p = null;
String realCommand = "";
if ((System.getProperty("os.name")).startsWith("Windows"))
realCommand += "cmd /c ";
realCommand += command;
String jSONNetworkDir = null;
if (curDiag.title == null)
MyOptionPane.showMessageDialog(frame, "No diagram selected: executing command with no diagram JSON", MyOptionPane.ERROR_MESSAGE);
else {
if (null == (jSONNetworkDir = properties.get("currentJSONNetworkDir"))) {
MyOptionPane.showMessageDialog(frame, "Diagram selected but JSON directory missing: generate JSON from diagram \n" + "will prompt for JSON directory", MyOptionPane.ERROR_MESSAGE);
return;
}
String fileName = jSONNetworkDir + File.separator + curDiag.title + ".json";
File file = new File(fileName);
if (!file.isFile()) {
MyOptionPane.showMessageDialog(frame, "JSON file for diagram does not exist: generate JSON from diagram", MyOptionPane.ERROR_MESSAGE);
return;
}
realCommand += " " + fileName;
}
ans = (String) MyOptionPane.showInputDialog(driver.frame, "Enter or change text", "Actual command", MyOptionPane.PLAIN_MESSAGE, null, null, realCommand);
if (ans != null && ans.length() > 0) {
realCommand = ans;
//properties.put("runCommand", realCommand);
//propertiesChanged = true;
}
try {
p = Runtime.getRuntime().exec(realCommand);
} catch (IOException e1) {
e1.printStackTrace();
}
// final JEditorPane pane = new JEditorPane();
final JFrame jframe = new JFrame("Run Output");
final JEditorPane pane = new JEditorPane("text/plain", " ");
pane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(pane);
jframe.add(scrollPane);
jframe.setVisible(true);
pane.setVisible(true);
scrollPane.setVisible(true);
pane.setFont(fontf);
jframe.setSize(600, 400);
jframe.setLocation(100, 50);
jframe.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent ev) {
jframe.dispose();
}
});
MyRunnable r = new MyRunnable(pane) {
public void run() {
BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = null;
try {
while ((line = input.readLine()) != null) {
try {
Document doc = pane.getDocument();
doc.insertString(doc.getLength(), line, null);
} catch (BadLocationException exc) {
exc.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
};
r.proc = p;
new Thread(r).start();
try {
r.proc.waitFor();
} catch (InterruptedException ev) {
ev.printStackTrace();
}
}
if (s.equals("Clear Language Association")) {
curDiag.diagLang = null;
curDiag.changed = true;
jtf.setText("");
// curDiag.changeCompLang();
}
// }
if (s.equals("Locate JavaFBP Jar File")) {
locateJavaFBPJarFile();
return;
}
if (s.equals("Add Additional Component Jar File")) {
addAdditionalJarFile();
return;
}
if (s.equals("Locate DrawFBP Help File")) {
locateJhallJarFile();
return;
}
if (s.equals("Change Fonts")) {
changeFonts();
}
if (s.equals("Change Font Size")) {
changeFontSize();
}
if (s.equals("Print")) {
int x1, w1, y1, h1;
x1 = curDiag.area.getX();
y1 = curDiag.area.getY();
w1 = curDiag.area.getWidth();
h1 = curDiag.area.getHeight();
Rectangle rect = new Rectangle(x1, y1, w1, h1);
PrintableDocument pd = new PrintableDocument(frame.getContentPane(), this);
// PrintableDocument.printComponent(frame.getContentPane());
// doesn't seem to make a difference!
pd.setRectangle(rect);
pd.print();
return;
}
if (s.equals("Display Properties")) {
displayProperties();
}
if (s.equals("Toggle Click to Grid")) {
curDiag.clickToGrid = !curDiag.clickToGrid;
grid.setSelected(curDiag.clickToGrid);
return;
}
if (s.equals("Toggle Pan Switch")) {
panSwitch = !panSwitch;
// frame.setCursor(defaultCursor);
return;
}
if (s.equals("Export Image")) {
if (curDiag == null || curDiag.title == null || curDiag.blocks.isEmpty()) {
MyOptionPane.showMessageDialog(null, "Unable to export image for empty or unsaved diagram - please do save first", MyOptionPane.ERROR_MESSAGE);
return;
}
File file = null;
//curDiag.imageFile = null;
// crop
int x1, w1, y1, h1;
x1 = Math.max(1, curDiag.minX);
w1 = curDiag.maxX - x1;
y1 = Math.max(1, curDiag.minY);
h1 = curDiag.maxY - y1;
int w = curDiag.area.getWidth();
int h = curDiag.area.getHeight();
w1 = Math.min(w1, w - x1);
h1 = Math.min(h1, h - y1);
BufferedImage buffer2 = buffer.getSubimage(x1, y1, w1, h1);
//int w2 = buffer2.getWidth();
//int h2 = buffer2.getHeight();
BufferedImage combined = new BufferedImage(w1, h1 + 100, BufferedImage.TYPE_INT_ARGB);
Graphics g = combined.getGraphics();
//Graphics g = buffer2.getGraphics();
g.setColor(Color.WHITE);
//g.fillRect(0, 0, w1, h1 + 100);
g.drawImage(buffer2, 0, 0, null);
//g.setColor(Color.RED);
g.fillRect(0, h1, w1, 100);
if (curDiag.desc != null) {
Color col = g.getColor();
g.setColor(Color.BLUE);
Font f = fontg.deriveFont(Font.ITALIC, 18.0f);
g.setFont(f);
int x = combined.getWidth() / 2;
//int x = buffer2.getWidth() / 2;
FontMetrics metrics = g.getFontMetrics(f);
String t = curDiag.desc;
byte[] str = t.getBytes();
int width = metrics.bytesWidth(str, 0, t.length());
g.drawString(t, x - width / 2, buffer2.getHeight() + 40);
g.setColor(col);
}
int i = curDiag.fCPArr[IMAGE].prompt.indexOf(":");
String fn;
if (curDiag.diagFile == null)
fn = "(null)";
else
fn = curDiag.diagFile.getName();
curDiag.fCPArr[IMAGE].prompt = curDiag.fCPArr[IMAGE].prompt.substring(0, i) + ": " + fn;
file = curDiag.genSave(null, fCPArray[IMAGE], combined);
//file = curDiag.genSave(null, fCPArray[IMAGE], buffer2);
if (file == null) {
MyOptionPane.showMessageDialog(frame, "File not saved");
// curDiag.imageFile = null;
g.dispose();
return;
}
// ImageIcon image = new ImageIcon(combined);
//curDiag.imageFile = file;
Date date = new Date();
file.setLastModified(date.getTime());
return;
}
if (s.equals("Show Image")) {
File fFile = null;
//if (fFile == null || !fFile.exists()) {
String ss = properties.get("currentImageDir");
if (ss == null)
currentImageDir = new File(System.getProperty("user.home"));
else
currentImageDir = new File(ss);
MyFileChooser fc = new MyFileChooser(currentImageDir, curDiag.fCPArr[IMAGE]);
int i = curDiag.diagFile.getName().indexOf(".drw");
ss += File.separator + curDiag.diagFile.getName().substring(0, i) + curDiag.fCPArr[IMAGE].fileExt;
fc.setSuggestedName(ss);
// set to saveAs
int returnVal = fc.showOpenDialog(true);
// fFile = null;
if (returnVal == MyFileChooser.APPROVE_OPTION) {
fFile = new File(getSelFile(fc));
}
// }
if (fFile == null)
return;
if (!(fFile.exists()))
return;
//}
BufferedImage buffer2 = new BufferedImage(1200, 2000, BufferedImage.TYPE_INT_RGB);
try {
buffer2 = ImageIO.read(fFile);
} catch (IOException e2) {
MyOptionPane.showMessageDialog(frame, "Could not get image", MyOptionPane.ERROR_MESSAGE);
}
ImageIcon image = new ImageIcon(buffer2);
currentImageDir = new File(fFile.getParent());
properties.put("currentImageDir", fFile.getParent());
propertiesChanged = true;
//curDiag.imageFile = fFile;
JDialog popup = new JDialog();
popup.setTitle(fFile.getName());
JLabel jLabel = new JLabel(image);
jLabel.addComponentListener(this);
JScrollPane jsp = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jsp.getViewport().add(jLabel);
Dimension dim = new Dimension(image.getIconWidth(), image.getIconHeight());
jsp.getViewport().setPreferredSize(dim);
jsp.getViewport().setBackground(Color.WHITE);
jLabel.setBackground(Color.WHITE);
popup.add(jsp, BorderLayout.CENTER);
popup.setLocation(new Point(200, 200));
popup.setBackground(Color.WHITE);
//popup.addComponentListener(this);
//popup.setPreferredSize(dim);
popup.pack();
popup.setVisible(true);
popup.setAlwaysOnTop(true);
popup.repaint();
frame.repaint();
return;
}
if (s.equals("Close Diagram")) {
closeTab();
return;
}
if (s.equals("Launch Help")) {
if (jHelpViewer == null) {
if (jhallJarFile == null) {
jhallJarFile = properties.get("jhallJarFile");
boolean res = true;
if (jhallJarFile == null) {
int response = MyOptionPane.showConfirmDialog(frame, //"Locate it?",
"Specify the location of the JavaHelp jar file -\n" + "do a search on Maven Central for 'javahelp'\n" + "Artifact ID: javahelp", "Locate it?", MyOptionPane.OK_CANCEL_OPTION);
if (response == MyOptionPane.OK_OPTION)
res = locateJhallJarFile();
else {
MyOptionPane.showMessageDialog(frame, "No DrawFBP Help jar file located", MyOptionPane.ERROR_MESSAGE);
res = false;
}
}
if (!res)
return;
}
jHelpClass = null;
helpSetClass = null;
URLClassLoader cl = null;
File jFile = new File(jhallJarFile);
if (!(jFile.exists())) {
MyOptionPane.showMessageDialog(frame, "DrawFBP Help jar file shown in properties does not exist\n" + "Use File/Locate DrawFBP Help File, and try Help again", MyOptionPane.ERROR_MESSAGE);
return;
}
try {
URL[] urls = new URL[] { jFile.toURI().toURL() };
// Create a new class loader with the directory
cl = new URLClassLoader(urls, this.getClass().getClassLoader());
// Find the HelpSet file and create the HelpSet object
helpSetClass = cl.loadClass("javax.help.HelpSet");
} catch (MalformedURLException e2) {
} catch (ClassNotFoundException e2) {
} catch (NoClassDefFoundError e2) {
}
if (helpSetClass == null) {
MyOptionPane.showMessageDialog(frame, "HelpSet class not found in jar file or invalid", MyOptionPane.ERROR_MESSAGE);
return;
}
URL url2 = null;
jHelpViewer = null;
try {
Method m = helpSetClass.getMethod("findHelpSet", ClassLoader.class, String.class);
url2 = (URL) m.invoke(null, cl, "helpSet.hs");
Constructor conhs = helpSetClass.getConstructor(ClassLoader.class, URL.class);
Object hs = conhs.newInstance(cl, url2);
jHelpClass = cl.loadClass("javax.help.JHelp");
if (jHelpClass == null) {
MyOptionPane.showMessageDialog(frame, "JHelp class not found in jar file", MyOptionPane.ERROR_MESSAGE);
return;
}
Constructor conjh = jHelpClass.getConstructor(helpSetClass);
jHelpViewer = (JComponent) conjh.newInstance(hs);
} catch (Exception e2) {
MyOptionPane.showMessageDialog(frame, "HelpSet could not be processed: " + e2, MyOptionPane.ERROR_MESSAGE);
return;
}
}
// Create a new frame.
popup2 = new JDialog(frame);
popup2.setTitle("Help DrawFBP");
popup2.setIconImage(favicon.getImage());
applyOrientation(popup2);
popup2.setFocusable(true);
popup2.requestFocusInWindow();
popup2.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ev) {
if (ev.getKeyCode() == KeyEvent.VK_ESCAPE) {
// frame2.setVisible(false);
popup2.dispose();
}
}
});
jHelpViewer.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKS, "CLOSE");
jHelpViewer.getActionMap().put("CLOSE", escapeAction);
// frame2.setPreferredSize(frame.getPreferredSize());
// Add the created helpViewer to it.
popup2.getContentPane().add(jHelpViewer);
// Set a default close operation.
popup2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// Make the frame visible.
popup2.setVisible(true);
popup2.pack();
Dimension dim = frame.getSize();
Point p = frame.getLocation();
int x_off = 100;
int y_off = 100;
popup2.setPreferredSize(new Dimension(dim.width - x_off * 2, dim.height - y_off));
popup2.pack();
popup2.setLocation(p.x + x_off, p.y + y_off);
return;
}
if (s.equals("About")) {
JTextArea ta = new JTextArea();
Font f = fontf;
ta.setColumns(80);
ta.setRows(7);
ta.setEditable(false);
ta.setBorder(BorderFactory.createLineBorder(Color.BLACK));
ta.setLineWrap(true);
String v = VersionAndTimestamp.getVersion();
String dt = VersionAndTimestamp.getDate();
int i = v.length();
String sp1 = " ".substring(0, 7 - i);
i = dt.length();
String sp2 = " ".substring(0, 14 - i);
ta.setText("****************************************************\n" + "* *\n" + "* DrawFBP v" + v + " " + sp1 + " *\n" + "* *\n" + "* Authors: J.Paul Rodker Morrison, *\n" + "* Bob Corrick *\n" + "* *\n" + "* Copyright 2009, ..., 2017 *\n" + "* *\n" + "* FBP web site: www.jpaulmorrison.com/fbp *\n" + "* *\n" + "* (" + dt + ") " + sp2 + " *\n" + "* *\n" + "****************************************************\n");
ta.setFont(f);
final JDialog popup = new JDialog(frame);
popup.add(ta, BorderLayout.CENTER);
Point p = frame.getLocation();
//popup.setPreferredSize(new Dimension(60,20));
popup.pack();
popup.setLocation(p.x + 200, p.y + 100);
popup.setVisible(true);
popup.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
popup.dispose();
}
});
popup.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ev) {
if (ev.getKeyCode() == KeyEvent.VK_ESCAPE) {
popup.dispose();
}
}
});
popup.requestFocusInWindow();
popup.repaint();
frame.repaint();
return;
}
if (// Title of diagram
s.equals("Edit Diagram Description")) {
// as a whole
String ans = (String) MyOptionPane.showInputDialog(frame, "Enter or change text", "Modify diagram description", MyOptionPane.PLAIN_MESSAGE, null, null, curDiag.desc);
if (/* && ans.length() > 0*/
ans != null) {
curDiag.desc = ans;
curDiag.desc = curDiag.desc.replace('\n', ' ');
curDiag.desc = curDiag.desc.trim();
curDiag.changed = true;
if (curDiag.parent != null)
curDiag.parent.description = ans;
}
frame.repaint();
return;
}
if (s.equals("New Block")) {
// if (newItemMenu == null) {
// newItemMenu = buildNewItemMenu(driver);
// }
// newItemMenu.setVisible(true);
curDiag.xa = 100 + (new Random()).nextInt(curDiag.area.getWidth() - 200);
curDiag.ya = 100 + (new Random()).nextInt(curDiag.area.getHeight() - 200);
if (null != createBlock(blockType))
curDiag.changed = true;
frame.repaint();
return;
}
if (s.equals("Block-related Actions")) {
Block b = selBlock;
if (b == null) {
MyOptionPane.showMessageDialog(frame, "Block not selected", MyOptionPane.ERROR_MESSAGE);
return;
}
curDiag = b.diag;
b.buildBlockPopupMenu();
use_drag_icon = false;
curDiag.jpm.show(frame, curDiag.xa + 100, curDiag.ya + 100);
frame.repaint();
return;
}
if (s.equals("Arrow-related Actions")) {
Arrow a = selArrow;
if (a == null) {
MyOptionPane.showMessageDialog(frame, "Arrow not selected", MyOptionPane.ERROR_MESSAGE);
return;
}
a.buildArrowPopupMenu();
curDiag = a.diag;
curDiag.jpm.show(frame, a.toX + 100, a.toY + 100);
frame.repaint();
return;
}
setBlkType(s);
frame.repaint();
}Example 40
| Project: Trivial4b-master File: VentanaPrincipal.java View source code |
private void cargaAyuda() {
URL hsURL;
HelpSet hs;
try {
File fichero = new File("ayuda/Ayuda.hs");
hsURL = fichero.toURI().toURL();
hs = new HelpSet(null, hsURL);
} catch (Exception e) {
System.out.println("Ayuda no encontrada");
return;
}
HelpBroker hb = hs.createHelpBroker();
hb.enableHelpKey(getRootPane(), "introduccion", hs);
hb.enableHelpOnButton(mntmNewMenuItem_3, "introduccion", hs);
hb.initPresentation();
}Example 41
| Project: Learn-Kirtan-master File: HelpMenu.java View source code |
/** * Find the HelpSet file and create a HelpSet object */ private HelpSet getHelpSet(String helpSetFile) { HelpSet hs = null; ClassLoader cl = this.getClass().getClassLoader(); try { URL hsURL = HelpSet.findHelpSet(cl, helpSetFile); hs = new HelpSet(null, hsURL); } catch (HelpSetException e) { e.printStackTrace(); } return hs; }
Example 42
| Project: RouteConverter-master File: ApplicationContext.java View source code |
public HelpBroker getHelpBroker() throws HelpSetException, MalformedURLException {
if (broker == null) {
HelpSet helpSet = new HelpSet(Application.class.getClassLoader(), new URL(helpBrokerUrl));
broker = helpSet.createHelpBroker();
}
return broker;
}