Java Code Examples for com.google.gwt.user.client.ui.Anchor#addClickHandler()

The following examples show how to use com.google.gwt.user.client.ui.Anchor#addClickHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UTCTimeBoxImplHtml4.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
public TimeBoxMenuOption(long offsetFromMidnight) {
    this.offsetFromMidnight = offsetFromMidnight;

    // format the time in the local time zone
    long time = UTCDateBox.timezoneOffsetMillis(new Date(0)) + offsetFromMidnight;
    value = timeFormat.format(new Date(time));

    Anchor anchor = new Anchor(value);
    anchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            acceptValue();
            hideMenu();
            clearInvalidStyle();
        }

    });
    setWidget(anchor);
}
 
Example 2
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyYoutubeButton()
{
    Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_youtube"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndWikiButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomYoutubeUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("https://www.youtube.com");
                }
            });

        }
    });
}
 
Example 3
Source File: UniTimeDialogBox.java    From unitime with Apache License 2.0 6 votes vote down vote up
public UniTimeDialogBox(boolean autoHide, boolean modal) {
      super(autoHide, modal);
      
setAnimationEnabled(true);
setGlassEnabled(true);
	
      iContainer = new FlowPanel();
      iContainer.addStyleName("dialogContainer");
      
      iClose = new Anchor();
  	iClose.setTitle(MESSAGES.hintCloseDialog());
      iClose.setStyleName("close");
      iClose.addClickHandler(new ClickHandler() {
      	@Override
          public void onClick(ClickEvent event) {
              onCloseClick(event);
          }
      });
      iClose.setVisible(autoHide);

      iControls = new FlowPanel();
      iControls.setStyleName("dialogControls");        
      iControls.add(iClose);
  }
 
Example 4
Source File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
public Anchor buildClick() {
	Anchor anchor = new Anchor();

	if (image != null) {
		anchor.getElement().appendChild(image.getElement());
	}
	if (text != null) {
		anchor.setText(text);
	}
	if (title != null) {
		anchor.setTitle(title);
	}
	if (clickHandler != null) {
		anchor.addClickHandler(clickHandler);
	}

	return anchor;
}
 
Example 5
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyGoogleButton()
{
    Anchor rndGoogleButton = Anchor.wrap(Document.get().getElementById("btn_rnd_google"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndGoogleButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomGoogleUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("google: hot trend");
                }
            });

        }
    });
}
 
Example 6
Source File: TractionDialogBox.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
public TractionDialogBox(boolean autoHide, boolean modal, boolean showCloseIcon) {
super(autoHide, modal, new TractionCaption());

container = new SimplePanel();
container.addStyleName("dialogContainer");

close = new Anchor();
close.setStyleName("x");
close.addClickHandler(new ClickHandler() {
           @Override
           public void onClick(ClickEvent event) {
               onCloseClick(event);
           }
});
setCloseIconVisible(showCloseIcon);

controls = new FlowPanel();
controls.setStyleName("dialogControls");
controls.add(close);

// add the controls to the end of the caption
TractionCaption caption = (TractionCaption) getCaption();
caption.add(controls);
   }
 
Example 7
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private void createLuckyTwitterButton()
{
    Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_twitter"));
    final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    rndWikiButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            wcService.getRandomTwitterUrl(new AsyncCallback<String>()
            {
                public void onSuccess(String result)
                {
                    textArea.setText(result);
                }

                public void onFailure(Throwable caught)
                {
                    textArea.setText("twitter: hot trend");
                }
            });

        }
    });
}
 
Example 8
Source File: SSOAccessControlView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Widget createWidget() {

    VerticalPanel panel = new VerticalPanel();
    panel.add(new ContentHeaderLabel("Access Control"));
    
    ContentDescription description = new ContentDescription(Console.CONSTANTS.sso_access_control_description());

    String text = "<span title=\"" + Console.CONSTANTS.sso_access_control_service_title()
            + "\">" + Console.CONSTANTS.sso_access_control_service_title() + "</span>: <a href=\"" 
            + BootstrapContext.retrieveSsoAuthUrl() + "\" target=\"_blank\">" + BootstrapContext.retrieveSsoAuthUrl() 
            + "</a>";

    Anchor userProfileAnchor = new Anchor(Console.CONSTANTS.sso_access_control_user_profile());
    userProfileAnchor.addClickHandler(clickEvent -> {
        String userMgmt = SSOUtils.getSsoUserManagementUrl();
        Window.Location.replace(userMgmt);
    });
    
    ContentDescription ssoLink = new ContentDescription(text);
    panel.add(description);
    panel.add(userProfileAnchor);
    panel.add(ssoLink);

    VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.setStyleName("rhs-content-panel");
    outerPanel.add(panel);

    DefaultTabLayoutPanel tabLayoutPanel = new DefaultTabLayoutPanel(40, Style.Unit.PX);
    tabLayoutPanel.addStyleName("default-tabpanel");
    tabLayoutPanel.add(outerPanel, "Access Control");
    return tabLayoutPanel;
}
 
