@Override
 public void setInput(Tree properties, Tile tile) {
   for (final TreeItem item : properties.getItems()) {
     clear(item);
   }
   properties.setData(tile);
   for (final PropertiesProviderTile provider : providersTile) {
     provider.setInput(properties, tile);
   }
   for (final TreeItem item : properties.getItems()) {
     UtilSwt.autoSize(item);
   }
 }
 @Override
 public void setInput(Tree properties, Configurer configurer) {
   for (final TreeItem item : properties.getItems()) {
     clear(item);
   }
   properties.setData(configurer);
   if (configurer != null) {
     for (final PropertiesProviderObject provider : providersObject) {
       provider.setInput(properties, configurer);
     }
   }
   for (final TreeItem item : properties.getItems()) {
     UtilSwt.autoSize(item);
   }
 }
  @Override
  public void createPartControl(Composite parent) {
    GridLayout gl_parent = new GridLayout(1, false);
    gl_parent.verticalSpacing = 1;
    gl_parent.marginHeight = 1;
    gl_parent.horizontalSpacing = 1;
    gl_parent.marginWidth = 1;
    parent.setLayout(gl_parent);

    Composite compositeToolbar = new Composite(parent, SWT.NONE);
    compositeToolbar.setLayout(new GridLayout(1, false));
    compositeToolbar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    ToolBar toolBar = new ToolBar(compositeToolbar, SWT.FLAT | SWT.RIGHT);
    GridData gd_toolBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_toolBar.widthHint = 267;
    toolBar.setLayoutData(gd_toolBar);

    ToolItem tltmRefresh = new ToolItem(toolBar, SWT.NONE);
    tltmRefresh.setToolTipText("Refresh");
    tltmRefresh.setImage(
        ResourceManager.getPluginImage(
            Activator.PLUGIN_ID, "resources/icons/refresh.png")); // $NON-NLS-1$
    tltmRefresh.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            comboViewer.getCombo().clearSelection();
            textTitle.setText("");
            textDescription.setText("");
            textQuery.setText("");

            initUI();
            // reLoadResource();
          }
        });

    SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    columnFilter = new DefaultTableColumnFilter();

    SashForm sashForm_1 = new SashForm(sashForm, SWT.NONE);

    treeViewer = new TreeViewer(sashForm_1, SWT.BORDER);
    Tree treeDatabase = treeViewer.getTree();
    treeDatabase.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    Composite composite_1 = new Composite(sashForm_1, SWT.NONE);
    composite_1.setLayout(new GridLayout(1, false));

    Composite composite_2 = new Composite(composite_1, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    GridData gd_composite_2 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_composite_2.heightHint = 28;
    composite_2.setLayoutData(gd_composite_2);

    Label lblFilter = new Label(composite_2, SWT.NONE);
    lblFilter.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblFilter.setText("Filter");

    textFilter = new Text(composite_2, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SEARCH | SWT.CANCEL);
    textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textFilter.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.Selection) {
              columnFilter.setSearchString(textFilter.getText());
              tableViewer.refresh();
            }
          }
        });

    tableViewer = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION);
    tableResource = tableViewer.getTable();
    tableResource.setHeaderVisible(true);
    tableResource.setLinesVisible(true);
    tableResource.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sashForm_1.setWeights(new int[] {230, 359});
    tableViewer.addFilter(columnFilter);

    Group grpQuery = new Group(sashForm, SWT.NONE);
    grpQuery.setText("Query");
    GridLayout gl_grpQuery = new GridLayout(1, false);
    gl_grpQuery.verticalSpacing = 1;
    gl_grpQuery.horizontalSpacing = 1;
    gl_grpQuery.marginHeight = 1;
    gl_grpQuery.marginWidth = 1;
    grpQuery.setLayout(gl_grpQuery);

    Composite composite = new Composite(grpQuery, SWT.NONE);
    GridLayout gl_composite = new GridLayout(6, false);
    gl_composite.marginHeight = 2;
    gl_composite.marginWidth = 2;
    gl_composite.verticalSpacing = 2;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("Share");

    comboViewer = new ComboViewer(composite, SWT.NONE);
    comboShare = comboViewer.getCombo();
    comboShare.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboShare.setItems(new String[] {"PUBLIC", "PRIVATE"});

    Label lblNewLabel_1 = new Label(composite, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel_1.setText("Title");

    textTitle = new Text(composite, SWT.BORDER);
    textTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button btnSave = new Button(composite, SWT.NONE);
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // TODO : SAVE...공유 구분및 제목 변경.
            if (tableViewer.getSelection().isEmpty()) return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            try {
              String share_type = comboShare.getText();
              share_type = (share_type == null || "".equals(share_type)) ? "PUBLIC" : share_type;
              dao.setShared_type(share_type);
              dao.setRes_title(textTitle.getText());
              dao.setDescription(textDescription.getText());
              TadpoleSystem_UserDBResource.updateResourceHeader(dao);
              // reLoadResource();
              addUserResouceData();
            } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    btnSave.setText("Save");

    Button btnDelete = new Button(composite, SWT.NONE);
    btnDelete.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // TODO : DELYN SET TO 'YES'
            if (tableViewer.getSelection().isEmpty()) return;

            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            ResourceManagerDAO dao = (ResourceManagerDAO) ss.getFirstElement();

            // 기존에 사용하던 좌측 트리(디비목록)에 리소스를 표시하지 않을 경우에는 dao를 통일해서 하나만 쓰게 수정이
            // 필요함.
            UserDBResourceDAO userDBResource = new UserDBResourceDAO();
            userDBResource.setResource_seq((int) dao.getResource_seq());
            userDBResource.setName(dao.getRes_title());
            userDBResource.setParent(userDB);

            try {
              TadpoleSystem_UserDBResource.delete(userDBResource);
            } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    btnDelete.setText("Delete");

    Label lblDescription = new Label(composite, SWT.NONE);
    lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDescription.setText("Description");

    textDescription =
        new Text(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1);
    gd_textDescription.heightHint = 44;
    textDescription.setLayoutData(gd_textDescription);

    textQuery =
        new Text(
            composite,
            SWT.BORDER
                | SWT.READ_ONLY
                | SWT.WRAP
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.CANCEL
                | SWT.MULTI);
    textQuery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 1));
    sashForm.setWeights(new int[] {179, 242});

    createTableColumn();

    initUI();
  }
