/** Set up the tree columns */ private void setColumns() { Table table = getTable(); table.setHeaderVisible(true); // table.setLinesVisible(true); // Use layout from parent container TableColumnLayout layout = (TableColumnLayout) getControl().getParent().getLayout(); TableColumn[] columns = new TableColumn[columnNames.length]; for (int i = 0; i < columnNames.length; i++) { columns[i] = new TableColumn(table, SWT.NONE); columns[i].setText(columnNames[i]); // Needed for sorting columns[i].setData("index", new Integer(i)); // $NON-NLS-1$ columns[i].addListener(SWT.Selection, sortListener); } layout.setColumnData(columns[0], new ColumnWeightData(5, true)); layout.setColumnData(columns[1], new ColumnWeightData(95, true)); setSorter(new Sorter()); // Column names are properties setColumnProperties(columnNames); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite composite = getWidgetFactory().createFlatFormComposite(parent); TableColumnLayout tableColumnLayout = new TableColumnLayout(); composite.setLayout(tableColumnLayout); FormData data; table = getWidgetFactory().createTable(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); table.setHeaderVisible(true); table.setLinesVisible(true); columns = new ArrayList(); String[] titles = UserGroupPropertySource.getPropertiesDisplayValuesTable(); int[] weights = {30, 30, 30}; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setText(titles[i]); tableColumnLayout.setColumnData(column, new ColumnWeightData(weights[i])); columns.add(column); } data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); table.setLayoutData(data); }
@Override protected Control createDialogArea(Composite parent) { Composite area = new Composite(parent, SWT.NONE); area.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); area.setLayout(new GridLayout(1, false)); Composite dateComposite = new Composite(area, SWT.NONE); dateComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); dateComposite.setLayout(new GridLayout(1, false)); dtDate = new DateTime(area, SWT.DATE | SWT.DROP_DOWN); dtDate.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadArticlesUsedOnSelectedDay(); tableViewer.setInput(currOrder.getEntries()); } }); Composite tableComposite = new Composite(area, SWT.NONE); tableComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); TableColumnLayout tcLayout = new TableColumnLayout(); tableComposite.setLayout(tcLayout); tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION); Table table = tableViewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); table.setHeaderVisible(true); table.setLinesVisible(true); TableViewerColumn tvc = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn tcAmount = tvc.getColumn(); tcLayout.setColumnData(tcAmount, new ColumnPixelData(70, false, false)); tcAmount.setText(Messages.DailyOrderDialog_Amount); tvc = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn tcArticle = tvc.getColumn(); tcLayout.setColumnData(tcArticle, new ColumnPixelData(300, true, true)); tcArticle.setText(Messages.DailyOrderDialog_Article); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new OrderLabelProvider()); loadArticlesUsedOnSelectedDay(); tableViewer.setInput(currOrder.getEntries()); return area; }
private void createHeaderTableColumns(TableViewer viewer, TableColumnLayout layout) { final String[] titles = { "Name", "Value", }; final ColumnLayoutData[] layoutData = { new ColumnPixelData(120, true, true), new ColumnWeightData(100, 100, true), }; final EditingSupport editorList[] = { new HeaderNameEditingSupport(viewer), new HeaderValueEditingSupport(viewer), }; final ColumnLabelProvider providerList[] = { new ColumnLabelProvider() { @Override public String getText(Object element) { return ((IHttpHeaderBuilder) element).getName(); } }, new ColumnLabelProvider() { @Override public String getText(Object element) { return ((IHttpHeaderBuilder) element).getValue(); } }, }; for (int i = 0; i < titles.length; i++) { final TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); final TableColumn c = column.getColumn(); layout.setColumnData(c, layoutData[i]); c.setText(titles[i]); c.setMoveable(true); column.setEditingSupport(editorList[i]); column.setLabelProvider(providerList[i]); } }
// Helper methods: private void createColumns(final Composite composite) { TableColumn colName = createColumn( UITexts.cabalImplsBlock_colName, new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent evt) { sortByUserIdentifier(); } }); TableColumn colInstallVersion = createColumn( UITexts.cabalImplsBlock_colCabalInstallVersion, new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent evt) { sortByInstallVersion(); } }); TableColumn colLibraryVersion = createColumn( UITexts.cabalImplsBlock_colCabalLibraryVersion, new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent evt) { sortByLibraryVersion(); } }); TableColumn colCabalPath = createColumn( UITexts.cabalImplsBlock_colCabalPath, new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent evt) { sortByExecutablePath(); } }); TableColumnLayout tcLayout = new TableColumnLayout(); composite.setLayout(tcLayout); tcLayout.setColumnData(colName, new ColumnWeightData(25, true)); tcLayout.setColumnData(colInstallVersion, new ColumnWeightData(20, true)); tcLayout.setColumnData(colLibraryVersion, new ColumnWeightData(20, true)); tcLayout.setColumnData(colCabalPath, new ColumnWeightData(35, true)); }
public Snippet016TableLayout(Composite comp) { final TableViewer v = new TableViewer(new Table(comp, SWT.BORDER)); v.setLabelProvider(new MyLabelProvider()); v.setContentProvider(new MyContentProvider()); v.getTable().setHeaderVisible(true); TableColumnLayout ad = new TableColumnLayout(); comp.setLayout(ad); TableColumn column1 = createTableColumn(v.getTable(), "Column 1"); TableColumn column2 = createTableColumn(v.getTable(), "Column 2"); ad.setColumnData(column1, new ColumnWeightData(90, 290)); ad.setColumnData(column2, new ColumnWeightData(10, 200)); MyModel[] model = createModel(); v.setInput(model); v.getTable().setLinesVisible(true); }
@Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); setControl(container); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container); Button checkbox = new Button(container, SWT.CHECK); checkbox.setText(Messages.SplitWizardLabelUpdateTransactions); Composite tableContainer = new Composite(container, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(tableContainer); TableColumnLayout layout = new TableColumnLayout(); tableContainer.setLayout(layout); tableViewer = new TableViewer(tableContainer, SWT.BORDER); Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn column = new TableColumn(tableViewer.getTable(), SWT.None); column.setText(Messages.ColumnDate); layout.setColumnData(column, new ColumnPixelData(80, true)); column = new TableColumn(tableViewer.getTable(), SWT.None); column.setText(Messages.ColumnTransactionType); layout.setColumnData(column, new ColumnPixelData(80, true)); column = new TableColumn(tableViewer.getTable(), SWT.RIGHT); column.setText(Messages.ColumnCurrentShares); layout.setColumnData(column, new ColumnPixelData(80, true)); column = new TableColumn(tableViewer.getTable(), SWT.RIGHT); column.setText(Messages.ColumnUpdatedShares); layout.setColumnData(column, new ColumnPixelData(80, true)); column = new TableColumn(tableViewer.getTable(), SWT.None); column.setText(Messages.ColumnSource); layout.setColumnData(column, new ColumnPixelData(200, true)); tableViewer.setLabelProvider(new TransactionLabelProvider()); tableViewer.setContentProvider(new SimpleListContentProvider()); // bindings DataBindingContext context = new DataBindingContext(); context.bindValue( SWTObservables.observeSelection(checkbox), // BeansObservables.observeValue(model, "changeTransactions")); // $NON-NLS-1$ checkbox.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { tableViewer.refresh(); } }); }
/** * @param layout * @param header * @param weight */ private void createColumn( TableColumnLayout layout, final int columnIndex, String header, int weight) { TableColumn tc = new TableColumn(tableViewer.getTable(), SWT.NONE); tc.setText(header); tc.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ((AAProductSorter) tableViewer.getSorter()).setColumn(columnIndex); tableViewer.refresh(); } }); layout.setColumnData(tc, new ColumnWeightData(weight)); }
private void addColumnsExceptionTable(TableViewer viewer, TableColumnLayout layout) { TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(Messages.ColumnErrorMessages); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { Exception e = (Exception) element; String text = e.getMessage(); return text == null || text.isEmpty() ? e.getClass().getName() : text; } }); layout.setColumnData(column.getColumn(), new ColumnWeightData(100, true)); }
/** Set up the table columns */ private void setupColumns() { Table table = getTable(); // Set up the columns table.setHeaderVisible(true); table.setLinesVisible(true); // Use layout from parent container TableColumnLayout layout = (TableColumnLayout) getControl().getParent().getLayout(); TableViewerColumn[] columns = new TableViewerColumn[columnNames.length]; for (int i = 0; i < columnNames.length; i++) { columns[i] = new TableViewerColumn(this, SWT.NONE); columns[i].getColumn().setText(columnNames[i]); } layout.setColumnData(columns[0].getColumn(), new ColumnWeightData(5, true)); layout.setColumnData(columns[1].getColumn(), new ColumnWeightData(95, true)); // Column properties for editors setColumnProperties(columnNames); }
private void createTableColumn( String name, int weight, int alignment, CellLabelProvider cellLabelProvider, TableViewer viewer, TableColumnLayout layout) { TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT); column.getColumn().setText(name); column.getColumn().setAlignment(alignment); if (cellLabelProvider != null) { column.setLabelProvider(cellLabelProvider); } layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true)); }
@Override public void create(Column column, Object option, Integer direction, int width) { TableViewerColumn col = new TableViewerColumn(table, column.getStyle()); TableColumn tableColumn = col.getColumn(); tableColumn.setText(column.getText(option)); tableColumn.setToolTipText(column.getToolTipText()); tableColumn.setMoveable(column.isMoveable()); tableColumn.setWidth(width); tableColumn.setData(Column.class.getName(), column); tableColumn.setData(OPTIONS_KEY, option); layout.setColumnData(tableColumn, new ColumnPixelData(width)); setCommonParameters(column, col, direction); }
/** * @see * com.vectrace.MercurialEclipse.ui.AbstractHighlightableTable#createColumns(org.eclipse.jface.viewers.TableViewer, * org.eclipse.jface.layout.TableColumnLayout) */ @Override protected List<TableViewerColumn> createColumns( TableViewer viewer, TableColumnLayout tableColumnLayout) { List<TableViewerColumn> l = new ArrayList<TableViewerColumn>(2); String[] titles = { Messages.getString("MergeView.column.status"), Messages.getString("MergeView.column.file") }; //$NON-NLS-1$ //$NON-NLS-2$ ColumnLayoutData[] widths = { new ColumnPixelData(100, false, true), new ColumnWeightData(100, 200, true) }; for (int i = 0; i < titles.length; i++) { TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titles[i]); tableColumnLayout.setColumnData(column.getColumn(), widths[i]); l.add(column); } return l; }
private void createUI20PartViewer(final Composite parent) { final PixelConverter pixelConverter = new PixelConverter(parent); final TableColumnLayout tableLayout = new TableColumnLayout(); final Composite layoutContainer = new Composite(parent, SWT.NONE); layoutContainer.setLayout(tableLayout); GridDataFactory.fillDefaults() // .grab(true, true) .hint(SWT.DEFAULT, pixelConverter.convertHeightInCharsToPixels(13)) .applyTo(layoutContainer); /* * create table */ final Table table = new Table(layoutContainer, SWT.FULL_SELECTION | SWT.BORDER); table.setLayout(new TableLayout()); table.setHeaderVisible(true); table.setLinesVisible(true); _partViewer = new TableViewer(table); /* * create columns */ TableViewerColumn tvc; TableColumn tvcColumn; // column: map provider tvc = new TableViewerColumn(_partViewer, SWT.LEAD); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_MapProvider); tvc.setLabelProvider( new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(partMp.partMp.getName()); } }); tableLayout.setColumnData(tvcColumn, new ColumnWeightData(100)); // column: existing images tvc = new TableViewerColumn(_partViewer, SWT.TRAIL); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_ExistingImages); tvcColumn.setToolTipText(Messages.Dialog_OfflineArea_Column_ExistingImages_Tooltip); tvc.setLabelProvider( new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(Integer.toString(partMp.existingImages)); } }); tableLayout.setColumnData( tvcColumn, new ColumnPixelData(pixelConverter.convertWidthInCharsToPixels(12), true)); // column: missing images tvc = new TableViewerColumn(_partViewer, SWT.TRAIL); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_MissingImages); tvcColumn.setToolTipText(Messages.Dialog_OfflineArea_Column_MissingImages_Tooltip); tvc.setLabelProvider( new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(Integer.toString(partMp.missingImages)); } }); tableLayout.setColumnData( tvcColumn, new ColumnPixelData(pixelConverter.convertWidthInCharsToPixels(12), true)); /* * create table viewer */ _partViewer.setContentProvider(new PartViewerContentProvicer()); _partViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final StructuredSelection selection = (StructuredSelection) event.getSelection(); if (selection != null) { enableControls(true); } } }); }
@Override public TabItem doCreateForm( TabFolder folder, EditingDomain domain, DataBindingContext dbc, IObservableValue master) { TabItem item = new TabItem(folder, SWT.NONE); IValueProperty textProp = WidgetProperties.text(); dbc.bindValue( textProp.observe(item), EMFEditObservables.observeDetailValue( Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS), new UpdateValueStrategy(), new UpdateValueStrategy().setConverter(new LengthConverter())); Composite comp = new Composite(folder, SWT.NONE); TableColumnLayout layout = new TableColumnLayout(); comp.setLayout(layout); TableViewer writerViewer = new TableViewer( comp, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); writerViewer.getTable().setHeaderVisible(true); writerViewer.getTable().setLinesVisible(true); ObservableListContentProvider cp = new ObservableListContentProvider(); writerViewer.setContentProvider(cp); CondiditionalTemplate[] tpl = new CondiditionalTemplate[3]; tpl[0] = new CondiditionalTemplate("${0}") { @Override public boolean isTemplate(EObject element) { return element instanceof Writer && ((Writer) element).getFirstName() != null; } }; tpl[1] = new CondiditionalTemplate("${0}") { @Override public boolean isTemplate(EObject element) { return element instanceof Writer && ((Writer) element).getLastName() != null; } }; tpl[2] = new CondiditionalTemplate("-") { @Override public boolean isTemplate(EObject element) { return true; } }; EStructuralFeature[] features = new EStructuralFeature[3]; features[0] = EXTLibraryPackage.Literals.PERSON__FIRST_NAME; features[1] = EXTLibraryPackage.Literals.PERSON__LAST_NAME; IObservableMap[] map = EMFEditObservables.observeMaps(domain, cp.getKnownElements(), features); TableViewerColumn c = new TableViewerColumn(writerViewer, SWT.NONE); c.getColumn().setText("Firstname"); layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120)); c.setLabelProvider( new ObservableColumnLabelProvider( new IObservableMap[] {map[0]}, Arrays.asList(tpl[0], tpl[2]))); c = new TableViewerColumn(writerViewer, SWT.NONE); c.getColumn().setText("Lastname"); layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120)); c.setLabelProvider( new ObservableColumnLabelProvider( new IObservableMap[] {map[1]}, Arrays.asList(tpl[1], tpl[2]))); MenuManager mgr = new MenuManager(); writerViewer.getControl().setMenu(mgr.createContextMenu(writerViewer.getControl())); getSite() .registerContextMenu( "org.eclipse.emf.examples.library.databinding.writer", mgr, writerViewer); writerViewer.setInput( EMFEditObservables.observeDetailList( Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS)); item.setControl(comp); return item; }
@Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); setControl(container); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container); Label lblAcc = new Label(container, SWT.NULL); lblAcc.setText(Messages.ColumnAccount); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblAcc); final Text accountName = new Text(container, SWT.BORDER | SWT.SINGLE); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .applyTo(accountName); Button button = new Button(container, SWT.PUSH); button.setText(Messages.NewFileWizardButtonAdd); GridDataFactory.fillDefaults().applyTo(button); Composite tableContainer = new Composite(container, SWT.NONE); GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(tableContainer); TableColumnLayout layout = new TableColumnLayout(); tableContainer.setLayout(layout); tViewer = new TableViewer(tableContainer); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String acnName = accountName.getText(); if (acnName.length() > 0) { Account currentAccount = new Account(); currentAccount.setName(acnName); client.addAccount(currentAccount); tViewer.refresh(); accountName.setText(""); // $NON-NLS-1$ accountName.setFocus(); } } }); Table table = tViewer.getTable(); table.setHeaderVisible(true); table.setEnabled(false); tViewer.setContentProvider(ArrayContentProvider.getInstance()); tViewer.setInput(client.getAccounts()); TableViewerColumn aCol = new TableViewerColumn(tViewer, SWT.NONE); layout.setColumnData(aCol.getColumn(), new ColumnWeightData(50)); aCol.getColumn().setText(Messages.ColumnAccount); aCol.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Account) element).getName(); } @Override public Image getImage(Object element) { return PortfolioPlugin.image(PortfolioPlugin.IMG_ACCOUNT); } }); container.pack(); setPageComplete(true); }
/** * method createParticipantsGroup * * @param aToolkit * @param aComposite */ private void createParticipantsGroup(FormToolkit aToolkit, Composite aComposite) { // Users to Add final Group usersToAddGroup = new Group(aComposite, SWT.NONE); usersToAddGroup.setText(PARTICIPANTS_GROUP_LABEL); usersToAddGroup.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); usersToAddGroup.setLayout(new GridLayout(4, false)); final GridData groupGridData = new GridData(GridData.FILL, GridData.FILL, true, true); usersToAddGroup.setLayoutData(groupGridData); // Participants data composite final Composite dataComposite = aToolkit.createComposite(usersToAddGroup); dataComposite.setLayout(new GridLayout()); final GridData dataCompositeData = new GridData(GridData.FILL, GridData.FILL, true, true); dataCompositeData.horizontalSpan = 3; dataComposite.setLayoutData(dataCompositeData); // Participants button composite final Composite buttonsComposite = aToolkit.createComposite(usersToAddGroup); buttonsComposite.setLayout(new GridLayout()); final GridData buttonsCompositeData = new GridData(GridData.END, GridData.FILL, false, true); buttonsComposite.setLayoutData(buttonsCompositeData); final String[] participantsLists = R4EPreferencePage.getParticipantsLists(); if (participantsLists.length > 0) { fUserToAddCombo = new CCombo(dataComposite, SWT.SINGLE | SWT.BORDER); ((CCombo) fUserToAddCombo).setItems(participantsLists); ((CCombo) fUserToAddCombo).setEditable(true); } else { fUserToAddCombo = aToolkit.createText(dataComposite, "", SWT.SINGLE | SWT.BORDER); ((Text) fUserToAddCombo).setEditable(true); } final GridData textGridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); fUserToAddCombo.setToolTipText(R4EUIConstants.PARTICIPANT_ADD_USER_TOOLTIP); fUserToAddCombo.setLayoutData(textGridData); fUserToAddCombo.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { String widgetStr = null; if (fUserToAddCombo instanceof CCombo) { widgetStr = ((CCombo) fUserToAddCombo).getText(); } else { widgetStr = ((Text) fUserToAddCombo).getText().trim(); } if (widgetStr.trim().length() > 0) { fAddUserButton.setEnabled(true); } else { fAddUserButton.setEnabled(false); } } }); // Trap \R key (Return) fUserToAddCombo.addListener( SWT.KeyDown, new Listener() { public void handleEvent(Event event) { if (event.character == SWT.CR) { getShell().setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); String widgetStr = null; if (fUserToAddCombo instanceof CCombo) { widgetStr = ((CCombo) fUserToAddCombo).getText(); } else { widgetStr = ((Text) fUserToAddCombo).getText(); } // Tokenize the users list final String[] users = widgetStr.split(R4EUIConstants.LIST_SEPARATOR); for (String user : users) { addUsersToParticipantList(user); } if (fUserToAddCombo instanceof CCombo) { ((CCombo) fUserToAddCombo).setText(""); } else { ((Text) fUserToAddCombo).setText(""); } getShell().setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); } } }); // Participants table final Composite tableComposite = aToolkit.createComposite(dataComposite); final GridData tableCompositeData = new GridData(GridData.FILL, GridData.FILL, true, true); fAddedParticipantsTable = aToolkit.createTable(tableComposite, SWT.FULL_SELECTION | SWT.BORDER); fAddedParticipantsTable.setHeaderVisible(true); fAddedParticipantsTable.setLinesVisible(true); fAddedParticipantsTable.setToolTipText(R4EUIConstants.PARTICIPANTS_ADD_TOOLTIP); fAddedParticipantsTable.setLinesVisible(true); fAddedParticipantsTable.setItemCount(0); final GridData tableGridData = new GridData(GridData.FILL, GridData.FILL, true, true); fAddedParticipantsTable.setLayoutData(tableGridData); final TableColumnLayout tableColumnLayout = new TableColumnLayout(); final TableColumn idColumn = new TableColumn(fAddedParticipantsTable, SWT.NONE, 0); idColumn.setText(R4EUIConstants.ID_LABEL); final TableColumn emailColumn = new TableColumn(fAddedParticipantsTable, SWT.NONE, 1); emailColumn.setText(R4EUIConstants.EMAIL_LABEL); tableColumnLayout.setColumnData( idColumn, new ColumnWeightData(30, idColumn.getWidth() * 2, true)); tableColumnLayout.setColumnData( emailColumn, new ColumnWeightData(70, emailColumn.getWidth(), true)); tableComposite.setLayout(tableColumnLayout); tableComposite.setLayoutData(tableCompositeData); fAddedParticipantsTable.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { fSelectedParticipantIndex = fAddedParticipantsTable.getSelectionIndex(); if (fSelectedParticipantIndex >= 0) { final R4EParticipant participant = fParticipants.get(fSelectedParticipantIndex); if (null != participant) { fParticipantIdInputTextField.setText(participant.getId()); if (null != participant.getEmail()) { fParticipantEmailInputTextField.setText(participant.getEmail()); } else { fParticipantEmailInputTextField.setText(""); } if (fSelectedParticipantIndex < fParticipantsDetailsValues.size()) { fParticipantDetailsInputTextField.setText( fParticipantsDetailsValues.get(fSelectedParticipantIndex)); } else { fParticipantDetailsInputTextField.setText(""); } } // Make sure fields are enabled fParticipantIdInputTextField.setEnabled(true); fParticipantEmailInputTextField.setEnabled(true); fParticipantDetailsInputTextField.setEnabled(true); } } }); // Add user button fAddUserButton = aToolkit.createButton(buttonsComposite, ADD_BUTTON_LABEL, SWT.NONE); final GridData addButtonGridData = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false); fAddUserButton.setEnabled(false); fAddUserButton.setToolTipText(R4EUIConstants.PARTICIPANT_ADD_USER_TOOLTIP); fAddUserButton.setLayoutData(addButtonGridData); fAddUserButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { getShell().setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); String widgetStr = null; if (fUserToAddCombo instanceof CCombo) { widgetStr = ((CCombo) fUserToAddCombo).getText(); } else { widgetStr = ((Text) fUserToAddCombo).getText(); } // Tokenize the users list final String[] users = widgetStr.split(R4EUIConstants.LIST_SEPARATOR); for (String user : users) { addUsersToParticipantList(user); } getShell().setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); } }); fFindUserButton = aToolkit.createButton(buttonsComposite, FIND_BUTTON_LABEL, SWT.NONE); final GridData findButtonGridData = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false); fFindUserButton.setToolTipText(R4EUIConstants.PARTICIPANT_FIND_USER_TOOLTIP); fFindUserButton.setLayoutData(findButtonGridData); fFindUserButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { if (R4EUIModelController.isUserQueryAvailable()) { final IFindUserDialog dialog = R4EUIDialogFactory.getInstance().getFindUserDialog(); dialog.create(); dialog.setDialogsDefaults(); final int result = dialog.open(); if (result == Window.OK) { final List<IUserInfo> usersInfos = dialog.getUserInfos(); for (IUserInfo user : usersInfos) { addUserToParticipantList(user); } } } else { R4EUIPlugin.Ftracer.traceWarning(LDAP_NOT_CONFIGURED); final ErrorDialog dialog = new ErrorDialog( null, R4EUIConstants.DIALOG_TITLE_WARNING, LDAP_NOT_CONFIGURED, new Status( IStatus.WARNING, R4EUIPlugin.PLUGIN_ID, 0, LDAP_NOT_CONFIGURED_DETAILED, null), IStatus.WARNING); Display.getDefault() .syncExec( new Runnable() { public void run() { dialog.open(); } }); } } }); fRemoveUserButton = aToolkit.createButton(buttonsComposite, REMOVE_BUTTON_LABEL, SWT.NONE); final GridData removeButtonGridData = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false); fRemoveUserButton.setEnabled(false); fRemoveUserButton.setToolTipText(R4EUIConstants.PARTICIPANT_REMOVE_TOOLTIP); fRemoveUserButton.setLayoutData(removeButtonGridData); if (!R4EUIModelController.isUserQueryAvailable()) { fRemoveUserButton.setEnabled(false); } fRemoveUserButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { if (fSelectedParticipantIndex >= 0 && fSelectedParticipantIndex < fAddedParticipantsTable.getItemCount()) { fAddedParticipantsTable.remove(fSelectedParticipantIndex); fParticipants.remove(fSelectedParticipantIndex); fParticipantsDetailsValues.remove(fSelectedParticipantIndex); clearParametersFields(); } } }); // Clear participants list button fClearParticipantsButton = aToolkit.createButton(buttonsComposite, CLEAR_BUTTON_LABEL, SWT.NONE); final GridData clearButtonGridData = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false); fClearParticipantsButton.setEnabled(false); fClearParticipantsButton.setToolTipText(R4EUIConstants.PARTICIPANTS_CLEAR_TOOLTIP); fClearParticipantsButton.setLayoutData(clearButtonGridData); fClearParticipantsButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { fParticipants.clear(); fParticipantsDetailsValues.clear(); fAddedParticipantsTable.removeAll(); fSelectedParticipantIndex = R4EUIConstants.INVALID_VALUE; clearParametersFields(); } }); }
@Override protected void createFieldEditors() { this.enableAutoCheckin = new BooleanFieldEditor( P_ENABLE_AUTO_CHECKIN, "Enable Auto Checkin", getFieldEditorParent()); addField(this.enableAutoCheckin); this.enableResChangeListener = new BooleanFieldEditor( P_ENABLE_TRACK_ECLIPSE_CHANGE, "Enable Track and Check in Eclipse Changes", getFieldEditorParent()); addField(this.enableResChangeListener); this.repositoryName = new ComboFieldEditor( P_REPOSITORY_NAME, "Repository name: ", REPOSITORY_NAMES, getFieldEditorParent()); addField(this.repositoryName); // uncomment this after enabling browse button in Repository Dialog /*this.repositoryBaseLocation = new StringFieldEditor(P_REPOSITORY_BASE_LOCATION, "Repository Base URL: ", getFieldEditorParent()); this.repositoryBaseLocation.setEmptyStringAllowed(false); addField(this.repositoryBaseLocation);*/ // this.repositoryUrl = new StringFieldEditor(P_REPOSITORY_URL, "Repository Url", // getFieldEditorParent()); /*this.repositoryUrl = new StringButtonFieldEditor(P_REPOSITORY_URL, "Repository Url: ", getFieldEditorParent()) { @Override protected String changePressed() { try { final String url = VersionControlPreferencePage.this.currentValueOfRepoLoc; final RepositoryService repositoryService = getRepositoryServiceClass(); final List<String> projects = repositoryService.getSharedProjects(url); final StringSelectionDialog selectionDialog = new StringSelectionDialog(new Shell(), "Select Project", "Select Project", projects.toArray(new String[0]), false); if (selectionDialog.open() == Window.CANCEL) { return null; } else { final String repository = (String) selectionDialog.getResult()[0]; return url + FORWARD_SLASH + repository; } } catch (final FastCodeRepositoryException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } return null; } }; addField(this.repositoryUrl);*/ this.userName = new StringFieldEditor(P_REPOSITORY_USERNAME, "UserName:"******"Password:"******"Project Name"); final int minWidth = computeMinimumColumnWidth(gc, "Project Name"); columnLayout.setColumnData(column1, new ColumnWeightData(12, minWidth, true)); final TableViewerColumn viewerColumn2 = new TableViewerColumn(this.prjUrlViewer, SWT.NONE); final TableColumn column2 = viewerColumn2.getColumn(); column2.setText("URL"); final int minWidth1 = computeMinimumColumnWidth(gc, "URL"); columnLayout.setColumnData(column2, new ColumnWeightData(24, minWidth1, true)); this.prjUrlViewer.setLabelProvider(new ProjectUrlLabelProvider()); this.prjUrlViewer.setContentProvider(new ProjectUrlContentProvider()); this.prjUrlViewer.setInput(getEmptyListForNull(loadData())); final Composite buttons = new Composite(innerParent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final GridLayout buttonLayout = new GridLayout(); buttonLayout.marginHeight = 0; buttonLayout.marginWidth = 0; buttons.setLayout(buttonLayout); this.addButton = new Button(buttons, SWT.PUSH); this.addButton.setText("Add"); if (isEmpty(this.preferenceStore.getString(P_REPOSITORY_PASSWORD)) || isEmpty(this.preferenceStore.getString(P_REPOSITORY_USERNAME))) { this.addButton.setEnabled(false); } this.addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.addButton.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(final Event e) { final String prjUrlPairs = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSIROTY_PROJECT_URL_PAIR); final RepositoryData repositoryData = new RepositoryData(); /*String repBaseLoc = VersionControlPreferencePage.this.currentValueOfRepoBaseLocation; if (isEmpty(repBaseLoc)) { repBaseLoc = VersionControlPreferencePage.this.preferenceStore.getString(P_REPOSITORY_BASE_LOCATION); if (isEmpty(repBaseLoc)) { //openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); //VersionControlPreferencePage.this.editButton.setEnabled(false); } } repositoryData.setRepBaseLocation(repBaseLoc);*/ // VersionControlPreferencePage.this.currentValueOfRepoName.toLowerCase() + COLON + // FORWARD_SLASH + FORWARD_SLASH + LOCAL_HOST); // repositoryData.setPrjUrlMap(getPrjUrlPairMap(prjUrlPairs)); String userName = VersionControlPreferencePage.this.currentValueOfUserName; if (isEmpty(userName)) { userName = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSITORY_USERNAME); if (isEmpty(userName)) { /*openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); VersionControlPreferencePage.this.editButton.setEnabled(false);*/ } } repositoryData.setUserName(userName); String password = VersionControlPreferencePage.this.currentValueOfPassWord; if (isEmpty(password)) { password = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSITORY_PASSWORD); if (isEmpty(password)) { /*openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); VersionControlPreferencePage.this.editButton.setEnabled(false);*/ } } repositoryData.setPassword(password); repositoryData.setSource("Add"); final RepositoryDialog repositoryDialog = new RepositoryDialog(getShell(), repositoryData); if (repositoryDialog.open() == Window.CANCEL) { return; } VersionControlPreferencePage.this.currentValueOfProject = repositoryData.getAssociatedProject(); VersionControlPreferencePage.this.currentValueOfRepoUrl = repositoryData.getRepUrl(); final String currPrjUrl = repositoryData.getAssociatedProject().trim() + prj_url_delim + repositoryData.getRepUrl().trim(); VersionControlPreferencePage.this.preferenceStore.setValue( P_REPOSIROTY_PROJECT_URL_PAIR, isEmpty(prjUrlPairs) ? currPrjUrl : prjUrlPairs + prj_url_pair_delim + currPrjUrl); VersionControlPreferencePage.this.prjUrlViewer.setInput( getEmptyListForNull(loadData())); VersionControlPreferencePage.this.prjUrlViewer.refresh(); } }); this.editButton = new Button(buttons, SWT.PUSH); this.editButton.setText("Edit"); this.editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (isEmpty(this.preferenceStore.getString(P_REPOSITORY_PASSWORD)) || isEmpty(this.preferenceStore.getString(P_REPOSITORY_USERNAME))) { this.editButton.setEnabled(false); } this.editButton.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(final Event e) { final String prjUrlPairs = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSIROTY_PROJECT_URL_PAIR); // final RepositoryData repositoryData = new RepositoryData(); final int index = VersionControlPreferencePage.this.table.getSelectionIndex(); if (index > -1) { final RepositoryData repositoryData = (RepositoryData) VersionControlPreferencePage.this.prjUrlViewer.getElementAt(index); final String origPrjUrl = repositoryData.getAssociatedProject().trim() + prj_url_delim + repositoryData.getRepUrl().trim(); /*String repLoc = VersionControlPreferencePage.this.currentValueOfRepoLoc; if (isEmpty(repLoc)) { repLoc = VersionControlPreferencePage.this.preferenceStore.getString(P_REPOSITORY_LOCATION); if (isEmpty(repLoc)) { openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); VersionControlPreferencePage.this.editButton.setEnabled(false); } }*/ repositoryData.setRepBaseLocation( VersionControlPreferencePage.this .currentValueOfRepoBaseLocation); // VersionControlPreferencePage.this.currentValueOfRepoName.toLowerCase() + COLON + FORWARD_SLASH + FORWARD_SLASH + LOCAL_HOST); // repositoryData.setPrjUrlMap(getPrjUrlPairMap(prjUrlPairs)); String userName = VersionControlPreferencePage.this.currentValueOfUserName; if (isEmpty(userName)) { userName = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSITORY_USERNAME); if (isEmpty(userName)) { /*openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); VersionControlPreferencePage.this.editButton.setEnabled(false);*/ } } repositoryData.setUserName(userName); String password = VersionControlPreferencePage.this.currentValueOfPassWord; if (isEmpty(password)) { password = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSITORY_PASSWORD); if (isEmpty(password)) { /*openWarning(getShell(), "Please enter value for URL", "Please enter value for Repository URL"); VersionControlPreferencePage.this.editButton.setEnabled(false);*/ } } repositoryData.setPassword(password); repositoryData.setSource("Edit"); final RepositoryDialog repositoryDialog = new RepositoryDialog(getShell(), repositoryData); if (repositoryDialog.open() == Window.CANCEL) { return; } VersionControlPreferencePage.this.currentValueOfProject = repositoryData.getAssociatedProject(); VersionControlPreferencePage.this.currentValueOfRepoUrl = repositoryData.getRepUrl(); final String currPrjUrl = repositoryData.getAssociatedProject().trim() + prj_url_delim + repositoryData.getRepUrl().trim(); final String finalPrjUrlPairs = prjUrlPairs.replace(origPrjUrl, currPrjUrl); VersionControlPreferencePage.this.preferenceStore.setValue( P_REPOSIROTY_PROJECT_URL_PAIR, finalPrjUrlPairs); VersionControlPreferencePage.this.prjUrlViewer.setInput( getEmptyListForNull(loadData())); VersionControlPreferencePage.this.prjUrlViewer.refresh(); } } }); this.removeButton = new Button(buttons, SWT.PUSH); this.removeButton.setText("Remove"); this.removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.removeButton.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(final Event e) { final int index = VersionControlPreferencePage.this.table.getSelectionIndex(); System.out.println("index--" + index); if (index > -1) { final RepositoryData repositoryData = (RepositoryData) VersionControlPreferencePage.this.prjUrlViewer.getElementAt(index); System.out.println("repositoryData--" + repositoryData); System.out.println(repositoryData.getAssociatedProject()); System.out.println(repositoryData.getRepUrl()); final String prjUrlPairs = VersionControlPreferencePage.this.preferenceStore.getString( P_REPOSIROTY_PROJECT_URL_PAIR); System.out.println(prjUrlPairs); final String finalPrjUrlPairs = prjUrlPairs.replace( repositoryData.getAssociatedProject().trim() + prj_url_delim + repositoryData.getRepUrl().trim(), EMPTY_STR); VersionControlPreferencePage.this.preferenceStore.setValue( P_REPOSIROTY_PROJECT_URL_PAIR, finalPrjUrlPairs); System.out.println("set to pref...."); VersionControlPreferencePage.this.prjUrlViewer.setInput( getEmptyListForNull(loadData())); System.out.println("refresh done..."); VersionControlPreferencePage.this.prjUrlViewer.refresh(); System.out.println("remove -- done"); } } }); this.checkIn = new RadioGroupFieldEditor( P_CHECK_IN, "Check In:", CHECK_IN_TYPES.length, CHECK_IN_TYPES, getFieldEditorParent(), true); addField(this.checkIn); this.timeGapBeforeAutoCheckIn = new IntegerFieldEditor( P_TIME_GAP_BEFORE_CHECK_IN, "Time Gap Before Check In(in Min):", getFieldEditorParent()); addField(this.timeGapBeforeAutoCheckIn); this.excludeDir = new StringFieldEditor( P_EXCLUDE_DIR, "Directories to be excluded: ", getFieldEditorParent()); addField(this.excludeDir); this.prefixComments = new StringFieldEditor(P_COMMENTS_PREFIX, "Prefix Comments: ", getFieldEditorParent()); addField(this.prefixComments); this.footerComments = new MultiStringFieldEditor( P_COMMENTS_FOOTER, "Footer Comments: ", getFieldEditorParent(), false); addField(this.footerComments); this.currentValueOfRepoName = this.preferenceStore.getString(P_REPOSITORY_NAME); this.currentValueOfRepoUrl = this.preferenceStore.getString(P_REPOSITORY_URL); this.currentValueOfUserName = this.preferenceStore.getString(P_REPOSITORY_USERNAME); this.currentValueOfPassWord = this.preferenceStore.getString(P_REPOSITORY_PASSWORD); // this.currentValueOfRepoBaseLocation = // this.preferenceStore.getString(P_REPOSITORY_BASE_LOCATION); /*if (isEmpty(this.currentValueOfRepoName) || isEmpty(this.currentValueOfRepoUrl) || isEmpty(this.currentValueOfUserName) || isEmpty(this.currentValueOfPassWord)) { MessageDialog.openWarning(getShell(), "Warning", "Input value to Repository Name,Repository Url,UserName and Password fields."); }*/ enableFields(getPreferenceStore().getBoolean(P_ENABLE_AUTO_CHECKIN)); }
/** * Create contents of the dialog. * * @param parent */ @Override protected Control createDialogArea(Composite parent) { setTitle(""); parent.setToolTipText("hghkhj"); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); CTabFolder tabFolder = new CTabFolder(container, SWT.BORDER); tabFolder.setTabHeight(22); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tabFolder.setSelectionBackground( Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); CTabItem tbtmNewItem = new CTabItem(tabFolder, SWT.NONE); tbtmNewItem.setText("Main"); Composite composite = new Composite(tabFolder, SWT.NONE); tbtmNewItem.setControl(composite); composite.setLayout(new GridLayout(2, false)); Label lblNewLabel = new Label(composite, SWT.NONE); lblNewLabel.setText("Id:"); idText = new Text(composite, SWT.BORDER); idText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel_1 = new Label(composite, SWT.NONE); lblNewLabel_1.setText("Source Ref:"); sourceRefViewer = new ComboViewer(composite, SWT.READ_ONLY); Combo combo = sourceRefViewer.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); sourceRefViewer.setContentProvider(new ArrayContentProvider()); sourceRefViewer.setLabelProvider(new IDataLabelProvider()); Label lblNewLabel_2 = new Label(composite, SWT.NONE); lblNewLabel_2.setText("Target Ref:"); targetRefViewer = new ComboViewer(composite, SWT.READ_ONLY); Combo combo_1 = targetRefViewer.getCombo(); combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); targetRefViewer.setContentProvider(new ArrayContentProvider()); targetRefViewer.setLabelProvider(new IDataLabelProvider()); Label lblNewLabel_3 = new Label(composite, SWT.NONE); lblNewLabel_3.setText("Transformation:"); transformationText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI); transformationText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); CTabItem tbtmNewItem_1 = new CTabItem(tabFolder, SWT.NONE); tbtmNewItem_1.setText("Assignments"); Composite composite_1 = new Composite(tabFolder, SWT.NONE); tbtmNewItem_1.setControl(composite_1); composite_1.setLayout(new GridLayout(1, true)); ToolBar toolBar = new ToolBar(composite_1, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); ToolItem addItem = new ToolItem(toolBar, SWT.NONE); addItem.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { Shell newshell = new Shell(getParentShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); AssignmentDialog dialog = new AssignmentDialog(newshell); String determinedId = IdUtil.getNextParentedIdInList( (List<BaseElement>) assignmentsViewer.getInput(), "A", idText.getText()); dialog.setDeterminedId(determinedId); if (dialog.open() == Window.OK) { ((List<Assignment>) assignmentsViewer.getInput()).add(dialog.getResult()); try { idHandler.addId(dialog.getResult()); } catch (IdAlreadyExistException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } assignmentsViewer.refresh(true); } } }); addItem.setText("New"); final ToolItem editItem = new ToolItem(toolBar, SWT.NONE); editItem.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { AssignmentDialog dialog = new AssignmentDialog(getShell()); String determinedId = IdUtil.getNextParentedIdInList( (List<BaseElement>) assignmentsViewer.getInput(), "A", idText.getText()); dialog.setDeterminedId(determinedId); IStructuredSelection selection = (IStructuredSelection) assignmentsViewer.getSelection(); if (dialog.open((Assignment) selection.getFirstElement()) == Window.OK) { int index = assignmentsViewer.getTable().getSelectionIndex(); try { idHandler.removeId((BaseElement) selection.getFirstElement()); } catch (IdNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((List<Assignment>) assignmentsViewer.getInput()).remove(selection.getFirstElement()); ((List<Assignment>) assignmentsViewer.getInput()).add(index, dialog.getResult()); try { idHandler.addId(dialog.getResult()); } catch (IdAlreadyExistException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } assignmentsViewer.refresh(true); // ModelIdProcessor.refreshModelIds(EcoreUtil.getURI(getDiagram())); } } }); editItem.setText("Edit"); editItem.setEnabled(false); final ToolItem deleteItem = new ToolItem(toolBar, SWT.NONE); deleteItem.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) assignmentsViewer.getSelection(); try { idHandler.removeId((BaseElement) selection.getFirstElement()); } catch (IdNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((List<Assignment>) assignmentsViewer.getInput()).remove(selection.getFirstElement()); assignmentsViewer.refresh(true); // ModelIdProcessor.refreshModelIds(EcoreUtil.getURI(getDiagram())); } }); deleteItem.setText("Delete"); deleteItem.setEnabled(false); final ToolItem upItem = new ToolItem(toolBar, SWT.NONE); upItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) assignmentsViewer.getSelection(); Assignment selected = (Assignment) selection.getFirstElement(); List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput(); int index = list.indexOf(selected); list.remove(selected); list.add(index - 1, selected); assignmentsViewer.setSelection(new StructuredSelection(selected)); assignmentsViewer.refresh(true); } }); upItem.setEnabled(false); upItem.setText("Up"); final ToolItem downItem = new ToolItem(toolBar, SWT.NONE); downItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) assignmentsViewer.getSelection(); Assignment selected = (Assignment) selection.getFirstElement(); List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput(); int index = list.indexOf(selected); list.remove(selected); list.add(index + 1, selected); assignmentsViewer.setSelection(new StructuredSelection(selected)); assignmentsViewer.refresh(true); } }); downItem.setEnabled(false); downItem.setText("Down"); Composite composite_2 = new Composite(composite_1, SWT.NONE); composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // composite_2.setLayout(new GridLayout(1, false)); assignmentsViewer = new TableViewer(composite_2, SWT.BORDER | SWT.FULL_SELECTION); assignmentsViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() == null) { editItem.setEnabled(false); deleteItem.setEnabled(false); upItem.setEnabled(false); downItem.setEnabled(false); } else { editItem.setEnabled(true); deleteItem.setEnabled(true); List<Assignment> list = (List<Assignment>) assignmentsViewer.getInput(); Assignment selected = (Assignment) (((StructuredSelection) event.getSelection()).getFirstElement()); if (list.indexOf(selected) == 0) { upItem.setEnabled(false); downItem.setEnabled(true); } else if (list.indexOf(selected) == list.size() - 1) { upItem.setEnabled(true); downItem.setEnabled(false); } else { upItem.setEnabled(true); downItem.setEnabled(true); } } } }); table = assignmentsViewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 1)); table.setLinesVisible(true); table.setHeaderVisible(true); TableViewerColumn tableViewerColumn = new TableViewerColumn(assignmentsViewer, SWT.NONE); TableColumn tblclmnNewColumn = tableViewerColumn.getColumn(); tblclmnNewColumn.setWidth(new Double(table.getSize().x * 0.2).intValue()); tblclmnNewColumn.setResizable(true); tblclmnNewColumn.setText("Id"); TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(assignmentsViewer, SWT.NONE); TableColumn tblclmnNewColumn_1 = tableViewerColumn_1.getColumn(); tblclmnNewColumn_1.setWidth(new Double(table.getSize().x * 0.4).intValue()); tblclmnNewColumn_1.setResizable(true); tblclmnNewColumn_1.setText("From"); TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(assignmentsViewer, SWT.NONE); TableColumn tblclmnNewColumn_2 = tableViewerColumn_2.getColumn(); tblclmnNewColumn_2.setResizable(true); tblclmnNewColumn_2.setWidth(new Double(table.getSize().x * 0.4).intValue()); tblclmnNewColumn_2.setText("To"); TableColumnLayout tableColumnLayout = new TableColumnLayout(); tableColumnLayout.setColumnData(tblclmnNewColumn, new ColumnWeightData(20, 50, true)); tableColumnLayout.setColumnData(tblclmnNewColumn_1, new ColumnWeightData(40, 50, true)); tableColumnLayout.setColumnData(tblclmnNewColumn_2, new ColumnWeightData(40, 50, true)); composite_2.setLayout(tableColumnLayout); assignmentsViewer.setContentProvider(new ArrayContentProvider()); assignmentsViewer.setLabelProvider(new AssignmentLabelProvider()); VariableSupport.decorateTextWithVariableSupport(transformationText); transformationText.setFont(FontUtil.INSTANCE.getExpressionFont()); new Label(composite, SWT.NONE); init(); return area; }
@Override protected Control createContents(final Composite ancestor) { loadProperties(); Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; parent.setLayout(layout); if (!isGlobal()) { createLinkToGlobal(ancestor, parent); } Composite innerParent = new Composite(parent, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 2; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; innerParent.setLayout(innerLayout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; innerParent.setLayoutData(gd); Composite tableComposite = new Composite(innerParent, SWT.NONE); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 360; data.heightHint = convertHeightInCharsToPixels(10); tableComposite.setLayoutData(data); TableColumnLayout columnLayout = new TableColumnLayout(); tableComposite.setLayout(columnLayout); Table table = new Table( tableComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); table.setHeaderVisible(true); table.setLinesVisible(true); GC gc = new GC(getShell()); gc.setFont(JFaceResources.getDialogFont()); TableColumn propertyNameColumn = new TableColumn(table, SWT.NONE); propertyNameColumn.setText("Name"); int minWidth = computeMinimumColumnWidth(gc, "Name"); columnLayout.setColumnData(propertyNameColumn, new ColumnWeightData(1, minWidth, true)); TableColumn propertyValueColumn = new TableColumn(table, SWT.NONE); propertyValueColumn.setText(VALUE); minWidth = computeMinimumColumnWidth(gc, VALUE); columnLayout.setColumnData(propertyValueColumn, new ColumnWeightData(1, minWidth, true)); gc.dispose(); fTableViewer = new TableViewer(table); fTableViewer.setLabelProvider(new SonarPropertiesLabelProvider()); fTableViewer.setContentProvider(new SonarPropertiesContentProvider()); fTableViewer.setComparator(null); fTableViewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent e) { edit(); } }); fTableViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent e) { updateButtons(); } }); createButtons(innerParent); fTableViewer.setInput(sonarProperties); updateButtons(); Dialog.applyDialogFont(parent); innerParent.layout(); return parent; }
private void addColumns(TableViewer viewer, TableColumnLayout layout) { TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(Messages.ColumnStatus); column.setLabelProvider( new FormattedLabelProvider() { @Override public Image getImage(ExtractedEntry element) { Images image = null; switch (element.getMaxCode()) { case WARNING: image = Images.WARNING; break; case ERROR: image = Images.ERROR; break; case OK: default: } return image != null ? image.image() : null; } @Override public String getText(ExtractedEntry entry) { return ""; //$NON-NLS-1$ } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(22, true)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(Messages.ColumnDate); column.setLabelProvider( new FormattedLabelProvider() { @Override public String getText(ExtractedEntry entry) { LocalDate date = entry.getItem().getDate(); return date != null ? Values.Date.format(date) : null; } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(Messages.ColumnTransactionType); column.setLabelProvider( new FormattedLabelProvider() { @Override public String getText(ExtractedEntry entry) { return entry.getItem().getTypeInformation(); } @Override public Image getImage(ExtractedEntry entry) { Annotated subject = entry.getItem().getSubject(); if (subject instanceof AccountTransaction) return Images.ACCOUNT.image(); else if (subject instanceof PortfolioTransaction) return Images.PORTFOLIO.image(); else if (subject instanceof Security) return Images.SECURITY.image(); else if (subject instanceof BuySellEntry) return Images.PORTFOLIO.image(); else if (subject instanceof AccountTransferEntry) return Images.ACCOUNT.image(); else if (subject instanceof PortfolioTransferEntry) return Images.PORTFOLIO.image(); else return null; } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(100, true)); column = new TableViewerColumn(viewer, SWT.RIGHT); column.getColumn().setText(Messages.ColumnAmount); column.setLabelProvider( new FormattedLabelProvider() { @Override public String getText(ExtractedEntry entry) { Money amount = entry.getItem().getAmount(); return amount != null ? Values.Money.format(amount) : null; } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true)); column = new TableViewerColumn(viewer, SWT.RIGHT); column.getColumn().setText(Messages.ColumnShares); column.setLabelProvider( new FormattedLabelProvider() { @Override public String getText(ExtractedEntry entry) { return Values.Share.formatNonZero(entry.getItem().getShares()); } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(Messages.ColumnSecurity); column.setLabelProvider( new FormattedLabelProvider() { @Override public String getText(ExtractedEntry entry) { Security security = entry.getItem().getSecurity(); return security != null ? security.getName() : null; } }); layout.setColumnData(column.getColumn(), new ColumnPixelData(250, true)); }
/* * @see org.eclipse.ui.internal.editors.text.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite) */ public Control createControl(Composite parent) { PixelConverter pixelConverter = new PixelConverter(parent); Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); addFiller(composite, 2); String label = TextEditorMessages.HyperlinksEnabled_label; fHyperlinksEnabledCheckBox = addCheckBox( composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, 0); fHyperlinksEnabledCheckBox.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean state = fHyperlinksEnabledCheckBox.getSelection(); fHyperlinkDefaultKeyModifierText.setEnabled(state); fHyperlinkKeyModifierText.setEnabled(state && getSelectedItem() != null); fHyperlinkDetectorsViewer.getTable().setEnabled(state); handleHyperlinkKeyModifierModified(); } public void widgetDefaultSelected(SelectionEvent e) {} }); // Text field for default modifier string label = TextEditorMessages.HyperlinkDefaultKeyModifier_label; fHyperlinkDefaultKeyModifierText = (Text) addTextField( composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, 15, 20, pixelConverter)[1]; fHyperlinkDefaultKeyModifierText.addKeyListener( new KeyListener() { private boolean isModifierCandidate; public void keyPressed(KeyEvent e) { isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0; } public void keyReleased(KeyEvent e) { if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) { // && e.time -time < 1000) { String modifierString = fHyperlinkDefaultKeyModifierText.getText(); Point selection = fHyperlinkDefaultKeyModifierText.getSelection(); int i = selection.x - 1; while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) { i--; } boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER); i = selection.y; while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) { i++; } boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER); String insertString; if (needsPrefixDelimiter && needsPostfixDelimiter) insertString = NLSUtility.format( TextEditorMessages .HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask)); else if (needsPrefixDelimiter) insertString = NLSUtility.format( TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask)); else if (needsPostfixDelimiter) insertString = NLSUtility.format( TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask)); else insertString = Action.findModifierString(e.stateMask); fHyperlinkDefaultKeyModifierText.insert(insertString); } } }); fHyperlinkDefaultKeyModifierText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { handleHyperlinkDefaultKeyModifierModified(); } }); addFiller(composite, 2); Composite editorComposite = new Composite(composite, SWT.NONE); GridData gd; gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.horizontalSpan = 2; gd.horizontalIndent = 20; editorComposite.setLayoutData(gd); TableColumnLayout tableColumnlayout = new TableColumnLayout(); editorComposite.setLayout(tableColumnlayout); // Hyperlink detector table Table hyperlinkDetectorTable = new Table( editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK); hyperlinkDetectorTable.setHeaderVisible(true); hyperlinkDetectorTable.setLinesVisible(true); hyperlinkDetectorTable.setFont(parent.getFont()); hyperlinkDetectorTable.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { handleListSelection(); } public void widgetDefaultSelected(SelectionEvent e) {} }); ColumnLayoutData columnLayoutData = new ColumnWeightData(1); TableColumn nameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 0); nameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_nameColumn); tableColumnlayout.setColumnData(nameColumn, columnLayoutData); TableColumn modifierKeysColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 1); modifierKeysColumn.setText(TextEditorMessages.HyperlinkDetectorTable_modifierKeysColumn); tableColumnlayout.setColumnData(modifierKeysColumn, columnLayoutData); TableColumn targetNameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 2); targetNameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_targetNameColumn); tableColumnlayout.setColumnData(targetNameColumn, columnLayoutData); fHyperlinkDetectorsViewer = new CheckboxTableViewer(hyperlinkDetectorTable); fHyperlinkDetectorsViewer.setUseHashlookup(true); fHyperlinkDetectorsViewer.addCheckStateListener( new ICheckStateListener() { /* * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) */ public void checkStateChanged(CheckStateChangedEvent event) { String id = ((ListItem) event.getElement()).id; if (id == null) return; fStore.setValue(id, !event.getChecked()); } }); fHyperlinkDetectorsViewer.setLabelProvider(new ItemLabelProvider()); fHyperlinkDetectorsViewer.setContentProvider(new ItemContentProvider()); gd = new GridData(SWT.FILL, SWT.FILL, true, false); gd.heightHint = pixelConverter.convertHeightInCharsToPixels(10); fHyperlinkDetectorsViewer.getControl().setLayoutData(gd); // addFiller(composite, 2); // Text field for modifier string label = TextEditorMessages.HyperlinkKeyModifier_label; fHyperlinkKeyModifierText = (Text) addTextField(composite, label, null, 15, 20, pixelConverter)[1]; fHyperlinkKeyModifierText.addKeyListener( new KeyListener() { private boolean isModifierCandidate; public void keyPressed(KeyEvent e) { isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0; } public void keyReleased(KeyEvent e) { if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) { // && e.time -time < 1000) { String modifierString = fHyperlinkKeyModifierText.getText(); Point selection = fHyperlinkKeyModifierText.getSelection(); int i = selection.x - 1; while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) { i--; } boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER); i = selection.y; while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) { i++; } boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER); String insertString; if (needsPrefixDelimiter && needsPostfixDelimiter) insertString = NLSUtility.format( TextEditorMessages .HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask)); else if (needsPrefixDelimiter) insertString = NLSUtility.format( TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask)); else if (needsPostfixDelimiter) insertString = NLSUtility.format( TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask)); else insertString = Action.findModifierString(e.stateMask); fHyperlinkKeyModifierText.insert(insertString); } } }); fHyperlinkKeyModifierText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { handleHyperlinkKeyModifierModified(); } }); return composite; }