Example 9
Source File: DeploymentBrowseContentView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void browseContent(List<ModelNode> contentItems) {

    panel.clear();
    List<ModelNode> contents = new ArrayList<>(contentItems);
    Collections.sort(contents, new Comparator<ModelNode>() {
        @Override
        public int compare(final ModelNode o1, final ModelNode o2) {
            return o1.get(PATH).asString().compareTo(o2.get(PATH).asString());
        }
    });
    
    for (ModelNode file: contents) {
        String contentFile = file.get(PATH).asString();
        boolean isDirectory = file.get("directory").asBoolean();
        long fileLength = 0;
        if (isDirectory) 
            continue;
        else
            fileLength = file.get("file-size").asLong();
        
        String fileLengthDisplay = "";
        if (fileLength > 0) 
            fileLengthDisplay = formatFileUnits(fileLength);
        
        Anchor anchor = new Anchor(contentFile + " | " + fileLengthDisplay);
        anchor.addClickHandler(clickEvent -> {
            Anchor sourceAnchor = (Anchor) clickEvent.getSource();
            String filepath = sourceAnchor.getText();
            // retrieve only the path portion
            filepath = filepath.substring(0, filepath.lastIndexOf('|') - 1);
            presenter.downloadFile(filepath);
        });
                
        panel.add(anchor);
    }
}
 
Example 10
Source File: ApiCallStatsPage.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a link with the text being the specified google account and which when clicked
 * opens the complete API call stats of the specified account.
 * @param googleAccount google account to create a link for
 * @return the created new link
 */
public static Anchor createLinkForOpenGoogleAccount( final String googleAccount ) {
	final Anchor googleAccountAnchor = new Anchor( googleAccount );
	
	googleAccountAnchor.setTitle( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER.toString() );
	googleAccountAnchor.addClickHandler( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER );
	
	return googleAccountAnchor;
}
 
Example 11
Source File: YoungAndroidPalettePanel.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void initExtensionPanel() {
  Anchor addComponentAnchor = new Anchor(MESSAGES.importExtensionMenuItem());
  addComponentAnchor.setStylePrimaryName("ode-ExtensionAnchor");
  addComponentAnchor.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      new ComponentImportWizard().center();
    }
  });

  categoryPanels.get(ComponentCategory.EXTENSION).add(addComponentAnchor);
  categoryPanels.get(ComponentCategory.EXTENSION).setCellHorizontalAlignment(
      addComponentAnchor, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 12
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refresh proposed query row
 *
 * @param propose
 */
private void refreshProposedQueryRow(final GWTProposedQueryReceived propose, int row) {
	boolean seen = (propose.getSeenDate() == null);
	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(row, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(row, 0, "");
	}

	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(row, 2, UtilComunicator.getTextAsBoldHTML(queryType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(queryName, seen));
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(row, 4, anchor);
}
 
Example 13
Source File: LienzoDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void addFilterReset() {
    Anchor anchor = new Anchor(LienzoDisplayerConstants.INSTANCE.resetAnchor());
    filterPanel.add(anchor);
    anchor.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getPresenter().onFilterResetClicked();
        }
    });
}
 