Exemple #4
0
  private Section createFileSection(Composite container) {
    Section filesSection =
        toolkit.createSection(
            container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
    Composite filesArea = toolkit.createComposite(filesSection);
    filesSection.setClient(filesArea);
    toolkit.paintBordersFor(filesArea);
    GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);

    ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);

    filesSection.setTextClient(filesToolbar);

    PatternFilter patternFilter =
        new PatternFilter() {
          @Override
          protected boolean isLeafMatch(Viewer viewer, Object element) {
            if (element instanceof CommitItem) {
              CommitItem commitItem = (CommitItem) element;
              return wordMatches(commitItem.path);
            }
            return super.isLeafMatch(viewer, element);
          }
        };
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredCheckboxTree resourcesTreeComposite =
        new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {
          @Override
          protected WorkbenchJob doCreateRefreshJob() {
            // workaround for file filter not having an explicit change
            // listener
            WorkbenchJob filterJob = super.doCreateRefreshJob();
            filterJob.addJobChangeListener(
                new JobChangeAdapter() {
                  public void done(IJobChangeEvent event) {
                    if (event.getResult().isOK()) {
                      getDisplay()
                          .asyncExec(
                              new Runnable() {
                                public void run() {
                                  updateFileSectionText();
                                }
                              });
                    }
                  }
                });
            return filterJob;
          }
        };
    Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
    resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    resourcesTreeComposite.setLayoutData(
        GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());

    resourcesTree.addSelectionListener(new CommitItemSelectionListener());

    resourcesTree.setHeaderVisible(true);
    TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
    statCol.setText(UIText.CommitDialog_Status);
    statCol.setWidth(150);
    statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));

    TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
    resourceCol.setText(UIText.CommitDialog_Path);
    resourceCol.setWidth(415);
    resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));

    filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
    new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
    new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
    ColumnViewerToolTipSupport.enableFor(filesViewer);
    filesViewer.setContentProvider(new CommitFileContentProvider());
    filesViewer.setUseHashlookup(true);
    IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
    if (settings.get(SHOW_UNTRACKED_PREF) != null) {
      // note, no matter how the dialog settings are, if
      // the preferences force us to include untracked files
      // we must show them
      showUntracked =
          Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue()
              || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
    }

    filesViewer.addFilter(new CommitItemFilter());
    filesViewer.setInput(items.toArray());
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(createContextMenuListener());
    filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
    filesViewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            updateFileSectionText();
          }
        });

    showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
    Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
    UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
    showUntrackedItem.setImage(showUntrackedImage);
    showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
    showUntrackedItem.setSelection(showUntracked);
    showUntrackedItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            showUntracked = showUntrackedItem.getSelection();
            filesViewer.refresh(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image checkImage = UIIcons.CHECK_ALL.createImage();
    UIUtils.hookDisposal(checkAllItem, checkImage);
    checkAllItem.setImage(checkImage);
    checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
    checkAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(true);
            updateFileSectionText();
            updateMessage();
          }
        });

    ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
    UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
    uncheckAllItem.setImage(uncheckImage);
    uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
    uncheckAllItem.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(false);
            updateFileSectionText();
            updateMessage();
          }
        });

    if (!allowToChangeSelection) {
      amendingItem.setSelection(false);
      amendingItem.setEnabled(false);
      showUntrackedItem.setSelection(false);
      showUntrackedItem.setEnabled(false);
      checkAllItem.setEnabled(false);
      uncheckAllItem.setEnabled(false);

      filesViewer.addCheckStateListener(
          new ICheckStateListener() {

            public void checkStateChanged(CheckStateChangedEvent event) {
              if (!event.getChecked()) filesViewer.setAllChecked(true);
              updateFileSectionText();
            }
          });
      filesViewer.setAllChecked(true);
    } else {
      final boolean includeUntracked =
          getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
      for (CommitItem item : items) {
        if (!preselectAll && !preselectedFiles.contains(item.path)) continue;
        if (item.status == Status.ASSUME_UNCHANGED) continue;
        if (!includeUntracked && item.status == Status.UNTRACKED) continue;
        filesViewer.setChecked(item, true);
      }
    }
    statCol.pack();
    resourceCol.pack();
    return filesSection;
  }