Package net.sf.logsaw.ui.model

Examples of net.sf.logsaw.ui.model.NamedFilter


      /* (non-Javadoc)
       * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
       */
      @Override
      public String getText(Object element) {
        NamedFilter flt = (NamedFilter) element;
        return flt.getName();
      }
    });
    namedFiltersViewer.setInput(namedFilters.toArray());
    namedFiltersViewer.setComparator(new ViewerComparator());
    namedFiltersViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      /* (non-Javadoc)
       * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
       */
      @Override
      public void selectionChanged(SelectionChangedEvent e) {
        IStructuredSelection sel = (IStructuredSelection) e.getSelection();
        NamedFilter flt = (NamedFilter) sel.getFirstElement();
        if (flt != null) {
          // Delete button is only enabled when a fresh filter is selected
          deleteButton.setEnabled(true);
          clearContents();
          // Set restrictions to load
          restrictions = new ArrayList<ARestriction<?>>(flt.getRestrictions());
          updateContents(false);
        }
      }
    });
    namedFiltersViewer.getCombo().addModifyListener(new ModifyListener() {
      /* (non-Javadoc)
       * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
       */
      @Override
      public void modifyText(ModifyEvent e) {
        updateSaveButton();
        // Delete button is being disabled as soon as the text is modified
        deleteButton.setEnabled(false);
        try {
          save();
        } catch (CoreException ce) {
          // Log and show error
          UIPlugin.logAndShowError(ce, true);
        }
      }
    });
    saveButton = new Button(group, SWT.NONE);
    saveButton.setText(Messages.FilterSettingsDialog_label_save);
    saveButton.addSelectionListener(new SelectionAdapter() {
      /* (non-Javadoc)
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       */
      @Override
      public void widgetSelected(SelectionEvent e) {
        NamedFilter flt = doFindNamedFilter();
        if (flt != null) {
          if (MessageDialog.openQuestion(getShell(),
              Messages.FilterSettingsDialog_confirm_title,
              Messages.FilterSettingsDialog_confirm_question)) {
            // Remove old
            namedFilters.remove(flt);
          } else {
            // Abort saving
            return;
          }
        }
        flt = new NamedFilter();
        flt.setName(namedFiltersViewer.getCombo().getText().trim());
        flt.setRestrictions(doGetRestrictions());
        namedFilters.add(flt);
        namedFiltersViewer.setInput(namedFilters.toArray());
        try {
          save();
        } catch (CoreException ce) {
          // Log and show error
          UIPlugin.logAndShowError(ce, true);
        }
      }
    });
    deleteButton = new Button(group, SWT.NONE);
    deleteButton.setText(Messages.FilterSettingsDialog_label_delete);
    deleteButton.addSelectionListener(new SelectionAdapter() {
      /* (non-Javadoc)
       * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       */
      @Override
      public void widgetSelected(SelectionEvent e) {
        NamedFilter flt = doFindNamedFilter();
        namedFilters.remove(flt);
        namedFiltersViewer.setInput(namedFilters.toArray());
      }
    });
    deleteButton.setEnabled(false);
View Full Code Here


  private NamedFilter doFindNamedFilter() {
    String name = namedFiltersViewer.getCombo().getText().trim();
    Iterator<NamedFilter> it = namedFilters.iterator();
    while (it.hasNext()) {
      NamedFilter flt = it.next();
      if (name.equals(flt.getName())) {
        return flt;
      }
    }
    return null;
  }
View Full Code Here

              Date val = fld.fromInputValue(clauseElem.getTextData(), log);
              restrictions.add(rf.newRestriction(fld, op, val));
            }
          });
        }
        NamedFilter flt = new NamedFilter();
        flt.setName(name);
        flt.setRestrictions(restrictions);
        namedFilters.add(flt);
      }
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.logsaw.ui.model.NamedFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.