/* (non-Javadoc) * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) */ public void setEnabled(boolean enabled) { fTree.getControl().setEnabled(enabled); if (enabled) { updateButtons(); } else { fSelectButton.setEnabled(false); fSelectAllButton.setEnabled(false); fDeselectButton.setEnabled(false); fDeselectAllButton.setEnabled(false); fSelectRequiredButton.setEnabled(false); fCountLabel.setText(""); // $NON-NLS-1$ } fModeLabel.setEnabled(enabled); fPluginModeButton.setEnabled(enabled); fFeaureModeButton.setEnabled(enabled); fShowLabel.setEnabled(enabled); fShowPluginsButton.setEnabled(enabled); fShowSourceButton.setEnabled(enabled); boolean isPluginMode = !fFeaureModeButton.getSelection(); fGroupLabel.setEnabled(enabled && isPluginMode); if (fGroupCombo != null) { fGroupCombo.setEnabled(enabled && isPluginMode); } else { fGroupComboPart.setEnabled(enabled && isPluginMode); } }
private Composite createAvailableList(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; container.setLayout(layout); container.setLayoutData(new GridData()); Label label = new Label(container, SWT.NONE); label.setText(PDEUIMessages.ImportWizard_DetailedPage_availableList); Table table = new Table(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 200; gd.widthHint = 225; table.setLayoutData(gd); fAvailableListViewer = new TableViewer(table); fAvailableListViewer.setLabelProvider(new PluginImportLabelProvider()); fAvailableListViewer.setContentProvider(new ContentProvider()); fAvailableListViewer.setInput(PDECore.getDefault().getModelManager()); fAvailableListViewer.setComparator(ListUtil.PLUGIN_COMPARATOR); return container; }
private void createImpLabel(Composite container) { Label label = new Label(container, SWT.NONE); label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc); label.setFont(container.getFont()); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; label.setLayoutData(gd); }
protected void createSpacer(Composite parent) { Label spacer = new Label(parent, SWT.NONE); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.heightHint = 4; spacer.setLayoutData(data); }
private void createLabels(Composite pageContent) { Label label = new Label(pageContent, SWT.LEFT); label.setText(Messages._UI_LABEL_SOURCE_FILES); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); label = new Label(pageContent, SWT.LEFT); label.setText(Messages._UI_LABEL_SELECTED_FILES); }
private void updateCount() { if (fCountTotal <= 0) { // Since we filter the list of available plug-ins the total may differ from the model count fCountTotal = fAvailableListViewer.getTable().getItemCount(); } fCountLabel.setText( NLS.bind( PDEUIMessages.ImportWizard_DetailedPage_count, (new String[] { Integer.toString(fImportListViewer.getTable().getItemCount()), Integer.toString(fCountTotal) }))); fCountLabel.getParent().layout(); }
private Composite createScrollArea(Composite parent) { Group container = new Group(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 6; container.setLayout(layout); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; container.setLayoutData(gd); container.setText(PDEUIMessages.ImportWizard_DetailedPage_filter); Label filterLabel = new Label(container, SWT.NONE); filterLabel.setText(PDEUIMessages.ImportWizard_DetailedPage_search); fFilterText = new Text(container, SWT.BORDER); fFilterText.setText(""); // $NON-NLS-1$ gd = new GridData(GridData.FILL_HORIZONTAL); fFilterText.setLayoutData(gd); return container; }
/** * Creates the contents of this group, using the given toolkit where appropriate so that the * controls have the form editor look and feel. * * @param parent parent composite * @param toolkit toolkit to create controls with */ protected void createFormContents(Composite parent, FormToolkit toolkit) { fGrouping = GROUP_BY_NONE; Composite comp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; comp.setLayout(layout); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); comp.setFont(parent.getFont()); createTree(comp, toolkit); createButtons(comp, toolkit); fCountLabel = toolkit.createLabel(comp, ""); // $NON-NLS-1$ GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; fCountLabel.setLayoutData(data); updateButtons(); initializeFilters(); }
/** * Set the container to display in the tree or <code>null</code> to disable the tree * * @param input bundle container or <code>null</code> */ public void setInput(ITargetDefinition input) { fTargetDefinition = input; // Update the cached data fFileBundleMapping = null; fAllBundles.clear(); if (input == null || !input.isResolved()) { fTree.setInput(Messages.TargetContentsGroup_10); setEnabled(false); return; } IResolvedBundle[] allResolvedBundles = input.getAllBundles(); if (allResolvedBundles == null || allResolvedBundles.length == 0) { fTree.setInput(Messages.TargetContentsGroup_11); setEnabled(false); return; } for (int i = 0; i < allResolvedBundles.length; i++) { fAllBundles.add(allResolvedBundles[i]); } boolean isFeatureMode = ((TargetDefinition) fTargetDefinition).getUIMode() == TargetDefinition.MODE_FEATURE; fFeaureModeButton.setSelection(isFeatureMode); fPluginModeButton.setSelection(!isFeatureMode); fGroupLabel.setEnabled(!isFeatureMode); fTree.getControl().setRedraw(false); fTree.setInput(fTargetDefinition); fTree.expandAll(); updateCheckState(); updateButtons(); setEnabled(true); fTree.getControl().setRedraw(true); }
private Composite createButtonArea(Composite parent) { ScrolledComposite comp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; comp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); Composite container = new Composite(comp, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; container.setLayout(layout); GridData gd = new GridData(GridData.FILL_VERTICAL); gd.verticalIndent = 15; container.setLayoutData(gd); Button button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_existing); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleExistingProjects(); } }); SWTUtil.setButtonDimensionHint(button); button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_existingUnshared); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleExistingUnshared(); } }); SWTUtil.setButtonDimensionHint(button); fAddButton = new Button(container, SWT.PUSH); fAddButton.setText(PDEUIMessages.ImportWizard_DetailedPage_add); fAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAdd(); } }); SWTUtil.setButtonDimensionHint(fAddButton); fAddAllButton = new Button(container, SWT.PUSH); fAddAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addAll); fAddAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddAllButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAddAll(); } }); SWTUtil.setButtonDimensionHint(fAddAllButton); fRemoveButton = new Button(container, SWT.PUSH); fRemoveButton.setText(PDEUIMessages.ImportWizard_DetailedPage_remove); fRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fRemoveButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemove(); } }); SWTUtil.setButtonDimensionHint(fRemoveButton); fRemoveAllButton = new Button(container, SWT.PUSH); fRemoveAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_removeAll); fRemoveAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fRemoveAllButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemoveAll(); } }); SWTUtil.setButtonDimensionHint(fRemoveAllButton); button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_swap); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleSwap(); } }); SWTUtil.setButtonDimensionHint(button); fAddRequiredButton = new Button(container, SWT.PUSH); fAddRequiredButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addRequired); fAddRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddRequiredButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAddRequiredPlugins(); } }); SWTUtil.setButtonDimensionHint(fAddRequiredButton); fCountLabel = new Label(container, SWT.NONE); fCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); comp.setContent(container); comp.setMinHeight(250); comp.setExpandHorizontal(true); comp.setExpandVertical(true); return container; }
@Override public void createControl(final Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText("&Container:"); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); containerText.setLayoutData(gd); containerText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); Button button = new Button(container, SWT.PUSH); button.setText("Browse..."); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { handleBrowse(); } }); label = new Label(container, SWT.NULL); label.setText("&Choose a model:"); Composite middleComposite = new Composite(container, SWT.NULL); FillLayout fillLayout = new FillLayout(); middleComposite.setLayout(fillLayout); emptyModelButton = new Button(middleComposite, SWT.RADIO); emptyModelButton.setText("Empty"); emptyModelButton.setSelection(true); skeletonModelButton = new Button(middleComposite, SWT.RADIO); skeletonModelButton.setText("Skeleton"); exampleModelButton = new Button(middleComposite, SWT.RADIO); exampleModelButton.setText("Example"); emptyModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "empty"; radioChanged(); } }); exampleModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "example"; radioChanged(); } }); skeletonModelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { typeOfModel = "skeleton"; radioChanged(); } }); /* Need to add empty label so the next controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&File name:"); fileText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); fileText.setLayoutData(gd); fileText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { Text t = (Text) e.getSource(); String fname = t.getText(); int i = fname.lastIndexOf(".gaml"); if (i > 0) { // model title = filename less extension less all non alphanumeric characters titleText.setText(fname.substring(0, i).replaceAll("[^\\p{Alnum}]", "")); } /* * else if (fname.length()>0) { * int pos = t.getSelection().x; * fname = fname.replaceAll("[[^\\p{Alnum}]&&[^_-]&&[^\\x2E]]", "_"); * t.setText(fname+".gaml"); * t.setSelection(pos); * } else { * t.setText("new.gaml"); * } */ dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Author:"); authorText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); authorText.setLayoutData(gd); authorText.setText(getComputerFullName()); authorText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Model name:"); titleText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); titleText.setLayoutData(gd); titleText.setText("new"); titleText.addModifyListener( new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { dialogChanged(); } }); /* Need to add empty label so the next two controls are pushed to the next line in the grid. */ label = new Label(container, SWT.NULL); label.setText(""); label = new Label(container, SWT.NULL); label.setText("&Model description:"); descriptionText = new Text(container, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); descriptionText.setBounds(0, 0, 250, 100); gd = new GridData(SWT.FILL, SWT.FILL, true, false); gd.verticalSpan = 4; descriptionText.setLayoutData(gd); /* * Need to add seven empty labels in order to push next controls after the descriptionText * box. */ // TODO Dirty!! Change the way to do this for (int i = 0; i < 7; i++) { label = new Label(container, SWT.NULL); label.setText(""); } label = new Label(container, SWT.NULL); label.setText("&Create a html template \nfor the model description ?"); middleComposite = new Composite(container, SWT.NULL); fillLayout = new FillLayout(); middleComposite.setLayout(fillLayout); yesButton = new Button(middleComposite, SWT.RADIO); yesButton.setText("Yes"); yesButton.setSelection(true); Button noButton = new Button(middleComposite, SWT.RADIO); noButton.setText("No"); yesButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { dialogChanged(); } }); /* Finished adding the custom control */ initialize(); dialogChanged(); setControl(container); }
/* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(composite); Label label = new Label(composite, SWT.WRAP); label.setText(PDEUIMessages.PluginWorkingSet_setName); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER); fWorkingSetName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fWorkingSetName.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validatePage(); } }); fWorkingSetName.setFocus(); label = new Label(composite, SWT.WRAP); label.setText(PDEUIMessages.PluginWorkingSet_setContent); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fTree = new CheckboxFilteredTree(composite, SWT.BORDER, new PatternFilter()); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 250; fTree.getViewer().getControl().setLayoutData(gd); final IStructuredContentProvider fTableContentProvider = new ContentProvider(); fTree.getCheckboxTreeViewer().setContentProvider(fTableContentProvider); fTree.getCheckboxTreeViewer().setLabelProvider(new WorkingSetLabelProvider()); fTree.getCheckboxTreeViewer().setUseHashlookup(true); fTree.getCheckboxTreeViewer().setInput(PDECore.getDefault()); fTree .getCheckboxTreeViewer() .addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { validatePage(); } }); // Add select / deselect all buttons for bug 46669 Composite buttonComposite = new Composite(composite, SWT.NONE); buttonComposite.setLayout(new GridLayout(2, true)); buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); Button selectAllButton = new Button(buttonComposite, SWT.PUSH); selectAllButton.setText(PDEUIMessages.PluginWorkingSet_selectAll_label); selectAllButton.setToolTipText(PDEUIMessages.PluginWorkingSet_selectAll_toolTip); selectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree .getCheckboxTreeViewer() .setCheckedElements( fTableContentProvider.getElements(fTree.getCheckboxTreeViewer().getInput())); validatePage(); } }); selectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(selectAllButton); Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); deselectAllButton.setText(PDEUIMessages.PluginWorkingSet_deselectAll_label); deselectAllButton.setToolTipText(PDEUIMessages.PluginWorkingSet_deselectAll_toolTip); deselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree.getCheckboxTreeViewer().setCheckedElements(new Object[0]); validatePage(); } }); deselectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(deselectAllButton); setPageComplete(false); setMessage(PDEUIMessages.PluginWorkingSet_message); initialize(); Dialog.applyDialogFont(composite); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(composite, IHelpContextIds.PLUGIN_WORKING_SET); }
/** @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; parent.setLayout(layout); // layout the top table & its buttons Label label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_topTableLabel); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fIdMapsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fIdMapsTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fIdMapsTable.getItemHeight() * 4; fIdMapsTable.setLayoutData(data); fIdMapsTable.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectionChanged(); } }); String column2Text = XMLCompareMessages.XMLComparePreference_topTableColumn2; String column3Text = XMLCompareMessages.XMLComparePreference_topTableColumn3; ColumnLayoutData columnLayouts[] = { new ColumnWeightData(1), new ColumnPixelData(convertWidthInCharsToPixels(column2Text.length() + 2), true), new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 5), true) }; TableLayout tablelayout = new TableLayout(); fIdMapsTable.setLayout(tablelayout); for (int i = 0; i < 3; i++) tablelayout.addColumnData(columnLayouts[i]); TableColumn column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_topTableColumn1); column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(column2Text); column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(column3Text); fillIdMapsTable(); Composite buttons = new Composite(parent, SWT.NULL); buttons.setLayout(new GridLayout()); data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; buttons.setLayoutData(data); fAddIdMapButton = new Button(buttons, SWT.PUSH); fAddIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topAdd); fAddIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addIdMap(fAddIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fAddIdMapButton.setLayoutData(data); fRenameIdMapButton = new Button(buttons, SWT.PUSH); fRenameIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRename); fRenameIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { renameIdMap(fRenameIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fRenameIdMapButton.setLayoutData(data); fRemoveIdMapButton = new Button(buttons, SWT.PUSH); fRemoveIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRemove); fRemoveIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeIdMap(fRemoveIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fRemoveIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fRemoveIdMapButton.setLayoutData(data); createSpacer(buttons); fEditIdMapButton = new Button(buttons, SWT.PUSH); fEditIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topEdit); fEditIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editIdMap(fEditIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fEditIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fEditIdMapButton.setLayoutData(data); // Spacer label = new Label(parent, SWT.LEFT); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); // layout the middle table & its buttons label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_middleTableLabel); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fMappingsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fMappingsTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fMappingsTable.getItemHeight() * 4; data.widthHint = convertWidthInCharsToPixels(70); fMappingsTable.setLayoutData(data); column3Text = XMLCompareMessages.XMLComparePreference_middleTableColumn3; String column4Text = XMLCompareMessages.XMLComparePreference_middleTableColumn4; columnLayouts = new ColumnLayoutData[] { new ColumnWeightData(10), new ColumnWeightData(18), new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 1), true), new ColumnPixelData(convertWidthInCharsToPixels(column4Text.length() + 3), true) }; tablelayout = new TableLayout(); fMappingsTable.setLayout(tablelayout); for (int i = 0; i < 4; i++) tablelayout.addColumnData(columnLayouts[i]); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn1); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn2); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(column3Text); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(column4Text); buttons = new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); fNewMappingsButton = new Button(buttons, SWT.PUSH); fNewMappingsButton.setLayoutData(getButtonGridData(fNewMappingsButton)); fNewMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleNew); fNewMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addMapping(fAddIdMapButton.getShell()); } }); fEditMappingsButton = new Button(buttons, SWT.PUSH); fEditMappingsButton.setLayoutData(getButtonGridData(fEditMappingsButton)); fEditMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleEdit); fEditMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editMapping(fEditMappingsButton.getShell()); } }); fRemoveMappingsButton = new Button(buttons, SWT.PUSH); fRemoveMappingsButton.setLayoutData(getButtonGridData(fRemoveMappingsButton)); fRemoveMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleRemove); fRemoveMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeMapping(fRemoveMappingsButton.getShell()); } }); createSpacer(buttons); // layout the botton table & its buttons label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_bottomTableLabel); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fOrderedTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fOrderedTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fOrderedTable.getItemHeight() * 2; data.widthHint = convertWidthInCharsToPixels(70); fOrderedTable.setLayoutData(data); columnLayouts = new ColumnLayoutData[] {new ColumnWeightData(1), new ColumnWeightData(1)}; tablelayout = new TableLayout(); fOrderedTable.setLayout(tablelayout); for (int i = 0; i < 2; i++) tablelayout.addColumnData(columnLayouts[i]); column = new TableColumn(fOrderedTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn1); column = new TableColumn(fOrderedTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn2); buttons = new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); fNewOrderedButton = new Button(buttons, SWT.PUSH); fNewOrderedButton.setLayoutData(getButtonGridData(fNewOrderedButton)); fNewOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomNew); fNewOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addOrdered(fNewOrderedButton.getShell()); } }); fEditOrderedButton = new Button(buttons, SWT.PUSH); fEditOrderedButton.setLayoutData(getButtonGridData(fEditOrderedButton)); fEditOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomEdit); fEditOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editOrdered(fEditOrderedButton.getShell()); } }); fRemoveOrderedButton = new Button(buttons, SWT.PUSH); fRemoveOrderedButton.setLayoutData(getButtonGridData(fRemoveOrderedButton)); fRemoveOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomRemove); fRemoveOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeOrdered(fRemoveOrderedButton.getShell()); } }); createSpacer(buttons); fIdMapsTable.setSelection(0); fIdMapsTable.setFocus(); selectionChanged(); return parent; }
private void updateButtons() { if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) { Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray(); boolean hasResolveBundle = false; boolean hasParent = false; boolean allSelected = true; boolean noneSelected = true; for (int i = 0; i < selection.length; i++) { if (!hasResolveBundle || !hasParent) { if (selection[i] instanceof IResolvedBundle) { hasResolveBundle = true; } else { hasParent = true; } } boolean checked = fTree.getChecked(selection[i]); if (checked) { noneSelected = false; } else { allSelected = false; } } // Selection is available if not everything is already selected and not both a parent and // child item are selected fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent)); fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent)); } else { fSelectButton.setEnabled(false); fDeselectButton.setEnabled(false); } int total = fAllBundles.size(); if (fFeaureModeButton.getSelection()) { if (fTargetDefinition == null) { total = 0; } else { total = fTargetDefinition.getAllFeatures().length; total += ((TargetDefinition) fTargetDefinition).getOtherBundles().length; } } if (fMissing != null) { total += fMissing.size(); } fSelectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != total); fDeselectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != 0); fSelectRequiredButton.setEnabled( fTargetDefinition != null && fTree.getCheckedLeafCount() > 0 && fTree.getCheckedLeafCount() != total); if (fTargetDefinition != null) { fCountLabel.setText( MessageFormat.format( Messages.TargetContentsGroup_9, new String[] { Integer.toString(fTree.getCheckedLeafCount()), Integer.toString(total) })); } else { fCountLabel.setText(""); // $NON-NLS-1$ } }
/** * Creates the buttons in this group inside a new composite * * @param parent parent composite * @param toolkit toolkit to give form style or <code>null</code> for dialog style */ private void createButtons(Composite parent, FormToolkit toolkit) { if (toolkit != null) { Composite buttonComp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; buttonComp.setLayout(layout); buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH); fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH); fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH); fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH); fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH); fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite filterComp = toolkit.createComposite(buttonComp); layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; filterComp.setLayout(layout); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing); fPluginModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO); fPluginModeButton.setSelection(true); fFeaureModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO); fFeaureModeButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9); fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK); fShowPluginsButton.setSelection(true); fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK); fShowSourceButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0); fGroupComboPart = new ComboPart(); fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupComboPart.getControl().setLayoutData(gd); fGroupComboPart.setItems( new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); fGroupComboPart.setVisibleItemCount(30); fGroupComboPart.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupComboPart.select(0); } else { Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null); Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1); fPluginModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode); fFeaureModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1); fGroupCombo = SWTFactory.createCombo( filterComp, SWT.READ_ONLY, 1, new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupCombo.setLayoutData(gd); fGroupCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupCombo.select(0); } fSelectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fDeselectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], false); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fSelectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(true); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fDeselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(false); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fSelectRequiredButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Object[] allChecked = fTree.getCheckedLeafElements(); Object[] required = null; if (fFeaureModeButton.getSelection()) { required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked); } else { required = getRequiredPlugins(fAllBundles, allChecked); } for (int i = 0; i < required.length; i++) { fTree.setChecked(required[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fPluginModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from feature based filtering to plug-in based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(true); if (fGroupCombo != null) { fGroupCombo.setEnabled(true); } else { fGroupComboPart.getControl().setEnabled(true); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fPluginModeButton.setSelection(true); GridData gd = new GridData(); gd.horizontalIndent = 10; fPluginModeButton.setLayoutData(gd); fFeaureModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from plug-in based filtering to feature based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(false); if (fGroupCombo != null) { fGroupCombo.setEnabled(false); } else { fGroupComboPart.getControl().setEnabled(false); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fFeaureModeButton.setSelection(false); gd = new GridData(); gd.horizontalIndent = 10; fFeaureModeButton.setLayoutData(gd); fShowPluginsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowPluginsButton.getSelection()) { fTree.addFilter(fPluginFilter); } else { fTree.removeFilter(fPluginFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowPluginsButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowPluginsButton.setLayoutData(gd); fShowSourceButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowSourceButton.getSelection()) { fTree.addFilter(fSourceFilter); } else { fTree.removeFilter(fSourceFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowSourceButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowSourceButton.setLayoutData(gd); }