List of usage examples for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_MARGIN
int HORIZONTAL_MARGIN
To view the source code for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_MARGIN.
Click Source Link
From source file:org.eclipse.jsch.internal.ui.preference.PreferencePage.java
License:Open Source License
private Control createHostKeyManagementPage(Composite parent) { Composite group = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2;/*from w w w . j a v a 2s. c o m*/ group.setLayout(layout); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; gd.verticalAlignment = GridData.FILL; group.setLayoutData(gd); Label label = new Label(group, SWT.NONE); label.setText(Messages.CVSSSH2PreferencePage_139); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); viewer = new TableViewer(group, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); Table table = viewer.getTable(); new TableEditor(table); table.setHeaderVisible(true); table.setLinesVisible(true); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(30); /* * The hardcoded hint does not look elegant, but in reality it does not make * anything bound to this 100-pixel value, because in any case the tree on * the left is taller and that's what really determines the height. */ gd.heightHint = 100; table.setLayoutData(gd); table.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { handleSelection(); } }); // Create the table columns new TableColumn(table, SWT.NULL); new TableColumn(table, SWT.NULL); new TableColumn(table, SWT.NULL); TableColumn[] columns = table.getColumns(); columns[0].setText(Messages.CVSSSH2PreferencePage_134); columns[1].setText(Messages.CVSSSH2PreferencePage_135); columns[2].setText(Messages.CVSSSH2PreferencePage_136); viewer.setColumnProperties(new String[] { Messages.CVSSSH2PreferencePage_134, // Messages.CVSSSH2PreferencePage_135, // Messages.CVSSSH2PreferencePage_136 }); viewer.setLabelProvider(new TableLabelProvider()); viewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { // nothing to do } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do } public Object[] getElements(Object inputElement) { if (inputElement == null) return null; return (Object[]) inputElement; } }); TableLayout tl = new TableLayout(); tl.addColumnData(new ColumnWeightData(30)); tl.addColumnData(new ColumnWeightData(20)); tl.addColumnData(new ColumnWeightData(70)); table.setLayout(tl); Composite buttons = new Composite(group, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); removeHostKeyButton = new Button(buttons, SWT.PUSH); removeHostKeyButton.setText(Messages.CVSSSH2PreferencePage_138); int buttonWidth = SWTUtils.calculateControlSize(SWTUtils.createDialogPixelConverter(parent), new Button[] { removeHostKeyButton }); removeHostKeyButton.setLayoutData( SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); removeHostKeyButton.setEnabled(false); removeHostKeyButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { removeHostKey(); } }); Dialog.applyDialogFont(parent); // JSchSession.loadKnownHosts(JSchContext.getDefaultContext().getJSch()); JSchCorePlugin.getPlugin().loadKnownHosts(); HostKeyRepository hkr = getJSch().getHostKeyRepository(); viewer.setInput(hkr.getHostKey()); handleSelection(); return group; }
From source file:org.eclipse.jsch.internal.ui.preference.PreferencePage.java
License:Open Source License
private Control createPreferredAuthenticationPage(Composite parent) { Composite root = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2;/*from w w w.ja v a2s.c o m*/ root.setLayout(layout); Label label = new Label(root, SWT.NONE); GridData textLayoutData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); textLayoutData.horizontalSpan = 2; label.setLayoutData(textLayoutData); label.setText(Messages.CVSSSH2PreferencePage_4); preferedAuthMethodTable = new Table(root, SWT.CHECK | SWT.BORDER); GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); layoutData.verticalSpan = 3; preferedAuthMethodTable.setLayoutData(layoutData); layoutData.minimumHeight = 150; layoutData.minimumWidth = 200; populateAuthMethods(); up = new Button(root, SWT.PUSH); up.setText(Messages.CVSSSH2PreferencePage_2); up.setEnabled(false); setButtonLayoutData(up); down = new Button(root, SWT.PUSH); down.setText(Messages.CVSSSH2PreferencePage_3); down.setEnabled(false); setButtonLayoutData(down); preferedAuthMethodTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean anySelected = false; for (int i = 0; i < preferedAuthMethodTable.getItemCount(); i++) { anySelected |= preferedAuthMethodTable.getItem(i).getChecked(); } if (anySelected) { setErrorMessage(null); setValid(true); } else { setErrorMessage(Messages.CVSSSH2PreferencePage_5); setValid(false); } up.setEnabled(preferedAuthMethodTable.getSelectionIndex() > 0); down.setEnabled( preferedAuthMethodTable.getSelectionIndex() < preferedAuthMethodTable.getItemCount() - 1); } }); up.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedAuthMethodTable.getSelectionIndex(); if (selectedIndex == 1) { //this is the last possible swap up.setEnabled(false); } down.setEnabled(true); TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex); TableItem targetItem = preferedAuthMethodTable.getItem(selectedIndex - 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedAuthMethodTable.setSelection(targetItem); } }); down.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedAuthMethodTable.getSelectionIndex(); if (selectedIndex == preferedAuthMethodTable.getItemCount() - 2) { //this is the last possible swap down.setEnabled(false); } up.setEnabled(true); TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex); TableItem targetItem = preferedAuthMethodTable.getItem(selectedIndex + 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedAuthMethodTable.setSelection(targetItem); } }); return root; }
From source file:org.eclipse.jsch.internal.ui.preference.PreferencePage.java
License:Open Source License
private Control createPreferredKeyExchangePage(Composite parent) { Composite root = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2;//from w w w.ja v a2s .co m root.setLayout(layout); Label label = new Label(root, SWT.NONE); GridData textLayoutData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); textLayoutData.horizontalSpan = 2; label.setLayoutData(textLayoutData); label.setText(Messages.CVSSSH2PreferencePage_140); preferedKeyExchangeMethodTable = new Table(root, SWT.CHECK | SWT.BORDER); GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); layoutData.verticalSpan = 3; preferedKeyExchangeMethodTable.setLayoutData(layoutData); layoutData.minimumHeight = 150; layoutData.minimumWidth = 200; populateAuthMethods(); kex_up = new Button(root, SWT.PUSH); kex_up.setText(Messages.CVSSSH2PreferencePage_2); kex_up.setEnabled(false); setButtonLayoutData(kex_up); kex_down = new Button(root, SWT.PUSH); kex_down.setText(Messages.CVSSSH2PreferencePage_3); kex_down.setEnabled(false); setButtonLayoutData(kex_down); preferedKeyExchangeMethodTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean anySelected = false; for (int i = 0; i < preferedKeyExchangeMethodTable.getItemCount(); i++) { anySelected |= preferedKeyExchangeMethodTable.getItem(i).getChecked(); } if (anySelected) { setErrorMessage(null); setValid(true); } else { setErrorMessage(Messages.CVSSSH2PreferencePage_142); setValid(false); } kex_up.setEnabled(preferedKeyExchangeMethodTable.getSelectionIndex() > 0); kex_down.setEnabled(preferedKeyExchangeMethodTable .getSelectionIndex() < preferedKeyExchangeMethodTable.getItemCount() - 1); } }); kex_up.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedKeyExchangeMethodTable.getSelectionIndex(); if (selectedIndex == 1) { //this is the last possible swap kex_up.setEnabled(false); } kex_down.setEnabled(true); TableItem sourceItem = preferedKeyExchangeMethodTable.getItem(selectedIndex); TableItem targetItem = preferedKeyExchangeMethodTable.getItem(selectedIndex - 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedKeyExchangeMethodTable.setSelection(targetItem); } }); kex_down.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedKeyExchangeMethodTable.getSelectionIndex(); if (selectedIndex == preferedKeyExchangeMethodTable.getItemCount() - 2) { //this is the last possible swap kex_down.setEnabled(false); } kex_up.setEnabled(true); TableItem sourceItem = preferedKeyExchangeMethodTable.getItem(selectedIndex); TableItem targetItem = preferedKeyExchangeMethodTable.getItem(selectedIndex + 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedKeyExchangeMethodTable.setSelection(targetItem); } }); return root; }
From source file:org.eclipse.jsch.internal.ui.preference.PreferencePage.java
License:Open Source License
private Control createPreferredMACPage(Composite parent) { Composite root = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2;/*from w w w . j a v a2 s . co m*/ root.setLayout(layout); Label label = new Label(root, SWT.NONE); GridData textLayoutData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); textLayoutData.horizontalSpan = 2; label.setLayoutData(textLayoutData); label.setText(Messages.CVSSSH2PreferencePage_141); preferedMACMethodTable = new Table(root, SWT.CHECK | SWT.BORDER); GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); layoutData.verticalSpan = 3; preferedMACMethodTable.setLayoutData(layoutData); layoutData.minimumHeight = 150; layoutData.minimumWidth = 200; populateMACMethods(); mac_up = new Button(root, SWT.PUSH); mac_up.setText(Messages.CVSSSH2PreferencePage_2); mac_up.setEnabled(false); setButtonLayoutData(mac_up); mac_down = new Button(root, SWT.PUSH); mac_down.setText(Messages.CVSSSH2PreferencePage_3); mac_down.setEnabled(false); setButtonLayoutData(mac_down); preferedMACMethodTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean anySelected = false; for (int i = 0; i < preferedMACMethodTable.getItemCount(); i++) { anySelected |= preferedMACMethodTable.getItem(i).getChecked(); } if (anySelected) { setErrorMessage(null); setValid(true); } else { setErrorMessage(Messages.CVSSSH2PreferencePage_143); setValid(false); } mac_up.setEnabled(preferedMACMethodTable.getSelectionIndex() > 0); mac_down.setEnabled( preferedMACMethodTable.getSelectionIndex() < preferedMACMethodTable.getItemCount() - 1); } }); mac_up.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedMACMethodTable.getSelectionIndex(); if (selectedIndex == 1) { //this is the last possible swap mac_up.setEnabled(false); } mac_down.setEnabled(true); TableItem sourceItem = preferedMACMethodTable.getItem(selectedIndex); TableItem targetItem = preferedMACMethodTable.getItem(selectedIndex - 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedMACMethodTable.setSelection(targetItem); } }); mac_down.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = preferedMACMethodTable.getSelectionIndex(); if (selectedIndex == preferedMACMethodTable.getItemCount() - 2) { //this is the last possible swap mac_down.setEnabled(false); } mac_up.setEnabled(true); TableItem sourceItem = preferedMACMethodTable.getItem(selectedIndex); TableItem targetItem = preferedMACMethodTable.getItem(selectedIndex + 1); //switch text String stemp = targetItem.getText(); targetItem.setText(sourceItem.getText()); sourceItem.setText(stemp); //switch selection boolean btemp = targetItem.getChecked(); targetItem.setChecked(sourceItem.getChecked()); sourceItem.setChecked(btemp); preferedMACMethodTable.setSelection(targetItem); } }); return root; }
From source file:org.eclipse.jsch.internal.ui.preference.PreferencePage.java
License:Open Source License
private Control createPreferredSSHAgentPage(Composite parent) { Composite root = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.numColumns = 2;//from w ww .ja v a2 s . c o m root.setLayout(layout); Label label = new Label(root, SWT.NONE); GridData textLayoutData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); textLayoutData.horizontalSpan = 2; label.setLayoutData(textLayoutData); label.setText(Messages.CVSSSH2PreferencePage_147); preferedSSHAgentTable = new Table(root, SWT.CHECK | SWT.BORDER); GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); layoutData.verticalSpan = 3; preferedSSHAgentTable.setLayoutData(layoutData); layoutData.minimumHeight = 150; layoutData.minimumWidth = 200; populateSSHAgents(); return root; }
From source file:org.eclipse.jst.j2ee.internal.dialogs.ListMessageDialog.java
License:Open Source License
/** * Creates and returns the contents of an area of the dialog which appears below the message and * above the button bar.//from w w w .j ava 2 s .com * <p> * The default implementation of this framework method returns <code>null</code>. Subclasses * may override. * </p> * * @param the * parent composite to contain the custom area * @return the custom area control, or <code>null</code> */ @Override protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, 0); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); if (listItems != null) { list = new List(composite, SWT.BORDER); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); list.setLayoutData(data); list.setItems(listItems); } return composite; }
From source file:org.eclipse.jst.j2ee.internal.plugin.ErrorDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout);//from w w w . j a v a 2 s . co m composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); ((GridLayout) composite.getLayout()).numColumns = 2; // create image Image image = composite.getDisplay().getSystemImage(SWT.ICON_ERROR); if (image != null) { Label label = new Label(composite, 0); image.setBackground(label.getBackground()); label.setImage(image); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING)); } // create message if (msg != null) { Label label = new Label(composite, SWT.WRAP); label.setText(msg); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(data); label.setFont(parent.getFont()); } return composite; }
From source file:org.eclipse.jst.server.jetty.ui.internal.editor.WebModuleDialog.java
License:Open Source License
/** * Creates and returns the contents of the upper part * of this dialog (above the button bar). * <p>//from ww w. j a va 2s. c o m * The <code>Dialog</code> implementation of this framework method * creates and returns a new <code>Composite</code> with * standard margins and spacing. Subclasses should override. * </p> * * @param parent the parent composite to contain the dialog area * @return the dialog area control */ protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG); // add project field if we are adding a project if (!isEdit && isProject) { Label l = new Label(composite, SWT.NONE); l.setText(Messages.configurationEditorWebModuleDialogProjects); GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); l.setLayoutData(data); projTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); data = new GridData(); data.widthHint = 150; data.heightHint = 75; projTable.setLayoutData(data); whs.setHelp(projTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT); // fill table with web module projects ILabelProvider labelProvider = ServerUICore.getLabelProvider(); IModule[] modules = ServerUtil.getModules(server2.getServerType().getRuntimeType().getModuleTypes()); if (modules != null) { int size = modules.length; for (int i = 0; i < size; i++) { IModule module3 = modules[i]; if ("jst.web".equals(module3.getModuleType().getId())) { IStatus status = server2.canModifyModules(new IModule[] { module3 }, null, null); if (status != null && status.isOK()) { TableItem item = new TableItem(projTable, SWT.NONE); item.setText(0, labelProvider.getText(module3)); item.setImage(0, labelProvider.getImage(module3)); item.setData(module3); } } } } labelProvider.dispose(); new Label(composite, SWT.NONE).setText(" "); } new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogDocumentBase); docBase = new Text(composite, SWT.BORDER); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); docBase.setLayoutData(data); docBase.setText(module.getDocumentBase()); whs.setHelp(docBase, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_DOCBASE); // disable document base for project modules if (isProject || (module.getMemento() != null && module.getMemento().length() > 0)) docBase.setEditable(false); else { docBase.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { module = new WebModule(module.getPath(), docBase.getText(), module.getMemento(), module.isReloadable()); validate(); } }); } if (isEdit || isProject) new Label(composite, SWT.NONE).setText(" "); else { Button browse = new Button(composite, SWT.NONE); browse.setText(Messages.browse); browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent se) { try { DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(Messages.configurationEditorWebModuleDialogSelectDirectory); String selectedDirectory = dialog.open(); if (selectedDirectory != null) docBase.setText(selectedDirectory); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error browsing", e); } } }); } // path (context-root) new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogPath); final Text path = new Text(composite, SWT.BORDER); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = 150; path.setLayoutData(data); path.setText(module.getPath()); /*if (module.getMemento() != null && module.getMemento().length() > 0) path.setEditable(false); else*/ path.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { module = new WebModule(path.getText(), module.getDocumentBase(), module.getMemento(), module.isReloadable()); } }); whs.setHelp(path, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PATH); new Label(composite, SWT.NONE).setText(""); // if (!isProject) { // // auto reload // new Label(composite, SWT.NONE).setText(""); // final Button reloadable = new Button(composite, SWT.CHECK); // reloadable.setText(Messages.configurationEditorWebModuleDialogReloadEnabled); // data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); // reloadable.setLayoutData(data); // reloadable.setSelection(module.isReloadable()); // reloadable.addSelectionListener(new SelectionAdapter() { // public void widgetSelected(SelectionEvent e) { // module = new WebModule(module.getPath(), module.getDocumentBase(), module.getMemento(), reloadable.getSelection()); // } // }); // whs.setHelp(reloadable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_RELOAD); // } if (!isEdit && isProject) { projTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { try { IModule module3 = (IModule) projTable.getSelection()[0].getData(); IWebModule module2 = (IWebModule) module3.loadAdapter(IWebModule.class, null); String contextRoot = module2.getContextRoot(); if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0) contextRoot = "/" + contextRoot; module = new WebModule(contextRoot, module3.getName(), module3.getId(), module.isReloadable()); docBase.setText(module3.getName()); path.setText(contextRoot); module4 = module3; } catch (Exception e) { // ignore } validate(); } }); new Label(composite, SWT.NONE).setText(""); } Dialog.applyDialogFont(composite); return composite; }
From source file:org.eclipse.jst.server.tomcat.ui.internal.editor.MimeMappingDialog.java
License:Open Source License
/** * Creates and returns the contents of the upper part * of this dialog (above the button bar). * <p>/*w ww . j av a2 s . c o m*/ * The <code>Dialog</code> implementation of this framework method * creates and returns a new <code>Composite</code> with * standard margins and spacing. Subclasses should override. * </p> * * @param parent the parent composite to contain the dialog area * @return the dialog area control */ protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG); new Label(composite, SWT.NONE).setText(Messages.configurationEditorMimeMapppingDialogMimeType); final Text type = new Text(composite, SWT.BORDER); GridData data = new GridData(); data.widthHint = 150; type.setLayoutData(data); type.setText(map.getMimeType()); type.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { map = new MimeMapping(map.getExtension(), type.getText()); validate(); } }); whs.setHelp(type, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG_TYPE); new Label(composite, SWT.NONE).setText(Messages.configurationEditorMimeMapppingDialogMimeExtension); final Text extension = new Text(composite, SWT.BORDER); data = new GridData(); data.widthHint = 150; extension.setLayoutData(data); extension.setText(map.getExtension()); extension.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { map = new MimeMapping(extension.getText(), map.getMimeType()); validate(); } }); whs.setHelp(extension, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG_EXTENSION); Dialog.applyDialogFont(composite); return composite; }
From source file:org.eclipse.jst.server.tomcat.ui.internal.editor.WebModuleDialog.java
License:Open Source License
/** * Creates and returns the contents of the upper part * of this dialog (above the button bar). * <p>// w w w . ja v a 2 s. c o m * The <code>Dialog</code> implementation of this framework method * creates and returns a new <code>Composite</code> with * standard margins and spacing. Subclasses should override. * </p> * * @param parent the parent composite to contain the dialog area * @return the dialog area control */ protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG); // add project field if we are adding a project if (!isEdit && isProject) { Label l = new Label(composite, SWT.NONE); l.setText(Messages.configurationEditorWebModuleDialogProjects); GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); l.setLayoutData(data); projTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); data = new GridData(); data.widthHint = 150; data.heightHint = 75; projTable.setLayoutData(data); whs.setHelp(projTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT); // fill table with web module projects ILabelProvider labelProvider = ServerUICore.getLabelProvider(); IModule[] modules = ServerUtil.getModules(server2.getServerType().getRuntimeType().getModuleTypes()); if (modules != null) { int size = modules.length; for (int i = 0; i < size; i++) { IModule module3 = modules[i]; if ("jst.web".equals(module3.getModuleType().getId())) { IStatus status = server2.canModifyModules(new IModule[] { module3 }, null, null); if (status != null && status.isOK()) { TableItem item = new TableItem(projTable, SWT.NONE); item.setText(0, labelProvider.getText(module3)); item.setImage(0, labelProvider.getImage(module3)); item.setData(module3); } } } } labelProvider.dispose(); new Label(composite, SWT.NONE).setText(" "); } new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogDocumentBase); docBase = new Text(composite, SWT.BORDER); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); docBase.setLayoutData(data); docBase.setText(module.getDocumentBase()); whs.setHelp(docBase, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_DOCBASE); // disable document base for project modules if (isProject || (module.getMemento() != null && module.getMemento().length() > 0)) docBase.setEditable(false); else { docBase.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { module = new WebModule(module.getPath(), docBase.getText(), module.getMemento(), module.isReloadable()); validate(); } }); } if (isEdit || isProject) new Label(composite, SWT.NONE).setText(" "); else { Button browse = new Button(composite, SWT.NONE); browse.setText(Messages.browse); browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent se) { try { DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(Messages.configurationEditorWebModuleDialogSelectDirectory); String selectedDirectory = dialog.open(); if (selectedDirectory != null) docBase.setText(selectedDirectory); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error browsing", e); } } }); } // path (context-root) new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogPath); final Text path = new Text(composite, SWT.BORDER); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = 150; path.setLayoutData(data); path.setText(module.getPath()); /*if (module.getMemento() != null && module.getMemento().length() > 0) path.setEditable(false); else*/ path.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { module = new WebModule(path.getText(), module.getDocumentBase(), module.getMemento(), module.isReloadable()); } }); whs.setHelp(path, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PATH); new Label(composite, SWT.NONE).setText(""); if (!isProject) { // auto reload new Label(composite, SWT.NONE).setText(""); final Button reloadable = new Button(composite, SWT.CHECK); reloadable.setText(Messages.configurationEditorWebModuleDialogReloadEnabled); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); reloadable.setLayoutData(data); reloadable.setSelection(module.isReloadable()); reloadable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { module = new WebModule(module.getPath(), module.getDocumentBase(), module.getMemento(), reloadable.getSelection()); } }); whs.setHelp(reloadable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_RELOAD); } if (!isEdit && isProject) { projTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { try { IModule module3 = (IModule) projTable.getSelection()[0].getData(); IWebModule module2 = (IWebModule) module3.loadAdapter(IWebModule.class, null); String contextRoot = module2.getContextRoot(); if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0) contextRoot = "/" + contextRoot; module = new WebModule(contextRoot, module3.getName(), module3.getId(), module.isReloadable()); docBase.setText(module3.getName()); path.setText(contextRoot); module4 = module3; } catch (Exception e) { // ignore } validate(); } }); new Label(composite, SWT.NONE).setText(""); } Dialog.applyDialogFont(composite); return composite; }