Example 14
Source File: HasFileStatInfoTablePage.java    From sc2gears with Apache License 2.0 4 votes vote down vote up
private void renderInfoRow( final FileStatInfo info, final FlexTable table, final ClickHandler googleAccountClickHandler ) {
	final CellFormatter cellFormatter = table.getCellFormatter();
	final RowFormatter  rowFormatter  = table.getRowFormatter();
	
	int column = 0;
	
	table.setWidget( row, column++, new Label( userCounter + "." ) );
	cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT );
	
	final VerticalPanel userPanel = new VerticalPanel();
	if ( info.getAddressedBy() != null )
		userPanel.add( ClientUtils.styledWidget( new Label( info.getAddressedBy() + ", "
			+ ( info.getCountry() == null ? "-" : info.getCountry() ) ), "explanation" ) );
	if ( googleAccountClickHandler == null || userCounter == 0 )
		userPanel.add( new Label( info.getGoogleAccount() ) );
	else {
		final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() );
		googleAccountAnchor.setTitle( googleAccountClickHandler.toString() );
		googleAccountAnchor.addClickHandler( googleAccountClickHandler );
		userPanel.add( googleAccountAnchor );
	}
	userPanel.add( ClientUtils.styledWidget( ClientUtils.createTimestampWidget( "Updated: ", info.getUpdated() ), "explanation" ) );
	userPanel.add( ClientUtils.styledWidget( new Label(
		( info.getAccountCreated() == null ? "" : "Created: " + ClientUtils.DATE_FORMAT.format( info.getAccountCreated() ) + ", " )
		+ "Pkg: " + info.getDbPackageName() + ";" ), "explanation" ) );
	if ( info.getComment() != null ) {
		final Label commentLabel = new Label();
		if ( info.getComment().length() <= 40 )
			commentLabel.setText( info.getComment() );
		else {
			commentLabel.setText( info.getComment().substring( 0, 40 ) + "..." );
			commentLabel.setTitle( info.getComment() );
		}
		userPanel.add( ClientUtils.styledWidget( commentLabel, "explanation" ) );
	}
	table.setWidget( row, column++, userPanel );
	
	final Widget dbPackageWidget = info.getDbPackageIcon() == null ? new Label( info.getDbPackageName() ) : new Image( info.getDbPackageIcon() );
	dbPackageWidget.setTitle( "Available storage: " + NUMBER_FORMAT.format( info.getPaidStorage() ) + " bytes" );
	table.setWidget( row, column++, dbPackageWidget );
	int rowSpan = 1;
	if ( info.getRepCount  () > 0 ) rowSpan++;
	if ( info.getSmpdCount () > 0 ) rowSpan++;
	if ( info.getOtherCount() > 0 ) rowSpan++;
	if ( rowSpan > 1 )
		for ( int i = column - 1; i >= 0; i-- )
			table.getFlexCellFormatter().setRowSpan( row, i, rowSpan );
	userCounter++;
	
	for ( int type = 0; type < 4; type++ ) {
		String fileType = null;
		int    count    = 0;
		long   storage  = 0;
		switch ( type ) {
		case 0 : count = info.getAllCount(); storage = info.getAllStorage(); fileType = "<all>"; break;
		case 1 : if ( ( count = info.getRepCount  () ) == 0 ) continue; storage = info.getRepStorage  (); fileType = "rep"  ; column = 0; break;
		case 2 : if ( ( count = info.getSmpdCount () ) == 0 ) continue; storage = info.getSmpdStorage (); fileType = "smpd" ; column = 0; break;
		case 3 : if ( ( count = info.getOtherCount() ) == 0 ) continue; storage = info.getOtherStorage(); fileType = "other"; column = 0; break;
		}
		table.setWidget( row, column++, new Label( fileType ) );
		final int firstNumberColumn = column;
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count ) ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( storage ) + " bytes" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count == 0 ? 0 : storage / count ) + " bytes" ) );
		final int usedPercent = info.getPaidStorage() == 0 ? 0 : (int) ( storage * 100 / info.getPaidStorage() );
		table.setWidget( row, column++, new Label( usedPercent + "%" ) );
		
		for ( int i = column - 1; i >= firstNumberColumn; i-- )
			cellFormatter.setHorizontalAlignment( row, i, HasHorizontalAlignment.ALIGN_RIGHT );
		
		rowFormatter.addStyleName( row, userCounter == 1 ? "gold" : ( userCounter & 0x01 ) == 0 ? "row0" : "row1" );
		
		row++;
	}
}
 
Example 15
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed subscription sent row
 *
 * @param propose
 */
private void addProposedSubscriptionSentRow(final GWTProposedSubscriptionSent propose) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	dataTable.setHTML(rows, 0, "");
	dataTable.setHTML(rows, 1, propose.getFrom());
	String docType = "";

	if (propose.getType().equals(GWTFolder.TYPE)) {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.folder");
	} else {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.document");
	}

	dataTable.setHTML(rows, 2, docType);
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, dtf.format(propose.getSentDate()));

	Anchor anchor = new Anchor();
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(path);
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 16
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed subscription received row
 *
 * @param propose
 */
