List of usage examples for org.eclipse.jface.viewers StructuredSelection isEmpty
@Override public boolean isEmpty()
From source file:com.google.gwt.eclipse.oophm.views.hierarchical.BreadcrumbNavigationView.java
License:Open Source License
private IModelNode getFirstElementInSelection() { StructuredSelection currentSelection = (StructuredSelection) getSelection(); if (currentSelection == null || currentSelection.isEmpty()) { return null; }//from w w w. j a v a 2s. co m return (IModelNode) currentSelection.getFirstElement(); }
From source file:com.google.gwt.eclipse.oophm.views.hierarchical.LaunchConfigurationContent.java
License:Open Source License
private String getSelectedUrl() { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); return selection != null && !selection.isEmpty() ? (String) selection.getFirstElement() : null; }
From source file:com.google.gwt.eclipse.oophm.views.hierarchical.LogContent.java
License:Open Source License
private void updateDetailsPane(SelectionChangedEvent event) { StructuredSelection structuredSelection = (StructuredSelection) event.getSelection(); if (structuredSelection == null || structuredSelection.isEmpty()) { scrolledFormDetailsText.setText(""); return;//from ww w. ja v a 2 s . c o m } LogEntry<?> logEntry = (LogEntry<?>) (structuredSelection.getFirstElement()); Color foregroundColor = logLabelProvider.getForeground(logEntry); scrolledFormDetailsText.setForeground(foregroundColor); LogEntry.Data data = logEntry.getLogData(); StringBuffer buf = new StringBuffer(); buf.append("<p>"); Date logEntryDate = new Date(data.getTimestamp()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); buf.append(simpleDateFormat.format(logEntryDate)); // Add the log level // FIXME: Need coloring here, for error entries. buf.append(" ["); buf.append(logEntry.getLogData().getLogLevel()); buf.append("]"); // Add the module name buf.append(" ["); buf.append(logEntry.getModuleHandle().getName()); buf.append("] "); buf.append(buildLabelHtml(logEntry)); buf.append("<br/>"); // Add the detailed information, if available String details = buildDetailsHtml(logEntry.getLogData().getDetails()); if (details.length() > 0) { buf.append("<br/>"); buf.append(details); buf.append("<br/>"); } /* * Add help information, if available. */ String helpInfoURL = logEntry.getLogData().getHelpInfoURL(); if (helpInfoURL.length() > 0) { String escapedHelpInfoURL = convertToHtmlContent(helpInfoURL); buf.append("<br/>"); buf.append("See the following URL for additional information:<br/>"); buf.append("<br/>"); buf.append("<a href='"); buf.append(escapedHelpInfoURL); buf.append("'>"); buf.append(escapedHelpInfoURL); buf.append("</a>"); buf.append("<br/>"); } else { /* * TODO: We always defer to the Help Info URL, as the Help Info text is in * HTML, and we're not rendering HTML in this region as yet. */ } buf.append("</p>"); String text = buf.toString(); scrolledFormDetailsTextContents = collapseHtmlFormatting(text); scrolledFormDetailsText.setText(text); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.AWSRDSLoginComposite.java
License:Open Source License
/** * Add RDS to Tadpole//w w w. j a v a2s . c o m */ private void addDatabase() { StructuredSelection ss = (StructuredSelection) tvRDS.getSelection(); if (ss.isEmpty()) { MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.AWSRDSLoginComposite_8); } else { AWSRDSUserDBDAO amazonRDSDto = (AWSRDSUserDBDAO) ss.getFirstElement(); SingleAddDBDialog dialog = new SingleAddDBDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), amazonRDSDto, getListGroupName(), getSelGroupName()); dialog.open(); } }
From source file:com.hangum.tadpole.rdb.core.dialog.driver.JDBCDriverManageDialog.java
License:Open Source License
/** * Create contents of the dialog.//from ww w.j av a 2s. c o m * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; SashForm sashForm = new SashForm(container, SWT.NONE); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeLeft = new Composite(sashForm, SWT.NONE); compositeLeft.setLayout(new GridLayout(1, false)); Label lblDriverList = new Label(compositeLeft, SWT.NONE); lblDriverList.setText(Messages.get().JDBCDriverSetting_DriverList); lvDB = new ListViewer(compositeLeft, SWT.BORDER | SWT.V_SCROLL); lvDB.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection ss = (StructuredSelection) lvDB.getSelection(); if (ss.isEmpty()) return; DBDefine dbDefine = (DBDefine) ss.getFirstElement(); jdbc_dir = ApplicationArgumentUtils.JDBC_RESOURCE_DIR + dbDefine.getExt() + PublicTadpoleDefine.DIR_SEPARATOR; lblRealFullPath.setText(jdbc_dir); initDBFileList(); } }); List list = lvDB.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); lvDB.setContentProvider(new ArrayContentProvider()); lvDB.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { DBDefine dbDefine = (DBDefine) element; return dbDefine.getDBToString(); } }); lvDB.setInput(DBDefine.getDriver()); Composite compositeBody = new Composite(sashForm, SWT.NONE); compositeBody.setLayout(new GridLayout(3, false)); Label lblDumy = new Label(compositeBody, SWT.NONE); lblDumy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); Label lblPath = new Label(compositeBody, SWT.NONE); lblPath.setText(Messages.get().JDBCDriverSetting_Path); lblRealFullPath = new Text(compositeBody, SWT.NONE | SWT.READ_ONLY); lblRealFullPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label txtFileList = new Label(compositeBody, SWT.NONE); txtFileList.setText(Messages.get().JDBCDriverSetting_FileList); new Label(compositeBody, SWT.NONE); new Label(compositeBody, SWT.NONE); lvDriverFile = new ListViewer(compositeBody, SWT.BORDER | SWT.V_SCROLL); lvDriverFile.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { btnDelete.setEnabled(true); } }); lvDriverFile.setContentProvider(new ArrayContentProvider()); lvDriverFile.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String str = element.toString(); return str; } }); List listDriver = lvDriverFile.getList(); listDriver.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Composite compositeBodyBtn = new Composite(compositeBody, SWT.NONE); compositeBodyBtn.setLayout(new GridLayout(1, false)); compositeBodyBtn.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1)); btnDelete = new Button(compositeBodyBtn, SWT.NONE); btnDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { StructuredSelection ss = (StructuredSelection) lvDriverFile.getSelection(); if (ss.isEmpty()) return; String strFile = (String) ss.getFirstElement(); if (!MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().Delete)) return; if (logger.isDebugEnabled()) logger.debug("File delete : " + jdbc_dir + strFile); try { FileUtils.forceDelete(new File(jdbc_dir + strFile)); initDBFileList(); } catch (IOException e1) { logger.error("File delete", e1); MessageDialog.openError(getShell(), Messages.get().Error, "File deleteing: " + e1.getMessage()); } } }); btnDelete.setText(Messages.get().Delete); final String url = startUploadReceiver(); pushSession = new ServerPushSession(); fileUpload = new FileUpload(compositeBodyBtn, SWT.NONE); fileUpload.setText(Messages.get().JDBCDriverSetting_JARUpload); fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fileUpload.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fileName = fileUpload.getFileName(); if ("".equals(fileName) || null == fileName) //$NON-NLS-1$ return; if (!MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().SQLiteLoginComposite_17)) return; if (logger.isDebugEnabled()) logger.debug("=[file name]==> " + fileName); pushSession.start(); fileUpload.submit(url); } }); Button btnRefresh = new Button(compositeBodyBtn, SWT.NONE); btnRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initDBFileList(); } }); btnRefresh.setText(Messages.get().Refresh); sashForm.setWeights(new int[] { 3, 7 }); initManager(); return container; }
From source file:com.hangum.tadpole.rdb.core.dialog.resource.ResourceDetailDialog.java
License:Open Source License
/** * Create contents of the dialog.//ww w . j a v a2 s . co m * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; Composite compositeHead = new Composite(container, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeHead.setLayout(new GridLayout(3, false)); Label lblTitle = new Label(compositeHead, SWT.NONE); lblTitle.setText(Messages.get().Title); textTitle = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY); textTitle.setEditable(true); textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textTitle.setText(resourceManagerDao.getName()); new Label(compositeHead, SWT.NONE); Label lblDescription = new Label(compositeHead, SWT.NONE); lblDescription.setText(Messages.get().Description); textDescription = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); textDescription.setEditable(true); GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_textDescription.heightHint = 40; textDescription.setLayoutData(gd_textDescription); textDescription.setText(resourceManagerDao.getDescription()); Button btnModify = new Button(compositeHead, SWT.NONE); btnModify.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if ("".equals(textTitle.getText().trim())) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().ResourceDetailDialog_name_empty); textTitle.setFocus(); return; } if (MessageDialog.openConfirm(getShell(), Messages.get().Confirm, Messages.get().ResourceDetailDialog_delete)) { resourceManagerDao.setName(textTitle.getText()); resourceManagerDao.setDescription(textDescription.getText()); try { TadpoleSystem_UserDBResource.userDbResourceHeadUpdate(resourceManagerDao); // tree refresh if (originalResourceDB != null) { originalResourceDB.setName(textTitle.getText()); originalResourceDB.setDescription(textDescription.getText()); ManagerViewer mv = (ManagerViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(ManagerViewer.ID); mv.refreshResource(originalResourceDB); } } catch (Exception ee) { logger.error("Resource title, desc saveing", ee); MessageDialog.openError(getShell(), Messages.get().Confirm, "Save exception." + ee.getMessage()); } } } }); btnModify.setText(Messages.get().Modified); Composite compositeHeaderUser = new Composite(compositeHead, SWT.NONE); compositeHeaderUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); compositeHeaderUser.setLayout(new GridLayout(4, false)); Label lblUser = new Label(compositeHeaderUser, SWT.NONE); lblUser.setText(Messages.get().User); textUser = new Text(compositeHeaderUser, SWT.BORDER | SWT.READ_ONLY); textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textUser.setText(resourceManagerDao.getUser_name()); Label lblCreateTime = new Label(compositeHeaderUser, SWT.NONE); lblCreateTime.setText(Messages.get().CreatTime); textCreateTime = new Text(compositeHeaderUser, SWT.BORDER | SWT.READ_ONLY); textCreateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textCreateTime.setText(resourceManagerDao.getCreate_time()); SashForm sashForm = new SashForm(container, SWT.BORDER | SWT.VERTICAL); sashForm.setLayout(new GridLayout(1, false)); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tvHistory = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); tvHistory.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection sss = (StructuredSelection) tvHistory.getSelection(); if (sss.isEmpty()) return; UserDBResourceDataDAO userDBResource = (UserDBResourceDataDAO) sss.getFirstElement(); compareWidget.changeDiff(userDBResource.getDatas(), ""); } }); Table table = tvHistory.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TableViewerColumn tvcDate = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnDate = tvcDate.getColumn(); tblclmnDate.setWidth(100); tblclmnDate.setText(Messages.get().Date); TableViewerColumn tvcUser = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnUser = tvcUser.getColumn(); tblclmnUser.setWidth(100); tblclmnUser.setText(Messages.get().User); TableViewerColumn tvcSQL = new TableViewerColumn(tvHistory, SWT.NONE); TableColumn tblclmnSql = tvcSQL.getColumn(); tblclmnSql.setWidth(500); tblclmnSql.setText(Messages.get().SQL); tvHistory.setContentProvider(new ArrayContentProvider()); tvHistory.setLabelProvider(new ResourceHistoryLabelProvider()); // SashForm compositeCompare = new SashForm(sashForm, SWT.NONE); // compositeCompare.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // compositeCompare.setLayout(new GridLayout(2, false)); compareWidget = new TadpoleCompareWidget(sashForm, SWT.BORDER); compareWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // textLeft = new TadpoleEditorWidget(compositeCompare, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", ""); // textLeft.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // // textRight = new TadpoleEditorWidget(compositeCompare, SWT.BORDER, EditorDefine.EXT_DEFAULT, "", ""); // textRight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); sashForm.setWeights(new int[] { 6, 4 }); initUIData(); return container; }
From source file:com.hangum.tadpole.rdb.core.dialog.resource.ResourceDetailDialog.java
License:Open Source License
@Override protected void okPressed() { StructuredSelection iss = (StructuredSelection) tvHistory.getSelection(); if (iss.isEmpty()) return;/*w w w .j a v a 2 s . com*/ Object[] objListSel = iss.toArray(); try { String source = "", target = ""; for (int i = 0; i < objListSel.length; i++) { if (i == 2) break; UserDBResourceDataDAO dao = (UserDBResourceDataDAO) objListSel[i]; if (i == 0) { source = dao.getDatas(); } else { target = dao.getDatas(); } } compareWidget.changeDiff(source, target); } catch (Exception e) { logger.error("Get detail sql", e); //$NON-NLS-1$ } }
From source file:com.jaspersoft.studio.components.customvisualization.creation.wizard.CustomVisualizationComponentListPage.java
License:Open Source License
/** * Get the first (and the only one) checked module inside the table * /*from w ww. j ava 2s . c om*/ * @return the checked module inside the table or null if no module is * checked */ public ModuleDefinition getSelectedModule() { ISelection selection = viewer.getSelection(); if (selection != null && selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; if (!ss.isEmpty()) return (ModuleDefinition) ss.getFirstElement(); } return null; }
From source file:com.jaspersoft.studio.property.dataset.dialog.ParametersTable.java
License:Open Source License
private void createControl(Composite parent) { composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setBackground(background); composite.setBackgroundMode(SWT.INHERIT_FORCE); wtable = new Table(composite, SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 100;/* w w w.j ava2 s . c o m*/ wtable.setLayoutData(gd); wtable.setHeaderVisible(true); wtable.setLinesVisible(true); TableColumn[] col = new TableColumn[4]; col[0] = new TableColumn(wtable, SWT.NONE); col[0].setText(Messages.ParametersTable_name); col[1] = new TableColumn(wtable, SWT.NONE); col[1].setText(Messages.ParametersTable_isForPrompt); col[2] = new TableColumn(wtable, SWT.NONE); col[2].setText(Messages.ParametersTable_class); col[3] = new TableColumn(wtable, SWT.NONE); col[3].setText(Messages.ParametersTable_description); for (TableColumn tc : col) tc.pack(); TableLayout tlayout = new TableLayout(); tlayout.addColumnData(new ColumnWeightData(25, false)); tlayout.addColumnData(new ColumnWeightData(25, false)); tlayout.addColumnData(new ColumnWeightData(25, false)); tlayout.addColumnData(new ColumnWeightData(25, false)); wtable.setLayout(tlayout); tviewer = new TableViewer(wtable); tviewer.setContentProvider(new ListContentProvider()); tviewer.setLabelProvider(new TLabelProvider()); attachCellEditors(tviewer, wtable); UIUtil.setViewerCellEditingOnDblClick(tviewer); Composite bGroup = new Composite(composite, SWT.NONE); bGroup.setLayout(new GridLayout(1, false)); bGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL)); bGroup.setBackground(background); new NewButton() { @Override protected void afterElementAdded(Object selement) { try { dataset.removeParameter((JRParameter) selement); dataset.addParameter((JRDesignParameter) selement); fireModifyListeners(); } catch (JRException e) { e.printStackTrace(); } } }.createNewButtons(bGroup, tviewer, new INewElement() { public Object newElement(List<?> input, int pos) { JRDesignParameter f = new JRDesignParameter(); f.setName(getName()); f.setValueClass(String.class); return f; } private String getName() { List<JRDesignParameter> list = (List<JRDesignParameter>) tviewer.getInput(); String name = "Parameter"; //$NON-NLS-1$ boolean match = false; String tmp = name; for (int i = 1; i < 100000; i++) { tmp = name + i;// ModelUtils.getNameFormat(name, i); for (JRDesignParameter f : list) { match = f.getName().equals(tmp); if (match) break; } if (!match) break; } return tmp; } }); final DeleteButton delb = new DeleteButton() { @Override protected void afterElementDeleted(Object element) { JRParameter todel = null; for (JRParameter p : dataset.getParametersList()) if (p.getName().equals(((JRDesignParameter) element).getName())) { todel = p; break; } if (todel != null) { dataset.removeParameter(todel); fireModifyListeners(); } } }; delb.createDeleteButton(bGroup, tviewer); List<JRParameter> fields = dataset.getParametersList(); if (fields == null) fields = new ArrayList<JRParameter>(); setFields(fields); tviewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection sel = (StructuredSelection) event.getSelection(); if (!sel.isEmpty()) { JRDesignParameter prm = (JRDesignParameter) sel.getFirstElement(); delb.setEnabled(!prm.isSystemDefined()); } } }); tviewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { TemplateTransfer.getInstance(), PluginTransfer.getInstance() }, new NodeDragListener(tviewer)); }
From source file:com.kdmanalytics.toif.report.internal.contributionItems.TraceContributionItem.java
License:Open Source License
/** * generate contribution items for the selection. *//*from w ww . ja v a 2 s . c om*/ @Override protected IContributionItem[] getContributionItems() { Object selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection(); if (!(selection instanceof StructuredSelection)) { return EMPTY; } StructuredSelection ss = (StructuredSelection) selection; if (ss.isEmpty()) { return EMPTY; } Object element = ss.getFirstElement(); if (!(element instanceof IToifReportEntry)) { return EMPTY; } IToifReportEntry entry = (IToifReportEntry) element; final IFindingEntry fEntry = entry.getFindingEntry(); List<Trace> traces = fEntry.getTraces(); List<CommandContributionItem> list = new ArrayList<CommandContributionItem>(); //for each of the traces for this finding entry. make contribution items for it. for (Trace trace : traces) { CommandContributionItemParameter param = new CommandContributionItemParameter( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), CONTRIBUTION_ID, COMMAND_ID, CommandContributionItem.STYLE_PUSH); final String lineNumber = trace.getLineNumber(); param.label = lineNumber; Map<Object, Object> parameters = Maps.newHashMap(); parameters.put(LINE_NUMBER_KEY, lineNumber); param.parameters = parameters; list.add(new CommandContributionItem(param)); } return list.toArray(new IContributionItem[] {}); }