openers improved: substitution hint button added

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/ipscan@23 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2006-09-18 21:45:39 +00:00
parent e802ac8c4e
commit 23df10ef03
3 changed files with 47 additions and 6 deletions

View File

@ -73,6 +73,8 @@ text.openers.name=Opener name (menu item):
text.openers.string=Execution string:
text.openers.directory=Working directory:
text.openers.isCommandLine=Command-line program
text.openers.hint=&Substitutions...
text.openers.hintText=You may use any scanned values returned by fetchers in the execution string.\n\nThe following fetchers are currently available for substitution:\n\n
text.about=%NAME\n\nVersion %VERSION\n%COPYLEFT\n\n<a>%WEBSITE</a>\n<a>%MAILTO</a>\n\nThis is an Open Source Software released under the GPL.
text.gettingStarted=Dummy
text.gettingStarted1=Angry IP Scanner is an IP address scanner tool.\n\nIt is used for scanning IP addresses for finding alive hosts, gathering any kind of needed information about each host.
@ -156,6 +158,7 @@ exception.UserErrorException.openTerminal.failed=Unable to launch the terminal,
exception.UserErrorException.opener.failed=Unable to launch an external process, sorry.\nCommand-line:
exception.UserErrorException.opener.unknownFetcher=The referenced fetcher cannot be resolved in the current scanning result. Cannot execute the opener with parameter:
exception.UserErrorException.opener.nullFetcherValue=The replacement value of the fetcher is empty in the scanning results. Cannot execute the opener with parameter:
exception.UserErrorException.opener.edit.noSelection=Please select the position where do you want to save your opener and or the Insert button to add a new one.
exception.UserErrorException.commands.noSelection=No IP address selected
exception.UserErrorException.commands.noResults=No scanning results available yet, please perform a scan first
exception.UserErrorException.favorite.alreadyExists=A favorite with the same name already exists, please try a different one

View File

@ -10,8 +10,12 @@ import net.azib.ipscan.config.Config;
import net.azib.ipscan.config.Labels;
import net.azib.ipscan.config.OpenersConfig;
import net.azib.ipscan.config.OpenersConfig.Opener;
import net.azib.ipscan.fetchers.Fetcher;
import net.azib.ipscan.fetchers.FetcherRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.RowLayout;
@ -22,6 +26,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@ -124,6 +129,10 @@ public class EditOpenersDialog extends AbstractModalDialog {
openerStringText = new Text(editGroup, SWT.BORDER);
openerStringText.setSize(SWT.DEFAULT, 22);
Button hintButton = new Button(editGroup, SWT.NONE);
hintButton.setText(Labels.getInstance().getString("text.openers.hint"));
hintButton.addListener(SWT.Selection, new HintButtonListener());
Label openerDirLabel = new Label(editGroup, SWT.NONE);
openerDirLabel.setText(Labels.getInstance().getString("text.openers.directory"));
openerDirLabel.setSize(SWT.DEFAULT, 18);
@ -136,14 +145,14 @@ public class EditOpenersDialog extends AbstractModalDialog {
editGroup.layout();
okButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
okButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
saveOpeners();
shell.close();
}
});
cancelButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
cancelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Config.getOpenersConfig().load();
shell.close();
}
@ -159,6 +168,23 @@ public class EditOpenersDialog extends AbstractModalDialog {
openersConfig.store();
}
private class HintButtonListener implements Listener {
public void handleEvent(Event event) {
// compose the message with all available fetchers
StringBuffer message = new StringBuffer(Labels.getInstance().getString("text.openers.hintText"));
for (Iterator i = FetcherRegistry.getInstance().getRegisteredFetchers().iterator(); i.hasNext(); ) {
String fetcherLabel = ((Fetcher)i.next()).getLabel();
message.append("${").append(fetcherLabel).append("} - ").append(Labels.getInstance().getString(fetcherLabel)).append('\n');
}
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText(Labels.getInstance().getString("title.openers.edit"));
mb.setMessage(message.toString());
mb.open();
}
}
private class UpButtonListener implements Listener {
public void handleEvent(Event event) {
@ -218,8 +244,15 @@ public class EditOpenersDialog extends AbstractModalDialog {
public void handleEvent(Event event) {
String openerName = openerNameText.getText();
if (openerName.length() == 0)
return;
int selectedItem = openersList.getSelectionIndex();
if (selectedItem < 0)
throw new UserErrorException("opener.edit.noSelection");
Config.getOpenersConfig().add(openerName, new OpenersConfig.Opener(openerStringText.getText(), isCommandlineCheckbox.getSelection(), new File(openerDirText.getText())));
openersList.setItem(openersList.getSelectionIndex(), openerName);
openersList.setItem(selectedItem, openerName);
}
}

View File

@ -125,9 +125,14 @@ public class CommandsActions {
throw new UserErrorException("commands.noSelection");
}
mainWindow.setStatusText(Labels.getInstance().getString("state.opening") + name);
openerLauncher.launch(opener, selectedItem);
try {
// wait a bit to make status visible
// TODO: somehow wait until the process is started
Thread.sleep(500);
}
catch (InterruptedException e) {}
mainWindow.setStatusText(null);
}
}