private void addProposedSubscriptionReceivedRow(final GWTProposedSubscriptionReceived propose) {
	int rows = dataTable.getRowCount();
	boolean seen = (propose.getSeenDate() == null);
	dataTable.insertRow(rows);

	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(rows, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(rows, 0, "");
	}

	dataTable.setHTML(rows, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String docType = "";
	if (propose.getType().equals(GWTFolder.TYPE)) {

		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.folder");
	} else {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.document");
	}
	dataTable.setHTML(rows, 2, UtilComunicator.getTextAsBoldHTML(docType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));

	Anchor anchor = new Anchor();
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(path, seen));
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 17
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addMail
 */
public static void addMail(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTMail mail = staple.getMail();

	// Mail is never checkout or subscribed ( because can not be changed )
	table.setHTML(row, 0, "&nbsp;");

	if (mail.getAttachments().size() > 0) {
		table.setHTML(row, 1, Util.imageItemHTML("img/email_attach.gif"));
	} else {
		table.setHTML(row, 1, Util.imageItemHTML("img/email.gif"));
	}

	Anchor anchor = new Anchor();
	anchor.setHTML(mail.getSubject());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			String docPath = mail.getPath();
			String path = docPath.substring(0, docPath.lastIndexOf("/"));
			GeneralComunicator.openPath(path, docPath);
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, Util.formatSize(mail.getSize()));


	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 18
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addFolder
 */
public static void addFolder(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTFolder folder = staple.getFolder();

	// Subscribed is a special case, must add icon with others
	if (folder.isSubscribed()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/subscribed.gif"));
	} else {
		table.setHTML(row, 0, "&nbsp;");
	}

	// Looks if must change icon on parent if now has no childs and properties with user security atention
	if ((folder.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE) {
		if (folder.isHasChildren()) {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_childs.gif"));
		} else {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_empty.gif"));
		}
	} else {
		if (folder.isHasChildren()) {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_childs_ro.gif"));
		} else {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_empty_ro.gif"));
		}
	}

	Anchor anchor = new Anchor();
	anchor.setHTML(folder.getName());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			GeneralComunicator.openPath(folder.getPath(), null);
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, "&nbsp;");

	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 19
Source File: WordCloudApp.java    From swcv with MIT License 4 votes vote down vote up
private void createShowAdvancedButton()
{
    final String COOKIE_NAME = "show-adv-options";

    final Anchor showAdvancedButton = Anchor.wrap(Document.get().getElementById("adv_link"));
    final Panel settingArea = RootPanel.get("settingContainer");

    showAdvancedButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            if (showAdvancedButton.getText().equals("Show Advanced Options"))
            {
                settingArea.removeStyleName("hide");
                showAdvancedButton.setText("Hide Advanced Options");
                Cookies.setCookie(COOKIE_NAME, "1", new Date(System.currentTimeMillis() + (86400 * 7 * 1000)));
            }
            else
            {
                settingArea.addStyleName("hide");
                showAdvancedButton.setText("Show Advanced Options");
                Cookies.removeCookie(COOKIE_NAME);
            }
        }
    });

    boolean needToShow = "1".equals(Cookies.getCookie(COOKIE_NAME));
    if (needToShow)
        showAdvancedButton.fireEvent(new GwtEvent<ClickHandler>()
        {
            @Override
            public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType()
            {
                return ClickEvent.getType();
            }

            @Override
            protected void dispatch(ClickHandler handler)
            {
                handler.onClick(null);
            }
        });
}
 
Example 20
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addDocument
 */
public static void addDocument(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTDocument doc = staple.getDoc();

	if (doc.isCheckedOut()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/edit.png"));
	} else if (doc.isLocked()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/lock.gif"));
	} else {
		table.setHTML(row, 0, "&nbsp;");
	}

	// Subscribed is a special case, must add icon with others
	if (doc.isSubscribed()) {
		table.setHTML(row, 0, table.getHTML(row, 0) + Util.imageItemHTML("img/icon/subscribed.gif"));
	}

	if (doc.isHasNotes()) {
		table.setHTML(row, 0, table.getHTML(row, 0) + Util.imageItemHTML("img/icon/note.gif"));
	}

	table.setHTML(row, 1, Util.mimeImageHTML(doc.getMimeType()));
	Anchor anchor = new Anchor();
	anchor.setHTML(doc.getName());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			String docPath = doc.getPath();
			String path = docPath.substring(0, docPath.lastIndexOf("/"));
			GeneralComunicator.openPath(path, doc.getPath());
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, Util.formatSize(doc.getActualVersion().getSize()));

	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}