public static Combo createEncodingCombo(Composite parent, String curCharset) { if (curCharset == null) { curCharset = GeneralUtils.getDefaultFileEncoding(); } Combo encodingCombo = new Combo(parent, SWT.DROP_DOWN); encodingCombo.setVisibleItemCount(30); SortedMap<String, Charset> charsetMap = Charset.availableCharsets(); int index = 0; int defIndex = -1; for (String csName : charsetMap.keySet()) { Charset charset = charsetMap.get(csName); encodingCombo.add(charset.displayName()); if (charset.displayName().equalsIgnoreCase(curCharset)) { defIndex = index; } if (defIndex < 0) { for (String alias : charset.aliases()) { if (alias.equalsIgnoreCase(curCharset)) { defIndex = index; } } } index++; } if (defIndex >= 0) { encodingCombo.select(defIndex); } else { log.warn("Charset '" + curCharset + "' is not recognized"); // $NON-NLS-1$ //$NON-NLS-2$ } return encodingCombo; }
@Nullable public static String getComboSelection(Combo combo) { int selectionIndex = combo.getSelectionIndex(); if (selectionIndex < 0) { return null; } return combo.getItem(selectionIndex); }
public static Combo createLabelCombo(Composite parent, String label, int style) { Label labelControl = createControlLabel(parent, label); // labelControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Combo combo = new Combo(parent, style); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return combo; }
public static boolean setComboSelection(Combo combo, String value) { if (value == null) { return false; } int count = combo.getItemCount(); for (int i = 0; i < count; i++) { if (value.equals(combo.getItem(i))) { combo.select(i); return true; } } return false; }
/** * Handle a dialog type combo selection event. * * @param event the selection event */ void dialogSelected(SelectionEvent event) { /* Enable/Disable the buttons */ String name = dialogCombo.getText(); boolean isMessageBox = name.equals(ControlExample.getResourceString("MessageBox")); boolean isFileDialog = name.equals(ControlExample.getResourceString("FileDialog")); okButton.setEnabled(isMessageBox); cancelButton.setEnabled(isMessageBox); yesButton.setEnabled(isMessageBox); noButton.setEnabled(isMessageBox); retryButton.setEnabled(isMessageBox); abortButton.setEnabled(isMessageBox); ignoreButton.setEnabled(isMessageBox); iconErrorButton.setEnabled(isMessageBox); iconInformationButton.setEnabled(isMessageBox); iconQuestionButton.setEnabled(isMessageBox); iconWarningButton.setEnabled(isMessageBox); iconWorkingButton.setEnabled(isMessageBox); noIconButton.setEnabled(isMessageBox); saveButton.setEnabled(isFileDialog); openButton.setEnabled(isFileDialog); multiButton.setEnabled(isFileDialog); /* Unselect the buttons */ if (!isMessageBox) { okButton.setSelection(false); cancelButton.setSelection(false); yesButton.setSelection(false); noButton.setSelection(false); retryButton.setSelection(false); abortButton.setSelection(false); ignoreButton.setSelection(false); } }
public void createFileFilterPanel(Shell dialog) { Composite filterPanel = new Composite(dialog, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); filterPanel.setLayoutData(gridData); filterPanel.setLayout(new GridLayout(3, false)); // create filter label Label filterLabel = new Label(filterPanel, SWT.NONE); filterLabel.setText(Messages.getString("VfsFileChooserDialog.filter")); // $NON-NLS-1$ gridData = new GridData(SWT.FILL, SWT.CENTER, false, false); filterLabel.setLayoutData(gridData); // create file filter combo fileFilterCombo = new Combo(filterPanel, SWT.READ_ONLY); gridData = new GridData(SWT.FILL, SWT.FILL, true, false); fileFilterCombo.setLayoutData(gridData); fileFilterCombo.setItems(fileFilterNames); fileFilterCombo.addSelectionListener(this); fileFilterCombo.select(0); }
public void populateCustomUIPanel(Shell dialog) { ArrayList<String> customNames = new ArrayList<String>(); for (int i = 0; i < customUIPanels.size(); i++) { CustomVfsUiPanel panel = customUIPanels.get(i); if (panel.getVfsScheme().equalsIgnoreCase("file") || schemeRestrictions == null || isRestrictedTo(panel.getVfsScheme())) { if (panel.getVfsScheme().equalsIgnoreCase("file") && !showFileScheme) { continue; } customNames.add(panel.getVfsSchemeDisplayText()); } } customUIPicker.setItems(customNames.toArray(new String[] {})); hideCustomPanelChildren(); // hide entire panel if no customizations if (customNames.size() == 0) { customUIPanel.setParent(fakeShell); } else { if (customNames.size() == 1 && "file".equals(customNames.get(0))) { customUIPanel.setParent(fakeShell); } else { String initialSchemeDisplayText = initialScheme; for (int i = 0; i < customUIPanels.size(); i++) { if (customUIPanels.get(i).getVfsScheme().equalsIgnoreCase(initialScheme)) { initialSchemeDisplayText = customUIPanels.get(i).getVfsSchemeDisplayText(); break; } } for (int i = 0; i < customUIPicker.getItemCount(); i++) { if (customUIPicker.getItem(i).equalsIgnoreCase(initialSchemeDisplayText)) { customUIPicker.select(i); customUIPicker.notifyListeners(SWT.Selection, null); } } } } }
public void updateParentFileCombo(FileObject selectedItem) { try { List<FileObject> parentChain = new ArrayList<FileObject>(); // are we a directory? try { if (selectedItem.getType() == FileType.FOLDER && selectedItem.getType().hasChildren()) { // we have real children.... parentChain.add(selectedItem); } } catch (Exception e) { // we are not a folder } FileObject parentFileObject; parentFileObject = selectedItem.getParent(); while (parentFileObject != null) { parentChain.add(parentFileObject); parentFileObject = parentFileObject.getParent(); } File roots[] = File.listRoots(); if (currentPanel != null) { for (int i = 0; i < roots.length; i++) { parentChain.add(currentPanel.resolveFile(roots[i].getAbsolutePath())); } } String items[] = new String[parentChain.size()]; int idx = 0; for (int i = parentChain.size() - 1; i >= 0; i--) { items[idx++] = ((FileObject) parentChain.get(i)).getName().getURI(); } openFileCombo.setItems(items); openFileCombo.select(items.length - 1); } catch (Exception e) { e.printStackTrace(); // then let's not update the GUI } }
private void selectCustomUI() { hideCustomPanelChildren(); String desiredScheme = customUIPicker.getText(); for (CustomVfsUiPanel panel : customUIPanels) { if (desiredScheme.equals(panel.getVfsSchemeDisplayText())) { panel.setParent(customUIPanel); panel.activate(); currentPanel = panel; } } if (currentPanel == null) { currentPanel = customUIPanels.get(0); currentPanel.setParent(customUIPanel); currentPanel.activate(); } customUIPanel.pack(); dialog.layout(); }
public void createCustomUIPanel(final Shell dialog) { customUIPanel = new Composite(dialog, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); customUIPanel.setLayoutData(gridData); customUIPanel.setLayout(new GridLayout(1, false)); comboPanel = new Composite(customUIPanel, SWT.NONE); comboPanel.setLayoutData(gridData); comboPanel.setLayout(new GridLayout(2, false)); comboPanel.setData("donotremove"); Label lookInLabel = new Label(comboPanel, SWT.NONE); lookInLabel.setText(Messages.getString("VfsFileChooserDialog.LookIn")); gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); lookInLabel.setLayoutData(gridData); customUIPicker = new Combo(comboPanel, SWT.READ_ONLY); gridData = new GridData(SWT.LEFT, SWT.CENTER, true, false); customUIPicker.setLayoutData(gridData); if (!showLocation) { comboPanel.setParent(fakeShell); } if (!showCustomUI) { customUIPanel.setParent(fakeShell); } customUIPicker.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent event) { selectCustomUI(); } public void widgetDefaultSelected(SelectionEvent event) { selectCustomUI(); } }); customUIPicker.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent arg0) { selectCustomUI(); } public void keyPressed(KeyEvent arg0) { selectCustomUI(); } }); boolean createdLocal = false; for (CustomVfsUiPanel panel : customUIPanels) { if (panel.getVfsScheme().equals("file")) { createdLocal = true; } } if (!createdLocal) { CustomVfsUiPanel localPanel = new CustomVfsUiPanel("file", "Local", this, SWT.None) { public void activate() { try { File startFile = new File(System.getProperty("user.home")); if (startFile == null || !startFile.exists()) { startFile = File.listRoots()[0]; } FileObject dot = fsm.resolveFile(startFile.toURI().toURL().toExternalForm()); rootFile = dot.getFileSystem().getRoot(); selectedFile = rootFile; setInitialFile(selectedFile); openFileCombo.setText(selectedFile.getName().getURI()); resolveVfsBrowser(); } catch (Throwable t) { } } }; addVFSUIPanel(localPanel); } }
void createControlTransfer(Composite parent) { Label l = new Label(parent, SWT.NONE); l.setText("Text:"); Button b = new Button(parent, SWT.PUSH); b.setText("Cut"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.cut(); } }); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.paste(); } }); text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; text.setLayoutData(data); l = new Label(parent, SWT.NONE); l.setText("Combo:"); b = new Button(parent, SWT.PUSH); b.setText("Cut"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.cut(); } }); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { combo.paste(); } }); combo = new Combo(parent, SWT.NONE); combo.setItems(new String[] {"Item 1", "Item 2", "Item 3", "A longer Item"}); l = new Label(parent, SWT.NONE); l.setText("StyledText:"); l = new Label(parent, SWT.NONE); l.setVisible(false); b = new Button(parent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { styledText.copy(); } }); b = new Button(parent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { styledText.paste(); } }); styledText = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; styledText.setLayoutData(data); }
/** * Handle the create button selection event. * * @param event org.eclipse.swt.events.SelectionEvent */ void createButtonSelected(SelectionEvent event) { /* Compute the appropriate dialog style */ int style = getDefaultStyle(); if (okButton.getEnabled() && okButton.getSelection()) style |= SWT.OK; if (cancelButton.getEnabled() && cancelButton.getSelection()) style |= SWT.CANCEL; if (yesButton.getEnabled() && yesButton.getSelection()) style |= SWT.YES; if (noButton.getEnabled() && noButton.getSelection()) style |= SWT.NO; if (retryButton.getEnabled() && retryButton.getSelection()) style |= SWT.RETRY; if (abortButton.getEnabled() && abortButton.getSelection()) style |= SWT.ABORT; if (ignoreButton.getEnabled() && ignoreButton.getSelection()) style |= SWT.IGNORE; if (iconErrorButton.getEnabled() && iconErrorButton.getSelection()) style |= SWT.ICON_ERROR; if (iconInformationButton.getEnabled() && iconInformationButton.getSelection()) style |= SWT.ICON_INFORMATION; if (iconQuestionButton.getEnabled() && iconQuestionButton.getSelection()) style |= SWT.ICON_QUESTION; if (iconWarningButton.getEnabled() && iconWarningButton.getSelection()) style |= SWT.ICON_WARNING; if (iconWorkingButton.getEnabled() && iconWorkingButton.getSelection()) style |= SWT.ICON_WORKING; if (primaryModalButton.getEnabled() && primaryModalButton.getSelection()) style |= SWT.PRIMARY_MODAL; if (applicationModalButton.getEnabled() && applicationModalButton.getSelection()) style |= SWT.APPLICATION_MODAL; if (systemModalButton.getEnabled() && systemModalButton.getSelection()) style |= SWT.SYSTEM_MODAL; if (saveButton.getEnabled() && saveButton.getSelection()) style |= SWT.SAVE; if (openButton.getEnabled() && openButton.getSelection()) style |= SWT.OPEN; if (multiButton.getEnabled() && multiButton.getSelection()) style |= SWT.MULTI; /* Open the appropriate dialog type */ String name = dialogCombo.getText(); if (name.equals(ControlExample.getResourceString("ColorDialog"))) { ColorDialog dialog = new ColorDialog(shell, style); dialog.setRGB(new RGB(100, 100, 100)); dialog.setText(ControlExample.getResourceString("Title")); RGB result = dialog.open(); textWidget.append(ControlExample.getResourceString("ColorDialog") + Text.DELIMITER); textWidget.append( ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER); textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); return; } if (name.equals(ControlExample.getResourceString("DirectoryDialog"))) { DirectoryDialog dialog = new DirectoryDialog(shell, style); dialog.setMessage(ControlExample.getResourceString("Example_string")); dialog.setText(ControlExample.getResourceString("Title")); String result = dialog.open(); textWidget.append(ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER); textWidget.append( ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER + Text.DELIMITER); return; } if (name.equals(ControlExample.getResourceString("FileDialog"))) { FileDialog dialog = new FileDialog(shell, style); dialog.setFileName(ControlExample.getResourceString("readme_txt")); dialog.setFilterNames(FilterNames); dialog.setFilterExtensions(FilterExtensions); dialog.setText(ControlExample.getResourceString("Title")); String result = dialog.open(); textWidget.append(ControlExample.getResourceString("FileDialog") + Text.DELIMITER); textWidget.append( ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER); textWidget.append("getFileNames() =" + Text.DELIMITER); if ((dialog.getStyle() & SWT.MULTI) != 0) { String[] files = dialog.getFileNames(); for (int i = 0; i < files.length; i++) { textWidget.append("\t" + files[i] + Text.DELIMITER); } } textWidget.append( "getFilterIndex() = " + dialog.getFilterIndex() + Text.DELIMITER + Text.DELIMITER); return; } if (name.equals(ControlExample.getResourceString("FontDialog"))) { FontDialog dialog = new FontDialog(shell, style); dialog.setText(ControlExample.getResourceString("Title")); FontData result = dialog.open(); textWidget.append(ControlExample.getResourceString("FontDialog") + Text.DELIMITER); textWidget.append( ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER); textWidget.append("getFontList() =" + Text.DELIMITER); FontData[] fonts = dialog.getFontList(); if (fonts != null) { for (int i = 0; i < fonts.length; i++) { textWidget.append("\t" + fonts[i] + Text.DELIMITER); } } textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); return; } if (name.equals(ControlExample.getResourceString("PrintDialog"))) { PrintDialog dialog = new PrintDialog(shell, style); dialog.setText(ControlExample.getResourceString("Title")); PrinterData result = dialog.open(); textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER); textWidget.append( ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER); textWidget.append("getScope() = " + dialog.getScope() + Text.DELIMITER); textWidget.append("getStartPage() = " + dialog.getStartPage() + Text.DELIMITER); textWidget.append("getEndPage() = " + dialog.getEndPage() + Text.DELIMITER); textWidget.append( "getPrintToFile() = " + dialog.getPrintToFile() + Text.DELIMITER + Text.DELIMITER); return; } if (name.equals(ControlExample.getResourceString("MessageBox"))) { MessageBox dialog = new MessageBox(shell, style); dialog.setMessage(ControlExample.getResourceString("Example_string")); dialog.setText(ControlExample.getResourceString("Title")); int result = dialog.open(); textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER); /* * The resulting integer depends on the original * dialog style. Decode the result and display it. */ switch (result) { case SWT.OK: textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.OK"})); break; case SWT.YES: textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.YES"})); break; case SWT.NO: textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.NO"})); break; case SWT.CANCEL: textWidget.append( ControlExample.getResourceString("Result", new String[] {"SWT.CANCEL"})); break; case SWT.ABORT: textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.ABORT"})); break; case SWT.RETRY: textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.RETRY"})); break; case SWT.IGNORE: textWidget.append( ControlExample.getResourceString("Result", new String[] {"SWT.IGNORE"})); break; default: textWidget.append(ControlExample.getResourceString("Result", new String[] {"" + result})); break; } textWidget.append(Text.DELIMITER + Text.DELIMITER); } }
public void widgetSelected(SelectionEvent se) { if (se.widget == openFileCombo) { // String filePath = parentFoldersCombo.getItem(parentFoldersCombo.getSelectionIndex()); // vfsBrowser.selectTreeItemByName(filePath, true); try { // resolve the selected folder (without displaying access/secret keys in plain text) // FileObject newRoot = // rootFile.getFileSystem().getFileSystemManager().resolveFile(folderURL.getFolderURL(openFileCombo.getText())); FileObject newRoot = currentPanel.resolveFile(getSelectedFile().getName().getURI()); vfsBrowser.resetVfsRoot(newRoot); } catch (FileSystemException e) { } } else if (se.widget == okButton) { okPressed(); } else if (se.widget == folderUpButton) { try { FileObject newRoot = vfsBrowser.getSelectedFileObject().getParent(); if (newRoot != null) { vfsBrowser.resetVfsRoot(newRoot); vfsBrowser.setSelectedFileObject(newRoot); // make sure access/secret keys not displayed in plain text // String str = folderURL.setFolderURL(newRoot.getName().getURI()); openFileCombo.setText(newRoot.getName().getURI()); } } catch (Exception e) { // top of root } } else if (se.widget == newFolderButton) { promptForNewFolder(); } else if (se.widget == deleteFileButton) { MessageBox messageDialog = new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.YES | SWT.NO); messageDialog.setText(Messages.getString("VfsFileChooserDialog.confirm")); // $NON-NLS-1$ messageDialog.setMessage( Messages.getString("VfsFileChooserDialog.deleteFile")); // $NON-NLS-1$ int status = messageDialog.open(); if (status == SWT.YES) { try { vfsBrowser.deleteSelectedItem(); } catch (FileSystemException e) { MessageBox errorDialog = new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.OK); errorDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$ errorDialog.setMessage(e.getMessage()); errorDialog.open(); } } // } else if (se.widget == changeRootButton) { // promptForNewVfsRoot(); } else if (se.widget == fileFilterCombo) { Runnable r = new Runnable() { public void run() { String filter = fileFilters[fileFilterCombo.getSelectionIndex()]; vfsBrowser.setFilter(filter); try { vfsBrowser.applyFilter(); } catch (FileSystemException e) { MessageBox mb = new MessageBox(newFolderButton.getShell(), SWT.OK); mb.setText( Messages.getString("VfsFileChooserDialog.errorApplyFilter")); // $NON-NLS-1$ mb.setMessage(e.getMessage()); mb.open(); } } }; BusyIndicator.showWhile(fileFilterCombo.getDisplay(), r); } else { okPressed = false; hideCustomPanelChildren(); dialog.dispose(); } }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() */ protected void targetChanged(ITargetDefinition definition) { super.targetChanged(definition); if (definition != null) { // When If the page isn't open yet, try running a UI job so the dialog has time to finish // opening new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { public IStatus runInUIThread(IProgressMonitor monitor) { ITargetDefinition definition = getTargetDefinition(); if (!definition.isResolved()) { try { getContainer() .run( true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor)); if (monitor.isCanceled()) { throw new InterruptedException(); } } }); } catch (InvocationTargetException e) { PDECore.log(e); } catch (InterruptedException e) { fContentTree.setCancelled(); return Status.CANCEL_STATUS; } } fContentTree.setInput(definition); fLocationTree.setInput(definition); if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) { fLocationTab.setImage( PlatformUI.getWorkbench() .getSharedImages() .getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); } else { fLocationTab.setImage(null); } return Status.OK_STATUS; } }.schedule(); String name = definition.getName(); if (name == null) { name = EMPTY_STRING; } if (name.trim().length() > 0) fNameText.setText(name); else setMessage(PDEUIMessages.TargetDefinitionContentPage_8); fLocationTree.setInput(definition); fContentTree.setInput(definition); String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); fOSCombo.setText(presetValue); presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS(); fWSCombo.setText(presetValue); presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch(); fArchCombo.setText(presetValue); presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL()); fNLCombo.setText(presetValue); IPath jrePath = definition.getJREContainer(); if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) { fDefaultJREButton.setSelection(true); } else { String ee = JavaRuntime.getExecutionEnvironmentId(jrePath); if (ee != null) { fExecEnvButton.setSelection(true); fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee)); } else { String vm = JavaRuntime.getVMInstallName(jrePath); if (vm != null) { fNamedJREButton.setSelection(true); fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm)); } } } if (fExecEnvsCombo.getSelectionIndex() == -1) fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); if (fNamedJREsCombo.getSelectionIndex() == -1) fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); updateJREWidgets(); presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments(); fProgramArgs.setText(presetValue); presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments(); fVMArgs.setText(presetValue); fElementViewer.refresh(); } }
private void createTargetEnvironmentGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); initializeChoices(); SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); fOSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()])); fOSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); fWSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()])); fWSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); fArchCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fArchChoices.toArray(new String[fArchChoices.size()])); fArchCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); fNLCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()])); fNLCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String value = fNLCombo.getText(); int index = value.indexOf("-"); // $NON-NLS-1$ if (index > 0) value = value.substring(0, index); getTargetDefinition().setNL(getModelValue(value)); } }); }
public void createToolbarPanel(Shell dialog) { Composite chooserToolbarPanel = new Composite(dialog, SWT.NONE); chooserToolbarPanel.setLayout(new GridLayout(6, false)); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); chooserToolbarPanel.setLayoutData(gridData); // changeRootButton = new Button(chooserToolbarPanel, SWT.PUSH); // changeRootButton.setToolTipText(Messages.getString("VfsFileChooserDialog.changeVFSRoot")); // //$NON-NLS-1$ // changeRootButton.setImage(new Image(chooserToolbarPanel.getDisplay(), // getClass().getResourceAsStream("/icons/network.gif"))); //$NON-NLS-1$ // gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); // changeRootButton.setLayoutData(gridData); // changeRootButton.addSelectionListener(this); Label parentFoldersLabel = new Label(chooserToolbarPanel, SWT.NONE); if (fileDialogMode != VFS_DIALOG_SAVEAS) { parentFoldersLabel.setText( Messages.getString("VfsFileChooserDialog.openFromFolder")); // $NON-NLS-1$ } else { parentFoldersLabel.setText( Messages.getString("VfsFileChooserDialog.saveInFolder")); // $NON-NLS-1$ } gridData = new GridData(SWT.FILL, SWT.CENTER, false, false); parentFoldersLabel.setLayoutData(gridData); openFileCombo = new Combo(chooserToolbarPanel, SWT.BORDER); gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); openFileCombo.setLayoutData(gridData); openFileCombo.addSelectionListener(this); openFileCombo.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent event) { // UP : // if ((event.keyCode == SWT.ARROW_UP) && ((event.stateMask & SWT.CONTROL) == 0) && ((event.stateMask & SWT.ALT) == 0)) { resolveVfsBrowser(); vfsBrowser.selectPreviousItem(); } // DOWN: // if ((event.keyCode == SWT.ARROW_DOWN) && ((event.stateMask & SWT.CONTROL) == 0) && ((event.stateMask & SWT.ALT) == 0)) { resolveVfsBrowser(); vfsBrowser.selectNextItem(); } } public void keyReleased(KeyEvent event) { if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) { try { // resolve the selected folder (without displaying access/secret keys in plain text) // FileObject newRoot = // rootFile.getFileSystem().getFileSystemManager().resolveFile(folderURL.getFolderURL(openFileCombo.getText())); // FileObject newRoot = // rootFile.getFileSystem().getFileSystemManager().resolveFile(getSelectedFile().getName().getURI()); FileObject newRoot = currentPanel.resolveFile(openFileCombo.getText()); vfsBrowser.resetVfsRoot(newRoot); } catch (FileSystemException e) { MessageBox errorDialog = new MessageBox(vfsBrowser.getDisplay().getActiveShell(), SWT.OK); errorDialog.setText( Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$ errorDialog.setMessage(e.getMessage()); errorDialog.open(); } } } }); folderUpButton = new Button(chooserToolbarPanel, SWT.PUSH); folderUpButton.setToolTipText( Messages.getString("VfsFileChooserDialog.upOneLevel")); // $NON-NLS-1$ folderUpButton.setImage(getFolderUpImage(chooserToolbarPanel.getDisplay())); gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); folderUpButton.setLayoutData(gridData); folderUpButton.addSelectionListener(this); deleteFileButton = new Button(chooserToolbarPanel, SWT.PUSH); deleteFileButton.setToolTipText( Messages.getString("VfsFileChooserDialog.deleteFile")); // $NON-NLS-1$ deleteFileButton.setImage(getDeleteImage(chooserToolbarPanel.getDisplay())); gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); deleteFileButton.setLayoutData(gridData); deleteFileButton.addSelectionListener(this); newFolderButton = new Button(chooserToolbarPanel, SWT.PUSH); newFolderButton.setToolTipText( Messages.getString("VfsFileChooserDialog.createNewFolder")); // $NON-NLS-1$ newFolderButton.setImage(getNewFolderImage(chooserToolbarPanel.getDisplay())); gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); newFolderButton.setLayoutData(gridData); newFolderButton.addSelectionListener(this); }
public FileObject open( Shell applicationShell, String[] schemeRestrictions, String initialScheme, boolean showFileScheme, String fileName, String[] fileFilters, String[] fileFilterNames, boolean returnUserAuthenticatedFile, int fileDialogMode, boolean showLocation, boolean showCustomUI) { this.fileDialogMode = fileDialogMode; this.fileFilters = fileFilters; this.fileFilterNames = fileFilterNames; this.applicationShell = applicationShell; this.showFileScheme = showFileScheme; this.initialScheme = initialScheme; this.schemeRestrictions = schemeRestrictions; this.showLocation = showLocation; this.showCustomUI = showCustomUI; FileObject tmpInitialFile = initialFile; if (defaultInitialFile != null && rootFile == null) { try { rootFile = defaultInitialFile.getFileSystem().getRoot(); initialFile = defaultInitialFile; } catch (FileSystemException ignored) { // well we tried } } createDialog(applicationShell); if (!showLocation) { comboPanel.setParent(fakeShell); } else { comboPanel.setParent(customUIPanel); } if (!showCustomUI) { customUIPanel.setParent(fakeShell); } else { customUIPanel.setParent(dialog); } // create our file chooser tool bar, contains parent folder combo and various controls createToolbarPanel(dialog); // create our vfs browser component createVfsBrowser(dialog); populateCustomUIPanel(dialog); if (fileDialogMode == VFS_DIALOG_SAVEAS) { createFileNamePanel(dialog, fileName); } else { // create file filter panel createFileFilterPanel(dialog); } // create our ok/cancel buttons createButtonPanel(dialog); initialFile = tmpInitialFile; // set the initial file selection try { if (initialFile != null || rootFile != null) { vfsBrowser.selectTreeItemByFileObject(initialFile != null ? initialFile : rootFile, true); updateParentFileCombo(initialFile != null ? initialFile : rootFile); setSelectedFile(initialFile != null ? initialFile : rootFile); openFileCombo.setText( initialFile != null ? initialFile.getName().getURI() : rootFile.getName().getURI()); } } catch (FileSystemException e) { MessageBox box = new MessageBox(dialog.getShell()); box.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$ box.setMessage(e.getMessage()); box.open(); } // set the size and show the dialog int height = 550; int width = 800; dialog.setSize(width, height); Rectangle bounds = dialog.getDisplay().getPrimaryMonitor().getClientArea(); int x = (bounds.width - width) / 2; int y = (bounds.height - height) / 2; dialog.setLocation(x, y); dialog.open(); if (rootFile != null && fileDialogMode == VFS_DIALOG_SAVEAS) { if (!rootFile.getFileSystem().hasCapability(Capability.WRITE_CONTENT)) { MessageBox messageDialog = new MessageBox(dialog.getShell(), SWT.OK); messageDialog.setText(Messages.getString("VfsFileChooserDialog.warning")); // $NON-NLS-1$ messageDialog.setMessage( Messages.getString("VfsFileChooserDialog.noWriteSupport")); // $NON-NLS-1$ messageDialog.open(); } } vfsBrowser.fileSystemTree.forceFocus(); while (!dialog.isDisposed()) { if (!dialog.getDisplay().readAndDispatch()) dialog.getDisplay().sleep(); } // we just woke up, we are probably disposed already.. if (!dialog.isDisposed()) { hideCustomPanelChildren(); dialog.dispose(); } if (okPressed) { FileObject returnFile = vfsBrowser.getSelectedFileObject(); if (returnFile != null && fileDialogMode == VFS_DIALOG_SAVEAS) { try { if (returnFile.getType().equals(FileType.FILE)) { returnFile = returnFile.getParent(); } returnFile = returnFile.resolveFile(enteredFileName); } catch (FileSystemException e) { e.printStackTrace(); } } // put user/pass on the filename so it comes out in the getUri call. if (!returnUserAuthenticatedFile) { // make sure to put the user/pass on the url if it's not there if (returnFile != null && returnFile.getName() instanceof URLFileName) { URLFileName urlFileName = (URLFileName) returnFile.getName(); if (urlFileName.getUserName() == null || urlFileName.getPassword() == null) { // set it String user = ""; String pass = ""; UserAuthenticator userAuthenticator = DefaultFileSystemConfigBuilder.getInstance() .getUserAuthenticator(returnFile.getFileSystem().getFileSystemOptions()); if (userAuthenticator != null) { UserAuthenticationData data = userAuthenticator.requestAuthentication(AUTHENTICATOR_TYPES); user = String.valueOf(data.getData(UserAuthenticationData.USERNAME)); pass = String.valueOf(data.getData(UserAuthenticationData.PASSWORD)); try { user = URLEncoder.encode(user, "UTF-8"); pass = URLEncoder.encode(pass, "UTF-8"); } catch (UnsupportedEncodingException e) { // ignore, just use the un encoded values } } // build up the url with user/pass on it int port = urlFileName.getPort(); String portString = (port < 1) ? "" : (":" + port); String urlWithUserPass = urlFileName.getScheme() + "://" + user + ":" + pass + "@" + urlFileName.getHostName() + portString + urlFileName.getPath(); try { returnFile = currentPanel.resolveFile(urlWithUserPass); } catch (FileSystemException e) { // couldn't resolve with user/pass on url??? interesting e.printStackTrace(); } } } } return returnFile; } else { return null; } }
private void createJREGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); initializeJREValues(); SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); fDefaultJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); } }); fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); fNamedJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fNamedJREsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); fNamedJREsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); fExecEnvButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); fExecEnvsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); fExecEnvsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); }
/** Creates the "Control" widget children. */ void createControlWidgets() { /* Create the combo */ String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox"), }; dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY); dialogCombo.setItems(strings); dialogCombo.setText(strings[0]); dialogCombo.setVisibleItemCount(strings.length); /* Create the create dialog button */ createButton = new Button(dialogStyleGroup, SWT.NONE); createButton.setText(ControlExample.getResourceString("Create_Dialog")); createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); /* Create a group for the various dialog button style controls */ Group buttonStyleGroup = new Group(controlGroup, SWT.NONE); buttonStyleGroup.setLayout(new GridLayout()); buttonStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles")); /* Create the button style buttons */ okButton = new Button(buttonStyleGroup, SWT.CHECK); okButton.setText("SWT.OK"); cancelButton = new Button(buttonStyleGroup, SWT.CHECK); cancelButton.setText("SWT.CANCEL"); yesButton = new Button(buttonStyleGroup, SWT.CHECK); yesButton.setText("SWT.YES"); noButton = new Button(buttonStyleGroup, SWT.CHECK); noButton.setText("SWT.NO"); retryButton = new Button(buttonStyleGroup, SWT.CHECK); retryButton.setText("SWT.RETRY"); abortButton = new Button(buttonStyleGroup, SWT.CHECK); abortButton.setText("SWT.ABORT"); ignoreButton = new Button(buttonStyleGroup, SWT.CHECK); ignoreButton.setText("SWT.IGNORE"); /* Create a group for the icon style controls */ Group iconStyleGroup = new Group(controlGroup, SWT.NONE); iconStyleGroup.setLayout(new GridLayout()); iconStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles")); /* Create the icon style buttons */ iconErrorButton = new Button(iconStyleGroup, SWT.RADIO); iconErrorButton.setText("SWT.ICON_ERROR"); iconInformationButton = new Button(iconStyleGroup, SWT.RADIO); iconInformationButton.setText("SWT.ICON_INFORMATION"); iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO); iconQuestionButton.setText("SWT.ICON_QUESTION"); iconWarningButton = new Button(iconStyleGroup, SWT.RADIO); iconWarningButton.setText("SWT.ICON_WARNING"); iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO); iconWorkingButton.setText("SWT.ICON_WORKING"); noIconButton = new Button(iconStyleGroup, SWT.RADIO); noIconButton.setText(ControlExample.getResourceString("No_Icon")); /* Create a group for the modal style controls */ Group modalStyleGroup = new Group(controlGroup, SWT.NONE); modalStyleGroup.setLayout(new GridLayout()); modalStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles")); /* Create the modal style buttons */ primaryModalButton = new Button(modalStyleGroup, SWT.RADIO); primaryModalButton.setText("SWT.PRIMARY_MODAL"); applicationModalButton = new Button(modalStyleGroup, SWT.RADIO); applicationModalButton.setText("SWT.APPLICATION_MODAL"); systemModalButton = new Button(modalStyleGroup, SWT.RADIO); systemModalButton.setText("SWT.SYSTEM_MODAL"); /* Create a group for the file dialog style controls */ Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE); fileDialogStyleGroup.setLayout(new GridLayout()); fileDialogStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles")); /* Create the file dialog style buttons */ openButton = new Button(fileDialogStyleGroup, SWT.RADIO); openButton.setText("SWT.OPEN"); saveButton = new Button(fileDialogStyleGroup, SWT.RADIO); saveButton.setText("SWT.SAVE"); multiButton = new Button(fileDialogStyleGroup, SWT.CHECK); multiButton.setText("SWT.MULTI"); /* Create the orientation group */ if (RTL_SUPPORT_ENABLE) { createOrientationGroup(); } /* Add the listeners */ dialogCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { dialogSelected(event); } }); createButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { createButtonSelected(event); } }); SelectionListener buttonStyleListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonStyleSelected(event); } }; okButton.addSelectionListener(buttonStyleListener); cancelButton.addSelectionListener(buttonStyleListener); yesButton.addSelectionListener(buttonStyleListener); noButton.addSelectionListener(buttonStyleListener); retryButton.addSelectionListener(buttonStyleListener); abortButton.addSelectionListener(buttonStyleListener); ignoreButton.addSelectionListener(buttonStyleListener); /* Set default values for style buttons */ okButton.setEnabled(false); cancelButton.setEnabled(false); yesButton.setEnabled(false); noButton.setEnabled(false); retryButton.setEnabled(false); abortButton.setEnabled(false); ignoreButton.setEnabled(false); iconErrorButton.setEnabled(false); iconInformationButton.setEnabled(false); iconQuestionButton.setEnabled(false); iconWarningButton.setEnabled(false); iconWorkingButton.setEnabled(false); noIconButton.setEnabled(false); saveButton.setEnabled(false); openButton.setEnabled(false); openButton.setSelection(true); multiButton.setEnabled(false); noIconButton.setSelection(true); }
private void createMultiUserGroup(Composite parent) { final Group multiUserGroup = NSISWizardDialogUtil.createGroup( parent, 2, "MultiUser Installation", null, false); // $NON-NLS-1$ GridData data = (GridData) multiUserGroup.getLayoutData(); data.verticalAlignment = SWT.FILL; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; NSISWizardSettings settings = mWizard.getSettings(); Composite composite = new Composite(multiUserGroup, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(data); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); final Button multiUser = NSISWizardDialogUtil.createCheckBox( composite, EclipseNSISPlugin.getResourceString("enable.multiuser.label"), // $NON-NLS-1$ settings.isMultiUserInstallation(), settings.getInstallerType() == INSTALLER_TYPE_MUI2, null, false); multiUser.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean selection = multiUser.getSelection(); mWizard.getSettings().setMultiUserInstallation(selection); validateField(MULTIUSER_CHECK); } }); final MasterSlaveController m = new MasterSlaveController(multiUser); boolean enabled = multiUser.isEnabled() && multiUser.getSelection(); final Combo execLevel = NSISWizardDialogUtil.createCombo( composite, NSISWizardDisplayValues.MULTIUSER_EXEC_LEVELS, settings.getMultiUserExecLevel(), true, EclipseNSISPlugin.getResourceString("multiuser.exec.level.label"), // $NON-NLS-1$ enabled, m, false); ((GridData) execLevel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) execLevel.getLayoutData()).grabExcessHorizontalSpace = true; final Group instModeGroup = NSISWizardDialogUtil.createGroup( multiUserGroup, 1, "Installation Mode", m, false); // $NON-NLS-1$ data = (GridData) instModeGroup.getLayoutData(); data.verticalAlignment = SWT.FILL; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; data.horizontalSpan = 1; MasterSlaveEnabler mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) {} public boolean canEnable(Control c) { return isMultiUser(); } }; m.addSlave(execLevel, mse); enabled = enabled && execLevel.getSelectionIndex() != MULTIUSER_EXEC_LEVEL_STANDARD; mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) {} public boolean canEnable(Control c) { return isMultiUser() && mWizard.getSettings().getMultiUserExecLevel() != MULTIUSER_EXEC_LEVEL_STANDARD; } }; execLevel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setMultiUserExecLevel(execLevel.getSelectionIndex()); m.updateSlaves(); validateField(MULTIUSER_CHECK); } }); final Combo instMode = NSISWizardDialogUtil.createCombo( instModeGroup, NSISWizardDisplayValues.MULTIUSER_INSTALL_MODES, settings.getMultiUserInstallMode(), true, EclipseNSISPlugin.getResourceString("multiuser.install.mode.label"), enabled, m, false); //$NON-NLS-1$ ((GridData) instMode.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) instMode.getLayoutData()).horizontalAlignment = SWT.FILL; instMode.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setMultiUserInstallMode(instMode.getSelectionIndex()); validateField(MULTIUSER_CHECK); } }); m.addSlave(instMode, mse); composite = new Composite(instModeGroup, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(data); layout = new GridLayout(2, true); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); final Button instModeRemember = NSISWizardDialogUtil.createCheckBox( composite, EclipseNSISPlugin.getResourceString("multiuser.install.mode.remember.label"), settings.isMultiUserInstallModeRemember(), // $NON-NLS-1$ enabled, m, false); ((GridData) instModeRemember.getLayoutData()).horizontalSpan = 1; instModeRemember.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setMultiUserInstallModeRemember(instModeRemember.getSelection()); validateField(MULTIUSER_CHECK); } }); m.addSlave(instModeRemember, mse); final Button instModeAsk = NSISWizardDialogUtil.createCheckBox( composite, EclipseNSISPlugin.getResourceString("multiuser.install.mode.ask.label"), settings.isMultiUserInstallModeAsk(), // $NON-NLS-1$ enabled, m, false); ((GridData) instModeAsk.getLayoutData()).horizontalSpan = 1; instModeAsk.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setMultiUserInstallModeAsk(instModeAsk.getSelection()); validateField(MULTIUSER_CHECK); } }); m.addSlave(instModeAsk, mse); m.updateSlaves(); addPageChangedRunnable( new Runnable() { public void run() { if (isCurrentPage()) { NSISWizardDialogUtil.setEnabled( multiUser, mWizard.getSettings().getInstallerType() == INSTALLER_TYPE_MUI2); m.updateSlaves(); } } }); mWizard.addSettingsListener( new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { NSISWizardSettings settings = mWizard.getSettings(); multiUser.setSelection(settings.isMultiUserInstallation()); execLevel.select(settings.getMultiUserExecLevel()); instMode.select(settings.getMultiUserInstallMode()); instModeRemember.setSelection(settings.isMultiUserInstallModeRemember()); instModeAsk.setSelection(settings.isMultiUserInstallModeAsk()); NSISWizardDialogUtil.setEnabled( multiUser, settings.getInstallerType() == INSTALLER_TYPE_MUI2); m.updateSlaves(); } }); }
protected void updateJREWidgets() { fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); }
/** @param composite */ private void createInstallationDirectoryGroup(Composite parent) { Group instDirGroup = NSISWizardDialogUtil.createGroup( parent, 2, "installation.directory.group.label", null, false); // $NON-NLS-1$ NSISWizardSettings settings = mWizard.getSettings(); ((GridData) NSISWizardDialogUtil.createLabel( instDirGroup, "installation.directory.label", true, null, isScriptWizard()) .getLayoutData()) .horizontalSpan = 1; //$NON-NLS-1$ final Composite instDirComposite = new Composite(instDirGroup, SWT.NONE); instDirComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final StackLayout instDirLayout = new StackLayout(); instDirComposite.setLayout(instDirLayout); final Combo instDirCombo = NSISWizardDialogUtil.createCombo( instDirComposite, 1, NSISWizardUtil.getPathConstantsAndVariables(settings.getTargetPlatform()), settings.getInstallDir(), false, true, null); final Text instDirText = NSISWizardDialogUtil.createText(instDirComposite, settings.getInstallDir(), 1, true, null); instDirLayout.topControl = instDirCombo; Runnable r = new Runnable() { private String mInstDirParent = ""; // $NON-NLS-1$ private void updateInstDir(NSISWizardSettings settings) { Control topControl; if (isMultiUser()) { if (settings.getInstallDir().startsWith(mInstDirParent)) { String instDir = settings.getInstallDir().substring(mInstDirParent.length()); settings.setInstallDir(instDir); instDirText.setText(instDir); } topControl = instDirText; } else { if (!settings.getInstallDir().startsWith(mInstDirParent)) { String instDir = mInstDirParent + settings.getInstallDir(); settings.setInstallDir(instDir); instDirCombo.setText(instDir); } topControl = instDirCombo; } if (instDirLayout.topControl != topControl) { instDirLayout.topControl = topControl; instDirComposite.layout(true); } validateField(INSTDIR_CHECK); } public void run() { final PropertyChangeListener propertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (NSISWizardSettings.INSTALLER_TYPE.equals(evt.getPropertyName()) || NSISWizardSettings.MULTIUSER_INSTALLATION.equals( evt.getPropertyName())) { updateInstDir(mWizard.getSettings()); } else if (NSISWizardSettings.INSTALL_DIR.equals(evt.getPropertyName())) { if (!isMultiUser()) { setInstDirParent(mWizard.getSettings()); } } } }; final INSISWizardSettingsListener settingsListener = new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, final NSISWizardSettings newSettings) { if (oldSettings != null) { oldSettings.removePropertyChangeListener(propertyListener); } setInstDirParent(newSettings); if (newSettings != null) { newSettings.addPropertyChangeListener(propertyListener); } updateInstDir(newSettings); } }; mWizard.addSettingsListener(settingsListener); mWizard.getSettings().addPropertyChangeListener(propertyListener); instDirCombo.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { mWizard.getSettings().removePropertyChangeListener(propertyListener); mWizard.removeSettingsListener(settingsListener); } }); setInstDirParent(mWizard.getSettings()); updateInstDir(mWizard.getSettings()); } private void setInstDirParent(NSISWizardSettings settings) { mInstDirParent = ""; // $NON-NLS-1$ if (settings != null) { String instDir = settings.getInstallDir(); if (!Common.isEmpty(instDir)) { int n = instDir.lastIndexOf('\\'); if (n > 0 && n < instDir.length() - 1) { mInstDirParent = instDir.substring(0, n + 1); } } } } }; r.run(); GridData gd = (GridData) instDirCombo.getLayoutData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; instDirCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = ((Combo) e.widget).getText(); mWizard.getSettings().setInstallDir(text); validateField(INSTDIR_CHECK); } }); instDirText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = ((Text) e.widget).getText(); mWizard.getSettings().setInstallDir(text); validateField(INSTDIR_CHECK); } }); final Button changeInstDir = NSISWizardDialogUtil.createCheckBox( instDirGroup, "change.installation.directory.label", //$NON-NLS-1$ settings.isChangeInstallDir(), (settings.getInstallerType() != INSTALLER_TYPE_SILENT), null, false); changeInstDir.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setChangeInstallDir(((Button) e.widget).getSelection()); } }); addPageChangedRunnable( new Runnable() { public void run() { if (isCurrentPage()) { NSISWizardSettings settings = mWizard.getSettings(); instDirCombo.setText(settings.getInstallDir()); changeInstDir.setEnabled(settings.getInstallerType() != INSTALLER_TYPE_SILENT); } } }); final PropertyChangeListener propertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (NSISWizardSettings.TARGET_PLATFORM.equals(evt.getPropertyName())) { NSISWizardDialogUtil.populateCombo( instDirCombo, NSISWizardUtil.getPathConstantsAndVariables( ((Integer) evt.getNewValue()).intValue()), ((NSISWizardSettings) evt.getSource()).getInstallDir()); } } }; settings.addPropertyChangeListener(propertyListener); final INSISWizardSettingsListener listener = new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { if (oldSettings != null) { oldSettings.removePropertyChangeListener(propertyListener); } instDirCombo.setText(newSettings.getInstallDir()); changeInstDir.setSelection(newSettings.isChangeInstallDir()); changeInstDir.setEnabled(newSettings.getInstallerType() != INSTALLER_TYPE_SILENT); newSettings.addPropertyChangeListener(propertyListener); } }; mWizard.addSettingsListener(listener); instDirGroup.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { mWizard.removeSettingsListener(listener); mWizard.getSettings().removePropertyChangeListener(propertyListener); } }); }
/** * Constructor to create an editor to update/create an ontology entry * * @param display - points back to the display * @param oureditOntEntry - the entry being edited * @param ontParent - the edited item's parent in the hierarchy * @param newItem - true if this is a new item */ public EditOntEntry( Display display, OntEntry oureditOntEntry, OntEntry ontParent, boolean newItem) { super(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL); shell.setText("OntEntry Information"); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = 5; gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); ourOntEntry = oureditOntEntry; ourParent = ontParent; if (newItem) { ourOntEntry.setName(""); ourOntEntry.setImportance(Importance.MODERATE); } new Label(shell, SWT.NONE).setText("Name:"); nameField = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL); nameField.setText(ourOntEntry.getName()); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); DisplayUtilities.setTextDimensions(nameField, gridData, 75); gridData.horizontalSpan = 2; nameField.setLayoutData(gridData); new Label(shell, SWT.NONE).setText("Description:"); descArea = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); descArea.setText(ourOntEntry.getDescription()); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); DisplayUtilities.setTextDimensions(descArea, gridData, 75, 5); gridData.horizontalSpan = 2; gridData.heightHint = descArea.getLineHeight() * 3; descArea.setLayoutData(gridData); new Label(shell, SWT.NONE).setText("Importance:"); importanceBox = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); Enumeration impEnum = Importance.elements(); int l = 0; Importance itype; while (impEnum.hasMoreElements()) { itype = (Importance) impEnum.nextElement(); importanceBox.add(itype.toString()); if (itype.toString().compareTo(ourOntEntry.getImportance().toString()) == 0) { importanceBox.select(l); } l++; } // Error checking: if no such selection is valid, set it to select index 0 if (importanceBox.getSelectionIndex() == -1) { importanceBox.select(0); } importanceBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(shell, SWT.NONE).setText(" "); new Label(shell, SWT.NONE).setText(" "); addButton = new Button(shell, SWT.PUSH); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); addButton.setLayoutData(gridData); if (newItem) { addButton.setText("Add"); addButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = false; if (!nameField.getText().trim().equals("")) { ConsistencyChecker checker = new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries"); if (ourOntEntry.getName() == nameField.getText() || checker.check()) { ourParent.addChild(ourOntEntry); ourOntEntry.setLevel(ourParent.getLevel() + 1); ourOntEntry.setName(nameField.getText()); ourOntEntry.setDescription(descArea.getText()); ourOntEntry.setImportance( Importance.fromString( importanceBox.getItem(importanceBox.getSelectionIndex()))); // comment before this made no sense... ourOntEntry.setID(ourOntEntry.toDatabase(ourParent.getID())); System.out.println("Name of added item = " + ourOntEntry.getName()); shell.close(); shell.dispose(); } } else { MessageBox mbox = new MessageBox(shell, SWT.ICON_ERROR); mbox.setMessage("Need to provide the OntEntry name"); mbox.open(); } } }); } else { addButton.setText("Save"); addButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = false; ConsistencyChecker checker = new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries"); if (ourOntEntry.getName() == nameField.getText() || checker.check()) { ourOntEntry.setName(nameField.getText()); ourOntEntry.setDescription(descArea.getText()); ourOntEntry.setImportance( Importance.fromString( importanceBox.getItem(importanceBox.getSelectionIndex()))); // since this is a save, not an add, the type and parent are ignored ourOntEntry.setID(ourOntEntry.toDatabase(0)); // RationaleDB db = RationaleDB.getHandle(); // db.addOntEntry(ourOntEntry); shell.close(); shell.dispose(); } } }); } cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); cancelButton.setLayoutData(gridData); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = true; shell.close(); shell.dispose(); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }