use of org.eclipse.swt.layout.RowData in project netxms by netxms.
the class TemplateDataSources method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
config = (ChartConfig) getElement().getAdapter(ChartConfig.class);
Composite dialogArea = new Composite(parent, SWT.NONE);
dciList = new ArrayList<ChartDciConfig>();
for (ChartDciConfig dci : config.getDciList()) dciList.add(new ChartDciConfig(dci));
labelProvider = new DciTemplateListLabelProvider(dciList);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().DataSources_ColPosition, "DCI name", "DCI description", "Display name", Messages.get().DataSources_ColColor };
final int[] columnWidths = { 40, 130, 200, 150, 50 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(labelProvider);
viewer.setInput(dciList.toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
gridData.horizontalSpan = 2;
viewer.getControl().setLayoutData(gridData);
/* buttons on left side */
Composite leftButtons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginLeft = 0;
leftButtons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.LEFT;
leftButtons.setLayoutData(gridData);
upButton = new Button(leftButtons, SWT.PUSH);
upButton.setText(Messages.get().DataSources_Up);
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
upButton.setLayoutData(rd);
upButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveUp();
}
});
upButton.setEnabled(false);
downButton = new Button(leftButtons, SWT.PUSH);
downButton.setText(Messages.get().DataSources_Down);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
downButton.setLayoutData(rd);
downButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveDown();
}
});
downButton.setEnabled(false);
/* buttons on right side */
Composite rightButtons = new Composite(dialogArea, SWT.NONE);
buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
rightButtons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
rightButtons.setLayoutData(gridData);
importButton = new Button(rightButtons, SWT.PUSH);
importButton.setText("Import");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
importButton.setLayoutData(rd);
importButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
importItem();
}
});
addButton = new Button(rightButtons, SWT.PUSH);
addButton.setText(Messages.get().DataSources_Add);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addItem();
}
});
editButton = new Button(rightButtons, SWT.PUSH);
editButton.setText(Messages.get().DataSources_Modify);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editItem();
}
});
editButton.setEnabled(false);
deleteButton = new Button(rightButtons, SWT.PUSH);
deleteButton.setText(Messages.get().DataSources_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteItems();
}
});
deleteButton.setEnabled(false);
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
upButton.setEnabled(selection.size() == 1);
downButton.setEnabled(selection.size() == 1);
}
});
return dialogArea;
}
use of org.eclipse.swt.layout.RowData in project netxms by netxms.
the class TrapConfigurationDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
dialogArea.setLayout(layout);
description = WidgetHelper.createLabeledText(dialogArea, SWT.BORDER, 300, Messages.get().TrapConfigurationDialog_Description, trap.getDescription(), WidgetHelper.DEFAULT_LAYOUT_DATA);
Composite oidSelection = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
oidSelection.setLayout(layout);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
oidSelection.setLayoutData(gd);
oid = WidgetHelper.createLabeledText(oidSelection, SWT.BORDER, 300, Messages.get().TrapConfigurationDialog_TrapOID, (trap.getObjectId() != null) ? trap.getObjectId().toString() : "", // $NON-NLS-1$
WidgetHelper.DEFAULT_LAYOUT_DATA);
buttonSelect = new Button(oidSelection, SWT.PUSH);
buttonSelect.setText(Messages.get().TrapConfigurationDialog_Select);
gd = new GridData();
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
gd.verticalAlignment = SWT.BOTTOM;
buttonSelect.setLayoutData(gd);
buttonSelect.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
selectObjectId();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
event = new EventSelector(dialogArea, SWT.NONE);
event.setLabel(Messages.get().TrapConfigurationDialog_Event);
event.setEventCode(trap.getEventCode());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
event.setLayoutData(gd);
eventTag = WidgetHelper.createLabeledText(dialogArea, SWT.BORDER, SWT.DEFAULT, Messages.get().TrapConfigurationDialog_UserTag, trap.getUserTag(), WidgetHelper.DEFAULT_LAYOUT_DATA);
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().TrapConfigurationDialog_Parameters);
Composite paramArea = new Composite(dialogArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
paramArea.setLayoutData(gd);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
paramArea.setLayout(layout);
paramList = new TableViewer(paramArea, SWT.BORDER | SWT.FULL_SELECTION);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 300;
paramList.getTable().setLayoutData(gd);
setupParameterList();
Composite buttonArea = new Composite(paramArea, SWT.NONE);
RowLayout btnLayout = new RowLayout();
btnLayout.type = SWT.VERTICAL;
btnLayout.marginBottom = 0;
btnLayout.marginLeft = 0;
btnLayout.marginRight = 0;
btnLayout.marginTop = 0;
btnLayout.fill = true;
btnLayout.spacing = WidgetHelper.OUTER_SPACING;
buttonArea.setLayout(btnLayout);
buttonAdd = new Button(buttonArea, SWT.PUSH);
buttonAdd.setText(Messages.get().TrapConfigurationDialog_Add);
buttonAdd.setLayoutData(new RowData(WidgetHelper.BUTTON_WIDTH_HINT, SWT.DEFAULT));
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
addParameter();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
buttonEdit = new Button(buttonArea, SWT.PUSH);
buttonEdit.setText(Messages.get().TrapConfigurationDialog_Edit);
buttonEdit.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editParameter();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
buttonDelete = new Button(buttonArea, SWT.PUSH);
buttonDelete.setText(Messages.get().TrapConfigurationDialog_Delete);
buttonDelete.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteParameters();
}
});
buttonUp = new Button(buttonArea, SWT.PUSH);
buttonUp.setText(Messages.get().TrapConfigurationDialog_MoveUp);
buttonDown = new Button(buttonArea, SWT.PUSH);
buttonDown.setText(Messages.get().TrapConfigurationDialog_MoveDown);
return dialogArea;
}
use of org.eclipse.swt.layout.RowData in project usbdm-eclipse-plugins by podonoghue.
the class UsbdmDebuggerPanel method createUsbdmParametersGroup.
/**
* Create USBDM Parameters selection Group
*
* @param parent Parent of group
*/
protected void createUsbdmParametersGroup(Composite parent) {
// System.err.println("createUsbdmControl()");
Group group = new Group(parent, SWT.NONE);
group.setText("USBDM Parameters");
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
RowLayout layout = new RowLayout();
layout.center = true;
layout.spacing = 10;
layout.wrap = false;
group.setLayout(layout);
//
// Create Combo for interface
//
Label label = new Label(group, SWT.NONE);
// $NON-NLS-1$
label.setText("Interface:");
fComboInterfaceType = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
fInterfaceTypes = new InterfaceType[InterfaceType.values().length];
fComboInterfaceType.select(0);
//
// Create Device selection group
//
label = new Label(group, SWT.NONE);
label.setText("Target Device:");
fTextTargetDeviceName = new Text(group, SWT.BORDER | SWT.READ_ONLY | SWT.CENTER);
fTextTargetDeviceName.setLayoutData(new RowData(200, SWT.DEFAULT));
fButtonTargetDeviceSelect = new Button(group, SWT.NONE);
fButtonTargetDeviceSelect.setText("Device...");
fButtonTargetDeviceSelect.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
InterfaceType interfaceType = getInterfaceType();
DeviceSelector ds = new DeviceSelector(getShell(), interfaceType.targetType, fTextTargetDeviceName.getText());
if (ds.open() == Window.OK) {
fTextTargetDeviceName.setText(ds.getText());
Device device = ds.getDevice();
if (device != null) {
fSuspendUpdate++;
fClockType = device.getClockType();
fGdbServerParameters.setClockTrimFrequency(device.getDefaultClockTrimFreq());
fGdbServerParameters.setNvmClockTrimLocation(device.getDefaultClockTrimNVAddress());
populateTrim();
fSuspendUpdate--;
doUpdate();
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
use of org.eclipse.swt.layout.RowData in project egit by eclipse.
the class PushBranchPage method createControl.
@Override
public void createControl(Composite parent) {
parent.addDisposeListener(event -> {
for (CancelableFuture<Collection<Ref>> l : refs.values()) {
l.cancel(CancelableFuture.CancelMode.INTERRUPT);
}
refs.clear();
});
try {
this.remoteConfigs = RemoteConfig.getAllRemoteConfigs(repository.getConfig());
Collections.sort(remoteConfigs, new Comparator<RemoteConfig>() {
@Override
public int compare(RemoteConfig first, RemoteConfig second) {
return String.CASE_INSENSITIVE_ORDER.compare(first.getName(), second.getName());
}
});
} catch (URISyntaxException e) {
this.remoteConfigs = new ArrayList<>();
handleError(e);
}
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(GridLayoutFactory.swtDefaults().create());
Composite inputPanel = new Composite(main, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(inputPanel);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(inputPanel);
Label sourceLabel = new Label(inputPanel, SWT.NONE);
sourceLabel.setText(UIText.PushBranchPage_Source);
Composite sourceComposite = new Composite(inputPanel, SWT.NONE);
sourceComposite.setLayoutData(GridDataFactory.fillDefaults().indent(UIUtils.getControlIndent(), 0).create());
RowLayout rowLayout = RowLayoutFactory.fillDefaults().create();
rowLayout.center = true;
sourceComposite.setLayout(rowLayout);
if (this.ref != null) {
Image branchIcon = UIIcons.BRANCH.createImage();
this.disposables.add(branchIcon);
Label branchIconLabel = new Label(sourceComposite, SWT.NONE);
branchIconLabel.setLayoutData(new RowData(branchIcon.getBounds().width, branchIcon.getBounds().height));
branchIconLabel.setImage(branchIcon);
Label localBranchLabel = new Label(sourceComposite, SWT.NONE);
localBranchLabel.setText(Repository.shortenRefName(this.ref.getName()));
Label spacer = new Label(sourceComposite, SWT.NONE);
spacer.setLayoutData(new RowData(3, SWT.DEFAULT));
}
Image commitIcon = UIIcons.CHANGESET.createImage();
this.disposables.add(commitIcon);
Label commitIconLabel = new Label(sourceComposite, SWT.NONE);
commitIconLabel.setImage(commitIcon);
commitIconLabel.setLayoutData(new RowData(commitIcon.getBounds().width, commitIcon.getBounds().height));
Label commit = new Label(sourceComposite, SWT.NONE);
StringBuilder commitBuilder = new StringBuilder(this.commitToPush.abbreviate(7).name());
StringBuilder commitTooltipBuilder = new StringBuilder(this.commitToPush.getName());
try (RevWalk revWalk = new RevWalk(repository)) {
RevCommit revCommit = revWalk.parseCommit(this.commitToPush);
// $NON-NLS-1$
commitBuilder.append(" ");
commitBuilder.append(Utils.shortenText(revCommit.getShortMessage(), MAX_SHORTCOMMIT_MESSAGE_LENGTH));
// $NON-NLS-1$
commitTooltipBuilder.append("\n\n");
commitTooltipBuilder.append(revCommit.getFullMessage());
} catch (IOException ex) {
commitBuilder.append(UIText.PushBranchPage_CannotAccessCommitDescription);
commitTooltipBuilder.append(ex.getMessage());
Activator.handleError(ex.getLocalizedMessage(), ex, false);
}
commit.setText(commitBuilder.toString());
commit.setToolTipText(commitTooltipBuilder.toString());
Label destinationLabel = new Label(inputPanel, SWT.NONE);
destinationLabel.setText(UIText.PushBranchPage_Destination);
GridDataFactory.fillDefaults().applyTo(destinationLabel);
Composite remoteGroup = new Composite(inputPanel, SWT.NONE);
remoteGroup.setLayoutData(GridDataFactory.fillDefaults().indent(UIUtils.getControlIndent(), 0).create());
remoteGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create());
Label remoteLabel = new Label(remoteGroup, SWT.NONE);
remoteLabel.setText(UIText.PushBranchPage_RemoteLabel);
// Use full width in case "New Remote..." button is not shown
int remoteSelectionSpan = showNewRemoteButton ? 1 : 2;
remoteSelectionCombo = new RemoteSelectionCombo(remoteGroup, SWT.NONE, SelectionType.PUSH);
GridDataFactory.fillDefaults().grab(true, false).span(remoteSelectionSpan, 1).applyTo(remoteSelectionCombo);
setRemoteConfigs();
remoteSelectionCombo.addRemoteSelectionListener(new IRemoteSelectionListener() {
@Override
public void remoteSelected(RemoteConfig rc) {
remoteConfig = rc;
setRefAssist(rc);
checkPage();
}
});
if (showNewRemoteButton) {
Button newRemoteButton = new Button(remoteGroup, SWT.PUSH);
newRemoteButton.setText(UIText.PushBranchPage_NewRemoteButton);
GridDataFactory.fillDefaults().applyTo(newRemoteButton);
newRemoteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showNewRemoteDialog();
}
});
}
Label branchNameLabel = new Label(remoteGroup, SWT.NONE);
branchNameLabel.setText(UIText.PushBranchPage_RemoteBranchNameLabel);
remoteBranchNameText = new Text(remoteGroup, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(remoteBranchNameText);
remoteBranchNameText.setText(getSuggestedBranchName());
AsynchronousRefProposalProvider candidateProvider = new AsynchronousRefProposalProvider(getContainer(), remoteBranchNameText, () -> {
RemoteConfig config = remoteSelectionCombo.getSelectedRemote();
if (config == null) {
return null;
}
List<URIish> uris = config.getURIs();
if (uris == null || uris.isEmpty()) {
return null;
}
return uris.get(0).toString();
}, uri -> {
FutureRefs list = refs.get(uri);
if (list == null) {
list = new FutureRefs(repository, uri, getLocalBranchName());
refs.put(uri, list);
}
return list;
});
candidateProvider.setContentProposalAdapter(UIUtils.addRefContentProposalToText(remoteBranchNameText, this.repository, candidateProvider, true));
if (this.ref != null) {
upstreamConfigComponent = new UpstreamConfigComponent(inputPanel, SWT.NONE);
upstreamConfigComponent.getContainer().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).indent(SWT.NONE, 20).create());
upstreamConfigComponent.addUpstreamConfigSelectionListener(new UpstreamConfigSelectionListener() {
@Override
public void upstreamConfigSelected(BranchRebaseMode newUpstreamConfig) {
upstreamConfig = newUpstreamConfig;
checkPage();
}
});
setDefaultUpstreamConfig();
}
final Button forceUpdateButton = new Button(inputPanel, SWT.CHECK);
forceUpdateButton.setText(UIText.PushBranchPage_ForceUpdateButton);
forceUpdateButton.setSelection(false);
forceUpdateButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create());
forceUpdateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
forceUpdateSelected = forceUpdateButton.getSelection();
}
});
Link advancedDialogLink = new Link(main, SWT.NONE);
advancedDialogLink.setText(UIText.PushBranchPage_advancedWizardLink);
advancedDialogLink.setToolTipText(UIText.PushBranchPage_advancedWizardLinkTooltip);
advancedDialogLink.setLayoutData(new GridData(SWT.END, SWT.END, false, true));
advancedDialogLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Shell parentShell = getShell().getParent().getShell();
PushWizard advancedWizard = null;
try {
advancedWizard = new PushWizard(repository);
getShell().close();
new WizardDialog(parentShell, advancedWizard).open();
} catch (URISyntaxException ex) {
Activator.logError(ex.getMessage(), ex);
}
}
});
setControl(main);
checkPage();
// Add listener now to avoid setText above to already trigger it.
remoteBranchNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkPage();
}
});
// Do not use a tooltip since there is already a content proposal
// adapter on this field
BranchNameNormalizer normalizer = new BranchNameNormalizer(remoteBranchNameText, null);
normalizer.setVisible(false);
}
use of org.eclipse.swt.layout.RowData in project LAMSADE-tools by LAntoine.
the class MainProgram method main.
/**
* The main that display the whole LAMSADE-Tools application The application
* needs at least that the user enters his login or his Firstname + Lastname
*
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
Preferences prefs = Preferences.userRoot().node("graphical_prefs :");
System.setProperty("SWT_GTK3", "0");
Display display = new Display();
shell = new Shell(display);
shell.setText("Conference List");
GridLayout gridLayout = new GridLayout();
shell.setLayout(gridLayout);
shell.setLocation(400, 200);
shell.layout(true, true);
final Point newSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
shell.setSize(new Point(912, 796));
Menu bar = display.getMenuBar();
if (bar == null) {
bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
}
// File menu
MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
fileItem.setText("&File");
Menu submenu = new Menu(shell, SWT.DROP_DOWN);
fileItem.setMenu(submenu);
MenuItem item = new MenuItem(submenu, SWT.PUSH);
item.addListener(SWT.Selection, e -> PreferencesWindow.open(display));
item.setText("Preferences");
// Help menu
MenuItem helpItem = new MenuItem(bar, SWT.CASCADE);
helpItem.setText("&Help");
Menu submenu2 = new Menu(shell, SWT.DROP_DOWN);
helpItem.setMenu(submenu2);
MenuItem help = new MenuItem(submenu2, SWT.PUSH);
help.addListener(SWT.Selection, e -> Util.openURL("https://github.com/LAntoine/LAMSADE-tools"));
help.setText("Help");
MenuItem about = new MenuItem(submenu2, SWT.PUSH);
about.addListener(SWT.Selection, e -> AboutWindow.open(display));
about.setText("About");
/*
* Initialize Group userDetails which will include : -The Grid data
* which will display the information on the user
*
* -The button that will allow the user to fill in his user information
* using Dauphine's yearbook -The button that will allow him to generate
* a document with his information
*/
Group grpUserDetails = new Group(shell, SWT.NONE);
GridData gd_grpUserDetails = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_grpUserDetails.widthHint = 860;
gd_grpUserDetails.heightHint = 244;
grpUserDetails.setLayoutData(gd_grpUserDetails);
grpUserDetails.setText("User Details");
Label lblFirstname = new Label(grpUserDetails, SWT.NONE);
lblFirstname.setBounds(10, 26, 70, 15);
lblFirstname.setText("First Name");
Label lblNewLabel_1 = new Label(grpUserDetails, SWT.NONE);
lblNewLabel_1.setBounds(10, 53, 70, 15);
lblNewLabel_1.setText("Last Name");
Label lblLogin = new Label(grpUserDetails, SWT.NONE);
lblLogin.setText("Login");
lblLogin.setBounds(9, 85, 70, 15);
txt_firstname = new Text(grpUserDetails, SWT.BORDER);
txt_firstname.setBounds(86, 23, 98, 21);
txt_firstname.setText(Prefs.getSurname());
txt_firstname.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Prefs.setSurname(txt_firstname.getText());
}
});
txt_lastname = new Text(grpUserDetails, SWT.BORDER);
txt_lastname.setBounds(86, 50, 98, 21);
txt_lastname.setText(Prefs.getName());
txt_lastname.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Prefs.setName(txt_lastname.getText());
}
});
txt_login = new Text(grpUserDetails, SWT.BORDER);
txt_login.setBounds(85, 82, 98, 21);
txt_login.setText(Prefs.getLogin());
txt_login.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Prefs.setLogin(txt_login.getText());
}
});
/*
* Handle the User Info's Search Throws exception if firstname or
* lastname is wrong
*/
Button btn_searchInfo = new Button(grpUserDetails, SWT.NONE);
btn_searchInfo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
try {
LOGGER.debug("Launching GetInfosFromYearbook.getUserDetails with : " + txt_lastname.getText() + " and " + txt_firstname.getText());
UserDetails user = null;
if (!txt_login.getText().isEmpty()) {
user = GetInfosFromYearbook.getUserDetails(txt_login.getText());
txt_firstname.setText(user.getFirstName());
txt_lastname.setText(user.getName());
} else {
user = GetInfosFromYearbook.getUserDetails(txt_lastname.getText(), txt_firstname.getText());
}
txt_function.setText(user.getFunction());
txt_number.setText(user.getNumber());
txt_email.setText(user.getEmail());
txt_group.setText(user.getGroup());
txt_fax.setText(user.getFax());
txt_office.setText(user.getOffice());
txt_city_ud.setText(user.getCity());
txt_country_ud.setText(user.getCountry());
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Error");
mb.setMessage("Please verify firstname and lastname");
mb.open();
}
}
});
btn_searchInfo.setBounds(26, 111, 158, 25);
btn_searchInfo.setText("Search My Info");
Label lbl_function = new Label(grpUserDetails, SWT.NONE);
lbl_function.setBounds(224, 26, 55, 15);
lbl_function.setText("Function");
Label lbl_number = new Label(grpUserDetails, SWT.NONE);
lbl_number.setBounds(224, 56, 55, 15);
lbl_number.setText("Phone");
Label lbl_email = new Label(grpUserDetails, SWT.NONE);
lbl_email.setBounds(224, 92, 55, 15);
lbl_email.setText("E-mail");
Label lbl_group = new Label(grpUserDetails, SWT.NONE);
lbl_group.setBounds(224, 124, 55, 15);
lbl_group.setText("Group");
txt_function = new Text(grpUserDetails, SWT.BORDER);
txt_function.setBounds(285, 20, 219, 21);
txt_number = new Text(grpUserDetails, SWT.BORDER);
txt_number.setBounds(285, 53, 219, 21);
txt_email = new Text(grpUserDetails, SWT.BORDER);
txt_email.setBounds(285, 87, 219, 21);
txt_group = new Text(grpUserDetails, SWT.BORDER);
txt_group.setBounds(285, 121, 219, 21);
Label lbl_fax = new Label(grpUserDetails, SWT.NONE);
lbl_fax.setText("Fax");
lbl_fax.setBounds(535, 26, 55, 15);
Label lbl_office = new Label(grpUserDetails, SWT.NONE);
lbl_office.setText("Office");
lbl_office.setBounds(535, 59, 55, 15);
Label lbl_city = new Label(grpUserDetails, SWT.NONE);
lbl_city.setText("City");
lbl_city.setBounds(535, 92, 55, 15);
Label lbl_country = new Label(grpUserDetails, SWT.NONE);
lbl_country.setText("Country");
lbl_country.setBounds(535, 124, 55, 15);
txt_fax = new Text(grpUserDetails, SWT.BORDER);
txt_fax.setBounds(596, 23, 219, 21);
txt_office = new Text(grpUserDetails, SWT.BORDER);
txt_office.setBounds(596, 56, 219, 21);
txt_city_ud = new Text(grpUserDetails, SWT.BORDER);
txt_city_ud.setBounds(596, 89, 219, 21);
txt_country_ud = new Text(grpUserDetails, SWT.BORDER);
txt_country_ud.setBounds(596, 121, 219, 21);
Button btnGeneratePapierEn = new Button(grpUserDetails, SWT.NONE);
btnGeneratePapierEn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
LOGGER.debug("Button clicked : Paper with header");
UserDetails user = getUserDetails();
if (user != null) {
try {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Success");
mb.setMessage("File saved in : " + SetCoordinates.fillPapierEnTete(user, FileSystems.getDefault().getPath(Prefs.getSaveDir())));
LOGGER.debug("SetCoordinates.fillPapierEnTete completed");
mb.open();
} catch (Exception e2) {
throw new IllegalStateException(e2);
}
} else {
LOGGER.error("Could not run SetCoordinates.fillPapierEnTete");
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Information missing");
mb.setMessage("Please fill name and first name");
mb.open();
}
}
});
Label lblPlaceholder = new Label(grpUserDetails, SWT.NONE);
lblPlaceholder.setBounds(197, 217, 658, 14);
lblPlaceholder.setText("");
btnGeneratePapierEn.setBounds(25, 142, 159, 28);
btnGeneratePapierEn.setText("Generate Papier");
/*
* Initialize Group conferencesInfos which will include : -The Grid data
* which will display conferences
*
* -The buttons that will allow the user to add a new conference in the
* database, [the following operations are available for a selected
* conference] to export an event as a calendar file, to display an
* itinerary from Paris to the conference City And an other button to
* check the available flights
*/
// Group Conferences informations
Group grp_conferencesInfos = new Group(shell, SWT.NONE);
GridData gd_conferencesInfos = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_conferencesInfos.heightHint = 214;
gd_conferencesInfos.widthHint = 860;
grp_conferencesInfos.setLayoutData(gd_conferencesInfos);
grp_conferencesInfos.setText("Conferences");
Table table = new Table(grp_conferencesInfos, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
table.setBounds(165, 16, 502, 134);
table.setHeaderVisible(true);
fillConferenceTable(table);
Button btn_addNewConf = new Button(grp_conferencesInfos, SWT.NONE);
btn_addNewConf.setBounds(165, 156, 149, 25);
btn_addNewConf.setText("Create conference");
Label lblTitle = new Label(grp_conferencesInfos, SWT.NONE);
lblTitle.setAlignment(SWT.RIGHT);
lblTitle.setBounds(25, 16, 50, 15);
lblTitle.setText("Title");
Text txt_title = new Text(grp_conferencesInfos, SWT.BORDER);
txt_title.setBounds(81, 15, 78, 21);
Label lblUrl = new Label(grp_conferencesInfos, SWT.NONE);
lblUrl.setAlignment(SWT.RIGHT);
lblUrl.setText("URL");
lblUrl.setBounds(25, 45, 50, 15);
Text txt_url = new Text(grp_conferencesInfos, SWT.BORDER);
txt_url.setBounds(81, 42, 78, 21);
Label lblStartDate = new Label(grp_conferencesInfos, SWT.NONE);
lblStartDate.setAlignment(SWT.RIGHT);
lblStartDate.setText("Start Date");
lblStartDate.setBounds(10, 72, 65, 15);
Text txt_startDate = new Text(grp_conferencesInfos, SWT.BORDER);
txt_startDate.setBounds(81, 69, 78, 21);
Label lblEndDate = new Label(grp_conferencesInfos, SWT.NONE);
lblEndDate.setAlignment(SWT.RIGHT);
lblEndDate.setText("End Date");
lblEndDate.setBounds(10, 99, 65, 15);
Text txt_endDate = new Text(grp_conferencesInfos, SWT.BORDER);
txt_endDate.setBounds(81, 96, 78, 21);
Label lblFee = new Label(grp_conferencesInfos, SWT.NONE);
lblFee.setText("Fee");
lblFee.setBounds(42, 126, 33, 15);
Text txt_fee = new Text(grp_conferencesInfos, SWT.BORDER);
txt_fee.setBounds(81, 123, 78, 21);
// add news fields
Label lblCity = new Label(grp_conferencesInfos, SWT.NONE);
lblCity.setAlignment(SWT.RIGHT);
lblCity.setBounds(25, 153, 50, 15);
lblCity.setText("City");
Text txt_city = new Text(grp_conferencesInfos, SWT.BORDER);
txt_city.setBounds(81, 150, 78, 21);
Label lblCountry = new Label(grp_conferencesInfos, SWT.NONE);
lblCountry.setAlignment(SWT.RIGHT);
lblCountry.setBounds(25, 180, 50, 15);
lblCountry.setText("Country");
Text txt_address = new Text(grp_conferencesInfos, SWT.BORDER);
txt_address.setBounds(81, 177, 78, 21);
/**
* Create new Conference object, assign it values from selection, then
* pass it function to export to desktop public Conference(int id,
* String title, String url, LocalDate start_date, LocalDate end_date,
* double entry_fee)
*/
Button btnExportEvent = new Button(grp_conferencesInfos, SWT.NONE);
btnExportEvent.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/M/yyyy");
TableItem[] ti = table.getSelection();
if (ti.length == 0) {
// TODO: Put somewhere that an event should be selected
} else {
Conference conf = new Conference(ti[0].getText(0), ti[0].getText(1), LocalDate.parse(ti[0].getText(2), formatter), LocalDate.parse(ti[0].getText(3), formatter), Double.parseDouble(ti[0].getText(4)), ti[0].getText(5), ti[0].getText(6));
try {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterNames(new String[] { "Calendar Files", "All Files (*.*)" });
// Windows
dialog.setFilterExtensions(new String[] { "*.ics", "*.*" });
switch(Util.getOS()) {
case WINDOWS:
dialog.setFilterPath("c:\\");
break;
case LINUX:
dialog.setFilterPath("/");
break;
case MAC:
dialog.setFilterPath("/");
break;
case SOLARIS:
dialog.setFilterPath("/");
break;
default:
dialog.setFilterPath("/");
}
dialog.setFileName("conference.ics");
String path = dialog.open();
File pathToFile = new File(path);
if (pathToFile.exists()) {
LOGGER.info("Duplicate Detected");
MessageBox mBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
mBox.setText("Duplicate detected");
mBox.setMessage("A file with that name already exists. Would you like to replace it?");
int returnCode = mBox.open();
if (returnCode == 256) {
LOGGER.info("User chose not to replace the existing file");
} else {
LOGGER.info("User chose to replace the existing file");
LOGGER.info(pathToFile.getAbsolutePath());
conf.generateCalendarFile(pathToFile.getAbsolutePath());
}
} else {
conf.generateCalendarFile(pathToFile.getAbsolutePath());
}
} catch (ValidationException | ParserException e2) {
e2.printStackTrace();
} catch (Exception e1) {
throw new IllegalStateException(e1);
}
}
}
});
btnExportEvent.setBounds(320, 154, 104, 28);
btnExportEvent.setText("Export Event");
Button btnSaveOrdreMission = new Button(grp_conferencesInfos, SWT.NONE);
btnSaveOrdreMission.setBounds(684, 32, 176, 28);
btnSaveOrdreMission.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
LOGGER.info("Opening the file dialog for user to choose a file to save to the app");
String dialogResult = dialog.open();
LOGGER.info("File chosen: " + dialogResult);
if (dialogResult == null) {
LOGGER.info("User closed the file save dialog");
} else {
// Check if there exists a file with the same name in our
// missions directory
Path path = FileSystems.getDefault().getPath("");
String pathToTargetFile = path.toAbsolutePath() + "/missions/" + new File(dialogResult).getName();
File pathToProject = new File(pathToTargetFile);
boolean exists = pathToProject.exists();
if (exists == true) {
LOGGER.info("Duplicate Detected");
MessageBox mBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
mBox.setText("Duplicate detected");
mBox.setMessage("A file with that name already exists. Would you like to replace it?");
int returnCode = mBox.open();
if (returnCode == 256) {
LOGGER.info("User chose not to replace the existing file");
} else {
LOGGER.info("User chose to replace the existing file");
Util.saveFile(dialogResult);
try {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Success");
mb.setMessage("File saved in : " + pathToTargetFile);
LOGGER.debug("SetCoordinates.fillPapierEnTete completed");
mb.open();
} catch (Exception e2) {
throw new IllegalStateException(e2);
}
}
} else {
LOGGER.info("Calling saveFile(String) to save the file to disk");
Util.saveFile(dialogResult);
try {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Success");
mb.setMessage("File saved in : " + pathToTargetFile);
LOGGER.debug("SetCoordinates.fillPapierEnTete completed");
mb.open();
} catch (Exception e2) {
throw new IllegalStateException(e2);
}
}
}
}
});
btnSaveOrdreMission.setText("Save Ordre Mission");
Button btnYoungSearcher = new Button(grp_conferencesInfos, SWT.CHECK);
btnYoungSearcher.setBounds(684, 114, 125, 16);
btnYoungSearcher.setText("Young searcher");
btnYoungSearcher.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Button btn = (Button) event.getSource();
tabHisto.removeAll();
fillHistoricTable(tabHisto, btn.getSelection());
}
});
/**
* Handle here the GenerateOrderMission button because it needs the
* table to be set This button handles order mission generations for
* both searcher and young searcher, depending on the checkbox
* "btnYoungSearcher" status
*/
Button btnGenerateOM = new Button(grp_conferencesInfos, SWT.NONE);
btnGenerateOM.setBounds(684, 72, 176, 28);
btnGenerateOM.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UserDetails user = getUserDetails();
if (user != null && table.getSelection().length != 0) {
TableItem[] items = table.getSelection();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/M/yyyy");
Conference conf = new Conference(items[0].getText(0), items[0].getText(1), LocalDate.parse(items[0].getText(2), formatter), LocalDate.parse(items[0].getText(3), formatter), Double.valueOf(items[0].getText(4)), items[0].getText(5), items[0].getText(6));
LOGGER.debug(items[0].getText(5) + " " + items[0].getText(6));
if (btnYoungSearcher.getSelection()) {
try {
String fileName = Prefs.getSaveDir() + "\\DJC_" + conf.getCity() + "-" + conf.getCountry() + "_" + conf.getStart_date() + ".fodt";
GenerateMissionOrderYS.fillYSOrderMission(user, conf, fileName);
try {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Success");
mb.setMessage("File saved in : " + fileName);
LOGGER.debug("SetCoordinates.fillPapierEnTete completed");
mb.open();
} catch (Exception e2) {
throw new IllegalStateException(e2);
}
tabHisto.removeAll();
fillHistoricTable(tabHisto, true);
} catch (IllegalArgumentException | IOException | SAXException | ParserConfigurationException e1) {
LOGGER.error("Error : ", e1);
throw new IllegalStateException(e1);
}
} else {
try {
String fileName = Prefs.getSaveDir() + "\\OM_" + conf.getCity() + "-" + conf.getCountry() + "_" + conf.getStart_date() + ".ods";
GenerateMissionOrder.generateSpreadsheetDocument(user, conf, fileName);
try {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setText("Success");
mb.setMessage("File saved in : " + fileName);
LOGGER.debug("SetCoordinates.fillPapierEnTete completed");
mb.open();
} catch (Exception e2) {
throw new IllegalStateException(e2);
}
tabHisto.removeAll();
fillHistoricTable(tabHisto, false);
} catch (Exception e1) {
LOGGER.error("Error : ", e1);
throw new IllegalStateException(e1);
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Information missing");
mb.setMessage("Please fill user information and select a conference");
mb.open();
}
}
});
btnGenerateOM.setText("Generate Order Mission");
Button btnItinerary = new Button(grp_conferencesInfos, SWT.NONE);
btnItinerary.setBounds(440, 156, 115, 25);
btnItinerary.setText("Itinerary");
/**
* This button allow the user to check the available flights to get to
* his conference The departure point is always set to Paris
*/
Button btnFlight = new Button(grp_conferencesInfos, SWT.NONE);
btnFlight.setBounds(561, 156, 84, 25);
btnFlight.setText("Flights");
btnFlight.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (table.getSelection().length != 0) {
try {
TableItem[] items = table.getSelection();
String city = items[0].getText(5);
String url = "https://www.google.fr/flights/flights-from-paris-to-" + city + ".html";
// LOGGER.info(url);
try {
Util.openURL(url);
} catch (IllegalStateException e4) {
LOGGER.error("The city name is not valid");
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Validation Error");
mb.setMessage("The city name is not valid");
mb.open();
}
} catch (IllegalArgumentException e2) {
LOGGER.error("Error : ", e2);
} catch (Exception e1) {
throw new IllegalStateException(e1);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Information missing");
mb.setMessage("Please choose a conference");
mb.open();
}
}
});
/**
* This Button allows the user to check his itinerary from the departure
* point (set to Paris) to the conference destination Needs a conference
* to be selected It will open Google maps on the browser with the
* itinerary set
*/
btnItinerary.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (table.getSelection().length != 0) {
try {
TableItem[] items = table.getSelection();
GoogleItineraryMap itinerary = new GoogleItineraryMap("Paris", items[0].getText(5));
String url = itinerary.setMapUrl();
LOGGER.debug(url);
itinerary.openMapUrl(url);
} catch (IllegalArgumentException e) {
LOGGER.error("Error : ", e);
} catch (Exception e) {
throw new IllegalStateException(e);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Information missing");
mb.setMessage("Please Choose a Conference");
mb.open();
}
}
});
/**
* Behavior of a click on the add new conference button
*/
btn_addNewConf.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
System.out.println("Appui sur le bouton");
if (!txt_title.getText().isEmpty() && !txt_url.getText().isEmpty() && !txt_startDate.getText().isEmpty() && !txt_startDate.getText().isEmpty() && !txt_endDate.getText().isEmpty() && !txt_fee.getText().isEmpty()) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDate startDate = LocalDate.parse(txt_startDate.getText(), formatter);
LocalDate endDate = LocalDate.parse(txt_endDate.getText(), formatter);
Conference conf = new Conference(txt_title.getText(), txt_url.getText(), startDate, endDate, Double.parseDouble(txt_fee.getText()), txt_city.getText(), txt_address.getText());
ConferenceDatabase.insertInDatabase(conf);
/*
* Reload the conference table
*/
table.removeAll();
fillConferenceTable(table);
} catch (DateTimeParseException e1) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Date format error");
mb.setMessage("Please fill the dates in the following format : dd/MM/YYYY");
mb.open();
} catch (SQLException e2) {
throw new IllegalStateException(e2);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Information missing");
mb.setMessage("Please fill in the information regarding the conference");
mb.open();
}
}
});
/**
* This group handles all the Mission order history
*/
Group grp_bottom = new Group(shell, SWT.NONE);
grp_bottom.setLayout(new RowLayout(SWT.HORIZONTAL));
GridData gd_grp_bottom = new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1);
gd_grp_bottom.heightHint = 236;
gd_grp_bottom.widthHint = 857;
grp_bottom.setLayoutData(gd_grp_bottom);
Group grpHistoric = new Group(grp_bottom, SWT.NONE);
grpHistoric.setLayoutData(new RowData(455, 183));
grpHistoric.setText("Historic");
tabHisto = new Table(grpHistoric, SWT.BORDER | SWT.FULL_SELECTION);
tabHisto.setBounds(10, 25, 233, 166);
tabHisto.setHeaderVisible(true);
tabHisto.setLinesVisible(true);
// display arbitrary the OM historic
fillHistoricTable(tabHisto, false);
Button btnDeleteFile = new Button(grpHistoric, SWT.NONE);
btnDeleteFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (tabHisto.getSelection().length != 0) {
Boolean isYC;
if (btnYoungSearcher.getSelection()) {
isYC = true;
} else {
isYC = false;
}
TableItem[] item = tabHisto.getSelection();
History.deleteFile(item[0].getText(0), isYC);
tabHisto.removeAll();
if (btnYoungSearcher.getSelection()) {
fillHistoricTable(tabHisto, true);
} else {
fillHistoricTable(tabHisto, false);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("No File selected");
mb.setMessage("Please Choose a file in the list");
mb.open();
}
}
});
btnDeleteFile.setText("Delete");
btnDeleteFile.setBounds(276, 86, 103, 32);
Button btnOpen = new Button(grpHistoric, SWT.NONE);
btnOpen.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (tabHisto.getSelection().length != 0) {
Boolean isYC;
if (btnYoungSearcher.getSelection()) {
isYC = true;
} else {
isYC = false;
}
TableItem[] item = tabHisto.getSelection();
try {
History.openFile(item[0].getText(0), isYC);
} catch (IOError | IOException e) {
throw new IOError(e);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("No File selected");
mb.setMessage("Please Choose a file in the list");
mb.open();
}
}
});
btnOpen.setText("Open");
btnOpen.setBounds(276, 38, 103, 32);
/**
* Send Email Be careful modification for presentation
*/
Button btnSendTo = new Button(grpHistoric, SWT.NONE);
btnSendTo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
if (tabHisto.getSelection().length != 0) /*
* || txt_email.getText() ==
* "" || txt_email.getText()
* == null
*/
{
Boolean isYC;
if (btnYoungSearcher.getSelection()) {
isYC = true;
} else {
isYC = false;
}
TableItem[] item = tabHisto.getSelection();
String pathToFile = History.getFilePath(item[0].getText(0), isYC);
try {
// Be Careful ! Only for demonstration !!
// sendEmail(txt_email.getText(), path);
Util.sendEmail("lamsadetoolsuser@gmail.com", pathToFile);
} catch (IOError e) {
throw new IOError(e);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("No File selected or no mail adress");
mb.setMessage("Please Choose a file in the list");
mb.open();
}
}
});
btnSendTo.setText("Send To");
btnSendTo.setBounds(276, 142, 103, 32);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
Aggregations